2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-01-31 09:07:06 -05:00
|
|
|
/* exported MonitorConstraint, LayoutManager */
|
2011-06-13 09:54:05 -04:00
|
|
|
|
2017-06-08 11:07:56 -04:00
|
|
|
const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi;
|
2022-07-04 18:30:44 -04:00
|
|
|
const Signals = imports.misc.signals;
|
2011-06-13 09:54:05 -04:00
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
const Background = imports.ui.background;
|
|
|
|
const BackgroundMenu = imports.ui.backgroundMenu;
|
|
|
|
|
2012-02-11 05:14:43 -05:00
|
|
|
const DND = imports.ui.dnd;
|
2011-06-13 09:54:05 -04:00
|
|
|
const Main = imports.ui.main;
|
2011-07-25 09:56:51 -04:00
|
|
|
const Params = imports.misc.params;
|
2019-02-21 02:45:17 -05:00
|
|
|
const Ripples = imports.ui.ripples;
|
2011-07-14 08:35:55 -04:00
|
|
|
|
2019-08-01 19:13:10 -04:00
|
|
|
var STARTUP_ANIMATION_TIME = 500;
|
|
|
|
var BACKGROUND_FADE_ANIMATION_TIME = 1000;
|
2011-07-25 14:25:51 -04:00
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels
|
|
|
|
var HOT_CORNER_PRESSURE_TIMEOUT = 1000; // ms
|
2013-03-01 16:19:07 -05:00
|
|
|
|
2021-09-23 03:45:14 -04:00
|
|
|
const SCREEN_TRANSITION_DELAY = 250; // ms
|
|
|
|
const SCREEN_TRANSITION_DURATION = 500; // ms
|
|
|
|
|
2013-02-12 16:00:41 -05:00
|
|
|
function isPopupMetaWindow(actor) {
|
2019-01-28 20:27:05 -05:00
|
|
|
switch (actor.meta_window.get_window_type()) {
|
2013-02-12 16:00:41 -05:00
|
|
|
case Meta.WindowType.DROPDOWN_MENU:
|
|
|
|
case Meta.WindowType.POPUP_MENU:
|
|
|
|
case Meta.WindowType.COMBO:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-30 21:23:39 -04:00
|
|
|
var MonitorConstraint = GObject.registerClass({
|
2019-01-29 13:15:23 -05:00
|
|
|
Properties: {
|
|
|
|
'primary': GObject.ParamSpec.boolean('primary',
|
|
|
|
'Primary', 'Track primary monitor',
|
|
|
|
GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
|
|
|
|
false),
|
|
|
|
'index': GObject.ParamSpec.int('index',
|
|
|
|
'Monitor index', 'Track specific monitor',
|
|
|
|
GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
|
|
|
|
-1, 64, -1),
|
|
|
|
'work-area': GObject.ParamSpec.boolean('work-area',
|
|
|
|
'Work-area', 'Track monitor\'s work-area',
|
|
|
|
GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
|
2019-08-20 17:43:54 -04:00
|
|
|
false),
|
2019-01-29 13:15:23 -05:00
|
|
|
},
|
2017-10-30 21:23:39 -04:00
|
|
|
}, class MonitorConstraint extends Clutter.Constraint {
|
2017-10-30 20:03:21 -04:00
|
|
|
_init(props) {
|
2012-08-14 09:37:12 -04:00
|
|
|
this._primary = false;
|
|
|
|
this._index = -1;
|
2015-02-06 13:27:02 -05:00
|
|
|
this._workArea = false;
|
2012-08-14 09:37:12 -04:00
|
|
|
|
2017-10-30 21:23:39 -04:00
|
|
|
super._init(props);
|
|
|
|
}
|
2012-08-14 09:37:12 -04:00
|
|
|
|
|
|
|
get primary() {
|
|
|
|
return this._primary;
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-08-14 09:37:12 -04:00
|
|
|
|
|
|
|
set primary(v) {
|
2012-10-14 12:34:22 -04:00
|
|
|
if (v)
|
|
|
|
this._index = -1;
|
2012-08-14 09:37:12 -04:00
|
|
|
this._primary = v;
|
|
|
|
if (this.actor)
|
|
|
|
this.actor.queue_relayout();
|
|
|
|
this.notify('primary');
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-08-14 09:37:12 -04:00
|
|
|
|
|
|
|
get index() {
|
|
|
|
return this._index;
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-08-14 09:37:12 -04:00
|
|
|
|
|
|
|
set index(v) {
|
2012-10-14 12:34:22 -04:00
|
|
|
this._primary = false;
|
2012-08-14 09:37:12 -04:00
|
|
|
this._index = v;
|
|
|
|
if (this.actor)
|
|
|
|
this.actor.queue_relayout();
|
|
|
|
this.notify('index');
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-08-14 09:37:12 -04:00
|
|
|
|
2021-01-29 20:03:07 -05:00
|
|
|
get workArea() {
|
2015-02-06 13:27:02 -05:00
|
|
|
return this._workArea;
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2015-02-06 13:27:02 -05:00
|
|
|
|
2021-01-29 20:03:07 -05:00
|
|
|
set workArea(v) {
|
2015-02-06 13:27:02 -05:00
|
|
|
if (v == this._workArea)
|
|
|
|
return;
|
|
|
|
this._workArea = v;
|
|
|
|
if (this.actor)
|
|
|
|
this.actor.queue_relayout();
|
|
|
|
this.notify('work-area');
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2015-02-06 13:27:02 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_set_actor(actor) {
|
2012-08-14 09:37:12 -04:00
|
|
|
if (actor) {
|
|
|
|
if (!this._monitorsChangedId) {
|
2017-10-30 20:38:18 -04:00
|
|
|
this._monitorsChangedId =
|
|
|
|
Main.layoutManager.connect('monitors-changed', () => {
|
|
|
|
this.actor.queue_relayout();
|
|
|
|
});
|
2012-08-14 09:37:12 -04:00
|
|
|
}
|
2015-02-06 13:27:02 -05:00
|
|
|
|
|
|
|
if (!this._workareasChangedId) {
|
2017-10-30 20:38:18 -04:00
|
|
|
this._workareasChangedId =
|
2018-01-03 02:55:38 -05:00
|
|
|
global.display.connect('workareas-changed', () => {
|
2017-10-30 20:38:18 -04:00
|
|
|
if (this._workArea)
|
|
|
|
this.actor.queue_relayout();
|
|
|
|
});
|
2015-02-06 13:27:02 -05:00
|
|
|
}
|
2012-08-14 09:37:12 -04:00
|
|
|
} else {
|
|
|
|
if (this._monitorsChangedId)
|
|
|
|
Main.layoutManager.disconnect(this._monitorsChangedId);
|
|
|
|
this._monitorsChangedId = 0;
|
2015-02-06 13:27:02 -05:00
|
|
|
|
|
|
|
if (this._workareasChangedId)
|
2018-01-03 02:55:38 -05:00
|
|
|
global.display.disconnect(this._workareasChangedId);
|
2015-02-06 13:27:02 -05:00
|
|
|
this._workareasChangedId = 0;
|
2012-08-14 09:37:12 -04:00
|
|
|
}
|
|
|
|
|
2017-10-30 21:23:39 -04:00
|
|
|
super.vfunc_set_actor(actor);
|
|
|
|
}
|
2012-08-14 09:37:12 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_update_allocation(actor, actorBox) {
|
2012-08-14 09:37:12 -04:00
|
|
|
if (!this._primary && this._index < 0)
|
|
|
|
return;
|
|
|
|
|
2017-04-12 02:46:54 -04:00
|
|
|
if (!Main.layoutManager.primaryMonitor)
|
|
|
|
return;
|
|
|
|
|
2015-02-06 13:27:02 -05:00
|
|
|
let index;
|
|
|
|
if (this._primary)
|
|
|
|
index = Main.layoutManager.primaryIndex;
|
|
|
|
else
|
|
|
|
index = Math.min(this._index, Main.layoutManager.monitors.length - 1);
|
|
|
|
|
|
|
|
let rect;
|
|
|
|
if (this._workArea) {
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let ws = workspaceManager.get_workspace_by_index(0);
|
2015-02-06 13:27:02 -05:00
|
|
|
rect = ws.get_work_area_for_monitor(index);
|
2012-08-14 09:37:12 -04:00
|
|
|
} else {
|
2015-02-06 13:27:02 -05:00
|
|
|
rect = Main.layoutManager.monitors[index];
|
2012-08-14 09:37:12 -04:00
|
|
|
}
|
|
|
|
|
2015-02-06 13:27:02 -05:00
|
|
|
actorBox.init_rect(rect.x, rect.y, rect.width, rect.height);
|
2012-08-14 09:37:12 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-10-30 21:19:44 -04:00
|
|
|
var Monitor = class Monitor {
|
2019-01-31 08:43:52 -05:00
|
|
|
constructor(index, geometry, geometryScale) {
|
2013-03-18 15:02:05 -04:00
|
|
|
this.index = index;
|
|
|
|
this.x = geometry.x;
|
|
|
|
this.y = geometry.y;
|
|
|
|
this.width = geometry.width;
|
|
|
|
this.height = geometry.height;
|
2019-01-31 08:43:52 -05:00
|
|
|
this.geometry_scale = geometryScale;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-03-18 15:02:05 -04:00
|
|
|
|
|
|
|
get inFullscreen() {
|
2018-01-03 02:55:38 -05:00
|
|
|
return global.display.get_monitor_in_fullscreen(this.index);
|
2013-03-18 15:02:05 -04:00
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
};
|
2013-03-18 15:02:05 -04:00
|
|
|
|
2019-03-05 05:34:27 -05:00
|
|
|
const UiActor = GObject.registerClass(
|
|
|
|
class UiActor extends St.Widget {
|
2019-08-19 13:55:49 -04:00
|
|
|
vfunc_get_preferred_width(_forHeight) {
|
2019-03-05 05:34:27 -05:00
|
|
|
let width = global.stage.width;
|
|
|
|
return [width, width];
|
|
|
|
}
|
|
|
|
|
2019-08-19 13:55:49 -04:00
|
|
|
vfunc_get_preferred_height(_forWidth) {
|
2019-03-05 05:34:27 -05:00
|
|
|
let height = global.stage.height;
|
|
|
|
return [height, height];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-01-27 23:34:33 -05:00
|
|
|
const defaultParams = {
|
|
|
|
trackFullscreen: false,
|
|
|
|
affectsStruts: false,
|
2019-08-20 17:43:54 -04:00
|
|
|
affectsInputRegion: true,
|
2013-01-27 23:34:33 -05:00
|
|
|
};
|
|
|
|
|
2017-10-30 21:23:39 -04:00
|
|
|
var LayoutManager = GObject.registerClass({
|
2021-02-11 08:10:48 -05:00
|
|
|
Signals: {
|
|
|
|
'hot-corners-changed': {},
|
|
|
|
'startup-complete': {},
|
|
|
|
'startup-prepared': {},
|
|
|
|
'monitors-changed': {},
|
|
|
|
'system-modal-opened': {},
|
|
|
|
},
|
2017-10-30 21:23:39 -04:00
|
|
|
}, class LayoutManager extends GObject.Object {
|
2017-10-30 20:03:21 -04:00
|
|
|
_init() {
|
2017-10-30 21:23:39 -04:00
|
|
|
super._init();
|
2018-08-21 06:13:30 -04:00
|
|
|
|
2019-08-19 15:38:51 -04:00
|
|
|
this._rtl = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL;
|
2011-06-13 09:54:05 -04:00
|
|
|
this.monitors = [];
|
|
|
|
this.primaryMonitor = null;
|
|
|
|
this.primaryIndex = -1;
|
2013-03-01 16:00:37 -05:00
|
|
|
this.hotCorners = [];
|
|
|
|
|
2012-10-14 12:57:45 -04:00
|
|
|
this._keyboardIndex = -1;
|
2012-07-30 13:02:33 -04:00
|
|
|
this._rightPanelBarrier = null;
|
2011-07-25 09:53:19 -04:00
|
|
|
|
2013-01-27 23:34:33 -05:00
|
|
|
this._inOverview = false;
|
|
|
|
this._updateRegionIdle = 0;
|
|
|
|
|
|
|
|
this._trackedActors = [];
|
2013-03-12 15:27:51 -04:00
|
|
|
this._topActors = [];
|
2013-02-12 16:00:41 -05:00
|
|
|
this._isPopupWindowVisible = false;
|
2013-02-19 20:20:44 -05:00
|
|
|
this._startingUp = true;
|
2017-04-12 02:46:54 -04:00
|
|
|
this._pendingLoadBackground = false;
|
2011-07-25 14:25:51 -04:00
|
|
|
|
2013-01-10 16:02:20 -05:00
|
|
|
// Set up stage hierarchy to group all UI actors under one container.
|
2019-03-05 05:34:27 -05:00
|
|
|
this.uiGroup = new UiActor({ name: 'uiGroup' });
|
2018-08-10 15:37:48 -04:00
|
|
|
this.uiGroup.set_flags(Clutter.ActorFlags.NO_LAYOUT);
|
2013-01-10 16:02:20 -05:00
|
|
|
|
2019-05-03 17:39:11 -04:00
|
|
|
global.stage.add_child(this.uiGroup);
|
|
|
|
|
2013-02-13 12:30:26 -05:00
|
|
|
global.stage.remove_actor(global.window_group);
|
|
|
|
this.uiGroup.add_actor(global.window_group);
|
2022-08-17 10:30:53 -04:00
|
|
|
global.connect('shutdown', () => {
|
|
|
|
const adoptedUiGroupActors = [
|
|
|
|
global.window_group,
|
|
|
|
global.top_window_group,
|
|
|
|
Meta.get_feedback_group_for_display(global.display),
|
|
|
|
];
|
|
|
|
|
|
|
|
for (let adoptedActor of adoptedUiGroupActors) {
|
|
|
|
this.uiGroup.remove_actor(adoptedActor);
|
|
|
|
global.stage.add_actor(adoptedActor);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.uiGroup.destroy();
|
|
|
|
});
|
2013-01-10 16:02:20 -05:00
|
|
|
|
2019-05-03 17:39:11 -04:00
|
|
|
// Using addChrome() to add actors to uiGroup will position actors
|
|
|
|
// underneath the top_window_group.
|
|
|
|
// To insert actors at the top of uiGroup, we use addTopChrome() or
|
|
|
|
// add the actor directly using uiGroup.add_actor().
|
|
|
|
global.stage.remove_actor(global.top_window_group);
|
|
|
|
this.uiGroup.add_actor(global.top_window_group);
|
2013-01-10 16:02:20 -05:00
|
|
|
|
2020-03-29 17:51:13 -04:00
|
|
|
this.overviewGroup = new St.Widget({
|
|
|
|
name: 'overviewGroup',
|
|
|
|
visible: false,
|
|
|
|
reactive: true,
|
2022-06-30 09:36:47 -04:00
|
|
|
constraints: new Clutter.BindConstraint({
|
|
|
|
source: this.uiGroup,
|
|
|
|
coordinate: Clutter.BindCoordinate.ALL,
|
|
|
|
}),
|
2020-03-29 17:51:13 -04:00
|
|
|
});
|
2013-05-22 12:05:24 -04:00
|
|
|
this.addChrome(this.overviewGroup);
|
|
|
|
|
2019-02-12 09:02:09 -05:00
|
|
|
this.screenShieldGroup = new St.Widget({
|
|
|
|
name: 'screenShieldGroup',
|
|
|
|
visible: false,
|
|
|
|
clip_to_allocation: true,
|
|
|
|
layout_manager: new Clutter.BinLayout(),
|
2022-06-30 09:29:55 -04:00
|
|
|
constraints: new Clutter.BindConstraint({
|
|
|
|
source: this.uiGroup,
|
|
|
|
coordinate: Clutter.BindCoordinate.ALL,
|
|
|
|
}),
|
2019-02-12 09:02:09 -05:00
|
|
|
});
|
2019-06-04 14:55:29 -04:00
|
|
|
this.addChrome(this.screenShieldGroup);
|
2012-05-22 18:27:06 -04:00
|
|
|
|
2020-03-29 17:51:13 -04:00
|
|
|
this.panelBox = new St.BoxLayout({
|
|
|
|
name: 'panelBox',
|
|
|
|
vertical: true,
|
|
|
|
});
|
|
|
|
this.addChrome(this.panelBox, {
|
|
|
|
affectsStruts: true,
|
|
|
|
trackFullscreen: true,
|
|
|
|
});
|
2020-05-09 15:37:18 -04:00
|
|
|
this.panelBox.connect('notify::allocation',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._panelBoxChanged.bind(this));
|
2011-07-25 14:25:51 -04:00
|
|
|
|
2020-03-29 17:51:13 -04:00
|
|
|
this.modalDialogGroup = new St.Widget({
|
|
|
|
name: 'modalDialogGroup',
|
|
|
|
layout_manager: new Clutter.BinLayout(),
|
|
|
|
});
|
2014-03-18 09:44:44 -04:00
|
|
|
this.uiGroup.add_actor(this.modalDialogGroup);
|
|
|
|
|
2020-03-29 17:51:13 -04:00
|
|
|
this.keyboardBox = new St.BoxLayout({
|
|
|
|
name: 'keyboardBox',
|
|
|
|
reactive: true,
|
|
|
|
track_hover: true,
|
|
|
|
});
|
2019-05-03 17:39:11 -04:00
|
|
|
this.addTopChrome(this.keyboardBox);
|
2011-09-01 11:37:54 -04:00
|
|
|
this._keyboardHeightNotifyId = 0;
|
2011-07-25 14:25:51 -04:00
|
|
|
|
2021-08-16 03:16:19 -04:00
|
|
|
this.screenshotUIGroup = new St.Widget({
|
|
|
|
name: 'screenshotUIGroup',
|
|
|
|
layout_manager: new Clutter.BinLayout(),
|
|
|
|
});
|
|
|
|
this.addTopChrome(this.screenshotUIGroup);
|
|
|
|
|
2013-02-15 04:56:34 -05:00
|
|
|
// A dummy actor that tracks the mouse or text cursor, based on the
|
2014-04-11 10:12:52 -04:00
|
|
|
// position and size set in setDummyCursorGeometry.
|
2019-03-04 18:39:54 -05:00
|
|
|
this.dummyCursor = new St.Widget({ width: 0, height: 0, opacity: 0 });
|
2013-02-15 04:56:34 -05:00
|
|
|
this.uiGroup.add_actor(this.dummyCursor);
|
|
|
|
|
2018-01-03 02:55:38 -05:00
|
|
|
let feedbackGroup = Meta.get_feedback_group_for_display(global.display);
|
2014-10-06 20:07:59 -04:00
|
|
|
global.stage.remove_actor(feedbackGroup);
|
|
|
|
this.uiGroup.add_actor(feedbackGroup);
|
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
this._backgroundGroup = new Meta.BackgroundGroup();
|
|
|
|
global.window_group.add_child(this._backgroundGroup);
|
2019-11-05 14:17:19 -05:00
|
|
|
global.window_group.set_child_below_sibling(this._backgroundGroup, null);
|
2012-12-24 09:20:39 -05:00
|
|
|
this._bgManagers = [];
|
|
|
|
|
2017-06-08 11:07:56 -04:00
|
|
|
this._interfaceSettings = new Gio.Settings({
|
2019-08-20 17:43:54 -04:00
|
|
|
schema_id: 'org.gnome.desktop.interface',
|
2017-06-08 11:07:56 -04:00
|
|
|
});
|
|
|
|
|
2019-07-10 21:01:40 -04:00
|
|
|
this._interfaceSettings.connect('changed::enable-hot-corners',
|
|
|
|
this._updateHotCorners.bind(this));
|
2017-06-08 11:07:56 -04:00
|
|
|
|
2013-01-27 23:34:33 -05:00
|
|
|
// Need to update struts on new workspaces when they are added
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
workspaceManager.connect('notify::n-workspaces',
|
|
|
|
this._queueUpdateRegions.bind(this));
|
|
|
|
|
|
|
|
let display = global.display;
|
|
|
|
display.connect('restacked',
|
|
|
|
this._windowsRestacked.bind(this));
|
|
|
|
display.connect('in-fullscreen-changed',
|
|
|
|
this._updateFullscreen.bind(this));
|
|
|
|
|
|
|
|
let monitorManager = Meta.MonitorManager.get();
|
|
|
|
monitorManager.connect('monitors-changed',
|
|
|
|
this._monitorsChanged.bind(this));
|
2011-07-25 14:25:51 -04:00
|
|
|
this._monitorsChanged();
|
2021-09-23 03:45:14 -04:00
|
|
|
|
|
|
|
this.screenTransition = new ScreenTransition();
|
|
|
|
this.uiGroup.add_child(this.screenTransition);
|
|
|
|
this.screenTransition.add_constraint(new Clutter.BindConstraint({
|
|
|
|
source: this.uiGroup,
|
|
|
|
coordinate: Clutter.BindCoordinate.ALL,
|
|
|
|
}));
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-06-13 09:54:05 -04:00
|
|
|
|
2013-05-22 12:05:24 -04:00
|
|
|
// This is called by Main after everything else is constructed
|
2017-10-30 20:03:21 -04:00
|
|
|
init() {
|
2017-12-01 19:27:35 -05:00
|
|
|
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
|
2013-03-06 17:55:33 -05:00
|
|
|
|
2013-05-18 19:34:35 -04:00
|
|
|
this._loadBackground();
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2013-01-27 23:34:33 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
showOverview() {
|
2013-05-22 12:05:24 -04:00
|
|
|
this.overviewGroup.show();
|
2021-09-23 03:45:14 -04:00
|
|
|
this.screenTransition.hide();
|
2013-05-22 12:05:24 -04:00
|
|
|
|
2013-01-27 23:34:33 -05:00
|
|
|
this._inOverview = true;
|
|
|
|
this._updateVisibility();
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 14:25:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
hideOverview() {
|
2013-05-22 12:05:24 -04:00
|
|
|
this.overviewGroup.hide();
|
2021-09-23 03:45:14 -04:00
|
|
|
this.screenTransition.hide();
|
2013-05-22 12:05:24 -04:00
|
|
|
|
2013-01-27 23:34:33 -05:00
|
|
|
this._inOverview = false;
|
|
|
|
this._updateVisibility();
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2013-01-27 23:34:33 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_sessionUpdated() {
|
2013-01-27 23:34:33 -05:00
|
|
|
this._updateVisibility();
|
|
|
|
this._queueUpdateRegions();
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-06-13 09:54:05 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateMonitors() {
|
2018-01-03 02:55:38 -05:00
|
|
|
let display = global.display;
|
2011-06-13 09:54:05 -04:00
|
|
|
|
|
|
|
this.monitors = [];
|
2018-01-03 02:55:38 -05:00
|
|
|
let nMonitors = display.get_n_monitors();
|
2019-08-19 20:51:42 -04:00
|
|
|
for (let i = 0; i < nMonitors; i++) {
|
2017-08-03 09:51:42 -04:00
|
|
|
this.monitors.push(new Monitor(i,
|
|
|
|
display.get_monitor_geometry(i),
|
|
|
|
display.get_monitor_scale(i)));
|
2019-08-19 20:51:42 -04:00
|
|
|
}
|
2011-06-13 09:54:05 -04:00
|
|
|
|
2017-04-12 02:46:54 -04:00
|
|
|
if (nMonitors == 0) {
|
|
|
|
this.primaryIndex = this.bottomIndex = -1;
|
|
|
|
} else if (nMonitors == 1) {
|
2011-06-13 10:37:10 -04:00
|
|
|
this.primaryIndex = this.bottomIndex = 0;
|
|
|
|
} else {
|
|
|
|
// If there are monitors below the primary, then we need
|
|
|
|
// to split primary from bottom.
|
2018-01-03 02:55:38 -05:00
|
|
|
this.primaryIndex = this.bottomIndex = display.get_primary_monitor();
|
2011-06-13 10:37:10 -04:00
|
|
|
for (let i = 0; i < this.monitors.length; i++) {
|
|
|
|
let monitor = this.monitors[i];
|
|
|
|
if (this._isAboveOrBelowPrimary(monitor)) {
|
|
|
|
if (monitor.y > this.monitors[this.bottomIndex].y)
|
|
|
|
this.bottomIndex = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-12 02:46:54 -04:00
|
|
|
if (this.primaryIndex != -1) {
|
|
|
|
this.primaryMonitor = this.monitors[this.primaryIndex];
|
|
|
|
this.bottomMonitor = this.monitors[this.bottomIndex];
|
|
|
|
|
|
|
|
if (this._pendingLoadBackground) {
|
|
|
|
this._loadBackground();
|
|
|
|
this._pendingLoadBackground = false;
|
|
|
|
}
|
2017-10-06 20:26:24 -04:00
|
|
|
} else {
|
|
|
|
this.primaryMonitor = null;
|
|
|
|
this.bottomMonitor = null;
|
2017-04-12 02:46:54 -04:00
|
|
|
}
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-06-13 09:54:05 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateHotCorners() {
|
2011-06-13 09:54:05 -04:00
|
|
|
// destroy old hot corners
|
2017-10-30 20:38:18 -04:00
|
|
|
this.hotCorners.forEach(corner => {
|
2013-03-19 15:50:16 -04:00
|
|
|
if (corner)
|
|
|
|
corner.destroy();
|
|
|
|
});
|
2013-03-01 16:00:37 -05:00
|
|
|
this.hotCorners = [];
|
2011-06-13 09:54:05 -04:00
|
|
|
|
2017-06-08 11:07:56 -04:00
|
|
|
if (!this._interfaceSettings.get_boolean('enable-hot-corners')) {
|
|
|
|
this.emit('hot-corners-changed');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-01 15:07:11 -05:00
|
|
|
let size = this.panelBox.height;
|
|
|
|
|
2011-06-13 09:54:05 -04:00
|
|
|
// build new hot corners
|
|
|
|
for (let i = 0; i < this.monitors.length; i++) {
|
|
|
|
let monitor = this.monitors[i];
|
|
|
|
let cornerX = this._rtl ? monitor.x + monitor.width : monitor.x;
|
|
|
|
let cornerY = monitor.y;
|
|
|
|
|
2013-03-19 15:50:16 -04:00
|
|
|
let haveTopLeftCorner = true;
|
2011-06-13 09:54:05 -04:00
|
|
|
|
2013-03-19 15:50:16 -04:00
|
|
|
if (i != this.primaryIndex) {
|
2013-03-01 16:00:37 -05:00
|
|
|
// Check if we have a top left (right for RTL) corner.
|
|
|
|
// I.e. if there is no monitor directly above or to the left(right)
|
|
|
|
let besideX = this._rtl ? monitor.x + 1 : cornerX - 1;
|
|
|
|
let besideY = cornerY;
|
|
|
|
let aboveX = cornerX;
|
|
|
|
let aboveY = cornerY - 1;
|
2011-07-14 08:35:55 -04:00
|
|
|
|
2013-03-01 16:00:37 -05:00
|
|
|
for (let j = 0; j < this.monitors.length; j++) {
|
|
|
|
if (i == j)
|
|
|
|
continue;
|
|
|
|
let otherMonitor = this.monitors[j];
|
|
|
|
if (besideX >= otherMonitor.x &&
|
|
|
|
besideX < otherMonitor.x + otherMonitor.width &&
|
|
|
|
besideY >= otherMonitor.y &&
|
|
|
|
besideY < otherMonitor.y + otherMonitor.height) {
|
|
|
|
haveTopLeftCorner = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (aboveX >= otherMonitor.x &&
|
|
|
|
aboveX < otherMonitor.x + otherMonitor.width &&
|
|
|
|
aboveY >= otherMonitor.y &&
|
|
|
|
aboveY < otherMonitor.y + otherMonitor.height) {
|
|
|
|
haveTopLeftCorner = false;
|
|
|
|
break;
|
|
|
|
}
|
2011-06-13 09:54:05 -04:00
|
|
|
}
|
2013-03-01 16:00:37 -05:00
|
|
|
}
|
2011-06-13 09:54:05 -04:00
|
|
|
|
2013-03-19 15:50:16 -04:00
|
|
|
if (haveTopLeftCorner) {
|
|
|
|
let corner = new HotCorner(this, monitor, cornerX, cornerY);
|
|
|
|
corner.setBarrierSize(size);
|
|
|
|
this.hotCorners.push(corner);
|
|
|
|
} else {
|
|
|
|
this.hotCorners.push(null);
|
|
|
|
}
|
2011-06-13 09:54:05 -04:00
|
|
|
}
|
2013-03-01 16:00:37 -05:00
|
|
|
|
|
|
|
this.emit('hot-corners-changed');
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-06-13 09:54:05 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_addBackgroundMenu(bgManager) {
|
2014-08-11 12:15:45 -04:00
|
|
|
BackgroundMenu.addBackgroundMenu(bgManager.backgroundActor, this);
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
layout: Fix several issues with the background management code
If monitor-changed fires at startup, it will destroy all of the
backgrounds, but since this._isStartup is true, won't recreate any
of them. Additionally, since _bgManagers is indexed by monitor index,
if the primary index is not 0, it could become a sparse array (e.g.
[undefined, undefined, primaryBackground]), and our for loop will
crash trying to access properties of undefined.
Fix both of these issues by always creating background managers for
every monitor, hiding them on startup but only showing them after
the startup animation is complete.
One thing we need to watch out for is that while LayoutManager is
constructing, Main.uiGroup / Main.layoutManager will be undefined,
so addBackgroundMenu will fail. Fix this by passing down the uiGroup
to the background menu code.
https://bugzilla.gnome.org/show_bug.cgi?id=709313
2013-11-07 17:14:47 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_createBackgroundManager(monitorIndex) {
|
2020-03-29 17:51:13 -04:00
|
|
|
const bgManager = new Background.BackgroundManager({
|
|
|
|
container: this._backgroundGroup,
|
|
|
|
layoutManager: this,
|
|
|
|
monitorIndex,
|
|
|
|
});
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2017-12-01 19:27:35 -05:00
|
|
|
bgManager.connect('changed', this._addBackgroundMenu.bind(this));
|
layout: Fix several issues with the background management code
If monitor-changed fires at startup, it will destroy all of the
backgrounds, but since this._isStartup is true, won't recreate any
of them. Additionally, since _bgManagers is indexed by monitor index,
if the primary index is not 0, it could become a sparse array (e.g.
[undefined, undefined, primaryBackground]), and our for loop will
crash trying to access properties of undefined.
Fix both of these issues by always creating background managers for
every monitor, hiding them on startup but only showing them after
the startup animation is complete.
One thing we need to watch out for is that while LayoutManager is
constructing, Main.uiGroup / Main.layoutManager will be undefined,
so addBackgroundMenu will fail. Fix this by passing down the uiGroup
to the background menu code.
https://bugzilla.gnome.org/show_bug.cgi?id=709313
2013-11-07 17:14:47 -05:00
|
|
|
this._addBackgroundMenu(bgManager);
|
2012-12-24 09:20:39 -05:00
|
|
|
|
layout: Fix several issues with the background management code
If monitor-changed fires at startup, it will destroy all of the
backgrounds, but since this._isStartup is true, won't recreate any
of them. Additionally, since _bgManagers is indexed by monitor index,
if the primary index is not 0, it could become a sparse array (e.g.
[undefined, undefined, primaryBackground]), and our for loop will
crash trying to access properties of undefined.
Fix both of these issues by always creating background managers for
every monitor, hiding them on startup but only showing them after
the startup animation is complete.
One thing we need to watch out for is that while LayoutManager is
constructing, Main.uiGroup / Main.layoutManager will be undefined,
so addBackgroundMenu will fail. Fix this by passing down the uiGroup
to the background menu code.
https://bugzilla.gnome.org/show_bug.cgi?id=709313
2013-11-07 17:14:47 -05:00
|
|
|
return bgManager;
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_showSecondaryBackgrounds() {
|
2012-12-24 09:20:39 -05:00
|
|
|
for (let i = 0; i < this.monitors.length; i++) {
|
|
|
|
if (i != this.primaryIndex) {
|
2014-08-11 12:15:45 -04:00
|
|
|
let backgroundActor = this._bgManagers[i].backgroundActor;
|
|
|
|
backgroundActor.show();
|
|
|
|
backgroundActor.opacity = 0;
|
2018-07-20 15:46:19 -04:00
|
|
|
backgroundActor.ease({
|
|
|
|
opacity: 255,
|
|
|
|
duration: BACKGROUND_FADE_ANIMATION_TIME,
|
2019-08-20 17:43:54 -04:00
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2018-07-20 15:46:19 -04:00
|
|
|
});
|
2012-12-24 09:20:39 -05:00
|
|
|
}
|
|
|
|
}
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2020-07-20 20:00:32 -04:00
|
|
|
_waitLoaded(bgManager) {
|
|
|
|
return new Promise(resolve => {
|
|
|
|
const id = bgManager.connect('loaded', () => {
|
|
|
|
bgManager.disconnect(id);
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateBackgrounds() {
|
2019-08-19 20:20:08 -04:00
|
|
|
for (let i = 0; i < this._bgManagers.length; i++)
|
2012-12-24 09:20:39 -05:00
|
|
|
this._bgManagers[i].destroy();
|
|
|
|
|
|
|
|
this._bgManagers = [];
|
|
|
|
|
|
|
|
if (Main.sessionMode.isGreeter)
|
2020-07-20 20:00:32 -04:00
|
|
|
return Promise.resolve();
|
2012-12-24 09:20:39 -05:00
|
|
|
|
|
|
|
for (let i = 0; i < this.monitors.length; i++) {
|
layout: Fix several issues with the background management code
If monitor-changed fires at startup, it will destroy all of the
backgrounds, but since this._isStartup is true, won't recreate any
of them. Additionally, since _bgManagers is indexed by monitor index,
if the primary index is not 0, it could become a sparse array (e.g.
[undefined, undefined, primaryBackground]), and our for loop will
crash trying to access properties of undefined.
Fix both of these issues by always creating background managers for
every monitor, hiding them on startup but only showing them after
the startup animation is complete.
One thing we need to watch out for is that while LayoutManager is
constructing, Main.uiGroup / Main.layoutManager will be undefined,
so addBackgroundMenu will fail. Fix this by passing down the uiGroup
to the background menu code.
https://bugzilla.gnome.org/show_bug.cgi?id=709313
2013-11-07 17:14:47 -05:00
|
|
|
let bgManager = this._createBackgroundManager(i);
|
|
|
|
this._bgManagers.push(bgManager);
|
|
|
|
|
|
|
|
if (i != this.primaryIndex && this._startingUp)
|
2014-08-11 12:15:45 -04:00
|
|
|
bgManager.backgroundActor.hide();
|
2012-12-24 09:20:39 -05:00
|
|
|
}
|
2020-07-20 20:00:32 -04:00
|
|
|
|
|
|
|
return Promise.all(this._bgManagers.map(this._waitLoaded));
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateKeyboardBox() {
|
2014-07-26 11:45:10 -04:00
|
|
|
this.keyboardBox.set_position(this.keyboardMonitor.x,
|
|
|
|
this.keyboardMonitor.y + this.keyboardMonitor.height);
|
|
|
|
this.keyboardBox.set_size(this.keyboardMonitor.width, -1);
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2014-07-26 11:45:10 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateBoxes() {
|
2017-04-12 02:46:54 -04:00
|
|
|
if (!this.primaryMonitor)
|
|
|
|
return;
|
|
|
|
|
2011-07-25 14:25:51 -04:00
|
|
|
this.panelBox.set_position(this.primaryMonitor.x, this.primaryMonitor.y);
|
|
|
|
this.panelBox.set_size(this.primaryMonitor.width, -1);
|
|
|
|
|
2014-10-13 11:43:39 -04:00
|
|
|
this.keyboardIndex = this.primaryIndex;
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 14:25:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_panelBoxChanged() {
|
2013-03-01 15:07:11 -05:00
|
|
|
this._updatePanelBarrier();
|
2012-12-03 15:56:18 -05:00
|
|
|
|
2013-03-01 15:07:11 -05:00
|
|
|
let size = this.panelBox.height;
|
2017-10-30 20:38:18 -04:00
|
|
|
this.hotCorners.forEach(corner => {
|
2013-03-19 15:50:16 -04:00
|
|
|
if (corner)
|
|
|
|
corner.setBarrierSize(size);
|
2013-03-01 15:07:11 -05:00
|
|
|
});
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-07-30 13:02:33 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updatePanelBarrier() {
|
2012-07-30 13:02:33 -04:00
|
|
|
if (this._rightPanelBarrier) {
|
|
|
|
this._rightPanelBarrier.destroy();
|
|
|
|
this._rightPanelBarrier = null;
|
|
|
|
}
|
2011-07-25 14:25:51 -04:00
|
|
|
|
2017-04-12 02:46:54 -04:00
|
|
|
if (!this.primaryMonitor)
|
|
|
|
return;
|
|
|
|
|
2011-07-25 14:25:51 -04:00
|
|
|
if (this.panelBox.height) {
|
|
|
|
let primary = this.primaryMonitor;
|
2012-07-30 13:02:33 -04:00
|
|
|
|
2020-03-29 17:51:13 -04:00
|
|
|
this._rightPanelBarrier = new Meta.Barrier({
|
|
|
|
display: global.display,
|
|
|
|
x1: primary.x + primary.width, y1: primary.y,
|
|
|
|
x2: primary.x + primary.width, y2: primary.y + this.panelBox.height,
|
|
|
|
directions: Meta.BarrierDirection.NEGATIVE_X,
|
|
|
|
});
|
2011-07-25 14:25:51 -04:00
|
|
|
}
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 14:25:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_monitorsChanged() {
|
2011-06-13 09:54:05 -04:00
|
|
|
this._updateMonitors();
|
2011-07-25 14:25:51 -04:00
|
|
|
this._updateBoxes();
|
2011-06-13 09:54:05 -04:00
|
|
|
this._updateHotCorners();
|
2012-12-24 09:20:39 -05:00
|
|
|
this._updateBackgrounds();
|
2013-01-27 23:34:33 -05:00
|
|
|
this._updateFullscreen();
|
|
|
|
this._updateVisibility();
|
|
|
|
this._queueUpdateRegions();
|
2011-06-13 09:54:05 -04:00
|
|
|
|
|
|
|
this.emit('monitors-changed');
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-06-13 09:54:05 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_isAboveOrBelowPrimary(monitor) {
|
2011-06-13 10:37:10 -04:00
|
|
|
let primary = this.monitors[this.primaryIndex];
|
|
|
|
let monitorLeft = monitor.x, monitorRight = monitor.x + monitor.width;
|
|
|
|
let primaryLeft = primary.x, primaryRight = primary.x + primary.width;
|
|
|
|
|
2011-10-10 13:21:18 -04:00
|
|
|
if ((monitorLeft >= primaryLeft && monitorLeft < primaryRight) ||
|
|
|
|
(monitorRight > primaryLeft && monitorRight <= primaryRight) ||
|
|
|
|
(primaryLeft >= monitorLeft && primaryLeft < monitorRight) ||
|
|
|
|
(primaryRight > monitorLeft && primaryRight <= monitorRight))
|
2011-06-13 10:37:10 -04:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-06-13 10:37:10 -04:00
|
|
|
|
2012-06-08 04:26:58 -04:00
|
|
|
get currentMonitor() {
|
2018-01-03 02:55:38 -05:00
|
|
|
let index = global.display.get_current_monitor();
|
2012-08-22 03:15:53 -04:00
|
|
|
return this.monitors[index];
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:53:19 -04:00
|
|
|
|
2012-10-14 12:57:45 -04:00
|
|
|
get keyboardMonitor() {
|
|
|
|
return this.monitors[this.keyboardIndex];
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-10-14 12:57:45 -04:00
|
|
|
|
|
|
|
get focusIndex() {
|
|
|
|
let i = Main.layoutManager.primaryIndex;
|
|
|
|
|
Rework window / actor focus handling
The duality of the Clutter's key focus and mutter's window focus has long been
a problem for us in lots of case, and caused us to create large and complicated
hacks to get around the issue, including GrabHelper's focus grab model.
Instead of doing this, tie basic focus management into the core of gnome-shell,
instead of requiring complex "application-level" management to get it done
right.
Do this by making sure that only one of an actor or window can be focused at
the same time, and apply the appropriate logic to drop one or the other,
reactively.
Modals are considered a special case, as we grab all keyboard events, but at
the X level, the client window still has focus. Make sure to not do any input
synchronization when we have a modal.
At the same time, remove the FOCUSED input mode, as it's no longer necessary.
https://bugzilla.gnome.org/show_bug.cgi?id=700735
2013-05-18 00:18:13 -04:00
|
|
|
if (global.stage.key_focus != null)
|
|
|
|
i = this.findIndexForActor(global.stage.key_focus);
|
|
|
|
else if (global.display.focus_window != null)
|
|
|
|
i = global.display.focus_window.get_monitor();
|
2012-10-14 12:57:45 -04:00
|
|
|
return i;
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-10-14 12:57:45 -04:00
|
|
|
|
|
|
|
get focusMonitor() {
|
2018-06-28 10:51:48 -04:00
|
|
|
if (this.focusIndex < 0)
|
|
|
|
return null;
|
2012-10-14 12:57:45 -04:00
|
|
|
return this.monitors[this.focusIndex];
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-10-14 12:57:45 -04:00
|
|
|
|
|
|
|
set keyboardIndex(v) {
|
|
|
|
this._keyboardIndex = v;
|
2014-07-26 11:45:10 -04:00
|
|
|
this._updateKeyboardBox();
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-10-14 12:57:45 -04:00
|
|
|
|
|
|
|
get keyboardIndex() {
|
|
|
|
return this._keyboardIndex;
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-10-14 12:57:45 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_loadBackground() {
|
2017-04-12 02:46:54 -04:00
|
|
|
if (!this.primaryMonitor) {
|
|
|
|
this._pendingLoadBackground = true;
|
|
|
|
return;
|
|
|
|
}
|
2013-05-18 19:34:35 -04:00
|
|
|
this._systemBackground = new Background.SystemBackground();
|
2019-07-16 05:24:13 -04:00
|
|
|
this._systemBackground.hide();
|
2013-05-18 19:34:35 -04:00
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
global.stage.insert_child_below(this._systemBackground, null);
|
2013-05-18 19:34:35 -04:00
|
|
|
|
2020-03-29 17:51:13 -04:00
|
|
|
const constraint = new Clutter.BindConstraint({
|
|
|
|
source: global.stage,
|
|
|
|
coordinate: Clutter.BindCoordinate.ALL,
|
|
|
|
});
|
2019-07-16 05:24:13 -04:00
|
|
|
this._systemBackground.add_constraint(constraint);
|
2013-05-18 19:34:35 -04:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
let signalId = this._systemBackground.connect('loaded', () => {
|
2013-05-18 19:34:35 -04:00
|
|
|
this._systemBackground.disconnect(signalId);
|
|
|
|
|
2020-03-17 03:58:21 -04:00
|
|
|
// We're mostly prepared for the startup animation
|
|
|
|
// now, but since a lot is going on asynchronously
|
|
|
|
// during startup, let's defer the startup animation
|
|
|
|
// until the event loop is uncontended and idle.
|
|
|
|
// This helps to prevent us from running the animation
|
|
|
|
// when the system is bogged down
|
|
|
|
const id = GLib.idle_add(GLib.PRIORITY_LOW, () => {
|
2022-02-01 15:04:19 -05:00
|
|
|
if (this.primaryMonitor) {
|
|
|
|
this._systemBackground.show();
|
|
|
|
global.stage.show();
|
|
|
|
this._prepareStartupAnimation();
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
} else {
|
|
|
|
return GLib.SOURCE_CONTINUE;
|
|
|
|
}
|
2020-03-17 03:58:21 -04:00
|
|
|
});
|
|
|
|
GLib.Source.set_name_by_id(id, '[gnome-shell] Startup Animation');
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2013-05-18 19:34:35 -04:00
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
// Startup Animations
|
|
|
|
//
|
|
|
|
// We have two different animations, depending on whether we're a greeter
|
|
|
|
// or a normal session.
|
|
|
|
//
|
|
|
|
// In the greeter, we want to animate the panel from the top, and smoothly
|
|
|
|
// fade the login dialog on top of whatever plymouth left on screen which
|
|
|
|
// we get as a still frame background before drawing anything else.
|
|
|
|
//
|
|
|
|
// Here we just have the code to animate the panel, and fade up the background.
|
|
|
|
// The login dialog animation is handled by modalDialog.js
|
|
|
|
//
|
|
|
|
// When starting a normal user session, we want to grow it out of the middle
|
|
|
|
// of the screen.
|
|
|
|
|
2020-07-20 20:00:32 -04:00
|
|
|
async _prepareStartupAnimation() {
|
2013-05-18 19:06:50 -04:00
|
|
|
// During the initial transition, add a simple actor to block all events,
|
|
|
|
// so they don't get delivered to X11 windows that have been transformed.
|
2020-03-29 17:51:13 -04:00
|
|
|
this._coverPane = new Clutter.Actor({
|
|
|
|
opacity: 0,
|
|
|
|
width: global.screen_width,
|
|
|
|
height: global.screen_height,
|
|
|
|
reactive: true,
|
|
|
|
});
|
2013-05-18 19:06:50 -04:00
|
|
|
this.addChrome(this._coverPane);
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2022-11-17 09:21:42 -05:00
|
|
|
// Force an update of the regions before we scale the UI group to
|
|
|
|
// get the correct allocation for the struts.
|
|
|
|
// Do this even when we don't animate on restart, so that maximized
|
|
|
|
// windows restore to the right size.
|
|
|
|
this._updateRegions();
|
|
|
|
|
2014-05-08 18:56:23 -04:00
|
|
|
if (Meta.is_restart()) {
|
2022-11-17 09:21:42 -05:00
|
|
|
// On restart, we don't do an animation.
|
2014-05-08 18:56:23 -04:00
|
|
|
} else if (Main.sessionMode.isGreeter) {
|
2012-12-24 09:20:39 -05:00
|
|
|
this.panelBox.translation_y = -this.panelBox.height;
|
|
|
|
} else {
|
2013-02-19 19:56:56 -05:00
|
|
|
this.keyboardBox.hide();
|
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
let monitor = this.primaryMonitor;
|
|
|
|
|
2021-02-15 15:39:14 -05:00
|
|
|
if (!Main.sessionMode.hasOverview) {
|
|
|
|
const x = monitor.x + monitor.width / 2.0;
|
|
|
|
const y = monitor.y + monitor.height / 2.0;
|
|
|
|
|
|
|
|
this.uiGroup.set_pivot_point(
|
|
|
|
x / global.screen_width,
|
|
|
|
y / global.screen_height);
|
|
|
|
this.uiGroup.scale_x = this.uiGroup.scale_y = 0.75;
|
|
|
|
this.uiGroup.opacity = 0;
|
|
|
|
}
|
|
|
|
|
2013-03-19 20:16:54 -04:00
|
|
|
global.window_group.set_clip(monitor.x, monitor.y, monitor.width, monitor.height);
|
2020-07-20 20:00:32 -04:00
|
|
|
|
|
|
|
await this._updateBackgrounds();
|
2012-12-24 09:20:39 -05:00
|
|
|
}
|
2013-02-21 14:32:23 -05:00
|
|
|
|
2013-05-18 19:34:35 -04:00
|
|
|
this.emit('startup-prepared');
|
|
|
|
|
2020-03-17 03:58:21 -04:00
|
|
|
this._startupAnimation();
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-08-22 03:22:30 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_startupAnimation() {
|
2014-05-08 18:56:23 -04:00
|
|
|
if (Meta.is_restart())
|
|
|
|
this._startupAnimationComplete();
|
|
|
|
else if (Main.sessionMode.isGreeter)
|
2012-12-24 09:20:39 -05:00
|
|
|
this._startupAnimationGreeter();
|
|
|
|
else
|
|
|
|
this._startupAnimationSession();
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-09-02 16:36:02 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_startupAnimationGreeter() {
|
2018-07-20 15:46:19 -04:00
|
|
|
this.panelBox.ease({
|
|
|
|
translation_y: 0,
|
|
|
|
duration: STARTUP_ANIMATION_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2022-04-13 14:57:05 -04:00
|
|
|
onStopped: () => this._startupAnimationComplete(),
|
2018-07-20 15:46:19 -04:00
|
|
|
});
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-08-22 03:22:30 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_startupAnimationSession() {
|
2022-04-13 14:57:05 -04:00
|
|
|
const onStopped = () => this._startupAnimationComplete();
|
2021-02-15 15:39:14 -05:00
|
|
|
if (Main.sessionMode.hasOverview) {
|
2022-04-13 14:57:05 -04:00
|
|
|
Main.overview.runStartupAnimation(onStopped);
|
2021-02-15 15:39:14 -05:00
|
|
|
} else {
|
|
|
|
this.uiGroup.ease({
|
|
|
|
scale_x: 1,
|
|
|
|
scale_y: 1,
|
|
|
|
opacity: 255,
|
|
|
|
duration: STARTUP_ANIMATION_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2022-04-13 14:57:05 -04:00
|
|
|
onStopped,
|
2021-02-15 15:39:14 -05:00
|
|
|
});
|
|
|
|
}
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 14:25:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_startupAnimationComplete() {
|
2013-05-18 19:06:50 -04:00
|
|
|
this._coverPane.destroy();
|
|
|
|
this._coverPane = null;
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
this._systemBackground.destroy();
|
2013-02-21 14:32:23 -05:00
|
|
|
this._systemBackground = null;
|
2013-02-19 20:31:56 -05:00
|
|
|
|
2013-02-19 20:20:44 -05:00
|
|
|
this._startingUp = false;
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2013-02-19 19:56:56 -05:00
|
|
|
this.keyboardBox.show();
|
|
|
|
|
2013-03-19 20:16:54 -04:00
|
|
|
if (!Main.sessionMode.isGreeter) {
|
layout: Fix several issues with the background management code
If monitor-changed fires at startup, it will destroy all of the
backgrounds, but since this._isStartup is true, won't recreate any
of them. Additionally, since _bgManagers is indexed by monitor index,
if the primary index is not 0, it could become a sparse array (e.g.
[undefined, undefined, primaryBackground]), and our for loop will
crash trying to access properties of undefined.
Fix both of these issues by always creating background managers for
every monitor, hiding them on startup but only showing them after
the startup animation is complete.
One thing we need to watch out for is that while LayoutManager is
constructing, Main.uiGroup / Main.layoutManager will be undefined,
so addBackgroundMenu will fail. Fix this by passing down the uiGroup
to the background menu code.
https://bugzilla.gnome.org/show_bug.cgi?id=709313
2013-11-07 17:14:47 -05:00
|
|
|
this._showSecondaryBackgrounds();
|
2013-03-19 20:16:54 -04:00
|
|
|
global.window_group.remove_clip();
|
|
|
|
}
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2013-02-19 23:21:35 -05:00
|
|
|
this._queueUpdateRegions();
|
2013-03-04 08:07:14 -05:00
|
|
|
|
|
|
|
this.emit('startup-complete');
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-09-02 16:36:02 -04:00
|
|
|
|
2014-04-11 10:12:52 -04:00
|
|
|
// setDummyCursorGeometry:
|
2013-02-15 04:56:34 -05:00
|
|
|
//
|
|
|
|
// The cursor dummy is a standard widget commonly used for popup
|
|
|
|
// menus and box pointers to track, as the box pointer API only
|
|
|
|
// tracks actors. If you want to pop up a menu based on where the
|
|
|
|
// user clicked, or where the text cursor is, the cursor dummy
|
|
|
|
// is what you should use. Given that the menu should not track
|
|
|
|
// the actual mouse pointer as it moves, you need to call this
|
|
|
|
// function before you show the menu to ensure it is at the right
|
2014-04-11 10:12:52 -04:00
|
|
|
// position and has the right size.
|
2017-10-30 20:03:21 -04:00
|
|
|
setDummyCursorGeometry(x, y, w, h) {
|
2013-02-15 04:56:34 -05:00
|
|
|
this.dummyCursor.set_position(Math.round(x), Math.round(y));
|
2014-04-11 10:12:52 -04:00
|
|
|
this.dummyCursor.set_size(Math.round(w), Math.round(h));
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2013-02-15 04:56:34 -05:00
|
|
|
|
2011-07-25 09:53:19 -04:00
|
|
|
// addChrome:
|
2011-09-01 10:20:52 -04:00
|
|
|
// @actor: an actor to add to the chrome
|
2011-07-25 09:53:19 -04:00
|
|
|
// @params: (optional) additional params
|
|
|
|
//
|
2015-02-09 03:25:00 -05:00
|
|
|
// Adds @actor to the chrome, and (unless %affectsInputRegion in
|
|
|
|
// @params is %false) extends the input region to include it.
|
|
|
|
// Changes in @actor's size, position, and visibility will
|
|
|
|
// automatically result in appropriate changes to the input
|
|
|
|
// region.
|
2011-07-25 09:53:19 -04:00
|
|
|
//
|
|
|
|
// If %affectsStruts in @params is %true (and @actor is along a
|
|
|
|
// screen edge), then @actor's size and position will also affect
|
|
|
|
// the window manager struts. Changes to @actor's visibility will
|
|
|
|
// NOT affect whether or not the strut is present, however.
|
|
|
|
//
|
2012-05-22 16:16:31 -04:00
|
|
|
// If %trackFullscreen in @params is %true, the actor's visibility
|
|
|
|
// will be bound to the presence of fullscreen windows on the same
|
|
|
|
// monitor (it will be hidden whenever a fullscreen window is visible,
|
|
|
|
// and shown otherwise)
|
2017-10-30 20:03:21 -04:00
|
|
|
addChrome(actor, params) {
|
2013-01-10 16:02:20 -05:00
|
|
|
this.uiGroup.add_actor(actor);
|
2013-06-26 04:41:04 -04:00
|
|
|
if (this.uiGroup.contains(global.top_window_group))
|
|
|
|
this.uiGroup.set_child_below_sibling(actor, global.top_window_group);
|
2013-01-27 23:34:33 -05:00
|
|
|
this._trackActor(actor, params);
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:53:19 -04:00
|
|
|
|
2019-05-03 17:39:11 -04:00
|
|
|
// addTopChrome:
|
|
|
|
// @actor: an actor to add to the chrome
|
|
|
|
// @params: (optional) additional params
|
|
|
|
//
|
|
|
|
// Like addChrome(), but adds @actor above all windows, including popups.
|
|
|
|
addTopChrome(actor, params) {
|
|
|
|
this.uiGroup.add_actor(actor);
|
|
|
|
this._trackActor(actor, params);
|
|
|
|
}
|
|
|
|
|
2011-07-25 09:53:19 -04:00
|
|
|
// trackChrome:
|
|
|
|
// @actor: a descendant of the chrome to begin tracking
|
|
|
|
// @params: parameters describing how to track @actor
|
|
|
|
//
|
2017-07-14 16:23:53 -04:00
|
|
|
// Tells the chrome to track @actor. This can be used to extend the
|
2011-07-25 09:53:19 -04:00
|
|
|
// struts or input region to cover specific children.
|
|
|
|
//
|
|
|
|
// @params can have any of the same values as in addChrome(),
|
2012-05-22 16:16:31 -04:00
|
|
|
// though some possibilities don't make sense. By default, @actor has
|
|
|
|
// the same params as its chrome ancestor.
|
2019-07-11 19:31:38 -04:00
|
|
|
trackChrome(actor, params = {}) {
|
2011-07-25 09:56:51 -04:00
|
|
|
let ancestor = actor.get_parent();
|
|
|
|
let index = this._findActor(ancestor);
|
|
|
|
while (ancestor && index == -1) {
|
|
|
|
ancestor = ancestor.get_parent();
|
|
|
|
index = this._findActor(ancestor);
|
|
|
|
}
|
|
|
|
|
2019-08-19 15:33:15 -04:00
|
|
|
let ancestorData = ancestor
|
|
|
|
? this._trackedActors[index]
|
|
|
|
: defaultParams;
|
2011-07-25 09:56:51 -04:00
|
|
|
// We can't use Params.parse here because we want to drop
|
|
|
|
// the extra values like ancestorData.actor
|
|
|
|
for (let prop in defaultParams) {
|
2019-06-29 19:05:27 -04:00
|
|
|
if (!Object.prototype.hasOwnProperty.call(params, prop))
|
2011-07-25 09:56:51 -04:00
|
|
|
params[prop] = ancestorData[prop];
|
|
|
|
}
|
|
|
|
|
|
|
|
this._trackActor(actor, params);
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2013-01-27 23:34:33 -05:00
|
|
|
// untrackChrome:
|
|
|
|
// @actor: an actor previously tracked via trackChrome()
|
|
|
|
//
|
|
|
|
// Undoes the effect of trackChrome()
|
2017-10-30 20:03:21 -04:00
|
|
|
untrackChrome(actor) {
|
2011-07-25 09:56:51 -04:00
|
|
|
this._untrackActor(actor);
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2013-01-27 23:34:33 -05:00
|
|
|
// removeChrome:
|
|
|
|
// @actor: a chrome actor
|
|
|
|
//
|
|
|
|
// Removes @actor from the chrome
|
2017-10-30 20:03:21 -04:00
|
|
|
removeChrome(actor) {
|
2013-01-10 16:02:20 -05:00
|
|
|
this.uiGroup.remove_actor(actor);
|
2011-07-25 09:56:51 -04:00
|
|
|
this._untrackActor(actor);
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_findActor(actor) {
|
2011-07-25 09:56:51 -04:00
|
|
|
for (let i = 0; i < this._trackedActors.length; i++) {
|
|
|
|
let actorData = this._trackedActors[i];
|
|
|
|
if (actorData.actor == actor)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_trackActor(actor, params) {
|
2011-07-25 09:56:51 -04:00
|
|
|
if (this._findActor(actor) != -1)
|
|
|
|
throw new Error('trying to re-track existing chrome actor');
|
|
|
|
|
|
|
|
let actorData = Params.parse(params, defaultParams);
|
|
|
|
actorData.actor = actor;
|
2021-08-15 18:36:59 -04:00
|
|
|
actor.connectObject(
|
|
|
|
'notify::visible', this._queueUpdateRegions.bind(this),
|
|
|
|
'notify::allocation', this._queueUpdateRegions.bind(this),
|
|
|
|
'destroy', this._untrackActor.bind(this), this);
|
2011-07-25 09:56:51 -04:00
|
|
|
// Note that destroying actor will unset its parent, so we don't
|
|
|
|
// need to connect to 'destroy' too.
|
|
|
|
|
|
|
|
this._trackedActors.push(actorData);
|
2015-05-14 11:33:24 -04:00
|
|
|
this._updateActorVisibility(actorData);
|
2011-07-25 09:56:51 -04:00
|
|
|
this._queueUpdateRegions();
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_untrackActor(actor) {
|
2011-07-25 09:56:51 -04:00
|
|
|
let i = this._findActor(actor);
|
|
|
|
|
|
|
|
if (i == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._trackedActors.splice(i, 1);
|
2021-08-15 18:36:59 -04:00
|
|
|
actor.disconnectObject(this);
|
2011-07-25 09:56:51 -04:00
|
|
|
|
|
|
|
this._queueUpdateRegions();
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateActorVisibility(actorData) {
|
2015-05-14 11:33:24 -04:00
|
|
|
if (!actorData.trackFullscreen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let monitor = this.findMonitorForActor(actorData.actor);
|
|
|
|
actorData.actor.visible = !(global.window_group.visible &&
|
|
|
|
monitor &&
|
|
|
|
monitor.inFullscreen);
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2015-05-14 11:33:24 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateVisibility() {
|
2013-03-13 14:38:59 -04:00
|
|
|
let windowsVisible = Main.sessionMode.hasWindows && !this._inOverview;
|
|
|
|
|
|
|
|
global.window_group.visible = windowsVisible;
|
|
|
|
global.top_window_group.visible = windowsVisible;
|
|
|
|
|
2017-12-01 19:27:35 -05:00
|
|
|
this._trackedActors.forEach(this._updateActorVisibility.bind(this));
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
getWorkAreaForMonitor(monitorIndex) {
|
2013-01-28 00:09:12 -05:00
|
|
|
// Assume that all workspaces will have the same
|
|
|
|
// struts and pick the first one.
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let ws = workspaceManager.get_workspace_by_index(0);
|
2013-01-28 00:09:12 -05:00
|
|
|
return ws.get_work_area_for_monitor(monitorIndex);
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2013-01-28 00:09:12 -05:00
|
|
|
|
2011-07-25 09:56:51 -04:00
|
|
|
// This call guarantees that we return some monitor to simplify usage of it
|
|
|
|
// In practice all tracked actors should be visible on some monitor anyway
|
2017-10-30 20:03:21 -04:00
|
|
|
findIndexForActor(actor) {
|
2011-07-25 09:56:51 -04:00
|
|
|
let [x, y] = actor.get_transformed_position();
|
|
|
|
let [w, h] = actor.get_transformed_size();
|
2019-08-19 15:06:04 -04:00
|
|
|
let rect = new Meta.Rectangle({ x, y, width: w, height: h });
|
2018-01-03 02:55:38 -05:00
|
|
|
return global.display.get_monitor_index_for_rect(rect);
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2012-10-14 12:57:45 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
findMonitorForActor(actor) {
|
2017-06-12 23:39:06 -04:00
|
|
|
let index = this.findIndexForActor(actor);
|
|
|
|
if (index >= 0 && index < this.monitors.length)
|
|
|
|
return this.monitors[index];
|
|
|
|
return null;
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_queueUpdateRegions() {
|
2019-08-19 20:51:42 -04:00
|
|
|
if (!this._updateRegionIdle) {
|
2014-03-13 16:46:34 -04:00
|
|
|
this._updateRegionIdle = Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
|
2017-12-01 19:27:35 -05:00
|
|
|
this._updateRegions.bind(this));
|
2019-08-19 20:51:42 -04:00
|
|
|
}
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateFullscreen() {
|
2013-03-14 14:36:13 -04:00
|
|
|
this._updateVisibility();
|
|
|
|
this._queueUpdateRegions();
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_windowsRestacked() {
|
2011-07-25 09:56:51 -04:00
|
|
|
let changed = false;
|
2012-06-06 18:20:23 -04:00
|
|
|
|
2013-03-14 14:36:13 -04:00
|
|
|
if (this._isPopupWindowVisible != global.top_window_group.get_children().some(isPopupMetaWindow))
|
2013-02-12 16:00:41 -05:00
|
|
|
changed = true;
|
|
|
|
|
2011-07-25 09:56:51 -04:00
|
|
|
if (changed) {
|
|
|
|
this._updateVisibility();
|
|
|
|
this._queueUpdateRegions();
|
|
|
|
}
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateRegions() {
|
2011-08-29 11:11:22 -04:00
|
|
|
if (this._updateRegionIdle) {
|
2014-03-13 16:46:34 -04:00
|
|
|
Meta.later_remove(this._updateRegionIdle);
|
2011-08-29 11:11:22 -04:00
|
|
|
delete this._updateRegionIdle;
|
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2014-09-19 20:54:31 -04:00
|
|
|
let rects = [], struts = [], i;
|
2013-02-12 16:00:41 -05:00
|
|
|
let isPopupMenuVisible = global.top_window_group.get_children().some(isPopupMetaWindow);
|
2021-02-25 08:31:47 -05:00
|
|
|
const wantsInputRegion =
|
2021-02-25 08:35:30 -05:00
|
|
|
!this._startingUp &&
|
2021-02-25 08:31:47 -05:00
|
|
|
!isPopupMenuVisible &&
|
|
|
|
Main.modalCount === 0 &&
|
|
|
|
!Meta.is_wayland_compositor();
|
2013-02-12 16:00:41 -05:00
|
|
|
|
2011-07-25 09:56:51 -04:00
|
|
|
for (i = 0; i < this._trackedActors.length; i++) {
|
|
|
|
let actorData = this._trackedActors[i];
|
2015-02-09 03:25:00 -05:00
|
|
|
if (!(actorData.affectsInputRegion && wantsInputRegion) && !actorData.affectsStruts)
|
2011-07-25 09:56:51 -04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
let [x, y] = actorData.actor.get_transformed_position();
|
|
|
|
let [w, h] = actorData.actor.get_transformed_size();
|
|
|
|
x = Math.round(x);
|
|
|
|
y = Math.round(y);
|
|
|
|
w = Math.round(w);
|
|
|
|
h = Math.round(h);
|
|
|
|
|
2022-03-05 07:06:59 -05:00
|
|
|
if (actorData.affectsInputRegion && wantsInputRegion && actorData.actor.get_paint_visibility())
|
2019-08-19 15:06:04 -04:00
|
|
|
rects.push(new Meta.Rectangle({ x, y, width: w, height: h }));
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2017-07-13 09:53:04 -04:00
|
|
|
let monitor = null;
|
|
|
|
if (actorData.affectsStruts)
|
|
|
|
monitor = this.findMonitorForActor(actorData.actor);
|
|
|
|
|
|
|
|
if (monitor) {
|
2013-02-12 15:57:08 -05:00
|
|
|
// Limit struts to the size of the screen
|
|
|
|
let x1 = Math.max(x, 0);
|
|
|
|
let x2 = Math.min(x + w, global.screen_width);
|
|
|
|
let y1 = Math.max(y, 0);
|
|
|
|
let y2 = Math.min(y + h, global.screen_height);
|
|
|
|
|
2015-02-08 17:03:07 -05:00
|
|
|
// Metacity wants to know what side of the monitor the
|
|
|
|
// strut is considered to be attached to. First, we find
|
|
|
|
// the monitor that contains the strut. If the actor is
|
2013-02-12 15:57:08 -05:00
|
|
|
// only touching one edge, or is touching the entire
|
2015-02-08 17:03:07 -05:00
|
|
|
// border of that monitor, then it's obvious which side
|
|
|
|
// to call it. If it's in a corner, we pick a side
|
|
|
|
// arbitrarily. If it doesn't touch any edges, or it
|
|
|
|
// spans the width/height across the middle of the
|
|
|
|
// screen, then we don't create a strut for it at all.
|
|
|
|
|
2013-02-12 15:57:08 -05:00
|
|
|
let side;
|
2015-02-08 17:03:07 -05:00
|
|
|
if (x1 <= monitor.x && x2 >= monitor.x + monitor.width) {
|
|
|
|
if (y1 <= monitor.y)
|
2013-02-12 15:57:08 -05:00
|
|
|
side = Meta.Side.TOP;
|
2015-02-08 17:03:07 -05:00
|
|
|
else if (y2 >= monitor.y + monitor.height)
|
2013-02-12 15:57:08 -05:00
|
|
|
side = Meta.Side.BOTTOM;
|
|
|
|
else
|
|
|
|
continue;
|
2015-02-08 17:03:07 -05:00
|
|
|
} else if (y1 <= monitor.y && y2 >= monitor.y + monitor.height) {
|
|
|
|
if (x1 <= monitor.x)
|
2013-02-12 15:57:08 -05:00
|
|
|
side = Meta.Side.LEFT;
|
2015-02-08 17:03:07 -05:00
|
|
|
else if (x2 >= monitor.x + monitor.width)
|
2013-02-12 15:57:08 -05:00
|
|
|
side = Meta.Side.RIGHT;
|
|
|
|
else
|
|
|
|
continue;
|
2019-08-19 20:51:42 -04:00
|
|
|
} else if (x1 <= monitor.x) {
|
2011-07-25 09:56:51 -04:00
|
|
|
side = Meta.Side.LEFT;
|
2019-08-19 20:51:42 -04:00
|
|
|
} else if (y1 <= monitor.y) {
|
2013-02-12 15:57:08 -05:00
|
|
|
side = Meta.Side.TOP;
|
2019-08-19 20:51:42 -04:00
|
|
|
} else if (x2 >= monitor.x + monitor.width) {
|
2011-07-25 09:56:51 -04:00
|
|
|
side = Meta.Side.RIGHT;
|
2019-08-19 20:51:42 -04:00
|
|
|
} else if (y2 >= monitor.y + monitor.height) {
|
2013-02-12 15:57:08 -05:00
|
|
|
side = Meta.Side.BOTTOM;
|
2019-08-19 20:51:42 -04:00
|
|
|
} else {
|
2011-07-25 09:56:51 -04:00
|
|
|
continue;
|
2019-08-19 20:51:42 -04:00
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2019-01-28 20:27:05 -05:00
|
|
|
let strutRect = new Meta.Rectangle({ x: x1, y: y1, width: x2 - x1, height: y2 - y1 });
|
2019-08-19 15:06:04 -04:00
|
|
|
let strut = new Meta.Strut({ rect: strutRect, side });
|
2013-02-12 15:57:08 -05:00
|
|
|
struts.push(strut);
|
|
|
|
}
|
2011-07-25 09:56:51 -04:00
|
|
|
}
|
|
|
|
|
2021-02-15 15:28:21 -05:00
|
|
|
if (wantsInputRegion)
|
|
|
|
global.set_stage_input_region(rects);
|
|
|
|
|
2013-02-12 16:00:41 -05:00
|
|
|
this._isPopupWindowVisible = isPopupMenuVisible;
|
2011-07-25 09:56:51 -04:00
|
|
|
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
for (let w = 0; w < workspaceManager.n_workspaces; w++) {
|
|
|
|
let workspace = workspaceManager.get_workspace_by_index(w);
|
2011-07-25 09:56:51 -04:00
|
|
|
workspace.set_builtin_struts(struts);
|
|
|
|
}
|
|
|
|
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2014-09-19 20:54:31 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
modalEnded() {
|
2014-09-19 20:54:31 -04:00
|
|
|
// We don't update the stage input region while in a modal,
|
|
|
|
// so queue an update now.
|
|
|
|
this._queueUpdateRegions();
|
2017-10-30 21:23:39 -04:00
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2013-01-27 23:32:40 -05:00
|
|
|
|
|
|
|
|
|
|
|
// HotCorner:
|
|
|
|
//
|
|
|
|
// This class manages a "hot corner" that can toggle switching to
|
|
|
|
// overview.
|
2019-07-16 05:24:13 -04:00
|
|
|
var HotCorner = GObject.registerClass(
|
|
|
|
class HotCorner extends Clutter.Actor {
|
|
|
|
_init(layoutManager, monitor, x, y) {
|
|
|
|
super._init();
|
|
|
|
|
2013-01-27 23:32:40 -05:00
|
|
|
// We use this flag to mark the case where the user has entered the
|
|
|
|
// hot corner and has not left both the hot corner and a surrounding
|
|
|
|
// guard area (the "environs"). This avoids triggering the hot corner
|
|
|
|
// multiple times due to an accidental jitter.
|
|
|
|
this._entered = false;
|
|
|
|
|
2013-03-09 21:12:37 -05:00
|
|
|
this._monitor = monitor;
|
|
|
|
|
2013-03-01 15:07:11 -05:00
|
|
|
this._x = x;
|
|
|
|
this._y = y;
|
|
|
|
|
2013-03-05 01:49:35 -05:00
|
|
|
this._setupFallbackCornerIfNeeded(layoutManager);
|
2013-01-27 23:32:40 -05:00
|
|
|
|
2013-03-01 16:19:07 -05:00
|
|
|
this._pressureBarrier = new PressureBarrier(HOT_CORNER_PRESSURE_THRESHOLD,
|
|
|
|
HOT_CORNER_PRESSURE_TIMEOUT,
|
2014-12-11 09:35:40 -05:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW);
|
2017-12-01 19:27:35 -05:00
|
|
|
this._pressureBarrier.connect('trigger', this._toggleOverview.bind(this));
|
2013-01-27 23:32:40 -05:00
|
|
|
|
2019-02-21 02:45:17 -05:00
|
|
|
let px = 0.0;
|
|
|
|
let py = 0.0;
|
|
|
|
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) {
|
|
|
|
px = 1.0;
|
|
|
|
py = 0.0;
|
|
|
|
}
|
2013-01-27 23:32:40 -05:00
|
|
|
|
2019-02-21 02:45:17 -05:00
|
|
|
this._ripples = new Ripples.Ripples(px, py, 'ripple-box');
|
|
|
|
this._ripples.addTo(layoutManager.uiGroup);
|
2019-07-16 05:24:13 -04:00
|
|
|
|
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-01-27 23:32:40 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setBarrierSize(size) {
|
2013-03-01 15:07:11 -05:00
|
|
|
if (this._verticalBarrier) {
|
2013-03-01 16:19:07 -05:00
|
|
|
this._pressureBarrier.removeBarrier(this._verticalBarrier);
|
2013-03-01 15:07:11 -05:00
|
|
|
this._verticalBarrier.destroy();
|
|
|
|
this._verticalBarrier = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._horizontalBarrier) {
|
2013-03-01 16:19:07 -05:00
|
|
|
this._pressureBarrier.removeBarrier(this._horizontalBarrier);
|
2013-03-01 15:07:11 -05:00
|
|
|
this._horizontalBarrier.destroy();
|
|
|
|
this._horizontalBarrier = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size > 0) {
|
2013-04-20 11:48:28 -04:00
|
|
|
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) {
|
2020-03-29 17:51:13 -04:00
|
|
|
this._verticalBarrier = new Meta.Barrier({
|
|
|
|
display: global.display,
|
|
|
|
x1: this._x, x2: this._x, y1: this._y, y2: this._y + size,
|
|
|
|
directions: Meta.BarrierDirection.NEGATIVE_X,
|
|
|
|
});
|
|
|
|
this._horizontalBarrier = new Meta.Barrier({
|
|
|
|
display: global.display,
|
|
|
|
x1: this._x - size, x2: this._x, y1: this._y, y2: this._y,
|
|
|
|
directions: Meta.BarrierDirection.POSITIVE_Y,
|
|
|
|
});
|
2013-04-20 11:48:28 -04:00
|
|
|
} else {
|
2020-03-29 17:51:13 -04:00
|
|
|
this._verticalBarrier = new Meta.Barrier({
|
|
|
|
display: global.display,
|
|
|
|
x1: this._x, x2: this._x, y1: this._y, y2: this._y + size,
|
|
|
|
directions: Meta.BarrierDirection.POSITIVE_X,
|
|
|
|
});
|
|
|
|
this._horizontalBarrier = new Meta.Barrier({
|
|
|
|
display: global.display,
|
|
|
|
x1: this._x, x2: this._x + size, y1: this._y, y2: this._y,
|
|
|
|
directions: Meta.BarrierDirection.POSITIVE_Y,
|
|
|
|
});
|
2013-04-20 11:48:28 -04:00
|
|
|
}
|
2013-03-01 16:19:07 -05:00
|
|
|
|
|
|
|
this._pressureBarrier.addBarrier(this._verticalBarrier);
|
|
|
|
this._pressureBarrier.addBarrier(this._horizontalBarrier);
|
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-03-01 16:19:07 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_setupFallbackCornerIfNeeded(layoutManager) {
|
2013-03-01 16:19:07 -05:00
|
|
|
if (!global.display.supports_extended_barriers()) {
|
2019-07-16 05:24:13 -04:00
|
|
|
this.set({
|
|
|
|
name: 'hot-corner-environs',
|
|
|
|
x: this._x,
|
|
|
|
y: this._y,
|
|
|
|
width: 3,
|
|
|
|
height: 3,
|
2019-08-20 17:43:54 -04:00
|
|
|
reactive: true,
|
2019-07-16 05:24:13 -04:00
|
|
|
});
|
2013-03-01 16:19:07 -05:00
|
|
|
|
2020-03-29 17:51:13 -04:00
|
|
|
this._corner = new Clutter.Actor({
|
|
|
|
name: 'hot-corner',
|
|
|
|
width: 1,
|
|
|
|
height: 1,
|
|
|
|
opacity: 0,
|
|
|
|
reactive: true,
|
|
|
|
});
|
2013-03-01 16:19:07 -05:00
|
|
|
this._corner._delegate = this;
|
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
this.add_child(this._corner);
|
|
|
|
layoutManager.addChrome(this);
|
2013-03-01 16:19:07 -05:00
|
|
|
|
|
|
|
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) {
|
2019-07-16 05:24:13 -04:00
|
|
|
this._corner.set_position(this.width - this._corner.width, 0);
|
2020-06-26 14:54:32 -04:00
|
|
|
this.set_pivot_point(1.0, 0.0);
|
|
|
|
this.translation_x = -this.width;
|
2013-03-01 16:19:07 -05:00
|
|
|
} else {
|
|
|
|
this._corner.set_position(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._corner.connect('enter-event',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onCornerEntered.bind(this));
|
2013-03-01 16:19:07 -05:00
|
|
|
this._corner.connect('leave-event',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onCornerLeft.bind(this));
|
2013-03-01 15:07:11 -05:00
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-03-01 15:07:11 -05:00
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
_onDestroy() {
|
2013-03-01 15:07:11 -05:00
|
|
|
this.setBarrierSize(0);
|
2013-03-01 16:19:07 -05:00
|
|
|
this._pressureBarrier.destroy();
|
|
|
|
this._pressureBarrier = null;
|
|
|
|
|
2019-08-30 19:40:53 -04:00
|
|
|
this._ripples.destroy();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-01-27 23:32:40 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_toggleOverview() {
|
2018-09-21 10:58:26 -04:00
|
|
|
if (this._monitor.inFullscreen && !Main.overview.visible)
|
2013-03-09 21:12:37 -05:00
|
|
|
return;
|
|
|
|
|
2013-03-04 17:02:02 -05:00
|
|
|
if (Main.overview.shouldToggleByCornerOrButton()) {
|
|
|
|
Main.overview.toggle();
|
2020-07-21 20:05:48 -04:00
|
|
|
if (Main.overview.animationInProgress)
|
|
|
|
this._ripples.playAnimation(this._x, this._y);
|
2013-01-27 23:32:40 -05:00
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-03-01 16:19:07 -05:00
|
|
|
|
2019-01-31 09:08:10 -05:00
|
|
|
handleDragOver(source, _actor, _x, _y, _time) {
|
2013-03-01 16:19:07 -05:00
|
|
|
if (source != Main.xdndHandler)
|
|
|
|
return DND.DragMotionResult.CONTINUE;
|
2013-01-27 23:32:40 -05:00
|
|
|
|
2013-03-23 05:51:43 -04:00
|
|
|
this._toggleOverview();
|
|
|
|
|
2013-01-27 23:32:40 -05:00
|
|
|
return DND.DragMotionResult.CONTINUE;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-01-27 23:32:40 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onCornerEntered() {
|
2013-01-27 23:32:40 -05:00
|
|
|
if (!this._entered) {
|
|
|
|
this._entered = true;
|
2013-03-01 16:19:07 -05:00
|
|
|
this._toggleOverview();
|
2013-01-27 23:32:40 -05:00
|
|
|
}
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-01-27 23:32:40 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onCornerLeft(actor, event) {
|
2019-07-16 05:24:13 -04:00
|
|
|
if (event.get_related() != this)
|
2013-01-27 23:32:40 -05:00
|
|
|
this._entered = false;
|
|
|
|
// Consume event, otherwise this will confuse onEnvironsLeft
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_STOP;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-01-27 23:32:40 -05:00
|
|
|
|
2019-09-10 01:42:48 -04:00
|
|
|
vfunc_leave_event(crossingEvent) {
|
|
|
|
if (crossingEvent.related != this._corner)
|
2013-01-27 23:32:40 -05:00
|
|
|
this._entered = false;
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2013-01-27 23:32:40 -05:00
|
|
|
}
|
2019-07-16 05:24:13 -04:00
|
|
|
});
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2022-07-04 18:30:44 -04:00
|
|
|
var PressureBarrier = class PressureBarrier extends Signals.EventEmitter {
|
2017-10-30 21:19:44 -04:00
|
|
|
constructor(threshold, timeout, actionMode) {
|
2022-07-04 18:30:44 -04:00
|
|
|
super();
|
|
|
|
|
2012-07-30 15:25:07 -04:00
|
|
|
this._threshold = threshold;
|
|
|
|
this._timeout = timeout;
|
2014-12-11 09:35:40 -05:00
|
|
|
this._actionMode = actionMode;
|
2013-03-01 14:57:38 -05:00
|
|
|
this._barriers = [];
|
2013-03-01 15:33:39 -05:00
|
|
|
this._eventFilter = null;
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2013-03-01 15:29:42 -05:00
|
|
|
this._isTriggered = false;
|
2012-07-30 15:25:07 -04:00
|
|
|
this._reset();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-03-01 14:57:38 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
addBarrier(barrier) {
|
2017-12-01 19:27:35 -05:00
|
|
|
barrier._pressureHitId = barrier.connect('hit', this._onBarrierHit.bind(this));
|
|
|
|
barrier._pressureLeftId = barrier.connect('left', this._onBarrierLeft.bind(this));
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2013-03-01 14:57:38 -05:00
|
|
|
this._barriers.push(barrier);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-03-01 14:57:38 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_disconnectBarrier(barrier) {
|
2013-03-01 14:57:38 -05:00
|
|
|
barrier.disconnect(barrier._pressureHitId);
|
|
|
|
barrier.disconnect(barrier._pressureLeftId);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-03-01 14:57:38 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
removeBarrier(barrier) {
|
2013-03-01 14:57:38 -05:00
|
|
|
this._disconnectBarrier(barrier);
|
|
|
|
this._barriers.splice(this._barriers.indexOf(barrier), 1);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
destroy() {
|
2017-12-01 19:27:35 -05:00
|
|
|
this._barriers.forEach(this._disconnectBarrier.bind(this));
|
2013-03-01 14:57:38 -05:00
|
|
|
this._barriers = [];
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setEventFilter(filter) {
|
2013-03-01 15:33:39 -05:00
|
|
|
this._eventFilter = filter;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-03-01 15:33:39 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_reset() {
|
2012-07-30 15:25:07 -04:00
|
|
|
this._barrierEvents = [];
|
|
|
|
this._currentPressure = 0;
|
|
|
|
this._lastTime = 0;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_isHorizontal(barrier) {
|
2013-03-01 14:57:38 -05:00
|
|
|
return barrier.y1 == barrier.y2;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-03-01 14:57:38 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_getDistanceAcrossBarrier(barrier, event) {
|
2013-03-01 14:57:38 -05:00
|
|
|
if (this._isHorizontal(barrier))
|
2012-07-30 15:25:07 -04:00
|
|
|
return Math.abs(event.dy);
|
|
|
|
else
|
|
|
|
return Math.abs(event.dx);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_getDistanceAlongBarrier(barrier, event) {
|
2013-03-01 14:57:38 -05:00
|
|
|
if (this._isHorizontal(barrier))
|
2012-07-30 15:25:07 -04:00
|
|
|
return Math.abs(event.dx);
|
|
|
|
else
|
|
|
|
return Math.abs(event.dy);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_trimBarrierEvents() {
|
2012-07-30 15:25:07 -04:00
|
|
|
// Events are guaranteed to be sorted in time order from
|
|
|
|
// oldest to newest, so just look for the first old event,
|
|
|
|
// and then chop events after that off.
|
|
|
|
let i = 0;
|
2013-03-01 15:21:25 -05:00
|
|
|
let threshold = this._lastTime - this._timeout;
|
|
|
|
|
2012-07-30 15:25:07 -04:00
|
|
|
while (i < this._barrierEvents.length) {
|
2019-01-31 09:08:00 -05:00
|
|
|
let [time, distance_] = this._barrierEvents[i];
|
2013-03-01 15:21:25 -05:00
|
|
|
if (time >= threshold)
|
2012-07-30 15:25:07 -04:00
|
|
|
break;
|
2013-02-14 21:21:20 -05:00
|
|
|
i++;
|
2012-07-30 15:25:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
let firstNewEvent = i;
|
|
|
|
|
|
|
|
for (i = 0; i < firstNewEvent; i++) {
|
2019-01-31 09:08:00 -05:00
|
|
|
let [time_, distance] = this._barrierEvents[i];
|
2013-03-01 15:21:25 -05:00
|
|
|
this._currentPressure -= distance;
|
2012-07-30 15:25:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
this._barrierEvents = this._barrierEvents.slice(firstNewEvent);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2019-01-31 09:08:10 -05:00
|
|
|
_onBarrierLeft(barrier, _event) {
|
2015-04-28 20:36:53 -04:00
|
|
|
barrier._isHit = false;
|
2017-10-30 20:38:18 -04:00
|
|
|
if (this._barriers.every(b => !b._isHit)) {
|
2015-04-28 20:36:53 -04:00
|
|
|
this._reset();
|
|
|
|
this._isTriggered = false;
|
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_trigger() {
|
2013-03-01 15:29:42 -05:00
|
|
|
this._isTriggered = true;
|
2013-02-21 17:21:25 -05:00
|
|
|
this.emit('trigger');
|
|
|
|
this._reset();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-02-21 17:21:25 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onBarrierHit(barrier, event) {
|
2015-04-28 20:36:53 -04:00
|
|
|
barrier._isHit = true;
|
|
|
|
|
2013-03-01 15:29:42 -05:00
|
|
|
// If we've triggered the barrier, wait until the pointer has the
|
|
|
|
// left the barrier hitbox until we trigger it again.
|
|
|
|
if (this._isTriggered)
|
|
|
|
return;
|
|
|
|
|
2013-03-01 15:33:39 -05:00
|
|
|
if (this._eventFilter && this._eventFilter(event))
|
2013-02-16 16:17:11 -05:00
|
|
|
return;
|
|
|
|
|
2013-03-01 15:45:56 -05:00
|
|
|
// Throw out all events not in the proper keybinding mode
|
2014-12-11 09:35:40 -05:00
|
|
|
if (!(this._actionMode & Main.actionMode))
|
2012-07-30 15:25:07 -04:00
|
|
|
return;
|
|
|
|
|
2013-03-01 14:57:38 -05:00
|
|
|
let slide = this._getDistanceAlongBarrier(barrier, event);
|
|
|
|
let distance = this._getDistanceAcrossBarrier(barrier, event);
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2013-02-21 17:21:25 -05:00
|
|
|
if (distance >= this._threshold) {
|
|
|
|
this._trigger();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-30 15:25:07 -04:00
|
|
|
// Throw out events where the cursor is move more
|
|
|
|
// along the axis of the barrier than moving with
|
|
|
|
// the barrier.
|
|
|
|
if (slide > distance)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._lastTime = event.time;
|
|
|
|
|
|
|
|
this._trimBarrierEvents();
|
2013-03-01 15:21:25 -05:00
|
|
|
distance = Math.min(15, distance);
|
|
|
|
|
|
|
|
this._barrierEvents.push([event.time, distance]);
|
|
|
|
this._currentPressure += distance;
|
2012-07-30 15:25:07 -04:00
|
|
|
|
2013-02-21 17:21:25 -05:00
|
|
|
if (this._currentPressure >= this._threshold)
|
|
|
|
this._trigger();
|
2012-07-30 15:25:07 -04:00
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
};
|
2021-09-23 03:45:14 -04:00
|
|
|
|
|
|
|
var ScreenTransition = GObject.registerClass(
|
|
|
|
class ScreenTransition extends Clutter.Actor {
|
|
|
|
_init() {
|
|
|
|
super._init({ visible: false });
|
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_hide() {
|
|
|
|
this.content = null;
|
|
|
|
super.vfunc_hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
run() {
|
|
|
|
if (this.visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Main.uiGroup.set_child_above_sibling(this, null);
|
|
|
|
|
|
|
|
const rect = new imports.gi.cairo.RectangleInt({
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
width: global.screen_width,
|
|
|
|
height: global.screen_height,
|
|
|
|
});
|
|
|
|
const [, , , scale] = global.stage.get_capture_final_size(rect);
|
|
|
|
this.content = global.stage.paint_to_content(rect, scale, Clutter.PaintFlag.NO_CURSORS);
|
|
|
|
|
|
|
|
this.opacity = 255;
|
|
|
|
this.show();
|
|
|
|
|
|
|
|
this.ease({
|
|
|
|
opacity: 0,
|
|
|
|
duration: SCREEN_TRANSITION_DURATION,
|
|
|
|
delay: SCREEN_TRANSITION_DELAY,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
onStopped: () => this.hide(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|