[maemo-commits] [maemo-commits] r17685 - in projects/haf/trunk/libmatchbox2: . matchbox/core

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Mar 13 19:56:20 EET 2009
Author: tthurman
Date: 2009-03-13 19:56:17 +0200 (Fri, 13 Mar 2009)
New Revision: 17685

Modified:
   projects/haf/trunk/libmatchbox2/ChangeLog
   projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c
   projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-atoms.c
   projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client-window.c
   projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-types.h
Log:
	Add new _HILDON_WM_NAME property which can be used to name
	a window and include markup (if you want to have italics
	or whatever in your window names).
	Fixes: NB#105404.
	* matchbox/core/mb-window-manager.c:
	* matchbox/core/mb-wm-atoms.c:
	* matchbox/core/mb-wm-client-window.c:
	* matchbox/core/mb-wm-types.h:



Modified: projects/haf/trunk/libmatchbox2/ChangeLog
===================================================================
--- projects/haf/trunk/libmatchbox2/ChangeLog	2009-03-13 15:15:48 UTC (rev 17684)
+++ projects/haf/trunk/libmatchbox2/ChangeLog	2009-03-13 17:56:17 UTC (rev 17685)
@@ -1,3 +1,16 @@
+2009-03-13  Thomas Thurman  <thomas.thurman at collabora.co.uk>
+
+	Add new _HILDON_WM_NAME property which can be used to name
+	a window and include markup (if you want to have italics
+	or whatever in your window names).
+
+	Fixes: NB#105404.
+
+	* matchbox/core/mb-window-manager.c:
+	* matchbox/core/mb-wm-atoms.c:
+	* matchbox/core/mb-wm-client-window.c:
+	* matchbox/core/mb-wm-types.h:
+
 2009-03-13  Kimmo Hämäläinen  <kimmo.hamalainen at nokia.com>
 
 	Hide some symbols.

Modified: projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c	2009-03-13 15:15:48 UTC (rev 17684)
+++ projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c	2009-03-13 17:56:17 UTC (rev 17685)
@@ -600,7 +600,8 @@
   if (xev->atom == wm->atoms[MBWM_ATOM_NET_WM_USER_TIME])
     flag = MBWM_WINDOW_PROP_NET_USER_TIME;
   else if (xev->atom == wm->atoms[MBWM_ATOM_WM_NAME] ||
-	   xev->atom == wm->atoms[MBWM_ATOM_NET_WM_NAME])
+	   xev->atom == wm->atoms[MBWM_ATOM_NET_WM_NAME] ||
+	   xev->atom == wm->atoms[MBWM_ATOM_HILDON_WM_NAME])
     flag = MBWM_WINDOW_PROP_NAME;
   else if (xev->atom == wm->atoms[MBWM_ATOM_WM_HINTS])
     flag = MBWM_WINDOW_PROP_WM_HINTS;

Modified: projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-atoms.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-atoms.c	2009-03-13 15:15:48 UTC (rev 17684)
+++ projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-atoms.c	2009-03-13 17:56:17 UTC (rev 17685)
@@ -5,7 +5,7 @@
 {
   /*
    *   The list below *MUST* be kept in the same order as the corresponding
-   *   emun in structs.h or *everything* will break.
+   *   enum in mb-wm-types.h or *everything* will break.
    *   Doing it like this avoids a mass of round trips on startup.
    */
 
@@ -103,6 +103,7 @@
     "_MB_CURRENT_APP_WINDOW",
     "_MB_SECONDARY",
     "_HILDON_STACKING_LAYER",
+    "_HILDON_WM_NAME",
   };
 
   /* FIXME: Error Traps */

Modified: projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client-window.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client-window.c	2009-03-13 15:15:48 UTC (rev 17684)
+++ projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-client-window.c	2009-03-13 17:56:17 UTC (rev 17685)
@@ -29,6 +29,7 @@
   COOKIE_WIN_GEOM,
   COOKIE_WIN_NAME,
   COOKIE_WIN_NAME_UTF8,
+  COOKIE_WIN_NAME_UTF8_XML,
   COOKIE_WIN_SIZE_HINTS,
   COOKIE_WIN_WM_HINTS,
   COOKIE_WIN_TRANSIENCY,
@@ -249,6 +250,10 @@
       cookies[COOKIE_WIN_NAME_UTF8] =
 	mb_wm_property_utf8_req(wm, xwin,
 				wm->atoms[MBWM_ATOM_NET_WM_NAME]);
+
+      cookies[COOKIE_WIN_NAME_UTF8_XML] =
+	mb_wm_property_utf8_req(wm, xwin,
+				wm->atoms[MBWM_ATOM_HILDON_WM_NAME]);
     }
 
   if (props_req & MBWM_WINDOW_PROP_WM_HINTS)
@@ -568,42 +573,77 @@
 
   if (props_req & MBWM_WINDOW_PROP_NAME)
     {
+      /* We have three options for the name, which in priority order are:
+       *  1) _HILDON_WM_NAME, in UTF-8, in XML markup
+       *  2) _NET_WM_NAME, in UTF-8, no markup
+       *  3) WM_NAME, in ISO 8859-1, no markup
+       */
+      int name_types[] = {
+			  COOKIE_WIN_NAME_UTF8_XML,
+			  COOKIE_WIN_NAME_UTF8,
+			  COOKIE_WIN_NAME,
+			  0
+      };
+      int *cursor = name_types;
+      char *name = NULL;
+
       if (win->name)
-	XFree(win->name);
+	g_free(win->name);
 
-      /* Prefer UTF8 Naming... */
-      win->name
-	= mb_wm_property_get_reply_and_validate (wm,
-						 cookies[COOKIE_WIN_NAME_UTF8],
-						 wm->atoms[MBWM_ATOM_UTF8_STRING],
-						 8,
-						 0,
-						 NULL,
-						 &x_error_code);
-
-      if (x_error_code == BadWindow)
-        goto badwindow_error;
-
-      /* FIXME: Validate the UTF8 */
-
-      if (!win->name)
+      while (*cursor)
 	{
-	  /* FIXME: Should flag up name could be in some wacko encoding ? */
-	  win->name
+	  name
 	    = mb_wm_property_get_reply_and_validate (wm,
-						     cookies[COOKIE_WIN_NAME],
-						     XA_STRING,
+						     cookies[*cursor],
+						     *cursor==COOKIE_WIN_NAME? XA_STRING: wm->atoms[MBWM_ATOM_UTF8_STRING],
 						     8,
 						     0,
 						     NULL,
 						     &x_error_code);
+
+	  if (x_error_code == BadWindow)
+	    goto badwindow_error;
+
+	  if (name)
+	    break;
+
+	  cursor++;
 	}
 
-      if (win->name == NULL)
-	win->name = strdup("unknown");
+      switch (*cursor)
+	{
+	case COOKIE_WIN_NAME:
+	  /* TODO:  We could convert ISO 8859-1 to UTF-8 here,
+	   * if we thought anyone was likely to use ISO 8859-1
+	   * outside of the range where it coincides with ASCII
+	   * (and therefore also with UTF-8).
+	   */
 
+	  /* We also need to escape the text... */
+	  /* FALLTHROUGH */
+
+	case COOKIE_WIN_NAME_UTF8:
+	  /* We need to escape the text. */
+	  win->name = g_markup_escape_text (name, -1);
+	  break;
+
+	case COOKIE_WIN_NAME_UTF8_XML:
+	  /* Everything's lovely, so just take a copy */
+	  win->name = g_strdup (name);
+	  break;
+
+	case 0:
+	default:
+	  /* didn't find anything */
+	  win->name = g_strdup("unknown");
+	}
+
+      /* FIXME: We could also check the UTF-8 for validity here. */
+
       MBWM_DBG("@@@ New Window Name: '%s' @@@", win->name);
 
+      XFree (name);
+
       changes |= MBWM_WINDOW_PROP_NAME;
     }
 

Modified: projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-types.h
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-types.h	2009-03-13 15:15:48 UTC (rev 17684)
+++ projects/haf/trunk/libmatchbox2/matchbox/core/mb-wm-types.h	2009-03-13 17:56:17 UTC (rev 17685)
@@ -297,6 +297,8 @@
   /* special layers above others for mobile use (e.g. touchscreen lock) */
   MBWM_ATOM_HILDON_STACKING_LAYER,
 
+  MBWM_ATOM_HILDON_WM_NAME,
+
   MBWM_ATOM_COUNT
 
 } MBWMAtom;


More information about the maemo-commits mailing list