[Xfce4-commits] <xfce4-screenshooter:master> Reenable the old active window workaround.

Jérôme Guelfucci jeromeg at xfce.org
Fri Aug 14 00:26:10 CEST 2009


Updating branch refs/heads/master
         to 98c6971ced389996a99335e1b926b56c1c1e5911 (commit)
       from 38afa7b699e52bfc321f0edc6d5ae5420ca3a8c8 (commit)

commit 98c6971ced389996a99335e1b926b56c1c1e5911
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Mon Aug 3 11:57:13 2009 +0200

    Reenable the old active window workaround.
    
    In some cases, the WM/X server does not update the active window
    quickly enough. When running the application and taking a screenshot
    of the active window this can create a corrupted screenshot. Adding
    a one second delay in that case fixes this issue.

 ChangeLog                   |    9 +++++++++
 lib/screenshooter-actions.c |    6 ++++--
 lib/screenshooter-capture.c |   12 ++++++++++--
 lib/screenshooter-capture.h |    7 ++++---
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a2e66a8..1311bab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,15 @@ Updated Italian and Galician documentation translation.
 
 2009-08-03 jeromeg
 
+Reenable the old active window workaround.
+
+In some cases, the WM/X server does not update the active window
+quickly enough. When running the application and taking a screenshot
+of the active window this can create a corrupted screenshot. Adding
+a one second delay in that case fixes this issue.
+
+2009-08-03 jeromeg
+
 Improve the creation of the save dialog's thumbnail.
 
 The thumbnail's width and height now have a maximum of 150 pixels, if
diff --git a/lib/screenshooter-actions.c b/lib/screenshooter-actions.c
index 744fe4a..d744e22 100644
--- a/lib/screenshooter-actions.c
+++ b/lib/screenshooter-actions.c
@@ -29,8 +29,10 @@ gboolean screenshooter_take_and_output_screenshot (ScreenshotData *sd)
 {
   GdkPixbuf *screenshot;
 
-  screenshot =
-    screenshooter_take_screenshot (sd->region, sd->delay, sd->show_mouse);
+  screenshot = screenshooter_take_screenshot (sd->region,
+                                              sd->delay,
+                                              sd->show_mouse,
+                                              sd->plugin);
 
   g_return_val_if_fail (screenshot != NULL, FALSE);
 
diff --git a/lib/screenshooter-capture.c b/lib/screenshooter-capture.c
index 9f35d04..131c728 100644
--- a/lib/screenshooter-capture.c
+++ b/lib/screenshooter-capture.c
@@ -442,7 +442,7 @@ static GdkPixbuf
  * Return value: a #GdkPixbuf containing the screenshot or %NULL (if @region is SELECT,
  * the user can cancel the operation).
  **/
-GdkPixbuf *screenshooter_take_screenshot (gint region, gint delay, gboolean show_mouse)
+GdkPixbuf *screenshooter_take_screenshot (gint region, gint delay, gboolean show_mouse, gboolean plugin)
 {
   GdkPixbuf *screenshot = NULL;
   GdkWindow *window = NULL;
@@ -462,8 +462,16 @@ GdkPixbuf *screenshooter_take_screenshot (gint region, gint delay, gboolean show
   gdk_display_sync (display);
 
   /* wait for n=delay seconds */
+  /* Workaround: sleep at least one second to make sure the
+   * WM/X server hast time to select the new active window after
+   * the dialog is closed */
   if (region != SELECT)
-    sleep (delay);
+    {
+      if (region == ACTIVE_WINDOW && !plugin)
+        delay ? sleep (delay): sleep (1);
+      else
+        sleep (delay);
+    }
 
   /* Get the window/desktop we want to screenshot*/
   if (region == FULLSCREEN)
diff --git a/lib/screenshooter-capture.h b/lib/screenshooter-capture.h
index 52086e7..c229d62 100644
--- a/lib/screenshooter-capture.h
+++ b/lib/screenshooter-capture.h
@@ -36,8 +36,9 @@
 
 
 GdkPixbuf
-*screenshooter_take_screenshot   (gint                  region,
-                                  gint                  delay,
-                                  gboolean              show_mouse);
+*screenshooter_take_screenshot   (gint     region,
+                                  gint     delay,
+                                  gboolean show_mouse,
+                                  gboolean plugin);
 
 #endif



More information about the Xfce4-commits mailing list