From cfd93246b314df9a7dbfb55fc4900c75708d8caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 10 Sep 2013 08:13:33 +0200 Subject: [PATCH] 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. --- client.cpp | 10 ++++++++-- client.h | 2 ++ deleted.cpp | 7 +++++++ deleted.h | 2 ++ manage.cpp | 3 ++- toplevel.cpp | 7 +++++-- toplevel.h | 14 +++----------- unmanaged.cpp | 2 +- 8 files changed, 30 insertions(+), 17 deletions(-) diff --git a/client.cpp b/client.cpp index 9780674786..6e833e9cd6 100644 --- a/client.cpp +++ b/client.cpp @@ -88,6 +88,7 @@ Client::Client() : Toplevel() , m_client() , m_wrapper() + , m_frame() , decoration(NULL) , bridge(new Bridge(this)) , m_activityUpdatesBlocked(false) @@ -299,7 +300,7 @@ void Client::releaseWindow(bool on_shutdown) m_client.unmap(); m_client.reset(); m_wrapper.reset(); - XDestroyWindow(display(), frameId()); + m_frame.reset(); //frame = None; --block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry if (!on_shutdown) { @@ -340,7 +341,7 @@ void Client::destroyClient() workspace()->removeClient(this); m_client.reset(); // invalidate m_wrapper.reset(); - XDestroyWindow(display(), frameId()); + m_frame.reset(); //frame = None; --block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry disownDataPassedToDeleted(); @@ -2500,6 +2501,11 @@ void Client::cancelFocusOutTimer() } } +xcb_window_t Client::frameId() const +{ + return m_frame; +} + } // namespace #include "client.moc" diff --git a/client.h b/client.h index 5b94a2d35d..a8076a16c6 100644 --- a/client.h +++ b/client.h @@ -270,6 +270,7 @@ public: xcb_window_t wrapperId() const; xcb_window_t decorationId() const; xcb_window_t inputId() const { return m_decoInputExtent; } + virtual xcb_window_t frameId() const override; const Client* transientFor() const; Client* transientFor(); @@ -831,6 +832,7 @@ private: Xcb::Window m_client; Xcb::Window m_wrapper; + Xcb::Window m_frame; KDecoration* decoration; Bridge* bridge; int desk; diff --git a/deleted.cpp b/deleted.cpp index 1230f4ee2d..57e8db85e4 100644 --- a/deleted.cpp +++ b/deleted.cpp @@ -34,6 +34,7 @@ namespace KWin Deleted::Deleted() : Toplevel() , delete_refcount(1) + , m_frame(XCB_WINDOW_NONE) , no_border(true) , padding_left(0) , padding_top(0) @@ -80,6 +81,7 @@ void Deleted::copyToDeleted(Toplevel* c) contentsRect = QRect(c->clientPos(), c->clientSize()); transparent_rect = c->transparentRect(); m_layer = c->layer(); + m_frame = c->frameId(); if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info)) cinfo->disable(); Client* client = dynamic_cast(c); @@ -185,6 +187,11 @@ void Deleted::mainClientClosed(Toplevel *client) m_mainClients.removeAll(static_cast(client)); } +xcb_window_t Deleted::frameId() const +{ + return m_frame; +} + } // namespace #include "deleted.moc" diff --git a/deleted.h b/deleted.h index 79b93ac06e..acaebe8e6b 100644 --- a/deleted.h +++ b/deleted.h @@ -45,6 +45,7 @@ public: virtual QSize clientSize() const; virtual QRect transparentRect() const; virtual bool isDeleted() const; + virtual xcb_window_t frameId() const override; bool noBorder() const { return no_border; } @@ -84,6 +85,7 @@ private: QStringList activityList; QRect contentsRect; // for clientPos()/clientSize() QRect transparent_rect; + xcb_window_t m_frame; bool no_border; QRect decoration_left; diff --git a/manage.cpp b/manage.cpp index 187c82ecde..4bc9ca2b79 100644 --- a/manage.cpp +++ b/manage.cpp @@ -677,8 +677,9 @@ void Client::embedClient(xcb_window_t w, const XWindowAttributes& attr) xcb_window_t frame = xcb_generate_id(conn); xcb_create_window(conn, attr.depth, frame, rootWindow(), 0, 0, 1, 1, 0, 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 xcb_window_t wrapperId = xcb_generate_id(conn); diff --git a/toplevel.cpp b/toplevel.cpp index f3b9be045a..56ea2623a3 100644 --- a/toplevel.cpp +++ b/toplevel.cpp @@ -42,7 +42,6 @@ Toplevel::Toplevel() , ready_for_painting(true) , m_isDamaged(false) , m_client() - , frame(None) , damage_handle(None) , is_shape(false) , effect_window(NULL) @@ -111,7 +110,6 @@ void Toplevel::copyToDeleted(Toplevel* c) bit_depth = c->bit_depth; info = c->info; m_client.reset(c->m_client, false); - frame = c->frame; ready_for_painting = c->ready_for_painting; damage_handle = None; damage_region = c->damage_region; @@ -461,6 +459,11 @@ pid_t Toplevel::pid() const return info->pid(); } +xcb_window_t Toplevel::frameId() const +{ + return m_client; +} + } // namespace #include "toplevel.moc" diff --git a/toplevel.h b/toplevel.h index 8ac1a59c38..662800c636 100644 --- a/toplevel.h +++ b/toplevel.h @@ -166,7 +166,7 @@ class Toplevel Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged) public: explicit Toplevel(); - Window frameId() const; + virtual xcb_window_t frameId() const; xcb_window_t window() const; QRect geometry() const; QSize size() const; @@ -347,7 +347,7 @@ protected Q_SLOTS: protected: virtual ~Toplevel(); - void setWindowHandles(xcb_window_t client, xcb_window_t frame); + void setWindowHandles(xcb_window_t client); void detectShape(Window id); virtual void propertyNotifyEvent(xcb_property_notify_event_t *e); virtual void damageNotifyEvent(); @@ -391,7 +391,6 @@ private: static xcb_window_t staticWmClientLeader(xcb_window_t); // when adding new data members, check also copyToDeleted() Xcb::Window m_client; - Window frame; xcb_damage_damage_t damage_handle; QRegion damage_region; // damage is really damaged window (XDamage) and texture needs bool is_shape; @@ -415,17 +414,10 @@ inline xcb_window_t Toplevel::window() const return m_client; } -inline Window Toplevel::frameId() const -{ - return frame; -} - -inline void Toplevel::setWindowHandles(xcb_window_t w, xcb_window_t f) +inline void Toplevel::setWindowHandles(xcb_window_t w) { assert(!m_client.isValid() && w != XCB_WINDOW_NONE); m_client.reset(w, false); - assert(frame == None && f != None); - frame = f; } inline QRect Toplevel::geometry() const diff --git a/unmanaged.cpp b/unmanaged.cpp index 2c737d124b..e87cf5d32d 100644 --- a/unmanaged.cpp +++ b/unmanaged.cpp @@ -57,7 +57,7 @@ bool Unmanaged::track(Window w) ungrabXServer(); 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); geom = QRect(attr.x, attr.y, attr.width, attr.height); checkScreen();