[gnome-shell] main: Move KeybindingMode into Shell
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] main: Move KeybindingMode into Shell
- Date: Mon, 4 Feb 2013 16:02:55 +0000 (UTC)
commit b682c8e0524153c34adb38ff029753f3a316d12d
Author: Florian MÃllner <fmuellner gnome org>
Date: Wed Dec 12 14:14:13 2012 +0100
main: Move KeybindingMode into Shell
Having the definition in C instead of Javascript allows sharing
the corresponding header with gnome-settings-daemon.
https://bugzilla.gnome.org/show_bug.cgi?id=643111
js/gdm/loginDialog.js | 2 +-
js/ui/components/recorder.js | 4 +-
js/ui/lookingGlass.js | 2 +-
js/ui/main.js | 35 ++++++--------------
js/ui/messageTray.js | 14 ++++----
js/ui/modalDialog.js | 2 +-
js/ui/overview.js | 2 +-
js/ui/screenShield.js | 5 ++-
js/ui/status/keyboard.js | 4 +-
js/ui/unlockDialog.js | 2 +-
js/ui/viewSelector.js | 4 +-
js/ui/windowManager.js | 72 +++++++++++++++++++++---------------------
src/Makefile.am | 1 +
src/shell-keybinding-modes.h | 35 ++++++++++++++++++++
14 files changed, 104 insertions(+), 80 deletions(-)
---
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index 31c04eb..0874fa0 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -677,7 +677,7 @@ const LoginDialog = new Lang.Class({
this.parent({ shellReactive: true,
styleClass: 'login-dialog',
parentActor: parentActor,
- keybindingMode: Main.KeybindingMode.LOGIN_SCREEN,
+ keybindingMode: Shell.KeyBindingMode.LOGIN_SCREEN,
shouldFadeIn: false });
this.connect('destroy',
Lang.bind(this, this._onDestroy));
diff --git a/js/ui/components/recorder.js b/js/ui/components/recorder.js
index cbc3e9e..2517f79 100644
--- a/js/ui/components/recorder.js
+++ b/js/ui/components/recorder.js
@@ -20,8 +20,8 @@ const Recorder = new Lang.Class({
Main.wm.addKeybinding('toggle-recording',
this._bindingSettings,
Meta.KeyBindingFlags.NONE,
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._toggleRecorder));
},
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index 097b15c..44802d2 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -1133,7 +1133,7 @@ const LookingGlass = new Lang.Class({
if (this._open)
return;
- if (!Main.pushModal(this._entry, { keybindingMode: Main.KeybindingMode.LOOKING_GLASS }))
+ if (!Main.pushModal(this._entry, { keybindingMode: Shell.KeyBindingMode.LOOKING_GLASS }))
return;
this._notebook.selectIndex(0);
diff --git a/js/ui/main.js b/js/ui/main.js
index 2e3a355..7d7d063 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -40,19 +40,6 @@ const Util = imports.misc.util;
const OVERRIDES_SCHEMA = 'org.gnome.shell.overrides';
const DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff);
-const KeybindingMode = {
- NONE: 0, // block all keybindings
- NORMAL: 1 << 0, // window mode
- OVERVIEW: 1 << 1,
- LOCK_SCREEN: 1 << 2,
- UNLOCK_SCREEN: 1 << 3,
- LOGIN_SCREEN: 1 << 4,
- MESSAGE_TRAY: 1 << 5,
- SYSTEM_MODAL: 1 << 6,
- LOOKING_GLASS: 1 << 7,
- ALL: ~0,
-};
-
let componentManager = null;
let panel = null;
let overview = null;
@@ -69,7 +56,7 @@ let shellDBusService = null;
let shellMountOpDBusService = null;
let screenSaverDBus = null;
let modalCount = 0;
-let keybindingMode = KeybindingMode.NORMAL;
+let keybindingMode = Shell.KeyBindingMode.NORMAL;
let modalActorFocusStack = [];
let uiGroup = null;
let magnifier = null;
@@ -83,15 +70,15 @@ let _overridesSettings = null;
function _sessionUpdated() {
wm.setCustomKeybindingHandler('panel-main-menu',
- KeybindingMode.NORMAL |
- KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
sessionMode.hasOverview ? Lang.bind(overview, overview.toggle) : null);
- wm.allowKeybinding('overlay-key', KeybindingMode.NORMAL |
- KeybindingMode.OVERVIEW);
+ wm.allowKeybinding('overlay-key', Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW);
wm.setCustomKeybindingHandler('panel-run-dialog',
- KeybindingMode.NORMAL |
- KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
sessionMode.hasRunDialog ? openRunDialog : null);
if (sessionMode.isGreeter)
screenShield.showDialog();
@@ -517,7 +504,7 @@ function isInModalStack(actor) {
* - options: Meta.ModalOptions flags to indicate that the pointer is
* already grabbed
*
- * - keybindingMode: used to set the current Main.KeybindingMode to filter
+ * - keybindingMode: used to set the current Shell.KeyBindingMode to filter
* global keybindings; the default of NONE will filter
* out all keybindings
*
@@ -526,7 +513,7 @@ function isInModalStack(actor) {
function pushModal(actor, params) {
params = Params.parse(params, { timestamp: global.get_current_time(),
options: 0,
- keybindingMode: KeybindingMode.NONE });
+ keybindingMode: Shell.KeyBindingMode.NONE });
if (modalCount == 0) {
if (!global.begin_modal(params.timestamp, params.options)) {
@@ -587,7 +574,7 @@ function popModal(actor, timestamp) {
global.stage.set_key_focus(null);
global.end_modal(timestamp);
global.set_stage_input_mode(Shell.StageInputMode.NORMAL);
- keybindingMode = KeybindingMode.NORMAL;
+ keybindingMode = Shell.KeyBindingMode.NORMAL;
throw new Error('incorrect pop');
}
@@ -636,7 +623,7 @@ function popModal(actor, timestamp) {
global.end_modal(timestamp);
global.set_stage_input_mode(Shell.StageInputMode.NORMAL);
Meta.enable_unredirect_for_screen(global.screen);
- keybindingMode = KeybindingMode.NORMAL;
+ keybindingMode = Shell.KeyBindingMode.NORMAL;
}
function createLookingGlass() {
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 6cc5729..49faf7a 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1535,7 +1535,7 @@ const MessageTray = new Lang.Class({
this.idleMonitor = new GnomeDesktop.IdleMonitor();
this._grabHelper = new GrabHelper.GrabHelper(this.actor,
- { keybindingMode: Main.KeybindingMode.MESSAGE_TRAY });
+ { keybindingMode: Shell.KeyBindingMode.MESSAGE_TRAY });
this._grabHelper.addActor(this._summaryBoxPointer.actor);
this._grabHelper.addActor(this.actor);
if (Main.panel.statusArea.activities)
@@ -1603,16 +1603,16 @@ const MessageTray = new Lang.Class({
Main.wm.addKeybinding('toggle-message-tray',
new Gio.Settings({ schema: SHELL_KEYBINDINGS_SCHEMA }),
Meta.KeyBindingFlags.NONE,
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.MESSAGE_TRAY |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.MESSAGE_TRAY |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this.toggleAndNavigate));
Main.wm.addKeybinding('focus-active-notification',
new Gio.Settings({ schema: SHELL_KEYBINDINGS_SCHEMA }),
Meta.KeyBindingFlags.NONE,
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.MESSAGE_TRAY |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.MESSAGE_TRAY |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._expandActiveNotification));
this._sources = new Hash.Map();
diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js
index 78e36dc..7c99598 100644
--- a/js/ui/modalDialog.js
+++ b/js/ui/modalDialog.js
@@ -37,7 +37,7 @@ const ModalDialog = new Lang.Class({
params = Params.parse(params, { shellReactive: false,
styleClass: null,
parentActor: Main.uiGroup,
- keybindingMode: Main.KeybindingMode.SYSTEM_MODAL,
+ keybindingMode: Shell.KeyBindingMode.SYSTEM_MODAL,
shouldFadeIn: true });
this.state = State.CLOSED;
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 84cd48c..a8f7e4a 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -576,7 +576,7 @@ const Overview = new Lang.Class({
if (this._shown) {
if (!this._modal) {
if (Main.pushModal(this._overview,
- { keybindingMode: Main.KeybindingMode.OVERVIEW }))
+ { keybindingMode: Shell.KeyBindingMode.OVERVIEW }))
this._modal = true;
else
this.hide();
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index 8db0f4d..7c2729e 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -8,6 +8,7 @@ const GnomeDesktop = imports.gi.GnomeDesktop;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
+const Shell = imports.gi.Shell;
const Signals = imports.signals;
const St = imports.gi.St;
const TweenerEquations = imports.tweener.equations;
@@ -693,7 +694,7 @@ const ScreenShield = new Lang.Class({
}
if (!this._isModal) {
- Main.pushModal(this.actor, { keybindingMode: Main.KeybindingMode.LOCK_SCREEN });
+ Main.pushModal(this.actor, { keybindingMode: Shell.KeyBindingMode.LOCK_SCREEN });
this._isModal = true;
}
@@ -1101,7 +1102,7 @@ const ScreenShield = new Lang.Class({
lock: function(animate) {
if (!this._isModal) {
- Main.pushModal(this.actor, { keybindingMode: Main.KeybindingMode.LOCK_SCREEN });
+ Main.pushModal(this.actor, { keybindingMode: Shell.KeyBindingMode.LOCK_SCREEN });
this._isModal = true;
}
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index 15e14d8..b0c17bd 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -337,14 +337,14 @@ const InputSourceIndicator = new Lang.Class({
Main.wm.addKeybinding('switch-input-source',
new Gio.Settings({ schema: "org.gnome.desktop.wm.keybindings" }),
Meta.KeyBindingFlags.REVERSES,
- Main.KeybindingMode.ALL,
+ Shell.KeyBindingMode.ALL,
Lang.bind(this, this._switchInputSource));
this._keybindingActionBackward =
Main.wm.addKeybinding('switch-input-source-backward',
new Gio.Settings({ schema: "org.gnome.desktop.wm.keybindings" }),
Meta.KeyBindingFlags.REVERSES |
Meta.KeyBindingFlags.REVERSED,
- Main.KeybindingMode.ALL,
+ Shell.KeyBindingMode.ALL,
Lang.bind(this, this._switchInputSource));
this._settings = new Gio.Settings({ schema: DESKTOP_INPUT_SOURCES_SCHEMA });
this._settings.connect('changed::' + KEY_CURRENT_INPUT_SOURCE, Lang.bind(this, this._currentInputSourceChanged));
diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js
index 6b6127b..b11f1ec 100644
--- a/js/ui/unlockDialog.js
+++ b/js/ui/unlockDialog.js
@@ -115,7 +115,7 @@ const UnlockDialog = new Lang.Class({
_init: function(parentActor) {
this.parent({ shellReactive: true,
styleClass: 'login-dialog',
- keybindingMode: Main.KeybindingMode.UNLOCK_SCREEN,
+ keybindingMode: Shell.KeyBindingMode.UNLOCK_SCREEN,
parentActor: parentActor
});
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 06cd436..5165910 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -136,8 +136,8 @@ const ViewSelector = new Lang.Class({
Main.wm.addKeybinding('toggle-application-view',
new Gio.Settings({ schema: SHELL_KEYBINDINGS_SCHEMA }),
Meta.KeyBindingFlags.NONE,
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._toggleAppsPage));
},
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 2b1af8f..b789d97 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -105,74 +105,74 @@ const WindowManager = new Lang.Class({
this._workspaceSwitcherPopup = null;
this.setCustomKeybindingHandler('switch-to-workspace-left',
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._showWorkspaceSwitcher));
this.setCustomKeybindingHandler('switch-to-workspace-right',
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._showWorkspaceSwitcher));
this.setCustomKeybindingHandler('switch-to-workspace-up',
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._showWorkspaceSwitcher));
this.setCustomKeybindingHandler('switch-to-workspace-down',
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._showWorkspaceSwitcher));
this.setCustomKeybindingHandler('move-to-workspace-left',
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._showWorkspaceSwitcher));
this.setCustomKeybindingHandler('move-to-workspace-right',
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._showWorkspaceSwitcher));
this.setCustomKeybindingHandler('move-to-workspace-up',
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._showWorkspaceSwitcher));
this.setCustomKeybindingHandler('move-to-workspace-down',
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW,
Lang.bind(this, this._showWorkspaceSwitcher));
this.setCustomKeybindingHandler('switch-applications',
- Main.KeybindingMode.NORMAL,
+ Shell.KeyBindingMode.NORMAL,
Lang.bind(this, this._startAppSwitcher));
this.setCustomKeybindingHandler('switch-group',
- Main.KeybindingMode.NORMAL,
+ Shell.KeyBindingMode.NORMAL,
Lang.bind(this, this._startAppSwitcher));
this.setCustomKeybindingHandler('switch-applications-backward',
- Main.KeybindingMode.NORMAL,
+ Shell.KeyBindingMode.NORMAL,
Lang.bind(this, this._startAppSwitcher));
this.setCustomKeybindingHandler('switch-group-backward',
- Main.KeybindingMode.NORMAL,
+ Shell.KeyBindingMode.NORMAL,
Lang.bind(this, this._startAppSwitcher));
this.setCustomKeybindingHandler('switch-windows',
- Main.KeybindingMode.NORMAL,
+ Shell.KeyBindingMode.NORMAL,
Lang.bind(this, this._startWindowSwitcher));
this.setCustomKeybindingHandler('switch-windows-backward',
- Main.KeybindingMode.NORMAL,
+ Shell.KeyBindingMode.NORMAL,
Lang.bind(this, this._startWindowSwitcher));
this.setCustomKeybindingHandler('switch-panels',
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW |
- Main.KeybindingMode.LOCK_SCREEN |
- Main.KeybindingMode.UNLOCK_SCREEN |
- Main.KeybindingMode.LOGIN_SCREEN,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW |
+ Shell.KeyBindingMode.LOCK_SCREEN |
+ Shell.KeyBindingMode.UNLOCK_SCREEN |
+ Shell.KeyBindingMode.LOGIN_SCREEN,
Lang.bind(this, this._startA11ySwitcher));
this.setCustomKeybindingHandler('switch-panels-backward',
- Main.KeybindingMode.NORMAL |
- Main.KeybindingMode.OVERVIEW |
- Main.KeybindingMode.LOCK_SCREEN |
- Main.KeybindingMode.UNLOCK_SCREEN |
- Main.KeybindingMode.LOGIN_SCREEN,
+ Shell.KeyBindingMode.NORMAL |
+ Shell.KeyBindingMode.OVERVIEW |
+ Shell.KeyBindingMode.LOCK_SCREEN |
+ Shell.KeyBindingMode.UNLOCK_SCREEN |
+ Shell.KeyBindingMode.LOGIN_SCREEN,
Lang.bind(this, this._startA11ySwitcher));
this.addKeybinding('open-application-menu',
new Gio.Settings({ schema: SHELL_KEYBINDINGS_SCHEMA }),
Meta.KeyBindingFlags.NONE,
- Main.KeybindingMode.NORMAL,
+ Shell.KeyBindingMode.NORMAL,
Lang.bind(this, this._openAppMenu));
Main.overview.connect('showing', Lang.bind(this, function() {
@@ -199,7 +199,7 @@ const WindowManager = new Lang.Class({
removeKeybinding: function(name) {
if (global.display.remove_keybinding(name))
- this.allowKeybinding(name, Main.KeybindingMode.NONE);
+ this.allowKeybinding(name, Shell.KeyBindingMode.NONE);
},
allowKeybinding: function(name, modes) {
@@ -502,14 +502,14 @@ const WindowManager = new Lang.Class({
},
_filterKeybinding: function(shellwm, binding) {
- if (Main.keybindingMode == Main.KeybindingMode.NONE)
+ if (Main.keybindingMode == Shell.KeyBindingMode.NONE)
return true;
// There's little sense in implementing a keybinding in mutter and
// not having it work in NORMAL mode; handle this case generically
// so we don't have to explicitly allow all builtin keybindings in
// NORMAL mode.
- if (Main.keybindingMode == Main.KeybindingMode.NORMAL &&
+ if (Main.keybindingMode == Shell.KeyBindingMode.NORMAL &&
binding.is_builtin())
return false;
diff --git a/src/Makefile.am b/src/Makefile.am
index 0e035ba..4dbff69 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -115,6 +115,7 @@ shell_public_headers_h = \
shell-gtk-embed.h \
shell-global.h \
shell-invert-lightness-effect.h \
+ shell-keybinding-modes.h \
shell-mobile-providers.h \
shell-mount-operation.h \
shell-network-agent.h \
diff --git a/src/shell-keybinding-modes.h b/src/shell-keybinding-modes.h
new file mode 100644
index 0000000..e02429a
--- /dev/null
+++ b/src/shell-keybinding-modes.h
@@ -0,0 +1,35 @@
+/**
+ * ShellKeyBindingMode:
+ * @SHELL_KEYBINDING_MODE_NONE: block keybinding
+ * @SHELL_KEYBINDING_MODE_NORMAL: allow keybinding when in window mode,
+ * e.g. when the focus is in an application window
+ * @SHELL_KEYBINDING_MODE_OVERVIEW: allow keybinding while the overview
+ * is active
+ * @SHELL_KEYBINDING_MODE_LOCK_SCREEN: allow keybinding when the screen
+ * is locked, e.g. when the screen shield is shown
+ * @SHELL_KEYBINDING_MODE_UNLOCK_SCREEN: allow keybinding in the unlock
+ * dialog
+ * @SHELL_KEYBINDING_MODE_LOGIN_SCREEN: allow keybinding in the login screen
+ * @SHELL_KEYBINDING_MODE_MESSAGE_TRAY: allow keybinding while the message
+ * tray is popped up
+ * @SHELL_KEYBINDING_MODE_SYSTEM_MODAL: allow keybinding when a system modal
+ * dialog (e.g. authentification or session dialogs) is open
+ * @SHELL_KEYBINDING_MODE_LOOKING_GLASS: allow keybinding in looking glass
+ * @SHELL_KEYBINDING_MODE_ALL: always allow keybinding
+ *
+ * Controls in which GNOME Shell states a keybinding should be handled.
+*/
+typedef enum {
+ SHELL_KEYBINDING_MODE_NONE = 0,
+ SHELL_KEYBINDING_MODE_NORMAL = 1 << 0,
+ SHELL_KEYBINDING_MODE_OVERVIEW = 1 << 1,
+ SHELL_KEYBINDING_MODE_LOCK_SCREEN = 1 << 2,
+ SHELL_KEYBINDING_MODE_UNLOCK_SCREEN = 1 << 3,
+ SHELL_KEYBINDING_MODE_LOGIN_SCREEN = 1 << 4,
+ SHELL_KEYBINDING_MODE_MESSAGE_TRAY = 1 << 5,
+ SHELL_KEYBINDING_MODE_SYSTEM_MODAL = 1 << 6,
+ SHELL_KEYBINDING_MODE_LOOKING_GLASS = 1 << 7,
+
+ SHELL_KEYBINDING_MODE_ALL = ~SHELL_KEYBINDING_MODE_NONE
+} ShellKeyBindingMode;
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]