mirror of
https://github.com/morgan9e/dash-to-panel
synced 2026-04-14 00:04:17 +09:00
Drop ES5 support
This commit is contained in:
280
windowPreview.js
280
windowPreview.js
@@ -15,6 +15,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const GObject = imports.gi.GObject;
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Config = imports.misc.config;
|
||||
const GLib = imports.gi.GLib;
|
||||
@@ -60,13 +61,12 @@ let scaleFactor = 1;
|
||||
let animationTime = 0;
|
||||
let aspectRatio = {};
|
||||
|
||||
var PreviewMenu = Utils.defineClass({
|
||||
Name: 'DashToPanel-PreviewMenu',
|
||||
Extends: St.Widget,
|
||||
Signals: { 'open-state-changed': {} },
|
||||
var PreviewMenu = GObject.registerClass({
|
||||
Signals: { 'open-state-changed': {} }
|
||||
}, class PreviewMenu extends St.Widget {
|
||||
|
||||
_init: function(panel) {
|
||||
this.callParent('_init', { layout_manager: new Clutter.BinLayout() });
|
||||
_init(panel) {
|
||||
super._init({ layout_manager: new Clutter.BinLayout() });
|
||||
|
||||
let geom = panel.geom;
|
||||
this.panel = panel;
|
||||
@@ -102,9 +102,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
this._scrollView.add_actor(this._box);
|
||||
this.menu.add_child(this._scrollView);
|
||||
this.add_child(this.menu);
|
||||
},
|
||||
}
|
||||
|
||||
enable: function() {
|
||||
enable() {
|
||||
this._timeoutsHandler = new Utils.TimeoutsHandler();
|
||||
this._signalsHandler = new Utils.GlobalSignalsHandler();
|
||||
|
||||
@@ -155,9 +155,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
}
|
||||
]
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
disable: function() {
|
||||
disable() {
|
||||
this._timeoutsHandler.destroy();
|
||||
this._signalsHandler.destroy();
|
||||
|
||||
@@ -165,9 +165,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
|
||||
Main.layoutManager.untrackChrome(this.menu);
|
||||
Main.layoutManager.removeChrome(this);
|
||||
},
|
||||
}
|
||||
|
||||
requestOpen: function(appIcon) {
|
||||
requestOpen(appIcon) {
|
||||
let timeout = Me.settings.get_int('show-window-previews-timeout');
|
||||
|
||||
if (this.opened) {
|
||||
@@ -176,14 +176,14 @@ var PreviewMenu = Utils.defineClass({
|
||||
|
||||
this._endOpenCloseTimeouts();
|
||||
this._timeoutsHandler.add([T1, timeout, () => this.open(appIcon)]);
|
||||
},
|
||||
}
|
||||
|
||||
requestClose: function() {
|
||||
requestClose() {
|
||||
this._endOpenCloseTimeouts();
|
||||
this._addCloseTimeout();
|
||||
},
|
||||
}
|
||||
|
||||
open: function(appIcon) {
|
||||
open(appIcon) {
|
||||
if (this.currentAppIcon != appIcon) {
|
||||
this.currentAppIcon = appIcon;
|
||||
|
||||
@@ -203,9 +203,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
this._setReactive(true);
|
||||
this._setOpenedState(true);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
close: function(immediate) {
|
||||
close(immediate) {
|
||||
this._endOpenCloseTimeouts();
|
||||
this._removeFocus();
|
||||
this._endPeek();
|
||||
@@ -219,9 +219,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
|
||||
this._setReactive(false);
|
||||
this.currentAppIcon = null;
|
||||
},
|
||||
}
|
||||
|
||||
update: function(appIcon, windows) {
|
||||
update(appIcon, windows) {
|
||||
if (this.currentAppIcon == appIcon) {
|
||||
if (windows && !windows.length) {
|
||||
this.close();
|
||||
@@ -230,13 +230,13 @@ var PreviewMenu = Utils.defineClass({
|
||||
this._updatePosition();
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
updatePosition: function() {
|
||||
updatePosition() {
|
||||
this._updatePosition();
|
||||
},
|
||||
}
|
||||
|
||||
focusNext: function() {
|
||||
focusNext() {
|
||||
let previews = this._box.get_children();
|
||||
let currentIndex = this._focusedPreview ? previews.indexOf(this._focusedPreview) : -1;
|
||||
let nextIndex = currentIndex + 1;
|
||||
@@ -250,15 +250,15 @@ var PreviewMenu = Utils.defineClass({
|
||||
}
|
||||
|
||||
return nextIndex;
|
||||
},
|
||||
}
|
||||
|
||||
activateFocused: function() {
|
||||
activateFocused() {
|
||||
if (this.opened && this._focusedPreview) {
|
||||
this._focusedPreview.activate();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
requestPeek: function(window) {
|
||||
requestPeek(window) {
|
||||
this._timeoutsHandler.remove(T3);
|
||||
|
||||
if (Me.settings.get_boolean('peek-mode')) {
|
||||
@@ -268,13 +268,13 @@ var PreviewMenu = Utils.defineClass({
|
||||
this._peek(window);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
endPeekHere: function() {
|
||||
endPeekHere() {
|
||||
this._endPeek(true);
|
||||
},
|
||||
}
|
||||
|
||||
ensureVisible: function(preview) {
|
||||
ensureVisible(preview) {
|
||||
let [ , upper, pageSize] = this._getScrollAdjustmentValues();
|
||||
|
||||
if (upper > pageSize) {
|
||||
@@ -284,39 +284,39 @@ var PreviewMenu = Utils.defineClass({
|
||||
() => Utils.ensureActorVisibleInScrollView(this._scrollView, preview, MIN_DIMENSION, () => this._updateScrollFade())
|
||||
]);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
getCurrentAppIcon: function() {
|
||||
getCurrentAppIcon() {
|
||||
return this.currentAppIcon;
|
||||
},
|
||||
}
|
||||
|
||||
_setReactive: function(reactive) {
|
||||
_setReactive(reactive) {
|
||||
this._box.get_children().forEach(c => c.reactive = reactive);
|
||||
this.menu.reactive = reactive;
|
||||
},
|
||||
}
|
||||
|
||||
_setOpenedState: function(opened) {
|
||||
_setOpenedState(opened) {
|
||||
this.opened = opened;
|
||||
this.emit('open-state-changed');
|
||||
},
|
||||
}
|
||||
|
||||
_resetHiddenState: function() {
|
||||
_resetHiddenState() {
|
||||
this.menu.hide();
|
||||
this.set_height(0);
|
||||
this._setOpenedState(false);
|
||||
this.menu.opacity = 0;
|
||||
this.menu[this._translationProp] = this._translationOffset;
|
||||
this._box.get_children().forEach(c => c.destroy());
|
||||
},
|
||||
}
|
||||
|
||||
_removeFocus: function() {
|
||||
_removeFocus() {
|
||||
if (this._focusedPreview) {
|
||||
this._focusedPreview.setFocus(false);
|
||||
this._focusedPreview = null;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_mergeWindows: function(appIcon, windows) {
|
||||
_mergeWindows(appIcon, windows) {
|
||||
windows = windows || (appIcon.window ? [appIcon.window] : appIcon.getAppIconInterestingWindows());
|
||||
windows.sort(Taskbar.sortWindowsCompareFunction);
|
||||
|
||||
@@ -332,9 +332,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
currentPreviews[i][!this.opened ? 'destroy' : 'animateOut']();
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_addAndRemoveWindows: function(windows) {
|
||||
_addAndRemoveWindows(windows) {
|
||||
let currentPreviews = this._box.get_children();
|
||||
|
||||
windows.sort(Taskbar.sortWindowsCompareFunction);
|
||||
@@ -355,30 +355,30 @@ var PreviewMenu = Utils.defineClass({
|
||||
}
|
||||
|
||||
currentPreviews.forEach(c => c.animateOut());
|
||||
},
|
||||
}
|
||||
|
||||
_addNewPreview: function(window) {
|
||||
_addNewPreview(window) {
|
||||
let preview = new Preview(this);
|
||||
|
||||
this._box.add_child(preview);
|
||||
preview.adjustOnStage();
|
||||
preview.assignWindow(window, this.opened);
|
||||
},
|
||||
}
|
||||
|
||||
_addCloseTimeout: function() {
|
||||
_addCloseTimeout() {
|
||||
this._timeoutsHandler.add([T2, Me.settings.get_int('leave-timeout'), () => this.close()]);
|
||||
},
|
||||
}
|
||||
|
||||
_onHoverChanged: function() {
|
||||
_onHoverChanged() {
|
||||
this._endOpenCloseTimeouts();
|
||||
|
||||
if (this.currentAppIcon && !this.menu.hover) {
|
||||
this._addCloseTimeout();
|
||||
this._endPeek();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onScrollEvent: function(actor, event) {
|
||||
_onScrollEvent(actor, event) {
|
||||
if (!event.is_pointer_emulated()) {
|
||||
let vOrh = this.isVertical ? 'v' : 'h';
|
||||
let adjustment = this._scrollView['get_' + vOrh + 'scroll_bar']().get_adjustment();
|
||||
@@ -401,15 +401,15 @@ var PreviewMenu = Utils.defineClass({
|
||||
}
|
||||
|
||||
return Clutter.EVENT_STOP;
|
||||
},
|
||||
}
|
||||
|
||||
_endOpenCloseTimeouts: function() {
|
||||
_endOpenCloseTimeouts() {
|
||||
this._timeoutsHandler.remove(T1);
|
||||
this._timeoutsHandler.remove(T2);
|
||||
this._timeoutsHandler.remove(T4);
|
||||
},
|
||||
}
|
||||
|
||||
_refreshGlobals: function() {
|
||||
_refreshGlobals() {
|
||||
isLeftButtons = Meta.prefs_get_button_layout().left_buttons.indexOf(Meta.ButtonFunction.CLOSE) >= 0;
|
||||
isTopHeader = Me.settings.get_string('window-preview-title-position') == 'TOP';
|
||||
isManualStyling = Me.settings.get_boolean('window-preview-manual-styling');
|
||||
@@ -428,9 +428,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
alphaBg = Me.settings.get_boolean('preview-use-custom-opacity') ?
|
||||
Me.settings.get_int('preview-custom-opacity') * .01 :
|
||||
this.panel.dynamicTransparency.alpha;
|
||||
},
|
||||
}
|
||||
|
||||
_updateClip: function() {
|
||||
_updateClip() {
|
||||
let x, y, w;
|
||||
let geom = this.panel.getGeometry();
|
||||
let panelBoxTheme = this.panel.panelBox.get_theme_node();
|
||||
@@ -458,9 +458,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
}
|
||||
|
||||
Utils.setClip(this, x, y, w, this.clipHeight);
|
||||
},
|
||||
}
|
||||
|
||||
_updatePosition: function() {
|
||||
_updatePosition() {
|
||||
let sourceNode = this.currentAppIcon.actor.get_theme_node();
|
||||
let sourceContentBox = sourceNode.get_content_box(this.currentAppIcon.actor.get_allocation_box());
|
||||
let sourceAllocation = Utils.getTransformedAllocation(this.currentAppIcon.actor);
|
||||
@@ -488,9 +488,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
} else {
|
||||
Utils.animate(this.menu, getTweenOpts({ x: x, y: y, width: previewsWidth, height: previewsHeight }));
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_updateScrollFade: function(remove) {
|
||||
_updateScrollFade(remove) {
|
||||
let [value, upper, pageSize] = this._getScrollAdjustmentValues();
|
||||
let needsFade = Math.round(upper) > Math.round(pageSize);
|
||||
let fadeWidgets = this.menu.get_children().filter(c => c != this._scrollView);
|
||||
@@ -509,15 +509,15 @@ var PreviewMenu = Utils.defineClass({
|
||||
} else if (remove || (!needsFade && fadeWidgets.length)) {
|
||||
fadeWidgets.forEach(fw => fw.destroy());
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_getScrollAdjustmentValues: function() {
|
||||
_getScrollAdjustmentValues() {
|
||||
let [value , , upper, , , pageSize] = this._scrollView[(this.isVertical ? 'v' : 'h') + 'scroll'].adjustment.get_values();
|
||||
|
||||
return [value, upper, pageSize];
|
||||
},
|
||||
}
|
||||
|
||||
_getFadeWidget: function(end) {
|
||||
_getFadeWidget(end) {
|
||||
let x = 0, y = 0;
|
||||
let startBg = Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgb, Math.min(alphaBg + .1, 1));
|
||||
let endBg = Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgb, 0)
|
||||
@@ -542,9 +542,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
});
|
||||
|
||||
return fadeWidget;
|
||||
},
|
||||
}
|
||||
|
||||
_getPreviewsSize: function() {
|
||||
_getPreviewsSize() {
|
||||
let previewsWidth = 0;
|
||||
let previewsHeight = 0;
|
||||
|
||||
@@ -563,9 +563,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
});
|
||||
|
||||
return [previewsWidth, previewsHeight];
|
||||
},
|
||||
}
|
||||
|
||||
_animateOpenOrClose: function(show, onComplete) {
|
||||
_animateOpenOrClose(show, onComplete) {
|
||||
let isTranslationAnimation = this.menu[this._translationProp] != 0;
|
||||
let tweenOpts = {
|
||||
opacity: show ? 255 : 0,
|
||||
@@ -582,9 +582,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
tweenOpts[this._translationProp] = show ? this._translationDirection : this._translationOffset;
|
||||
|
||||
Utils.animate(this.menu, getTweenOpts(tweenOpts));
|
||||
},
|
||||
}
|
||||
|
||||
_peek: function(window) {
|
||||
_peek(window) {
|
||||
let currentWorkspace = Utils.getCurrentWorkspace();
|
||||
let windowWorkspace = window.get_workspace();
|
||||
let focusWindow = () => this._focusMetaWindow(Me.settings.get_int('peek-mode-opacity'), window);
|
||||
@@ -602,9 +602,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
if (this.peekInitialWorkspaceIndex < 0) {
|
||||
this.peekInitialWorkspaceIndex = currentWorkspace.index();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_endPeek: function(stayHere) {
|
||||
_endPeek(stayHere) {
|
||||
this._timeoutsHandler.remove(T3);
|
||||
|
||||
if (this._peekedWindow) {
|
||||
@@ -620,9 +620,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
|
||||
this.peekInitialWorkspaceIndex = -1;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_switchToWorkspaceImmediate: function(workspaceIndex) {
|
||||
_switchToWorkspaceImmediate(workspaceIndex) {
|
||||
let workspace = Utils.getWorkspaceByIndex(workspaceIndex);
|
||||
let shouldAnimate = Main.wm._shouldAnimate;
|
||||
|
||||
@@ -634,9 +634,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
Main.wm._shouldAnimate = () => false;
|
||||
workspace.activate(global.display.get_current_time_roundtrip());
|
||||
Main.wm._shouldAnimate = shouldAnimate;
|
||||
},
|
||||
}
|
||||
|
||||
_focusMetaWindow: function(dimOpacity, window, immediate, ignoreFocus) {
|
||||
_focusMetaWindow(dimOpacity, window, immediate, ignoreFocus) {
|
||||
window.get_workspace().list_windows().forEach(mw => {
|
||||
let wa = mw.get_compositor_private();
|
||||
let isFocused = !ignoreFocus && mw == window;
|
||||
@@ -662,9 +662,9 @@ var PreviewMenu = Utils.defineClass({
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_restorePeekedWindowStack: function() {
|
||||
_restorePeekedWindowStack() {
|
||||
let windowActor = this._peekedWindow ? this._peekedWindow.get_compositor_private() : null;
|
||||
|
||||
if (windowActor) {
|
||||
@@ -677,15 +677,14 @@ var PreviewMenu = Utils.defineClass({
|
||||
windowActor.hide();
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
var Preview = Utils.defineClass({
|
||||
Name: 'DashToPanel-Preview',
|
||||
Extends: St.Widget,
|
||||
var Preview = GObject.registerClass({
|
||||
}, class Preview extends St.Widget {
|
||||
|
||||
_init: function(previewMenu) {
|
||||
this.callParent('_init', {
|
||||
_init(previewMenu) {
|
||||
super._init({
|
||||
style_class: 'preview-container',
|
||||
reactive: true,
|
||||
track_hover: true,
|
||||
@@ -759,9 +758,9 @@ var Preview = Utils.defineClass({
|
||||
this.connect('notify::hover', () => this._onHoverChanged());
|
||||
this.connect('button-release-event', (actor, e) => this._onButtonReleaseEvent(e));
|
||||
this.connect('destroy', () => this._onDestroy());
|
||||
},
|
||||
}
|
||||
|
||||
adjustOnStage: function() {
|
||||
adjustOnStage() {
|
||||
let closeButton = this._closeButtonBin.get_first_child();
|
||||
let closeButtonHeight = closeButton.height;
|
||||
let maxCloseButtonSize = MAX_CLOSE_BUTTON_SIZE * scaleFactor;
|
||||
@@ -788,9 +787,9 @@ var Preview = Utils.defineClass({
|
||||
this._getBackgroundColor(HEADER_COLOR_OFFSET, headerHeight ? 1 : .6) +
|
||||
closeButtonBorderRadius
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
assignWindow: function(window, animateSize) {
|
||||
assignWindow(window, animateSize) {
|
||||
if (this.window != window) {
|
||||
let _assignWindowClone = () => {
|
||||
if (window.get_compositor_private()) {
|
||||
@@ -818,9 +817,9 @@ var Preview = Utils.defineClass({
|
||||
this.window = window;
|
||||
this._needsCloseButton = window.can_close() && !Utils.checkIfWindowHasTransient(window);
|
||||
this._updateHeader();
|
||||
},
|
||||
}
|
||||
|
||||
animateOut: function() {
|
||||
animateOut() {
|
||||
if (!this.animatingOut) {
|
||||
let tweenOpts = getTweenOpts({ opacity: 0, width: 0, height: 0, onComplete: () => this.destroy() });
|
||||
|
||||
@@ -829,18 +828,18 @@ var Preview = Utils.defineClass({
|
||||
Utils.stopAnimations(this);
|
||||
Utils.animate(this, tweenOpts);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
getSize: function() {
|
||||
getSize() {
|
||||
let [binWidth, binHeight] = this._getBinSize();
|
||||
|
||||
binWidth = Math.max(binWidth, this.cloneWidth + this._padding * 2);
|
||||
binHeight = Math.max(binHeight, this.cloneHeight + this._padding * 2) + headerHeight;
|
||||
|
||||
return [binWidth, binHeight];
|
||||
},
|
||||
}
|
||||
|
||||
setFocus: function(focused) {
|
||||
setFocus(focused) {
|
||||
this._hideOrShowCloseButton(!focused);
|
||||
setStyle(this, this._getBackgroundColor(FOCUSED_COLOR_OFFSET, focused ? '-' : 0));
|
||||
|
||||
@@ -848,28 +847,28 @@ var Preview = Utils.defineClass({
|
||||
this._previewMenu.ensureVisible(this);
|
||||
this._previewMenu.requestPeek(this.window);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
activate: function() {
|
||||
activate() {
|
||||
this._previewMenu.endPeekHere();
|
||||
this._previewMenu.close();
|
||||
Main.activateWindow(this.window);
|
||||
},
|
||||
}
|
||||
|
||||
_onDestroy: function() {
|
||||
_onDestroy() {
|
||||
if (this._waitWindowId) {
|
||||
GLib.source_remove(this._waitWindowId);
|
||||
this._waitWindowId = 0;
|
||||
}
|
||||
|
||||
this._removeWindowSignals();
|
||||
},
|
||||
}
|
||||
|
||||
_onHoverChanged: function() {
|
||||
_onHoverChanged() {
|
||||
this.setFocus(this.hover);
|
||||
},
|
||||
}
|
||||
|
||||
_onCloseBtnClick: function() {
|
||||
_onCloseBtnClick() {
|
||||
this._hideOrShowCloseButton(true);
|
||||
this.reactive = false;
|
||||
|
||||
@@ -880,9 +879,9 @@ var Preview = Utils.defineClass({
|
||||
}
|
||||
|
||||
this.window.delete(global.get_current_time());
|
||||
},
|
||||
}
|
||||
|
||||
_onButtonReleaseEvent: function(e) {
|
||||
_onButtonReleaseEvent(e) {
|
||||
switch (e.get_button()) {
|
||||
case 1: // Left click
|
||||
this.activate();
|
||||
@@ -898,18 +897,18 @@ var Preview = Utils.defineClass({
|
||||
}
|
||||
|
||||
return Clutter.EVENT_STOP;
|
||||
},
|
||||
}
|
||||
|
||||
_cancelAnimateOut: function() {
|
||||
_cancelAnimateOut() {
|
||||
if (this.animatingOut) {
|
||||
this.animatingOut = false;
|
||||
|
||||
Utils.stopAnimations(this);
|
||||
Utils.animate(this, getTweenOpts({ opacity: 255, width: this.cloneWidth, height: this.cloneHeight }));
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_showContextMenu: function(e) {
|
||||
_showContextMenu(e) {
|
||||
let coords = e.get_coords();
|
||||
let currentWorkspace = this._previewMenu.peekInitialWorkspaceIndex < 0 ?
|
||||
Utils.getCurrentWorkspace() :
|
||||
@@ -935,16 +934,16 @@ var Preview = Utils.defineClass({
|
||||
ctxMenuData.menu.addMenuItem(menuItem, insertIndex);
|
||||
menuItem.connect('activate', () => this.window.change_workspace(currentWorkspace));
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_removeWindowSignals: function() {
|
||||
_removeWindowSignals() {
|
||||
if (this._titleWindowChangeId) {
|
||||
this.window.disconnect(this._titleWindowChangeId);
|
||||
this._titleWindowChangeId = 0;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_updateHeader: function() {
|
||||
_updateHeader() {
|
||||
if (headerHeight) {
|
||||
let iconTextureSize = Me.settings.get_boolean('window-preview-use-custom-icon-size') ?
|
||||
Me.settings.get_int('window-preview-custom-icon-size') :
|
||||
@@ -973,24 +972,24 @@ var Preview = Utils.defineClass({
|
||||
setStyle(this._windowTitle, 'max-width: 0px; padding-right: 4px;' + commonTitleStyles);
|
||||
this._updateWindowTitle();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_updateWindowTitle: function() {
|
||||
_updateWindowTitle() {
|
||||
this._windowTitle.text = this.window.title;
|
||||
},
|
||||
}
|
||||
|
||||
_hideOrShowCloseButton: function(hide) {
|
||||
_hideOrShowCloseButton(hide) {
|
||||
if (this._needsCloseButton) {
|
||||
Utils.animate(this._closeButtonBin, getTweenOpts({ opacity: hide ? 0 : 255 }));
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_getBackgroundColor: function(offset, alpha) {
|
||||
_getBackgroundColor(offset, alpha) {
|
||||
return 'background-color: ' + this._getRgbaColor(offset, alpha) +
|
||||
'transition-duration:' + this._previewMenu.panel.dynamicTransparency.animationDuration;
|
||||
},
|
||||
}
|
||||
|
||||
_getRgbaColor: function(offset, alpha) {
|
||||
_getRgbaColor(offset, alpha) {
|
||||
alpha = Math.abs(alpha);
|
||||
|
||||
if (isNaN(alpha)) {
|
||||
@@ -998,9 +997,9 @@ var Preview = Utils.defineClass({
|
||||
}
|
||||
|
||||
return Utils.getrgbaColor(this._previewMenu.panel.dynamicTransparency.backgroundColorRgb, alpha, offset);
|
||||
},
|
||||
}
|
||||
|
||||
_addClone: function(newCloneBin, animateSize) {
|
||||
_addClone(newCloneBin, animateSize) {
|
||||
let currentClones = this._previewBin.get_children();
|
||||
let newCloneOpts = getTweenOpts({ opacity: 255 });
|
||||
|
||||
@@ -1034,9 +1033,9 @@ var Preview = Utils.defineClass({
|
||||
}
|
||||
|
||||
Utils.animate(newCloneBin, newCloneOpts);
|
||||
},
|
||||
}
|
||||
|
||||
_getWindowCloneBin: function(window) {
|
||||
_getWindowCloneBin(window) {
|
||||
let frameRect = window.get_frame_rect();
|
||||
let bufferRect = window.get_buffer_rect();
|
||||
let clone = new Clutter.Clone({ source: window.get_compositor_private() });
|
||||
@@ -1051,18 +1050,18 @@ var Preview = Utils.defineClass({
|
||||
cloneBin.add_child(clone);
|
||||
|
||||
return cloneBin;
|
||||
},
|
||||
}
|
||||
|
||||
_getBinSize: function() {
|
||||
_getBinSize() {
|
||||
let [fixedWidth, fixedHeight] = this._previewDimensions;
|
||||
|
||||
return [
|
||||
aspectRatio.x.fixed ? fixedWidth + this._padding * 2 : -1,
|
||||
aspectRatio.y.fixed ? fixedHeight + this._padding * 2 : -1
|
||||
];
|
||||
},
|
||||
}
|
||||
|
||||
_resizeClone: function(cloneBin, window) {
|
||||
_resizeClone(cloneBin, window) {
|
||||
let frameRect = cloneBin.layout_manager.frameRect || window.get_frame_rect();
|
||||
let [fixedWidth, fixedHeight] = this._previewDimensions;
|
||||
let ratio = Math.min(fixedWidth / frameRect.width, fixedHeight / frameRect.height, 1);
|
||||
@@ -1082,9 +1081,9 @@ var Preview = Utils.defineClass({
|
||||
cloneBin.layout_manager.padding = [clonePaddingLeft * scaleFactor, clonePaddingTop * scaleFactor];
|
||||
|
||||
cloneBin.get_first_child().set_size(cloneWidth, cloneHeight);
|
||||
},
|
||||
}
|
||||
|
||||
_getPreviewDimensions: function() {
|
||||
_getPreviewDimensions() {
|
||||
let size = Me.settings.get_int('window-preview-size') * scaleFactor;
|
||||
let w, h;
|
||||
|
||||
@@ -1100,19 +1099,18 @@ var Preview = Utils.defineClass({
|
||||
}
|
||||
});
|
||||
|
||||
var WindowCloneLayout = Utils.defineClass({
|
||||
Name: 'DashToPanel-WindowCloneLayout',
|
||||
Extends: Clutter.BinLayout,
|
||||
var WindowCloneLayout = GObject.registerClass({
|
||||
}, class WindowCloneLayout extends Clutter.BinLayout {
|
||||
|
||||
_init: function(frameRect, bufferRect) {
|
||||
this.callParent('_init');
|
||||
_init(frameRect, bufferRect) {
|
||||
super._init();
|
||||
|
||||
//the buffer_rect contains the transparent padding that must be removed
|
||||
this.frameRect = frameRect;
|
||||
this.bufferRect = bufferRect;
|
||||
},
|
||||
}
|
||||
|
||||
vfunc_allocate: function(actor, box, flags) {
|
||||
vfunc_allocate(actor, box, flags) {
|
||||
let [width, height] = box.get_size();
|
||||
|
||||
box.set_origin(
|
||||
|
||||
Reference in New Issue
Block a user