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
This commit is contained in:
Luboš Luňák 2004-02-02 14:17:01 +00:00
parent 8d00434917
commit e5d090ff4d
3 changed files with 20 additions and 17 deletions

View file

@ -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:

View file

@ -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 );
}

View file

@ -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;
};