keybindings: Add a helper for taking the standard three-button grab

This commit is contained in:
Jasper St. Pierre 2014-08-14 16:02:19 -04:00
parent cfb85d9a9a
commit 1e225ecdaf

View File

@ -1021,6 +1021,20 @@ meta_display_get_window_grab_modifiers (MetaDisplay *display)
return keys->window_grab_modifiers; return keys->window_grab_modifiers;
} }
static void
meta_change_buttons_grab (MetaKeyBindingManager *keys,
Window xwindow,
gboolean grab,
gboolean sync,
int modmask)
{
#define MAX_BUTTON 3
int i;
for (i = 1; i <= MAX_BUTTON; i++)
meta_change_button_grab (keys, xwindow, grab, sync, i, modmask);
}
void void
meta_display_grab_window_buttons (MetaDisplay *display, meta_display_grab_window_buttons (MetaDisplay *display,
Window xwindow) Window xwindow)
@ -1044,14 +1058,8 @@ meta_display_grab_window_buttons (MetaDisplay *display,
if (keys->window_grab_modifiers != 0) if (keys->window_grab_modifiers != 0)
{ {
int i; meta_change_buttons_grab (keys, xwindow, TRUE, FALSE,
for (i = 1; i < 4; i++) keys->window_grab_modifiers);
{
meta_change_button_grab (keys, xwindow,
TRUE,
FALSE,
i, keys->window_grab_modifiers);
}
/* In addition to grabbing Alt+Button1 for moving the window, /* In addition to grabbing Alt+Button1 for moving the window,
* grab Alt+Shift+Button1 for snap-moving the window. See bug * grab Alt+Shift+Button1 for snap-moving the window. See bug
@ -1071,7 +1079,6 @@ meta_display_ungrab_window_buttons (MetaDisplay *display,
Window xwindow) Window xwindow)
{ {
MetaKeyBindingManager *keys = &display->key_binding_manager; MetaKeyBindingManager *keys = &display->key_binding_manager;
int i;
if (meta_is_wayland_compositor ()) if (meta_is_wayland_compositor ())
return; return;
@ -1079,15 +1086,8 @@ meta_display_ungrab_window_buttons (MetaDisplay *display,
if (keys->window_grab_modifiers == 0) if (keys->window_grab_modifiers == 0)
return; return;
i = 1; meta_change_buttons_grab (keys, xwindow, FALSE, FALSE,
while (i < 4) keys->window_grab_modifiers);
{
meta_change_button_grab (keys, xwindow,
FALSE, FALSE, i,
keys->window_grab_modifiers);
++i;
}
} }
static void static void
@ -1103,7 +1103,6 @@ update_window_grab_modifiers (MetaKeyBindingManager *keys)
} }
/* Grab buttons we only grab while unfocused in click-to-focus mode */ /* Grab buttons we only grab while unfocused in click-to-focus mode */
#define MAX_FOCUS_BUTTON 4
void void
meta_display_grab_focus_window_button (MetaDisplay *display, meta_display_grab_focus_window_button (MetaDisplay *display,
MetaWindow *window) MetaWindow *window)
@ -1142,20 +1141,8 @@ meta_display_grab_focus_window_button (MetaDisplay *display,
* XSync() * XSync()
*/ */
{ meta_change_buttons_grab (keys, window->xwindow, TRUE, TRUE, 0);
int i = 1; window->have_focus_click_grab = TRUE;
while (i < MAX_FOCUS_BUTTON)
{
meta_change_button_grab (keys,
window->xwindow,
TRUE, TRUE,
i, 0);
++i;
}
window->have_focus_click_grab = TRUE;
}
} }
void void
@ -1172,18 +1159,8 @@ meta_display_ungrab_focus_window_button (MetaDisplay *display,
if (!window->have_focus_click_grab) if (!window->have_focus_click_grab)
return; return;
{ meta_change_buttons_grab (keys, window->xwindow, FALSE, FALSE, 0);
int i = 1; window->have_focus_click_grab = FALSE;
while (i < MAX_FOCUS_BUTTON)
{
meta_change_button_grab (keys, window->xwindow,
FALSE, FALSE, i, 0);
++i;
}
window->have_focus_click_grab = FALSE;
}
} }
static void static void