[gnome-shell] main: clean up handling of metacity keybindings during grabs
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] main: clean up handling of metacity keybindings during grabs
- Date: Mon, 10 Jan 2011 20:27:57 +0000 (UTC)
commit 44f70646d3ba2ea5ac15e53dd9cd418cdaf430c1
Author: Dan Winship <danw gnome org>
Date: Thu Jan 6 15:30:24 2011 -0500
main: clean up handling of metacity keybindings during grabs
Although certain keys (like Ctrl-Alt-Tab and Alt-F2) should work in
the overview, we generally don't want them to work from inside each
others grabs. In particular, typing Left or Right from inside
Ctrl-Alt-Tab should navigate among focus groups, not switch
workspaces.
https://bugzilla.gnome.org/show_bug.cgi?id=636971
js/ui/main.js | 62 ++++++++++++++++++++++++--------------------------------
1 files changed, 27 insertions(+), 35 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index e407517..8574fe7 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -298,12 +298,6 @@ function _removeUnusedWorkspaces() {
// are disabled with a global grab. (When there is a global grab, then
// all key events will be delivered to the stage, so ::captured-event
// on the stage can be used for global keybindings.)
-//
-// We expect to need to conditionally enable just a few keybindings
-// depending on circumstance; the main hackiness here is that we are
-// assuming that keybindings have their default values; really we
-// should be asking Mutter to resolve the key into an action and then
-// base our handling based on the action.
function _globalKeyPressHandler(actor, event) {
if (modalCount == 0)
return false;
@@ -313,32 +307,36 @@ function _globalKeyPressHandler(actor, event) {
let symbol = event.get_key_symbol();
let keyCode = event.get_key_code();
let modifierState = Shell.get_event_state(event);
- // Check the overview key first, this isn't a Meta.KeyBindingAction yet
- if (symbol == Clutter.Super_L || symbol == Clutter.Super_R) {
- // The super key is the default for triggering the overview, and should
- // get us out of the overview when we are already in it.
- if (overview.visible)
- overview.hide();
+ let display = global.screen.get_display();
+ // This relies on the fact that Clutter.ModifierType is the same as Gdk.ModifierType
+ let action = display.get_keybinding_action(keyCode, modifierState);
+
+ // The screenshot action should always be available (even if a
+ // modal dialog is present)
+ if (action == Meta.KeyBindingAction.COMMAND_SCREENSHOT) {
+ let gconf = GConf.Client.get_default();
+ let command = gconf.get_string('/apps/metacity/keybinding_commands/command_screenshot');
+ if (command != null && command != '') {
+ let [ok, len, args] = GLib.shell_parse_argv(command);
+ let p = new Shell.Process({'args' : args});
+ p.run();
+ }
return true;
}
- // Whitelist some of the Metacity actions
- let display = global.screen.get_display();
- let activeWorkspaceIndex = global.screen.get_active_workspace_index();
+ // Other bindings are only available when the overview is up and
+ // no modal dialog is present.
+ if (!overview.visible || modalCount > 1)
+ return false;
+
+ // This isn't a Meta.KeyBindingAction yet
+ if (symbol == Clutter.Super_L || symbol == Clutter.Super_R) {
+ overview.hide();
+ return true;
+ }
- // This relies on the fact that Clutter.ModifierType is the same as Gdk.ModifierType
- let action = display.get_keybinding_action(keyCode, modifierState);
switch (action) {
- case Meta.KeyBindingAction.COMMAND_SCREENSHOT:
- let gconf = GConf.Client.get_default();
- let command = gconf.get_string('/apps/metacity/keybinding_commands/command_screenshot');
- if (command != null && command != '') {
- let [ok, len, args] = GLib.shell_parse_argv(command);
- let p = new Shell.Process({'args' : args});
- p.run();
- }
- return true;
case Meta.KeyBindingAction.WORKSPACE_LEFT:
wm.actionMoveWorkspaceLeft();
return true;
@@ -350,17 +348,11 @@ function _globalKeyPressHandler(actor, event) {
getRunDialog().open();
return true;
case Meta.KeyBindingAction.PANEL_MAIN_MENU:
- if (overview.visible)
- overview.hide();
+ overview.hide();
return true;
case Meta.KeyBindingAction.SWITCH_PANELS:
- // Only intercept this when we're in the overview, and don't
- // intercept it if something beyond that (like, say, the
- // ctrl-alt-tab popup!) is visible
- if (overview.visible && modalCount == 1) {
- ctrlAltTabManager.popup(modifierState & Clutter.ModifierType.SHIFT_MASK);
- return true;
- }
+ ctrlAltTabManager.popup(modifierState & Clutter.ModifierType.SHIFT_MASK);
+ return true;
}
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]