From e5d090ff4d4f2f25a70a5a417c4ee1cf3b89039c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 2 Feb 2004 14:17:01 +0000 Subject: [PATCH] When the X focus gets set to None, reset it to the null focus window, so that keyboard shortcuts still work. svn path=/trunk/kdebase/kwin/; revision=284489 --- events.cpp | 7 +++++++ workspace.cpp | 29 ++++++++++++----------------- workspace.h | 1 + 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/events.cpp b/events.cpp index 51281e0be7..d4d616904f 100644 --- a/events.cpp +++ b/events.cpp @@ -404,6 +404,13 @@ bool Workspace::workspaceEvent( XEvent * e ) return FALSE; break; case FocusIn: + if( e->xfocus.window == rootWin() && e->xfocus.detail == NotifyDetailNone ) + { + kdWarning( 1212 ) << "X focus set to None, reseting focus" << endl; + XSetInputFocus(qt_xdisplay(), null_focus_window, RevertToPointerRoot, CurrentTime ); + // focusToNull() uses qt_x_time, which is old now (FocusIn has no timestamp) + } + // fall through case FocusOut: return true; // always eat these, they would tell Qt that KWin is the active app default: diff --git a/workspace.cpp b/workspace.cpp index 158ac78996..6d3639fb5a 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -49,8 +49,6 @@ namespace KWinInternal extern int screen_number; -static Window null_focus_window = 0; - Workspace *Workspace::_self = 0; // Rikkus: This class is too complex. It needs splitting further. @@ -136,7 +134,8 @@ Workspace::Workspace( bool restore ) PropertyChangeMask | ColormapChangeMask | SubstructureRedirectMask | - SubstructureNotifyMask + SubstructureNotifyMask | + FocusChangeMask // for NotifyDetailNone ); Shape::init(); @@ -175,6 +174,12 @@ void Workspace::init() supportWindow = new QWidget; XLowerWindow( qt_xdisplay(), supportWindow->winId()); // see usage in layers.cpp + XSetWindowAttributes attr; + attr.override_redirect = 1; + null_focus_window = XCreateWindow( qt_xdisplay(), qt_xrootwin(), -1,-1, 1, 1, 0, CopyFromParent, + InputOnly, CopyFromParent, CWOverrideRedirect, &attr ); + XMapWindow(qt_xdisplay(), null_focus_window); + unsigned long protocols[ 5 ] = { NET::Supported | @@ -271,10 +276,6 @@ void Workspace::init() // now we know how many desktops we'll, thus, we initialise the positioning object initPositioning = new Placement(this); - unsigned int i, nwins; - Window root_return, parent_return, *wins; - XWindowAttributes attr; - connect(&reconfigureTimer, SIGNAL(timeout()), this, SLOT(slotReconfigure())); connect( &updateToolWindowsTimer, SIGNAL( timeout()), this, SLOT( slotUpdateToolWindows())); @@ -308,9 +309,12 @@ void Workspace::init() else lostTopMenuSelection(); + unsigned int i, nwins; + Window root_return, parent_return, *wins; XQueryTree(qt_xdisplay(), root, &root_return, &parent_return, &wins, &nwins); for (i = 0; i < nwins; i++) { + XWindowAttributes attr; XGetWindowAttributes(qt_xdisplay(), wins[i], &attr); if (attr.override_redirect ) continue; @@ -406,6 +410,7 @@ Workspace::~Workspace() delete topmenu_watcher; delete topmenu_selection; delete topmenu_space; + XDestroyWindow( qt_xdisplay(), null_focus_window ); // TODO ungrabXServer(); _self = 0; } @@ -1936,16 +1941,6 @@ bool Workspace::checkStartupNotification( const Client* c, KStartupInfoData& dat */ void Workspace::focusToNull() { - int mask; - XSetWindowAttributes attr; - if (null_focus_window == 0) - { - mask = CWOverrideRedirect; - attr.override_redirect = 1; - null_focus_window = XCreateWindow(qt_xdisplay(), qt_xrootwin(), -1,-1, 1, 1, 0, CopyFromParent, - InputOnly, CopyFromParent, mask, &attr); - XMapWindow(qt_xdisplay(), null_focus_window); - } XSetInputFocus(qt_xdisplay(), null_focus_window, RevertToPointerRoot, qt_x_time ); } diff --git a/workspace.h b/workspace.h index 153b54385f..197ae103a6 100644 --- a/workspace.h +++ b/workspace.h @@ -511,6 +511,7 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine 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; friend class StackingUpdatesBlocker; };