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

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Sep 6 17:51:41 EEST 2007
Author: jobi
Date: 2007-09-06 17:51:39 +0300 (Thu, 06 Sep 2007)
New Revision: 13648

Modified:
   projects/haf/trunk/hildon-desktop/ChangeLog
   projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-composite.c
   projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-picture.c
   projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-picture.h
   projects/haf/trunk/hildon-desktop/src/hd-panel-window-dialog.c
Log:

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

	* src/hd-panel-window-dialog.c:
	- when using XComposite, redirect the window to avoid
	flicking when a menu or application comes on top
	* libhildondesktop/hildon-desktop-panel-window-composite.c:
	- cache the theme pattern painted on top of the home background
	to speed up painting



Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog	2007-09-06 14:26:15 UTC (rev 13647)
+++ projects/haf/trunk/hildon-desktop/ChangeLog	2007-09-06 14:51:39 UTC (rev 13648)
@@ -1,3 +1,12 @@
+2007-09-06 Johan Bilien  <johan.bilien at nokia.com>
+
+	* src/hd-panel-window-dialog.c:
+	- when using XComposite, redirect the window to avoid
+	flicking when a menu or application comes on top
+	* libhildondesktop/hildon-desktop-panel-window-composite.c:
+	- cache the theme pattern painted on top of the home background
+	to speed up painting
+
 2007-09-06  Moises Martinez  <moises.martinez at nokia.com>
 
 	* libhildondesktop/hildon-desktop-panel-expandable.c:

Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-composite.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-composite.c	2007-09-06 14:26:15 UTC (rev 13647)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-composite.c	2007-09-06 14:51:39 UTC (rev 13648)
@@ -61,9 +61,12 @@
 struct _HildonDesktopPanelWindowCompositePrivate
 {
   Picture       background_picture;
-  Picture       background_mask;
-  gint          background_width, background_height;
+  guint         background_width, background_height;
 
+  Picture       pattern_picture;
+  Picture       pattern_mask;
+  guint         pattern_width, pattern_height;
+
   gint          x, y, width, height;
 
   XTransform    transform;
@@ -236,6 +239,90 @@
 
 #ifdef HAVE_X_COMPOSITE
 
+static void
+hildon_desktop_panel_window_composite_update_background (HildonDesktopPanelWindowComposite *window,
+                                                         GdkRectangle *area)
+{
+  HildonDesktopPanelWindowCompositePrivate     *priv = window->priv;
+  HildonDesktopPanelWindowCompositeClass       *klass =
+      HILDON_DESKTOP_PANEL_WINDOW_COMPOSITE_GET_CLASS (window);
+  DesktopWindowData                            *data =
+        klass->desktop_window_data;
+
+  if (!priv->width || !priv->height) return;
+
+  if (priv->background_picture == None ||
+      priv->width != priv->background_width ||
+      priv->height != priv->background_height)
+  {
+    const GdkColor      white = { 0xFFFFFFFF, 0xFFFF, 0xFFFF, 0xFFFF };
+
+    if (priv->background_picture != None)
+      XRenderFreePicture (GDK_DISPLAY (), priv->background_picture);
+
+    priv->background_picture = hildon_desktop_picture_from_color (&white,
+                                                                  priv->width,
+                                                                  priv->height);
+
+    g_return_if_fail (priv->background_picture != None);
+
+    priv->background_width  = priv->width;
+    priv->background_height = priv->height;
+
+    area->x = 0;
+    area->y = 0;
+    area->width  = priv->width;
+    area->height = priv->height;
+  }
+
+  if (data->home_picture != None)
+
+  {
+    XRenderComposite (GDK_DISPLAY (),
+                      PictOpSrc,
+                      data->home_picture,
+                      None,
+                      priv->background_picture,
+                      priv->x + area->x, priv->y + area->y,
+                      priv->x + area->x, priv->y + area->y,
+                      area->x,
+                      area->y,
+                      area->width,
+                      area->height);
+  }
+
+  if (priv->pattern_picture != None)
+  {
+    if (priv->scale)
+    {
+      XRenderSetPictureTransform (GDK_DISPLAY (),
+                                  priv->pattern_picture,
+                                  &priv->transform);
+
+      if (priv->pattern_mask != None)
+        XRenderSetPictureTransform (GDK_DISPLAY (),
+                                    priv->pattern_mask,
+                                    &priv->transform);
+    }
+
+    XRenderComposite (GDK_DISPLAY (),
+                      PictOpOver,
+                      priv->pattern_picture,
+                      priv->pattern_mask,
+                      priv->background_picture,
+                      area->x, area->y,
+                      area->x, area->y,
+                      area->x, area->y,
+                      area->width, area->height);
+
+  }
+
+  gdk_window_invalidate_rect (GTK_WIDGET (window)->window,
+                              area,
+                              TRUE);
+
+}
+
 static GdkFilterReturn
 home_window_filter (GdkXEvent          *xevent,
                     GdkEvent           *event,
@@ -288,18 +375,8 @@
               MIN (rects[i].y + rects[i].height,  priv->y + priv->height) -
               MAX (rects[i].y, priv->y);
 
-#if 0
-          g_debug ("invalidating part of panel window %s: %i,%i %ix%i",
-                   gtk_widget_get_name (GTK_WIDGET (window)),
-                   rect.x,
-                   rect.y,
-                   rect.width,
-                   rect.height);
-#endif
-
-          gdk_window_invalidate_rect (GTK_WIDGET (window)->window,
-                                      &rect,
-                                      TRUE);
+          hildon_desktop_panel_window_composite_update_background (window,
+                                                                   &rect);
         }
       }
     }
@@ -394,8 +471,8 @@
   priv->width = event->width;
   priv->height = event->height;
 
-  if (priv->background_width != priv->width ||
-      priv->background_height != priv->height)
+  if (priv->pattern_width != priv->width ||
+      priv->pattern_height != priv->height)
   {
     XTransform scale = {{{ XDoubleToFixed ((gdouble)priv->background_width /priv->width), 0, 0},
                    {0, XDoubleToFixed ((gdouble)priv->background_height / priv->height), 0},
@@ -415,14 +492,19 @@
 hildon_desktop_panel_window_composite_expose (GtkWidget *widget,
                                               GdkEventExpose *event)
 {
+
+#if 0
+  g_debug ("Got expose event on %s, area %i,%i %ix%i",
+           gtk_widget_get_name (widget),
+           event->area.x,
+           event->area.y,
+           event->area.width,
+           event->area.height);
+#endif
   if (GTK_WIDGET_DRAWABLE (widget))
   {
-    HildonDesktopPanelWindowCompositeClass     *klass =
-        HILDON_DESKTOP_PANEL_WINDOW_COMPOSITE_GET_CLASS (widget);
     HildonDesktopPanelWindowCompositePrivate   *priv =
         HILDON_DESKTOP_PANEL_WINDOW_COMPOSITE (widget)->priv;
-    DesktopWindowData                          *data =
-        klass->desktop_window_data;
     GdkDrawable *drawable;
     gint x_offset, y_offset;
     Picture picture;
@@ -439,37 +521,12 @@
     g_object_set_data (G_OBJECT (drawable),
                        "picture", GINT_TO_POINTER (picture));
 
-    if (data->home_picture != None)
-      XRenderComposite (GDK_DISPLAY (),
-                        PictOpSrc,
-                        data->home_picture,
-                        None,
-                        picture,
-                        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);
-
     if (priv->background_picture != None)
     {
-      if (priv->scale)
-      {
-        XRenderSetPictureTransform (GDK_DISPLAY (),
-                                    priv->background_picture,
-                                    &priv->transform);
-
-        if (priv->background_mask != None)
-          XRenderSetPictureTransform (GDK_DISPLAY (),
-                                      priv->background_mask,
-                                      &priv->transform);
-      }
-
       XRenderComposite (GDK_DISPLAY (),
-                        PictOpOver,
+                        PictOpSrc,
                         priv->background_picture,
-                        priv->background_mask,
+                        None,
                         picture,
                         event->area.x,
                         event->area.y,
@@ -515,6 +572,7 @@
 hildon_desktop_panel_window_composite_unrealize (GtkWidget *widget)
 {
   HildonDesktopPanelWindowCompositeClass       *klass;
+
   GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
 
   klass = HILDON_DESKTOP_PANEL_WINDOW_COMPOSITE_GET_CLASS (widget);
@@ -529,26 +587,28 @@
 hildon_desktop_panel_window_composite_style_set (GtkWidget   *widget,
                                                  GtkStyle    *old_style)
 {
-  HildonDesktopPanelWindowCompositePrivate     *priv =
-      HILDON_DESKTOP_PANEL_WINDOW_COMPOSITE (widget)->priv;
+  HildonDesktopPanelWindowComposite            *window =
+      HILDON_DESKTOP_PANEL_WINDOW_COMPOSITE (widget);
+  HildonDesktopPanelWindowCompositePrivate     *priv = window->priv;
   const gchar                  *filename;
+  GdkRectangle                  rect = {0};
 
   if (!GTK_WIDGET_REALIZED (widget) ||
       !widget->style || !widget->style->rc_style)
     return;
 
-  if (priv->background_picture != None)
+  if (priv->pattern_picture != None)
     {
       XRenderFreePicture (GDK_DISPLAY (),
-                          priv->background_picture);
-      priv->background_picture = None;
+                          priv->pattern_picture);
+      priv->pattern_picture = None;
     }
 
-  if (priv->background_mask != None)
+  if (priv->pattern_mask != None)
     {
       XRenderFreePicture (GDK_DISPLAY (),
-                          priv->background_mask);
-      priv->background_mask = None;
+                          priv->pattern_mask);
+      priv->pattern_mask = None;
     }
 
   filename = widget->style->rc_style->bg_pixmap_name[GTK_STATE_NORMAL];
@@ -557,16 +617,16 @@
     return;
 
   hildon_desktop_picture_and_mask_from_file (filename,
-                                             &priv->background_picture,
-                                             &priv->background_mask,
-                                             &priv->background_width,
-                                             &priv->background_height);
+                                             &priv->pattern_picture,
+                                             &priv->pattern_mask,
+                                             &priv->pattern_width,
+                                             &priv->pattern_height);
 
-  if (priv->background_width != priv->width ||
-      priv->background_height != priv->height)
+  if (priv->pattern_width != priv->width ||
+      priv->pattern_height != priv->height)
   {
-    XTransform scale = {{{ XDoubleToFixed ((gdouble)priv->background_width /priv->width), 0, 0},
-                   {0, XDoubleToFixed ((gdouble)priv->background_height / priv->height), 0},
+    XTransform scale = {{{ XDoubleToFixed ((gdouble)priv->pattern_width /priv->width), 0, 0},
+                   {0, XDoubleToFixed ((gdouble)priv->pattern_height / priv->height), 0},
                    {0, 0, XDoubleToFixed (1.0)}}};
 
     priv->transform = scale;
@@ -575,6 +635,11 @@
   else
     priv->scale = FALSE;
 
+  rect.width = widget->allocation.width;
+  rect.height = widget->allocation.height;
+  hildon_desktop_panel_window_composite_update_background (window,
+                                                           &rect);
+
   GTK_WIDGET_CLASS (parent_class)->style_set (widget, old_style);
 
 }

Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-picture.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-picture.c	2007-09-06 14:26:15 UTC (rev 13647)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-picture.c	2007-09-06 14:51:39 UTC (rev 13648)
@@ -322,9 +322,9 @@
 }
 
 Picture
-hildon_desktop_picture_from_color (GdkColor    *gcolor,
-                                   guint        width,
-                                   guint        height)
+hildon_desktop_picture_from_color (const GdkColor      *gcolor,
+                                   guint                width,
+                                   guint                height)
 {
   Picture                       picture;
   XRenderPictFormat            *format = NULL;

Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-picture.h
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-picture.h	2007-09-06 14:26:15 UTC (rev 13647)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-picture.h	2007-09-06 14:51:39 UTC (rev 13648)
@@ -42,7 +42,7 @@
 
 Picture hildon_desktop_picture_from_drawable      (GdkDrawable *drawable);
 
-Picture hildon_desktop_picture_from_color         (GdkColor    *color,
+Picture hildon_desktop_picture_from_color         (const GdkColor    *color,
                                                    guint        width,
                                                    guint        height);
 

Modified: projects/haf/trunk/hildon-desktop/src/hd-panel-window-dialog.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-panel-window-dialog.c	2007-09-06 14:26:15 UTC (rev 13647)
+++ projects/haf/trunk/hildon-desktop/src/hd-panel-window-dialog.c	2007-09-06 14:51:39 UTC (rev 13648)
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2006, 2007 Nokia Corporation.
  *
- * Author:  Johan Bilien <johan.bilien at nokia.com>
+ * Author:  Moises Martinez <moises.martinez at nokia.com>
  * Contact: Karoliina Salminen <karoliina.t.salminen at nokia.com>
  *
  * This library is free software; you can redistribute it and/or
@@ -33,6 +33,11 @@
 #include <dbus/dbus-glib-lowlevel.h>
 #include <dbus/dbus-glib-bindings.h>
 
+#ifdef HAVE_X_COMPOSITE
+#include <X11/Xlib.h>
+#include <X11/extensions/Xcomposite.h>
+#endif
+
 #include <libhildondesktop/hildon-desktop-panel-expandable.h>
 #include <libhildonwm/hd-wm.h>
 #include "hd-panel-window-dialog.h"
@@ -108,6 +113,29 @@
 }
 #endif
 
+#ifdef HAVE_X_COMPOSITE
+static void
+hd_panel_window_dialog_realize (GtkWidget *widget)
+{
+  GTK_WIDGET_CLASS (hd_panel_window_dialog_parent_class)->realize (widget);
+
+  XCompositeRedirectWindow (GDK_DISPLAY (),
+                            GDK_WINDOW_XID (widget->window),
+                            CompositeRedirectAutomatic);
+}
+
+static void
+hd_panel_window_dialog_unrealize (GtkWidget *widget)
+{
+  XCompositeUnredirectWindow (GDK_DISPLAY (),
+                              GDK_WINDOW_XID (widget->window),
+                              CompositeRedirectAutomatic);
+
+  GTK_WIDGET_CLASS (hd_panel_window_dialog_parent_class)->unrealize (widget);
+
+}
+#endif
+
 static void 
 hd_panel_window_dialog_notify_condition (GObject *object, 
 		                         gboolean condition, 
@@ -230,6 +258,14 @@
   panel_window_class->orientation_changed = hd_panel_window_dialog_orientation_changed;
 #endif
 
+#ifdef HAVE_X_COMPOSITE
+  {
+    GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (window_class);
+    widget_class->realize   = hd_panel_window_dialog_realize;
+    widget_class->unrealize = hd_panel_window_dialog_unrealize;
+  }
+#endif
+
   g_type_class_add_private (window_class, sizeof (HDPanelWindowDialogPrivate));
 
   hd_wd_signals[HD_WD_UPDATE_SB] =


More information about the maemo-commits mailing list