[maemo-commits] [maemo-commits] r13028 - in projects/haf/trunk/hildon-desktop: . libhildondesktop
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Aug 6 16:16:10 EEST 2007
- Previous message: [maemo-commits] r13027 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r13029 - in projects/haf/trunk/hildon-desktop: . src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: jobi Date: 2007-08-06 16:16:02 +0300 (Mon, 06 Aug 2007) New Revision: 13028 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-panel-window-composite.h projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-dialog.c projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-dialog.h Log: 2007-08-06 Johan Bilien <johan.bilien at nokia.com> * libhildondesktop/hildon-desktop-panel-window-composite.[ch]: - make the tracking of the home window base-class specific, so it's done once for all instances of the subclasses. * libhildondesktop/hildon-desktop-panel-window-dialog.[ch]: - inherit from HildonDesktopPanelWindowComposite. This enables transparency in the statusbar. Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-08-06 12:50:53 UTC (rev 13027) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-08-06 13:16:02 UTC (rev 13028) @@ -1,3 +1,12 @@ +2007-08-06 Johan Bilien <johan.bilien at nokia.com> + + * libhildondesktop/hildon-desktop-panel-window-composite.[ch]: + - make the tracking of the home window base-class specific, + so it's done once for all instances of the subclasses. + * libhildondesktop/hildon-desktop-panel-window-dialog.[ch]: + - inherit from HildonDesktopPanelWindowComposite. This enables + transparency in the statusbar. + 2007-08-06 Lucas Rocha <lucas.rocha at nokia.com> * src/hd-applications-menu.c: re-estabilished the correct focus/selection 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-08-06 12:50:53 UTC (rev 13027) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-composite.c 2007-08-06 13:16:02 UTC (rev 13028) @@ -48,18 +48,17 @@ static void hildon_desktop_panel_window_composite_realize (GtkWidget *widget); +static void +hildon_desktop_panel_window_composite_unrealize (GtkWidget *widget); + static gboolean hildon_desktop_panel_window_composite_configure (GtkWidget *widget, GdkEventConfigure *event); static void -hildon_desktop_panel_window_composite_desktop_window_changed (HildonDesktopPanelWindowComposite *window); +desktop_window_changed (DesktopWindowData *data); struct _HildonDesktopPanelWindowCompositePrivate { - Picture home_picture; - Damage home_damage; - GdkWindow *home_gwindow; - Picture background_picture; Picture background_mask; gint background_width, background_height; @@ -70,69 +69,159 @@ gboolean scale; }; + +struct _DesktopWindowData +{ + gboolean composite; + Window home_window; + Damage home_damage; + GdkWindow *home_gwindow; + Picture home_picture; + gint ref_count; + guint desktop_window_changed_handler; + GSList *instances; + int xdamage_event_base; + +}; #endif -G_DEFINE_TYPE (HildonDesktopPanelWindowComposite, hildon_desktop_panel_window_composite, HILDON_DESKTOP_TYPE_PANEL_WINDOW) +static void +hildon_desktop_panel_window_composite_class_init (HildonDesktopPanelWindowCompositeClass *klass); static void -hildon_desktop_panel_window_composite_init (HildonDesktopPanelWindowComposite *window) -{ -#ifdef HAVE_X_COMPOSITE - window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, HILDON_DESKTOP_TYPE_PANEL_WINDOW_COMPOSITE, HildonDesktopPanelWindowCompositePrivate); +hildon_desktop_panel_window_composite_base_init (HildonDesktopPanelWindowCompositeClass *klass); - if (HILDON_DESKTOP_PANEL_WINDOW_COMPOSITE_GET_CLASS (window)->composite) - { - HDWM *wm; +static void +hildon_desktop_panel_window_composite_base_finalize (HildonDesktopPanelWindowCompositeClass *klass); - wm = hd_wm_get_singleton (); +static void +hildon_desktop_panel_window_composite_init (HildonDesktopPanelWindowComposite *window); - g_signal_connect_swapped (wm, "notify::desktop-window", - G_CALLBACK (hildon_desktop_panel_window_composite_desktop_window_changed), - window); - } +static HildonDesktopPanelWindowClass *parent_class = NULL; -#endif +GType hildon_desktop_panel_window_composite_get_type(void) +{ + static GType window_type = 0; - + if (!window_type) { + static const GTypeInfo window_info = { + sizeof(HildonDesktopPanelWindowCompositeClass), + (GBaseInitFunc) hildon_desktop_panel_window_composite_base_init, + (GBaseFinalizeFunc) hildon_desktop_panel_window_composite_base_finalize, + (GClassInitFunc) hildon_desktop_panel_window_composite_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(HildonDesktopPanelWindowComposite), + 0, /* n_preallocs */ + (GInstanceInitFunc) hildon_desktop_panel_window_composite_init, + }; + window_type = g_type_register_static(HILDON_DESKTOP_TYPE_PANEL_WINDOW, + "HildonDesktopPanelWindowComposite", + &window_info, 0); + } + return window_type; } static void -hildon_desktop_panel_window_composite_class_init (HildonDesktopPanelWindowCompositeClass *klass) +hildon_desktop_panel_window_composite_base_init (HildonDesktopPanelWindowCompositeClass *klass) { #ifdef HAVE_X_COMPOSITE + static DesktopWindowData *data = NULL; + + if (!data) { - gint damage_error, composite_error; - gint composite_event_base; + gint damage_error, composite_error; + gint composite_event_base; + data = g_new0 (DesktopWindowData, 1); + if (XDamageQueryExtension (GDK_DISPLAY (), - &klass->xdamage_event_base, + &data->xdamage_event_base, &damage_error) && XCompositeQueryExtension (GDK_DISPLAY (), &composite_event_base, &composite_error)) { - GtkWidgetClass *widget_class; + HDWM *wm; - widget_class = GTK_WIDGET_CLASS (klass); + data->composite = TRUE; - klass->composite = TRUE; - gdk_x11_register_standard_event_type (gdk_display_get_default (), - klass->xdamage_event_base + + data->xdamage_event_base + XDamageNotify, 1); + wm = hd_wm_get_singleton (); + + data->desktop_window_changed_handler = + g_signal_connect_swapped (wm, "notify::desktop-window", + G_CALLBACK (desktop_window_changed), + data); + } + } + + klass->desktop_window_data = data; + data->ref_count ++; +#endif +} + +static void +hildon_desktop_panel_window_composite_base_finalize (HildonDesktopPanelWindowCompositeClass *klass) +{ +#ifdef HAVE_X_COMPOSITE + if (klass->desktop_window_data) + { + klass->desktop_window_data->ref_count --; + if (klass->desktop_window_data->ref_count == 0) + { + if (klass->desktop_window_data->composite) + { + HDWM *wm = hd_wm_get_singleton (); + g_signal_handler_disconnect (wm, + klass->desktop_window_data->desktop_window_changed_handler); + } + g_free (klass->desktop_window_data); + } + + klass->desktop_window_data = NULL; + } +#endif + +} + +static void +hildon_desktop_panel_window_composite_init (HildonDesktopPanelWindowComposite *window) +{ +#ifdef HAVE_X_COMPOSITE + window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, HILDON_DESKTOP_TYPE_PANEL_WINDOW_COMPOSITE, HildonDesktopPanelWindowCompositePrivate); + + gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE); +#endif + + +} + +static void +hildon_desktop_panel_window_composite_class_init (HildonDesktopPanelWindowCompositeClass *klass) +{ +#ifdef HAVE_X_COMPOSITE + { + if (klass->desktop_window_data->composite) + { + GtkWidgetClass *widget_class; + + widget_class = GTK_WIDGET_CLASS (klass); + widget_class->style_set = hildon_desktop_panel_window_composite_style_set; widget_class->realize = hildon_desktop_panel_window_composite_realize; + widget_class->unrealize = hildon_desktop_panel_window_composite_unrealize; widget_class->expose_event = hildon_desktop_panel_window_composite_expose; widget_class->configure_event = hildon_desktop_panel_window_composite_configure; } - else - klass->composite = FALSE; g_type_class_add_private (klass, sizeof (HildonDesktopPanelWindowCompositePrivate)); @@ -140,27 +229,20 @@ } #endif + parent_class = g_type_class_peek_parent (klass); + } #ifdef HAVE_X_COMPOSITE static GdkFilterReturn -hildon_desktop_panel_window_composite_home_window_filter - (GdkXEvent *xevent, - GdkEvent *event, - HildonDesktopPanelWindowComposite *window) +home_window_filter (GdkXEvent *xevent, + GdkEvent *event, + DesktopWindowData *data) { XEvent *e = xevent; - HildonDesktopPanelWindowCompositeClass *klass; - HildonDesktopPanelWindowCompositePrivate *priv; - klass = HILDON_DESKTOP_PANEL_WINDOW_COMPOSITE_GET_CLASS (window); - priv = window->priv; - - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (window))) - return GDK_FILTER_CONTINUE; - - if (e->type == klass->xdamage_event_base + XDamageNotify) + if (e->type == data->xdamage_event_base + XDamageNotify) { XserverRegion parts; XDamageNotifyEvent *ev = xevent; @@ -180,21 +262,28 @@ 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) - + GSList *w; + for (w = data->instances; w ; w = w->next) { - GdkRectangle rect; + HildonDesktopPanelWindowComposite *window = w->data; + HildonDesktopPanelWindowCompositePrivate *priv = window->priv; - 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); + 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); + } } } @@ -205,11 +294,10 @@ } static void -hildon_desktop_panel_window_composite_desktop_window_changed (HildonDesktopPanelWindowComposite *window) +desktop_window_changed (DesktopWindowData *data) { - HildonDesktopPanelWindowCompositePrivate *priv = window->priv; - HDWM *wm; - Window desktop_window; + HDWM *wm; + Window desktop_window; wm = hd_wm_get_singleton (); @@ -217,23 +305,28 @@ "desktop-window", &desktop_window, NULL); - if (priv->home_picture != None) + if (desktop_window == data->home_window) + return; + + data->home_window = desktop_window; + + if (data->home_picture != None) { - XRenderFreePicture (GDK_DISPLAY (), priv->home_picture); - priv->home_picture = None; + XRenderFreePicture (GDK_DISPLAY (), data->home_picture); + data->home_picture = None; } - if (priv->home_damage != None) + if (data->home_damage != None) { XDamageDestroy (GDK_DISPLAY (), - priv->home_damage); - priv->home_damage = None; + data->home_damage); + data->home_damage = None; } - if (GDK_IS_WINDOW (priv->home_gwindow)) + if (GDK_IS_WINDOW (data->home_gwindow)) { - g_object_unref (priv->home_gwindow); - priv->home_gwindow = NULL; + g_object_unref (data->home_gwindow); + data->home_gwindow = NULL; } if (desktop_window != None) @@ -244,7 +337,7 @@ desktop_window, CompositeRedirectAutomatic); - priv->home_damage = XDamageCreate (GDK_DISPLAY (), + data->home_damage = XDamageCreate (GDK_DISPLAY (), desktop_window, XDamageReportNonEmpty); @@ -255,17 +348,17 @@ return; } - priv->home_gwindow = gdk_window_foreign_new (desktop_window); + data->home_gwindow = gdk_window_foreign_new (desktop_window); - if (GDK_IS_WINDOW (priv->home_gwindow)) + if (GDK_IS_WINDOW (data->home_gwindow)) { - priv->home_picture = - hildon_desktop_picture_from_drawable (priv->home_gwindow); + data->home_picture = + hildon_desktop_picture_from_drawable (data->home_gwindow); - gdk_window_add_filter (priv->home_gwindow, + gdk_window_add_filter (data->home_gwindow, (GdkFilterFunc) - hildon_desktop_panel_window_composite_home_window_filter, - window); + home_window_filter, + data); } } @@ -307,8 +400,12 @@ { 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; @@ -324,10 +421,10 @@ g_object_set_data (G_OBJECT (drawable), "picture", GINT_TO_POINTER (picture)); - if (priv->home_picture != None) + if (data->home_picture != None) XRenderComposite (GDK_DISPLAY (), PictOpSrc, - priv->home_picture, + data->home_picture, None, picture, priv->x + event->area.x, priv->y + event->area.y, @@ -355,8 +452,10 @@ priv->background_picture, priv->background_mask, picture, - priv->x + event->area.x, priv->y + event->area.y, - priv->x + event->area.x, priv->y + event->area.y, + event->area.x, + event->area.y, + event->area.x, + event->area.y, event->area.x - x_offset, event->area.y - y_offset, event->area.width, @@ -364,8 +463,7 @@ } - result = GTK_WIDGET_CLASS (hildon_desktop_panel_window_composite_parent_class)-> - expose_event (widget, event); + result = GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); XRenderFreePicture (GDK_DISPLAY (), picture); @@ -383,12 +481,32 @@ static void hildon_desktop_panel_window_composite_realize (GtkWidget *widget) { - GTK_WIDGET_CLASS (hildon_desktop_panel_window_composite_parent_class)->realize (widget); + HildonDesktopPanelWindowCompositeClass *klass; + GTK_WIDGET_CLASS (parent_class)->realize (widget); + klass = HILDON_DESKTOP_PANEL_WINDOW_COMPOSITE_GET_CLASS (widget); + + klass->desktop_window_data->instances = + g_slist_append (klass->desktop_window_data->instances, widget); + hildon_desktop_panel_window_composite_style_set (widget, widget->style); } static void +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); + + klass->desktop_window_data->instances = + g_slist_remove (klass->desktop_window_data->instances, widget); + + hildon_desktop_panel_window_composite_style_set (widget, widget->style); +} + +static void hildon_desktop_panel_window_composite_style_set (GtkWidget *widget, GtkStyle *old_style) { Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-composite.h =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-composite.h 2007-08-06 12:50:53 UTC (rev 13027) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-composite.h 2007-08-06 13:16:02 UTC (rev 13028) @@ -28,6 +28,11 @@ #include <libhildondesktop/hildon-desktop-panel-window.h> +#ifdef HAVE_X_COMPOSITE +#include <X11/extensions/Xdamage.h> +#include <X11/extensions/Xrender.h> +#endif + G_BEGIN_DECLS #define HILDON_DESKTOP_TYPE_PANEL_WINDOW_COMPOSITE (hildon_desktop_panel_window_composite_get_type ()) @@ -45,6 +50,9 @@ typedef struct _HildonDesktopPanelWindowComposite HildonDesktopPanelWindowComposite; typedef struct _HildonDesktopPanelWindowCompositeClass HildonDesktopPanelWindowCompositeClass; typedef struct _HildonDesktopPanelWindowCompositePrivate HildonDesktopPanelWindowCompositePrivate; +#ifdef HAVE_X_COMPOSITE +typedef struct _DesktopWindowData DesktopWindowData; +#endif struct _HildonDesktopPanelWindowComposite { HildonDesktopPanelWindow parent; @@ -55,8 +63,9 @@ struct _HildonDesktopPanelWindowCompositeClass { HildonDesktopPanelWindowClass parent_class; - gboolean composite; - gint xdamage_event_base; +#ifdef HAVE_X_COMPOSITE + DesktopWindowData *desktop_window_data; +#endif }; Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-dialog.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-dialog.c 2007-08-06 12:50:53 UTC (rev 13027) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-dialog.c 2007-08-06 13:16:02 UTC (rev 13028) @@ -23,6 +23,10 @@ * */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + #include <gtk/gtk.h> #include <gdk/gdk.h> #include <libhildonwm/hd-wm.h> @@ -35,7 +39,7 @@ #define HILDON_DESKTOP_PANEL_WINDOW_DIALOG_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), HILDON_DESKTOP_TYPE_PANEL_WINDOW_DIALOG, HildonDesktopPanelWindowDialogPrivate)) -G_DEFINE_TYPE (HildonDesktopPanelWindowDialog, hildon_desktop_panel_window_dialog, HILDON_DESKTOP_TYPE_PANEL_WINDOW); +G_DEFINE_TYPE (HildonDesktopPanelWindowDialog, hildon_desktop_panel_window_dialog, HILDON_DESKTOP_TYPE_PANEL_WINDOW_COMPOSITE); enum { Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-dialog.h =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-dialog.h 2007-08-06 12:50:53 UTC (rev 13027) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-panel-window-dialog.h 2007-08-06 13:16:02 UTC (rev 13028) @@ -28,7 +28,7 @@ #include <gtk/gtkwindow.h> -#include <libhildondesktop/hildon-desktop-panel-window.h> +#include <libhildondesktop/hildon-desktop-panel-window-composite.h> G_BEGIN_DECLS @@ -44,14 +44,14 @@ struct _HildonDesktopPanelWindowDialog { - HildonDesktopPanelWindow parent; + HildonDesktopPanelWindowComposite parent; HildonDesktopPanelWindowDialogPrivate *priv; }; struct _HildonDesktopPanelWindowDialogClass { - HildonDesktopPanelWindowClass parent_class; + HildonDesktopPanelWindowCompositeClass parent_class; };
- Previous message: [maemo-commits] r13027 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r13029 - in projects/haf/trunk/hildon-desktop: . src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]