All pastes #709112 Raw Edit

Jemand

public text v1 · immutable
#709112 ·published 2007-09-24 12:09 UTC
rendered paste body
diff --git a/plugins/place.c b/plugins/place.c
index fcc5694..1e0e436 100644
--- a/plugins/place.c
+++ b/plugins/place.c
@@ -800,9 +800,18 @@ placeRandom (CompWindow *window,
             int        *x,
             int        *y)
 {
-    *x = workarea->x + rand () % (workarea->width - get_window_width (window));
-    *y = workarea->y + rand () % (workarea->height -
-                                 get_window_height (window));
+    int remainX, remainY;
+
+    *x = workarea->x;
+    *y = workarea->y;
+
+    remainX = workarea->width - get_window_width (window);
+    if (remainX > 0)
+       *x += rand () % remainX;
+
+    remainY = workarea->height - get_window_height (window);
+    if (remainY > 0)
+       *y += rand () % remainY;
 }
 
 static void