Use the Xlib API to take window screenshots
authorAlberto Garcia <agarcia@igalia.com>
Tue, 15 Sep 2009 18:12:29 +0000 (20:12 +0200)
committerAlberto Garcia <agarcia@igalia.com>
Thu, 17 Sep 2009 11:55:46 +0000 (13:55 +0200)
* 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)

ChangeLog
hildon/hildon-gtk.c

index 962aa61..7aa1214 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-09-17  Alberto Garcia  <agarcia@igalia.com>
+
+       * 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  <csaavedra@igalia.com>
 
        [2.2.0 Release Candidate 6]
index f6b8ae2..9fda66f 100644 (file)
@@ -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);
 }