[gnome-shell/wip/jimmac/dash-icon-spacing: 51/72] overview: Make 4fg vertical swipes bring overview and app grid
- From: Jakub Steiner <jimmac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/jimmac/dash-icon-spacing: 51/72] overview: Make 4fg vertical swipes bring overview and app grid
- Date: Tue, 2 Feb 2021 11:58:19 +0000 (UTC)
commit e7ed866acdfa0f5e501c00b72dbacb7c6d9c9b7d
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Jan 4 16:23:45 2021 +0100
overview: Make 4fg vertical swipes bring overview and app grid
The gesture internally manipulates the main adjustment so one swipe
up brings up the overview, and a second swipe up brings the app
grid. The gesture also works in the other direction to get out of
the overview.
Internally, this is delegated on the OverviewControls, so the
adjustment is not leaked out of there. This however meant open
coding the gesture interaction so it can be directed from
overview.js code.
js/ui/overview.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++-
js/ui/overviewControls.js | 39 ++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 835665003c..5f98ed59a7 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -15,6 +15,7 @@ const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
const OverviewControls = imports.ui.overviewControls;
const Params = imports.misc.params;
+const SwipeTracker = imports.ui.swipeTracker;
const WindowManager = imports.ui.windowManager;
var DND_WINDOW_SWITCH_TIMEOUT = 750;
@@ -117,6 +118,10 @@ class OverviewActor extends St.BoxLayout {
get viewSelector() {
return this._controls.viewSelector;
}
+
+ get controls() {
+ return this._controls;
+ }
});
var Overview = class {
@@ -238,7 +243,6 @@ var Overview = class {
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this.toggle.bind(this));
-
let side;
if (Clutter.get_default_text_direction() === Clutter.TextDirection.RTL)
side = St.Side.RIGHT;
@@ -255,6 +259,15 @@ var Overview = class {
this.showApps();
});
global.stage.add_action(gesture);
+
+ const swipeTracker = new SwipeTracker.SwipeTracker(global.stage,
+ Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+ { allowDrag: false, allowScroll: false });
+ swipeTracker.orientation = Clutter.Orientation.VERTICAL;
+ swipeTracker.connect('begin', this._gestureBegin.bind(this));
+ swipeTracker.connect('update', this._gestureUpdate.bind(this));
+ swipeTracker.connect('end', this._gestureEnd.bind(this));
+ this._swipeTracker = swipeTracker;
}
addSearchProvider(provider) {
@@ -386,6 +399,44 @@ var Overview = class {
this.emit('windows-restacked', stackIndices);
}
+ _gestureBegin(tracker) {
+ this._overview.controls.gestureBegin(tracker);
+ }
+
+ _gestureUpdate(tracker, progress) {
+ if (!this._shown) {
+ Meta.disable_unredirect_for_display(global.display);
+
+ this._shown = true;
+ this._visible = true;
+ this._visibleTarget = true;
+ this._animationInProgress = true;
+
+ Main.layoutManager.overviewGroup.set_child_above_sibling(
+ this._coverPane, null);
+ this._coverPane.show();
+ this.emit('showing');
+
+ Main.layoutManager.showOverview();
+ this._syncGrab();
+ }
+
+ this._overview.controls.gestureProgress(progress);
+ }
+
+ _gestureEnd(tracker, duration, endProgress) {
+ let onComplete;
+ if (endProgress === 0) {
+ this._shown = false;
+ this.emit('hiding');
+ onComplete = () => this._hideDone();
+ } else {
+ onComplete = () => this._showDone();
+ }
+
+ this._overview.controls.gestureEnd(endProgress, duration, onComplete);
+ }
+
beginItemDrag(source) {
this.emit('item-drag-begin', source);
this._inItemDrag = true;
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index dcab0465ca..e869550f5e 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -275,4 +275,43 @@ class ControlsManager extends St.Widget {
get searchEntry() {
return this._searchEntry;
}
+
+ gestureBegin(tracker) {
+ const baseDistance = global.screen_height;
+ const progress = this._adjustment.value;
+ const points = [
+ ControlsState.HIDDEN,
+ ControlsState.WINDOW_PICKER,
+ ControlsState.APP_GRID,
+ ];
+
+ const transition = this._adjustment.get_transition('value');
+ const cancelProgress = transition
+ ? transition.get_interval().peek_final_value()
+ : Math.round(progress);
+
+ tracker.confirmSwipe(baseDistance, points, progress, cancelProgress);
+ this.viewSelector.prepareToEnterOverview();
+ }
+
+ gestureProgress(progress) {
+ this._adjustment.value = progress;
+ }
+
+ gestureEnd(target, duration, onComplete) {
+ this._animating = true;
+
+ if (target === ControlsState.HIDDEN)
+ this.viewSelector.prepareToLeaveOverview();
+
+ this._adjustment.ease(target, {
+ duration,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ onComplete,
+ });
+
+ this.dash.showAppsButton.checked =
+ target === ControlsState.APP_GRID;
+ this._animating = false;
+ }
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]