windowManager: Implement tile previews

Mutter now delegates tile previews to compositor plugins, so
add a simple implementation based on the UI previously provided
by mutter.

https://bugzilla.gnome.org/show_bug.cgi?id=665758
This commit is contained in:
Florian Müllner
2013-09-02 00:26:12 +02:00
parent 2663e1be5d
commit 6d93c8b3fd
5 changed files with 150 additions and 0 deletions

View File

@ -358,6 +358,55 @@ const WorkspaceTracker = new Lang.Class({
}
});
const TilePreview = new Lang.Class({
Name: 'TilePreview',
_init: function() {
this.actor = new St.Widget({ visible: false });
global.window_group.add_actor(this.actor);
this._showing = false;
},
show: function(window, tileRect, monitorIndex) {
let windowActor = window.get_compositor_private();
if (!windowActor)
return;
global.window_group.set_child_below_sibling(this.actor, windowActor);
this._updateStyle(monitorIndex, tileRect);
this.actor.set_size(tileRect.width, tileRect.height);
this.actor.set_position(tileRect.x, tileRect.y);
this._showing = true;
this.actor.show();
},
hide: function() {
if (!this._showing)
return;
this._showing = false;
this.actor.hide();
},
_updateStyle: function(monitorIndex, tileRect) {
let monitor = Main.layoutManager.monitors[monitorIndex];
let styles = ['tile-preview'];
if (monitorIndex == Main.layoutManager.primaryIndex)
styles.push('on-primary');
if (tileRect.x == monitor.x)
styles.push('tile-preview-left');
if (tileRect.x + tileRect.width == monitor.x + monitor.width)
styles.push('tile-preview-right');
this.actor.style_class = styles.join(' ');
}
});
const WindowManager = new Lang.Class({
Name: 'WindowManager',
@ -388,6 +437,8 @@ const WindowManager = new Lang.Class({
}));
this._shellwm.connect('switch-workspace', Lang.bind(this, this._switchWorkspace));
this._shellwm.connect('show-tile-preview', Lang.bind(this, this._showTilePreview));
this._shellwm.connect('hide-tile-preview', Lang.bind(this, this._hideTilePreview));
this._shellwm.connect('minimize', Lang.bind(this, this._minimizeWindow));
this._shellwm.connect('maximize', Lang.bind(this, this._maximizeWindow));
this._shellwm.connect('unmaximize', Lang.bind(this, this._unmaximizeWindow));
@ -397,6 +448,8 @@ const WindowManager = new Lang.Class({
this._shellwm.connect('confirm-display-change', Lang.bind(this, this._confirmDisplayChange));
this._workspaceSwitcherPopup = null;
this._tilePreview = null;
this.setCustomKeybindingHandler('switch-to-workspace-left',
Shell.KeyBindingMode.NORMAL |
Shell.KeyBindingMode.OVERVIEW,
@ -1046,6 +1099,18 @@ const WindowManager = new Lang.Class({
shellwm.completed_switch_workspace();
},
_showTilePreview: function(shellwm, window, tileRect, monitorIndex) {
if (!this._tilePreview)
this._tilePreview = new TilePreview();
this._tilePreview.show(window, tileRect, monitorIndex);
},
_hideTilePreview: function(shellwm) {
if (!this._tilePreview)
return;
this._tilePreview.hide();
},
_startAppSwitcher : function(display, screen, window, binding) {
/* prevent a corner case where both popups show up at once */
if (this._workspaceSwitcherPopup != null)