[cheese] Use GDK provided work area code, bug 670996



commit 5a5e4cea95e2616760e759f71dd71785d173ebe1
Author: Javier JardÃn <jjardon gnome org>
Date:   Tue Feb 28 19:03:34 2012 +0000

    Use GDK provided work area code, bug 670996

 configure.ac             |    2 +-
 libcheese/cheese-flash.c |  143 ++--------------------------------------------
 2 files changed, 6 insertions(+), 139 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8cbbf3f..39b3c74 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,7 +61,7 @@ GLIB_REQUIRED="glib-2.0 >= 2.28.0"
 GOBJECT_REQUIRED="gobject-2.0 >= 2.28.0"
 GIO_REQUIRED="gio-2.0 >= 2.28.0"
 GTK_REQUIRED="gtk+-3.0 >= 2.99.4"
-GDK_REQUIRED="gdk-3.0 >= 2.99.4"
+GDK_REQUIRED="gdk-3.0 >= 3.3.6"
 GDK_PIXBUF_REQUIRED="gdk-pixbuf-2.0"
 LIBGNOMEDESKTOP_REQUIRED="gnome-desktop-3.0 >= 2.91.6"
 GSTREAMER_VERSION=0.10.32
diff --git a/libcheese/cheese-flash.c b/libcheese/cheese-flash.c
index 48e4110..27b44da 100644
--- a/libcheese/cheese-flash.c
+++ b/libcheese/cheese-flash.c
@@ -24,14 +24,6 @@
 #include "cheese-camera.h"
 #include "cheese-flash.h"
 
-#ifdef GDK_WINDOWING_X11
-#include <X11/Xproto.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>
-#include <gdk/gdkx.h>
-#endif /* GDK_WINDOWING_X11 */
-
 /**
  * SECTION:cheese-flash
  * @short_description: Flash the screen, like a real camera flash
@@ -85,127 +77,6 @@ struct _CheeseFlashPrivate
 };
 
 /*
- * get_current_desktop:
- * @screen: the #GdkScreen containing the parent #GtkWidget
- *
- * Get the current desktop that the parent widget is mostly located on.
- *
- * Returns: the ID of the current desktop
- */
-/* Copy-pasted from totem/src/backend/video-utils.c
- * Waiting on GTK+ bug:
- * https://bugzilla.gnome.org/show_bug.cgi?id=523574 */
-#ifdef GDK_WINDOWING_X11
-static int
-get_current_desktop (GdkScreen *screen)
-{
-        Display *display;
-        Window win;
-        Atom current_desktop, type;
-        int format;
-        unsigned long n_items, bytes_after;
-        unsigned char *data_return = NULL;
-        int workspace = 0;
-
-        display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
-        win = XRootWindow (display, GDK_SCREEN_XNUMBER (screen));
-
-        current_desktop = XInternAtom (display, "_NET_CURRENT_DESKTOP", True);
-
-        XGetWindowProperty (display,
-                            win,
-                            current_desktop,
-                            0, G_MAXLONG,
-                            False, XA_CARDINAL,
-                            &type, &format, &n_items, &bytes_after,
-                            &data_return);
-
-        if (type == XA_CARDINAL && format == 32 && n_items > 0)
-                workspace = (int) data_return[0];
-        if (data_return)
-                XFree (data_return);
-
-        return workspace;
-}
-
-/*
- * get_work_area:
- * @screen: the #GdkScreen of which to get the area
- * @rect: a return location for the area
- *
- * Get the area of the current workspace.
- *
- * Returns %TRUE if the work area was succesfully found, %FALSE otherwise
- */
-static gboolean
-get_work_area (GdkScreen      *screen,
-	       GdkRectangle   *rect)
-{
-	Atom            workarea;
-	Atom            type;
-	Window          win;
-	int             format;
-	gulong          num;
-	gulong          leftovers;
-	gulong          max_len = 4 * 32;
-	guchar         *ret_workarea;
-	long           *workareas;
-	int             result;
-	int             disp_screen;
-	int             desktop;
-	Display        *display;
-
-	display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
-	workarea = XInternAtom (display, "_NET_WORKAREA", True);
-
-	disp_screen = GDK_SCREEN_XNUMBER (screen);
-
-	/* Defaults in case of error */
-	rect->x = 0;
-	rect->y = 0;
-	rect->width = gdk_screen_get_width (screen);
-	rect->height = gdk_screen_get_height (screen);
-
-	if (workarea == None)
-		return FALSE;
-
-	win = XRootWindow (display, disp_screen);
-	result = XGetWindowProperty (display,
-				     win,
-				     workarea,
-				     0,
-				     max_len,
-				     False,
-				     AnyPropertyType,
-				     &type,
-				     &format,
-				     &num,
-				     &leftovers,
-				     &ret_workarea);
-
-	if (result != Success
-	    || type == None
-	    || format == 0
-	    || leftovers
-	    || num % 4) {
-		return FALSE;
-	}
-
-	desktop = get_current_desktop (screen);
-
-	workareas = (long *) ret_workarea;
-	rect->x = workareas[desktop * 4];
-	rect->y = workareas[desktop * 4 + 1];
-	rect->width = workareas[desktop * 4 + 2];
-	rect->height = workareas[desktop * 4 + 3];
-
-	XFree (ret_workarea);
-
-	return TRUE;
-}
-#endif /* GDK_WINDOWING_X11 */
-
-/*
  * cheese_flash_draw_event_cb:
  * @widget: the #CheeseFlash
  * @cr: the Cairo context
@@ -387,7 +258,7 @@ cheese_flash_fire (CheeseFlash *flash)
   CheeseFlashPrivate *flash_priv;
   GtkWidget          *parent;
   GdkScreen          *screen;
-  GdkRectangle        rect;
+  GdkRectangle        rect, work_rect;
   int                 monitor;
   GtkWindow *flash_window;
 
@@ -408,15 +279,11 @@ cheese_flash_fire (CheeseFlash *flash)
   screen  = gtk_widget_get_screen (parent);
   monitor = gdk_screen_get_monitor_at_window (screen,
 					      gtk_widget_get_window (parent));
+
   gdk_screen_get_monitor_geometry (screen, monitor, &rect);
-#ifdef GDK_WINDOWING_X11
-  {
-    GdkRectangle area, dest;
-    get_work_area (screen, &area);
-    if (gdk_rectangle_intersect (&area, &rect, &dest))
-      rect = dest;
-  }
-#endif /* GDK_WINDOWING_X11 */
+  gdk_screen_get_monitor_workarea (screen, monitor, &work_rect);
+  gdk_rectangle_intersect (&work_rect, &rect, &rect);
+
   gtk_window_set_transient_for (GTK_WINDOW (flash_window), GTK_WINDOW (parent));
   gtk_window_resize (flash_window, rect.width, rect.height);
   gtk_window_move (flash_window, rect.x, rect.y);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]