summaryrefslogtreecommitdiff
path: root/applets/notification_area/na-tray-child.c
diff options
context:
space:
mode:
Diffstat (limited to 'applets/notification_area/na-tray-child.c')
-rw-r--r--applets/notification_area/na-tray-child.c80
1 files changed, 73 insertions, 7 deletions
diff --git a/applets/notification_area/na-tray-child.c b/applets/notification_area/na-tray-child.c
index 5160d699..93ac4bb8 100644
--- a/applets/notification_area/na-tray-child.c
+++ b/applets/notification_area/na-tray-child.c
@@ -54,21 +54,33 @@ na_tray_child_realize (GtkWidget *widget)
* extension. */
/* Set a transparent background */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0);
+ gdk_window_set_background_pattern (window, transparent);
+#else
GdkColor transparent = { 0, 0, 0, 0 }; /* only pixel=0 matters */
gdk_window_set_background (window, &transparent);
+#endif
gdk_window_set_composited (window, TRUE);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_pattern_destroy (transparent);
+#endif
child->parent_relative_bg = FALSE;
- }
- #if GTK_CHECK_VERSION(3, 0, 0)
- else if (visual == gdk_window_get_visual(gdk_window_get_parent(window)))
- #else
- else if (visual == gdk_drawable_get_visual(GDK_DRAWABLE(gdk_window_get_parent(window))))
- #endif
- {
+ }
+#if GTK_CHECK_VERSION(3, 0, 0)
+ else if (visual == gdk_window_get_visual(gdk_window_get_parent(window)))
+#else
+ else if (visual == gdk_drawable_get_visual(GDK_DRAWABLE(gdk_window_get_parent(window))))
+#endif
+ {
/* Otherwise, if the visual matches the visual of the parent window, we
* can use a parent-relative background and fake transparency. */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_window_set_background_pattern (window, NULL);
+#else
gdk_window_set_back_pixmap (window, NULL, TRUE);
+#endif
child->parent_relative_bg = TRUE;
}
@@ -180,8 +192,13 @@ na_tray_child_size_allocate (GtkWidget *widget,
* expose handler draws with real or fake transparency.
*/
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+na_tray_child_draw (GtkWidget *widget,
+ cairo_t *cr)
+#else
na_tray_child_expose_event (GtkWidget *widget,
GdkEventExpose *event)
+#endif
{
NaTrayChild *child = NA_TRAY_CHILD (widget);
GdkWindow *window = gtk_widget_get_window (widget);
@@ -189,19 +206,50 @@ na_tray_child_expose_event (GtkWidget *widget,
if (na_tray_child_has_alpha (child))
{
/* Clear to transparent */
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_t *cr = gdk_cairo_create (window);
+#endif
cairo_set_source_rgba (cr, 0, 0, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_paint (cr);
+#else
gdk_cairo_region (cr, event->region);
cairo_fill (cr);
cairo_destroy (cr);
+#endif
}
else if (child->parent_relative_bg)
{
/* Clear to parent-relative pixmap */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkWindow *window;
+ cairo_surface_t *target;
+ GdkRectangle clip_rect;
+
+ window = gtk_widget_get_window (widget);
+ target = cairo_get_group_target (cr);
+
+ gdk_cairo_get_clip_rectangle (cr, &clip_rect);
+
+ /* Clear to parent-relative pixmap
+ * We need to use direct X access here because GDK doesn't know about
+ * the parent relative pixmap. */
+ cairo_surface_flush (target);
+
+ XClearArea (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
+ clip_rect.x, clip_rect.y,
+ clip_rect.width, clip_rect.height,
+ False);
+ cairo_surface_mark_dirty_rectangle (target,
+ clip_rect.x, clip_rect.y,
+ clip_rect.width, clip_rect.height);
+#else
gdk_window_clear_area (window,
event->area.x, event->area.y,
event->area.width, event->area.height);
+#endif
}
return FALSE;
@@ -225,7 +273,11 @@ na_tray_child_class_init (NaTrayChildClass *klass)
widget_class->style_set = na_tray_child_style_set;
widget_class->realize = na_tray_child_realize;
widget_class->size_allocate = na_tray_child_size_allocate;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->draw = na_tray_child_draw;
+#else
widget_class->expose_event = na_tray_child_expose_event;
+#endif
}
GtkWidget *
@@ -237,8 +289,10 @@ na_tray_child_new (GdkScreen *screen,
NaTrayChild *child;
GdkVisual *visual;
gboolean visual_has_alpha;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkColormap *colormap;
gboolean new_colormap;
+#endif
int red_prec, green_prec, blue_prec, depth;
int result;
@@ -264,6 +318,7 @@ na_tray_child_new (GdkScreen *screen,
if (!visual) /* Icon window is on another screen? */
return NULL;
+#if !GTK_CHECK_VERSION (3, 0, 0)
new_colormap = FALSE;
if (visual == gdk_screen_get_rgb_visual (screen))
@@ -277,11 +332,16 @@ na_tray_child_new (GdkScreen *screen,
colormap = gdk_colormap_new (visual, FALSE);
new_colormap = TRUE;
}
+#endif
child = g_object_new (NA_TYPE_TRAY_CHILD, NULL);
child->icon_window = icon_window;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_set_visual (GTK_WIDGET (child), visual);
+#else
gtk_widget_set_colormap (GTK_WIDGET (child), colormap);
+#endif
/* We have alpha if the visual has something other than red, green,
* and blue */
@@ -296,8 +356,10 @@ na_tray_child_new (GdkScreen *screen,
child->composited = child->has_alpha;
+#if !GTK_CHECK_VERSION (3, 0, 0)
if (new_colormap)
g_object_unref (colormap);
+#endif
return GTK_WIDGET (child);
}
@@ -426,7 +488,11 @@ na_tray_child_force_redraw (NaTrayChild *child)
gtk_widget_get_allocation (widget, &allocation);
xev.xexpose.type = Expose;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ xev.xexpose.window = GDK_WINDOW_XID (plug_window);
+#else
xev.xexpose.window = GDK_WINDOW_XWINDOW (plug_window);
+#endif
xev.xexpose.x = 0;
xev.xexpose.y = 0;
xev.xexpose.width = allocation.width;