summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Fourdan <fourdan@xfce.org>2009-09-30 16:53:28 +0200
committerOlivier Fourdan <fourdan@xfce.org>2009-09-30 16:53:28 +0200
commit7688f3288ff34157281cd531bc8b490edfed1adb (patch)
tree513a977acb205b38bb0e08e47bda0e88c434e9e1
parent9e5075fb9163272c88086d9bc018faaa1643f77b (diff)
downloadxfwm4-7688f3288ff34157281cd531bc8b490edfed1adb.tar.gz
"I don't remember why we need sync grab on keyboard. This is causing all sort of problems, so let's get rid of it (maybe someday I'll figure out why it was needed, but for now it works much better with async grabs)"
-rw-r--r--src/cycle.c12
-rw-r--r--src/display.c38
-rw-r--r--src/events.c115
-rw-r--r--src/keyboard.c14
-rw-r--r--src/moveresize.c24
5 files changed, 49 insertions, 154 deletions
diff --git a/src/cycle.c b/src/cycle.c
index 345821c6f..31b6500f8 100644
--- a/src/cycle.c
+++ b/src/cycle.c
@@ -314,8 +314,8 @@ clientCycle (Client * c, XKeyEvent * ev)
TRACE ("grab failed in clientCycle");
gdk_beep ();
- myScreenUngrabKeyboard (screen_info, CurrentTime);
- myScreenUngrabPointer (screen_info, CurrentTime);
+ myScreenUngrabKeyboard (screen_info, myDisplayGetCurrentTime (display_info));
+ myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
g_list_free (client_list);
return;
@@ -380,12 +380,8 @@ clientCycle (Client * c, XKeyEvent * ev)
g_free (passdata.tabwin);
g_list_free (client_list);
- /*
- * Use CurrentTime instead of actual last event time to make sure
- * that the grab is released in any case.
- */
- myScreenUngrabKeyboard (screen_info, CurrentTime);
- myScreenUngrabPointer (screen_info, CurrentTime);
+ myScreenUngrabKeyboard (screen_info, myDisplayGetCurrentTime (display_info));
+ myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
}
gboolean
diff --git a/src/display.c b/src/display.c
index 7ea5a980a..6ca9bca40 100644
--- a/src/display.c
+++ b/src/display.c
@@ -678,48 +678,62 @@ myDisplayGetDefaultScreen (DisplayInfo *display)
guint32
myDisplayUpdateCurrentTime (DisplayInfo *display, XEvent *ev)
{
- g_return_val_if_fail (display != NULL, CurrentTime);
+ guint32 timestamp;
+ g_return_val_if_fail (display != NULL, (guint32) CurrentTime);
+
+ timestamp = (guint32) CurrentTime;
switch (ev->type)
{
case KeyPress:
case KeyRelease:
- display->current_time = (guint32) ev->xkey.time;
+ timestamp = (guint32) ev->xkey.time;
break;
case ButtonPress:
case ButtonRelease:
- display->current_time = (guint32) ev->xbutton.time;
+ timestamp = (guint32) ev->xbutton.time;
break;
case MotionNotify:
- display->current_time = (guint32) ev->xmotion.time;
+ timestamp = (guint32) ev->xmotion.time;
break;
case EnterNotify:
case LeaveNotify:
- display->current_time = (guint32) ev->xcrossing.time;
+ timestamp = (guint32) ev->xcrossing.time;
break;
case PropertyNotify:
- display->current_time = (guint32) ev->xproperty.time;
+ timestamp = (guint32) ev->xproperty.time;
break;
case SelectionClear:
- display->current_time = (guint32) ev->xselectionclear.time;
+ timestamp = (guint32) ev->xselectionclear.time;
break;
case SelectionRequest:
- display->current_time = (guint32) ev->xselectionrequest.time;
+ timestamp = (guint32) ev->xselectionrequest.time;
break;
case SelectionNotify:
- display->current_time = (guint32) ev->xselection.time;
+ timestamp = (guint32) ev->xselection.time;
break;
default:
- display->current_time = (guint32) CurrentTime;
+#ifdef HAVE_XSYNC
+ if ((display->have_xsync) && (ev->type == display->xsync_event_base + XSyncAlarmNotify))
+ {
+ timestamp = ((XSyncAlarmNotifyEvent*) ev)->time;
+ }
+#endif /* HAVE_XSYNC */
break;
}
+
+ if ((timestamp == (guint32) CurrentTime) || TIMESTAMP_IS_BEFORE(display->current_time, timestamp))
+ {
+ display->current_time = timestamp;
+ }
+
return display->current_time;
}
guint32
myDisplayGetCurrentTime (DisplayInfo *display)
{
- g_return_val_if_fail (display != NULL, CurrentTime);
+ g_return_val_if_fail (display != NULL, (guint32) CurrentTime);
TRACE ("myDisplayGetCurrentTime gives timestamp=%u", (guint32) display->current_time);
return display->current_time;
@@ -743,7 +757,7 @@ myDisplayGetTime (DisplayInfo * display, guint32 timestamp)
guint32
myDisplayGetLastUserTime (DisplayInfo *display)
{
- g_return_val_if_fail (display != NULL, CurrentTime);
+ g_return_val_if_fail (display != NULL, (guint32) CurrentTime);
TRACE ("myDisplayGetLastUserTime gives timestamp=%u", (guint32) display->last_user_time);
return display->last_user_time;
diff --git a/src/events.c b/src/events.c
index 67b152911..792086d20 100644
--- a/src/events.c
+++ b/src/events.c
@@ -252,22 +252,6 @@ typeOfClick (ScreenInfo *screen_info, Window w, XEvent * ev, gboolean allow_doub
return (XfwmButtonClickType) passdata.clicks;
}
-#if CHECK_BUTTON_TIME
-static gboolean
-check_button_time (XButtonEvent *ev)
-{
- static guint32 last_button_time = CurrentTime;
-
- if (last_button_time > ev->time)
- {
- return FALSE;
- }
-
- last_button_time = ev->time;
- return TRUE;
-}
-#endif
-
static void
toggle_show_desktop (ScreenInfo *screen_info)
{
@@ -298,10 +282,8 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
TRACE ("entering handleKeyEvent");
ev_screen_info = myDisplayGetScreenFromRoot (display_info, ev->root);
-
if (!ev_screen_info)
{
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
return EVENT_FILTER_PASS;
}
@@ -317,57 +299,37 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
switch (key)
{
case KEY_MOVE:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientMove (c, (XEvent *) ev);
break;
case KEY_RESIZE:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientResize (c, CORNER_BOTTOM_RIGHT, (XEvent *) ev);
break;
case KEY_CYCLE_WINDOWS:
case KEY_CYCLE_REVERSE_WINDOWS:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientCycle (c, ev);
break;
case KEY_CLOSE_WINDOW:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientClose (c);
break;
case KEY_HIDE_WINDOW:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
if (CLIENT_CAN_HIDE_WINDOW (c))
{
clientWithdraw (c, c->win_workspace, TRUE);
}
break;
case KEY_MAXIMIZE_WINDOW:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientToggleMaximized (c, WIN_STATE_MAXIMIZED, TRUE);
break;
case KEY_MAXIMIZE_VERT:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientToggleMaximized (c, WIN_STATE_MAXIMIZED_VERT, TRUE);
break;
case KEY_MAXIMIZE_HORIZ:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientToggleMaximized (c, WIN_STATE_MAXIMIZED_HORIZ, TRUE);
break;
case KEY_SHADE_WINDOW:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientToggleShaded (c);
break;
case KEY_STICK_WINDOW:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
if (FLAG_TEST(c->xfwm_flags, XFWM_FLAG_HAS_STICK))
{
clientToggleSticky (c, TRUE);
@@ -375,53 +337,33 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
}
break;
case KEY_RAISE_WINDOW:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientRaise (c, None);
break;
case KEY_LOWER_WINDOW:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientLower (c, None);
break;
case KEY_TOGGLE_ABOVE:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientToggleLayerAbove (c);
break;
case KEY_TOGGLE_FULLSCREEN:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientToggleFullscreen (c);
break;
case KEY_MOVE_NEXT_WORKSPACE:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceSwitch (screen_info, screen_info->current_ws + 1, c, TRUE, ev->time);
break;
case KEY_MOVE_PREV_WORKSPACE:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceSwitch (screen_info, screen_info->current_ws - 1, c, TRUE, ev->time);
break;
case KEY_MOVE_UP_WORKSPACE:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceMove (screen_info, -1, 0, c, ev->time);
break;
case KEY_MOVE_DOWN_WORKSPACE:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceMove (screen_info, 1, 0, c, ev->time);
break;
case KEY_MOVE_LEFT_WORKSPACE:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceMove (screen_info, 0, -1, c, ev->time);
break;
case KEY_MOVE_RIGHT_WORKSPACE:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceMove (screen_info, 0, 1, c, ev->time);
break;
case KEY_MOVE_WORKSPACE_1:
@@ -436,8 +378,6 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
case KEY_MOVE_WORKSPACE_10:
case KEY_MOVE_WORKSPACE_11:
case KEY_MOVE_WORKSPACE_12:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
if ((guint) (key - KEY_MOVE_WORKSPACE_1) < screen_info->workspace_count)
{
clientRaise (c, None);
@@ -445,26 +385,18 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
}
break;
case KEY_POPUP_MENU:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
show_window_menu (c, frameX (c) + frameLeft (c),
frameY (c) + frameTop (c),
Button1, ev->time);
break;
case KEY_FILL_WINDOW:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientFill (c, CLIENT_FILL);
break;
case KEY_FILL_VERT:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientFill (c, CLIENT_FILL_VERT);
break;
case KEY_FILL_HORIZ:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
- clientFill (c, CLIENT_FILL_HORIZ);
+ clientFill (c, CLIENT_FILL_HORIZ);
break;
default:
break;
@@ -477,8 +409,6 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
{
case KEY_CYCLE_WINDOWS:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
if (ev_screen_info->clients)
{
clientCycle (ev_screen_info->clients->prev, ev);
@@ -486,8 +416,6 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
break;
case KEY_CLOSE_WINDOW:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
if (display_info->session)
{
logout_session (display_info->session);
@@ -501,71 +429,47 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
switch (key)
{
case KEY_SWITCH_WINDOW:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientSwitchWindow ();
break;
case KEY_SWITCH_APPLICATION:
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
clientSwitchApp ();
break;
case KEY_NEXT_WORKSPACE:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceSwitch (ev_screen_info, ev_screen_info->current_ws + 1, NULL, TRUE, ev->time);
break;
case KEY_PREV_WORKSPACE:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceSwitch (ev_screen_info, ev_screen_info->current_ws - 1, NULL, TRUE, ev->time);
break;
case KEY_UP_WORKSPACE:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceMove(ev_screen_info, -1, 0, NULL, ev->time);
break;
case KEY_DOWN_WORKSPACE:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceMove(ev_screen_info, 1, 0, NULL, ev->time);
break;
case KEY_LEFT_WORKSPACE:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceMove(ev_screen_info, 0, -1, NULL, ev->time);
break;
case KEY_RIGHT_WORKSPACE:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceMove(ev_screen_info, 0, 1, NULL, ev->time);
break;
case KEY_ADD_WORKSPACE:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceSetCount (ev_screen_info, ev_screen_info->workspace_count + 1);
break;
case KEY_DEL_WORKSPACE:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
workspaceSetCount (ev_screen_info, ev_screen_info->workspace_count - 1);
break;
case KEY_ADD_ADJACENT_WORKSPACE:
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
- handled = TRUE;
workspaceInsert (ev_screen_info, ev_screen_info->current_ws + 1);
break;
case KEY_DEL_ACTIVE_WORKSPACE:
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
- handled = TRUE;
workspaceDelete (ev_screen_info, ev_screen_info->current_ws);
break;
case KEY_WORKSPACE_1:
@@ -581,8 +485,6 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
case KEY_WORKSPACE_11:
case KEY_WORKSPACE_12:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
if ((guint) (key - KEY_WORKSPACE_1) < ev_screen_info->workspace_count)
{
workspaceSwitch (ev_screen_info, key - KEY_WORKSPACE_1, NULL, TRUE, ev->time);
@@ -590,21 +492,12 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev)
break;
case KEY_SHOW_DESKTOP:
status = EVENT_FILTER_REMOVE;
- handled = TRUE;
- XAllowEvents (display_info->dpy, AsyncKeyboard, ev->time);
toggle_show_desktop (ev_screen_info);
break;
default:
break;
}
- if (!handled)
- {
- /* That should not happen, really */
- g_warning ("Unhandled keyboard shortcut");
- XAllowEvents (display_info->dpy, AsyncKeyboard, CurrentTime);
- }
-
return status;
}
@@ -1095,7 +988,7 @@ handleButtonPress (DisplayInfo *display_info, XButtonEvent * ev)
}
/* Release pending events */
- XAllowEvents (display_info->dpy, replay ? ReplayPointer : SyncPointer, CurrentTime);
+ XAllowEvents (display_info->dpy, replay ? ReplayPointer : SyncPointer, myDisplayGetCurrentTime (display_info));
return EVENT_FILTER_REMOVE;
}
@@ -1115,7 +1008,7 @@ handleButtonRelease (DisplayInfo *display_info, XButtonEvent * ev)
}
/* Release pending events */
- XAllowEvents (display_info->dpy, SyncPointer, CurrentTime);
+ XAllowEvents (display_info->dpy, SyncPointer, myDisplayGetCurrentTime (display_info));
return EVENT_FILTER_REMOVE;
}
@@ -2922,7 +2815,7 @@ initGtkCallbacks (ScreenInfo *screen_info)
g_signal_connect (G_OBJECT(screen_info->gscr), "size-changed",
G_CALLBACK(size_changed_cb),
(gpointer) (screen_info));
- if(gtk_major_version > 2 || (gtk_major_version == 2 && gtk_minor_version >= 13))
+ if (gtk_major_version > 2 || (gtk_major_version == 2 && gtk_minor_version >= 13))
{
TRACE ("connect \"monitors-changed\" cb");
g_signal_connect (G_OBJECT(screen_info->gscr), "monitors-changed",
diff --git a/src/keyboard.c b/src/keyboard.c
index 3fb8d31f2..153ab2171 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -141,31 +141,31 @@ grabKey (Display * dpy, MyKey * key, Window w)
status |=
XGrabKey (dpy, key->keycode,
key->modifier | ScrollLockMask, w,
- TRUE, GrabModeAsync, GrabModeSync);
+ TRUE, GrabModeAsync, GrabModeAsync);
status |=
XGrabKey (dpy, key->keycode,
key->modifier | NumLockMask, w,
- TRUE, GrabModeAsync, GrabModeSync);
+ TRUE, GrabModeAsync, GrabModeAsync);
status |=
XGrabKey (dpy, key->keycode,
key->modifier | LockMask, w,
- TRUE, GrabModeAsync, GrabModeSync);
+ TRUE, GrabModeAsync, GrabModeAsync);
status |=
XGrabKey (dpy, key->keycode,
key->modifier | ScrollLockMask | NumLockMask, w,
- TRUE, GrabModeAsync, GrabModeSync);
+ TRUE, GrabModeAsync, GrabModeAsync);
status |=
XGrabKey (dpy, key->keycode,
key->modifier | ScrollLockMask | LockMask, w,
- TRUE, GrabModeAsync, GrabModeSync);
+ TRUE, GrabModeAsync, GrabModeAsync);
status |=
XGrabKey (dpy, key->keycode,
key->modifier | LockMask | NumLockMask, w,
- TRUE, GrabModeAsync, GrabModeSync);
+ TRUE, GrabModeAsync, GrabModeAsync);
status |=
XGrabKey (dpy, key->keycode,
key->modifier | ScrollLockMask | LockMask | NumLockMask, w,
- TRUE, GrabModeAsync, GrabModeSync);
+ TRUE, GrabModeAsync, GrabModeAsync);
}
return (status == GrabSuccess);
diff --git a/src/moveresize.c b/src/moveresize.c
index 853d8d0f6..57c303c65 100644
--- a/src/moveresize.c
+++ b/src/moveresize.c
@@ -1062,8 +1062,8 @@ clientMove (Client * c, XEvent * ev)
TRACE ("grab failed in clientMove");
gdk_beep ();
- myScreenUngrabKeyboard (screen_info, CurrentTime);
- myScreenUngrabPointer (screen_info, CurrentTime);
+ myScreenUngrabKeyboard (screen_info, myDisplayGetCurrentTime (display_info));
+ myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
return;
}
@@ -1133,12 +1133,8 @@ clientMove (Client * c, XEvent * ev)
eventFilterPop (display_info->xfilter);
}
- /*
- * Use CurrentTime instead of actual last event time to make sure
- * that the grab is released in any case.
- */
- myScreenUngrabKeyboard (screen_info, CurrentTime);
- myScreenUngrabPointer (screen_info, CurrentTime);
+ myScreenUngrabKeyboard (screen_info, myDisplayGetCurrentTime (display_info));
+ myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
if (passdata.grab && screen_info->params->box_move)
{
@@ -1627,8 +1623,8 @@ clientResize (Client * c, int handle, XEvent * ev)
TRACE ("grab failed in clientResize");
gdk_beep ();
- myScreenUngrabKeyboard (screen_info, CurrentTime);
- myScreenUngrabPointer (screen_info, CurrentTime);
+ myScreenUngrabKeyboard (screen_info, myDisplayGetCurrentTime (display_info));
+ myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
return;
}
@@ -1700,12 +1696,8 @@ clientResize (Client * c, int handle, XEvent * ev)
eventFilterPop (display_info->xfilter);
}
- /*
- * Use CurrentTime instead of actual last event time to make sure
- * that the grab is released in any case.
- */
- myScreenUngrabKeyboard (screen_info, CurrentTime);
- myScreenUngrabPointer (screen_info, CurrentTime);
+ myScreenUngrabKeyboard (screen_info, myDisplayGetCurrentTime (display_info));
+ myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
if (passdata.grab && screen_info->params->box_resize)
{