From 2320b71cb7e5577d4aed349d809d25e317d54ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 30 Apr 2013 13:06:46 +0200 Subject: [PATCH] Port Workspace's null focus window to xcb Adding wrappers to Xcb::Window for setInputFocus. REVIEW: 110246 --- workspace.cpp | 11 ++++------- workspace.h | 7 ++++++- xcbutils.h | 13 +++++++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/workspace.cpp b/workspace.cpp index a9513d6a9c..ffaddd6035 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -240,11 +240,9 @@ void Workspace::init() supportWindow = new QWidget(NULL, Qt::X11BypassWindowManagerHint); XLowerWindow(display(), supportWindow->winId()); // See usage in layers.cpp - XSetWindowAttributes attr; - attr.override_redirect = 1; - null_focus_window = XCreateWindow(display(), rootWindow(), -1, -1, 1, 1, 0, CopyFromParent, - InputOnly, CopyFromParent, CWOverrideRedirect, &attr); - XMapWindow(display(), null_focus_window); + const uint32_t nullFocusValues[] = {true}; + m_nullFocus.reset(new Xcb::Window(QRect(-1, -1, 1, 1), XCB_WINDOW_CLASS_INPUT_ONLY, XCB_CW_OVERRIDE_REDIRECT, nullFocusValues)); + m_nullFocus->map(); unsigned long protocols[5] = { NET::Supported | @@ -511,7 +509,6 @@ Workspace::~Workspace() delete client_keys_dialog; foreach (SessionInfo * s, session) delete s; - XDestroyWindow(display(), null_focus_window); // TODO: ungrabXServer(); @@ -1378,7 +1375,7 @@ bool Workspace::checkStartupNotification(xcb_window_t w, KStartupInfoId &id, KSt */ void Workspace::focusToNull() { - XSetInputFocus(display(), null_focus_window, RevertToPointerRoot, xTime()); + m_nullFocus->focus(); } void Workspace::setShowingDesktop(bool showing) diff --git a/workspace.h b/workspace.h index 39af1ddc6e..076aa0b30e 100644 --- a/workspace.h +++ b/workspace.h @@ -46,6 +46,11 @@ class KStartupInfoData; namespace KWin { +namespace Xcb +{ +class Window; +} + class Client; class KillWindow; class RootInfo; @@ -556,7 +561,7 @@ private: int set_active_client_recursion; int block_stacking_updates; // When > 0, stacking updates are temporarily disabled bool blocked_propagating_new_clients; // Propagate also new clients after enabling stacking updates? - Window null_focus_window; + QScopedPointer m_nullFocus; bool forced_global_mouse_grab; friend class StackingUpdatesBlocker; diff --git a/xcbutils.h b/xcbutils.h index 51b9357d73..51b8f5d421 100644 --- a/xcbutils.h +++ b/xcbutils.h @@ -38,6 +38,7 @@ typedef xcb_window_t WindowId; // forward declaration of methods static void defineCursor(xcb_window_t window, xcb_cursor_t cursor); +static void setInputFocus(xcb_window_t window, uint8_t revertTo = XCB_INPUT_FOCUS_POINTER_ROOT, xcb_timestamp_t time = xTime()); template