finish overview click-to-exit feature

This commit is contained in:
Jason DeRose
2020-08-02 17:52:57 -04:00
parent 2b5f7408ea
commit 01807c168d
4 changed files with 178 additions and 66 deletions

View File

@@ -6125,6 +6125,51 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="clicktoexit_row">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="clicktoexit_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="row_spacing">6</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkSwitch" id="clicktoexit_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="clicktoexit_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Click empty space to close overview</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="group_apps_row">
<property name="width_request">100</property>

View File

@@ -33,6 +33,7 @@ const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const Mainloop = imports.mainloop;
const IconGrid = imports.ui.iconGrid;
const ViewSelector = imports.ui.viewSelector;
const Meta = imports.gi.Meta;
@@ -59,70 +60,9 @@ var dtpOverview = Utils.defineClass({
this._optionalWorkspaceIsolation();
this._optionalHotKeys();
this._optionalNumberOverlay();
this._optionalClickToExit();
this._toggleDash();
Main.overview._overview.reactive = true;
this._clickAction = new Clutter.ClickAction();
this._clickAction.connect('clicked', (obj, obj2) => {
if(this._appPageSwiping)
return;
let visibleView;
Main.overview.viewSelector.appDisplay._views.every(function(v, index) {
if (v.view.actor.visible) {
visibleView = index;
return false;
}
else
return true;
});
if(Main.overview.viewSelector._showAppsButton.checked) {
if(Me.settings.get_boolean('animate-show-apps')) {
let view = Main.overview.viewSelector.appDisplay._views[visibleView].view;
view.animate(IconGrid.AnimationDirection.OUT, Lang.bind(this, function() {
Main.overview.viewSelector._appsPage.hide();
Main.overview.hide();
}));
} else {
Main.overview.hide();
}
} else {
Main.overview.toggle();
}
});
Main.overview._overview.add_action(this._clickAction);
if(Main.overview.viewSelector.appDisplay._views[1].view._swipeTracker) {
this._signalsHandler.add([
Main.overview.viewSelector.appDisplay._views[1].view._swipeTracker,
'begin',
Lang.bind(this, this._onAppPageSwipeBegin)
],[
Main.overview.viewSelector.appDisplay._views[1].view._swipeTracker,
'end',
Lang.bind(this, this._onAppPageSwipeEnd)
]);
} else if(Main.overview.viewSelector.appDisplay._views[1].view._panAction) {
this._signalsHandler.add([
Main.overview.viewSelector.appDisplay._views[1].view._panAction,
'gesture-begin',
Lang.bind(this, this._onAppPageSwipeBegin)
],[
Main.overview.viewSelector.appDisplay._views[1].view._panAction,
'gesture-cancel',
Lang.bind(this, this._onAppPageSwipeEnd)
],[
Main.overview.viewSelector.appDisplay._views[1].view._panAction,
'gesture-end',
Lang.bind(this, this._onAppPageSwipeEnd)
]);
}
this._signalsHandler.add([
Me.settings,
'changed::stockgs-keep-dash',
@@ -133,14 +73,13 @@ var dtpOverview = Utils.defineClass({
disable: function () {
this._signalsHandler.destroy();
this._injectionsHandler.destroy();
Main.overview._overview.remove_action(this._clickAction);
this._toggleDash(true);
// Remove key bindings
this._disableHotKeys();
this._disableExtraShortcut();
this._disableClickToExit();
},
_toggleDash: function(visible) {
@@ -461,9 +400,127 @@ var dtpOverview = Utils.defineClass({
}));
},
_optionalClickToExit: function() {
this._clickToExitEnabled = false;
if (Me.settings.get_boolean('overview-click-to-exit'))
this._enableClickToExit();
this._signalsHandler.add([
Me.settings,
'changed::overview-click-to-exit',
Lang.bind(this, function() {
if (Me.settings.get_boolean('overview-click-to-exit'))
Lang.bind(this, this._enableClickToExit)();
else
Lang.bind(this, this._disableClickToExit)();
})
]);
},
_enableClickToExit: function() {
if (this._clickToExitEnabled)
return;
this._oldOverviewReactive = Main.overview._overview.reactive
Main.overview._overview.reactive = true;
this._clickAction = new Clutter.ClickAction();
this._clickAction.connect('clicked', () => {
if(this._appPageSwiping)
return Clutter.EVENT_PROPAGATE;
let [x, y] = global.get_pointer();
let pickedActor = global.stage.get_actor_at_pos(Clutter.PickMode.ALL, x, y);
let activePage = Main.overview.viewSelector.getActivePage();
if (activePage == ViewSelector.ViewPage.APPS) {
if(pickedActor != Main.overview._overview
&& pickedActor != Main.overview.viewSelector.appDisplay._views[1].view._scrollView
&& pickedActor != Main.overview.viewSelector.appDisplay._views[1].view._grid) {
return Clutter.EVENT_PROPAGATE;
}
let visibleView;
Main.overview.viewSelector.appDisplay._views.every(function(v, index) {
if (v.view.actor.visible) {
visibleView = index;
return false;
}
else
return true;
});
if(Me.settings.get_boolean('animate-show-apps')) {
let view = Main.overview.viewSelector.appDisplay._views[visibleView].view;
view.animate(IconGrid.AnimationDirection.OUT, Lang.bind(this, function() {
Main.overview.viewSelector._appsPage.hide();
Main.overview.hide();
}));
} else {
Main.overview.hide();
}
} else if (activePage == ViewSelector.ViewPage.WINDOWS) {
if(pickedActor == Main.overview._overview._controls._thumbnailsBox
|| pickedActor == Main.overview._overview._controls.dash._container) {
return Clutter.EVENT_PROPAGATE;
}
Main.overview.toggle();
} else {
Main.overview.toggle();
}
});
Main.overview._overview.add_action(this._clickAction);
if(Main.overview.viewSelector.appDisplay._views[1].view._swipeTracker) {
this._signalsHandler.addWithLabel('clickToExit', [
Main.overview.viewSelector.appDisplay._views[1].view._swipeTracker,
'begin',
Lang.bind(this, this._onAppPageSwipeBegin)
],[
Main.overview.viewSelector.appDisplay._views[1].view._swipeTracker,
'end',
Lang.bind(this, this._onAppPageSwipeEnd)
]);
} else if(Main.overview.viewSelector.appDisplay._views[1].view._panAction) {
this._signalsHandler.addWithLabel('clickToExit', [
Main.overview.viewSelector.appDisplay._views[1].view._panAction,
'gesture-begin',
Lang.bind(this, this._onAppPageSwipeBegin)
],[
Main.overview.viewSelector.appDisplay._views[1].view._panAction,
'gesture-cancel',
Lang.bind(this, this._onAppPageSwipeEnd)
],[
Main.overview.viewSelector.appDisplay._views[1].view._panAction,
'gesture-end',
Lang.bind(this, this._onAppPageSwipeEnd)
]);
}
this._clickToExitEnabled = true;
},
_disableClickToExit: function () {
if(!this._clickToExitEnabled)
return;
Main.overview._overview.remove_action(this._clickAction);
Main.overview._overview.reactive = this._oldOverviewReactive;
this._signalsHandler.removeWithLabel('clickToExit');
this._clickToExitEnabled = false;
},
_onAppPageSwipeBegin: function() {
this._appPageSwiping = true;
return true;
return Clutter.EVENT_PROPAGATE;
},
_onAppPageSwipeEnd: function() {
@@ -472,6 +529,6 @@ var dtpOverview = Utils.defineClass({
0,
() => this._appPageSwiping = false
]);
return true;
return Clutter.EVENT_PROPAGATE;
}
});

View File

@@ -1355,6 +1355,11 @@ const Settings = new Lang.Class({
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('overview-click-to-exit',
this._builder.get_object('clicktoexit_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('group-apps',
this._builder.get_object('group_apps_switch'),
'active',

View File

@@ -526,6 +526,11 @@
<default>false</default>
<summary>Provide workspace isolation</summary>
<description>Dash shows only windows from the current workspace</description>
</key>
<key type="b" name="overview-click-to-exit">
<default>false</default>
<summary>Close overview by clicking in empty space</summary>
<description>Close overview or app grid by clicking in empty space</description>
</key>
<key type="b" name="group-apps">
<default>true</default>