[maemo-commits] [maemo-commits] r19368 - in projects/haf/trunk/gtk+: . gdk/x11

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Sep 18 14:07:45 EEST 2009
Author: kris
Date: 2009-09-18 14:07:17 +0300 (Fri, 18 Sep 2009)
New Revision: 19368

Modified:
   projects/haf/trunk/gtk+/ChangeLog
   projects/haf/trunk/gtk+/gdk/x11/gdkevents-x11.c
   projects/haf/trunk/gtk+/gdk/x11/gdkscreen-x11.c
Log:
2009-09-18  Kristian Rietveld  <kris at lanedo.com>

	Fixes: NB#139504 - GdkScreen needs to respond to size events from
	the window manager

	* gdk/x11/gdkscreen-x11.c (_gdk_x11_screen_size_changed): apply
	patch from Gordon Williams to emit size-changed upon changes of
	the _MAEMO_SCREEN_WIDTH and HEIGHT properties.
	
	* gdk/x11/gdkevents-x11.c (gdk_event_translate): listen for
	property notify of _MAEMO_SCREEN_HEIGHT property here.



Modified: projects/haf/trunk/gtk+/ChangeLog
===================================================================
--- projects/haf/trunk/gtk+/ChangeLog	2009-09-18 07:03:31 UTC (rev 19367)
+++ projects/haf/trunk/gtk+/ChangeLog	2009-09-18 11:07:17 UTC (rev 19368)
@@ -1,3 +1,15 @@
+2009-09-18  Kristian Rietveld  <kris at lanedo.com>
+
+	Fixes: NB#139504 - GdkScreen needs to respond to size events from
+	the window manager
+
+	* gdk/x11/gdkscreen-x11.c (_gdk_x11_screen_size_changed): apply
+	patch from Gordon Williams to emit size-changed upon changes of
+	the _MAEMO_SCREEN_WIDTH and HEIGHT properties.
+	
+	* gdk/x11/gdkevents-x11.c (gdk_event_translate): listen for
+	property notify of _MAEMO_SCREEN_HEIGHT property here.
+
 2009-09-10  Alberto Garcia  <agarcia at igalia.com>
 
 	* docs/reference/gtk/gtk-sections.txt

Modified: projects/haf/trunk/gtk+/gdk/x11/gdkevents-x11.c
===================================================================
--- projects/haf/trunk/gtk+/gdk/x11/gdkevents-x11.c	2009-09-18 07:03:31 UTC (rev 19367)
+++ projects/haf/trunk/gtk+/gdk/x11/gdkevents-x11.c	2009-09-18 11:07:17 UTC (rev 19368)
@@ -1911,6 +1911,19 @@
 			   gdk_x11_get_xatom_name_for_display (display, xevent->xproperty.atom),
 			   "\""));
 
+#ifdef MAEMO_CHANGES
+      /* Check for maemo specific width/height change. Height is always
+       * changed last, so we only check on that. This allows us to relayout
+       * apps that depend on GdkScreen for orientation, *before* we do the
+       * real XRandR rotate.
+       */
+      if (xevent->xproperty.atom ==
+          gdk_x11_get_xatom_by_name_for_display (display, "_MAEMO_SCREEN_HEIGHT"))
+        {
+          _gdk_x11_screen_size_changed (screen, xevent);
+        }
+#endif /* MAEMO_CHANGES */
+
       if (window_private == NULL)
         {
 	  return_val = FALSE;

Modified: projects/haf/trunk/gtk+/gdk/x11/gdkscreen-x11.c
===================================================================
--- projects/haf/trunk/gtk+/gdk/x11/gdkscreen-x11.c	2009-09-18 07:03:31 UTC (rev 19367)
+++ projects/haf/trunk/gtk+/gdk/x11/gdkscreen-x11.c	2009-09-18 11:07:17 UTC (rev 19368)
@@ -895,10 +895,65 @@
 			      XEvent    *event)
 {
   gint width, height;
+#ifdef MAEMO_CHANGES
+  GdkWindow *root_window;
+  GdkAtom type;
+  guchar *rwidth, *rheight;
+  gboolean has_props = FALSE;
+#endif /* MAEMO_CHANGES */
 
   width = gdk_screen_get_width (screen);
   height = gdk_screen_get_height (screen);
 
+#ifdef MAEMO_CHANGES
+  /* The SCREEN_WIDTH/SCREEN_HEIGHT properties allow hildon-desktop to
+   * resize/relayout applications to the correct orientation before
+   * XRandR rotation actually happens.
+   */
+
+  root_window = gdk_screen_get_root_window (screen);
+  type = gdk_atom_intern ("CARDINAL", FALSE);
+
+  gdk_property_get (root_window,
+                    gdk_atom_intern_static_string ("_MAEMO_SCREEN_WIDTH"),
+                    type,
+                    0, 32, FALSE, 0, 0, 0, (guchar **) &rwidth);
+  gdk_property_get (root_window,
+                    gdk_atom_intern_static_string ("_MAEMO_SCREEN_HEIGHT"),
+                    type,
+                    0, 32, FALSE, 0, 0, 0, (guchar **) &rheight);
+
+  if (rwidth && rheight)
+    {
+      gint prop_width, prop_height;
+
+      prop_width = *(gint *)rwidth;
+      prop_height = *(gint *)rheight;
+
+      if (prop_width != width || prop_height != height)
+        {
+          Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
+          xscreen->width = prop_width;
+          xscreen->height = prop_height;
+
+          _gdk_x11_screen_process_monitors_change (screen);
+          g_signal_emit_by_name (screen, "size_changed");
+        }
+
+      has_props = TRUE;
+    }
+
+  if (rwidth)
+    g_free (rwidth);
+
+  if (rheight)
+    g_free (rheight);
+
+  /* If we had properties, return and ignore XRandR */
+  if (has_props)
+    return;
+#endif /* MAEMO_CHANGES */
+
 #ifdef HAVE_RANDR
   if (!XRRUpdateConfiguration (event))
     return;

More information about the maemo-commits mailing list