2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-01-31 14:07:06 +00:00
|
|
|
/* exported MonitorConstraint, LayoutManager */
|
2011-06-13 13:54:05 +00:00
|
|
|
|
2017-06-08 15:07:56 +00:00
|
|
|
const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi;
|
2011-06-13 13:54:05 +00:00
|
|
|
const Signals = imports.signals;
|
|
|
|
|
2012-12-24 14:20:39 +00:00
|
|
|
const Background = imports.ui.background;
|
|
|
|
const BackgroundMenu = imports.ui.backgroundMenu;
|
2015-03-19 14:46:08 +00:00
|
|
|
const LoginManager = imports.misc.loginManager;
|
2012-12-24 14:20:39 +00:00
|
|
|
|
2012-02-11 10:14:43 +00:00
|
|
|
const DND = imports.ui.dnd;
|
2011-06-13 13:54:05 +00:00
|
|
|
const Main = imports.ui.main;
|
2011-07-25 13:56:51 +00:00
|
|
|
const Params = imports.misc.params;
|
2019-02-21 07:45:17 +00:00
|
|
|
const Ripples = imports.ui.ripples;
|
2011-07-14 12:35:55 +00:00
|
|
|
|
2019-08-01 23:13:10 +00:00
|
|
|
var STARTUP_ANIMATION_TIME = 500;
|
|
|
|
var KEYBOARD_ANIMATION_TIME = 150;
|
|
|
|
var BACKGROUND_FADE_ANIMATION_TIME = 1000;
|
2011-07-25 18:25:51 +00:00
|
|
|
|
2017-07-18 17:47:27 +00:00
|
|
|
var HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels
|
|
|
|
var HOT_CORNER_PRESSURE_TIMEOUT = 1000; // ms
|
2013-03-01 21:19:07 +00:00
|
|
|
|
2013-02-12 21:00:41 +00:00
|
|
|
function isPopupMetaWindow(actor) {
|
2019-01-29 01:27:05 +00:00
|
|
|
switch (actor.meta_window.get_window_type()) {
|
2013-02-12 21:00:41 +00:00
|
|
|
case Meta.WindowType.DROPDOWN_MENU:
|
|
|
|
case Meta.WindowType.POPUP_MENU:
|
|
|
|
case Meta.WindowType.COMBO:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-31 01:23:39 +00:00
|
|
|
var MonitorConstraint = GObject.registerClass({
|
2019-01-29 18:15:23 +00: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 21:43:54 +00:00
|
|
|
false),
|
2019-01-29 18:15:23 +00:00
|
|
|
},
|
2017-10-31 01:23:39 +00:00
|
|
|
}, class MonitorConstraint extends Clutter.Constraint {
|
2017-10-31 00:03:21 +00:00
|
|
|
_init(props) {
|
2012-08-14 13:37:12 +00:00
|
|
|
this._primary = false;
|
|
|
|
this._index = -1;
|
2015-02-06 18:27:02 +00:00
|
|
|
this._workArea = false;
|
2012-08-14 13:37:12 +00:00
|
|
|
|
2017-10-31 01:23:39 +00:00
|
|
|
super._init(props);
|
|
|
|
}
|
2012-08-14 13:37:12 +00:00
|
|
|
|
|
|
|
get primary() {
|
|
|
|
return this._primary;
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-08-14 13:37:12 +00:00
|
|
|
|
|
|
|
set primary(v) {
|
2012-10-14 16:34:22 +00:00
|
|
|
if (v)
|
|
|
|
this._index = -1;
|
2012-08-14 13:37:12 +00:00
|
|
|
this._primary = v;
|
|
|
|
if (this.actor)
|
|
|
|
this.actor.queue_relayout();
|
|
|
|
this.notify('primary');
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-08-14 13:37:12 +00:00
|
|
|
|
|
|
|
get index() {
|
|
|
|
return this._index;
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-08-14 13:37:12 +00:00
|
|
|
|
|
|
|
set index(v) {
|
2012-10-14 16:34:22 +00:00
|
|
|
this._primary = false;
|
2012-08-14 13:37:12 +00:00
|
|
|
this._index = v;
|
|
|
|
if (this.actor)
|
|
|
|
this.actor.queue_relayout();
|
|
|
|
this.notify('index');
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-08-14 13:37:12 +00:00
|
|
|
|
2019-02-01 00:16:20 +00:00
|
|
|
// eslint-disable-next-line camelcase
|
2015-02-06 18:27:02 +00:00
|
|
|
get work_area() {
|
|
|
|
return this._workArea;
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2015-02-06 18:27:02 +00:00
|
|
|
|
2019-02-01 00:16:20 +00:00
|
|
|
// eslint-disable-next-line camelcase
|
2015-02-06 18:27:02 +00:00
|
|
|
set work_area(v) {
|
|
|
|
if (v == this._workArea)
|
|
|
|
return;
|
|
|
|
this._workArea = v;
|
|
|
|
if (this.actor)
|
|
|
|
this.actor.queue_relayout();
|
|
|
|
this.notify('work-area');
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2015-02-06 18:27:02 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
vfunc_set_actor(actor) {
|
2012-08-14 13:37:12 +00:00
|
|
|
if (actor) {
|
|
|
|
if (!this._monitorsChangedId) {
|
2017-10-31 00:38:18 +00:00
|
|
|
this._monitorsChangedId =
|
|
|
|
Main.layoutManager.connect('monitors-changed', () => {
|
|
|
|
this.actor.queue_relayout();
|
|
|
|
});
|
2012-08-14 13:37:12 +00:00
|
|
|
}
|
2015-02-06 18:27:02 +00:00
|
|
|
|
|
|
|
if (!this._workareasChangedId) {
|
2017-10-31 00:38:18 +00:00
|
|
|
this._workareasChangedId =
|
2018-01-03 07:55:38 +00:00
|
|
|
global.display.connect('workareas-changed', () => {
|
2017-10-31 00:38:18 +00:00
|
|
|
if (this._workArea)
|
|
|
|
this.actor.queue_relayout();
|
|
|
|
});
|
2015-02-06 18:27:02 +00:00
|
|
|
}
|
2012-08-14 13:37:12 +00:00
|
|
|
} else {
|
|
|
|
if (this._monitorsChangedId)
|
|
|
|
Main.layoutManager.disconnect(this._monitorsChangedId);
|
|
|
|
this._monitorsChangedId = 0;
|
2015-02-06 18:27:02 +00:00
|
|
|
|
|
|
|
if (this._workareasChangedId)
|
2018-01-03 07:55:38 +00:00
|
|
|
global.display.disconnect(this._workareasChangedId);
|
2015-02-06 18:27:02 +00:00
|
|
|
this._workareasChangedId = 0;
|
2012-08-14 13:37:12 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 01:23:39 +00:00
|
|
|
super.vfunc_set_actor(actor);
|
|
|
|
}
|
2012-08-14 13:37:12 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
vfunc_update_allocation(actor, actorBox) {
|
2012-08-14 13:37:12 +00:00
|
|
|
if (!this._primary && this._index < 0)
|
|
|
|
return;
|
|
|
|
|
2017-04-12 06:46:54 +00:00
|
|
|
if (!Main.layoutManager.primaryMonitor)
|
|
|
|
return;
|
|
|
|
|
2015-02-06 18:27:02 +00: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 07:55:38 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let ws = workspaceManager.get_workspace_by_index(0);
|
2015-02-06 18:27:02 +00:00
|
|
|
rect = ws.get_work_area_for_monitor(index);
|
2012-08-14 13:37:12 +00:00
|
|
|
} else {
|
2015-02-06 18:27:02 +00:00
|
|
|
rect = Main.layoutManager.monitors[index];
|
2012-08-14 13:37:12 +00:00
|
|
|
}
|
|
|
|
|
2015-02-06 18:27:02 +00:00
|
|
|
actorBox.init_rect(rect.x, rect.y, rect.width, rect.height);
|
2012-08-14 13:37:12 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var Monitor = class Monitor {
|
2019-01-31 13:43:52 +00:00
|
|
|
constructor(index, geometry, geometryScale) {
|
2013-03-18 19:02:05 +00:00
|
|
|
this.index = index;
|
|
|
|
this.x = geometry.x;
|
|
|
|
this.y = geometry.y;
|
|
|
|
this.width = geometry.width;
|
|
|
|
this.height = geometry.height;
|
2019-01-31 13:43:52 +00:00
|
|
|
this.geometry_scale = geometryScale;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-18 19:02:05 +00:00
|
|
|
|
|
|
|
get inFullscreen() {
|
2018-01-03 07:55:38 +00:00
|
|
|
return global.display.get_monitor_in_fullscreen(this.index);
|
2013-03-18 19:02:05 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2013-03-18 19:02:05 +00:00
|
|
|
|
2019-03-05 10:34:27 +00:00
|
|
|
const UiActor = GObject.registerClass(
|
|
|
|
class UiActor extends St.Widget {
|
2019-08-19 17:55:49 +00:00
|
|
|
vfunc_get_preferred_width(_forHeight) {
|
2019-03-05 10:34:27 +00:00
|
|
|
let width = global.stage.width;
|
|
|
|
return [width, width];
|
|
|
|
}
|
|
|
|
|
2019-08-19 17:55:49 +00:00
|
|
|
vfunc_get_preferred_height(_forWidth) {
|
2019-03-05 10:34:27 +00:00
|
|
|
let height = global.stage.height;
|
|
|
|
return [height, height];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-01-28 04:34:33 +00:00
|
|
|
const defaultParams = {
|
|
|
|
trackFullscreen: false,
|
|
|
|
affectsStruts: false,
|
2019-08-20 21:43:54 +00:00
|
|
|
affectsInputRegion: true,
|
2013-01-28 04:34:33 +00:00
|
|
|
};
|
|
|
|
|
2017-10-31 01:23:39 +00:00
|
|
|
var LayoutManager = GObject.registerClass({
|
2018-08-21 10:13:30 +00:00
|
|
|
Signals: { 'hot-corners-changed': {},
|
|
|
|
'startup-complete': {},
|
|
|
|
'startup-prepared': {},
|
|
|
|
'monitors-changed': {},
|
2019-12-06 12:56:24 +00:00
|
|
|
'system-modal-opened': {},
|
2018-08-21 10:13:30 +00:00
|
|
|
'keyboard-visible-changed': { param_types: [GObject.TYPE_BOOLEAN] } },
|
2017-10-31 01:23:39 +00:00
|
|
|
}, class LayoutManager extends GObject.Object {
|
2017-10-31 00:03:21 +00:00
|
|
|
_init() {
|
2017-10-31 01:23:39 +00:00
|
|
|
super._init();
|
2018-08-21 10:13:30 +00:00
|
|
|
|
2019-08-19 19:38:51 +00:00
|
|
|
this._rtl = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL;
|
2011-06-13 13:54:05 +00:00
|
|
|
this.monitors = [];
|
|
|
|
this.primaryMonitor = null;
|
|
|
|
this.primaryIndex = -1;
|
2013-03-01 21:00:37 +00:00
|
|
|
this.hotCorners = [];
|
|
|
|
|
2012-10-14 16:57:45 +00:00
|
|
|
this._keyboardIndex = -1;
|
2012-07-30 17:02:33 +00:00
|
|
|
this._rightPanelBarrier = null;
|
2011-07-25 13:53:19 +00:00
|
|
|
|
2013-01-28 04:34:33 +00:00
|
|
|
this._inOverview = false;
|
|
|
|
this._updateRegionIdle = 0;
|
|
|
|
|
|
|
|
this._trackedActors = [];
|
2013-03-12 19:27:51 +00:00
|
|
|
this._topActors = [];
|
2013-02-12 21:00:41 +00:00
|
|
|
this._isPopupWindowVisible = false;
|
2013-02-20 01:20:44 +00:00
|
|
|
this._startingUp = true;
|
2017-04-12 06:46:54 +00:00
|
|
|
this._pendingLoadBackground = false;
|
2011-07-25 18:25:51 +00:00
|
|
|
|
2013-01-10 21:02:20 +00:00
|
|
|
// Set up stage hierarchy to group all UI actors under one container.
|
2019-03-05 10:34:27 +00:00
|
|
|
this.uiGroup = new UiActor({ name: 'uiGroup' });
|
2018-08-10 19:37:48 +00:00
|
|
|
this.uiGroup.set_flags(Clutter.ActorFlags.NO_LAYOUT);
|
2013-01-10 21:02:20 +00:00
|
|
|
|
2019-05-03 21:39:11 +00:00
|
|
|
global.stage.add_child(this.uiGroup);
|
|
|
|
|
2013-02-13 17:30:26 +00:00
|
|
|
global.stage.remove_actor(global.window_group);
|
|
|
|
this.uiGroup.add_actor(global.window_group);
|
2013-01-10 21:02:20 +00:00
|
|
|
|
2019-05-03 21:39:11 +00: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 21:02:20 +00:00
|
|
|
|
2013-05-22 16:05:24 +00:00
|
|
|
this.overviewGroup = new St.Widget({ name: 'overviewGroup',
|
2016-07-02 09:16:22 +00:00
|
|
|
visible: false,
|
|
|
|
reactive: true });
|
2013-05-22 16:05:24 +00:00
|
|
|
this.addChrome(this.overviewGroup);
|
|
|
|
|
2019-02-12 14:02:09 +00:00
|
|
|
this.screenShieldGroup = new St.Widget({
|
|
|
|
name: 'screenShieldGroup',
|
|
|
|
visible: false,
|
|
|
|
clip_to_allocation: true,
|
|
|
|
layout_manager: new Clutter.BinLayout(),
|
|
|
|
});
|
2019-06-04 18:55:29 +00:00
|
|
|
this.addChrome(this.screenShieldGroup);
|
2012-05-22 22:27:06 +00:00
|
|
|
|
2011-07-25 18:25:51 +00:00
|
|
|
this.panelBox = new St.BoxLayout({ name: 'panelBox',
|
|
|
|
vertical: true });
|
2012-05-22 20:16:31 +00:00
|
|
|
this.addChrome(this.panelBox, { affectsStruts: true,
|
|
|
|
trackFullscreen: true });
|
2011-07-25 18:25:51 +00:00
|
|
|
this.panelBox.connect('allocation-changed',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._panelBoxChanged.bind(this));
|
2011-07-25 18:25:51 +00:00
|
|
|
|
2014-03-18 13:44:44 +00:00
|
|
|
this.modalDialogGroup = new St.Widget({ name: 'modalDialogGroup',
|
|
|
|
layout_manager: new Clutter.BinLayout() });
|
|
|
|
this.uiGroup.add_actor(this.modalDialogGroup);
|
|
|
|
|
2011-09-09 14:56:51 +00:00
|
|
|
this.keyboardBox = new St.BoxLayout({ name: 'keyboardBox',
|
|
|
|
reactive: true,
|
|
|
|
track_hover: true });
|
2019-05-03 21:39:11 +00:00
|
|
|
this.addTopChrome(this.keyboardBox);
|
2011-09-01 15:37:54 +00:00
|
|
|
this._keyboardHeightNotifyId = 0;
|
2011-07-25 18:25:51 +00:00
|
|
|
|
2013-02-15 09:56:34 +00:00
|
|
|
// A dummy actor that tracks the mouse or text cursor, based on the
|
2014-04-11 14:12:52 +00:00
|
|
|
// position and size set in setDummyCursorGeometry.
|
2019-03-04 23:39:54 +00:00
|
|
|
this.dummyCursor = new St.Widget({ width: 0, height: 0, opacity: 0 });
|
2013-02-15 09:56:34 +00:00
|
|
|
this.uiGroup.add_actor(this.dummyCursor);
|
|
|
|
|
2018-01-03 07:55:38 +00:00
|
|
|
let feedbackGroup = Meta.get_feedback_group_for_display(global.display);
|
2014-10-07 00:07:59 +00:00
|
|
|
global.stage.remove_actor(feedbackGroup);
|
|
|
|
this.uiGroup.add_actor(feedbackGroup);
|
|
|
|
|
2012-12-24 14:20:39 +00:00
|
|
|
this._backgroundGroup = new Meta.BackgroundGroup();
|
|
|
|
global.window_group.add_child(this._backgroundGroup);
|
2019-11-05 19:17:19 +00:00
|
|
|
global.window_group.set_child_below_sibling(this._backgroundGroup, null);
|
2012-12-24 14:20:39 +00:00
|
|
|
this._bgManagers = [];
|
|
|
|
|
2017-06-08 15:07:56 +00:00
|
|
|
this._interfaceSettings = new Gio.Settings({
|
2019-08-20 21:43:54 +00:00
|
|
|
schema_id: 'org.gnome.desktop.interface',
|
2017-06-08 15:07:56 +00:00
|
|
|
});
|
|
|
|
|
2019-07-11 01:01:40 +00:00
|
|
|
this._interfaceSettings.connect('changed::enable-hot-corners',
|
|
|
|
this._updateHotCorners.bind(this));
|
2017-06-08 15:07:56 +00:00
|
|
|
|
2013-01-28 04:34:33 +00:00
|
|
|
// Need to update struts on new workspaces when they are added
|
2018-01-03 07:55:38 +00: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 18:25:51 +00:00
|
|
|
this._monitorsChanged();
|
2015-03-19 14:46:08 +00:00
|
|
|
|
|
|
|
// NVIDIA drivers don't preserve FBO contents across
|
|
|
|
// suspend/resume, see
|
|
|
|
// https://bugzilla.gnome.org/show_bug.cgi?id=739178
|
|
|
|
if (Shell.util_need_background_refresh()) {
|
|
|
|
LoginManager.getLoginManager().connect('prepare-for-sleep',
|
2017-10-31 00:38:18 +00:00
|
|
|
(lm, suspending) => {
|
|
|
|
if (suspending)
|
|
|
|
return;
|
|
|
|
Meta.Background.refresh_all();
|
|
|
|
});
|
2015-03-19 14:46:08 +00:00
|
|
|
}
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-06-13 13:54:05 +00:00
|
|
|
|
2013-05-22 16:05:24 +00:00
|
|
|
// This is called by Main after everything else is constructed
|
2017-10-31 00:03:21 +00:00
|
|
|
init() {
|
2017-12-02 00:27:35 +00:00
|
|
|
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
|
2013-03-06 22:55:33 +00:00
|
|
|
|
2013-05-18 23:34:35 +00:00
|
|
|
this._loadBackground();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2013-01-28 04:34:33 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
showOverview() {
|
2013-05-22 16:05:24 +00:00
|
|
|
this.overviewGroup.show();
|
|
|
|
|
2013-01-28 04:34:33 +00:00
|
|
|
this._inOverview = true;
|
|
|
|
this._updateVisibility();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 18:25:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
hideOverview() {
|
2013-05-22 16:05:24 +00:00
|
|
|
this.overviewGroup.hide();
|
|
|
|
|
2013-01-28 04:34:33 +00:00
|
|
|
this._inOverview = false;
|
|
|
|
this._updateVisibility();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2013-01-28 04:34:33 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_sessionUpdated() {
|
2013-01-28 04:34:33 +00:00
|
|
|
this._updateVisibility();
|
|
|
|
this._queueUpdateRegions();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-06-13 13:54:05 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateMonitors() {
|
2018-01-03 07:55:38 +00:00
|
|
|
let display = global.display;
|
2011-06-13 13:54:05 +00:00
|
|
|
|
|
|
|
this.monitors = [];
|
2018-01-03 07:55:38 +00:00
|
|
|
let nMonitors = display.get_n_monitors();
|
2019-08-20 00:51:42 +00:00
|
|
|
for (let i = 0; i < nMonitors; i++) {
|
2017-08-03 13:51:42 +00:00
|
|
|
this.monitors.push(new Monitor(i,
|
|
|
|
display.get_monitor_geometry(i),
|
|
|
|
display.get_monitor_scale(i)));
|
2019-08-20 00:51:42 +00:00
|
|
|
}
|
2011-06-13 13:54:05 +00:00
|
|
|
|
2017-04-12 06:46:54 +00:00
|
|
|
if (nMonitors == 0) {
|
|
|
|
this.primaryIndex = this.bottomIndex = -1;
|
|
|
|
} else if (nMonitors == 1) {
|
2011-06-13 14:37:10 +00: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 07:55:38 +00:00
|
|
|
this.primaryIndex = this.bottomIndex = display.get_primary_monitor();
|
2011-06-13 14:37:10 +00: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 06:46:54 +00: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-07 00:26:24 +00:00
|
|
|
} else {
|
|
|
|
this.primaryMonitor = null;
|
|
|
|
this.bottomMonitor = null;
|
2017-04-12 06:46:54 +00:00
|
|
|
}
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-06-13 13:54:05 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateHotCorners() {
|
2011-06-13 13:54:05 +00:00
|
|
|
// destroy old hot corners
|
2017-10-31 00:38:18 +00:00
|
|
|
this.hotCorners.forEach(corner => {
|
2013-03-19 19:50:16 +00:00
|
|
|
if (corner)
|
|
|
|
corner.destroy();
|
|
|
|
});
|
2013-03-01 21:00:37 +00:00
|
|
|
this.hotCorners = [];
|
2011-06-13 13:54:05 +00:00
|
|
|
|
2017-06-08 15:07:56 +00:00
|
|
|
if (!this._interfaceSettings.get_boolean('enable-hot-corners')) {
|
|
|
|
this.emit('hot-corners-changed');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-01 20:07:11 +00:00
|
|
|
let size = this.panelBox.height;
|
|
|
|
|
2011-06-13 13:54:05 +00: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 19:50:16 +00:00
|
|
|
let haveTopLeftCorner = true;
|
2011-06-13 13:54:05 +00:00
|
|
|
|
2013-03-19 19:50:16 +00:00
|
|
|
if (i != this.primaryIndex) {
|
2013-03-01 21:00:37 +00: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 12:35:55 +00:00
|
|
|
|
2013-03-01 21:00:37 +00: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 13:54:05 +00:00
|
|
|
}
|
2013-03-01 21:00:37 +00:00
|
|
|
}
|
2011-06-13 13:54:05 +00:00
|
|
|
|
2013-03-19 19:50:16 +00: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 13:54:05 +00:00
|
|
|
}
|
2013-03-01 21:00:37 +00:00
|
|
|
|
|
|
|
this.emit('hot-corners-changed');
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-06-13 13:54:05 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_addBackgroundMenu(bgManager) {
|
2014-08-11 16:15:45 +00:00
|
|
|
BackgroundMenu.addBackgroundMenu(bgManager.backgroundActor, this);
|
2017-10-31 01:23:39 +00: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 22:14:47 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_createBackgroundManager(monitorIndex) {
|
2012-12-24 14:20:39 +00:00
|
|
|
let bgManager = new Background.BackgroundManager({ container: this._backgroundGroup,
|
|
|
|
layoutManager: this,
|
2019-08-19 19:06:04 +00:00
|
|
|
monitorIndex });
|
2012-12-24 14:20:39 +00:00
|
|
|
|
2017-12-02 00:27:35 +00: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 22:14:47 +00:00
|
|
|
this._addBackgroundMenu(bgManager);
|
2012-12-24 14:20:39 +00: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 22:14:47 +00:00
|
|
|
return bgManager;
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-12-24 14:20:39 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_showSecondaryBackgrounds() {
|
2012-12-24 14:20:39 +00:00
|
|
|
for (let i = 0; i < this.monitors.length; i++) {
|
|
|
|
if (i != this.primaryIndex) {
|
2014-08-11 16:15:45 +00:00
|
|
|
let backgroundActor = this._bgManagers[i].backgroundActor;
|
|
|
|
backgroundActor.show();
|
|
|
|
backgroundActor.opacity = 0;
|
2018-07-20 19:46:19 +00:00
|
|
|
backgroundActor.ease({
|
|
|
|
opacity: 255,
|
|
|
|
duration: BACKGROUND_FADE_ANIMATION_TIME,
|
2019-08-20 21:43:54 +00:00
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2018-07-20 19:46:19 +00:00
|
|
|
});
|
2012-12-24 14:20:39 +00:00
|
|
|
}
|
|
|
|
}
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-12-24 14:20:39 +00:00
|
|
|
|
2020-07-21 00:00:32 +00:00
|
|
|
_waitLoaded(bgManager) {
|
|
|
|
return new Promise(resolve => {
|
|
|
|
const id = bgManager.connect('loaded', () => {
|
|
|
|
bgManager.disconnect(id);
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateBackgrounds() {
|
2019-08-20 00:20:08 +00:00
|
|
|
for (let i = 0; i < this._bgManagers.length; i++)
|
2012-12-24 14:20:39 +00:00
|
|
|
this._bgManagers[i].destroy();
|
|
|
|
|
|
|
|
this._bgManagers = [];
|
|
|
|
|
|
|
|
if (Main.sessionMode.isGreeter)
|
2020-07-21 00:00:32 +00:00
|
|
|
return Promise.resolve();
|
2012-12-24 14:20:39 +00: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 22:14:47 +00:00
|
|
|
let bgManager = this._createBackgroundManager(i);
|
|
|
|
this._bgManagers.push(bgManager);
|
|
|
|
|
|
|
|
if (i != this.primaryIndex && this._startingUp)
|
2014-08-11 16:15:45 +00:00
|
|
|
bgManager.backgroundActor.hide();
|
2012-12-24 14:20:39 +00:00
|
|
|
}
|
2020-07-21 00:00:32 +00:00
|
|
|
|
|
|
|
return Promise.all(this._bgManagers.map(this._waitLoaded));
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-12-24 14:20:39 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateKeyboardBox() {
|
2014-07-26 15:45:10 +00:00
|
|
|
this.keyboardBox.set_position(this.keyboardMonitor.x,
|
|
|
|
this.keyboardMonitor.y + this.keyboardMonitor.height);
|
|
|
|
this.keyboardBox.set_size(this.keyboardMonitor.width, -1);
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2014-07-26 15:45:10 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateBoxes() {
|
2012-05-24 20:47:48 +00:00
|
|
|
this.screenShieldGroup.set_position(0, 0);
|
|
|
|
this.screenShieldGroup.set_size(global.screen_width, global.screen_height);
|
|
|
|
|
2017-04-12 06:46:54 +00:00
|
|
|
if (!this.primaryMonitor)
|
|
|
|
return;
|
|
|
|
|
2011-07-25 18:25:51 +00:00
|
|
|
this.panelBox.set_position(this.primaryMonitor.x, this.primaryMonitor.y);
|
|
|
|
this.panelBox.set_size(this.primaryMonitor.width, -1);
|
|
|
|
|
2014-10-13 15:43:39 +00:00
|
|
|
this.keyboardIndex = this.primaryIndex;
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 18:25:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_panelBoxChanged() {
|
2013-03-01 20:07:11 +00:00
|
|
|
this._updatePanelBarrier();
|
2012-12-03 20:56:18 +00:00
|
|
|
|
2013-03-01 20:07:11 +00:00
|
|
|
let size = this.panelBox.height;
|
2017-10-31 00:38:18 +00:00
|
|
|
this.hotCorners.forEach(corner => {
|
2013-03-19 19:50:16 +00:00
|
|
|
if (corner)
|
|
|
|
corner.setBarrierSize(size);
|
2013-03-01 20:07:11 +00:00
|
|
|
});
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-07-30 17:02:33 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updatePanelBarrier() {
|
2012-07-30 17:02:33 +00:00
|
|
|
if (this._rightPanelBarrier) {
|
|
|
|
this._rightPanelBarrier.destroy();
|
|
|
|
this._rightPanelBarrier = null;
|
|
|
|
}
|
2011-07-25 18:25:51 +00:00
|
|
|
|
2017-04-12 06:46:54 +00:00
|
|
|
if (!this.primaryMonitor)
|
|
|
|
return;
|
|
|
|
|
2011-07-25 18:25:51 +00:00
|
|
|
if (this.panelBox.height) {
|
|
|
|
let primary = this.primaryMonitor;
|
2012-07-30 17:02:33 +00: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 18:25:51 +00:00
|
|
|
}
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 18:25:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_monitorsChanged() {
|
2011-06-13 13:54:05 +00:00
|
|
|
this._updateMonitors();
|
2011-07-25 18:25:51 +00:00
|
|
|
this._updateBoxes();
|
2011-06-13 13:54:05 +00:00
|
|
|
this._updateHotCorners();
|
2012-12-24 14:20:39 +00:00
|
|
|
this._updateBackgrounds();
|
2013-01-28 04:34:33 +00:00
|
|
|
this._updateFullscreen();
|
|
|
|
this._updateVisibility();
|
|
|
|
this._queueUpdateRegions();
|
2011-06-13 13:54:05 +00:00
|
|
|
|
|
|
|
this.emit('monitors-changed');
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-06-13 13:54:05 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_isAboveOrBelowPrimary(monitor) {
|
2011-06-13 14:37:10 +00: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 17:21:18 +00:00
|
|
|
if ((monitorLeft >= primaryLeft && monitorLeft < primaryRight) ||
|
|
|
|
(monitorRight > primaryLeft && monitorRight <= primaryRight) ||
|
|
|
|
(primaryLeft >= monitorLeft && primaryLeft < monitorRight) ||
|
|
|
|
(primaryRight > monitorLeft && primaryRight <= monitorRight))
|
2011-06-13 14:37:10 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-06-13 14:37:10 +00:00
|
|
|
|
2012-06-08 08:26:58 +00:00
|
|
|
get currentMonitor() {
|
2018-01-03 07:55:38 +00:00
|
|
|
let index = global.display.get_current_monitor();
|
2012-08-22 07:15:53 +00:00
|
|
|
return this.monitors[index];
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:53:19 +00:00
|
|
|
|
2012-10-14 16:57:45 +00:00
|
|
|
get keyboardMonitor() {
|
|
|
|
return this.monitors[this.keyboardIndex];
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-10-14 16:57:45 +00: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 04:18:13 +00: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 16:57:45 +00:00
|
|
|
return i;
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-10-14 16:57:45 +00:00
|
|
|
|
|
|
|
get focusMonitor() {
|
2018-06-28 14:51:48 +00:00
|
|
|
if (this.focusIndex < 0)
|
|
|
|
return null;
|
2012-10-14 16:57:45 +00:00
|
|
|
return this.monitors[this.focusIndex];
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-10-14 16:57:45 +00:00
|
|
|
|
|
|
|
set keyboardIndex(v) {
|
|
|
|
this._keyboardIndex = v;
|
2014-07-26 15:45:10 +00:00
|
|
|
this._updateKeyboardBox();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-10-14 16:57:45 +00:00
|
|
|
|
|
|
|
get keyboardIndex() {
|
|
|
|
return this._keyboardIndex;
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-10-14 16:57:45 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_loadBackground() {
|
2017-04-12 06:46:54 +00:00
|
|
|
if (!this.primaryMonitor) {
|
|
|
|
this._pendingLoadBackground = true;
|
|
|
|
return;
|
|
|
|
}
|
2013-05-18 23:34:35 +00:00
|
|
|
this._systemBackground = new Background.SystemBackground();
|
2019-07-16 09:24:13 +00:00
|
|
|
this._systemBackground.hide();
|
2013-05-18 23:34:35 +00:00
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
global.stage.insert_child_below(this._systemBackground, null);
|
2013-05-18 23:34:35 +00:00
|
|
|
|
|
|
|
let constraint = new Clutter.BindConstraint({ source: global.stage,
|
|
|
|
coordinate: Clutter.BindCoordinate.ALL });
|
2019-07-16 09:24:13 +00:00
|
|
|
this._systemBackground.add_constraint(constraint);
|
2013-05-18 23:34:35 +00:00
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
let signalId = this._systemBackground.connect('loaded', () => {
|
2013-05-18 23:34:35 +00:00
|
|
|
this._systemBackground.disconnect(signalId);
|
|
|
|
|
2020-03-17 07:58:21 +00: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, () => {
|
|
|
|
this._systemBackground.show();
|
|
|
|
global.stage.show();
|
|
|
|
this._prepareStartupAnimation();
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
});
|
|
|
|
GLib.Source.set_name_by_id(id, '[gnome-shell] Startup Animation');
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2013-05-18 23:34:35 +00:00
|
|
|
|
2012-12-24 14:20:39 +00: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-21 00:00:32 +00:00
|
|
|
async _prepareStartupAnimation() {
|
2013-05-18 23:06:50 +00: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.
|
|
|
|
this._coverPane = new Clutter.Actor({ opacity: 0,
|
|
|
|
width: global.screen_width,
|
|
|
|
height: global.screen_height,
|
|
|
|
reactive: true });
|
|
|
|
this.addChrome(this._coverPane);
|
2012-12-24 14:20:39 +00:00
|
|
|
|
2014-05-08 22:56:23 +00:00
|
|
|
if (Meta.is_restart()) {
|
2016-02-04 18:13:13 +00:00
|
|
|
// On restart, we don't do an animation. Force an update of the
|
|
|
|
// regions immediately so that maximized windows restore to the
|
|
|
|
// right size taking struts into account.
|
|
|
|
this._updateRegions();
|
2014-05-08 22:56:23 +00:00
|
|
|
} else if (Main.sessionMode.isGreeter) {
|
2012-12-24 14:20:39 +00:00
|
|
|
this.panelBox.translation_y = -this.panelBox.height;
|
|
|
|
} else {
|
2013-02-20 04:21:35 +00:00
|
|
|
// We need to force an update of the regions now before we scale
|
2014-04-13 16:47:06 +00:00
|
|
|
// the UI group to get the correct allocation for the struts.
|
2013-02-20 04:21:35 +00:00
|
|
|
this._updateRegions();
|
|
|
|
|
2013-02-20 00:56:56 +00:00
|
|
|
this.keyboardBox.hide();
|
|
|
|
|
2012-12-24 14:20:39 +00:00
|
|
|
let monitor = this.primaryMonitor;
|
|
|
|
let x = monitor.x + monitor.width / 2.0;
|
|
|
|
let y = monitor.y + monitor.height / 2.0;
|
|
|
|
|
|
|
|
this.uiGroup.set_pivot_point(x / global.screen_width,
|
|
|
|
y / global.screen_height);
|
2013-11-20 01:35:30 +00:00
|
|
|
this.uiGroup.scale_x = this.uiGroup.scale_y = 0.75;
|
2013-02-21 19:38:50 +00:00
|
|
|
this.uiGroup.opacity = 0;
|
2013-03-20 00:16:54 +00:00
|
|
|
global.window_group.set_clip(monitor.x, monitor.y, monitor.width, monitor.height);
|
2020-07-21 00:00:32 +00:00
|
|
|
|
|
|
|
await this._updateBackgrounds();
|
2012-12-24 14:20:39 +00:00
|
|
|
}
|
2013-02-21 19:32:23 +00:00
|
|
|
|
2013-05-18 23:34:35 +00:00
|
|
|
this.emit('startup-prepared');
|
|
|
|
|
2020-03-17 07:58:21 +00:00
|
|
|
this._startupAnimation();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-08-22 07:22:30 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_startupAnimation() {
|
2014-05-08 22:56:23 +00:00
|
|
|
if (Meta.is_restart())
|
|
|
|
this._startupAnimationComplete();
|
|
|
|
else if (Main.sessionMode.isGreeter)
|
2012-12-24 14:20:39 +00:00
|
|
|
this._startupAnimationGreeter();
|
|
|
|
else
|
|
|
|
this._startupAnimationSession();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-09-02 20:36:02 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_startupAnimationGreeter() {
|
2018-07-20 19:46:19 +00:00
|
|
|
this.panelBox.ease({
|
|
|
|
translation_y: 0,
|
|
|
|
duration: STARTUP_ANIMATION_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2019-08-20 21:43:54 +00:00
|
|
|
onComplete: () => this._startupAnimationComplete(),
|
2018-07-20 19:46:19 +00:00
|
|
|
});
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-08-22 07:22:30 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_startupAnimationSession() {
|
2018-07-20 19:46:19 +00:00
|
|
|
this.uiGroup.ease({
|
|
|
|
scale_x: 1,
|
|
|
|
scale_y: 1,
|
|
|
|
opacity: 255,
|
|
|
|
duration: STARTUP_ANIMATION_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2019-08-20 21:43:54 +00:00
|
|
|
onComplete: () => this._startupAnimationComplete(),
|
2018-07-20 19:46:19 +00:00
|
|
|
});
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 18:25:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_startupAnimationComplete() {
|
2013-05-18 23:06:50 +00:00
|
|
|
this._coverPane.destroy();
|
|
|
|
this._coverPane = null;
|
2012-12-24 14:20:39 +00:00
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
this._systemBackground.destroy();
|
2013-02-21 19:32:23 +00:00
|
|
|
this._systemBackground = null;
|
2013-02-20 01:31:56 +00:00
|
|
|
|
2013-02-20 01:20:44 +00:00
|
|
|
this._startingUp = false;
|
2012-12-24 14:20:39 +00:00
|
|
|
|
2013-02-20 00:56:56 +00:00
|
|
|
this.keyboardBox.show();
|
|
|
|
|
2013-03-20 00:16:54 +00: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 22:14:47 +00:00
|
|
|
this._showSecondaryBackgrounds();
|
2013-03-20 00:16:54 +00:00
|
|
|
global.window_group.remove_clip();
|
|
|
|
}
|
2012-12-24 14:20:39 +00:00
|
|
|
|
2013-02-20 04:21:35 +00:00
|
|
|
this._queueUpdateRegions();
|
2013-03-04 13:07:14 +00:00
|
|
|
|
|
|
|
this.emit('startup-complete');
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-09-02 20:36:02 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
showKeyboard() {
|
2017-08-15 18:48:47 +00:00
|
|
|
this.keyboardBox.show();
|
2018-07-20 19:46:19 +00:00
|
|
|
this.keyboardBox.ease({
|
2020-02-20 13:23:01 +00:00
|
|
|
translation_y: -this.keyboardBox.height,
|
2018-07-20 19:46:19 +00:00
|
|
|
opacity: 255,
|
|
|
|
duration: KEYBOARD_ANIMATION_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
onComplete: () => {
|
|
|
|
this._showKeyboardComplete();
|
2019-08-20 21:43:54 +00:00
|
|
|
},
|
2018-07-20 19:46:19 +00:00
|
|
|
});
|
2012-09-08 18:01:30 +00:00
|
|
|
this.emit('keyboard-visible-changed', true);
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-08-29 15:11:22 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_showKeyboardComplete() {
|
2011-08-29 15:11:22 +00:00
|
|
|
// Poke Chrome to update the input shape; it doesn't notice
|
|
|
|
// anchor point changes
|
2013-01-28 04:34:33 +00:00
|
|
|
this._updateRegions();
|
2011-08-29 15:11:22 +00:00
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
this._keyboardHeightNotifyId = this.keyboardBox.connect('notify::height', () => {
|
2020-02-20 13:23:01 +00:00
|
|
|
this.keyboardBox.translation_y = -this.keyboardBox.height;
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-08-29 15:11:22 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
hideKeyboard(immediate) {
|
2011-09-01 15:35:25 +00:00
|
|
|
if (this._keyboardHeightNotifyId) {
|
2011-09-01 15:37:54 +00:00
|
|
|
this.keyboardBox.disconnect(this._keyboardHeightNotifyId);
|
2011-09-01 15:35:25 +00:00
|
|
|
this._keyboardHeightNotifyId = 0;
|
|
|
|
}
|
2018-07-20 19:46:19 +00:00
|
|
|
this.keyboardBox.ease({
|
2020-03-28 13:34:24 +00:00
|
|
|
translation_y: 0,
|
2018-07-20 19:46:19 +00:00
|
|
|
opacity: 0,
|
2019-08-19 19:33:15 +00:00
|
|
|
duration: immediate ? 0 : KEYBOARD_ANIMATION_TIME,
|
2018-07-20 19:46:19 +00:00
|
|
|
mode: Clutter.AnimationMode.EASE_IN_QUAD,
|
|
|
|
onComplete: () => {
|
|
|
|
this._hideKeyboardComplete();
|
2019-08-20 21:43:54 +00:00
|
|
|
},
|
2018-07-20 19:46:19 +00:00
|
|
|
});
|
2012-10-14 16:57:45 +00:00
|
|
|
|
2012-09-08 18:01:30 +00:00
|
|
|
this.emit('keyboard-visible-changed', false);
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-08-29 15:11:22 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_hideKeyboardComplete() {
|
2017-08-15 18:48:47 +00:00
|
|
|
this.keyboardBox.hide();
|
2013-01-28 04:34:33 +00:00
|
|
|
this._updateRegions();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-08-29 15:11:22 +00:00
|
|
|
|
2014-04-11 14:12:52 +00:00
|
|
|
// setDummyCursorGeometry:
|
2013-02-15 09:56:34 +00: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 14:12:52 +00:00
|
|
|
// position and has the right size.
|
2017-10-31 00:03:21 +00:00
|
|
|
setDummyCursorGeometry(x, y, w, h) {
|
2013-02-15 09:56:34 +00:00
|
|
|
this.dummyCursor.set_position(Math.round(x), Math.round(y));
|
2014-04-11 14:12:52 +00:00
|
|
|
this.dummyCursor.set_size(Math.round(w), Math.round(h));
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2013-02-15 09:56:34 +00:00
|
|
|
|
2011-07-25 13:53:19 +00:00
|
|
|
// addChrome:
|
2011-09-01 14:20:52 +00:00
|
|
|
// @actor: an actor to add to the chrome
|
2011-07-25 13:53:19 +00:00
|
|
|
// @params: (optional) additional params
|
|
|
|
//
|
2015-02-09 08:25:00 +00: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 13:53:19 +00: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 20:16:31 +00: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-31 00:03:21 +00:00
|
|
|
addChrome(actor, params) {
|
2013-01-10 21:02:20 +00:00
|
|
|
this.uiGroup.add_actor(actor);
|
2013-06-26 08:41:04 +00:00
|
|
|
if (this.uiGroup.contains(global.top_window_group))
|
|
|
|
this.uiGroup.set_child_below_sibling(actor, global.top_window_group);
|
2013-01-28 04:34:33 +00:00
|
|
|
this._trackActor(actor, params);
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:53:19 +00:00
|
|
|
|
2019-05-03 21:39:11 +00: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 13:53:19 +00:00
|
|
|
// trackChrome:
|
|
|
|
// @actor: a descendant of the chrome to begin tracking
|
|
|
|
// @params: parameters describing how to track @actor
|
|
|
|
//
|
2017-07-14 20:23:53 +00:00
|
|
|
// Tells the chrome to track @actor. This can be used to extend the
|
2011-07-25 13:53:19 +00:00
|
|
|
// struts or input region to cover specific children.
|
|
|
|
//
|
|
|
|
// @params can have any of the same values as in addChrome(),
|
2012-05-22 20:16:31 +00:00
|
|
|
// though some possibilities don't make sense. By default, @actor has
|
|
|
|
// the same params as its chrome ancestor.
|
2019-07-11 23:31:38 +00:00
|
|
|
trackChrome(actor, params = {}) {
|
2011-07-25 13:56:51 +00: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 19:33:15 +00:00
|
|
|
let ancestorData = ancestor
|
|
|
|
? this._trackedActors[index]
|
|
|
|
: defaultParams;
|
2011-07-25 13:56:51 +00: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 23:05:27 +00:00
|
|
|
if (!Object.prototype.hasOwnProperty.call(params, prop))
|
2011-07-25 13:56:51 +00:00
|
|
|
params[prop] = ancestorData[prop];
|
|
|
|
}
|
|
|
|
|
|
|
|
this._trackActor(actor, params);
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2013-01-28 04:34:33 +00:00
|
|
|
// untrackChrome:
|
|
|
|
// @actor: an actor previously tracked via trackChrome()
|
|
|
|
//
|
|
|
|
// Undoes the effect of trackChrome()
|
2017-10-31 00:03:21 +00:00
|
|
|
untrackChrome(actor) {
|
2011-07-25 13:56:51 +00:00
|
|
|
this._untrackActor(actor);
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2013-01-28 04:34:33 +00:00
|
|
|
// removeChrome:
|
|
|
|
// @actor: a chrome actor
|
|
|
|
//
|
|
|
|
// Removes @actor from the chrome
|
2017-10-31 00:03:21 +00:00
|
|
|
removeChrome(actor) {
|
2013-01-10 21:02:20 +00:00
|
|
|
this.uiGroup.remove_actor(actor);
|
2011-07-25 13:56:51 +00:00
|
|
|
this._untrackActor(actor);
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_findActor(actor) {
|
2011-07-25 13:56:51 +00: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-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_trackActor(actor, params) {
|
2011-07-25 13:56:51 +00: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;
|
|
|
|
actorData.visibleId = actor.connect('notify::visible',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._queueUpdateRegions.bind(this));
|
2011-07-25 13:56:51 +00:00
|
|
|
actorData.allocationId = actor.connect('notify::allocation',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._queueUpdateRegions.bind(this));
|
2014-02-08 20:44:58 +00:00
|
|
|
actorData.destroyId = actor.connect('destroy',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._untrackActor.bind(this));
|
2011-07-25 13:56:51 +00: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 15:33:24 +00:00
|
|
|
this._updateActorVisibility(actorData);
|
2011-07-25 13:56:51 +00:00
|
|
|
this._queueUpdateRegions();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_untrackActor(actor) {
|
2011-07-25 13:56:51 +00:00
|
|
|
let i = this._findActor(actor);
|
|
|
|
|
|
|
|
if (i == -1)
|
|
|
|
return;
|
|
|
|
let actorData = this._trackedActors[i];
|
|
|
|
|
|
|
|
this._trackedActors.splice(i, 1);
|
|
|
|
actor.disconnect(actorData.visibleId);
|
|
|
|
actor.disconnect(actorData.allocationId);
|
2014-02-08 20:44:58 +00:00
|
|
|
actor.disconnect(actorData.destroyId);
|
2011-07-25 13:56:51 +00:00
|
|
|
|
|
|
|
this._queueUpdateRegions();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateActorVisibility(actorData) {
|
2015-05-14 15:33:24 +00:00
|
|
|
if (!actorData.trackFullscreen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let monitor = this.findMonitorForActor(actorData.actor);
|
|
|
|
actorData.actor.visible = !(global.window_group.visible &&
|
|
|
|
monitor &&
|
|
|
|
monitor.inFullscreen);
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2015-05-14 15:33:24 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateVisibility() {
|
2013-03-13 18:38:59 +00:00
|
|
|
let windowsVisible = Main.sessionMode.hasWindows && !this._inOverview;
|
|
|
|
|
|
|
|
global.window_group.visible = windowsVisible;
|
|
|
|
global.top_window_group.visible = windowsVisible;
|
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
this._trackedActors.forEach(this._updateActorVisibility.bind(this));
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getWorkAreaForMonitor(monitorIndex) {
|
2013-01-28 05:09:12 +00:00
|
|
|
// Assume that all workspaces will have the same
|
|
|
|
// struts and pick the first one.
|
2018-01-03 07:55:38 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let ws = workspaceManager.get_workspace_by_index(0);
|
2013-01-28 05:09:12 +00:00
|
|
|
return ws.get_work_area_for_monitor(monitorIndex);
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2013-01-28 05:09:12 +00:00
|
|
|
|
2011-07-25 13:56:51 +00: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-31 00:03:21 +00:00
|
|
|
findIndexForActor(actor) {
|
2011-07-25 13:56:51 +00:00
|
|
|
let [x, y] = actor.get_transformed_position();
|
|
|
|
let [w, h] = actor.get_transformed_size();
|
2019-08-19 19:06:04 +00:00
|
|
|
let rect = new Meta.Rectangle({ x, y, width: w, height: h });
|
2018-01-03 07:55:38 +00:00
|
|
|
return global.display.get_monitor_index_for_rect(rect);
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2012-10-14 16:57:45 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
findMonitorForActor(actor) {
|
2017-06-13 03:39:06 +00:00
|
|
|
let index = this.findIndexForActor(actor);
|
|
|
|
if (index >= 0 && index < this.monitors.length)
|
|
|
|
return this.monitors[index];
|
|
|
|
return null;
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_queueUpdateRegions() {
|
2013-02-20 04:21:35 +00:00
|
|
|
if (this._startingUp)
|
|
|
|
return;
|
|
|
|
|
2019-08-20 00:51:42 +00:00
|
|
|
if (!this._updateRegionIdle) {
|
2014-03-13 20:46:34 +00:00
|
|
|
this._updateRegionIdle = Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
|
2017-12-02 00:27:35 +00:00
|
|
|
this._updateRegions.bind(this));
|
2019-08-20 00:51:42 +00:00
|
|
|
}
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getWindowActorsForWorkspace(workspace) {
|
2017-10-31 00:38:18 +00:00
|
|
|
return global.get_window_actors().filter(actor => {
|
2013-01-14 17:43:24 +00:00
|
|
|
let win = actor.meta_window;
|
|
|
|
return win.located_on_workspace(workspace);
|
|
|
|
});
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2013-01-14 17:43:24 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateFullscreen() {
|
2013-03-14 18:36:13 +00:00
|
|
|
this._updateVisibility();
|
|
|
|
this._queueUpdateRegions();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_windowsRestacked() {
|
2011-07-25 13:56:51 +00:00
|
|
|
let changed = false;
|
2012-06-06 22:20:23 +00:00
|
|
|
|
2013-03-14 18:36:13 +00:00
|
|
|
if (this._isPopupWindowVisible != global.top_window_group.get_children().some(isPopupMetaWindow))
|
2013-02-12 21:00:41 +00:00
|
|
|
changed = true;
|
|
|
|
|
2011-07-25 13:56:51 +00:00
|
|
|
if (changed) {
|
|
|
|
this._updateVisibility();
|
|
|
|
this._queueUpdateRegions();
|
|
|
|
}
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateRegions() {
|
2011-08-29 15:11:22 +00:00
|
|
|
if (this._updateRegionIdle) {
|
2014-03-13 20:46:34 +00:00
|
|
|
Meta.later_remove(this._updateRegionIdle);
|
2011-08-29 15:11:22 +00:00
|
|
|
delete this._updateRegionIdle;
|
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2014-09-20 00:54:31 +00:00
|
|
|
// No need to update when we have a modal.
|
|
|
|
if (Main.modalCount > 0)
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
|
|
|
|
let rects = [], struts = [], i;
|
2013-02-12 21:00:41 +00:00
|
|
|
let isPopupMenuVisible = global.top_window_group.get_children().some(isPopupMetaWindow);
|
|
|
|
let wantsInputRegion = !isPopupMenuVisible;
|
|
|
|
|
2011-07-25 13:56:51 +00:00
|
|
|
for (i = 0; i < this._trackedActors.length; i++) {
|
|
|
|
let actorData = this._trackedActors[i];
|
2015-02-09 08:25:00 +00:00
|
|
|
if (!(actorData.affectsInputRegion && wantsInputRegion) && !actorData.affectsStruts)
|
2011-07-25 13:56:51 +00: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);
|
|
|
|
|
2015-02-09 08:25:00 +00:00
|
|
|
if (actorData.affectsInputRegion && wantsInputRegion && actorData.actor.get_paint_visibility())
|
2019-08-19 19:06:04 +00:00
|
|
|
rects.push(new Meta.Rectangle({ x, y, width: w, height: h }));
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2017-07-13 13:53:04 +00:00
|
|
|
let monitor = null;
|
|
|
|
if (actorData.affectsStruts)
|
|
|
|
monitor = this.findMonitorForActor(actorData.actor);
|
|
|
|
|
|
|
|
if (monitor) {
|
2013-02-12 20:57:08 +00: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 22:03:07 +00: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 20:57:08 +00:00
|
|
|
// only touching one edge, or is touching the entire
|
2015-02-08 22:03:07 +00: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 20:57:08 +00:00
|
|
|
let side;
|
2015-02-08 22:03:07 +00:00
|
|
|
if (x1 <= monitor.x && x2 >= monitor.x + monitor.width) {
|
|
|
|
if (y1 <= monitor.y)
|
2013-02-12 20:57:08 +00:00
|
|
|
side = Meta.Side.TOP;
|
2015-02-08 22:03:07 +00:00
|
|
|
else if (y2 >= monitor.y + monitor.height)
|
2013-02-12 20:57:08 +00:00
|
|
|
side = Meta.Side.BOTTOM;
|
|
|
|
else
|
|
|
|
continue;
|
2015-02-08 22:03:07 +00:00
|
|
|
} else if (y1 <= monitor.y && y2 >= monitor.y + monitor.height) {
|
|
|
|
if (x1 <= monitor.x)
|
2013-02-12 20:57:08 +00:00
|
|
|
side = Meta.Side.LEFT;
|
2015-02-08 22:03:07 +00:00
|
|
|
else if (x2 >= monitor.x + monitor.width)
|
2013-02-12 20:57:08 +00:00
|
|
|
side = Meta.Side.RIGHT;
|
|
|
|
else
|
|
|
|
continue;
|
2019-08-20 00:51:42 +00:00
|
|
|
} else if (x1 <= monitor.x) {
|
2011-07-25 13:56:51 +00:00
|
|
|
side = Meta.Side.LEFT;
|
2019-08-20 00:51:42 +00:00
|
|
|
} else if (y1 <= monitor.y) {
|
2013-02-12 20:57:08 +00:00
|
|
|
side = Meta.Side.TOP;
|
2019-08-20 00:51:42 +00:00
|
|
|
} else if (x2 >= monitor.x + monitor.width) {
|
2011-07-25 13:56:51 +00:00
|
|
|
side = Meta.Side.RIGHT;
|
2019-08-20 00:51:42 +00:00
|
|
|
} else if (y2 >= monitor.y + monitor.height) {
|
2013-02-12 20:57:08 +00:00
|
|
|
side = Meta.Side.BOTTOM;
|
2019-08-20 00:51:42 +00:00
|
|
|
} else {
|
2011-07-25 13:56:51 +00:00
|
|
|
continue;
|
2019-08-20 00:51:42 +00:00
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2019-01-29 01:27:05 +00:00
|
|
|
let strutRect = new Meta.Rectangle({ x: x1, y: y1, width: x2 - x1, height: y2 - y1 });
|
2019-08-19 19:06:04 +00:00
|
|
|
let strut = new Meta.Strut({ rect: strutRect, side });
|
2013-02-12 20:57:08 +00:00
|
|
|
struts.push(strut);
|
|
|
|
}
|
2011-07-25 13:56:51 +00:00
|
|
|
}
|
|
|
|
|
2019-01-31 11:02:39 +00:00
|
|
|
global.set_stage_input_region(rects);
|
2013-02-12 21:00:41 +00:00
|
|
|
this._isPopupWindowVisible = isPopupMenuVisible;
|
2011-07-25 13:56:51 +00:00
|
|
|
|
2018-01-03 07:55:38 +00: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 13:56:51 +00:00
|
|
|
workspace.set_builtin_struts(struts);
|
|
|
|
}
|
|
|
|
|
2013-11-29 00:45:39 +00:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2014-09-20 00:54:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
modalEnded() {
|
2014-09-20 00:54:31 +00:00
|
|
|
// We don't update the stage input region while in a modal,
|
|
|
|
// so queue an update now.
|
|
|
|
this._queueUpdateRegions();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2013-01-28 04:32:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
// HotCorner:
|
|
|
|
//
|
|
|
|
// This class manages a "hot corner" that can toggle switching to
|
|
|
|
// overview.
|
2019-07-16 09:24:13 +00:00
|
|
|
var HotCorner = GObject.registerClass(
|
|
|
|
class HotCorner extends Clutter.Actor {
|
|
|
|
_init(layoutManager, monitor, x, y) {
|
|
|
|
super._init();
|
|
|
|
|
2013-01-28 04:32:40 +00: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-10 02:12:37 +00:00
|
|
|
this._monitor = monitor;
|
|
|
|
|
2013-03-01 20:07:11 +00:00
|
|
|
this._x = x;
|
|
|
|
this._y = y;
|
|
|
|
|
2013-03-05 06:49:35 +00:00
|
|
|
this._setupFallbackCornerIfNeeded(layoutManager);
|
2013-01-28 04:32:40 +00:00
|
|
|
|
2013-03-01 21:19:07 +00:00
|
|
|
this._pressureBarrier = new PressureBarrier(HOT_CORNER_PRESSURE_THRESHOLD,
|
|
|
|
HOT_CORNER_PRESSURE_TIMEOUT,
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW);
|
2017-12-02 00:27:35 +00:00
|
|
|
this._pressureBarrier.connect('trigger', this._toggleOverview.bind(this));
|
2013-01-28 04:32:40 +00:00
|
|
|
|
2019-02-21 07:45:17 +00: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-28 04:32:40 +00:00
|
|
|
|
2019-02-21 07:45:17 +00:00
|
|
|
this._ripples = new Ripples.Ripples(px, py, 'ripple-box');
|
|
|
|
this._ripples.addTo(layoutManager.uiGroup);
|
2019-07-16 09:24:13 +00:00
|
|
|
|
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-28 04:32:40 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
setBarrierSize(size) {
|
2013-03-01 20:07:11 +00:00
|
|
|
if (this._verticalBarrier) {
|
2013-03-01 21:19:07 +00:00
|
|
|
this._pressureBarrier.removeBarrier(this._verticalBarrier);
|
2013-03-01 20:07:11 +00:00
|
|
|
this._verticalBarrier.destroy();
|
|
|
|
this._verticalBarrier = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._horizontalBarrier) {
|
2013-03-01 21:19:07 +00:00
|
|
|
this._pressureBarrier.removeBarrier(this._horizontalBarrier);
|
2013-03-01 20:07:11 +00:00
|
|
|
this._horizontalBarrier.destroy();
|
|
|
|
this._horizontalBarrier = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size > 0) {
|
2013-04-20 15:48:28 +00:00
|
|
|
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) {
|
|
|
|
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 });
|
|
|
|
} else {
|
|
|
|
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-03-01 21:19:07 +00:00
|
|
|
|
|
|
|
this._pressureBarrier.addBarrier(this._verticalBarrier);
|
|
|
|
this._pressureBarrier.addBarrier(this._horizontalBarrier);
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-01 21:19:07 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_setupFallbackCornerIfNeeded(layoutManager) {
|
2013-03-01 21:19:07 +00:00
|
|
|
if (!global.display.supports_extended_barriers()) {
|
2019-07-16 09:24:13 +00:00
|
|
|
this.set({
|
|
|
|
name: 'hot-corner-environs',
|
|
|
|
x: this._x,
|
|
|
|
y: this._y,
|
|
|
|
width: 3,
|
|
|
|
height: 3,
|
2019-08-20 21:43:54 +00:00
|
|
|
reactive: true,
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|
2013-03-01 21:19:07 +00:00
|
|
|
|
2013-05-09 01:53:20 +00:00
|
|
|
this._corner = new Clutter.Actor({ name: 'hot-corner',
|
|
|
|
width: 1,
|
|
|
|
height: 1,
|
|
|
|
opacity: 0,
|
|
|
|
reactive: true });
|
2013-03-01 21:19:07 +00:00
|
|
|
this._corner._delegate = this;
|
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
this.add_child(this._corner);
|
|
|
|
layoutManager.addChrome(this);
|
2013-03-01 21:19:07 +00:00
|
|
|
|
|
|
|
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) {
|
2019-07-16 09:24:13 +00:00
|
|
|
this._corner.set_position(this.width - this._corner.width, 0);
|
|
|
|
this.set_anchor_point_from_gravity(Clutter.Gravity.NORTH_EAST);
|
2013-03-01 21:19:07 +00:00
|
|
|
} else {
|
|
|
|
this._corner.set_position(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._corner.connect('enter-event',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._onCornerEntered.bind(this));
|
2013-03-01 21:19:07 +00:00
|
|
|
this._corner.connect('leave-event',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._onCornerLeft.bind(this));
|
2013-03-01 20:07:11 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-01 20:07:11 +00:00
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
_onDestroy() {
|
2013-03-01 20:07:11 +00:00
|
|
|
this.setBarrierSize(0);
|
2013-03-01 21:19:07 +00:00
|
|
|
this._pressureBarrier.destroy();
|
|
|
|
this._pressureBarrier = null;
|
|
|
|
|
2019-08-30 23:40:53 +00:00
|
|
|
this._ripples.destroy();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-28 04:32:40 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_toggleOverview() {
|
2018-09-21 14:58:26 +00:00
|
|
|
if (this._monitor.inFullscreen && !Main.overview.visible)
|
2013-03-10 02:12:37 +00:00
|
|
|
return;
|
|
|
|
|
2013-03-04 22:02:02 +00:00
|
|
|
if (Main.overview.shouldToggleByCornerOrButton()) {
|
|
|
|
Main.overview.toggle();
|
2020-07-22 00:05:48 +00:00
|
|
|
if (Main.overview.animationInProgress)
|
|
|
|
this._ripples.playAnimation(this._x, this._y);
|
2013-01-28 04:32:40 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-01 21:19:07 +00:00
|
|
|
|
2019-01-31 14:08:10 +00:00
|
|
|
handleDragOver(source, _actor, _x, _y, _time) {
|
2013-03-01 21:19:07 +00:00
|
|
|
if (source != Main.xdndHandler)
|
|
|
|
return DND.DragMotionResult.CONTINUE;
|
2013-01-28 04:32:40 +00:00
|
|
|
|
2013-03-23 09:51:43 +00:00
|
|
|
this._toggleOverview();
|
|
|
|
|
2013-01-28 04:32:40 +00:00
|
|
|
return DND.DragMotionResult.CONTINUE;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-28 04:32:40 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onCornerEntered() {
|
2013-01-28 04:32:40 +00:00
|
|
|
if (!this._entered) {
|
|
|
|
this._entered = true;
|
2013-03-01 21:19:07 +00:00
|
|
|
this._toggleOverview();
|
2013-01-28 04:32:40 +00:00
|
|
|
}
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-28 04:32:40 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onCornerLeft(actor, event) {
|
2019-07-16 09:24:13 +00:00
|
|
|
if (event.get_related() != this)
|
2013-01-28 04:32:40 +00:00
|
|
|
this._entered = false;
|
|
|
|
// Consume event, otherwise this will confuse onEnvironsLeft
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-28 04:32:40 +00:00
|
|
|
|
2019-09-10 05:42:48 +00:00
|
|
|
vfunc_leave_event(crossingEvent) {
|
|
|
|
if (crossingEvent.related != this._corner)
|
2013-01-28 04:32:40 +00:00
|
|
|
this._entered = false;
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2013-01-28 04:32:40 +00:00
|
|
|
}
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var PressureBarrier = class PressureBarrier {
|
|
|
|
constructor(threshold, timeout, actionMode) {
|
2012-07-30 19:25:07 +00:00
|
|
|
this._threshold = threshold;
|
|
|
|
this._timeout = timeout;
|
2014-12-11 14:35:40 +00:00
|
|
|
this._actionMode = actionMode;
|
2013-03-01 19:57:38 +00:00
|
|
|
this._barriers = [];
|
2013-03-01 20:33:39 +00:00
|
|
|
this._eventFilter = null;
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2013-03-01 20:29:42 +00:00
|
|
|
this._isTriggered = false;
|
2012-07-30 19:25:07 +00:00
|
|
|
this._reset();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-01 19:57:38 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
addBarrier(barrier) {
|
2017-12-02 00:27:35 +00:00
|
|
|
barrier._pressureHitId = barrier.connect('hit', this._onBarrierHit.bind(this));
|
|
|
|
barrier._pressureLeftId = barrier.connect('left', this._onBarrierLeft.bind(this));
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2013-03-01 19:57:38 +00:00
|
|
|
this._barriers.push(barrier);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-01 19:57:38 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_disconnectBarrier(barrier) {
|
2013-03-01 19:57:38 +00:00
|
|
|
barrier.disconnect(barrier._pressureHitId);
|
|
|
|
barrier.disconnect(barrier._pressureLeftId);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-01 19:57:38 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
removeBarrier(barrier) {
|
2013-03-01 19:57:38 +00:00
|
|
|
this._disconnectBarrier(barrier);
|
|
|
|
this._barriers.splice(this._barriers.indexOf(barrier), 1);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
destroy() {
|
2017-12-02 00:27:35 +00:00
|
|
|
this._barriers.forEach(this._disconnectBarrier.bind(this));
|
2013-03-01 19:57:38 +00:00
|
|
|
this._barriers = [];
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
setEventFilter(filter) {
|
2013-03-01 20:33:39 +00:00
|
|
|
this._eventFilter = filter;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-01 20:33:39 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_reset() {
|
2012-07-30 19:25:07 +00:00
|
|
|
this._barrierEvents = [];
|
|
|
|
this._currentPressure = 0;
|
|
|
|
this._lastTime = 0;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_isHorizontal(barrier) {
|
2013-03-01 19:57:38 +00:00
|
|
|
return barrier.y1 == barrier.y2;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-01 19:57:38 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getDistanceAcrossBarrier(barrier, event) {
|
2013-03-01 19:57:38 +00:00
|
|
|
if (this._isHorizontal(barrier))
|
2012-07-30 19:25:07 +00:00
|
|
|
return Math.abs(event.dy);
|
|
|
|
else
|
|
|
|
return Math.abs(event.dx);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getDistanceAlongBarrier(barrier, event) {
|
2013-03-01 19:57:38 +00:00
|
|
|
if (this._isHorizontal(barrier))
|
2012-07-30 19:25:07 +00:00
|
|
|
return Math.abs(event.dx);
|
|
|
|
else
|
|
|
|
return Math.abs(event.dy);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_trimBarrierEvents() {
|
2012-07-30 19:25:07 +00: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 20:21:25 +00:00
|
|
|
let threshold = this._lastTime - this._timeout;
|
|
|
|
|
2012-07-30 19:25:07 +00:00
|
|
|
while (i < this._barrierEvents.length) {
|
2019-01-31 14:08:00 +00:00
|
|
|
let [time, distance_] = this._barrierEvents[i];
|
2013-03-01 20:21:25 +00:00
|
|
|
if (time >= threshold)
|
2012-07-30 19:25:07 +00:00
|
|
|
break;
|
2013-02-15 02:21:20 +00:00
|
|
|
i++;
|
2012-07-30 19:25:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let firstNewEvent = i;
|
|
|
|
|
|
|
|
for (i = 0; i < firstNewEvent; i++) {
|
2019-01-31 14:08:00 +00:00
|
|
|
let [time_, distance] = this._barrierEvents[i];
|
2013-03-01 20:21:25 +00:00
|
|
|
this._currentPressure -= distance;
|
2012-07-30 19:25:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this._barrierEvents = this._barrierEvents.slice(firstNewEvent);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2019-01-31 14:08:10 +00:00
|
|
|
_onBarrierLeft(barrier, _event) {
|
2015-04-29 00:36:53 +00:00
|
|
|
barrier._isHit = false;
|
2017-10-31 00:38:18 +00:00
|
|
|
if (this._barriers.every(b => !b._isHit)) {
|
2015-04-29 00:36:53 +00:00
|
|
|
this._reset();
|
|
|
|
this._isTriggered = false;
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_trigger() {
|
2013-03-01 20:29:42 +00:00
|
|
|
this._isTriggered = true;
|
2013-02-21 22:21:25 +00:00
|
|
|
this.emit('trigger');
|
|
|
|
this._reset();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-02-21 22:21:25 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onBarrierHit(barrier, event) {
|
2015-04-29 00:36:53 +00:00
|
|
|
barrier._isHit = true;
|
|
|
|
|
2013-03-01 20:29:42 +00: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 20:33:39 +00:00
|
|
|
if (this._eventFilter && this._eventFilter(event))
|
2013-02-16 21:17:11 +00:00
|
|
|
return;
|
|
|
|
|
2013-03-01 20:45:56 +00:00
|
|
|
// Throw out all events not in the proper keybinding mode
|
2014-12-11 14:35:40 +00:00
|
|
|
if (!(this._actionMode & Main.actionMode))
|
2012-07-30 19:25:07 +00:00
|
|
|
return;
|
|
|
|
|
2013-03-01 19:57:38 +00:00
|
|
|
let slide = this._getDistanceAlongBarrier(barrier, event);
|
|
|
|
let distance = this._getDistanceAcrossBarrier(barrier, event);
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2013-02-21 22:21:25 +00:00
|
|
|
if (distance >= this._threshold) {
|
|
|
|
this._trigger();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-30 19:25:07 +00: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 20:21:25 +00:00
|
|
|
distance = Math.min(15, distance);
|
|
|
|
|
|
|
|
this._barrierEvents.push([event.time, distance]);
|
|
|
|
this._currentPressure += distance;
|
2012-07-30 19:25:07 +00:00
|
|
|
|
2013-02-21 22:21:25 +00:00
|
|
|
if (this._currentPressure >= this._threshold)
|
|
|
|
this._trigger();
|
2012-07-30 19:25:07 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2012-07-30 19:25:07 +00:00
|
|
|
Signals.addSignalMethods(PressureBarrier.prototype);
|