diff --git a/src/focus.c b/src/focus.c index 6c78f06f..140df003 100644 --- a/src/focus.c +++ b/src/focus.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2004-2008 Kim Woelders + * Copyright (C) 2004-2009 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -517,6 +517,15 @@ FocusNewDesk(void) XUngrabKeyboard(disp, CurrentTime); } +void +FocusCheckScreen(void) +{ + if (EQueryPointer(NULL, NULL, NULL, NULL, NULL)) + return; /* On screen */ + + FocusToEWin(NULL, FOCUS_DESK_LEAVE); +} + static void FocusInit(void) { diff --git a/src/focus.h b/src/focus.h index e91711ed..48280b9d 100644 --- a/src/focus.h +++ b/src/focus.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors + * Copyright (C) 2004-2009 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -48,6 +49,7 @@ void FocusHandleChange(EWin * ewin, XEvent * ev); void FocusHandleClick(EWin * ewin, Win win); void FocusNewDeskBegin(void); void FocusNewDesk(void); +void FocusCheckScreen(void); void ClickGrabsUpdate(void); diff --git a/src/ipc.c b/src/ipc.c index 41650d39..306f8786 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -29,6 +29,7 @@ #include "eobj.h" #include "ewins.h" #include "ewin-ops.h" +#include "focus.h" #include "grabs.h" #include "hints.h" /* FIXME - Should not be here */ #include "screen.h" @@ -1259,8 +1260,15 @@ IPC_Warp(const char *params) x = (Dpy.screen + 1) % ScreenCount(disp); sscanf(params, "%*s %i", &x); if (x >= 0 && x < ScreenCount(disp)) - EXWarpPointer(RootWindow(disp, x), DisplayWidth(disp, x) / 2, - DisplayHeight(disp, x) / 2); + { + EXWarpPointer(RootWindow(disp, x), DisplayWidth(disp, x) / 2, + DisplayHeight(disp, x) / 2); + /* IIRC warping to a different screen once did cause + * LeaveNotify's on the current root window. This does not + * happen in xorg 1.5.3 (and probably other versions). + * So, check and focus out if left. */ + FocusCheckScreen(); + } } else {