diff options
author | 10:49:20 Tim Janik <timj@imendio.com> | 2008-05-21 19:04:24 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 2008-05-21 19:04:24 +0000 |
commit | 4111cf2065e1f7edc614a936f1fa35e750f13a0f (patch) | |
tree | 02dc780ca4f81be2b58623b6f293e03ee1cc9af8 /gtk/gtkwidget.c | |
parent | e10e51c958b9e981ce458dcfb53c3611246fef15 (diff) | |
download | gtk+-4111cf2065e1f7edc614a936f1fa35e750f13a0f.tar.gz |
Bug 318807 – Offscreen windows and window redirection.
2008-03-18 10:49:20 Tim Janik <timj@imendio.com>
* Applied pixmap redirection patch by Alexander Larsson with
various updates from:
Bug 318807 – Offscreen windows and window redirection.
Updates:
* updated docs to mention "Since 2.16".
* tests/testgtk.c: fixed snapshooting pixmap leak.
convert pixmap to pixbuf after snapshooting, to compensate for different
bit depths (occurs when snapshooting ARGB visuals and displaying the
pixmap in an RGB visual).
* gdk/gdkwindow.[hc]: made GdkWindowRedirect private.
* gdk/gdkwindow.c: removed damage idle handler, there's no aparent
need for it. enqueue damage notification as GDK_DAMAGE events
for each painting redirection at the start of the event queue.
consider windows with a redirection fully visible when invalidating,
and when updating from backing store. cleaned up stale variables.
* gdk/gdkevents.c: added _gdk_event_queue_prepend().
* gtk/gtkwidget.c: fixed coordinates for !NO_WINDOW widgets in
gtk_widget_get_snapshot; this fixes garbage snap offsets for gammacurve,
tree, drawingarea, text, handlebox, etc.
clip the redirected window hierarchy to window sizes, the visible
rectangles don't need to be taken into account here.
extended snapshooting docs to recommend gdk_pixbuf_get_from_drawable()
in case pixmap visuals could mismatch.
* gdk/x11/gdkwindow-x11.c: removed _gdk_windowing_window_get_visible_rect().
Base patch:
* tests/testgtk.c: add a "Snapshot" test to demonstrate snapshooting
of possibly obscured widgets into an offscreen pixmap.
* gtk/gtkwidget.[hc]: add GtkWidget::damage-event signal, add
gtk_widget_get_snapshot() to render a widget's contents to a GdkPixmap.
* gtk/gtkmain.c: dispatch GDK_DAMAGE events.
* gdk/gdkwindow.c: moved outer gdk_window_new() and gdk_window_reparent()
implementations here, adapted them to propagate redirects to child windows.
gdk_window_end_paint(): copy repainted window contents to redirection pixmap,
clipped to visible region. queue GDK_DAMAGE event delivery.
gdk_window_redirect_to_drawable(): install window painting redirection.
gdk_window_remove_redirection(): remove previously installed redirection.
* gdk/x11/gdkwindow-x11.c: added _gdk_windowing_window_get_visible_rect(),
renamed _gdk_window_new() and _gdk_window_reparent().
* gdk/gdkwindow.h: added GdkWindowRedirect* to GdkWindowObject, export
gdk_window_redirect_to_drawable() and gdk_window_remove_redirection().
* gdk/gdkevents.h: added GDK_DAMAGE event type.
* gdk/gdkevents.c: extract time and state from GDK_DAMAGE events.
* gdk/gdkinternals.h: added internal prototypes.
svn path=/trunk/; revision=20122
Diffstat (limited to 'gtk/gtkwidget.c')
-rw-r--r-- | gtk/gtkwidget.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 78e425be71..1f4f9fbd09 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -127,6 +127,7 @@ enum { QUERY_TOOLTIP, KEYNAV_FAILED, DRAG_FAILED, + DAMAGE_EVENT, LAST_SIGNAL }; @@ -1994,6 +1995,28 @@ gtk_widget_class_init (GtkWidgetClass *klass) GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); /** + * GtkWidget::damage-event: + * @widget: the object which received the signal + * @event: the #GdkEventExpose event + * + * Emitted when a redirected window belonging to @widget gets drawn into. + * The region/area members of the event shows what area of the redirected + * drawable was drawn into. + * + * Returns: %TRUE to stop other handlers from being invoked for the event. + * %FALSE to propagate the event further. + * + * Since: 2.16 + */ + widget_signals[DAMAGE_EVENT] = + g_signal_new ("damage_event", + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_LAST, 0, + _gtk_boolean_handled_accumulator, NULL, + _gtk_marshal_BOOLEAN__BOXED, + G_TYPE_BOOLEAN, 1, + GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); +/** * GtkWidget::grab-broken-event: * @widget: the object which received the signal * @event: the #GdkEventGrabBroken event @@ -4667,6 +4690,9 @@ gtk_widget_event_internal (GtkWidget *widget, case GDK_GRAB_BROKEN: signal_num = GRAB_BROKEN; break; + case GDK_DAMAGE: + signal_num = DAMAGE_EVENT; + break; default: g_warning ("gtk_widget_event(): unhandled event type: %d", event->type); signal_num = -1; @@ -8285,6 +8311,53 @@ gtk_widget_unref (GtkWidget *widget) g_object_unref ((GObject*) widget); } +/** + * gtk_widget_get_snapshot: + * @widget: a #GtkWidget + * + * Creates a #GdkPixmap of the contents of the widget and its + * children. Works even if the widget is obscured. + * Note that the depth and visual of the resulting pixmap is dependent + * on the widget being snapshot and likely differs from those of a target + * widget displaying the pixmap. Use gdk_pixbuf_get_from_drawable() + * to convert the pixmap to a visual independant representation. + * + * Return value: #GdkPixmap of the widget + * Since: 2.16 + **/ +GdkPixmap* +gtk_widget_get_snapshot (GtkWidget *widget) +{ + GdkPixmap *pixmap; + int x, y; + + if (!GTK_WIDGET_REALIZED (widget)) + gtk_widget_realize (widget); + + pixmap = gdk_pixmap_new (widget->window, + widget->allocation.width, + widget->allocation.height, + gdk_drawable_get_depth (widget->window)); + if (GTK_WIDGET_NO_WINDOW (widget)) + { + x = widget->allocation.x; + y = widget->allocation.y; + } + else + x = y = 0; + + gdk_window_redirect_to_drawable (widget->window, + pixmap, + x, y, + 0, 0, + widget->allocation.width, + widget->allocation.height); + gtk_widget_queue_draw (widget); + gdk_window_process_updates (widget->window, TRUE); + gdk_window_remove_redirection (widget->window); + + return pixmap; +} /* style properties */ |