]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Unity/X11: Work area struts are [x1,x2) and [y1,y2).
authorVMware, Inc <>
Mon, 26 Apr 2010 18:16:40 +0000 (11:16 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 27 Apr 2010 03:48:52 +0000 (20:48 -0700)
The region code defines a 25x25 rectangle with its upper left corner
at the origin as (x1,x2,y1,y2) = (0,25,0,25); upper bounds are
exclusive.  However, the strut code works with inclusive coordinates,
so we should instead use (0,24,0,24).  Without doing this, we run
into problems.

Consider a multihead setup of 2 displays at 1600x1200 in a horizontal
configuration.  There should be a single 25px top strut attached to the
left display.  By adding a pixel, we have a strut that ranges from
[0,1600], occupying a single pixel on the right display.  The guest will
now reserve the top 25px on the right display while the host does not.

Should someone maximize a window on that display, the guest places
the window's upper left corner at (0,25) while the host places it at
(0,0), and all hell breaks loose.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/unity/unityPlatformX11.c

index 58cfe843bd673859fdf9de69be2efa3ca32a5e63..1569dbf19af16ddc1c3ecf9787e7c0a55754aa7a 100644 (file)
@@ -2360,21 +2360,30 @@ UnityPlatformSetDesktopWorkAreas(UnityPlatform *up,     // IN
           * XSetProperty(..._NET_WM_STRUTS_PARTIAL).  I.e., look up that
           * property's entry in NetWM/wm-spec for more info on the indices.
           *
-          * I went the switch/case route only because it does a better job (for me)
-          * of organizing & showing -all- possible cases.  YMMV.
+          * I went the switch/case route only because it does a better job
+          * (for me) of organizing & showing -all- possible cases.  YMMV.
+          *
+          * The region code treats rectanges as ranges from [x1,x2) and
+          * [y1,y2).  In other words, x2 and y2 are OUTSIDE the region.  I
+          * guess it makes calculating widths/heights easier.  However, the
+          * strut width/height dimensions are INCLUSIVE, so we'll subtract 1
+          * from the "end" (as opposed to "start") value.
+          *
+          * (Ex:  A 1600x1200 display with a 25px top strut would be marked
+          * as top = 25, top_start_x = 0, top_end_x = 1599.)
           */
          switch (bounds) {
          case TOUCHES_LEFT | TOUCHES_RIGHT | TOUCHES_TOP:
             /* Top strut. */
             strutInfos[numStrutInfos][2] = p->y2 - p->y1;
             strutInfos[numStrutInfos][8] = p->x1;
-            strutInfos[numStrutInfos][9] = p->x2;
+            strutInfos[numStrutInfos][9] = p->x2 - 1;
             break;
          case TOUCHES_LEFT | TOUCHES_RIGHT | TOUCHES_BOTTOM:
             /* Bottom strut. */
             strutInfos[numStrutInfos][3] = p->y2 - p->y1;
             strutInfos[numStrutInfos][10] = p->x1;
-            strutInfos[numStrutInfos][11] = p->x2;
+            strutInfos[numStrutInfos][11] = p->x2 - 1;
             break;
          case TOUCHES_LEFT:
          case TOUCHES_LEFT | TOUCHES_TOP:
@@ -2383,7 +2392,7 @@ UnityPlatformSetDesktopWorkAreas(UnityPlatform *up,     // IN
             /* Left strut. */
             strutInfos[numStrutInfos][0] = p->x2 - p->x1;
             strutInfos[numStrutInfos][4] = p->y1;
-            strutInfos[numStrutInfos][5] = p->y2;
+            strutInfos[numStrutInfos][5] = p->y2 - 1;
             break;
          case TOUCHES_RIGHT:
          case TOUCHES_RIGHT | TOUCHES_TOP:
@@ -2392,7 +2401,7 @@ UnityPlatformSetDesktopWorkAreas(UnityPlatform *up,     // IN
             /* Right strut. */
             strutInfos[numStrutInfos][1] = p->x2 - p->x1;
             strutInfos[numStrutInfos][6] = p->y1;
-            strutInfos[numStrutInfos][7] = p->y2;
+            strutInfos[numStrutInfos][7] = p->y2 - 1;
             break;
          case TOUCHES_LEFT | TOUCHES_RIGHT | TOUCHES_TOP | TOUCHES_BOTTOM:
             Warning("%s: Struts occupy entire display.", __func__);