[gnome-shell] CtrlAltTabPopup: Fix pixel alignment
- From: Adel Gadllah <agadllah src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] CtrlAltTabPopup: Fix pixel alignment
- Date: Fri, 4 Mar 2011 16:08:17 +0000 (UTC)
commit 03401bbb589d6f38b6e65cacee1f57880ca57afd
Author: Adel Gadllah <adel gadllah gmail com>
Date: Fri Mar 4 09:46:05 2011 +0100
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
js/ui/ctrlAltTab.js | 43 +++++++++++++++++++++++++++++++++++++------
1 files changed, 37 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/ctrlAltTab.js b/js/ui/ctrlAltTab.js
index 8faa6c5..83bb9b9 100644
--- a/js/ui/ctrlAltTab.js
+++ b/js/ui/ctrlAltTab.js
@@ -91,12 +91,12 @@ function CtrlAltTabPopup() {
CtrlAltTabPopup.prototype = {
_init : function() {
- let primary = global.get_primary_monitor();
- this.actor = new St.BoxLayout({ name: 'ctrlAltTabPopup',
- reactive: true,
- x: primary.x + primary.width / 2,
- y: primary.y + primary.height / 2,
- anchor_gravity: Clutter.Gravity.CENTER });
+ this.actor = new Shell.GenericContainer({ name: 'ctrlAltTabPopup',
+ reactive: true });
+
+ this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
+ this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
+ this.actor.connect('allocate', Lang.bind(this, this._allocate));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
@@ -106,6 +106,37 @@ CtrlAltTabPopup.prototype = {
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) {
if (!Main.pushModal(this.actor))
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]