[gnome-shell] Improve postioning of status menu



commit f1a9ada5f018437e2bbf72c2845a9290390655f6
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Wed Jun 17 14:35:32 2009 -0400

    Improve postioning of status menu
    
    Currently we position the user status menu at the upper left of
    the user status button. Then, because Mutter is inappropriately
    positioning override-redirect windows it get shoved into the
    workarea. Once that bug is fixed (bug 582639), we'll have to
    position the menu ourselves.
    
    This patch aligns the user status menu at the left end of
    and beneath the top panel.
    
    http://bugzilla.gnome.org/show_bug.cgi?id=586156

 src/shell-status-menu.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/src/shell-status-menu.c b/src/shell-status-menu.c
index bfe9b41..8293ac2 100644
--- a/src/shell-status-menu.c
+++ b/src/shell-status-menu.c
@@ -598,12 +598,25 @@ static void
 position_menu (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
 {
   ShellStatusMenu *status = SHELL_STATUS_MENU (user_data);
+  ClutterActor *parent;
   float src_x, src_y;
-
-  clutter_actor_get_transformed_position (CLUTTER_ACTOR (status), &src_x, &src_y);
-
-  *x = (gint)(0.5 + src_x);
-  *y = (gint)(0.5 + src_y);
+  float width, height;
+  int menu_width;
+
+  gtk_widget_get_size_request (GTK_WIDGET (menu), &menu_width, NULL);
+
+  /* Encapsulation breakage: it looks better if the menu is
+   * aligned with the bottom of the actor's grandparent - the
+   * panel, rather than with the bottom of the actor. We just
+   * assume what the hierarchy is and where we are positioned
+   * in the panel.
+   */
+  parent = clutter_actor_get_parent (CLUTTER_ACTOR (status));
+  parent = clutter_actor_get_parent (parent);
+  clutter_actor_get_transformed_position (parent, &src_x, &src_y);
+  clutter_actor_get_transformed_size (parent, &width, &height);
+  *x = (gint)(0.5 + src_x + width - menu_width);
+  *y = (gint)(0.5 + src_y + height);
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]