From b4d2129a3f9ff9d867bc1f2e0cbe67dfb0b2f2f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 2 May 2013 18:43:49 +0200 Subject: [PATCH] Port Client::client to XCB Unfortunately the Xcb::Window wrapper cannot be used for the client window as the client should not be destroyed by KWin. All the API calls except XSelectInput are changed to xcb and the name is adjusted to m_client to follow the naming scheme. --- client.cpp | 35 ++++++++++++++++++----------------- client.h | 2 +- events.cpp | 2 +- manage.cpp | 20 ++++++++++---------- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/client.cpp b/client.cpp index 1a1e6e0fc6..5e2436650e 100644 --- a/client.cpp +++ b/client.cpp @@ -89,7 +89,7 @@ bool Client::s_haveResizeEffect = false; */ Client::Client() : Toplevel() - , client(None) + , m_client(XCB_WINDOW_NONE) , m_wrapper() , decoration(NULL) , bridge(new Bridge(this)) @@ -232,7 +232,7 @@ Client::~Client() XSyncDestroyAlarm(display(), syncRequest.alarm); #endif assert(!moveResizeMode); - assert(client == None); + assert(m_client == XCB_WINDOW_NONE); assert(m_wrapper == XCB_WINDOW_NONE); //assert( frameId() == None ); assert(decoration == NULL); @@ -289,20 +289,21 @@ void Client::releaseWindow(bool on_shutdown) info->setState(0, info->state()); // Reset all state flags } else untab(); - XDeleteProperty(display(), client, atoms->kde_net_wm_user_creation_time); - XDeleteProperty(display(), client, atoms->net_frame_extents); - XDeleteProperty(display(), client, atoms->kde_net_wm_frame_strut); - XReparentWindow(display(), client, rootWindow(), x(), y()); - XRemoveFromSaveSet(display(), client); - XSelectInput(display(), client, NoEventMask); + xcb_connection_t *c = connection(); + xcb_delete_property(c, m_client, atoms->kde_net_wm_user_creation_time); + xcb_delete_property(c, m_client, atoms->net_frame_extents); + xcb_delete_property(c, m_client, atoms->kde_net_wm_frame_strut); + xcb_reparent_window(c, m_client, rootWindow(), x(), y()); + xcb_change_save_set(c, XCB_SET_MODE_DELETE, m_client); + XSelectInput(display(), m_client, NoEventMask); if (on_shutdown) // Map the window, so it can be found after another WM is started - XMapWindow(display(), client); + xcb_map_window(connection(), m_client); // TODO: Preserve minimized, shaded etc. state? else // Make sure it's not mapped if the app unmapped it (#65279). The app // may do map+unmap before we initially map the window by calling rawShow() from manage(). - XUnmapWindow(display(), client); - client = None; + xcb_unmap_window(connection(), m_client); + m_client = XCB_WINDOW_NONE; m_wrapper.reset(); XDestroyWindow(display(), frameId()); //frame = None; @@ -343,7 +344,7 @@ void Client::destroyClient() destroyDecoration(); cleanGrouping(); workspace()->removeClient(this); - client = None; // invalidate + m_client = XCB_WINDOW_NONE; // invalidate m_wrapper.reset(); XDestroyWindow(display(), frameId()); //frame = None; @@ -981,7 +982,7 @@ void Client::setShade(ShadeMode mode) s.setHeight(border_top + border_bottom); XSelectInput(display(), m_wrapper, ClientWinMask); // Avoid getting UnmapNotify m_wrapper.unmap(); - XUnmapWindow(display(), client); + xcb_unmap_window(connection(), m_client); XSelectInput(display(), m_wrapper, ClientWinMask | SubstructureNotifyMask); exportMappingState(IconicState); plainResize(s); @@ -1123,7 +1124,7 @@ void Client::resetShowingDesktop(bool keep_hidden) */ void Client::exportMappingState(int s) { - assert(client != None); + assert(m_client != XCB_WINDOW_NONE); assert(!deleting || s == WithdrawnState); if (s == WithdrawnState) { XDeleteProperty(display(), window(), atoms->wm_state); @@ -1207,7 +1208,7 @@ void Client::map() XMapWindow(display(), frameId()); if (!isShade()) { m_wrapper.map(); - XMapWindow(display(), client); + xcb_map_window(connection(), m_client); m_decoInputExtent.map(); exportMappingState(NormalState); } else @@ -1228,7 +1229,7 @@ void Client::unmap() XSelectInput(display(), m_wrapper, ClientWinMask); // Avoid getting UnmapNotify XUnmapWindow(display(), frameId()); m_wrapper.unmap(); - XUnmapWindow(display(), client); + xcb_unmap_window(connection(), m_client); m_decoInputExtent.unmap(); XSelectInput(display(), m_wrapper, ClientWinMask | SubstructureNotifyMask); if (decoration != NULL) @@ -1990,7 +1991,7 @@ void Client::getWMHints() void Client::getMotifHints() { bool mgot_noborder, mnoborder, mresize, mmove, mminimize, mmaximize, mclose; - Motif::readFlags(client, mgot_noborder, mnoborder, mresize, mmove, mminimize, mmaximize, mclose); + Motif::readFlags(m_client, mgot_noborder, mnoborder, mresize, mmove, mminimize, mmaximize, mclose); if (mgot_noborder && motif_noborder != mnoborder) { motif_noborder = mnoborder; // If we just got a hint telling us to hide decorations, we do so. diff --git a/client.h b/client.h index d0c00ef18e..76b810ff04 100644 --- a/client.h +++ b/client.h @@ -832,7 +832,7 @@ private: bool tabTo(Client *other, bool behind, bool activate); - Window client; + xcb_window_t m_client; Xcb::Window m_wrapper; KDecoration* decoration; Bridge* bridge; diff --git a/events.cpp b/events.cpp index 7b41213ac9..2b789f1a4c 100644 --- a/events.cpp +++ b/events.cpp @@ -589,7 +589,7 @@ void Client::unmapNotifyEvent(XUnmapEvent* e) // check whether this is result of an XReparentWindow - client then won't be parented by wrapper // in this case do not release the client (causes reparent to root, removal from saveSet and what not) // but just destroy the client - Xcb::Tree tree(client); + Xcb::Tree tree(m_client); xcb_window_t daddy = tree.parent(); if (daddy == m_wrapper) { releaseWindow(); // unmapped from a regular client state diff --git a/manage.cpp b/manage.cpp index f2e0838114..1c60629481 100644 --- a/manage.cpp +++ b/manage.cpp @@ -100,7 +100,7 @@ bool Client::manage(Window w, bool isMapped) NET::WM2FrameOverlap | 0; - info = new WinInfo(this, display(), client, rootWindow(), properties, 2); + info = new WinInfo(this, display(), m_client, rootWindow(), properties, 2); cmap = attr.colormap; @@ -628,10 +628,10 @@ bool Client::manage(Window w, bool isMapped) // Called only from manage() void Client::embedClient(Window w, const XWindowAttributes& attr) { - assert(client == None); + assert(m_client == XCB_WINDOW_NONE); assert(frameId() == None); assert(m_wrapper == XCB_WINDOW_NONE); - client = w; + m_client = w; const xcb_visualid_t visualid = XVisualIDFromVisual(attr.visual); const uint32_t zero_value = 0; @@ -639,11 +639,11 @@ void Client::embedClient(Window w, const XWindowAttributes& attr) xcb_connection_t *conn = connection(); // We don't want the window to be destroyed when we quit - xcb_change_save_set(conn, XCB_SET_MODE_INSERT, client); + xcb_change_save_set(conn, XCB_SET_MODE_INSERT, m_client); - xcb_change_window_attributes(conn, client, XCB_CW_EVENT_MASK, &zero_value); - xcb_unmap_window(conn, client); - xcb_configure_window(conn, client, XCB_CONFIG_WINDOW_BORDER_WIDTH, &zero_value); + xcb_change_window_attributes(conn, m_client, XCB_CW_EVENT_MASK, &zero_value); + xcb_unmap_window(conn, m_client); + xcb_configure_window(conn, m_client, XCB_CONFIG_WINDOW_BORDER_WIDTH, &zero_value); // Note: These values must match the order in the xcb_cw_t enum const uint32_t cw_values[] = { @@ -678,7 +678,7 @@ void Client::embedClient(Window w, const XWindowAttributes& attr) xcb_create_window(conn, attr.depth, frame, rootWindow(), 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, visualid, cw_mask, cw_values); - setWindowHandles(client, frame); + setWindowHandles(m_client, frame); // Create the wrapper window xcb_window_t wrapperId = xcb_generate_id(conn); @@ -686,14 +686,14 @@ void Client::embedClient(Window w, const XWindowAttributes& attr) XCB_WINDOW_CLASS_INPUT_OUTPUT, visualid, cw_mask, cw_values); m_wrapper.reset(wrapperId); - xcb_reparent_window(conn, client, m_wrapper, 0, 0); + xcb_reparent_window(conn, m_client, m_wrapper, 0, 0); // We could specify the event masks when we create the windows, but the original // Xlib code didn't. Let's preserve that behavior here for now so we don't end up // receiving any unexpected events from the wrapper creation or the reparenting. xcb_change_window_attributes(conn, frame, XCB_CW_EVENT_MASK, &frame_event_mask); xcb_change_window_attributes(conn, m_wrapper, XCB_CW_EVENT_MASK, &wrapper_event_mask); - xcb_change_window_attributes(conn, client, XCB_CW_EVENT_MASK, &client_event_mask); + xcb_change_window_attributes(conn, m_client, XCB_CW_EVENT_MASK, &client_event_mask); updateMouseGrab(); }