|
rpm-build |
4d155a |
/* exported WindowPicker, WindowPickerToggle */
|
|
rpm-build |
4d155a |
const { Clutter, GLib, GObject, Meta, Shell, St } = imports.gi;
|
|
rpm-build |
4d155a |
const Signals = imports.signals;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
const Layout = imports.ui.layout;
|
|
rpm-build |
4d155a |
const Main = imports.ui.main;
|
|
rpm-build |
4d155a |
const Overview = imports.ui.overview;
|
|
rpm-build |
4d155a |
const { WorkspacesDisplay } = imports.ui.workspacesView;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
let MyWorkspacesDisplay = class extends WorkspacesDisplay {
|
|
rpm-build |
4d155a |
constructor() {
|
|
rpm-build |
4d155a |
super();
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this.actor.add_constraint(
|
|
rpm-build |
4d155a |
new Layout.MonitorConstraint({
|
|
rpm-build |
4d155a |
primary: true,
|
|
rpm-build |
4d155a |
work_area: true
|
|
rpm-build |
4d155a |
}));
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this.actor.connect('destroy', this._onDestroy.bind(this));
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._workareasChangedId = global.display.connect('workareas-changed',
|
|
rpm-build |
4d155a |
this._onWorkAreasChanged.bind(this));
|
|
rpm-build |
4d155a |
this._onWorkAreasChanged();
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
show(...args) {
|
|
rpm-build |
4d155a |
if (this._scrollEventId == 0)
|
|
rpm-build |
4d155a |
this._scrollEventId = Main.windowPicker.connect('scroll-event',
|
|
rpm-build |
4d155a |
this._onScrollEvent.bind(this));
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
super.show(...args);
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
hide(...args) {
|
|
rpm-build |
4d155a |
if (this._scrollEventId > 0)
|
|
rpm-build |
4d155a |
Main.windowPicker.disconnect(this._scrollEventId);
|
|
rpm-build |
4d155a |
this._scrollEventId = 0;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
super.hide(...args);
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
_onWorkAreasChanged() {
|
|
rpm-build |
4d155a |
let { primaryIndex } = Main.layoutManager;
|
|
rpm-build |
4d155a |
let workarea = Main.layoutManager.getWorkAreaForMonitor(primaryIndex);
|
|
rpm-build |
4d155a |
this.setWorkspacesFullGeometry(workarea);
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
_updateWorkspacesViews() {
|
|
rpm-build |
4d155a |
super._updateWorkspacesViews();
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._workspacesViews.forEach(v => {
|
|
rpm-build |
4d155a |
Main.layoutManager.overviewGroup.remove_actor(v.actor);
|
|
rpm-build |
4d155a |
Main.windowPicker.actor.add_actor(v.actor);
|
|
rpm-build |
4d155a |
});
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
_onDestroy() {
|
|
rpm-build |
4d155a |
if (this._workareasChangedId)
|
|
rpm-build |
4d155a |
global.display.disconnect(this._workareasChangedId);
|
|
rpm-build |
4d155a |
this._workareasChangedId = 0;
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
};
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
var WindowPicker = class {
|
|
rpm-build |
4d155a |
constructor() {
|
|
rpm-build |
4d155a |
this._visible = false;
|
|
rpm-build |
4d155a |
this._modal = false;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._overlayKeyId = 0;
|
|
rpm-build |
4d155a |
this._stageKeyPressId = 0;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this.actor = new Clutter.Actor();
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this.actor.connect('destroy', this._onDestroy.bind(this));
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
global.bind_property('screen-width',
|
|
rpm-build |
4d155a |
this.actor, 'width',
|
|
rpm-build |
4d155a |
GObject.BindingFlags.SYNC_CREATE);
|
|
rpm-build |
4d155a |
global.bind_property('screen-height',
|
|
rpm-build |
4d155a |
this.actor, 'height',
|
|
rpm-build |
4d155a |
GObject.BindingFlags.SYNC_CREATE);
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._backgroundGroup = new Meta.BackgroundGroup({ reactive: true });
|
|
rpm-build |
4d155a |
this.actor.add_child(this._backgroundGroup);
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._backgroundGroup.connect('scroll-event', (a, ev) => {
|
|
rpm-build |
4d155a |
this.emit('scroll-event', ev);
|
|
rpm-build |
4d155a |
});
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
// Trick WorkspacesDisplay constructor into adding actions here
|
|
rpm-build |
4d155a |
let addActionOrig = Main.overview.addAction;
|
|
rpm-build |
4d155a |
Main.overview.addAction = a => this._backgroundGroup.add_action(a);
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._workspacesDisplay = new MyWorkspacesDisplay();
|
|
rpm-build |
4d155a |
this.actor.add_child(this._workspacesDisplay.actor);
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
Main.overview.addAction = addActionOrig;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._bgManagers = [];
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._monitorsChangedId = Main.layoutManager.connect('monitors-changed',
|
|
rpm-build |
4d155a |
this._updateBackgrounds.bind(this));
|
|
rpm-build |
4d155a |
this._updateBackgrounds();
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
Main.uiGroup.insert_child_below(this.actor, global.window_group);
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
if (!Main.sessionMode.hasOverview) {
|
|
rpm-build |
4d155a |
this._overlayKeyId = global.display.connect('overlay-key', () => {
|
|
rpm-build |
4d155a |
if (!this._visible)
|
|
rpm-build |
4d155a |
this.open();
|
|
rpm-build |
4d155a |
else
|
|
rpm-build |
4d155a |
this.close();
|
|
rpm-build |
4d155a |
});
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
get visible() {
|
|
rpm-build |
4d155a |
return this._visible;
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
open() {
|
|
rpm-build |
4d155a |
if (this._visible)
|
|
rpm-build |
4d155a |
return;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._visible = true;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
if (!this._syncGrab())
|
|
rpm-build |
4d155a |
return;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._fakeOverviewVisible(true);
|
|
rpm-build |
4d155a |
this._shadeBackgrounds();
|
|
rpm-build |
4d155a |
this._fakeOverviewAnimation();
|
|
rpm-build |
4d155a |
this._workspacesDisplay.show(false);
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._stageKeyPressId = global.stage.connect('key-press-event',
|
|
rpm-build |
4d155a |
(a, event) => {
|
|
rpm-build |
4d155a |
let sym = event.get_key_symbol();
|
|
rpm-build |
4d155a |
if (sym == Clutter.KEY_Escape) {
|
|
rpm-build |
4d155a |
this.close();
|
|
rpm-build |
4d155a |
return Clutter.EVENT_STOP;
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
return Clutter.EVENT_PROPAGATE;
|
|
rpm-build |
4d155a |
});
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this.emit('open-state-changed', this._visible);
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
close() {
|
|
rpm-build |
4d155a |
if (!this._visible)
|
|
rpm-build |
4d155a |
return;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._visible = false;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
if (!this._syncGrab())
|
|
rpm-build |
4d155a |
return;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._workspacesDisplay.animateFromOverview(false);
|
|
rpm-build |
4d155a |
this._unshadeBackgrounds();
|
|
rpm-build |
4d155a |
this._fakeOverviewAnimation(() => {
|
|
rpm-build |
4d155a |
this._workspacesDisplay.hide();
|
|
rpm-build |
4d155a |
this._fakeOverviewVisible(false);
|
|
rpm-build |
4d155a |
});
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
global.stage.disconnect(this._stageKeyPressId);
|
|
rpm-build |
4d155a |
this._stageKeyPressId = 0;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this.emit('open-state-changed', this._visible);
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
_fakeOverviewAnimation(onComplete) {
|
|
rpm-build |
4d155a |
Main.overview.animationInProgress = true;
|
|
rpm-build |
4d155a |
GLib.timeout_add(
|
|
rpm-build |
4d155a |
GLib.PRIORITY_DEFAULT,
|
|
rpm-build |
4d155a |
Overview.ANIMATION_TIME * 1000,
|
|
rpm-build |
4d155a |
() => {
|
|
rpm-build |
4d155a |
Main.overview.animationInProgress = false;
|
|
rpm-build |
4d155a |
if (onComplete)
|
|
rpm-build |
4d155a |
onComplete();
|
|
rpm-build |
4d155a |
});
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
_fakeOverviewVisible(visible) {
|
|
rpm-build |
4d155a |
// Fake overview state for WorkspacesDisplay
|
|
rpm-build |
4d155a |
Main.overview.visible = visible;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
// Hide real windows
|
|
rpm-build |
4d155a |
Main.layoutManager._inOverview = visible;
|
|
rpm-build |
4d155a |
Main.layoutManager._updateVisibility();
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
_syncGrab() {
|
|
rpm-build |
4d155a |
if (this._visible) {
|
|
rpm-build |
4d155a |
if (this._modal)
|
|
rpm-build |
4d155a |
return true;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this._modal = Main.pushModal(this.actor, {
|
|
rpm-build |
4d155a |
actionMode: Shell.ActionMode.OVERVIEW
|
|
rpm-build |
4d155a |
});
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
if (!this._modal) {
|
|
rpm-build |
4d155a |
this.hide();
|
|
rpm-build |
4d155a |
return false;
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
} else if (this._modal) {
|
|
rpm-build |
4d155a |
Main.popModal(this.actor);
|
|
rpm-build |
4d155a |
this._modal = false;
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
return true;
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
_onDestroy() {
|
|
rpm-build |
4d155a |
if (this._monitorsChangedId)
|
|
rpm-build |
4d155a |
Main.layoutManager.disconnect(this._monitorsChangedId);
|
|
rpm-build |
4d155a |
this._monitorsChangedId = 0;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
if (this._overlayKeyId)
|
|
rpm-build |
4d155a |
global.display.disconnect(this._overlayKeyId);
|
|
rpm-build |
4d155a |
this._overlayKeyId = 0;
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
if (this._stageKeyPressId)
|
|
rpm-build |
4d155a |
global.stage.disconnect(this._stageKeyPressId);
|
|
rpm-build |
4d155a |
this._stageKeyPressId = 0;
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
_updateBackgrounds() {
|
|
rpm-build |
4d155a |
Main.overview._updateBackgrounds.call(this);
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
_shadeBackgrounds() {
|
|
rpm-build |
4d155a |
Main.overview._shadeBackgrounds.call(this);
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
_unshadeBackgrounds() {
|
|
rpm-build |
4d155a |
Main.overview._unshadeBackgrounds.call(this);
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
};
|
|
rpm-build |
4d155a |
Signals.addSignalMethods(WindowPicker.prototype);
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
var WindowPickerToggle = GObject.registerClass(
|
|
rpm-build |
4d155a |
class WindowPickerToggle extends St.Button {
|
|
rpm-build |
4d155a |
_init() {
|
|
rpm-build |
4d155a |
let iconBin = new St.Widget({
|
|
rpm-build |
4d155a |
layout_manager: new Clutter.BinLayout()
|
|
rpm-build |
4d155a |
});
|
|
rpm-build |
4d155a |
iconBin.add_child(new St.Icon({
|
|
rpm-build |
4d155a |
icon_name: 'focus-windows-symbolic',
|
|
rpm-build |
4d155a |
icon_size: 16,
|
|
rpm-build |
4d155a |
x_expand: true,
|
|
rpm-build |
4d155a |
y_expand: true,
|
|
rpm-build |
4d155a |
x_align: Clutter.ActorAlign.CENTER,
|
|
rpm-build |
4d155a |
y_align: Clutter.ActorAlign.CENTER
|
|
rpm-build |
4d155a |
}));
|
|
rpm-build |
4d155a |
super._init({
|
|
rpm-build |
4d155a |
style_class: 'window-picker-toggle',
|
|
rpm-build |
4d155a |
child: iconBin,
|
|
rpm-build |
4d155a |
visible: !Main.sessionMode.hasOverview,
|
|
rpm-build |
4d155a |
x_fill: true,
|
|
rpm-build |
4d155a |
y_fill: true,
|
|
rpm-build |
4d155a |
toggle_mode: true
|
|
rpm-build |
4d155a |
});
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
this.connect('notify::checked', () => {
|
|
rpm-build |
4d155a |
if (this.checked)
|
|
rpm-build |
4d155a |
Main.windowPicker.open();
|
|
rpm-build |
4d155a |
else
|
|
rpm-build |
4d155a |
Main.windowPicker.close();
|
|
rpm-build |
4d155a |
});
|
|
rpm-build |
4d155a |
|
|
rpm-build |
4d155a |
Main.windowPicker.connect('open-state-changed', () => {
|
|
rpm-build |
4d155a |
this.checked = Main.windowPicker.visible;
|
|
rpm-build |
4d155a |
});
|
|
rpm-build |
4d155a |
}
|
|
rpm-build |
4d155a |
});
|