Skip to content

Commit

Permalink
Disable keybindings message should ungrab keys
Browse files Browse the repository at this point in the history
The disable-keybindings action is currently only 'soft' in that it
just causes Metacity to ignore keypresses; the keys themselves are left
bound.

Sugar would like to use this message to actually disable the bindings
*and* release the grabs so that it can implement its own Alt-Tab handler.

This patch implements this. Based on earlier work by Bernie Innocenti.
  • Loading branch information
Daniel Drake authored and dsd committed May 21, 2011
1 parent 48cc8cb commit 429b200
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/display.c
Expand Up @@ -2268,7 +2268,7 @@ event_callback (XEvent *event,
{
meta_verbose ("Received set keybindings request = %d\n",
(int) event->xclient.data.l[0]);
meta_set_keybindings_disabled (!event->xclient.data.l[0]);
meta_set_keybindings_disabled (display, !event->xclient.data.l[0]);
}
else if (event->xclient.message_type ==
display->atom__METACITY_TOGGLE_VERBOSE)
Expand Down
10 changes: 9 additions & 1 deletion src/core/keybindings.c
Expand Up @@ -817,6 +817,9 @@ meta_screen_grab_keys (MetaScreen *screen)
if (screen->keys_grabbed)
return;

if (all_bindings_disabled)
return;

grab_keys (screen->display->key_bindings,
screen->display->n_key_bindings,
screen->display, screen->xroot,
Expand All @@ -841,6 +844,9 @@ meta_window_grab_keys (MetaWindow *window)
if (window->all_keys_grabbed)
return;

if (all_bindings_disabled)
return;

if (window->type == META_WINDOW_DOCK)
{
if (window->keys_grabbed)
Expand Down Expand Up @@ -3356,9 +3362,11 @@ handle_set_spew_mark (MetaDisplay *display,
}

void
meta_set_keybindings_disabled (gboolean setting)
meta_set_keybindings_disabled (MetaDisplay *display,
gboolean setting)
{
all_bindings_disabled = setting;
regrab_key_bindings (display);
meta_topic (META_DEBUG_KEYBINDINGS,
"Keybindings %s\n", all_bindings_disabled ? "disabled" : "enabled");
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/keybindings.h
Expand Up @@ -49,7 +49,8 @@ void meta_window_ungrab_all_keys (MetaWindow *window,
void meta_display_process_key_event (MetaDisplay *display,
MetaWindow *window,
XEvent *event);
void meta_set_keybindings_disabled (gboolean setting);
void meta_set_keybindings_disabled (MetaDisplay *display,
gboolean setting);
void meta_display_process_mapping_event (MetaDisplay *display,
XEvent *event);

Expand Down

0 comments on commit 429b200

Please sign in to comment.