HiDPI support. Fixes #10

This commit is contained in:
jderose9
2017-01-09 17:54:03 -05:00
parent 3cdd20c057
commit a6d8ac0ee9
2 changed files with 47 additions and 34 deletions

View File

@@ -50,6 +50,26 @@ const taskbarPanel = new Lang.Class({
this.appMenu = this.panel.statusArea.appMenu;
this.panelBox = Main.layoutManager.panelBox;
this._oldPanelHeight = this.panel.actor.get_height();
// The overview uses the this.panel height as a margin by way of a "ghost" transparent Clone
// This pushes everything down, which isn't desired when the this.panel is moved to the bottom
// I'm adding a 2nd ghost this.panel and will resize the top or bottom ghost depending on the this.panel position
this._myPanelGhost = new St.Bin({
child: new Clutter.Clone({ source: Main.overview._panelGhost.get_child(0) }),
reactive: false,
opacity: 0
});
Main.overview._overview.add_actor(this._myPanelGhost);
this._setPanelPosition();
this._MonitorsChangedListener = global.screen.connect("monitors-changed", Lang.bind(this, function(){
this._setPanelPosition();
}));
this._HeightNotifyListener = this.panelBox.connect("notify::height", Lang.bind(this, function(){
this._setPanelPosition();
}));
// The main panel's connection to the "allocate" signal is competing with this extension
// trying to move the centerBox over to the right, creating a never-ending cycle.
// Since we don't have the ID to disconnect that handler, wrap the allocate() function
@@ -79,23 +99,6 @@ const taskbarPanel = new Lang.Class({
this.container.insert_child_at_index( this.taskbar.actor, 2 );
this._oldPanelHeight = this.panel.actor.get_height();
// The overview uses the this.panel height as a margin by way of a "ghost" transparent Clone
// This pushes everything down, which isn't desired when the this.panel is moved to the bottom
// I'm adding a 2nd ghost this.panel and will resize the top or bottom ghost depending on the this.panel position
this._myPanelGhost = new St.Bin({
child: new Clutter.Clone({ source: Main.overview._panelGhost.get_child(0) }),
reactive: false,
opacity: 0
});
Main.overview._overview.add_actor(this._myPanelGhost);
// this.panel styling
this._MonitorsChangedListener = global.screen.connect("monitors-changed", Lang.bind(this, function(){this._setPanelStyle();}));
this._HeightNotifyListener = this.panelBox.connect("notify::height", Lang.bind(this, function(){this._setPanelStyle();}));
this._setPanelStyle();
this._oldLeftBoxStyle = this.panel._leftBox.get_style();
this._oldCenterBoxStyle = this.panel._centerBox.get_style();
this._oldRightBoxStyle = this.panel._rightBox.get_style();
@@ -196,11 +199,11 @@ const taskbarPanel = new Lang.Class({
_bindSettingsChanges: function() {
this._dtpSettings.connect('changed::panel-position', Lang.bind(this, function() {
this._setPanelStyle();
this._setPanelPosition();
}));
this._dtpSettings.connect('changed::panel-size', Lang.bind(this, function() {
this._setPanelStyle();
this._setPanelPosition();
}));
this._dtpSettings.connect('changed::show-activities-button', Lang.bind(this, function() {
@@ -274,13 +277,17 @@ const taskbarPanel = new Lang.Class({
this.panel._rightCorner.actor.allocate(childBox, flags);
},
_setPanelStyle: function() {
_setPanelPosition: function() {
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let size = this._dtpSettings.get_int('panel-size');
let position = this._dtpSettings.get_string('panel-position');
let isTop = position == "TOP";
if(scaleFactor)
size = size*scaleFactor;
this.panel.actor.set_height(size);
let position = this._dtpSettings.get_string('panel-position');
let isTop = position == "TOP";
Main.overview._panelGhost.set_height(isTop ? size : 0);
this._myPanelGhost.set_height(isTop ? 0 : size);
isTop ? this.panelBox.set_anchor_point(0, 0) :

View File

@@ -37,15 +37,14 @@ const Workspace = imports.ui.workspace;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Taskbar = Me.imports.taskbar;
let THUMBNAIL_WIDTH = 350;
let THUMBNAIL_HEIGHT = 200;
let DEFAULT_THUMBNAIL_WIDTH = 350;
let DEFAULT_THUMBNAIL_HEIGHT = 200;
const thumbnailPreviewMenu = new Lang.Class({
Name: 'thumbnailPreviewMenu',
Extends: PopupMenu.PopupMenu,
_init: function(source, settings) {
this._dtpSettings = settings;
let side = Taskbar.getPosition();
@@ -190,6 +189,13 @@ const thumbnailPreview = new Lang.Class({
_init: function(window) {
this.window = window;
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
if(!scaleFactor)
scaleFactor = 1;
this._thumbnailWidth = DEFAULT_THUMBNAIL_WIDTH*scaleFactor;
this._thumbnailHeight = DEFAULT_THUMBNAIL_HEIGHT*scaleFactor;
this.parent({reactive: true});
this._workId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._onResize));
this._closeButtonId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._repositionCloseButton));
@@ -207,7 +213,7 @@ const thumbnailPreview = new Lang.Class({
vertical: true });
this._previewBin = new St.Bin();
this._previewBin.set_size(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
this._previewBin.set_size(this._thumbnailWidth, this._thumbnailHeight);
this._closeButton = new St.Button({ style_class: 'window-close',
accessible_name: "Close window" });
@@ -221,7 +227,7 @@ const thumbnailPreview = new Lang.Class({
this._title = new St.Label({ text: window.title });
this._titleBin = new St.Bin({ child: this._title,
x_align: St.Align.MIDDLE,
width: THUMBNAIL_WIDTH
width: this._thumbnailWidth
});
this._titleBin.add_style_class_name("preview-window-title");
@@ -231,8 +237,8 @@ const thumbnailPreview = new Lang.Class({
this._windowBin = new St.Bin({ child: this.overlayGroup,
x_align: St.Align.MIDDLE,
width: THUMBNAIL_WIDTH,
height: THUMBNAIL_HEIGHT
width: this._thumbnailWidth,
height: this._thumbnailHeight
});
this._windowBox.add_child(this._windowBin);
@@ -311,7 +317,7 @@ const thumbnailPreview = new Lang.Class({
if (mutterWindow) {
let windowTexture = mutterWindow.get_texture();
let [width, height] = windowTexture.get_size();
this.scale = Math.min(1.0, THUMBNAIL_WIDTH / width, THUMBNAIL_HEIGHT / height);
this.scale = Math.min(1.0, this._thumbnailWidth / width, this._thumbnailHeight / height);
thumbnail = new Clutter.Clone ({ source: windowTexture,
reactive: true,
width: width * this.scale,
@@ -334,7 +340,7 @@ const thumbnailPreview = new Lang.Class({
_onResize: function() {
let [width, height] = this.preview.get_source().get_size();
this.scale = Math.min(1.0, THUMBNAIL_WIDTH / width, THUMBNAIL_HEIGHT / height);
this.scale = Math.min(1.0, this._thumbnailWidth / width, this._thumbnailHeight / height);
this.preview.set_size(width * this.scale, height * this.scale);
this._queueRepositionCloseButton();
@@ -349,8 +355,8 @@ const thumbnailPreview = new Lang.Class({
let cloneWidth = Math.floor(rect.width) * this.scale;
let cloneHeight = Math.floor(rect.height) * this.scale;
let cloneX = (THUMBNAIL_WIDTH - cloneWidth) / 2 ;
let cloneY = (THUMBNAIL_HEIGHT - cloneHeight) / 2;
let cloneX = (this._thumbnailWidth - cloneWidth) / 2 ;
let cloneY = (this._thumbnailHeight - cloneHeight) / 2;
let buttonX;
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) {
@@ -358,7 +364,7 @@ const thumbnailPreview = new Lang.Class({
buttonX = Math.max(buttonX, 0);
} else {
buttonX = cloneX + (cloneWidth - (this._closeButton.width / 2));
buttonX = Math.min(buttonX, THUMBNAIL_WIDTH - this._closeButton.width);
buttonX = Math.min(buttonX, this._thumbnailWidth - this._closeButton.width);
}
let buttonY = cloneY - (this._closeButton.height / 2);