Bug 3516 - new Windows do not appear under cursor if active screen is left-of primary display
Status: CLOSED FIXED
Alias: None
Product: Openbox
Classification: Unclassified
Component: general
Version: 3.4.5
Hardware: All Linux
: P1 minor
Assignee: Dana Jansens
QA Contact:
URL:
Depends on:
Blocks:
 
Reported: 2008-01-13 08:31 EST by elven
Modified: 2008-02-01 10:54:10 EST
0 users

See Also:



Description elven 2008-01-13 08:31:53 EST
With UnderMouse-placement active, new windows created will appear on the primary display instead of the current, ONLY if the current is left of the primary display. Screens right of the primary display receive correct window placement.

Example:
 A | B | C

B is the primary display, A left-of, C right-of.

Hovering on C and creating a window will make that window appear on C,
hovering on A will create it on B at the leftmost edge, hoever.

This behaviour was introduced with commit a9f2b2c681cd7028398ef62513dec003376bda6b in version 3.4.3.

This patch fixes it for normal windows, diffed against master HEAD for 3.4.5.

The behaviour is toolkit-independent.

diff --git a/openbox/client.c b/openbox/client.c
index d0fed54..80e7f05 100644
--- a/openbox/client.c
+++ b/openbox/client.c
@@ -1012,15 +1012,10 @@ gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h,
     for (i = 0; i < screen_num_monitors; ++i) {
         Rect *a;

-        if (!screen_physical_area_monitor_contains(i, &desired)) {
-            if (i < screen_num_monitors - 1)
+        if (!screen_physical_area_monitor_contains(i, &desired))
                 continue;

-            /* the window is not inside any monitor! so just use the first
-               one */
-            a = screen_area(self->desktop, 0, NULL);
-        } else
-            a = screen_area(self->desktop, SCREEN_AREA_ONE_MONITOR, &desired);
+               a = screen_area(self->desktop, SCREEN_AREA_ONE_MONITOR, &desired);

         /* This makes sure windows aren't entirely outside of the screen so you
            can't see them at all.
Comment 1 Dana Jansens 2008-01-31 17:12:32 EST
i'm trying, but i can't reproduce this with our xinerama test-code (i.e. pretend the x server reported two monitors, and split the single one into two parts)

with a window focused on either monitor, new windows appear under my mouse cursor.  how are you launching them?  i have tried with a keybinding, and with an openbox menu
Comment 2 Dana Jansens 2008-01-31 17:14:49 EST
i also tried making the "first" display be to the right of the second, but no effect..
Comment 3 Dana Jansens 2008-01-31 17:33:23 EST
ok, i have tracked it down, you can disregard previous questions i think.  and if you'd like to try it out and let me know, that'd be appreciated.  here is the diff (commit 6a3ac55):

diff --git a/openbox/client.c b/openbox/client.c
index 8169048..a0ba343 100644
--- a/openbox/client.c
+++ b/openbox/client.c
@@ -993,6 +993,7 @@ gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h,
     gint fw, fh;
     Rect desired;
     guint i;
+    gboolean found_mon;
 
     RECT_SET(desired, *x, *y, w, h);
     frame_rect_to_frame(self->frame, &desired);
@@ -1042,18 +1043,26 @@ gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h,
             rudeb = TRUE;
     }
 
+    /* we iterate through every monitor that the window is at least partially
+       on, to make sure it is obeying the rules on them all
+
+       if the window does not appear on any monitors, then use the first one
+    */
+    found_mon = FALSE;
     for (i = 0; i < screen_num_monitors; ++i) {
         Rect *a;
 
         if (!screen_physical_area_monitor_contains(i, &desired)) {
-            if (i < screen_num_monitors - 1)
+            if (i < screen_num_monitors - 1 || found_mon)
                 continue;
 
             /* the window is not inside any monitor! so just use the first
                one */
             a = screen_area(self->desktop, 0, NULL);
-        } else
+        } else {
+            found_mon = TRUE;
             a = screen_area(self->desktop, SCREEN_AREA_ONE_MONITOR, &desired);
+        }
 
         /* This makes sure windows aren't entirely outside of the screen so you
            can't see them at all.
Comment 4 Dana Jansens 2008-01-31 17:33:39 EST
marking as fixed
Comment 5 elven 2008-02-01 07:00:48 EST
I confirm, it's fixed. :)

Many thanks.
Comment 6 Dana Jansens 2008-02-01 10:54:10 EST
great, thank you :)