Toplevel::frameId() becomes virtual

The frameId only makes sense for a Client, in case of Unmanaged the
same window id is used as for the window() handle. Client creates the
frame and destroys it.

Given that it makes sense to let Client manage the frame properly.
The ::frameId() is therefore virtual and as base implementation it
returns the client id. Client reimplements it and returns the proper
frame id.

Method is also implemented in Deleted as it used to be passed to
deleted.
This commit is contained in:
Martin Gräßlin 2013-09-10 08:13:33 +02:00
parent 4e5a44e23c
commit cfd93246b3
8 changed files with 30 additions and 17 deletions

View file

@ -88,6 +88,7 @@ Client::Client()
: Toplevel() : Toplevel()
, m_client() , m_client()
, m_wrapper() , m_wrapper()
, m_frame()
, decoration(NULL) , decoration(NULL)
, bridge(new Bridge(this)) , bridge(new Bridge(this))
, m_activityUpdatesBlocked(false) , m_activityUpdatesBlocked(false)
@ -299,7 +300,7 @@ void Client::releaseWindow(bool on_shutdown)
m_client.unmap(); m_client.unmap();
m_client.reset(); m_client.reset();
m_wrapper.reset(); m_wrapper.reset();
XDestroyWindow(display(), frameId()); m_frame.reset();
//frame = None; //frame = None;
--block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry --block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry
if (!on_shutdown) { if (!on_shutdown) {
@ -340,7 +341,7 @@ void Client::destroyClient()
workspace()->removeClient(this); workspace()->removeClient(this);
m_client.reset(); // invalidate m_client.reset(); // invalidate
m_wrapper.reset(); m_wrapper.reset();
XDestroyWindow(display(), frameId()); m_frame.reset();
//frame = None; //frame = None;
--block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry --block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry
disownDataPassedToDeleted(); disownDataPassedToDeleted();
@ -2500,6 +2501,11 @@ void Client::cancelFocusOutTimer()
} }
} }
xcb_window_t Client::frameId() const
{
return m_frame;
}
} // namespace } // namespace
#include "client.moc" #include "client.moc"

View file

@ -270,6 +270,7 @@ public:
xcb_window_t wrapperId() const; xcb_window_t wrapperId() const;
xcb_window_t decorationId() const; xcb_window_t decorationId() const;
xcb_window_t inputId() const { return m_decoInputExtent; } xcb_window_t inputId() const { return m_decoInputExtent; }
virtual xcb_window_t frameId() const override;
const Client* transientFor() const; const Client* transientFor() const;
Client* transientFor(); Client* transientFor();
@ -831,6 +832,7 @@ private:
Xcb::Window m_client; Xcb::Window m_client;
Xcb::Window m_wrapper; Xcb::Window m_wrapper;
Xcb::Window m_frame;
KDecoration* decoration; KDecoration* decoration;
Bridge* bridge; Bridge* bridge;
int desk; int desk;

View file

@ -34,6 +34,7 @@ namespace KWin
Deleted::Deleted() Deleted::Deleted()
: Toplevel() : Toplevel()
, delete_refcount(1) , delete_refcount(1)
, m_frame(XCB_WINDOW_NONE)
, no_border(true) , no_border(true)
, padding_left(0) , padding_left(0)
, padding_top(0) , padding_top(0)
@ -80,6 +81,7 @@ void Deleted::copyToDeleted(Toplevel* c)
contentsRect = QRect(c->clientPos(), c->clientSize()); contentsRect = QRect(c->clientPos(), c->clientSize());
transparent_rect = c->transparentRect(); transparent_rect = c->transparentRect();
m_layer = c->layer(); m_layer = c->layer();
m_frame = c->frameId();
if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info)) if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info))
cinfo->disable(); cinfo->disable();
Client* client = dynamic_cast<Client*>(c); Client* client = dynamic_cast<Client*>(c);
@ -185,6 +187,11 @@ void Deleted::mainClientClosed(Toplevel *client)
m_mainClients.removeAll(static_cast<Client*>(client)); m_mainClients.removeAll(static_cast<Client*>(client));
} }
xcb_window_t Deleted::frameId() const
{
return m_frame;
}
} // namespace } // namespace
#include "deleted.moc" #include "deleted.moc"

View file

@ -45,6 +45,7 @@ public:
virtual QSize clientSize() const; virtual QSize clientSize() const;
virtual QRect transparentRect() const; virtual QRect transparentRect() const;
virtual bool isDeleted() const; virtual bool isDeleted() const;
virtual xcb_window_t frameId() const override;
bool noBorder() const { bool noBorder() const {
return no_border; return no_border;
} }
@ -84,6 +85,7 @@ private:
QStringList activityList; QStringList activityList;
QRect contentsRect; // for clientPos()/clientSize() QRect contentsRect; // for clientPos()/clientSize()
QRect transparent_rect; QRect transparent_rect;
xcb_window_t m_frame;
bool no_border; bool no_border;
QRect decoration_left; QRect decoration_left;

View file

@ -677,8 +677,9 @@ void Client::embedClient(xcb_window_t w, const XWindowAttributes& attr)
xcb_window_t frame = xcb_generate_id(conn); xcb_window_t frame = xcb_generate_id(conn);
xcb_create_window(conn, attr.depth, frame, rootWindow(), 0, 0, 1, 1, 0, xcb_create_window(conn, attr.depth, frame, rootWindow(), 0, 0, 1, 1, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT, visualid, cw_mask, cw_values); XCB_WINDOW_CLASS_INPUT_OUTPUT, visualid, cw_mask, cw_values);
m_frame.reset(frame);
setWindowHandles(m_client, frame); setWindowHandles(m_client);
// Create the wrapper window // Create the wrapper window
xcb_window_t wrapperId = xcb_generate_id(conn); xcb_window_t wrapperId = xcb_generate_id(conn);

View file

@ -42,7 +42,6 @@ Toplevel::Toplevel()
, ready_for_painting(true) , ready_for_painting(true)
, m_isDamaged(false) , m_isDamaged(false)
, m_client() , m_client()
, frame(None)
, damage_handle(None) , damage_handle(None)
, is_shape(false) , is_shape(false)
, effect_window(NULL) , effect_window(NULL)
@ -111,7 +110,6 @@ void Toplevel::copyToDeleted(Toplevel* c)
bit_depth = c->bit_depth; bit_depth = c->bit_depth;
info = c->info; info = c->info;
m_client.reset(c->m_client, false); m_client.reset(c->m_client, false);
frame = c->frame;
ready_for_painting = c->ready_for_painting; ready_for_painting = c->ready_for_painting;
damage_handle = None; damage_handle = None;
damage_region = c->damage_region; damage_region = c->damage_region;
@ -461,6 +459,11 @@ pid_t Toplevel::pid() const
return info->pid(); return info->pid();
} }
xcb_window_t Toplevel::frameId() const
{
return m_client;
}
} // namespace } // namespace
#include "toplevel.moc" #include "toplevel.moc"

View file

@ -166,7 +166,7 @@ class Toplevel
Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged) Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged)
public: public:
explicit Toplevel(); explicit Toplevel();
Window frameId() const; virtual xcb_window_t frameId() const;
xcb_window_t window() const; xcb_window_t window() const;
QRect geometry() const; QRect geometry() const;
QSize size() const; QSize size() const;
@ -347,7 +347,7 @@ protected Q_SLOTS:
protected: protected:
virtual ~Toplevel(); virtual ~Toplevel();
void setWindowHandles(xcb_window_t client, xcb_window_t frame); void setWindowHandles(xcb_window_t client);
void detectShape(Window id); void detectShape(Window id);
virtual void propertyNotifyEvent(xcb_property_notify_event_t *e); virtual void propertyNotifyEvent(xcb_property_notify_event_t *e);
virtual void damageNotifyEvent(); virtual void damageNotifyEvent();
@ -391,7 +391,6 @@ private:
static xcb_window_t staticWmClientLeader(xcb_window_t); static xcb_window_t staticWmClientLeader(xcb_window_t);
// when adding new data members, check also copyToDeleted() // when adding new data members, check also copyToDeleted()
Xcb::Window m_client; Xcb::Window m_client;
Window frame;
xcb_damage_damage_t damage_handle; xcb_damage_damage_t damage_handle;
QRegion damage_region; // damage is really damaged window (XDamage) and texture needs QRegion damage_region; // damage is really damaged window (XDamage) and texture needs
bool is_shape; bool is_shape;
@ -415,17 +414,10 @@ inline xcb_window_t Toplevel::window() const
return m_client; return m_client;
} }
inline Window Toplevel::frameId() const inline void Toplevel::setWindowHandles(xcb_window_t w)
{
return frame;
}
inline void Toplevel::setWindowHandles(xcb_window_t w, xcb_window_t f)
{ {
assert(!m_client.isValid() && w != XCB_WINDOW_NONE); assert(!m_client.isValid() && w != XCB_WINDOW_NONE);
m_client.reset(w, false); m_client.reset(w, false);
assert(frame == None && f != None);
frame = f;
} }
inline QRect Toplevel::geometry() const inline QRect Toplevel::geometry() const

View file

@ -57,7 +57,7 @@ bool Unmanaged::track(Window w)
ungrabXServer(); ungrabXServer();
return false; return false;
} }
setWindowHandles(w, w); // the window is also the frame setWindowHandles(w); // the window is also the frame
Xcb::selectInput(w, attr.your_event_mask | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE); Xcb::selectInput(w, attr.your_event_mask | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE);
geom = QRect(attr.x, attr.y, attr.width, attr.height); geom = QRect(attr.x, attr.y, attr.width, attr.height);
checkScreen(); checkScreen();