[empathy] Create EMPATHY_RECT_IS_ON_SCREEN macro instead of duplicating its code.



commit 496598a1d17599b809d981c5c3016f90eec15376
Author: Xavier Claessens <xclaesse gmail com>
Date:   Mon Nov 23 16:30:26 2009 +0100

    Create EMPATHY_RECT_IS_ON_SCREEN macro instead of duplicating its code.

 libempathy-gtk/empathy-geometry.c |    5 ++---
 libempathy-gtk/empathy-ui-utils.c |    4 +---
 libempathy-gtk/empathy-ui-utils.h |    5 +++++
 3 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/libempathy-gtk/empathy-geometry.c b/libempathy-gtk/empathy-geometry.c
index b807425..abf50d6 100644
--- a/libempathy-gtk/empathy-geometry.c
+++ b/libempathy-gtk/empathy-geometry.c
@@ -30,6 +30,7 @@
 
 #include "libempathy/empathy-utils.h"
 #include "empathy-geometry.h"
+#include "empathy-ui-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
 #include <libempathy/empathy-debug.h>
@@ -147,9 +148,7 @@ empathy_geometry_save (GtkWindow *window,
   maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0;
 
   /* Don't save off-screen positioning */
-  if (x + w < 0 || y + h < 0 ||
-      x > gdk_screen_width () ||
-      y > gdk_screen_height ())
+  if (!EMPATHY_RECT_IS_ON_SCREEN (x, y, w, h))
     return;
 
   key_file = geometry_get_key_file ();
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index be6aaa2..9ba0173 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -1313,9 +1313,7 @@ empathy_window_present (GtkWindow *window,
 		 * reposition on the current workspace. */
 		gtk_window_get_position (window, &x, &y);
 		gtk_window_get_size (window, &w, &h);
-		if (x + w < 0 || y + h < 0 ||
-		    x > gdk_screen_width () ||
-		    y > gdk_screen_height ())
+		if (!EMPATHY_RECT_IS_ON_SCREEN (x, y, w, h))
 			gtk_widget_hide (GTK_WIDGET (window));
 	}
 
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 486301c..7bec088 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -41,6 +41,11 @@
 
 G_BEGIN_DECLS
 
+#define EMPATHY_RECT_IS_ON_SCREEN(x,y,w,h) ((x) + (w) > 0 && \
+					    (y) + (h) > 0 && \
+					    (x) < gdk_screen_width () && \
+					    (y) < gdk_screen_height ())
+
 void            empathy_gtk_init                        (void);
 GRegex *        empathy_uri_regex_dup_singleton         (void);
 



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