summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Fourdan <fourdan.olivier@wanadoo.fr>2006-12-13 20:15:19 +0000
committerOlivier Fourdan <fourdan.olivier@wanadoo.fr>2006-12-13 20:15:19 +0000
commitfee375e8d77e045d8c2cc5e0be0738d8170e081b (patch)
tree591b25e67fdcf51cd81b904ed04973c98434b399
parent6927324d76f2b45ee11993f87b2d4892a0628d8a (diff)
downloadxfwm4-fee375e8d77e045d8c2cc5e0be0738d8170e081b.tar.gz
Use timestamp provided by NET_ACTIVE_WINDOW and NET_CURRENT_DESKTOP messages from EWMH version 1.3 and above, fix focus transition with NET_CURRENT_DESKTOP messages causing either flickering or wrong restacking on workspace switch (bug #2654), fix serious bug introduced with previous commit causing xfwm4 to quit on any selection MESSAGE notify.
(Old svn revision: 24096)
-rw-r--r--src/client.c30
-rw-r--r--src/display.c17
-rw-r--r--src/display.h2
-rw-r--r--src/events.c193
-rw-r--r--src/focus.c27
-rw-r--r--src/focus.h9
-rw-r--r--src/hints.c7
-rw-r--r--src/main.c3
-rw-r--r--src/screen.c14
-rw-r--r--src/screen.h2
-rw-r--r--src/stacking.c2
-rw-r--r--src/workspaces.c37
-rw-r--r--src/workspaces.h11
13 files changed, 219 insertions, 135 deletions
diff --git a/src/client.c b/src/client.c
index 38a000e9a..072593b95 100644
--- a/src/client.c
+++ b/src/client.c
@@ -1952,7 +1952,7 @@ clientFrame (DisplayInfo *display_info, Window w, gboolean recapture)
}
else
{
- clientFocusNew(c);
+ clientFocusNew(c, myDisplayGetCurrentTime (display_info));
grabbed = TRUE;
}
}
@@ -2123,7 +2123,7 @@ clientFrameAll (ScreenInfo *screen_info)
{
XFree (wins);
}
- clientFocusTop (screen_info, WIN_LAYER_NORMAL);
+ clientFocusTop (screen_info, WIN_LAYER_NORMAL, myDisplayGetCurrentTime (display_info));
xfwmWindowDelete (&shield);
myDisplayUngrabServer (display_info);
XSync (display_info->dpy, FALSE);
@@ -2352,7 +2352,7 @@ clientHideSingle (Client * c, gboolean change_state)
display_info = screen_info->display_info;
TRACE ("hiding client \"%s\" (0x%lx)", c->name, c->window);
- clientPassFocus(c->screen_info, c, c);
+ clientPassFocus(c->screen_info, c, c, myDisplayGetCurrentTime (display_info));
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE))
{
FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_VISIBLE);
@@ -2481,7 +2481,7 @@ clientToggleShowDesktop (ScreenInfo *screen_info)
clientHide (c, c->win_workspace, TRUE);
}
}
- clientFocusTop (screen_info, WIN_LAYER_DESKTOP);
+ clientFocusTop (screen_info, WIN_LAYER_DESKTOP, myDisplayGetCurrentTime (screen_info->display_info));
}
else
{
@@ -2494,7 +2494,7 @@ clientToggleShowDesktop (ScreenInfo *screen_info)
}
FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_WAS_SHOWN);
}
- clientFocusTop (screen_info, WIN_LAYER_NORMAL);
+ clientFocusTop (screen_info, WIN_LAYER_NORMAL, myDisplayGetCurrentTime (screen_info->display_info));
}
}
@@ -3534,14 +3534,14 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
if (edge & CLIENT_CONSTRAINED_TOP)
{
- if (workspaceMove (screen_info, -1, 0, c))
+ if (workspaceMove (screen_info, -1, 0, c, xevent->xkey.time))
{
c->y = maxy + maxh;
}
}
else if (edge & CLIENT_CONSTRAINED_BOTTOM)
{
- if (workspaceMove (screen_info, 1, 0, c))
+ if (workspaceMove (screen_info, 1, 0, c, xevent->xkey.time))
{
c->y = maxy + frameTop (c);
}
@@ -3549,14 +3549,14 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
if (edge & CLIENT_CONSTRAINED_LEFT)
{
- if (workspaceMove (screen_info, 0, -1, c))
+ if (workspaceMove (screen_info, 0, -1, c, xevent->xkey.time))
{
c->x = maxx + maxw - frameWidth (c) + frameRight (c);
}
}
else if (edge & CLIENT_CONSTRAINED_RIGHT)
{
- if (workspaceMove (screen_info, 0, 1, c))
+ if (workspaceMove (screen_info, 0, 1, c, xevent->xkey.time))
{
c->x = maxx + frameLeft (c);
}
@@ -3607,7 +3607,7 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
}
if (screen_info->current_ws != passdata->cancel_workspace)
{
- workspaceSwitch (screen_info, passdata->cancel_workspace, c, FALSE);
+ workspaceSwitch (screen_info, passdata->cancel_workspace, c, FALSE, xevent->xkey.time);
}
if (toggled_maximize)
{
@@ -3715,14 +3715,14 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
{
if (msx == 0)
{
- if (workspaceMove (screen_info, 0, -1, c))
+ if (workspaceMove (screen_info, 0, -1, c, xevent->xmotion.time))
{
rx = 4 * maxx / 5;
}
}
else
{
- if (workspaceMove (screen_info, 0, 1, c))
+ if (workspaceMove (screen_info, 0, 1, c, xevent->xmotion.time))
{
rx = -4 * maxx / 5;
}
@@ -3738,14 +3738,14 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
{
if (msy == 0)
{
- if (workspaceMove (screen_info, -1, 0, c))
+ if (workspaceMove (screen_info, -1, 0, c, xevent->xmotion.time))
{
ry = 4 * maxy / 5;
}
}
else
{
- if (workspaceMove (screen_info, 1, 0, c))
+ if (workspaceMove (screen_info, 1, 0, c, xevent->xmotion.time))
{
ry = -4 * maxy / 5;
}
@@ -4772,7 +4772,7 @@ clientCycle (Client * c, XEvent * ev)
if (workspace != screen_info->current_ws)
{
- workspaceSwitch (screen_info, workspace, c, FALSE);
+ workspaceSwitch (screen_info, workspace, c, FALSE, myDisplayGetCurrentTime (display_info));
}
if ((focused) && (passdata.c != focused))
diff --git a/src/display.c b/src/display.c
index 9144e160b..1634cf2ab 100644
--- a/src/display.c
+++ b/src/display.c
@@ -708,14 +708,31 @@ myDisplayGetCurrentTime (DisplayInfo *display)
{
g_return_val_if_fail (display != NULL, (Time) CurrentTime);
+ TRACE ("myDisplayGetCurrentTime gives timestamp=%u", display->current_time);
return (Time) display->current_time;
}
Time
+myDisplayGetTime (DisplayInfo * display, Time timestamp)
+{
+ Time time;
+
+ time = timestamp;
+ if (time == (Time) CurrentTime)
+ {
+ time = getXServerTime (display);
+ }
+
+ TRACE ("myDisplayGetTime gives timestamp=%u", time);
+ return (time);
+}
+
+Time
myDisplayGetLastUserTime (DisplayInfo *display)
{
g_return_val_if_fail (display != NULL, (Time) CurrentTime);
+ TRACE ("myDisplayGetLastUserTime gives timestamp=%u", display->last_user_time);
return (Time) display->last_user_time;
}
diff --git a/src/display.h b/src/display.h
index 3678932a6..4786d31a8 100644
--- a/src/display.h
+++ b/src/display.h
@@ -331,6 +331,8 @@ ScreenInfo *myDisplayGetDefaultScreen (DisplayInfo *);
Time myDisplayUpdateCurrentTime (DisplayInfo *,
XEvent *);
Time myDisplayGetCurrentTime (DisplayInfo *);
+Time myDisplayGetTime (DisplayInfo *,
+ Time);
Time myDisplayGetLastUserTime (DisplayInfo *);
void myDisplaySetLastUserTime (DisplayInfo *,
Time);
diff --git a/src/events.c b/src/events.c
index 4d3e4a209..032aaf924 100644
--- a/src/events.c
+++ b/src/events.c
@@ -259,7 +259,7 @@ typeOfClick (ScreenInfo *screen_info, Window w, XEvent * ev, gboolean allow_doub
static gboolean
check_button_time (XButtonEvent *ev)
{
- static Time last_button_time = (Time) 0;
+ static Time last_button_time = (Time) CurrentTime;
if (last_button_time > ev->time)
{
@@ -445,22 +445,22 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
clientToggleFullscreen (c);
break;
case KEY_MOVE_NEXT_WORKSPACE:
- workspaceSwitch (screen_info, screen_info->current_ws + 1, c, TRUE);
+ workspaceSwitch (screen_info, screen_info->current_ws + 1, c, TRUE, ev->time);
break;
case KEY_MOVE_PREV_WORKSPACE:
- workspaceSwitch (screen_info, screen_info->current_ws - 1, c, TRUE);
+ workspaceSwitch (screen_info, screen_info->current_ws - 1, c, TRUE, ev->time);
break;
case KEY_MOVE_UP_WORKSPACE:
- workspaceMove (screen_info, -1, 0, c);
+ workspaceMove (screen_info, -1, 0, c, ev->time);
break;
case KEY_MOVE_DOWN_WORKSPACE:
- workspaceMove (screen_info, 1, 0, c);
+ workspaceMove (screen_info, 1, 0, c, ev->time);
break;
case KEY_MOVE_LEFT_WORKSPACE:
- workspaceMove (screen_info, 0, -1, c);
+ workspaceMove (screen_info, 0, -1, c, ev->time);
break;
case KEY_MOVE_RIGHT_WORKSPACE:
- workspaceMove (screen_info, 0, 1, c);
+ workspaceMove (screen_info, 0, 1, c, ev->time);
break;
case KEY_MOVE_WORKSPACE_1:
case KEY_MOVE_WORKSPACE_2:
@@ -477,7 +477,7 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
if (key - KEY_MOVE_WORKSPACE_1 < screen_info->workspace_count)
{
clientRaise (c, None);
- workspaceSwitch (screen_info, key - KEY_MOVE_WORKSPACE_1, c, TRUE);
+ workspaceSwitch (screen_info, key - KEY_MOVE_WORKSPACE_1, c, TRUE, ev->time);
}
break;
case KEY_POPUP_MENU:
@@ -531,22 +531,22 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
switch (key)
{
case KEY_NEXT_WORKSPACE:
- workspaceSwitch (screen_info, screen_info->current_ws + 1, NULL, TRUE);
+ workspaceSwitch (screen_info, screen_info->current_ws + 1, NULL, TRUE, ev->time);
break;
case KEY_PREV_WORKSPACE:
- workspaceSwitch (screen_info, screen_info->current_ws - 1, NULL, TRUE);
+ workspaceSwitch (screen_info, screen_info->current_ws - 1, NULL, TRUE, ev->time);
break;
case KEY_UP_WORKSPACE:
- workspaceMove(screen_info, -1, 0, NULL);
+ workspaceMove(screen_info, -1, 0, NULL, ev->time);
break;
case KEY_DOWN_WORKSPACE:
- workspaceMove(screen_info, 1, 0, NULL);
+ workspaceMove(screen_info, 1, 0, NULL, ev->time);
break;
case KEY_LEFT_WORKSPACE:
- workspaceMove(screen_info, 0, -1, NULL);
+ workspaceMove(screen_info, 0, -1, NULL, ev->time);
break;
case KEY_RIGHT_WORKSPACE:
- workspaceMove(screen_info, 0, 1, NULL);
+ workspaceMove(screen_info, 0, 1, NULL, ev->time);
break;
case KEY_ADD_WORKSPACE:
workspaceSetCount (screen_info, screen_info->workspace_count + 1);
@@ -568,7 +568,7 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
case KEY_WORKSPACE_12:
if (key - KEY_WORKSPACE_1 < screen_info->workspace_count)
{
- workspaceSwitch (screen_info, key - KEY_WORKSPACE_1, NULL, TRUE);
+ workspaceSwitch (screen_info, key - KEY_WORKSPACE_1, NULL, TRUE, ev->time);
}
break;
case KEY_SHOW_DESKTOP:
@@ -768,7 +768,7 @@ titleButton (Client * c, int state, XButtonEvent * ev)
static void
rootScrollButton (DisplayInfo *display_info, XButtonEvent * ev)
{
- static Time lastscroll = (Time) 0;
+ static Time lastscroll = (Time) CurrentTime;
ScreenInfo *screen_info;
if ((ev->time - lastscroll) < 25) /* ms */
@@ -787,11 +787,11 @@ rootScrollButton (DisplayInfo *display_info, XButtonEvent * ev)
if (ev->button == Button4)
{
- workspaceSwitch (screen_info, screen_info->current_ws - 1, NULL, TRUE);
+ workspaceSwitch (screen_info, screen_info->current_ws - 1, NULL, TRUE, ev->time);
}
else if (ev->button == Button5)
{
- workspaceSwitch (screen_info, screen_info->current_ws + 1, NULL, TRUE);
+ workspaceSwitch (screen_info, screen_info->current_ws + 1, NULL, TRUE, ev->time);
}
}
@@ -1104,7 +1104,7 @@ handleDestroyNotify (DisplayInfo *display_info, XDestroyWindowEvent * ev)
if (c)
{
TRACE ("DestroyNotify for \"%s\" (0x%lx)", c->name, c->window);
- clientPassFocus (c->screen_info, c, c);
+ clientPassFocus (c->screen_info, c, c, myDisplayGetCurrentTime (display_info));
clientUnframe (c, FALSE);
}
}
@@ -1142,7 +1142,7 @@ handleMapRequest (DisplayInfo *display_info, XMapRequestEvent * ev)
if (FLAG_TEST (c->flags, CLIENT_FLAG_STICKY) ||
(c->win_workspace == screen_info->current_ws))
{
- clientFocusNew(c);
+ clientFocusNew(c, myDisplayGetCurrentTime (display_info));
}
}
else
@@ -1223,7 +1223,7 @@ handleUnmapNotify (DisplayInfo *display_info, XUnmapEvent * ev)
if ((ev->event == screen_info->xroot) && (ev->send_event))
{
TRACE ("ICCCM UnmapNotify for \"%s\"", c->name);
- clientPassFocus (screen_info, c, c);
+ clientPassFocus (screen_info, c, c, myDisplayGetCurrentTime (display_info));
clientUnframe (c, FALSE);
return;
}
@@ -1238,7 +1238,7 @@ handleUnmapNotify (DisplayInfo *display_info, XUnmapEvent * ev)
{
TRACE ("unmapping \"%s\" as ignore_unmap is %i",
c->name, c->ignore_unmap);
- clientPassFocus (screen_info, c, c);
+ clientPassFocus (screen_info, c, c, myDisplayGetCurrentTime (display_info));
clientUnframe (c, FALSE);
}
}
@@ -1418,6 +1418,7 @@ handleConfigureRequest (DisplayInfo *display_info, XConfigureRequestEvent * ev)
}
constrained = TRUE;
}
+
/*
Let's say that if the client performs a XRaiseWindow, we show the window if focus
stealing prevention is not activated, otherwise we just set the "demands attention"
@@ -1425,21 +1426,25 @@ handleConfigureRequest (DisplayInfo *display_info, XConfigureRequestEvent * ev)
*/
if ((ev->value_mask & CWStackMode) && (wc.stack_mode == Above) && (wc.sibling == None))
{
- ev->value_mask &= ~CWStackMode;
- if (c != clientGetLastRaise (screen_info))
+ Client *last_raised;
+
+ last_raised = clientGetLastRaise (screen_info);
+ if (last_raised && (c != last_raised))
{
if (screen_info->params->prevent_focus_stealing)
{
+ ev->value_mask &= ~CWStackMode;
TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
clientSetNetState (c);
}
else
{
- clientActivate (c, myDisplayGetCurrentTime(display_info));
+ clientActivate (c, getXServerTime (display_info));
}
}
}
+
clientConfigure (c, &wc, ev->value_mask, (constrained ? CFG_CONSTRAINED : 0) | CFG_REQUEST);
}
else
@@ -1452,7 +1457,7 @@ handleConfigureRequest (DisplayInfo *display_info, XConfigureRequestEvent * ev)
static void
handleEnterNotify (DisplayInfo *display_info, XCrossingEvent * ev)
{
- static Time lastresist = (Time) 0;
+ static Time lastresist = (Time) CurrentTime;
ScreenInfo *screen_info;
Client *c;
gboolean warp_pointer;
@@ -1567,14 +1572,14 @@ handleEnterNotify (DisplayInfo *display_info, XCrossingEvent * ev)
edge_scroll_x = 0;
if (msx == 0)
{
- if (workspaceMove (screen_info, 0, -1, NULL))
+ if (workspaceMove (screen_info, 0, -1, NULL, ev->time))
{
rx = 4 * maxx / 5;
}
}
else
{
- if (workspaceMove (screen_info, 0, 1, NULL))
+ if (workspaceMove (screen_info, 0, 1, NULL, ev->time))
{
rx = -4 * maxx / 5;
}
@@ -1586,14 +1591,14 @@ handleEnterNotify (DisplayInfo *display_info, XCrossingEvent * ev)
edge_scroll_y = 0;
if (msy == 0)
{
- if (workspaceMove (screen_info, -1, 0, NULL))
+ if (workspaceMove (screen_info, -1, 0, NULL, ev->time))
{
ry = 4 * maxy / 5;
}
}
else
{
- if (workspaceMove (screen_info, 1, 0, NULL))
+ if (workspaceMove (screen_info, 1, 0, NULL, ev->time))
{
ry = -4 * maxy / 5;
}
@@ -1673,14 +1678,11 @@ handleFocusIn (DisplayInfo *display_info, XFocusChangeEvent * ev)
clientSetFocus (screen_info, c, getXServerTime (display_info), FOCUS_FORCE);
return;
}
-
- if ((ev->mode == NotifyGrab) || (ev->mode == NotifyUngrab) ||
- (ev->detail > NotifyNonlinearVirtual))
+ if ((ev->mode == NotifyGrab) || (ev->mode == NotifyUngrab))
{
/* We're not interested in such notifications */
return;
}
-
c = myDisplayGetClientFromWindow (display_info, ev->window, ANY);
user_focus = clientGetUserFocus ();
current_focus = clientGetFocus ();
@@ -1688,7 +1690,7 @@ handleFocusIn (DisplayInfo *display_info, XFocusChangeEvent * ev)
TRACE ("FocusIn on window (0x%lx)", ev->window);
if ((c) && (c != current_focus))
{
- TRACE ("focus set to \"%s\" (0x%lx)", c->name, c->window);
+ TRACE ("Focus transfered to \"%s\" (0x%lx)", c->name, c->window);
screen_info = c->screen_info;
@@ -1706,14 +1708,15 @@ handleFocusIn (DisplayInfo *display_info, XFocusChangeEvent * ev)
*/
if (screen_info->params->prevent_focus_stealing)
{
- TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
- FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
- clientSetNetState (c);
+ TRACE ("Setting focus back to \"%s\" (0x%lx)", user_focus->name, user_focus->window);
clientSetFocus (user_focus->screen_info, user_focus, getXServerTime (display_info), NO_FOCUS_FLAG);
}
- else
+
+ if (current_focus)
{
- clientRaise (c, None);
+ TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
+ FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
+ clientSetNetState (c);
}
}
@@ -1758,6 +1761,14 @@ handleFocusOut (DisplayInfo *display_info, XFocusChangeEvent * ev)
(ev->detail == NotifyDetailNone) ?
"NotifyDetailNone" :
"(unknown)");
+
+ if ((ev->mode == NotifyGrab) || (ev->mode == NotifyUngrab) ||
+ (ev->detail == NotifyInferior) || (ev->detail > NotifyNonlinearVirtual))
+ {
+ /* We're not interested in such notifications */
+ return;
+ }
+
if ((ev->mode == NotifyNormal)
&& ((ev->detail == NotifyNonlinear)
|| (ev->detail == NotifyNonlinearVirtual)))
@@ -1807,7 +1818,7 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev)
}
else if (ev->atom == display_info->atoms[MOTIF_WM_HINTS])
{
- TRACE ("client \"%s\" (0x%lx) has received a motif_wm_hints notify", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a MOTIF_WM_HINTS notify", c->name, c->window);
clientGetMWMHints (c, TRUE);
}
else if (ev->atom == XA_WM_HINTS)
@@ -1838,14 +1849,14 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev)
}
else if (ev->atom == display_info->atoms[WM_PROTOCOLS])
{
- TRACE ("client \"%s\" (0x%lx) has received a wm_protocols notify", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a WM_PROTOCOLS notify", c->name, c->window);
clientGetWMProtocols (c);
}
else if (ev->atom == display_info->atoms[WM_TRANSIENT_FOR])
{
Window w;
- TRACE ("client \"%s\" (0x%lx) has received a wm_transient_for notify", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a WM_TRANSIENT_FOR notify", c->name, c->window);
getTransientFor (display_info, c->screen_info->xroot, c->window, &w);
if (clientCheckTransientWindow (c, w))
{
@@ -1873,19 +1884,19 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev)
}
else if (ev->atom == display_info->atoms[WIN_HINTS])
{
- TRACE ("client \"%s\" (0x%lx) has received a win_hints notify", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a WIN_HINTS notify", c->name, c->window);
getHint (display_info, c->window, WIN_HINTS, (long *) &c->win_hints);
}
else if (ev->atom == display_info->atoms[NET_WM_WINDOW_TYPE])
{
- TRACE ("client \"%s\" (0x%lx) has received a net_wm_window_type notify", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a NET_WM_WINDOW_TYPE notify", c->name, c->window);
clientGetNetWmType (c);
frameDraw (c, TRUE);
}
else if ((ev->atom == display_info->atoms[NET_WM_STRUT]) ||
(ev->atom == display_info->atoms[NET_WM_STRUT_PARTIAL]))
{
- TRACE ("client \"%s\" (0x%lx) has received a net_wm_strut notify", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a NET_WM_STRUT notify", c->name, c->window);
if (clientGetNetStruts (c) && FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE))
{
workspaceUpdateArea (c->screen_info);
@@ -1893,7 +1904,7 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev)
}
else if (ev->atom == display_info->atoms[WM_COLORMAP_WINDOWS])
{
- TRACE ("client \"%s\" (0x%lx) has received a wm_colormap_windows notify", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a WM_COLORMAP_WINDOWS notify", c->name, c->window);
clientUpdateColormaps (c);
if (c == clientGetFocus ())
{
@@ -1902,7 +1913,7 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev)
}
else if (ev->atom == display_info->atoms[NET_WM_USER_TIME])
{
- TRACE ("client \"%s\" (0x%lx) has received a net_wm_user_time notify", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a NET_WM_USER_TIME notify", c->name, c->window);
if (getNetWMUserTime (display_info, c->window, &c->user_time))
{
myDisplaySetLastUserTime (display_info, c->user_time);
@@ -1911,7 +1922,7 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev)
}
else if (ev->atom == display_info->atoms[NET_WM_WINDOW_OPACITY])
{
- TRACE ("client \"%s\" (0x%lx) has received a net_wm_opacity notify", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a NET_WM_OPACITY notify", c->name, c->window);
if (!getOpacity (display_info, c->window, &c->opacity))
{
c->opacity = NET_WM_OPAQUE;
@@ -1920,7 +1931,7 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev)
}
else if (ev->atom == display_info->atoms[NET_WM_WINDOW_OPACITY_LOCKED])
{
- TRACE ("client \"%s\" (0x%lx) has received a net_wm_opacity_locked notify", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a NET_WM_OPACITY_LOCKED notify", c->name, c->window);
c->opacity_locked = getOpacityLock (display_info, c->window);
}
else if ((screen_info->params->show_app_icon) &&
@@ -1963,7 +1974,7 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev)
gchar **names;
int items;
- TRACE ("root has received a net_desktop_names notify");
+ TRACE ("root has received a NET_DESKTOP_NAMES notify");
if (getUTF8StringList (display_info, screen_info->xroot, NET_DESKTOP_NAMES, &names, &items))
{
workspaceSetNames (screen_info, names, items);
@@ -1971,13 +1982,13 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev)
}
else if (ev->atom == display_info->atoms[GNOME_PANEL_DESKTOP_AREA])
{
- TRACE ("root has received a gnome_panel_desktop_area notify");
+ TRACE ("root has received a GNOME_PANEL_DESKTOP_AREA notify");
getGnomeDesktopMargins (display_info, screen_info->xroot, screen_info->gnome_margins);
workspaceUpdateArea (screen_info);
}
else if (ev->atom == display_info->atoms[NET_DESKTOP_LAYOUT])
{
- TRACE ("root has received a net_desktop_layout notify");
+ TRACE ("root has received a NET_DESKTOP_LAYOUT notify");
getDesktopLayout(display_info, screen_info->xroot, screen_info->workspace_count, &screen_info->desktop_layout);
placeSidewalks(screen_info, screen_info->params->wrap_workspaces);
}
@@ -2000,20 +2011,20 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
if ((ev->message_type == display_info->atoms[WM_CHANGE_STATE]) && (ev->format == 32) && (ev->data.l[0] == IconicState))
{
- TRACE ("client \"%s\" (0x%lx) has received a wm_change_state event", c->name, c->window);
- if (!FLAG_TEST (c->flags, CLIENT_FLAG_ICONIFIED) && CLIENT_CAN_HIDE_WINDOW (c))
+ TRACE ("client \"%s\" (0x%lx) has received a WM_CHANGE_STATE event", c->name, c->window);
+ if (!FLAG_TEST (c->flags, CLIENT_FLAG_ICONIFIED) && CLIENT_CAN_HIDE_WINDOW (c))
{
clientHide (c, c->win_workspace, TRUE);
}
}
else if ((ev->message_type == display_info->atoms[WIN_STATE]) && (ev->format == 32))
{
- TRACE ("client \"%s\" (0x%lx) has received a win_state event", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a WIN_STATE event", c->name, c->window);
clientUpdateWinState (c, ev);
}
else if ((ev->message_type == display_info->atoms[WIN_LAYER]) && (ev->format == 32))
{
- TRACE ("client \"%s\" (0x%lx) has received a win_layer event", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a WIN_LAYER event", c->name, c->window);
if ((ev->data.l[0] != c->win_layer) && !is_transient)
{
clientSetLayer (c, ev->data.l[0]);
@@ -2021,7 +2032,7 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
}
else if ((ev->message_type == display_info->atoms[WIN_WORKSPACE]) && (ev->format == 32))
{
- TRACE ("client \"%s\" (0x%lx) has received a win_workspace event", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a WIN_WORKSPACE event", c->name, c->window);
if ((ev->data.l[0] != c->win_workspace) && !is_transient)
{
clientSetWorkspace (c, ev->data.l[0], TRUE);
@@ -2029,7 +2040,7 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
}
else if ((ev->message_type == display_info->atoms[NET_WM_DESKTOP]) && (ev->format == 32))
{
- TRACE ("client \"%s\" (0x%lx) has received a net_wm_desktop event", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a NET_WM_DESKTOP event", c->name, c->window);
if (!is_transient)
{
if (ev->data.l[0] == ALL_WORKSPACES)
@@ -2056,30 +2067,33 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
}
else if ((ev->message_type == display_info->atoms[NET_CLOSE_WINDOW]) && (ev->format == 32))
{
- TRACE ("client \"%s\" (0x%lx) has received a net_close_window event", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a NET_CLOSE_WINDOW event", c->name, c->window);
clientClose (c);
}
else if ((ev->message_type == display_info->atoms[NET_WM_STATE]) && (ev->format == 32))
{
- TRACE ("client \"%s\" (0x%lx) has received a net_wm_state event", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a NET_WM_STATE event", c->name, c->window);
clientUpdateNetState (c, ev);
}
else if ((ev->message_type == display_info->atoms[NET_WM_MOVERESIZE]) && (ev->format == 32))
{
- TRACE ("client \"%s\" (0x%lx) has received a net_wm_moveresize event", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a NET_WM_MOVERESIZE event", c->name, c->window);
clientNetMoveResize (c, ev);
}
else if ((ev->message_type == display_info->atoms[NET_ACTIVE_WINDOW]) && (ev->format == 32))
{
- TRACE ("client \"%s\" (0x%lx) has received a net_active_window event", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a NET_ACTIVE_WINDOW event", c->name, c->window);
if (ev->data.l[0] != 0)
{
- Time current = myDisplayGetLastUserTime (screen_info->display_info);
+ Time current = myDisplayGetLastUserTime (display_info);
Time ev_time = (Time) ev->data.l[1];
TRACE ("Time of event received is %u, current XServer time is %u", (unsigned int) ev_time, (unsigned int) current);
- if ((screen_info->params->prevent_focus_stealing) && (ev_time != (Time) 0) && TIMESTAMP_IS_BEFORE(ev_time, current))
+ if ((screen_info->params->prevent_focus_stealing) &&
+ (ev_time != (Time) CurrentTime) &&
+ TIMESTAMP_IS_BEFORE(ev_time, current))
{
+ TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
clientSetNetState (c);
}
@@ -2090,12 +2104,12 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
}
else
{
- clientActivate (c, myDisplayGetCurrentTime (screen_info->display_info));
+ clientActivate (c, getXServerTime (display_info));
}
}
else if (ev->message_type == display_info->atoms[NET_REQUEST_FRAME_EXTENTS])
{
- TRACE ("client \"%s\" (0x%lx) has received a net_request_frame_extents event", c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) has received a NET_REQUEST_FRAME_EXTENTS event", c->name, c->window);
setNetFrameExtents (display_info, c->window, frameTop (c), frameLeft (c),
frameRight (c), frameBottom (c));
}
@@ -2111,10 +2125,16 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
if (((ev->message_type == display_info->atoms[WIN_WORKSPACE]) ||
(ev->message_type == display_info->atoms[NET_CURRENT_DESKTOP])) && (ev->format == 32))
{
- TRACE ("root has received a win_workspace or a net_current_desktop event %li", ev->data.l[0]);
- if ((ev->data.l[0] >= 0) && (ev->data.l[0] < screen_info->workspace_count) && (ev->data.l[0] != screen_info->current_ws))
+ TRACE ("root has received a win_workspace or a NET_CURRENT_DESKTOP event %li", ev->data.l[0]);
+ if ((ev->data.l[0] >= 0) && (ev->data.l[0] < screen_info->workspace_count) &&
+ (ev->data.l[0] != screen_info->current_ws))
{
- workspaceSwitch (screen_info, ev->data.l[0], NULL, TRUE);
+ Time ev_time = (Time) ev->data.l[1];
+ if (ev_time == (Time) CurrentTime)
+ {
+ ev_time = getXServerTime (display_info);
+ }
+ workspaceSwitch (screen_info, ev->data.l[0], NULL, TRUE, ev_time);
}
}
else if (((ev->message_type == display_info->atoms[WIN_WORKSPACE_COUNT]) ||
@@ -2127,23 +2147,16 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
getDesktopLayout(display_info, screen_info->xroot, screen_info->workspace_count, &screen_info->desktop_layout);
}
}
-#ifdef ENABLE_KDE_SYSTRAY_PROXY
- else if ((ev->message_type == display_info->atoms[MANAGER]) && (ev->data.l[1] == screen_info->net_system_tray_selection) && (ev->format == 32))
- {
- TRACE ("root has received a net_system_tray_manager event");
- screen_info->systray = getSystrayWindow (display_info, screen_info->net_system_tray_selection);
- }
-#endif
else if ((ev->message_type == display_info->atoms[NET_SHOWING_DESKTOP]) && (ev->format == 32))
{
- TRACE ("root has received a net_showing_desktop event");
+ TRACE ("root has received a NET_SHOWING_DESKTOP event");
screen_info->show_desktop = (ev->data.l[0] != 0);
clientToggleShowDesktop (screen_info);
setHint (display_info, screen_info->xroot, NET_SHOWING_DESKTOP, ev->data.l[0]);
}
else if (ev->message_type == display_info->atoms[NET_REQUEST_FRAME_EXTENTS])
{
- TRACE ("window (0x%lx) has received a net_request_frame_extents event", ev->window);
+ TRACE ("window (0x%lx) has received a NET_REQUEST_FRAME_EXTENTS event", ev->window);
/* Size estimate from the decoration extents */
setNetFrameExtents (display_info, ev->window,
frameDecorationTop (screen_info),
@@ -2151,10 +2164,26 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
frameDecorationRight (screen_info),
frameDecorationBottom (screen_info));
}
- else if (ev->message_type == display_info->atoms[MANAGER])
+ else if ((ev->message_type == display_info->atoms[MANAGER]) && (ev->format == 32))
{
- TRACE ("window (0x%lx) has received a manager event", ev->window);
- display_info->quit = TRUE;
+ Atom selection;
+
+ TRACE ("window (0x%lx) has received a MANAGER event", ev->window);
+ selection = (Atom) ev->data.l[1];
+
+#ifdef ENABLE_KDE_SYSTRAY_PROXY
+ if (selection == screen_info->net_system_tray_selection)
+ {
+ TRACE ("root has received a NET_SYSTEM_TRAY_MANAGER selection event");
+ screen_info->systray = getSystrayWindow (display_info, screen_info->net_system_tray_selection);
+ }
+ else
+#endif
+ if (myScreenCheckWMAtom (screen_info, selection))
+ {
+ TRACE ("root has received a WM_Sn selection event");
+ display_info->quit = TRUE;
+ }
}
else
{
diff --git a/src/focus.c b/src/focus.c
index 11832d07a..dd4412a76 100644
--- a/src/focus.c
+++ b/src/focus.c
@@ -103,7 +103,7 @@ clientGetTopMostFocusable (ScreenInfo *screen_info, int layer, Client * exclude)
}
void
-clientFocusTop (ScreenInfo *screen_info, int layer)
+clientFocusTop (ScreenInfo *screen_info, int layer, Time timestamp)
{
ClientPair top_client;
DisplayInfo *display_info;
@@ -113,19 +113,19 @@ clientFocusTop (ScreenInfo *screen_info, int layer)
if (top_client.prefered)
{
clientSetFocus (screen_info, top_client.prefered,
- myDisplayGetCurrentTime (screen_info->display_info),
+ timestamp,
NO_FOCUS_FLAG);
}
else
{
clientSetFocus (screen_info, top_client.highest,
- myDisplayGetCurrentTime (screen_info->display_info),
+ timestamp,
NO_FOCUS_FLAG);
}
}
gboolean
-clientFocusNew(Client * c)
+clientFocusNew(Client * c, Time timestamp)
{
ScreenInfo *screen_info;
DisplayInfo *display_info;
@@ -175,7 +175,7 @@ clientFocusNew(Client * c)
clientRaise (c, None);
clientShow (c, TRUE);
clientSetFocus (screen_info, c,
- myDisplayGetCurrentTime (display_info),
+ timestamp,
FOCUS_IGNORE_MODAL);
}
else
@@ -184,7 +184,7 @@ clientFocusNew(Client * c)
if (prevented && c2 && (c2->win_layer == c->win_layer))
{
- TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
+ TRACE ("clientFocusNew: Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
clientSortRing(c);
clientLower (c, c2->frame);
@@ -288,7 +288,7 @@ clientGetPrevious (Client * c, int mask)
}
void
-clientPassFocus (ScreenInfo *screen_info, Client *c, Client *exclude)
+clientPassFocus (ScreenInfo *screen_info, Client *c, Client *exclude, Time timestamp)
{
DisplayInfo *display_info;
ClientPair top_most;
@@ -362,7 +362,7 @@ clientPassFocus (ScreenInfo *screen_info, Client *c, Client *exclude)
new_focus = top_most.prefered ? top_most.prefered : top_most.highest;
}
clientSetFocus (screen_info, new_focus,
- myDisplayGetCurrentTime (screen_info->display_info),
+ timestamp,
FOCUS_IGNORE_MODAL | FOCUS_FORCE);
}
@@ -455,6 +455,12 @@ clientUpdateFocus (ScreenInfo *screen_info, Client * c, unsigned short flags)
{
clientSortRing(c);
}
+ if (FLAG_TEST(c->flags, CLIENT_FLAG_DEMANDS_ATTENTION))
+ {
+ TRACE ("Un-setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
+ FLAG_UNSET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
+ clientSetNetState (c);
+ }
data[0] = c->window;
clientAdjustFullscreenLayer (c, TRUE);
frameDraw (c, FALSE);
@@ -502,7 +508,7 @@ clientSetFocus (ScreenInfo *screen_info, Client * c, Time timestamp, unsigned sh
c2 = ((client_focus != c) ? client_focus : NULL);
if ((c) && FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE))
{
- TRACE ("setting focus to client \"%s\" (0x%lx)", c->name, c->window);
+ TRACE ("setting focus to client \"%s\" (0x%lx) with timestamp %u", c->name, c->window, timestamp);
user_focus = c;
if (FLAG_TEST(c->flags, CLIENT_FLAG_DEMANDS_ATTENTION))
{
@@ -512,8 +518,7 @@ clientSetFocus (ScreenInfo *screen_info, Client * c, Time timestamp, unsigned sh
}
if ((c == client_focus) && !(flags & FOCUS_FORCE))
{
- TRACE ("client \"%s\" (0x%lx) is already focused, ignoring request",
- c->name, c->window);
+ TRACE ("client \"%s\" (0x%lx) is already focused, ignoring request", c->name, c->window);
return;
}
if (!clientAcceptFocus (c))
diff --git a/src/focus.h b/src/focus.h
index 45fe8d3db..f7019181f 100644
--- a/src/focus.h
+++ b/src/focus.h
@@ -39,8 +39,10 @@
#define FOCUS_FORCE (1<<2)
void clientFocusTop (ScreenInfo *,
- int);
-gboolean clientFocusNew (Client *);
+ int,
+ Time);
+gboolean clientFocusNew (Client *,
+ Time);
gboolean clientSelectMask (Client *,
int,
int);
@@ -50,7 +52,8 @@ Client *clientGetPrevious (Client *,
int);
void clientPassFocus (ScreenInfo *,
Client *,
- Client *);
+ Client *,
+ Time);
gboolean clientAcceptFocus (Client *);
void clientSortRing (Client *);
void clientUpdateFocus (ScreenInfo *,
diff --git a/src/hints.c b/src/hints.c
index 79b95e316..2daa64f11 100644
--- a/src/hints.c
+++ b/src/hints.c
@@ -1196,19 +1196,22 @@ getXServerTime (DisplayInfo *display_info)
g_return_val_if_fail (display_info, (Time) CurrentTime);
timestamp = myDisplayGetCurrentTime (display_info);
- if (timestamp == CurrentTime)
+ if (timestamp == (Time) CurrentTime)
{
screen_info = myDisplayGetDefaultScreen (display_info);
g_return_val_if_fail (screen_info, (Time) CurrentTime);
+ TRACE ("getXServerTime: Using X server roundtrip");
XChangeProperty (display_info->dpy, screen_info->xfwm4_win,
display_info->atoms[XFWM4_TIMESTAMP_PROP],
display_info->atoms[XFWM4_TIMESTAMP_PROP],
8, PropModeReplace, (unsigned char *) &c, 1);
XIfEvent (display_info->dpy, &xevent, checkPropEvent, (XPointer) display_info);
- timestamp = (Time) xevent.xproperty.time;
+ timestamp = (Time) myDisplayUpdateCurrentTime (display_info, &xevent);
}
+
+ TRACE ("getXServerTime gives timestamp=%u", timestamp);
return timestamp;
}
diff --git a/src/main.c b/src/main.c
index 12edf80ee..73b22dd4b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -504,8 +504,7 @@ initialize (int argc, char **argv, gint compositor_mode)
screen_info->width,
screen_info->height);
workspaceUpdateArea (screen_info);
- XSetInputFocus (display_info->dpy, screen_info->xfwm4_win, RevertToPointerRoot,
- myDisplayGetCurrentTime (display_info));
+ XSetInputFocus (display_info->dpy, screen_info->xfwm4_win, RevertToPointerRoot, CurrentTime);
clientFrameAll (screen_info);
diff --git a/src/screen.c b/src/screen.c
index 372b95c85..cacc7978f 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -188,7 +188,7 @@ myScreenInit (DisplayInfo *display_info, GdkScreen *gscr, unsigned long event_ma
g_snprintf (selection, sizeof (selection), "WM_S%d", screen_info->screen);
wm_sn_atom = XInternAtom (display_info->dpy, selection, FALSE);
- XSetSelectionOwner (display_info->dpy, wm_sn_atom, screen_info->xfwm4_win, myDisplayGetCurrentTime (display_info));
+ XSetSelectionOwner (display_info->dpy, wm_sn_atom, screen_info->xfwm4_win, CurrentTime);
screen_info->box_gc = None;
screen_info->black_gc = NULL;
@@ -328,6 +328,18 @@ myScreenGrabKeyboard (ScreenInfo *screen_info, Time time)
}
gboolean
+myScreenCheckWMAtom (ScreenInfo *screen_info, Atom atom)
+{
+ gchar selection[32];
+ Atom wm_sn_atom;
+
+ g_snprintf (selection, sizeof (selection), "WM_S%d", screen_info->screen);
+ wm_sn_atom = XInternAtom (myScreenGetXDisplay (screen_info), selection, FALSE);
+
+ return (atom == wm_sn_atom);
+}
+
+gboolean
myScreenGrabPointer (ScreenInfo *screen_info, unsigned int event_mask, Cursor cursor, Time time)
{
gboolean grab;
diff --git a/src/screen.h b/src/screen.h
index b82c98084..e366ca0a0 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -160,6 +160,8 @@ Display *myScreenGetXDisplay (ScreenInfo *);
GtkWidget *myScreenGetGtkWidget (ScreenInfo *);
GtkWidget *myScreenGetGtkWidget (ScreenInfo *);
GdkWindow *myScreenGetGdkWindow (ScreenInfo *);
+gboolean myScreenCheckWMAtom (ScreenInfo *,
+ Atom atom);
gboolean myScreenGrabKeyboard (ScreenInfo *,
Time);
gboolean myScreenGrabPointer (ScreenInfo *,
diff --git a/src/stacking.c b/src/stacking.c
index 988f32bba..e718193d8 100644
--- a/src/stacking.c
+++ b/src/stacking.c
@@ -522,7 +522,7 @@ clientLower (Client * c, Window wsibling)
clientApplyStackList (screen_info);
clientSetNetClientList (screen_info, display_info->atoms[NET_CLIENT_LIST_STACKING], screen_info->windows_stack);
clientPassGrabMouseButton (NULL);
- clientPassFocus (screen_info, c, NULL);
+ clientPassFocus (screen_info, c, NULL, myDisplayGetCurrentTime (display_info));
if (screen_info->last_raise == c)
{
screen_info->last_raise = NULL;
diff --git a/src/workspaces.c b/src/workspaces.c
index d74dc91d2..6f5cd5db3 100644
--- a/src/workspaces.c
+++ b/src/workspaces.c
@@ -23,9 +23,14 @@
#include <config.h>
#endif
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xmd.h>
+
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
@@ -174,14 +179,14 @@ modify_with_wrap (int value, int by, int limit, gboolean wrap)
/* returns TRUE if the workspace was changed, FALSE otherwise */
gboolean
-workspaceMove (ScreenInfo *screen_info, int rowmod, int colmod, Client * c)
+workspaceMove (ScreenInfo *screen_info, int rowmod, int colmod, Client * c, Time timestamp)
{
int row, col, newrow, newcol, previous_ws, n;
- workspaceGetPosition(screen_info, screen_info->current_ws, &row, &col);
- newrow = modify_with_wrap(row, rowmod, screen_info->desktop_layout.rows, screen_info->params->wrap_layout);
- newcol = modify_with_wrap(col, colmod, screen_info->desktop_layout.cols, screen_info->params->wrap_layout);
- n = workspaceGetNumber(screen_info, newrow, newcol);
+ workspaceGetPosition (screen_info, screen_info->current_ws, &row, &col);
+ newrow = modify_with_wrap (row, rowmod, screen_info->desktop_layout.rows, screen_info->params->wrap_layout);
+ newcol = modify_with_wrap (col, colmod, screen_info->desktop_layout.cols, screen_info->params->wrap_layout);
+ n = workspaceGetNumber (screen_info, newrow, newcol);
if (n == screen_info->current_ws)
{
@@ -191,7 +196,7 @@ workspaceMove (ScreenInfo *screen_info, int rowmod, int colmod, Client * c)
previous_ws = screen_info->current_ws;
if ((n >= 0) && (n < screen_info->workspace_count))
{
- workspaceSwitch(screen_info, n, c, TRUE);
+ workspaceSwitch (screen_info, n, c, TRUE, timestamp);
}
else if (screen_info->params->wrap_layout)
{
@@ -218,16 +223,16 @@ workspaceMove (ScreenInfo *screen_info, int rowmod, int colmod, Client * c)
return FALSE;
}
- n = workspaceGetNumber(screen_info, newrow, newcol);
+ n = workspaceGetNumber (screen_info, newrow, newcol);
}
- workspaceSwitch(screen_info, n, c, TRUE);
+ workspaceSwitch (screen_info, n, c, TRUE, timestamp);
}
return (screen_info->current_ws != previous_ws);
}
void
-workspaceSwitch (ScreenInfo *screen_info, int new_ws, Client * c2, gboolean update_focus)
+workspaceSwitch (ScreenInfo *screen_info, int new_ws, Client * c2, gboolean update_focus, Time timestamp)
{
DisplayInfo *display_info;
Client *c, *new_focus;
@@ -268,7 +273,7 @@ workspaceSwitch (ScreenInfo *screen_info, int new_ws, Client * c2, gboolean upda
return;
}
- myScreenGrabPointer (screen_info, EnterWindowMask, None, myDisplayGetCurrentTime (display_info));
+ myScreenGrabPointer (screen_info, EnterWindowMask, None, timestamp);
screen_info->previous_ws = screen_info->current_ws;
screen_info->current_ws = new_ws;
@@ -325,7 +330,7 @@ workspaceSwitch (ScreenInfo *screen_info, int new_ws, Client * c2, gboolean upda
if (c == previous)
{
FLAG_SET (previous->xfwm_flags, XFWM_FLAG_FOCUS);
- clientSetFocus (screen_info, NULL, myDisplayGetCurrentTime (display_info), FOCUS_IGNORE_MODAL);
+ clientSetFocus (screen_info, NULL, timestamp, FOCUS_IGNORE_MODAL);
}
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE) && !FLAG_TEST (c->flags, CLIENT_FLAG_STICKY))
{
@@ -381,15 +386,15 @@ workspaceSwitch (ScreenInfo *screen_info, int new_ws, Client * c2, gboolean upda
{
if (new_focus)
{
- clientSetFocus (screen_info, new_focus, myDisplayGetCurrentTime (display_info), NO_FOCUS_FLAG);
+ clientSetFocus (screen_info, new_focus, timestamp, NO_FOCUS_FLAG);
}
else
{
- clientFocusTop (screen_info, WIN_LAYER_NORMAL);
+ clientFocusTop (screen_info, WIN_LAYER_NORMAL, timestamp);
}
}
- myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
+ myScreenUngrabPointer (screen_info, timestamp);
}
void
@@ -436,12 +441,12 @@ workspaceSetCount (ScreenInfo * screen_info, int count)
}
if (screen_info->current_ws > count - 1)
{
- workspaceSwitch (screen_info, count - 1, NULL, TRUE);
+ workspaceSwitch (screen_info, count - 1, NULL, TRUE, myDisplayGetCurrentTime (display_info));
}
setNetWorkarea (display_info, screen_info->xroot, screen_info->workspace_count,
screen_info->width, screen_info->height, screen_info->margins);
/* Recompute the layout based on the (changed) number of desktops */
- getDesktopLayout(display_info, screen_info->xroot, screen_info->workspace_count,
+ getDesktopLayout (display_info, screen_info->xroot, screen_info->workspace_count,
&screen_info->desktop_layout);
}
diff --git a/src/workspaces.h b/src/workspaces.h
index bb852426e..5f423092a 100644
--- a/src/workspaces.h
+++ b/src/workspaces.h
@@ -26,21 +26,28 @@
# include "config.h"
#endif
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xmd.h>
#include <glib.h>
+
#include "screen.h"
#include "client.h"
gboolean workspaceMove (ScreenInfo *,
int,
int,
- Client *);
+ Client *,
+ Time);
void workspaceSwitch (ScreenInfo *,
int,
Client *,
- gboolean);
+ gboolean,
+ Time);
void workspaceSetNames (ScreenInfo *,
gchar **,
int);