Disable gnome-shell application hotkeys on 3.32

This commit is contained in:
Charles Gagnon
2019-03-17 00:08:07 -04:00
parent b8832c1ed3
commit d43ddec7b2
5 changed files with 67 additions and 46 deletions

View File

@@ -21,6 +21,7 @@
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const PanelManager = Me.imports.panelManager;
const Utils = Me.imports.utils;
const Main = imports.ui.main;
const Meta = imports.gi.Meta;
@@ -43,7 +44,7 @@ let extensionChangedHandler;
let disabledUbuntuDock;
function init() {
Convenience.initTranslations(Me.imports.utils.TRANSLATION_DOMAIN);
Convenience.initTranslations(Utils.TRANSLATION_DOMAIN);
}
function enable() {
@@ -80,18 +81,17 @@ function _enable() {
panelManager = new PanelManager.dtpPanelManager(settings);
panelManager.enable();
Main.wm.removeKeybinding('open-application-menu');
Main.wm.addKeybinding('open-application-menu',
Utils.removeKeybinding('open-application-menu');
Utils.addKeybinding(
'open-application-menu',
new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
Meta.KeyBindingFlags.NONE,
Shell.ActionMode.NORMAL |
Shell.ActionMode.POPUP,
Lang.bind(this, function() {
if(settings.get_boolean('show-appmenu'))
Main.wm._toggleAppMenu();
else
panelManager.primaryPanel.taskbar.popupFocusedAppSecondaryMenu();
})
}),
Shell.ActionMode.NORMAL | Shell.ActionMode.POPUP
);
// Pretend I'm the dash: meant to make appgrd swarm animation come from the
@@ -109,13 +109,13 @@ function disable(reset) {
oldDash = null;
panelManager = null;
Main.wm.removeKeybinding('open-application-menu');
Main.wm.addKeybinding('open-application-menu',
new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
Meta.KeyBindingFlags.NONE,
Shell.ActionMode.NORMAL |
Shell.ActionMode.POPUP,
Lang.bind(Main.wm, Main.wm._toggleAppMenu));
Utils.removeKeybinding('open-application-menu');
Utils.addKeybinding(
'open-application-menu',
new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
Lang.bind(Main.wm, Main.wm._toggleAppMenu),
Shell.ActionMode.NORMAL | Shell.ActionMode.POPUP,
);
if (!reset) {
ExtensionSystem.disconnect(extensionChangedHandler);

View File

@@ -30,10 +30,13 @@ const Main = imports.ui.main;
const Shell = imports.gi.Shell;
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
const GS_HOTKEYS_KEY = 'switch-to-application-';
var dtpOverview = Utils.defineClass({
Name: 'DashToPanel.Overview',
@@ -172,6 +175,8 @@ var dtpOverview = Utils.defineClass({
seenApps[appIcon.app] = (seenApps[appIcon.app] || 0) + 1;
});
this._showOverlay();
if (appIndex < apps.length) {
let appIcon = apps[appIndex];
let windowCount = !appIcon.window ? appIcon._nWindows : seenApps[appIcon.app];
@@ -247,6 +252,13 @@ var dtpOverview = Utils.defineClass({
if (this._hotKeysEnabled)
return;
//3.32 introduced app hotkeys, disable them to prevent conflicts
if (Main.wm._switchToApplication) {
for (let i = 1; i < 10; ++i) {
Utils.removeKeybinding(GS_HOTKEYS_KEY + i);
}
}
// Setup keyboard bindings for taskbar elements
let keys = ['app-hotkey-', 'app-shift-hotkey-', 'app-ctrl-hotkey-', // Regular numbers
'app-hotkey-kp-', 'app-shift-hotkey-kp-', 'app-ctrl-hotkey-kp-']; // Key-pad numbers
@@ -254,15 +266,7 @@ var dtpOverview = Utils.defineClass({
for (let i = 0; i < this._numHotkeys; i++) {
let appNum = i;
if (!Main.wm._allowedKeybindings[key + (i + 1)]) {
Main.wm.addKeybinding(key + (i + 1), this._dtpSettings,
Meta.KeyBindingFlags.NONE,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
Lang.bind(this, function() {
this._activateApp(appNum);
this._showOverlay();
}));
}
Utils.addKeybinding(key + (i + 1), this._dtpSettings, () => this._activateApp(appNum));
}
}, this);
@@ -280,11 +284,17 @@ var dtpOverview = Utils.defineClass({
'app-hotkey-kp-', 'app-shift-hotkey-kp-', 'app-ctrl-hotkey-kp-']; // Key-pad numbers
keys.forEach( function(key) {
for (let i = 0; i < this._numHotkeys; i++) {
if (Main.wm._allowedKeybindings[key + (i + 1)]) {
Main.wm.removeKeybinding(key + (i + 1));
}
Utils.removeKeybinding(key + (i + 1));
}
}, this);
if (Main.wm._switchToApplication) {
let gsSettings = new Gio.Settings({ schema_id: imports.ui.windowManager.SHELL_KEYBINDINGS_SCHEMA });
for (let i = 1; i < 10; ++i) {
Utils.addKeybinding(GS_HOTKEYS_KEY + i, gsSettings, Main.wm._switchToApplication.bind(Main.wm));
}
}
this._hotKeysEnabled = false;
@@ -320,20 +330,11 @@ var dtpOverview = Utils.defineClass({
},
_enableExtraShortcut: function() {
if (!Main.wm._allowedKeybindings['shortcut']) {
Main.wm.addKeybinding('shortcut', this._dtpSettings,
Meta.KeyBindingFlags.NONE,
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
Lang.bind(this, function() {
this._showOverlay(true);
}));
}
Utils.addKeybinding('shortcut', this._dtpSettings, () => this._showOverlay(true));
},
_disableExtraShortcut: function() {
if (Main.wm._allowedKeybindings['shortcut']) {
Main.wm.removeKeybinding('shortcut');
}
Utils.removeKeybinding('shortcut');
},
_showOverlay: function(overlayFromShortcut) {

View File

@@ -331,12 +331,10 @@ var dtpPanelManager = Utils.defineClass({
};
Object.keys(keys).forEach(k => {
if (Main.wm._allowedKeybindings[k]) {
Main.wm.removeKeybinding(k);
}
Utils.removeKeybinding(k);
if (enable) {
Main.wm.addKeybinding(k, this._dtpSettings, Meta.KeyBindingFlags.NONE, Shell.ActionMode.NORMAL, keys[k]);
Utils.addKeybinding(k, this._dtpSettings, keys[k], Shell.ActionMode.NORMAL);
}
});
},

View File

@@ -31,7 +31,7 @@ const Mainloop = imports.mainloop;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const Gettext = imports.gettext.domain(Me.imports.utils.TRANSLATION_DOMAIN);
const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']);
const _ = Gettext.gettext;
const N_ = function(e) { return e };

View File

@@ -22,8 +22,12 @@
*/
const Gi = imports._gi;
const GObject = imports.gi.GObject;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
let es6Support = imports.misc.config.PACKAGE_VERSION >= '3.31.9';
@@ -42,10 +46,10 @@ var defineClass = function (classDef) {
};
}
return new imports.lang.Class(classDef);
return new Lang.Class(classDef);
}
let isGObject = parentProto instanceof imports.gi.GObject.Object;
let isGObject = parentProto instanceof GObject.Object;
let needsSuper = es6Support && parentProto && !isGObject;
let getParentArgs = function(args) {
let parentArgs = [];
@@ -88,7 +92,7 @@ var defineClass = function (classDef) {
.forEach(k => C.prototype[k] = classDef[k]);
if (isGObject) {
C = imports.gi.GObject.registerClass(C);
C = GObject.registerClass(C);
}
return C;
@@ -261,7 +265,7 @@ var DisplayWrapper = {
},
getMonitorManager: function() {
return global.screen || imports.gi.Meta.MonitorManager.get();
return global.screen || Meta.MonitorManager.get();
}
};
@@ -273,3 +277,21 @@ var hookVfunc = function(proto, symbol, func) {
Gi.hook_up_vfunc(proto, symbol, func);
}
};
var addKeybinding = function(key, settings, handler, modes) {
if (!Main.wm._allowedKeybindings[key]) {
Main.wm.addKeybinding(
key,
settings,
Meta.KeyBindingFlags.NONE,
modes || (Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW),
handler
);
}
};
var removeKeybinding = function(key) {
if (Main.wm._allowedKeybindings[key]) {
Main.wm.removeKeybinding(key);
}
};