CtrlAltTabPopup: Fix pixel alignment
CtrlAltTabPopup was using a St.BoxLayout and relied on anchor_gravity center for positioning. This does not guarantee correct pixel alignment, so use a St.GenericContainer instead and do the positioning similar to that of the appSwitcher. https://bugzilla.gnome.org/show_bug.cgi?id=643820
This commit is contained in:
parent
75ae209653
commit
03401bbb58
@ -91,12 +91,12 @@ function CtrlAltTabPopup() {
|
|||||||
|
|
||||||
CtrlAltTabPopup.prototype = {
|
CtrlAltTabPopup.prototype = {
|
||||||
_init : function() {
|
_init : function() {
|
||||||
let primary = global.get_primary_monitor();
|
this.actor = new Shell.GenericContainer({ name: 'ctrlAltTabPopup',
|
||||||
this.actor = new St.BoxLayout({ name: 'ctrlAltTabPopup',
|
reactive: true });
|
||||||
reactive: true,
|
|
||||||
x: primary.x + primary.width / 2,
|
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
|
||||||
y: primary.y + primary.height / 2,
|
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
|
||||||
anchor_gravity: Clutter.Gravity.CENTER });
|
this.actor.connect('allocate', Lang.bind(this, this._allocate));
|
||||||
|
|
||||||
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||||
|
|
||||||
@ -106,6 +106,37 @@ CtrlAltTabPopup.prototype = {
|
|||||||
Main.uiGroup.add_actor(this.actor);
|
Main.uiGroup.add_actor(this.actor);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getPreferredWidth: function (actor, forHeight, alloc) {
|
||||||
|
let primary = global.get_primary_monitor();
|
||||||
|
|
||||||
|
alloc.min_size = primary.width;
|
||||||
|
alloc.natural_size = primary.width;
|
||||||
|
},
|
||||||
|
|
||||||
|
_getPreferredHeight: function (actor, forWidth, alloc) {
|
||||||
|
let primary = global.get_primary_monitor();
|
||||||
|
|
||||||
|
alloc.min_size = primary.height;
|
||||||
|
alloc.natural_size = primary.height;
|
||||||
|
},
|
||||||
|
|
||||||
|
_allocate: function (actor, box, flags) {
|
||||||
|
let childBox = new Clutter.ActorBox();
|
||||||
|
let primary = global.get_primary_monitor();
|
||||||
|
|
||||||
|
let leftPadding = this.actor.get_theme_node().get_padding(St.Side.LEFT);
|
||||||
|
let vPadding = this.actor.get_theme_node().get_vertical_padding();
|
||||||
|
let hPadding = this.actor.get_theme_node().get_horizontal_padding();
|
||||||
|
|
||||||
|
let [childMinHeight, childNaturalHeight] = this._switcher.actor.get_preferred_height(primary.width - hPadding);
|
||||||
|
let [childMinWidth, childNaturalWidth] = this._switcher.actor.get_preferred_width(childNaturalHeight);
|
||||||
|
childBox.x1 = Math.max(primary.x + leftPadding, primary.x + Math.floor((primary.width - childNaturalWidth) / 2));
|
||||||
|
childBox.x2 = Math.min(primary.width - hPadding, childBox.x1 + childNaturalWidth);
|
||||||
|
childBox.y1 = primary.y + Math.floor((primary.height - childNaturalHeight) / 2);
|
||||||
|
childBox.y2 = childBox.y1 + childNaturalHeight;
|
||||||
|
this._switcher.actor.allocate(childBox, flags);
|
||||||
|
},
|
||||||
|
|
||||||
show : function(items, startBackwards) {
|
show : function(items, startBackwards) {
|
||||||
if (!Main.pushModal(this.actor))
|
if (!Main.pushModal(this.actor))
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user