Implement HiDPI scaling

This commit is contained in:
Olaf Leidinger 2017-11-21 01:29:57 +01:00
parent 51062d0eee
commit 2a053cf4ea
3 changed files with 19 additions and 2 deletions

View File

@ -399,6 +399,11 @@ const TeaTime = new Lang.Class({
this._logo.setColor(this._primaryColor, this._secondaryColor);
this._graphicalTimer.setColor(this._primaryColor, this._secondaryColor);
// forward (possible) scaling style change to child
let scaling = Utils.getGlobalDisplayScaleFactor();
this._logo.setScaling(scaling);
this._graphicalTimer.setScaling(scaling);
}
});

View File

@ -26,8 +26,9 @@ const TwoColorIcon = new Lang.Class({
reactive: true,
style: 'padding: 0px 2px'
});
this.set_width(size);
this.set_height(size);
this._base_size = size;
this.setScaling(Utils.getGlobalDisplayScaleFactor());
this._drawingObject = drawingObject;
this.connect('repaint', Lang.bind(this, this._drawIcon));
@ -51,6 +52,12 @@ const TwoColorIcon = new Lang.Class({
this._secundaryColor = secundary;
this.queue_repaint();
},
setScaling: function (newScale) {
this._default_scale = newScale;
this.set_width(this._base_size * this._default_scale);
this.set_height(this._base_size * this._default_scale);
this.queue_repaint();
},
setStatus: function (newStatus) {
this._customStatus = newStatus;
this.queue_repaint();

View File

@ -9,6 +9,7 @@ const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Config = imports.misc.config;
const Gst = imports.gi.Gst;
const St = imports.gi.St;
const TEATIME_STEEP_TIMES_KEY = 'steep-times';
const TEATIME_FULLSCREEN_NOTIFICATION_KEY = 'fullscreen-notification';
@ -138,3 +139,7 @@ function setCairoColorFromClutter(cr, c) {
let s = 1.0 / 255;
cr.setSourceRGBA(s * c.red, s * c.green, s * c.blue, s * c.alpha);
}
function getGlobalDisplayScaleFactor() {
return St.ThemeContext.get_for_stage(global.stage).scale_factor;
}