[maemo-commits] [maemo-commits] r18277 - in projects/haf/trunk/libmatchbox2: . matchbox/client-types matchbox/theme-engines

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu May 7 00:46:02 EEST 2009
Author: tthurman
Date: 2009-05-07 00:45:46 +0300 (Thu, 07 May 2009)
New Revision: 18277

Modified:
   projects/haf/trunk/libmatchbox2/ChangeLog
   projects/haf/trunk/libmatchbox2/matchbox/client-types/mb-wm-client-menu.c
   projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.c
   projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.h
Log:
	NB#111652 legacy widget : application menu is not horizontally
	aligned application title text
	* matchbox/client-types/mb-wm-client-menu.c:
	Legacy app menus are positioned according to the
	position of the window title.
	* matchbox/theme-engines/mb-wm-theme.c:
	* matchbox/theme-engines/mb-wm-theme.h:
	Add accessor to retrieve the position of the window title.



Modified: projects/haf/trunk/libmatchbox2/ChangeLog
===================================================================
--- projects/haf/trunk/libmatchbox2/ChangeLog	2009-05-06 17:20:09 UTC (rev 18276)
+++ projects/haf/trunk/libmatchbox2/ChangeLog	2009-05-06 21:45:46 UTC (rev 18277)
@@ -1,3 +1,15 @@
+2009-05-06  Thomas Thurman  <thomas.thurman at collabora.co.uk>
+
+	NB#111652 legacy widget : application menu is not horizontally
+	aligned application title text
+	
+	* matchbox/client-types/mb-wm-client-menu.c:
+	Legacy app menus are positioned according to the
+	position of the window title.
+	* matchbox/theme-engines/mb-wm-theme.c:
+	* matchbox/theme-engines/mb-wm-theme.h:
+	Add accessor to retrieve the position of the window title.
+
 2009-05-06  Adam Endrodi  <adam.endrodi at blumsoft.eu>
 
 	Now, try to deal with preexisting fullscreen clients correctly,

Modified: projects/haf/trunk/libmatchbox2/matchbox/client-types/mb-wm-client-menu.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/client-types/mb-wm-client-menu.c	2009-05-06 17:20:09 UTC (rev 18276)
+++ projects/haf/trunk/libmatchbox2/matchbox/client-types/mb-wm-client-menu.c	2009-05-06 21:45:46 UTC (rev 18277)
@@ -111,26 +111,34 @@
   else if (geom.x < 0 && geom.y < 0) /* magic marker for
                                         legacy application menu */
   {
+    gint title_x, title_y;
+    const gint menu_left_gutter = 23;
+
     geom.x += wm->xdpy_width;
     geom.y += wm->xdpy_height;
 
-    if (geom.x < 112 * 2)
-      /* TODO: this should be dynamic, depending on status area.
-       * Also, submenus need to be handled differently */
-      geom.x = 112 * 2;
+    mb_wm_theme_get_title_xy (wm->theme, &title_x, &title_y);
+	
+    if (geom.x < title_x)
+      geom.x = title_x - menu_left_gutter;
 
-    if (geom.y < 56)
-      geom.y = 56; /* shouldn't this be taken from the theme? */
+    if (geom.y < title_y)
+      geom.y = title_y;
   }
   else /* FIXME: remove this else branch after the widget side does
           negative coordinates for legacy application menus,
           see NB#101437 */
   {
-    if (geom.x < 112 * 2)
-      geom.x = 112 * 2;
+    gint title_x, title_y;
+    const gint menu_left_gutter = 23;
 
-    if (geom.y < 56)
-      geom.y = 56; /* shouldn't this be taken from the theme? */
+    mb_wm_theme_get_title_xy (wm->theme, &title_x, &title_y);
+
+    if (geom.x < title_x)
+      geom.x = title_x - menu_left_gutter;
+
+    if (geom.y < title_y)
+      geom.y = title_y;
   }
 
   g_debug ("%s: Menu will be at %d %d %d %d", __func__, geom.x, geom.y,

Modified: projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.c	2009-05-06 17:20:09 UTC (rev 18276)
+++ projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.c	2009-05-06 21:45:46 UTC (rev 18277)
@@ -71,6 +71,8 @@
 static MBWMDecor *
 mb_wm_theme_simple_create_decor (MBWMTheme *, MBWindowManagerClient *,
 				 MBWMDecorType);
+static void
+mb_wm_theme_simple_get_title_xy (MBWMTheme *theme, int *x, int *y);
 
 static void
 mb_wm_theme_class_init (MBWMObjectClass *klass)
@@ -83,6 +85,7 @@
   t_class->button_size      = mb_wm_theme_simple_get_button_size;
   t_class->button_position  = mb_wm_theme_simple_get_button_position;
   t_class->create_decor     = mb_wm_theme_simple_create_decor;
+  t_class->get_title_xy     = mb_wm_theme_simple_get_title_xy;
 
 #if MBWM_WANT_DEBUG
   klass->klass_name = "MBWMTheme";
@@ -667,6 +670,26 @@
     klass->set_left_padding (theme, decor, new_padding);
 }
 
+void
+mb_wm_theme_get_title_xy (MBWMTheme             *theme,
+			  int                   *x,
+			  int                   *y)
+{
+  MBWMThemeClass *klass;
+
+  /* defaults */
+  if (x) *x = 112 * 2;
+  if (y) *y = 56;
+
+  if (!theme)
+    return;
+
+  klass = MB_WM_THEME_CLASS(MB_WM_OBJECT_GET_CLASS (theme));
+
+  if (klass->get_title_xy)
+    klass->get_title_xy (theme, x, y);
+}
+
 MBWMClientLayoutHints
 mb_wm_theme_get_client_layout_hints (MBWMTheme             * theme,
 				     MBWindowManagerClient * client)
@@ -2130,7 +2153,7 @@
   XClearWindow (wm->xdpy, xwin);
 }
 
-/*
+/**
  * Installs a global handler that can be used to translate custom client type
  * names to their numerical values.
  *
@@ -2145,7 +2168,7 @@
   custom_client_type_func_data = user_data;
 }
 
-/*
+/**
  * Installs a global handler that can be used to translate custom theme names
  * to their numerical (MBWMObject) values.
  *
@@ -2160,7 +2183,7 @@
   custom_theme_type_func_data = user_data;
 }
 
-/*
+/**
  * Installs a global handler that can be used to translate custom button names
  * to their numerical values.
  *
@@ -2175,7 +2198,7 @@
   custom_button_type_func_data = user_data;
 }
 
-/*
+/**
  * Installs a global handler that can be used to allocate a custom
  * MBWMThemeSubclass.
  *
@@ -2187,3 +2210,18 @@
 {
   custom_theme_alloc_func = func;
 }
+
+/**
+ * Gets the current X position of the left-hand side of
+ * the title in this theme, and the Y position of the
+ * bottom edge of the title.
+ */
+void
+mb_wm_theme_simple_get_title_xy (MBWMTheme *theme, int *x, int *y)
+{
+  /* The mysterious numbers are taken from the spec
+   * and were originally found in mb_wm_client_menu_init().
+   */
+  if (x) *x = 112 * 2;
+  if (y) *y = 56;
+}

Modified: projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.h
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.h	2009-05-06 17:20:09 UTC (rev 18276)
+++ projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.h	2009-05-06 21:45:46 UTC (rev 18277)
@@ -93,6 +93,10 @@
   void  (*set_left_padding)     (MBWMTheme             *theme,
 			         MBWMDecor             *decor,
                                  int                    new_padding);
+
+  void  (*get_title_xy)         (MBWMTheme             *theme,
+				 int                   *x,
+				 int                   *y);
 };
 
 /**
@@ -232,4 +236,7 @@
 
 extern unsigned int left_padding;
 
+void
+mb_wm_theme_get_title_xy (MBWMTheme *theme, int *x, int *y);
+
 #endif


More information about the maemo-commits mailing list