56
55
/* Set a transparent background */
57
GdkColor transparent = { 0, 0, 0, 0 }; /* only pixel=0 matters */
58
gdk_window_set_background (window, &transparent);
56
cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0);
57
gdk_window_set_background_pattern (window, transparent);
59
58
gdk_window_set_composited (window, TRUE);
59
cairo_pattern_destroy (transparent);
61
61
child->parent_relative_bg = FALSE;
63
else if (visual == gdk_drawable_get_visual (GDK_DRAWABLE (gdk_window_get_parent (window))))
63
else if (visual == gdk_window_get_visual (gdk_window_get_parent (window)))
65
65
/* Otherwise, if the visual matches the visual of the parent window, we
66
66
* can use a parent-relative background and fake transparency. */
67
gdk_window_set_back_pixmap (window, NULL, TRUE);
67
gdk_window_set_background_pattern (window, NULL);
69
69
child->parent_relative_bg = TRUE;
174
174
/* The plug window should completely occupy the area of the child, so we won't
175
* get an expose event. But in case we do (the plug unmaps itself, say), this
176
* expose handler draws with real or fake transparency.
175
* get a draw event. But in case we do (the plug unmaps itself, say), this
176
* draw handler draws with real or fake transparency.
179
na_tray_child_expose_event (GtkWidget *widget,
180
GdkEventExpose *event)
179
na_tray_child_draw (GtkWidget *widget,
182
182
NaTrayChild *child = NA_TRAY_CHILD (widget);
183
GdkWindow *window = gtk_widget_get_window (widget);
185
184
if (na_tray_child_has_alpha (child))
187
186
/* Clear to transparent */
188
cairo_t *cr = gdk_cairo_create (window);
189
187
cairo_set_source_rgba (cr, 0, 0, 0, 0);
190
188
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
191
gdk_cairo_region (cr, event->region);
195
191
else if (child->parent_relative_bg)
197
/* Clear to parent-relative pixmap */
198
gdk_window_clear_area (window,
199
event->area.x, event->area.y,
200
event->area.width, event->area.height);
194
cairo_surface_t *target;
195
GdkRectangle clip_rect;
197
window = gtk_widget_get_window (widget);
198
target = cairo_get_group_target (cr);
200
gdk_cairo_get_clip_rectangle (cr, &clip_rect);
202
/* Clear to parent-relative pixmap
203
* We need to use direct X access here because GDK doesn't know about
204
* the parent relative pixmap. */
205
cairo_surface_flush (target);
207
XClearArea (GDK_WINDOW_XDISPLAY (window),
208
GDK_WINDOW_XID (window),
209
clip_rect.x, clip_rect.y,
210
clip_rect.width, clip_rect.height,
212
cairo_surface_mark_dirty_rectangle (target,
213
clip_rect.x, clip_rect.y,
214
clip_rect.width, clip_rect.height);
260
272
if (!visual) /* Icon window is on another screen? */
263
new_colormap = FALSE;
265
if (visual == gdk_screen_get_rgb_visual (screen))
266
colormap = gdk_screen_get_rgb_colormap (screen);
267
else if (visual == gdk_screen_get_rgba_visual (screen))
268
colormap = gdk_screen_get_rgba_colormap (screen);
269
else if (visual == gdk_screen_get_system_visual (screen))
270
colormap = gdk_screen_get_system_colormap (screen);
273
colormap = gdk_colormap_new (visual, FALSE);
277
275
child = g_object_new (NA_TYPE_TRAY_CHILD, NULL);
278
276
child->icon_window = icon_window;
280
gtk_widget_set_colormap (GTK_WIDGET (child), colormap);
278
gtk_widget_set_visual (GTK_WIDGET (child), visual);
282
280
/* We have alpha if the visual has something other than red, green,
430
425
xev.xexpose.count = 0;
432
427
gdk_error_trap_push ();
433
XSendEvent (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget)),
428
XSendEvent (xdisplay,
434
429
xev.xexpose.window,
435
430
False, ExposureMask,
437
/* We have to sync to reliably catch errors from the XSendEvent(),
438
* since that is asynchronous.
440
XSync (xdisplay, False);
441
gdk_error_trap_pop ();
432
gdk_error_trap_pop_ignored ();
443
434
/* Hiding and showing is the safe way to do it, but can result in more