From: Alberto Garcia Date: Tue, 15 Sep 2009 18:12:29 +0000 (+0200) Subject: Use the Xlib API to take window screenshots X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=a6a438fefa4f44520b42921abe02f3c78df1b2e7;p=hildon Use the Xlib API to take window screenshots * hildon/hildon-gtk.c (hildon_gtk_window_take_screenshot): Use the Xlib API to take window screenshots, since the GDK API doesn't allow us to set the event mask. Fixes: NB#138857 (hildon_gtk_window_take_screenshot doesn't take a screenshot) --- diff --git a/ChangeLog b/ChangeLog index 962aa61..7aa1214 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-09-17 Alberto Garcia + + * hildon/hildon-gtk.c (hildon_gtk_window_take_screenshot): + Use the Xlib API to take window screenshots, since the GDK API + doesn't allow us to set the event mask. + + Fixes: NB#138857 (hildon_gtk_window_take_screenshot doesn't take a + screenshot) + 2009-09-14 Claudio Saavedra [2.2.0 Release Candidate 6] diff --git a/hildon/hildon-gtk.c b/hildon/hildon-gtk.c index f6b8ae2..9fda66f 100644 --- a/hildon/hildon-gtk.c +++ b/hildon/hildon-gtk.c @@ -431,25 +431,29 @@ void hildon_gtk_window_take_screenshot (GtkWindow *window, gboolean take) { - GdkEventClient *ev; - GdkWindow *rootwin; + XEvent xev = { 0 }; g_return_if_fail (GTK_IS_WINDOW (window)); g_return_if_fail (GTK_WIDGET_MAPPED (window)); - rootwin = gdk_screen_get_root_window (gtk_window_get_screen (window)); - - ev = (GdkEventClient *) gdk_event_new (GDK_CLIENT_EVENT); - ev->window = g_object_ref (rootwin); - ev->send_event = TRUE; - ev->message_type = gdk_atom_intern ("_HILDON_LOADING_SCREENSHOT", FALSE); - ev->data_format = 32; - ev->data.l[0] = take ? 1 : 0; - ev->data.l[1] = GDK_WINDOW_XID (GTK_WIDGET (window)->window); - - gdk_event_send_client_message ((GdkEvent *) ev, GDK_WINDOW_XWINDOW (rootwin)); - - gdk_event_free ((GdkEvent *) ev); + xev.xclient.type = ClientMessage; + xev.xclient.serial = 0; + xev.xclient.send_event = True; + xev.xclient.display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (window))); + xev.xclient.window = XDefaultRootWindow (xev.xclient.display); + xev.xclient.message_type = XInternAtom (xev.xclient.display, "_HILDON_LOADING_SCREENSHOT", False); + xev.xclient.format = 32; + xev.xclient.data.l[0] = take ? 0 : 1; + xev.xclient.data.l[1] = GDK_WINDOW_XID (GTK_WIDGET (window)->window); + + XSendEvent (xev.xclient.display, + xev.xclient.window, + False, + SubstructureRedirectMask | SubstructureNotifyMask, + &xev); + + XFlush (xev.xclient.display); + XSync (xev.xclient.display, False); }