workspace: Always leave overview when in app grid state
The behavior of workspaces is different depending on whether the overview is in window picker state, or app grid state. When in window picker state, clicking on adjacent workspaces should only activate them, without hiding the overview; and clicking on the active workspace hides the overview. When in app grid state, clicking on a workspace must always hide the overview. Pass the overview adjustment to Workspace, and leave overview if the overview state is bigger than WINDOW_PICKER. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1645>
This commit is contained in:
parent
d6a1414a94
commit
2e817d3fa8
@ -6,6 +6,7 @@ const { Clutter, GLib, GObject, Graphene, Meta, St } = imports.gi;
|
|||||||
const Background = imports.ui.background;
|
const Background = imports.ui.background;
|
||||||
const DND = imports.ui.dnd;
|
const DND = imports.ui.dnd;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
|
const OverviewControls = imports.ui.overviewControls;
|
||||||
const Params = imports.misc.params;
|
const Params = imports.misc.params;
|
||||||
const Util = imports.misc.util;
|
const Util = imports.misc.util;
|
||||||
const { WindowPreview } = imports.ui.windowPreview;
|
const { WindowPreview } = imports.ui.windowPreview;
|
||||||
@ -932,7 +933,7 @@ class WorkspaceBackground extends St.Widget {
|
|||||||
*/
|
*/
|
||||||
var Workspace = GObject.registerClass(
|
var Workspace = GObject.registerClass(
|
||||||
class Workspace extends St.Widget {
|
class Workspace extends St.Widget {
|
||||||
_init(metaWorkspace, monitorIndex) {
|
_init(metaWorkspace, monitorIndex, overviewAdjustment) {
|
||||||
super._init({
|
super._init({
|
||||||
style_class: 'window-picker',
|
style_class: 'window-picker',
|
||||||
pivot_point: new Graphene.Point({ x: 0.5, y: 0.5 }),
|
pivot_point: new Graphene.Point({ x: 0.5, y: 0.5 }),
|
||||||
@ -942,6 +943,7 @@ class Workspace extends St.Widget {
|
|||||||
|
|
||||||
this.metaWorkspace = metaWorkspace;
|
this.metaWorkspace = metaWorkspace;
|
||||||
|
|
||||||
|
this._overviewAdjustment = overviewAdjustment;
|
||||||
this.monitorIndex = monitorIndex;
|
this.monitorIndex = monitorIndex;
|
||||||
this._monitor = Main.layoutManager.monitors[this.monitorIndex];
|
this._monitor = Main.layoutManager.monitors[this.monitorIndex];
|
||||||
|
|
||||||
@ -954,12 +956,15 @@ class Workspace extends St.Widget {
|
|||||||
|
|
||||||
const clickAction = new Clutter.ClickAction();
|
const clickAction = new Clutter.ClickAction();
|
||||||
clickAction.connect('clicked', action => {
|
clickAction.connect('clicked', action => {
|
||||||
// Only switch to the workspace when there's no application
|
// Switch to the workspace when not the active one, leave the
|
||||||
// windows open. The problem is that it's too easy to miss
|
// overview otherwise.
|
||||||
// an app window and get the wrong one focused.
|
if (action.get_button() === 1 || action.get_button() === 0) {
|
||||||
if ((action.get_button() === 1 || action.get_button() === 0) &&
|
const leaveOverview = this._shouldLeaveOverview();
|
||||||
this.isEmpty())
|
|
||||||
Main.overview.hide();
|
this.metaWorkspace?.activate(global.get_current_time());
|
||||||
|
if (leaveOverview)
|
||||||
|
Main.overview.hide();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.bind_property('mapped', clickAction, 'enabled', GObject.BindingFlags.SYNC_CREATE);
|
this.bind_property('mapped', clickAction, 'enabled', GObject.BindingFlags.SYNC_CREATE);
|
||||||
this.add_action(clickAction);
|
this.add_action(clickAction);
|
||||||
@ -995,6 +1000,14 @@ class Workspace extends St.Widget {
|
|||||||
this._delegate = this;
|
this._delegate = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_shouldLeaveOverview() {
|
||||||
|
if (!this.metaWorkspace || this.metaWorkspace.active)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const overviewState = this._overviewAdjustment.value;
|
||||||
|
return overviewState > OverviewControls.ControlsState.WINDOW_PICKER;
|
||||||
|
}
|
||||||
|
|
||||||
vfunc_get_focus_chain() {
|
vfunc_get_focus_chain() {
|
||||||
return this.layout_manager.getFocusChain();
|
return this.layout_manager.getFocusChain();
|
||||||
}
|
}
|
||||||
@ -1267,7 +1280,11 @@ class Workspace extends St.Widget {
|
|||||||
|
|
||||||
_onCloneSelected(clone, time) {
|
_onCloneSelected(clone, time) {
|
||||||
const wsIndex = this.metaWorkspace?.index();
|
const wsIndex = this.metaWorkspace?.index();
|
||||||
Main.activateWindow(clone.metaWindow, time, wsIndex);
|
|
||||||
|
if (this._shouldLeaveOverview())
|
||||||
|
Main.activateWindow(clone.metaWindow, time, wsIndex);
|
||||||
|
else
|
||||||
|
this.metaWorkspace?.activate(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draggable target interface
|
// Draggable target interface
|
||||||
|
@ -449,7 +449,10 @@ class WorkspacesView extends WorkspacesViewBase {
|
|||||||
let workspace;
|
let workspace;
|
||||||
|
|
||||||
if (j >= this._workspaces.length) { /* added */
|
if (j >= this._workspaces.length) { /* added */
|
||||||
workspace = new Workspace.Workspace(metaWorkspace, this._monitorIndex);
|
workspace = new Workspace.Workspace(
|
||||||
|
metaWorkspace,
|
||||||
|
this._monitorIndex,
|
||||||
|
this._overviewAdjustment);
|
||||||
this.add_actor(workspace);
|
this.add_actor(workspace);
|
||||||
this._workspaces[j] = workspace;
|
this._workspaces[j] = workspace;
|
||||||
} else {
|
} else {
|
||||||
@ -540,7 +543,8 @@ var ExtraWorkspaceView = GObject.registerClass(
|
|||||||
class ExtraWorkspaceView extends WorkspacesViewBase {
|
class ExtraWorkspaceView extends WorkspacesViewBase {
|
||||||
_init(monitorIndex, overviewAdjustment) {
|
_init(monitorIndex, overviewAdjustment) {
|
||||||
super._init(monitorIndex, overviewAdjustment);
|
super._init(monitorIndex, overviewAdjustment);
|
||||||
this._workspace = new Workspace.Workspace(null, monitorIndex);
|
this._workspace =
|
||||||
|
new Workspace.Workspace(null, monitorIndex, overviewAdjustment);
|
||||||
this.add_actor(this._workspace);
|
this.add_actor(this._workspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user