altTab: Factor out thumbnail creation

https://bugzilla.gnome.org/show_bug.cgi?id=688913
This commit is contained in:
Florian Müllner 2012-12-04 16:26:00 +01:00
parent aba46720c0
commit 525d3c2619

View File

@ -20,6 +20,20 @@ const THUMBNAIL_FADE_TIME = 0.1; // seconds
const iconSizes = [96, 64, 48, 32, 22]; const iconSizes = [96, 64, 48, 32, 22];
function _createWindowClone(window, size) {
let windowTexture = window.get_texture();
let [width, height] = windowTexture.get_size();
let scale = Math.min(1.0, size / width, size / height);
return new Clutter.Clone({ source: windowTexture,
width: width * scale,
height: height * scale,
x_align: Clutter.ActorAlign.CENTER,
y_align: Clutter.ActorAlign.CENTER,
// usual hack for the usual bug in ClutterBinLayout...
x_expand: true,
y_expand: true });
};
const AppSwitcherPopup = new Lang.Class({ const AppSwitcherPopup = new Lang.Class({
Name: 'AppSwitcherPopup', Name: 'AppSwitcherPopup',
Extends: SwitcherPopup.SwitcherPopup, Extends: SwitcherPopup.SwitcherPopup,
@ -621,14 +635,7 @@ const ThumbnailList = new Lang.Class({
if (!mutterWindow) if (!mutterWindow)
continue; continue;
let windowTexture = mutterWindow.get_texture (); let clone = _createWindowClone(mutterWindow, THUMBNAIL_DEFAULT_SIZE);
let [width, height] = windowTexture.get_size();
let scale = Math.min(1.0, THUMBNAIL_DEFAULT_SIZE / width, availHeight / height);
let clone = new Clutter.Clone ({ source: windowTexture,
reactive: true,
width: width * scale,
height: height * scale });
this._thumbnailBins[i].set_height(binHeight); this._thumbnailBins[i].set_height(binHeight);
this._thumbnailBins[i].add_actor(clone); this._thumbnailBins[i].add_actor(clone);
this._clones.push(clone); this._clones.push(clone);