keybindings: Use input event helper functions

This commit is contained in:
Carlos Garnacho 2011-06-11 18:24:44 +02:00
parent 3b0aa9f881
commit 36e237cf1e

View File

@ -34,6 +34,7 @@
#include "ui.h" #include "ui.h"
#include "frame.h" #include "frame.h"
#include "place.h" #include "place.h"
#include "input-events.h"
#include <meta/prefs.h> #include <meta/prefs.h>
#include <meta/util.h> #include <meta/util.h>
@ -1256,17 +1257,23 @@ process_overlay_key (MetaDisplay *display,
XEvent *event, XEvent *event,
KeySym keysym) KeySym keysym)
{ {
if (event->xkey.keycode != display->overlay_key_combo.keycode) guint evtype, keycode;
if (!meta_input_event_get_type (display, event, &evtype) ||
!meta_input_event_get_keycode (display, event, &keycode))
return FALSE;
if (keycode != display->overlay_key_combo.keycode)
{ {
display->overlay_key_only_pressed = FALSE; display->overlay_key_only_pressed = FALSE;
return FALSE; return FALSE;
} }
if (event->xkey.type == KeyPress) if (evtype == KeyPress)
{ {
display->overlay_key_only_pressed = TRUE; display->overlay_key_only_pressed = TRUE;
} }
else if (event->xkey.type == KeyRelease && display->overlay_key_only_pressed) else if (evtype == KeyRelease && display->overlay_key_only_pressed)
{ {
display->overlay_key_only_pressed = FALSE; display->overlay_key_only_pressed = FALSE;
meta_display_overlay_key_activate (display); meta_display_overlay_key_activate (display);
@ -1325,10 +1332,16 @@ process_event (MetaKeyBinding *bindings,
KeySym keysym, KeySym keysym,
gboolean on_window) gboolean on_window)
{ {
guint evtype, keycode, state;
int i; int i;
/* we used to have release-based bindings but no longer. */ /* we used to have release-based bindings but no longer. */
if (event->type == KeyRelease) if (!meta_input_event_get_type (display, event, &evtype) ||
!meta_input_event_get_keycode (display, event, &keycode) ||
!meta_input_event_get_state (display, event, &state))
return FALSE;
if (evtype == KeyRelease)
return FALSE; return FALSE;
/* /*
@ -1340,9 +1353,9 @@ process_event (MetaKeyBinding *bindings,
MetaKeyHandler *handler = bindings[i].handler; MetaKeyHandler *handler = bindings[i].handler;
if ((!on_window && handler->flags & BINDING_PER_WINDOW) || if ((!on_window && handler->flags & BINDING_PER_WINDOW) ||
event->type != KeyPress || evtype != KeyPress ||
bindings[i].keycode != event->xkey.keycode || bindings[i].keycode != keycode ||
((event->xkey.state & 0xff & ~(display->ignored_modifier_mask)) != ((state & 0xff & ~(display->ignored_modifier_mask)) !=
bindings[i].mask)) bindings[i].mask))
continue; continue;
@ -1355,7 +1368,7 @@ process_event (MetaKeyBinding *bindings,
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Binding keycode 0x%x mask 0x%x matches event 0x%x state 0x%x\n", "Binding keycode 0x%x mask 0x%x matches event 0x%x state 0x%x\n",
bindings[i].keycode, bindings[i].mask, bindings[i].keycode, bindings[i].mask,
event->xkey.keycode, event->xkey.state); keycode, state);
if (handler == NULL) if (handler == NULL)
meta_bug ("Binding %s has no handler\n", bindings[i].name); meta_bug ("Binding %s has no handler\n", bindings[i].name);
@ -1405,39 +1418,49 @@ meta_display_process_key_event (MetaDisplay *display,
gboolean handled; gboolean handled;
const char *str; const char *str;
MetaScreen *screen; MetaScreen *screen;
guint evtype, keycode, state;
Window xwindow;
Time evtime;
if (!meta_input_event_get_type (display, event, &evtype) ||
!meta_input_event_get_keycode (display, event, &keycode) ||
!meta_input_event_get_state (display, event, &state))
return FALSE;
evtime = meta_input_event_get_time (display, event);
XAllowEvents (display->xdisplay, XAllowEvents (display->xdisplay,
all_bindings_disabled ? ReplayKeyboard : AsyncKeyboard, all_bindings_disabled ? ReplayKeyboard : AsyncKeyboard,
event->xkey.time); evtime);
if (all_bindings_disabled) if (all_bindings_disabled)
return FALSE; return FALSE;
xwindow = meta_input_event_get_window (display, event);
/* if key event was on root window, we have a shortcut */ /* if key event was on root window, we have a shortcut */
screen = meta_display_screen_for_root (display, event->xkey.window); screen = meta_display_screen_for_root (display, xwindow);
/* else round-trip to server */ /* else round-trip to server */
if (screen == NULL) if (screen == NULL)
screen = meta_display_screen_for_xwindow (display, screen = meta_display_screen_for_xwindow (display, xwindow);
event->xany.window);
if (screen == NULL) if (screen == NULL)
return FALSE; /* event window is destroyed */ return FALSE; /* event window is destroyed */
/* ignore key events on popup menus and such. */ /* ignore key events on popup menus and such. */
if (meta_ui_window_is_widget (screen->ui, event->xany.window)) if (meta_ui_window_is_widget (screen->ui, xwindow))
return FALSE; return FALSE;
/* window may be NULL */ /* window may be NULL */
keysym = XKeycodeToKeysym (display->xdisplay, event->xkey.keycode, 0); keysym = XKeycodeToKeysym (display->xdisplay, keycode, 0);
str = XKeysymToString (keysym); str = XKeysymToString (keysym);
/* was topic */ /* was topic */
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Processing key %s event, keysym: %s state: 0x%x window: %s\n", "Processing key %s event, keysym: %s state: 0x%x window: %s\n",
event->type == KeyPress ? "press" : "release", evtype == KeyPress ? "press" : "release",
str ? str : "none", event->xkey.state, str ? str : "none", state,
window ? window->desc : "(no window)"); window ? window->desc : "(no window)");
keep_grab = TRUE; keep_grab = TRUE;
@ -1521,7 +1544,8 @@ meta_display_process_key_event (MetaDisplay *display,
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Ending grab op %u on key event sym %s\n", "Ending grab op %u on key event sym %s\n",
display->grab_op, XKeysymToString (keysym)); display->grab_op, XKeysymToString (keysym));
meta_display_end_grab_op (display, event->xkey.time); meta_display_end_grab_op (display,
meta_input_event_get_time (display, event));
} }
return TRUE; return TRUE;
@ -1546,7 +1570,7 @@ process_mouse_move_resize_grab (MetaDisplay *display,
KeySym keysym) KeySym keysym)
{ {
/* don't care about releases, but eat them, don't end grab */ /* don't care about releases, but eat them, don't end grab */
if (event->type == KeyRelease) if (meta_input_event_is_type (display, event, KeyRelease))
return TRUE; return TRUE;
if (keysym == XK_Escape) if (keysym == XK_Escape)
@ -1595,27 +1619,31 @@ process_keyboard_move_grab (MetaDisplay *display,
int x, y; int x, y;
int incr; int incr;
gboolean smart_snap; gboolean smart_snap;
guint keycode, state;
handled = FALSE; handled = FALSE;
/* don't care about releases, but eat them, don't end grab */ /* don't care about releases, but eat them, don't end grab */
if (event->type == KeyRelease) if (meta_input_event_is_type (display, event, KeyRelease))
return TRUE; return TRUE;
meta_input_event_get_keycode (display, event, &keycode);
meta_input_event_get_state (display, event, &state);
/* don't end grab on modifier key presses */ /* don't end grab on modifier key presses */
if (is_modifier (display, event->xkey.keycode)) if (is_modifier (display, keycode))
return TRUE; return TRUE;
meta_window_get_position (window, &x, &y); meta_window_get_position (window, &x, &y);
smart_snap = (event->xkey.state & ShiftMask) != 0; smart_snap = (state & ShiftMask) != 0;
#define SMALL_INCREMENT 1 #define SMALL_INCREMENT 1
#define NORMAL_INCREMENT 10 #define NORMAL_INCREMENT 10
if (smart_snap) if (smart_snap)
incr = 1; incr = 1;
else if (event->xkey.state & ControlMask) else if (state & ControlMask)
incr = SMALL_INCREMENT; incr = SMALL_INCREMENT;
else else
incr = NORMAL_INCREMENT; incr = NORMAL_INCREMENT;
@ -1841,15 +1869,19 @@ process_keyboard_resize_grab (MetaDisplay *display,
int width, height; int width, height;
gboolean smart_snap; gboolean smart_snap;
int gravity; int gravity;
guint keycode, state;
handled = FALSE; handled = FALSE;
/* don't care about releases, but eat them, don't end grab */ /* don't care about releases, but eat them, don't end grab */
if (event->type == KeyRelease) if (meta_input_event_is_type (display, event, KeyRelease))
return TRUE; return TRUE;
meta_input_event_get_keycode (display, event, &keycode);
meta_input_event_get_state (display, event, &state);
/* don't end grab on modifier key presses */ /* don't end grab on modifier key presses */
if (is_modifier (display, event->xkey.keycode)) if (is_modifier (display, keycode))
return TRUE; return TRUE;
if (keysym == XK_Escape) if (keysym == XK_Escape)
@ -1874,7 +1906,7 @@ process_keyboard_resize_grab (MetaDisplay *display,
gravity = meta_resize_gravity_from_grab_op (display->grab_op); gravity = meta_resize_gravity_from_grab_op (display->grab_op);
smart_snap = (event->xkey.state & ShiftMask) != 0; smart_snap = (state & ShiftMask) != 0;
#define SMALL_INCREMENT 1 #define SMALL_INCREMENT 1
#define NORMAL_INCREMENT 10 #define NORMAL_INCREMENT 10
@ -1884,7 +1916,7 @@ process_keyboard_resize_grab (MetaDisplay *display,
height_inc = 1; height_inc = 1;
width_inc = 1; width_inc = 1;
} }
else if (event->xkey.state & ControlMask) else if (state & ControlMask)
{ {
width_inc = SMALL_INCREMENT; width_inc = SMALL_INCREMENT;
height_inc = SMALL_INCREMENT; height_inc = SMALL_INCREMENT;
@ -2103,13 +2135,18 @@ process_tab_grab (MetaDisplay *display,
gboolean backward; gboolean backward;
gboolean key_used; gboolean key_used;
MetaWindow *prev_window; MetaWindow *prev_window;
guint evtype, keycode;
if (screen != display->grab_screen) if (screen != display->grab_screen)
return FALSE; return FALSE;
if (!meta_input_event_get_type (display, event, &evtype) ||
!meta_input_event_get_keycode (display, event, &keycode))
return FALSE;
binding = display_get_keybinding (display, binding = display_get_keybinding (display,
keysym, keysym,
event->xkey.keycode, keycode,
display->grab_mask); display->grab_mask);
if (binding) if (binding)
action = meta_prefs_get_keybinding_action (binding->name); action = meta_prefs_get_keybinding_action (binding->name);
@ -2123,9 +2160,9 @@ process_tab_grab (MetaDisplay *display,
*/ */
if (!screen->tab_popup) if (!screen->tab_popup)
{ {
if (event->type == KeyRelease) if (evtype == KeyRelease)
{ {
if (end_keyboard_grab (display, event->xkey.keycode)) if (end_keyboard_grab (display, keycode))
{ {
invoke_handler_by_name (display, screen, "tab_popup_select", NULL, event); invoke_handler_by_name (display, screen, "tab_popup_select", NULL, event);
@ -2174,7 +2211,7 @@ process_tab_grab (MetaDisplay *display,
* If this is simply user pressing the Shift key, we do not want * If this is simply user pressing the Shift key, we do not want
* to cancel the grab. * to cancel the grab.
*/ */
if (is_modifier (display, event->xkey.keycode)) if (is_modifier (display, keycode))
return TRUE; return TRUE;
} }
@ -2187,8 +2224,8 @@ process_tab_grab (MetaDisplay *display,
return FALSE; return FALSE;
} }
if (event->type == KeyRelease && if (evtype == KeyRelease &&
end_keyboard_grab (display, event->xkey.keycode)) end_keyboard_grab (display, keycode))
{ {
/* We're done, move to the new window. */ /* We're done, move to the new window. */
MetaWindow *target_window; MetaWindow *target_window;
@ -2200,6 +2237,9 @@ process_tab_grab (MetaDisplay *display,
if (target_window) if (target_window)
{ {
Time evtime;
evtime = meta_input_event_get_time (display, event);
target_window->tab_unminimized = FALSE; target_window->tab_unminimized = FALSE;
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
@ -2209,11 +2249,11 @@ process_tab_grab (MetaDisplay *display,
"selection and turning mouse_mode off\n", "selection and turning mouse_mode off\n",
target_window->desc); target_window->desc);
display->mouse_mode = FALSE; display->mouse_mode = FALSE;
meta_window_activate (target_window, event->xkey.time); meta_window_activate (target_window, evtime);
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Ending grab early so we can focus the target window\n"); "Ending grab early so we can focus the target window\n");
meta_display_end_grab_op (display, event->xkey.time); meta_display_end_grab_op (display, evtime);
return TRUE; /* we already ended the grab */ return TRUE; /* we already ended the grab */
} }
@ -2222,11 +2262,11 @@ process_tab_grab (MetaDisplay *display,
} }
/* don't care about other releases, but eat them, don't end grab */ /* don't care about other releases, but eat them, don't end grab */
if (event->type == KeyRelease) if (evtype == KeyRelease)
return TRUE; return TRUE;
/* don't end grab on modifier key presses */ /* don't end grab on modifier key presses */
if (is_modifier (display, event->xkey.keycode)) if (is_modifier (display, keycode))
return TRUE; return TRUE;
prev_window = meta_screen_tab_popup_get_selected (screen); prev_window = meta_screen_tab_popup_get_selected (screen);
@ -2342,10 +2382,14 @@ process_tab_grab (MetaDisplay *display,
if (key_used) if (key_used)
{ {
guint state;
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Key pressed, moving tab focus in popup\n"); "Key pressed, moving tab focus in popup\n");
if (event->xkey.state & ShiftMask) meta_input_event_get_state (display, event, &state);
if (state & ShiftMask)
backward = !backward; backward = !backward;
if (backward) if (backward)
@ -2432,7 +2476,8 @@ handle_switch_to_workspace (MetaDisplay *display,
if (workspace) if (workspace)
{ {
meta_workspace_activate (workspace, event->xkey.time); meta_workspace_activate (workspace,
meta_input_event_get_time (display, event));
} }
else else
{ {
@ -2544,8 +2589,10 @@ handle_run_command (MetaDisplay *display,
gint which = binding->handler->data; gint which = binding->handler->data;
const char *command; const char *command;
GError *err; GError *err;
Time evtime;
command = meta_prefs_get_command (which); command = meta_prefs_get_command (which);
evtime = meta_input_event_get_time (display, event);
if (command == NULL) if (command == NULL)
{ {
@ -2557,7 +2604,7 @@ handle_run_command (MetaDisplay *display,
s = g_strdup_printf (_("No command %d has been defined.\n"), s = g_strdup_printf (_("No command %d has been defined.\n"),
which + 1); which + 1);
error_on_command (which, NULL, s, screen, event->xkey.time); error_on_command (which, NULL, s, screen, evtime);
g_free (s); g_free (s);
return; return;
@ -2566,7 +2613,7 @@ handle_run_command (MetaDisplay *display,
err = NULL; err = NULL;
if (!meta_spawn_command_line_async_on_screen (command, screen, &err)) if (!meta_spawn_command_line_async_on_screen (command, screen, &err))
{ {
error_on_command (which, command, err->message, screen, event->xkey.time); error_on_command (which, command, err->message, screen, evtime);
g_error_free (err); g_error_free (err);
} }
@ -2783,12 +2830,20 @@ process_workspace_switch_grab (MetaDisplay *display,
KeySym keysym) KeySym keysym)
{ {
MetaWorkspace *workspace; MetaWorkspace *workspace;
guint evtype, keycode;
Time evtime;
if (screen != display->grab_screen || !screen->ws_popup) if (screen != display->grab_screen || !screen->ws_popup)
return FALSE; return FALSE;
if (event->type == KeyRelease && if (!meta_input_event_get_type (display, event, &evtype) ||
end_keyboard_grab (display, event->xkey.keycode)) !meta_input_event_get_keycode (display, event, &keycode))
return FALSE;
evtime = meta_input_event_get_time (display, event);
if (evtype == KeyRelease &&
end_keyboard_grab (display, keycode))
{ {
/* We're done, move to the new workspace. */ /* We're done, move to the new workspace. */
MetaWorkspace *target_workspace; MetaWorkspace *target_workspace;
@ -2802,14 +2857,14 @@ process_workspace_switch_grab (MetaDisplay *display,
{ {
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Ending grab so we can focus on the target workspace\n"); "Ending grab so we can focus on the target workspace\n");
meta_display_end_grab_op (display, event->xkey.time); meta_display_end_grab_op (display, evtime);
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Focusing default window on target workspace\n"); "Focusing default window on target workspace\n");
meta_workspace_focus_default_window (target_workspace, meta_workspace_focus_default_window (target_workspace,
NULL, NULL,
event->xkey.time); evtime);
return TRUE; /* we already ended the grab */ return TRUE; /* we already ended the grab */
} }
@ -2821,11 +2876,11 @@ process_workspace_switch_grab (MetaDisplay *display,
} }
/* don't care about other releases, but eat them, don't end grab */ /* don't care about other releases, but eat them, don't end grab */
if (event->type == KeyRelease) if (evtype == KeyRelease)
return TRUE; return TRUE;
/* don't end grab on modifier key presses */ /* don't end grab on modifier key presses */
if (is_modifier (display, event->xkey.keycode)) if (is_modifier (display, keycode))
return TRUE; return TRUE;
/* select the next workspace in the popup */ /* select the next workspace in the popup */
@ -2837,7 +2892,7 @@ process_workspace_switch_grab (MetaDisplay *display,
MetaKeyBindingAction action; MetaKeyBindingAction action;
action = meta_display_get_keybinding_action (display, action = meta_display_get_keybinding_action (display,
event->xkey.keycode, keycode,
display->grab_mask); display->grab_mask);
switch (action) switch (action)
@ -2876,7 +2931,7 @@ process_workspace_switch_grab (MetaDisplay *display,
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Activating target workspace\n"); "Activating target workspace\n");
meta_workspace_activate (target_workspace, event->xkey.time); meta_workspace_activate (target_workspace, evtime);
return TRUE; /* we already ended the grab */ return TRUE; /* we already ended the grab */
} }
@ -2886,7 +2941,7 @@ process_workspace_switch_grab (MetaDisplay *display,
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Ending workspace tabbing & focusing default window; uninteresting key pressed\n"); "Ending workspace tabbing & focusing default window; uninteresting key pressed\n");
workspace = meta_screen_workspace_popup_get_selected (screen); workspace = meta_screen_workspace_popup_get_selected (screen);
meta_workspace_focus_default_window (workspace, NULL, event->xkey.time); meta_workspace_focus_default_window (workspace, NULL, evtime);
return FALSE; return FALSE;
} }
@ -2898,15 +2953,18 @@ handle_show_desktop (MetaDisplay *display,
MetaKeyBinding *binding, MetaKeyBinding *binding,
gpointer dummy) gpointer dummy)
{ {
Time evtime;
evtime = meta_input_event_get_time (display, event);
if (screen->active_workspace->showing_desktop) if (screen->active_workspace->showing_desktop)
{ {
meta_screen_unshow_desktop (screen); meta_screen_unshow_desktop (screen);
meta_workspace_focus_default_window (screen->active_workspace, meta_workspace_focus_default_window (screen->active_workspace,
NULL, NULL, evtime);
event->xkey.time);
} }
else else
meta_screen_show_desktop (screen, event->xkey.time); meta_screen_show_desktop (screen, evtime);
} }
static void static void
@ -2920,6 +2978,7 @@ handle_panel (MetaDisplay *display,
MetaKeyBindingAction action = binding->handler->data; MetaKeyBindingAction action = binding->handler->data;
Atom action_atom; Atom action_atom;
XClientMessageEvent ev; XClientMessageEvent ev;
Time evtime;
action_atom = None; action_atom = None;
switch (action) switch (action)
@ -2935,22 +2994,24 @@ handle_panel (MetaDisplay *display,
return; return;
} }
evtime = meta_input_event_get_time (display, event);
ev.type = ClientMessage; ev.type = ClientMessage;
ev.window = screen->xroot; ev.window = screen->xroot;
ev.message_type = display->atom__GNOME_PANEL_ACTION; ev.message_type = display->atom__GNOME_PANEL_ACTION;
ev.format = 32; ev.format = 32;
ev.data.l[0] = action_atom; ev.data.l[0] = action_atom;
ev.data.l[1] = event->xkey.time; ev.data.l[1] = evtime;
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Sending panel message with timestamp %lu, and turning mouse_mode " "Sending panel message with timestamp %lu, and turning mouse_mode "
"off due to keybinding press\n", event->xkey.time); "off due to keybinding press\n", evtime);
display->mouse_mode = FALSE; display->mouse_mode = FALSE;
meta_error_trap_push (display); meta_error_trap_push (display);
/* Release the grab for the panel before sending the event */ /* Release the grab for the panel before sending the event */
XUngrabKeyboard (display->xdisplay, event->xkey.time); XUngrabKeyboard (display->xdisplay, evtime);
XSendEvent (display->xdisplay, XSendEvent (display->xdisplay,
screen->xroot, screen->xroot,
@ -2982,6 +3043,7 @@ handle_activate_window_menu (MetaDisplay *display,
{ {
if (display->focus_window) if (display->focus_window)
{ {
Time evtime;
int x, y; int x, y;
meta_window_get_position (display->focus_window, meta_window_get_position (display->focus_window,
@ -2990,10 +3052,12 @@ handle_activate_window_menu (MetaDisplay *display,
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL) if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
x += display->focus_window->rect.width; x += display->focus_window->rect.width;
evtime = meta_input_event_get_time (display, event);
meta_window_show_menu (display->focus_window, meta_window_show_menu (display->focus_window,
x, y, x, y,
0, 0,
event->xkey.time); evtime);
} }
} }
@ -3044,14 +3108,21 @@ do_choose_window (MetaDisplay *display,
{ {
MetaTabList type = binding->handler->data; MetaTabList type = binding->handler->data;
MetaWindow *initial_selection; MetaWindow *initial_selection;
guint state;
Time evtime;
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Tab list = %u show_popup = %d\n", type, show_popup); "Tab list = %u show_popup = %d\n", type, show_popup);
if (!meta_input_event_get_state (display, event, &state))
return;
/* reverse direction if shift is down */ /* reverse direction if shift is down */
if (event->xkey.state & ShiftMask) if (state & ShiftMask)
backward = !backward; backward = !backward;
evtime = meta_input_event_get_time (display, event);
initial_selection = meta_display_get_tab_next (display, initial_selection = meta_display_get_tab_next (display,
type, type,
screen, screen,
@ -3082,7 +3153,7 @@ do_choose_window (MetaDisplay *display,
"switch/cycle windows with no modifiers\n", "switch/cycle windows with no modifiers\n",
initial_selection->desc); initial_selection->desc);
display->mouse_mode = FALSE; display->mouse_mode = FALSE;
meta_window_activate (initial_selection, event->xkey.time); meta_window_activate (initial_selection, evtime);
return; return;
} }
@ -3102,7 +3173,7 @@ do_choose_window (MetaDisplay *display,
FALSE, FALSE,
0, 0,
binding->mask, binding->mask,
event->xkey.time, evtime,
0, 0)) 0, 0))
return; return;
@ -3117,9 +3188,10 @@ do_choose_window (MetaDisplay *display,
"mouse_mode due to switch/cycle windows where " "mouse_mode due to switch/cycle windows where "
"modifier was released prior to grab\n", "modifier was released prior to grab\n",
initial_selection->desc); initial_selection->desc);
meta_display_end_grab_op (display, event->xkey.time);
meta_display_end_grab_op (display, evtime);
display->mouse_mode = FALSE; display->mouse_mode = FALSE;
meta_window_activate (initial_selection, event->xkey.time); meta_window_activate (initial_selection, evtime);
return; return;
} }
@ -3269,10 +3341,14 @@ handle_toggle_shaded (MetaDisplay *display,
MetaKeyBinding *binding, MetaKeyBinding *binding,
gpointer dummy) gpointer dummy)
{ {
Time evtime;
evtime = meta_input_event_get_time (display, event);
if (window->shaded) if (window->shaded)
meta_window_unshade (window, event->xkey.time); meta_window_unshade (window, evtime);
else if (window->has_shade_func) else if (window->has_shade_func)
meta_window_shade (window, event->xkey.time); meta_window_shade (window, evtime);
} }
static void static void
@ -3284,7 +3360,9 @@ handle_close (MetaDisplay *display,
gpointer dummy) gpointer dummy)
{ {
if (window->has_close_func) if (window->has_close_func)
meta_window_delete (window, event->xkey.time); meta_window_delete (window,
meta_input_event_get_time (display,
event));
} }
static void static void
@ -3312,7 +3390,7 @@ handle_begin_move (MetaDisplay *display,
meta_window_begin_grab_op (window, meta_window_begin_grab_op (window,
META_GRAB_OP_KEYBOARD_MOVING, META_GRAB_OP_KEYBOARD_MOVING,
FALSE, FALSE,
event->xkey.time); meta_input_event_get_time (display, event));
} }
} }
@ -3329,7 +3407,7 @@ handle_begin_resize (MetaDisplay *display,
meta_window_begin_grab_op (window, meta_window_begin_grab_op (window,
META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN, META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN,
FALSE, FALSE,
event->xkey.time); meta_input_event_get_time (display, event));
} }
} }
@ -3387,13 +3465,13 @@ handle_move_to_workspace (MetaDisplay *display,
meta_window_change_workspace (window, workspace); meta_window_change_workspace (window, workspace);
if (flip) if (flip)
{ {
Time evtime = meta_input_event_get_time (display, event);
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
"Resetting mouse_mode to FALSE due to " "Resetting mouse_mode to FALSE due to "
"handle_move_to_workspace() call with flip set.\n"); "handle_move_to_workspace() call with flip set.\n");
workspace->screen->display->mouse_mode = FALSE; workspace->screen->display->mouse_mode = FALSE;
meta_workspace_activate_with_focus (workspace, meta_workspace_activate_with_focus (workspace, window, evtime);
window,
event->xkey.time);
} }
} }
else else
@ -3483,14 +3561,20 @@ handle_workspace_switch (MetaDisplay *display,
unsigned int grab_mask; unsigned int grab_mask;
MetaWorkspace *next; MetaWorkspace *next;
gboolean grabbed_before_release; gboolean grabbed_before_release;
guint state;
Time evtime;
g_assert (motion < 0); g_assert (motion < 0);
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"Starting tab between workspaces, showing popup\n"); "Starting tab between workspaces, showing popup\n");
if (!meta_input_event_get_state (display, event, &state))
return;
/* FIXME should we use binding->mask ? */ /* FIXME should we use binding->mask ? */
grab_mask = event->xkey.state & ~(display->ignored_modifier_mask); grab_mask = state & ~(display->ignored_modifier_mask);
evtime = meta_input_event_get_time (display, event);
if (!meta_display_begin_grab_op (display, if (!meta_display_begin_grab_op (display,
screen, screen,
@ -3500,7 +3584,7 @@ handle_workspace_switch (MetaDisplay *display,
FALSE, FALSE,
0, 0,
grab_mask, grab_mask,
event->xkey.time, evtime,
0, 0)) 0, 0))
return; return;
@ -3518,10 +3602,10 @@ handle_workspace_switch (MetaDisplay *display,
* release event. Must end grab before we can switch * release event. Must end grab before we can switch
* spaces. * spaces.
*/ */
meta_display_end_grab_op (display, event->xkey.time); meta_display_end_grab_op (display, evtime);
} }
meta_workspace_activate (next, event->xkey.time); meta_workspace_activate (next, evtime);
if (grabbed_before_release && !meta_prefs_get_no_tab_popup ()) if (grabbed_before_release && !meta_prefs_get_no_tab_popup ())
meta_screen_workspace_popup_create (screen, next); meta_screen_workspace_popup_create (screen, next);
@ -3555,8 +3639,10 @@ handle_run_terminal (MetaDisplay *display,
gpointer dummy) gpointer dummy)
{ {
const char *command; const char *command;
Time evtime;
GError *err; GError *err;
evtime = meta_input_event_get_time (display, event);
command = meta_prefs_get_terminal_command (); command = meta_prefs_get_terminal_command ();
if (command == NULL) if (command == NULL)
@ -3568,7 +3654,7 @@ handle_run_terminal (MetaDisplay *display,
"keybinding press\n"); "keybinding press\n");
s = g_strdup_printf (_("No terminal command has been defined.\n")); s = g_strdup_printf (_("No terminal command has been defined.\n"));
error_on_command (-1, NULL, s, screen, event->xkey.time); error_on_command (-1, NULL, s, screen, evtime);
g_free (s); g_free (s);
return; return;
@ -3578,7 +3664,7 @@ handle_run_terminal (MetaDisplay *display,
if (!meta_spawn_command_line_async_on_screen (command, screen, &err)) if (!meta_spawn_command_line_async_on_screen (command, screen, &err))
{ {
error_on_command (-1, command, err->message, screen, error_on_command (-1, command, err->message, screen,
event->xkey.time); evtime);
g_error_free (err); g_error_free (err);
} }