check RECT_INTERSECTS_RECT before using RECT_SET_INTERSECTION
authorDana Jansens <danakj@orodu.net>
Sun, 16 Oct 2011 15:13:14 +0000 (11:13 -0400)
committerDana Jansens <danakj@orodu.net>
Sun, 16 Oct 2011 22:58:21 +0000 (18:58 -0400)
openbox/screen.c

index 51f41ab5f266eeb4ae85d242b573688a02e29be7..35366beb9cca0584becddda63d342682889e1e30 100644 (file)
@@ -1680,22 +1680,24 @@ guint screen_find_monitor(const Rect *search)
 
         monitor = screen_physical_area_monitor(config_primary_monitor_index);
 
-        RECT_SET_INTERSECTION(on_current_monitor, *monitor, *search);
-        area = RECT_AREA(on_current_monitor);
+        if (RECT_INTERSECTS_RECT(*monitor, *search)) {
+            RECT_SET_INTERSECTION(on_current_monitor, *monitor, *search);
+            area = RECT_AREA(on_current_monitor);
 
-        if (area > mostpx) {
-            mostpx = area;
-            most = config_primary_monitor_index;
-        }
+            if (area > mostpx) {
+                mostpx = area;
+                most = config_primary_monitor_index;
+            }
 
-        /* add the intersection rect on the current monitor to the
-           counted list. that's easy for the first one, we just mark it for
-           subtraction */
-        {
-            RectArithmetic *ra = g_slice_new(RectArithmetic);
-            ra->r = on_current_monitor;
-            ra->subtract = TRUE;
-            counted = g_slist_prepend(counted, ra);
+            /* add the intersection rect on the current monitor to the
+               counted list. that's easy for the first one, we just mark it for
+               subtraction */
+            {
+                RectArithmetic *ra = g_slice_new(RectArithmetic);
+                ra->r = on_current_monitor;
+                ra->subtract = TRUE;
+                counted = g_slist_prepend(counted, ra);
+            }
         }
     }