[maemo-commits] [maemo-commits] r11508 - in projects/haf/trunk/hildon-desktop: . libhildonwm src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon May 7 21:32:17 EEST 2007
- Previous message: [maemo-commits] r11507 - in projects/haf/trunk/hildon-desktop: . libhildondesktop src
- Next message: [maemo-commits] r11509 - in projects/haf/trunk/hildon-1: . examples src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: jobi Date: 2007-05-07 21:32:14 +0300 (Mon, 07 May 2007) New Revision: 11508 Modified: projects/haf/trunk/hildon-desktop/ChangeLog projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c projects/haf/trunk/hildon-desktop/src/hd-home-background.c projects/haf/trunk/hildon-desktop/src/hd-home-window.c projects/haf/trunk/hildon-desktop/src/hd-panel-window.c projects/haf/trunk/hildon-desktop/src/hd-panel-window.h projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c projects/haf/trunk/hildon-desktop/src/hn-app-button.c projects/haf/trunk/hildon-desktop/src/hn-app-button.h projects/haf/trunk/hildon-desktop/src/hn-others-button.c Log: 2007-05-07 Johan Bilien <johan.bilien at nokia.com> * libhildonwm/hd-wm.[ch]: - added desktop-window property. It is currently set manually. * src/hd-home-window.c: - added _realize / _unrealize to composite-redirect the window and update the "desktop-window" WM property * src/hd-panel-window.c: - tack the desktop-window property and create a Damage and Picture when the desktop window changes - added _expose which draws the desktop window as background * src/hn-others-button.[ch], src/hn-app-button.[ch]: - use a HildonToggleButton instead of a GtkToggleButton to draw the focus and pressed mark with alpha Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-05-07 16:39:05 UTC (rev 11507) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-05-07 18:32:14 UTC (rev 11508) @@ -1,3 +1,18 @@ +2007-05-07 Johan Bilien <johan.bilien at nokia.com> + + * libhildonwm/hd-wm.[ch]: + - added desktop-window property. It is currently set manually. + * src/hd-home-window.c: + - added _realize / _unrealize to composite-redirect the window + and update the "desktop-window" WM property + * src/hd-panel-window.c: + - tack the desktop-window property and create a Damage and Picture + when the desktop window changes + - added _expose which draws the desktop window as background + * src/hn-others-button.[ch], src/hn-app-button.[ch]: + - use a HildonToggleButton instead of a GtkToggleButton to + draw the focus and pressed mark with alpha + 2007-05-07 Moises Martinez <moises.martinez at nokia.com> * src/hd-switcher-menu-item.[ch]: Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c 2007-05-07 16:39:05 UTC (rev 11507) +++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c 2007-05-07 18:32:14 UTC (rev 11508) @@ -128,7 +128,8 @@ enum { PROP_0, - PROP_INIT_DBUS + PROP_INIT_DBUS, + PROP_DESKTOP_WINDOW }; static gint hdwm_signals[HDWM_SIGNALS]; @@ -219,6 +220,8 @@ GtkWidget *all_menu; + Window desktop_window; + /* stack for the launch banner messages. * Needed to work round gtk(hindon)_infoprint issues. */ @@ -1029,19 +1032,33 @@ "Max width when horizontal", TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property (object_class, + PROP_DESKTOP_WINDOW, + g_param_spec_int("desktop-window", + "desktop window", + "Current desktop window", + 0, + G_MAXINT, + 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); } static void hd_wm_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - HDWM *hdwm = HD_WM (object); - + HDWM *hdwm = HD_WM (object); + switch (prop_id) { case PROP_INIT_DBUS: g_value_set_boolean (value, hdwm->priv->init_dbus); break; - + + case PROP_DESKTOP_WINDOW: + g_value_set_int (value, (int)hdwm->priv->desktop_window); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1059,6 +1076,10 @@ hdwm->priv->init_dbus = g_value_get_boolean (value); break; + case PROP_DESKTOP_WINDOW: + hdwm->priv->desktop_window = (Window)g_value_get_int (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; Modified: projects/haf/trunk/hildon-desktop/src/hd-home-background.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-home-background.c 2007-05-07 16:39:05 UTC (rev 11507) +++ projects/haf/trunk/hildon-desktop/src/hd-home-background.c 2007-05-07 18:32:14 UTC (rev 11508) @@ -101,7 +101,7 @@ static void hd_home_background_init (HDHomeBackground *background) { - background->priv = + background->priv = G_TYPE_INSTANCE_GET_PRIVATE ((background), HD_TYPE_HOME_BACKGROUND, HDHomeBackgroundPrivate); @@ -117,7 +117,7 @@ object_class->finalize = hd_home_background_finalize; object_class->set_property = hd_home_background_set_property; object_class->get_property = hd_home_background_get_property; - + pspec = g_param_spec_string ("filename", "filename", "Image filename", @@ -126,7 +126,7 @@ g_object_class_install_property (object_class, PROP_FILENAME, pspec); - + pspec = g_param_spec_string ("north-border", "North border", "North border image filename", @@ -135,7 +135,7 @@ g_object_class_install_property (object_class, PROP_NORTH_BORDER, pspec); - + pspec = g_param_spec_string ("south-border", "South border", "South border image filename", Modified: projects/haf/trunk/hildon-desktop/src/hd-home-window.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-home-window.c 2007-05-07 16:39:05 UTC (rev 11507) +++ projects/haf/trunk/hildon-desktop/src/hd-home-window.c 2007-05-07 18:32:14 UTC (rev 11508) @@ -30,10 +30,18 @@ #include <hildon/hildon-help.h> #endif +#ifdef HAVE_X_COMPOSITE +#include <X11/extensions/Xrender.h> +#include <X11/extensions/Xcomposite.h> +#endif + #ifdef HAVE_LIBOSSO #include <libosso.h> #endif + +#include <libhildonwm/hd-wm.h> + #include <libhildondesktop/hildon-home-area.h> #include <libhildondesktop/hildon-home-titlebar.h> #include <libhildondesktop/hildon-desktop-home-item.h> @@ -193,6 +201,12 @@ hd_home_window_map_event (GtkWidget *widget, GdkEventAny *event); +static void +hd_home_window_realize (GtkWidget *widget); + +static void +hd_home_window_unrealize (GtkWidget *widget); + static gboolean hd_home_window_key_press_event (GtkWidget *widget, GdkEventKey *event); @@ -236,6 +250,8 @@ widget_class->map_event = hd_home_window_map_event; widget_class->style_set = hd_home_window_style_set; widget_class->key_press_event = hd_home_window_key_press_event; + widget_class->realize = hd_home_window_realize; + widget_class->unrealize = hd_home_window_unrealize; hhwindow_class->layout_mode_accept = hd_home_window_layout_mode_accept; hhwindow_class->layout_mode_cancel = hd_home_window_layout_mode_cancel; @@ -531,9 +547,9 @@ HD_DESKTOP_USER_PATH, HD_HOME_BACKGROUND_CONF_FILE, NULL); - + priv = HD_HOME_WINDOW_GET_PRIVATE (window); - + hd_home_background_save (priv->background, conffile, &save_error); @@ -550,6 +566,44 @@ } +static void +hd_home_window_realize (GtkWidget *widget) +{ + HDWM *wm; + + GTK_WIDGET_CLASS (hd_home_window_parent_class)->realize (widget); + +#ifdef HAVE_X_COMPOSITE + XCompositeRedirectWindow (GDK_DISPLAY (), + GDK_WINDOW_XID (widget->window), + CompositeRedirectAutomatic); +#endif + + wm = hd_wm_get_singleton (); + g_object_set (wm, + "desktop-window", (gint)GDK_WINDOW_XID (widget->window), + NULL); + +} + +static void +hd_home_window_unrealize (GtkWidget *widget) +{ + HDWM *wm; +#ifdef HAVE_X_COMPOSITE + XCompositeUnredirectWindow (GDK_DISPLAY (), + GDK_WINDOW_XID (widget->window), + CompositeRedirectAutomatic); +#endif + + wm = hd_wm_get_singleton (); + g_object_set (wm, + "desktop-window", (gint)None, + NULL); + + GTK_WIDGET_CLASS (hd_home_window_parent_class)->unrealize (widget); +} + static gboolean hd_home_window_map_event (GtkWidget *widget, GdkEventAny *event) Modified: projects/haf/trunk/hildon-desktop/src/hd-panel-window.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-panel-window.c 2007-05-07 16:39:05 UTC (rev 11507) +++ projects/haf/trunk/hildon-desktop/src/hd-panel-window.c 2007-05-07 18:32:14 UTC (rev 11508) @@ -3,7 +3,8 @@ * * Copyright (C) 2006, 2007 Nokia Corporation. * - * Author: Johan Bilien <johan.bilien at nokia.com> + * Author: Lucas Rocha <lucas.rocha at nokia.com> + * Johan Bilien <johan.bilien at nokia.com> * Contact: Karoliina Salminen <karoliina.t.salminen at nokia.com> * * This library is free software; you can redistribute it and/or @@ -32,6 +33,15 @@ #include "hd-panel-window.h" +#ifdef HAVE_X_COMPOSITE +#include <X11/extensions/Xrender.h> +#include <X11/extensions/Xdamage.h> +#include <X11/extensions/Xcomposite.h> +#include <gdk/gdkx.h> + +#include <libhildonwm/hd-wm.h> +#endif + #define HD_PANEL_WINDOW_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), HD_TYPE_PANEL_WINDOW, HDPanelWindowPrivate)) @@ -45,7 +55,200 @@ #define HD_PANEL_WINDOW_BUTTON_NAME_2 "hildon-navigator-button-two" #define HD_PANEL_WINDOW_BUTTON_NAME_MIDDLE "hildon-navigator-button-three" +#ifdef HAVE_X_COMPOSITE + +struct _HDPanelWindowPrivate +{ + Picture home_picture; + Damage home_damage; + GdkWindow *home_gwindow; +}; + +static gboolean +hd_panel_window_expose (GtkWidget *widget, + GdkEventExpose *event) +{ + if (GTK_WIDGET_DRAWABLE (widget)) + { + HDPanelWindowPrivate *priv = HD_PANEL_WINDOW (widget)->priv; + + if (priv->home_picture != None) + { + GdkDrawable *drawable; + gint x_offset, y_offset; + gint x, y; + Picture picture; + GdkVisual *visual; + XRenderPictFormat *format; + XRenderPictureAttributes pa = {0}; + + gtk_window_get_position (GTK_WINDOW (widget), &x, &y); + + g_debug ("got position: %i, %i", x, y); + g_debug ("got expose on the window: %i,%i %ix%i", + event->area.x, + event->area.y, + event->area.width, + event->area.height); + + gdk_window_get_internal_paint_info (widget->window, + &drawable, + &x_offset, + &y_offset); + + visual = gdk_drawable_get_visual (drawable); + + format = XRenderFindVisualFormat (GDK_DISPLAY (), + GDK_VISUAL_XVISUAL (visual)); + + picture = XRenderCreatePicture (GDK_DISPLAY (), + GDK_DRAWABLE_XID (drawable), + format, + 0, + &pa); + + XRenderComposite (GDK_DISPLAY (), + PictOpSrc, + priv->home_picture, + None, + picture, + x + event->area.x, y + event->area.y, + 0, 0, + event->area.x - x_offset, + event->area.y - y_offset, + event->area.width, + event->area.height); + + XRenderFreePicture (GDK_DISPLAY (), + picture); + + return GTK_WIDGET_CLASS (hd_panel_window_parent_class)-> + expose_event (widget, event); + + } + } + + return FALSE; +} + +static GdkFilterReturn +hd_panel_window_home_window_filter (GdkXEvent *xevent, + GdkEvent *event, + HDPanelWindow *window) +{ + XEvent *e = xevent; + HDPanelWindowClass *klass; + + klass = HD_PANEL_WINDOW_GET_CLASS (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; + + 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); + XDamageSubtract (GDK_DISPLAY (), ev->damage, None, parts); + XFixesDestroyRegion (GDK_DISPLAY (), parts); + + gdk_window_invalidate_rect (GTK_WIDGET (window)->window, &rect, FALSE); + } + + return GDK_FILTER_CONTINUE; +} + + + static void +hd_panel_window_desktop_window_changed (HDPanelWindow *window) +{ + HDPanelWindowPrivate *priv = window->priv; + HDWM *wm; + Window desktop_window; + + wm = hd_wm_get_singleton (); + + g_object_get (wm, + "desktop-window", &desktop_window, + NULL); + + if (priv->home_picture != None) + { + XRenderFreePicture (GDK_DISPLAY (), priv->home_picture); + priv->home_picture = None; + } + + if (priv->home_damage != None) + { + XDamageDestroy (GDK_DISPLAY (), + priv->home_damage); + priv->home_damage = None; + } + + if (GDK_IS_WINDOW (priv->home_gwindow)) + { + g_object_unref (priv->home_gwindow); + priv->home_gwindow = NULL; + } + + if (desktop_window != None) + { + XRenderPictureAttributes pa = {0}; + XRenderPictFormat *format; + XWindowAttributes wa = {0}; + Status s; + + gdk_error_trap_push (); + s = XGetWindowAttributes (GDK_DISPLAY (), + desktop_window, + &wa); + + if (gdk_error_trap_pop () || s == 0) + { + g_warning ("Could not retrieve window attributes for the desktop " + "window"); + return; + } + + format = XRenderFindVisualFormat (GDK_DISPLAY (), + wa.visual); + + if (format == None) + return; + + priv->home_picture = XRenderCreatePicture (GDK_DISPLAY (), + desktop_window, + format, + 0, + &pa); + + priv->home_damage = XDamageCreate (GDK_DISPLAY (), + desktop_window, + XDamageReportNonEmpty); + + priv->home_gwindow = gdk_window_foreign_new (desktop_window); + if (GDK_IS_WINDOW (priv->home_gwindow)) + { + gdk_window_add_filter (priv->home_gwindow, + (GdkFilterFunc) + hd_panel_window_home_window_filter, + window); + } + } + + +} +#endif + +static void hd_panel_window_set_style (HDPanelWindow *window, HildonDesktopPanelWindowOrientation orientation) { @@ -127,24 +330,69 @@ NULL); hd_panel_window_set_style (HD_PANEL_WINDOW (object), orientation); + + gtk_widget_set_app_paintable (GTK_WIDGET (object), TRUE); return object; } static void -hd_panel_window_class_init (HDPanelWindowClass *window_class) +hd_panel_window_class_init (HDPanelWindowClass *klass) { GObjectClass *object_class; + GtkWidgetClass *widget_class; HildonDesktopPanelWindowClass *panel_window_class; - object_class = G_OBJECT_CLASS (window_class); - panel_window_class = HILDON_DESKTOP_PANEL_WINDOW_CLASS (window_class); + object_class = G_OBJECT_CLASS (klass); + widget_class = GTK_WIDGET_CLASS (klass); + panel_window_class = HILDON_DESKTOP_PANEL_WINDOW_CLASS (klass); object_class->constructor = hd_panel_window_constructor; panel_window_class->orientation_changed = hd_panel_window_orientation_changed; + +#ifdef HAVE_X_COMPOSITE + { + gint damage_error, composite_error; + gint composite_event_base; + + widget_class->expose_event = hd_panel_window_expose; + + if (XDamageQueryExtension (GDK_DISPLAY (), + &klass->xdamage_event_base, + &damage_error) && + + XCompositeQueryExtension (GDK_DISPLAY (), + &composite_event_base, + &composite_error)) + { + klass->composite = TRUE; + + gdk_x11_register_standard_event_type (gdk_display_get_default (), + klass->xdamage_event_base + + XDamageNotify, + 1); + } + else + klass->composite = FALSE; + + + g_type_class_add_private (klass, sizeof (HDPanelWindowPrivate)); + } +#endif } static void hd_panel_window_init (HDPanelWindow *window) { +#ifdef HAVE_X_COMPOSITE + HDWM *wm; + + wm = hd_wm_get_singleton (); + + g_signal_connect_swapped (wm, "notify::desktop-window", + G_CALLBACK (hd_panel_window_desktop_window_changed), + window); + + window->priv = HD_PANEL_WINDOW_GET_PRIVATE (window); +#endif } Modified: projects/haf/trunk/hildon-desktop/src/hd-panel-window.h =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-panel-window.h 2007-05-07 16:39:05 UTC (rev 11507) +++ projects/haf/trunk/hildon-desktop/src/hd-panel-window.h 2007-05-07 18:32:14 UTC (rev 11508) @@ -44,11 +44,16 @@ struct _HDPanelWindow { HildonDesktopPanelWindow parent; + + HDPanelWindowPrivate *priv; }; struct _HDPanelWindowClass { HildonDesktopPanelWindowClass parent_class; + + gboolean composite; + gint xdamage_event_base; }; GType hd_panel_window_get_type (void); Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c 2007-05-07 16:39:05 UTC (rev 11507) +++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c 2007-05-07 18:32:14 UTC (rev 11508) @@ -52,7 +52,7 @@ #define ANIM_DURATION 5000 /* 5 Secs for blinking icons */ #define ANIM_FPS 2 -#define AS_MENU_BUTTON_NAME "hildon-navigator-small-button5" +#define AS_MENU_BUTTON_NAME "hildon-navigator-small-button4" /* Hardcoded pixel perfecting values */ #define AS_BUTTON_BORDER_WIDTH 0 Modified: projects/haf/trunk/hildon-desktop/src/hn-app-button.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hn-app-button.c 2007-05-07 16:39:05 UTC (rev 11507) +++ projects/haf/trunk/hildon-desktop/src/hn-app-button.c 2007-05-07 18:32:14 UTC (rev 11508) @@ -43,7 +43,6 @@ #include <gtk/gtkcontainer.h> #include <gtk/gtkbutton.h> #include <gtk/gtkcheckbutton.h> -#include <gtk/gtktogglebutton.h> #include <gtk/gtkradiobutton.h> #include <gtk/gtkmenu.h> #include <gtk/gtkmenuitem.h> @@ -141,7 +140,7 @@ }; -G_DEFINE_TYPE (HNAppButton, hn_app_button, GTK_TYPE_TOGGLE_BUTTON); +G_DEFINE_TYPE (HNAppButton, hn_app_button, HILDON_DESKTOP_TYPE_TOGGLE_BUTTON); #if 0 Modified: projects/haf/trunk/hildon-desktop/src/hn-app-button.h =================================================================== --- projects/haf/trunk/hildon-desktop/src/hn-app-button.h 2007-05-07 16:39:05 UTC (rev 11507) +++ projects/haf/trunk/hildon-desktop/src/hn-app-button.h 2007-05-07 18:32:14 UTC (rev 11508) @@ -33,7 +33,7 @@ #define HN_APP_BUTTON_H #include <gdk-pixbuf/gdk-pixbuf.h> -#include <gtk/gtktogglebutton.h> +#include <libhildondesktop/hildon-desktop-toggle-button.h> #include <libhildonwm/hd-wm.h> @@ -55,7 +55,7 @@ struct _HNAppButton { - GtkToggleButton parent_instance; + HildonDesktopToggleButton parent_instance; GSList *group; @@ -64,7 +64,7 @@ struct _HNAppButtonClass { - GtkToggleButtonClass parent_class; + HildonDesktopToggleButtonClass parent_class; GdkPixbuf **groupped_emblems; GdkPixbuf *bkilled_emblem; Modified: projects/haf/trunk/hildon-desktop/src/hn-others-button.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hn-others-button.c 2007-05-07 16:39:05 UTC (rev 11507) +++ projects/haf/trunk/hildon-desktop/src/hn-others-button.c 2007-05-07 18:32:14 UTC (rev 11508) @@ -55,6 +55,7 @@ #include <libhildondesktop/libhildonmenu.h> #include <libhildondesktop/hildon-desktop-panel-window.h> #include <libhildondesktop/hildon-thumb-menu-item.h> +#include <libhildondesktop/hildon-desktop-toggle-button.h> #include <libhildonwm/hd-wm.h> #include "hn-others-button.h" @@ -163,7 +164,7 @@ gtk_widget_set_extension_events (GTK_WIDGET (button), GDK_EXTENSION_EVENTS_ALL); - priv->button = gtk_toggle_button_new (); + priv->button = hildon_desktop_toggle_button_new (); icon = gtk_image_new_from_pixbuf (get_icon (OTHERS_MENU_ICON_NAME, OTHERS_MENU_ICON_SIZE));
- Previous message: [maemo-commits] r11507 - in projects/haf/trunk/hildon-desktop: . libhildondesktop src
- Next message: [maemo-commits] r11509 - in projects/haf/trunk/hildon-1: . examples src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]