[maemo-commits] [maemo-commits] r12027 - in projects/haf/trunk/hildon-desktop: . libhildondesktop src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Jun 1 13:24:24 EEST 2007
Author: jobi
Date: 2007-06-01 13:24:21 +0300 (Fri, 01 Jun 2007)
New Revision: 12027

Modified:
   projects/haf/trunk/hildon-desktop/ChangeLog
   projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-toggle-button.c
   projects/haf/trunk/hildon-desktop/src/hd-panel-window.c
Log:

2007-06-01  Johan Bilien  <johan.bilien at nokia.com>

	* src/hd-panel-window.c:
	- added configure-event handler to track window geometry
	- attach the picture to the drawable so it can be used
	by child widgets drawing on the same window
	* src/hildon-toggle-button.c:
	- check if the drawable already has a Picture attached
	and use it if available



Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog	2007-06-01 10:18:57 UTC (rev 12026)
+++ projects/haf/trunk/hildon-desktop/ChangeLog	2007-06-01 10:24:21 UTC (rev 12027)
@@ -1,3 +1,13 @@
+2007-06-01  Johan Bilien  <johan.bilien at nokia.com>
+
+	* src/hd-panel-window.c:
+	- added configure-event handler to track window geometry
+	- attach the picture to the drawable so it can be used
+	by child widgets drawing on the same window
+	* src/hildon-toggle-button.c:
+	- check if the drawable already has a Picture attached
+	and use it if available
+
 2007-05-31  Johan Bilien  <johan.bilien at nokia.com>
 
 	* hildon-home-area.c:

Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-toggle-button.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-toggle-button.c	2007-06-01 10:18:57 UTC (rev 12026)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-toggle-button.c	2007-06-01 10:24:21 UTC (rev 12027)
@@ -92,9 +92,10 @@
       GdkDrawable                      *drawable;
       GdkVisual                        *visual;
       gint                              x_offset, y_offset;
-      Picture                           picture;
+      Picture                           picture = None;
       XRenderPictFormat                *format;
       XRenderPictureAttributes          pa = {0};
+      gboolean                          picture_is_ours = FALSE;
 
       button = GTK_BUTTON (widget);
       priv = HILDON_DESKTOP_TOGGLE_BUTTON (widget)->priv;
@@ -112,12 +113,19 @@
       if (format == None)
         return FALSE;
 
-      picture = XRenderCreatePicture (GDK_DISPLAY (),
-                                      GDK_DRAWABLE_XID (drawable),
-                                      format,
-                                      0,
-                                      &pa);
+      picture = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (drawable),
+                                                    "picture"));
 
+      if (picture == None)
+        {
+          picture_is_ours = TRUE;
+          picture = XRenderCreatePicture (GDK_DISPLAY (),
+                                          GDK_DRAWABLE_XID (drawable),
+                                          format,
+                                          0,
+                                          &pa);
+        }
+
       if (priv->pressed_picture != None  && button->depressed)
         XRenderComposite (GDK_DISPLAY (),
                           PictOpOver,
@@ -140,8 +148,9 @@
                           event->area.x - x_offset, event->area.y - y_offset,
                           event->area.width, event->area.height);
 
-      XRenderFreePicture (GDK_DISPLAY (),
-                          picture);
+      if (picture_is_ours)
+        XRenderFreePicture (GDK_DISPLAY (),
+                            picture);
 
       return GTK_WIDGET_CLASS (hildon_desktop_toggle_button_parent_class)->
                 expose_event (widget, event);

Modified: projects/haf/trunk/hildon-desktop/src/hd-panel-window.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-panel-window.c	2007-06-01 10:18:57 UTC (rev 12026)
+++ projects/haf/trunk/hildon-desktop/src/hd-panel-window.c	2007-06-01 10:24:21 UTC (rev 12027)
@@ -68,6 +68,8 @@
 
   Picture       background_picture;
   Picture       background_mask;
+
+  gint          x, y, width, height;
 };
 
 
@@ -297,14 +299,12 @@
     HDPanelWindowPrivate       *priv = HD_PANEL_WINDOW (widget)->priv;
     GdkDrawable *drawable;
     gint x_offset, y_offset;
-    gint x, y;
     Picture picture;
     GdkVisual *visual;
     XRenderPictFormat *format;
     XRenderPictureAttributes pa = {0};
+    gboolean result;
 
-    gtk_window_get_position (GTK_WINDOW (widget), &x, &y);
-
     gdk_window_get_internal_paint_info (widget->window,
                                         &drawable,
                                         &x_offset,
@@ -321,14 +321,17 @@
                                     0,
                                     &pa);
 
+    g_object_set_data (G_OBJECT (drawable),
+                       "picture", GINT_TO_POINTER (picture));
+
     if (priv->home_picture != None)
       XRenderComposite (GDK_DISPLAY (),
                         PictOpSrc,
                         priv->home_picture,
                         None,
                         picture,
-                        x + event->area.x, y + event->area.y,
-                        x + event->area.x, y + event->area.y,
+                        priv->x + event->area.x, priv->y + event->area.y,
+                        priv->x + event->area.x, priv->y + event->area.y,
                         event->area.x - x_offset,
                         event->area.y - y_offset,
                         event->area.width,
@@ -340,25 +343,43 @@
                         priv->background_picture,
                         priv->background_mask,
                         picture,
-                        x + event->area.x, y + event->area.y,
-                        x + event->area.x, y + event->area.y,
+                        priv->x + event->area.x, priv->y + event->area.y,
+                        priv->x + event->area.x, priv->y + event->area.y,
                         event->area.x - x_offset,
                         event->area.y - y_offset,
                         event->area.width,
                         event->area.height);
 
+    result = GTK_WIDGET_CLASS (hd_panel_window_parent_class)->
+        expose_event (widget, event);
 
     XRenderFreePicture (GDK_DISPLAY (),
                         picture);
 
-    return GTK_WIDGET_CLASS (hd_panel_window_parent_class)->
-        expose_event (widget, event);
+    g_object_set_data (G_OBJECT (drawable),
+                       "picture", GINT_TO_POINTER (None));
 
+    return result;
+
   }
 
 return FALSE;
 }
 
+static gboolean
+hd_panel_window_configure (GtkWidget           *widget,
+                           GdkEventConfigure   *event)
+{
+  HDPanelWindowPrivate *priv = HD_PANEL_WINDOW_GET_PRIVATE (widget);
+
+  priv->x = event->x;
+  priv->y = event->y;
+  priv->width = event->width;
+  priv->height = event->height;
+
+  return FALSE;
+}
+
 static GdkFilterReturn
 hd_panel_window_home_window_filter (GdkXEvent          *xevent,
                                     GdkEvent           *event,
@@ -366,28 +387,51 @@
 {
   XEvent               *e = xevent;
   HDPanelWindowClass   *klass;
+  HDPanelWindowPrivate *priv;
 
   klass = HD_PANEL_WINDOW_GET_CLASS (window);
+  priv  = HD_PANEL_WINDOW_GET_PRIVATE (window);
 
   if (!GTK_WIDGET_REALIZED (GTK_WIDGET (window)))
     return GDK_FILTER_CONTINUE;
 
   if (e->type == klass->xdamage_event_base + XDamageNotify)
     {
-      XDamageNotifyEvent *ev = xevent;
-      GdkRectangle rect;
-      XserverRegion parts;
+      XserverRegion             parts;
+      XDamageNotifyEvent       *ev = xevent;
+      XRectangle               *rects;
+      guint                     i, n_rect;
 
-      rect.x = ev->area.x;
-      rect.y = ev->area.y;
-      rect.width = ev->area.width;
-      rect.height = ev->area.height;
+      parts = XFixesCreateRegion (GDK_DISPLAY (), 0, 0);
 
-      parts = XFixesCreateRegion (GDK_DISPLAY (), &ev->area, 1);
       XDamageSubtract (GDK_DISPLAY (), ev->damage, None, parts);
-      XFixesDestroyRegion (GDK_DISPLAY (), parts);
 
-      gdk_window_invalidate_rect (GTK_WIDGET (window)->window, &rect, FALSE);
+      rects = XFixesFetchRegion (GDK_DISPLAY (),
+                                 parts,
+                                 &n_rect);
+
+      XFixesDestroyRegion (GDK_DISPLAY (),
+                           parts);
+
+      for (i = 0; i < n_rect; i++)
+        {
+          if (priv->x + priv->width >= rects[i].x       &&
+              priv->x <= rects[i].x + rects[i].width   &&
+              priv->y + priv->height >= rects[i].y      &&
+              priv->y <= rects[i].y + rects[i].height)
+
+           {
+             GdkRectangle rect;
+
+             rect.x = rects[i].x;
+             rect.y = rects[i].y;
+             rect.width = rects[i].width;
+             rect.height = rects[i].height;
+             gdk_window_invalidate_rect (GTK_WIDGET (window)->window,
+                                         &rect,
+                                         TRUE);
+           }
+        }
     }
 
   return GDK_FILTER_CONTINUE;
@@ -593,9 +637,10 @@
     gint damage_error, composite_error;
     gint composite_event_base;
 
-    widget_class->expose_event = hd_panel_window_expose;
-    widget_class->style_set    = hd_panel_window_style_set;
-    widget_class->realize      = hd_panel_window_realize;
+    widget_class->expose_event          = hd_panel_window_expose;
+    widget_class->style_set             = hd_panel_window_style_set;
+    widget_class->realize               = hd_panel_window_realize;
+    widget_class->configure_event       = hd_panel_window_configure;
 
     if (XDamageQueryExtension (GDK_DISPLAY (),
                                &klass->xdamage_event_base,
@@ -636,7 +681,10 @@
                                 window);
     }
 
-/*  gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE); */
+#if 0
+  gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
+  gtk_widget_set_double_buffered (GTK_WIDGET (window), FALSE);
+#endif
 
   window->priv = HD_PANEL_WINDOW_GET_PRIVATE (window);
 #endif


More information about the maemo-commits mailing list