[maemo-commits] [maemo-commits] r18935 - in projects/haf/trunk/libmatchbox2: . debian matchbox/core matchbox/theme-engines

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Jul 22 10:50:55 EEST 2009
Author: kihamala
Date: 2009-07-22 10:50:51 +0300 (Wed, 22 Jul 2009)
New Revision: 18935

Modified:
   projects/haf/trunk/libmatchbox2/ChangeLog
   projects/haf/trunk/libmatchbox2/debian/changelog
   projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c
   projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.c
   projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.h
Log:
apply patch from Laszlo


Modified: projects/haf/trunk/libmatchbox2/ChangeLog
===================================================================
--- projects/haf/trunk/libmatchbox2/ChangeLog	2009-07-22 06:58:47 UTC (rev 18934)
+++ projects/haf/trunk/libmatchbox2/ChangeLog	2009-07-22 07:50:51 UTC (rev 18935)
@@ -1,3 +1,13 @@
+2009-07-22  Kimmo Hämäläinen  <kimmo.hamalainen at nokia.com>
+
+	Applied patch from Laszlo Pere for NB#123486.
+
+	* matchbox/theme-engines/mb-wm-theme.[ch]: New functions
+	mb_wm_theme_protect, mb_wm_theme_unprotect, mb_wm_theme_check_broken,
+	mb_wm_theme_is_broken.
+	* matchbox/core/mb-window-manager.c: Fallback to the default theme if
+	we detected brokenness in the current theme.
+
 2009-07-21  Kimmo Hämäläinen  <kimmo.hamalainen at nokia.com>
 
 	* matchbox/core/mb-wm-main-context.c

Modified: projects/haf/trunk/libmatchbox2/debian/changelog
===================================================================
--- projects/haf/trunk/libmatchbox2/debian/changelog	2009-07-22 06:58:47 UTC (rev 18934)
+++ projects/haf/trunk/libmatchbox2/debian/changelog	2009-07-22 07:50:51 UTC (rev 18935)
@@ -1,7 +1,12 @@
 matchbox-window-manager-2 (0.2.49-1~unreleased) unstable; urgency=low
 
-  * phoo
+  Laszlo:
+  * Changes and new API related to NB#123486.
 
+  Kimmo:
+  * Zero removed event handler to allow call_handlers_for_event see it as
+    invalid. Could fix some non-reproducable crashes.
+
  -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com>  Mon, 20 Jul 2009 12:46:40 +0300
 
 matchbox-window-manager-2 (0.2.48-1) unstable; urgency=low

Modified: projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c	2009-07-22 06:58:47 UTC (rev 18934)
+++ projects/haf/trunk/libmatchbox2/matchbox/core/mb-window-manager.c	2009-07-22 07:50:51 UTC (rev 18935)
@@ -54,6 +54,8 @@
 #include <X11/extensions/Xfixes.h> /* Used to hide the cursor */
 #endif
 
+#define FALLBACK_THEME_PATH "/usr/share/themes/default"
+
 static void
 mb_wm_process_cmdline (MBWindowManager *wm);
 
@@ -535,6 +537,7 @@
 	  unsigned long items;
 	  unsigned long left;
 	  unsigned char *theme_path;
+	  Bool           same_path;
 
 	  XGetWindowProperty (wm->xdpy, wm->root_win->xwindow,
 			      xev->atom, 0, 8192, False,
@@ -545,7 +548,20 @@
 	  if (!type || !items)
 	    return True;
 
+	  /*
+	   * With protecting/unprotecting of the theme we can sense if the WM
+	   * segfaults because of a broken theme. However if the theme path is
+	   * the same we don't want to unprotect the theme if it is considered
+	   * to be broken. We only unprotect when the user sets a new theme to
+	   * be used.
+	   */
+	  same_path = theme_path && wm->theme_path && 
+		  strcmp ((char *)theme_path, wm->theme_path) == 0;
+	  if (!same_path)
+	    mb_wm_theme_protect ();
 	  mb_wm_set_theme_from_path (wm, (char*)theme_path);
+	  if (!same_path)
+            mb_wm_theme_unprotect ();
 
 	  XFree (theme_path);
 	}
@@ -1627,6 +1643,15 @@
   MBWindowManagerClass *wm_class;
 
   wm_class = (MBWindowManagerClass *) MB_WM_OBJECT_GET_CLASS (wm);
+  
+  /*
+   * We just started. If the theme protect file exists we had a crash the 
+   * previous time we loaded the theme. Then this theme is broken, we need to
+   * use the fallback theme.
+   */
+  if (mb_wm_theme_check_broken ()) {
+    wm->theme_path = FALLBACK_THEME_PATH;
+  }
 
   mb_wm_set_theme_from_path (wm, wm->theme_path);
 

Modified: projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.c
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.c	2009-07-22 06:58:47 UTC (rev 18934)
+++ projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.c	2009-07-22 07:50:51 UTC (rev 18935)
@@ -28,9 +28,11 @@
 #include <expat.h>
 #include <X11/Xft/Xft.h>
 #include <glib-object.h>
+#include <fcntl.h>
 
 #define SIMPLE_FRAME_TITLEBAR_HEIGHT 40
 #define SIMPLE_FRAME_EDGE_SIZE 0
+#define THEME_PROTECT_FILE_NAME "/tmp/mb_wm_theme_loading"
 
 /* FIXME! Global variable named like this? What about putting it to struct? */
 unsigned int left_padding = 0;
@@ -408,6 +410,63 @@
   Bool          shaped;
 };
 
+static Bool broken_theme;
+
+static Bool
+mb_wm_theme_is_protected (void)
+{
+  return access (THEME_PROTECT_FILE_NAME, F_OK) == 0;
+}
+
+/*
+ * Checks if the /tmp/mb_wm_theme_loading file exists and it is there it sets
+ * the broken flag for the theme. If the /tmp/mb_wm_theme_loading file exists
+ * when the window manager starts the current theme should be considered broken
+ * and should be not used.
+ */
+Bool
+mb_wm_theme_check_broken (void)
+{
+    broken_theme = mb_wm_theme_is_protected ();
+    return broken_theme;
+}
+
+/*
+ * Returns True if the current theme is considered to be broken.
+ */
+Bool
+mb_wm_theme_is_broken (void)
+{
+    return broken_theme;
+}
+
+/*
+ * Creates the /tmp/mb_wm_theme_loading file to sense if the window manager is
+ * crashed because of a broken theme.
+ */
+void
+mb_wm_theme_protect (void)
+{
+  if (mb_wm_theme_is_protected())
+    return;
+
+  creat (THEME_PROTECT_FILE_NAME, S_IRUSR | S_IWUSR);
+}
+
+/*
+ * Removes the /tmp/mb_wm_theme_loading file and unsets the broken theme flaf to
+ * indicate, that the theme is successfully loaded.
+ */
+void
+mb_wm_theme_unprotect (void)
+{
+  broken_theme = False;
+  if (!mb_wm_theme_is_protected())
+    return;
+
+  unlink (THEME_PROTECT_FILE_NAME);
+}
+
 /**
  * Loads a theme into memory from disk, and returns it.
  */

Modified: projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.h
===================================================================
--- projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.h	2009-07-22 06:58:47 UTC (rev 18934)
+++ projects/haf/trunk/libmatchbox2/matchbox/theme-engines/mb-wm-theme.h	2009-07-22 07:50:51 UTC (rev 18935)
@@ -122,6 +122,11 @@
 int
 mb_wm_theme_class_type ();
 
+void mb_wm_theme_protect   (void);
+void mb_wm_theme_unprotect (void);
+Bool mb_wm_theme_check_broken (void);
+Bool mb_wm_theme_is_broken (void);
+
 MBWMTheme *
 mb_wm_theme_new (MBWindowManager * wm,  const char * theme_path);
 

More information about the maemo-commits mailing list