API: Remove gdk_window_set_composited()

And the related call gdk_display_supports_composite().
This commit is contained in:
Benjamin Otte 2016-10-02 03:02:10 +02:00
parent 8d54c641f1
commit 89f2e17f91
20 changed files with 4 additions and 430 deletions

View File

@ -259,12 +259,6 @@ gdk_broadway_display_supports_input_shapes (GdkDisplay *display)
return FALSE;
}
static gboolean
gdk_broadway_display_supports_composite (GdkDisplay *display)
{
return FALSE;
}
static gulong
gdk_broadway_display_get_next_serial (GdkDisplay *display)
{
@ -341,7 +335,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->store_clipboard = gdk_broadway_display_store_clipboard;
display_class->supports_shapes = gdk_broadway_display_supports_shapes;
display_class->supports_input_shapes = gdk_broadway_display_supports_input_shapes;
display_class->supports_composite = gdk_broadway_display_supports_composite;
display_class->get_cursor_for_type = _gdk_broadway_display_get_cursor_for_type;
display_class->get_cursor_for_name = _gdk_broadway_display_get_cursor_for_name;
display_class->get_cursor_for_surface = _gdk_broadway_display_get_cursor_for_surface;

View File

@ -1523,12 +1523,6 @@ gdk_broadway_window_set_opacity (GdkWindow *window,
opacity = 1;
}
static void
gdk_broadway_window_set_composited (GdkWindow *window,
gboolean composited)
{
}
void
_gdk_broadway_display_before_process_all_updates (GdkDisplay *display)
{
@ -1618,7 +1612,6 @@ gdk_window_impl_broadway_class_init (GdkWindowImplBroadwayClass *klass)
impl_class->begin_resize_drag = gdk_broadway_window_begin_resize_drag;
impl_class->begin_move_drag = gdk_broadway_window_begin_move_drag;
impl_class->set_opacity = gdk_broadway_window_set_opacity;
impl_class->set_composited = gdk_broadway_window_set_composited;
impl_class->destroy_notify = gdk_broadway_window_destroy_notify;
impl_class->register_dnd = _gdk_broadway_window_register_dnd;
impl_class->drag_begin = _gdk_broadway_window_drag_begin;

View File

@ -1862,31 +1862,6 @@ gdk_display_supports_input_shapes (GdkDisplay *display)
return GDK_DISPLAY_GET_CLASS (display)->supports_input_shapes (display);
}
/**
* gdk_display_supports_composite:
* @display: a #GdkDisplay
*
* Returns %TRUE if gdk_window_set_composited() can be used
* to redirect drawing on the window using compositing.
*
* Currently this only works on X11 with XComposite and
* XDamage extensions available.
*
* Returns: %TRUE if windows may be composited.
*
* Since: 2.12
*
* Deprecated: 3.16: Compositing is an outdated technology that
* only ever worked on X11.
*/
gboolean
gdk_display_supports_composite (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
return GDK_DISPLAY_GET_CLASS (display)->supports_composite (display);
}
/**
* gdk_display_list_devices:
* @display: a #GdkDisplay

View File

@ -161,8 +161,6 @@ GDK_AVAILABLE_IN_ALL
gboolean gdk_display_supports_shapes (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
gboolean gdk_display_supports_input_shapes (GdkDisplay *display);
GDK_DEPRECATED_IN_3_16
gboolean gdk_display_supports_composite (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
void gdk_display_notify_startup_complete (GdkDisplay *display,
const gchar *startup_id);

View File

@ -151,7 +151,6 @@ struct _GdkDisplayClass
GdkAtom selection);
gboolean (*supports_shapes) (GdkDisplay *display);
gboolean (*supports_input_shapes) (GdkDisplay *display);
gboolean (*supports_composite) (GdkDisplay *display);
gboolean (*supports_cursor_alpha) (GdkDisplay *display);
gboolean (*supports_cursor_color) (GdkDisplay *display);

View File

@ -328,7 +328,6 @@ struct _GdkWindow
guint input_only : 1;
guint pass_through : 1;
guint modal_hint : 1;
guint composited : 1;
guint has_alpha_background : 1;
guint destroyed : 2;

View File

@ -758,7 +758,6 @@ gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass)
impl_class->enable_synchronized_configure = gdk_offscreen_window_do_nothing;
impl_class->configure_finished = NULL;
impl_class->set_opacity = gdk_offscreen_window_set_opacity;
impl_class->set_composited = NULL;
impl_class->destroy_notify = NULL;
impl_class->register_dnd = gdk_offscreen_window_do_nothing;
impl_class->drag_begin = NULL;

View File

@ -69,15 +69,6 @@
* and so on; a #GtkWindow may contain many #GdkWindows. For example,
* each #GtkButton has a #GdkWindow associated with it.
*
* # Composited Windows # {#COMPOSITED-WINDOWS}
*
* Normally, the windowing system takes care of rendering the contents
* of a child window onto its parent window. This mechanism can be
* intercepted by calling gdk_window_set_composited() on the child
* window. For a composited window it is the
* responsibility of the application to render the window contents at
* the right spot.
*
* # Offscreen Windows # {#OFFSCREEN-WINDOWS}
*
* Offscreen windows are more general than composited windows, since
@ -701,7 +692,7 @@ remove_sibling_overlapped_area (GdkWindow *window,
if (sibling == window)
break;
if (!GDK_WINDOW_IS_MAPPED (sibling) || sibling->input_only || sibling->composited)
if (!GDK_WINDOW_IS_MAPPED (sibling) || sibling->input_only)
continue;
/* Ignore offscreen children, as they don't draw in their parent and
@ -763,7 +754,7 @@ remove_child_area (GdkWindow *window,
if (cairo_region_is_empty (region))
break;
if (!GDK_WINDOW_IS_MAPPED (child) || child->input_only || child->composited)
if (!GDK_WINDOW_IS_MAPPED (child) || child->input_only)
continue;
/* Ignore offscreen children, as they don't draw in their parent and
@ -2975,9 +2966,7 @@ gdk_window_begin_paint_internal (GdkWindow *window,
static void
gdk_window_end_paint_internal (GdkWindow *window)
{
GdkWindow *composited;
GdkWindowImplClass *impl_class;
GdkRectangle clip_box = { 0, };
cairo_t *cr;
if (GDK_WINDOW_DESTROYED (window) ||
@ -2999,8 +2988,6 @@ gdk_window_end_paint_internal (GdkWindow *window)
{
cairo_surface_t *surface;
cairo_region_get_extents (window->current_paint.region, &clip_box);
if (window->current_paint.use_gl)
{
cairo_region_t *opaque_region = cairo_region_copy (window->current_paint.region);
@ -3046,29 +3033,6 @@ gdk_window_end_paint_internal (GdkWindow *window)
}
gdk_window_free_current_paint (window);
/* find a composited window in our hierarchy to signal its
* parent to redraw, calculating the clip box as we go...
*
* stop if parent becomes NULL since then we'd have nowhere
* to draw (ie: 'composited' will always be non-NULL here).
*/
for (composited = window;
composited->parent;
composited = composited->parent)
{
clip_box.x += composited->x;
clip_box.y += composited->y;
clip_box.width = MIN (clip_box.width, composited->parent->width - clip_box.x);
clip_box.height = MIN (clip_box.height, composited->parent->height - clip_box.y);
if (composited->composited)
{
gdk_window_invalidate_rect (GDK_WINDOW (composited->parent),
&clip_box, FALSE);
break;
}
}
}
/**
@ -3844,7 +3808,7 @@ _gdk_window_process_updates_recurse_helper (GdkWindow *window,
{
child = l->data;
if (child->destroyed || !GDK_WINDOW_IS_MAPPED (child) || child->input_only || child->composited)
if (child->destroyed || !GDK_WINDOW_IS_MAPPED (child) || child->input_only)
continue;
/* Ignore offscreen children, as they don't draw in their parent and
@ -7307,102 +7271,6 @@ gdk_window_set_static_gravities (GdkWindow *window,
return FALSE;
}
/**
* gdk_window_get_composited:
* @window: a #GdkWindow
*
* Determines whether @window is composited.
*
* See gdk_window_set_composited().
*
* Returns: %TRUE if the window is composited.
*
* Since: 2.22
*
* Deprecated: 3.16: Compositing is an outdated technology that
* only ever worked on X11.
**/
gboolean
gdk_window_get_composited (GdkWindow *window)
{
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
return window->composited;
}
/**
* gdk_window_set_composited:
* @window: a #GdkWindow
* @composited: %TRUE to set the window as composited
*
* Sets a #GdkWindow as composited, or unsets it. Composited
* windows do not automatically have their contents drawn to
* the screen. Drawing is redirected to an offscreen buffer
* and an expose event is emitted on the parent of the composited
* window. It is the responsibility of the parents expose handler
* to manually merge the off-screen content onto the screen in
* whatever way it sees fit.
*
* It only makes sense for child windows to be composited; see
* gdk_window_set_opacity() if you need translucent toplevel
* windows.
*
* An additional effect of this call is that the area of this
* window is no longer clipped from regions marked for
* invalidation on its parent. Draws done on the parent
* window are also no longer clipped by the child.
*
* This call is only supported on some systems (currently,
* only X11 with new enough Xcomposite and Xdamage extensions).
* You must call gdk_display_supports_composite() to check if
* setting a window as composited is supported before
* attempting to do so.
*
* Since: 2.12
*
* Deprecated: 3.16: Compositing is an outdated technology that
* only ever worked on X11.
*/
void
gdk_window_set_composited (GdkWindow *window,
gboolean composited)
{
GdkDisplay *display;
GdkWindowImplClass *impl_class;
g_return_if_fail (GDK_IS_WINDOW (window));
composited = composited != FALSE;
if (window->composited == composited)
return;
if (composited)
gdk_window_ensure_native (window);
display = gdk_window_get_display (window);
impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (composited && (!gdk_display_supports_composite (display) || !impl_class->set_composited))
{
g_warning ("gdk_window_set_composited called but "
"compositing is not supported");
return;
}
G_GNUC_END_IGNORE_DEPRECATIONS
impl_class->set_composited (window, composited);
recompute_visible_regions (window, FALSE);
if (GDK_WINDOW_IS_MAPPED (window))
gdk_window_invalidate_in_parent (window);
window->composited = composited;
}
/**
* gdk_window_get_modal_hint:
* @window: A toplevel #GdkWindow.
@ -11265,8 +11133,7 @@ gdk_window_configure_finished (GdkWindow *window)
*
* For child windows this function only works for non-native windows.
*
* For setting up per-pixel alpha topelevels, see gdk_screen_get_rgba_visual(),
* and for non-toplevels, see gdk_window_set_composited().
* For setting up per-pixel alpha topelevels, see gdk_screen_get_rgba_visual().
*
* Support for non-toplevel windows was added in 3.8.
*

View File

@ -238,8 +238,6 @@ struct _GdkWindowImplClass
void (* configure_finished) (GdkWindow *window);
void (* set_opacity) (GdkWindow *window,
gdouble opacity);
void (* set_composited) (GdkWindow *window,
gboolean composited);
void (* destroy_notify) (GdkWindow *window);
GdkDragProtocol (* get_drag_protocol) (GdkWindow *window,
GdkWindow **target);

View File

@ -266,13 +266,6 @@ gdk_mir_display_supports_input_shapes (GdkDisplay *display)
return FALSE;
}
static gboolean
gdk_mir_display_supports_composite (GdkDisplay *display)
{
//g_printerr ("gdk_mir_display_supports_composite\n");
return FALSE;
}
static gboolean
gdk_mir_display_supports_clipboard_persistence (GdkDisplay *display)
{
@ -733,7 +726,6 @@ gdk_mir_display_class_init (GdkMirDisplayClass *klass)
display_class->get_default_group = gdk_mir_display_get_default_group;
display_class->supports_shapes = gdk_mir_display_supports_shapes;
display_class->supports_input_shapes = gdk_mir_display_supports_input_shapes;
display_class->supports_composite = gdk_mir_display_supports_composite;
display_class->supports_clipboard_persistence = gdk_mir_display_supports_clipboard_persistence;
display_class->supports_cursor_alpha = gdk_mir_display_supports_cursor_alpha;
display_class->supports_cursor_color = gdk_mir_display_supports_cursor_color;

View File

@ -1395,13 +1395,6 @@ gdk_mir_window_impl_set_opacity (GdkWindow *window,
// FIXME
}
static void
gdk_mir_window_impl_set_composited (GdkWindow *window,
gboolean composited)
{
//g_printerr ("gdk_mir_window_impl_set_composited window=%p\n", window);
}
static void
gdk_mir_window_impl_destroy_notify (GdkWindow *window)
{
@ -1877,7 +1870,6 @@ gdk_mir_window_impl_class_init (GdkMirWindowImplClass *klass)
impl_class->enable_synchronized_configure = gdk_mir_window_impl_enable_synchronized_configure;
impl_class->configure_finished = gdk_mir_window_impl_configure_finished;
impl_class->set_opacity = gdk_mir_window_impl_set_opacity;
impl_class->set_composited = gdk_mir_window_impl_set_composited;
impl_class->destroy_notify = gdk_mir_window_impl_destroy_notify;
impl_class->get_drag_protocol = gdk_mir_window_impl_get_drag_protocol;
impl_class->register_dnd = gdk_mir_window_impl_register_dnd;

View File

@ -175,14 +175,6 @@ gdk_quartz_display_store_clipboard (GdkDisplay *display,
/* FIXME: Implement */
}
static gboolean
gdk_quartz_display_supports_composite (GdkDisplay *display)
{
/* FIXME: Implement */
return FALSE;
}
static gulong
gdk_quartz_display_get_next_serial (GdkDisplay *display)
{
@ -245,7 +237,6 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class)
display_class->store_clipboard = gdk_quartz_display_store_clipboard;
display_class->supports_shapes = gdk_quartz_display_supports_shapes;
display_class->supports_input_shapes = gdk_quartz_display_supports_input_shapes;
display_class->supports_composite = gdk_quartz_display_supports_composite;
display_class->get_cursor_for_type = _gdk_quartz_display_get_cursor_for_type;
display_class->get_cursor_for_name = _gdk_quartz_display_get_cursor_for_name;
display_class->get_cursor_for_surface = _gdk_quartz_display_get_cursor_for_surface;

View File

@ -772,12 +772,6 @@ gdk_wayland_display_supports_input_shapes (GdkDisplay *display)
return TRUE;
}
static gboolean
gdk_wayland_display_supports_composite (GdkDisplay *display)
{
return FALSE;
}
static void
gdk_wayland_display_before_process_all_updates (GdkDisplay *display)
{
@ -923,7 +917,6 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
display_class->store_clipboard = gdk_wayland_display_store_clipboard;
display_class->supports_shapes = gdk_wayland_display_supports_shapes;
display_class->supports_input_shapes = gdk_wayland_display_supports_input_shapes;
display_class->supports_composite = gdk_wayland_display_supports_composite;
display_class->get_app_launch_context = _gdk_wayland_display_get_app_launch_context;
display_class->get_default_cursor_size = _gdk_wayland_display_get_default_cursor_size;
display_class->get_maximal_cursor_size = _gdk_wayland_display_get_maximal_cursor_size;

View File

@ -3445,12 +3445,6 @@ gdk_wayland_window_set_opacity (GdkWindow *window,
{
}
static void
gdk_wayland_window_set_composited (GdkWindow *window,
gboolean composited)
{
}
static void
gdk_wayland_window_destroy_notify (GdkWindow *window)
{
@ -3685,7 +3679,6 @@ _gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass)
impl_class->begin_resize_drag = gdk_wayland_window_begin_resize_drag;
impl_class->begin_move_drag = gdk_wayland_window_begin_move_drag;
impl_class->set_opacity = gdk_wayland_window_set_opacity;
impl_class->set_composited = gdk_wayland_window_set_composited;
impl_class->destroy_notify = gdk_wayland_window_destroy_notify;
impl_class->get_drag_protocol = _gdk_wayland_window_get_drag_protocol;
impl_class->register_dnd = _gdk_wayland_window_register_dnd;

View File

@ -743,12 +743,6 @@ gdk_win32_display_supports_input_shapes (GdkDisplay *display)
return TRUE;
}
static gboolean
gdk_win32_display_supports_composite (GdkDisplay *display)
{
return FALSE;
}
static void
gdk_win32_display_beep (GdkDisplay *display)
{
@ -906,7 +900,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
display_class->store_clipboard = gdk_win32_display_store_clipboard;
display_class->supports_shapes = gdk_win32_display_supports_shapes;
display_class->supports_input_shapes = gdk_win32_display_supports_input_shapes;
display_class->supports_composite = gdk_win32_display_supports_composite;
//? display_class->get_app_launch_context = _gdk_win32_display_get_app_launch_context;
display_class->get_cursor_for_type = _gdk_win32_display_get_cursor_for_type;

View File

@ -5992,7 +5992,6 @@ gdk_window_impl_win32_class_init (GdkWindowImplWin32Class *klass)
impl_class->begin_resize_drag = gdk_win32_window_begin_resize_drag;
impl_class->begin_move_drag = gdk_win32_window_begin_move_drag;
impl_class->set_opacity = gdk_win32_window_set_opacity;
//impl_class->set_composited = gdk_win32_window_set_composited;
impl_class->destroy_notify = gdk_win32_window_destroy_notify;
impl_class->get_drag_protocol = _gdk_win32_window_get_drag_protocol;
impl_class->register_dnd = _gdk_win32_window_register_dnd;

View File

@ -1014,39 +1014,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
}
else
#endif
#if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES)
if (display_x11->have_xdamage && window && window->composited &&
xevent->type == display_x11->xdamage_event_base + XDamageNotify &&
((XDamageNotifyEvent *) xevent)->damage == window_impl->damage)
{
XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) xevent;
XserverRegion repair;
GdkRectangle rect;
int x2, y2;
rect.x = window->x + damage_event->area.x / window_impl->window_scale;
rect.y = window->y + damage_event->area.y / window_impl->window_scale;
x2 = (rect.x * window_impl->window_scale + damage_event->area.width + window_impl->window_scale -1) / window_impl->window_scale;
y2 = (rect.y * window_impl->window_scale + damage_event->area.height + window_impl->window_scale -1) / window_impl->window_scale;
rect.width = x2 - rect.x;
rect.height = y2 - rect.y;
repair = XFixesCreateRegion (display_x11->xdisplay,
&damage_event->area, 1);
XDamageSubtract (display_x11->xdisplay,
window_impl->damage,
repair, None);
XFixesDestroyRegion (display_x11->xdisplay, repair);
if (window->parent != NULL)
_gdk_x11_window_process_expose (window->parent,
damage_event->serial, &rect);
return_val = TRUE;
}
else
#endif
#ifdef HAVE_XKB
if (xevent->type == display_x11->xkb_event_type)
{
@ -2447,16 +2414,6 @@ gdk_x11_display_set_startup_notification_id (GdkDisplay *display,
}
}
static gboolean
gdk_x11_display_supports_composite (GdkDisplay *display)
{
GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
return x11_display->have_xcomposite &&
x11_display->have_xdamage &&
x11_display->have_xfixes;
}
/**
* gdk_x11_register_standard_event_type:
* @display: (type GdkX11Display): a #GdkDisplay
@ -2968,7 +2925,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
display_class->store_clipboard = gdk_x11_display_store_clipboard;
display_class->supports_shapes = gdk_x11_display_supports_shapes;
display_class->supports_input_shapes = gdk_x11_display_supports_input_shapes;
display_class->supports_composite = gdk_x11_display_supports_composite;
display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context;
display_class->get_cursor_for_type = _gdk_x11_display_get_cursor_for_type;
display_class->get_cursor_for_name = _gdk_x11_display_get_cursor_for_name;

View File

@ -5422,36 +5422,6 @@ gdk_x11_window_set_opacity (GdkWindow *window,
(guchar *) &cardinal, 1);
}
static void
gdk_x11_window_set_composited (GdkWindow *window,
gboolean composited)
{
#if defined(HAVE_XCOMPOSITE) && defined(HAVE_XDAMAGE) && defined (HAVE_XFIXES)
GdkWindowImplX11 *impl;
GdkDisplay *display;
Display *dpy;
Window xid;
impl = GDK_WINDOW_IMPL_X11 (window->impl);
display = gdk_window_get_display (window);
dpy = GDK_DISPLAY_XDISPLAY (display);
xid = GDK_WINDOW_XID (window);
if (composited)
{
XCompositeRedirectWindow (dpy, xid, CompositeRedirectManual);
impl->damage = XDamageCreate (dpy, xid, XDamageReportBoundingBox);
}
else
{
XCompositeUnredirectWindow (dpy, xid, CompositeRedirectManual);
XDamageDestroy (dpy, impl->damage);
impl->damage = None;
}
#endif
}
void
_gdk_x11_display_before_process_all_updates (GdkDisplay *display)
{
@ -5763,7 +5733,6 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
impl_class->begin_resize_drag = gdk_x11_window_begin_resize_drag;
impl_class->begin_move_drag = gdk_x11_window_begin_move_drag;
impl_class->set_opacity = gdk_x11_window_set_opacity;
impl_class->set_composited = gdk_x11_window_set_composited;
impl_class->destroy_notify = gdk_x11_window_destroy_notify;
impl_class->get_drag_protocol = gdk_x11_window_get_drag_protocol;
impl_class->register_dnd = _gdk_x11_window_register_dnd;

View File

@ -9975,10 +9975,6 @@ gtk_widget_propagate_screen_changed_recurse (GtkWidget *widget,
* drawn correctly. On X11 this function returns whether a
* compositing manager is running for @widgets screen.
*
* Please note that the semantics of this call will change
* in the future if used on a widget that has a composited
* window in its hierarchy (as set by gdk_window_set_composited()).
*
* Returns: %TRUE if the widget can rely on its alpha
* channel being drawn correctly.
*

View File

@ -314,126 +314,6 @@ create_alpha_window (GtkWidget *widget)
gtk_widget_destroy (window);
}
/*
* Composited non-toplevel window
*/
/* The draw event handler for the event box.
*
* This function simply draws a transparency onto a widget on the area
* for which it receives expose events. This is intended to give the
* event box a "transparent" background.
*
* In order for this to work properly, the widget must have an RGBA
* colourmap. The widget should also be set as app-paintable since it
* doesn't make sense for GTK to draw a background if we are drawing it
* (and because GTK might actually replace our transparency with its
* default background colour).
*/
static gboolean
transparent_draw (GtkWidget *widget,
cairo_t *cr)
{
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_paint (cr);
return FALSE;
}
/* The expose event handler for the window.
*
* This function performs the actual compositing of the event box onto
* the already-existing background of the window at 50% normal opacity.
*
* In this case we do not want app-paintable to be set on the widget
* since we want it to draw its own (red) background. Because of this,
* however, we must ensure that we use g_signal_register_after so that
* this handler is called after the red has been drawn. If it was
* called before then GTK would just blindly paint over our work.
*/
static gboolean
window_draw (GtkWidget *widget,
cairo_t *cr)
{
GtkAllocation allocation;
GtkWidget *child;
/* put a red background on the window */
cairo_set_source_rgb (cr, 1, 0, 0);
cairo_paint (cr);
/* get our child (in this case, the event box) */
child = gtk_bin_get_child (GTK_BIN (widget));
gtk_widget_get_allocation (child, &allocation);
/* the source data is the (composited) event box */
gdk_cairo_set_source_window (cr, gtk_widget_get_window (child),
allocation.x,
allocation.y);
/* composite, with a 50% opacity */
cairo_paint_with_alpha (cr, 0.5);
return FALSE;
}
void
create_composited_window (GtkWidget *widget)
{
static GtkWidget *window;
if (!window)
{
GtkWidget *event, *button;
/* make the widgets */
button = gtk_button_new_with_label ("A Button");
event = gtk_event_box_new ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&window);
/* set our event box to have a fully-transparent background
* drawn on it. currently there is no way to simply tell gtk
* that "transparency" is the background colour for a widget.
*/
gtk_widget_set_app_paintable (GTK_WIDGET (event), TRUE);
g_signal_connect (event, "draw",
G_CALLBACK (transparent_draw), NULL);
/* put them inside one another */
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
gtk_container_add (GTK_CONTAINER (window), event);
gtk_container_add (GTK_CONTAINER (event), button);
/* realise and show everything */
gtk_widget_realize (button);
/* set the event box GdkWindow to be composited.
* obviously must be performed after event box is realised.
*/
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gdk_window_set_composited (gtk_widget_get_window (event),
TRUE);
G_GNUC_END_IGNORE_DEPRECATIONS
/* set up the compositing handler.
* note that we do _after so that the normal (red) background is drawn
* by gtk before our compositing occurs.
*/
g_signal_connect_after (window, "draw",
G_CALLBACK (window_draw), NULL);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show_all (window);
else
gtk_widget_destroy (window);
}
/*
* Big windows and guffaw scrolling
*/
@ -9428,7 +9308,6 @@ struct {
{ "buttons", create_buttons },
{ "check buttons", create_check_buttons },
{ "color selection", create_color_selection },
{ "composited window", create_composited_window },
{ "cursors", create_cursors },
{ "dialog", create_dialog },
{ "display", create_display_screen, TRUE },