From 80d258b20ffc766e08f0be051422cf08815c0856 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sat, 2 Jan 2021 17:41:54 -0300 Subject: [PATCH] viewSelector: Move 'toggle-applications-view' to ControlsManager Move the shortcut handling into ControlsManager, and reimplement the callback in such a way that it behaves correctly with the current overview machinery. Part-of: --- js/ui/overviewControls.js | 20 +++++++++++++++++++- js/ui/viewSelector.js | 14 +------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js index f836f822e..c0998983b 100644 --- a/js/ui/overviewControls.js +++ b/js/ui/overviewControls.js @@ -1,11 +1,13 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported ControlsManager */ -const { Clutter, GObject, St } = imports.gi; +const { Clutter, Gio, GObject, Meta, Shell, St } = imports.gi; const Dash = imports.ui.dash; +const Main = imports.ui.main; const Overview = imports.ui.overview; const ViewSelector = imports.ui.viewSelector; +const WindowManager = imports.ui.windowManager; var SIDE_CONTROLS_ANIMATION_TIME = Overview.ANIMATION_TIME; @@ -142,6 +144,13 @@ class ControlsManager extends St.Widget { this.dash.showAppsButton.connect('notify::checked', this._onShowAppsButtonToggled.bind(this)); + Main.wm.addKeybinding( + 'toggle-application-view', + new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }), + Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, + Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, + this._toggleAppsPage.bind(this)); + this.connect('destroy', this._onDestroy.bind(this)); } @@ -160,6 +169,15 @@ class ControlsManager extends St.Widget { }); } + _toggleAppsPage() { + if (Main.overview.visible) { + const checked = this.dash.showAppsButton.checked; + this.dash.showAppsButton.checked = !checked; + } else { + Main.overview.show(ControlsState.APP_GRID); + } + } + _onDestroy() { global.workspace_manager.disconnect(this._nWorkspacesNotifyId); } diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js index 1abdf9cff..11228749b 100644 --- a/js/ui/viewSelector.js +++ b/js/ui/viewSelector.js @@ -1,7 +1,7 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported ViewSelector */ -const { Clutter, Gio, GObject, Meta, Shell, St } = imports.gi; +const { Clutter, GObject, Meta, Shell, St } = imports.gi; const Signals = imports.signals; const AppDisplay = imports.ui.appDisplay; @@ -351,13 +351,6 @@ var ViewSelector = GObject.registerClass({ } }); - Main.wm.addKeybinding('toggle-application-view', - new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }), - Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, - Shell.ActionMode.NORMAL | - Shell.ActionMode.OVERVIEW, - this._toggleAppsPage.bind(this)); - let side; if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) side = St.Side.RIGHT; @@ -386,11 +379,6 @@ var ViewSelector = GObject.registerClass({ Main.overview.show(); } - _toggleAppsPage() { - this._showAppsButton.checked = !this._showAppsButton.checked; - Main.overview.show(); - } - prepareToEnterOverview() { this.show(); this.reset();