[beryl-commits] r1555 - trunk/beryl-core/src

kristian at server.beryl-project.org kristian at server.beryl-project.org
Tue Dec 5 20:39:06 CET 2006


Author: kristian
Date: 2006-12-05 20:38:45 +0100 (Tue, 05 Dec 2006)
New Revision: 1555

Modified:
   trunk/beryl-core/src/screen.c
   trunk/beryl-core/src/window.c
Log:
Improve multihead strut caluclations. Closes #27 and #40



Modified: trunk/beryl-core/src/screen.c
===================================================================
--- trunk/beryl-core/src/screen.c	2006-12-05 19:23:04 UTC (rev 1554)
+++ trunk/beryl-core/src/screen.c	2006-12-05 19:38:45 UTC (rev 1555)
@@ -2763,6 +2763,90 @@
     updatePassiveKeyGrabs (s);
 }
 
+/* Finds the output devs for the x/y/w/h, starting at 'start' outputdev.
+ * This is meant to find all output devs for a given area.
+ * NOTE:  Unlike screenGetOuputDev(), this returns the s->outputDev 
+ * reference without +1. Returns -1 when no more output devs are found.
+ */
+
+static int screenGetOutputDev_multi (CompScreen * s, int start, int x, int y, int w, int h)
+{
+	int i;
+	if(start > s->nOutputDev) 
+		return -1; 
+	
+	if (s->nOutputDev == 1)
+		return 0;
+	h--; w--; // if width == resolution we're NOT in the next head.
+	for (i = start; i < s->nOutputDev; i++)
+	{
+		if (x >= s->outputDev[i].region.extents.x1 &&
+			x < s->outputDev[i].region.extents.x2
+		 	&& y >= s->outputDev[i].region.extents.y1 &&
+			y < s->outputDev[i].region.extents.y2)
+			return i;
+		if (x+w >= s->outputDev[i].region.extents.x1 &&
+			x+w < s->outputDev[i].region.extents.x2
+		 	&& y >= s->outputDev[i].region.extents.y1 &&
+			y < s->outputDev[i].region.extents.y2)
+			return i;
+		if (x >= s->outputDev[i].region.extents.x1 &&
+			x < s->outputDev[i].region.extents.x2
+		 	&& y+h >= s->outputDev[i].region.extents.y1 &&
+			y+h < s->outputDev[i].region.extents.y2)
+			return i;
+		if (x+w >= s->outputDev[i].region.extents.x1 &&
+			x+w < s->outputDev[i].region.extents.x2
+		 	&& y+h >= s->outputDev[i].region.extents.y1 &&
+			y+h < s->outputDev[i].region.extents.y2)
+			return i;
+	}
+	return -1;
+}
+
+
+/* Applies struts to all output devices a given window is in.
+ * (Ie: handles struts for panels stretching multiple heads)
+ * FIXME: Above layout needs work.
+ */
+
+static void updateWorkareaForScreen_outputWindow (CompScreen * s, CompWindow * w) {
+	int outputDev=0;
+	int size;
+	CompOutput *device;
+	while((outputDev = screenGetOutputDev_multi(s, outputDev, 
+		w->serverX, w->serverY, w->width, w->height)) != -1) 
+	{
+                device = &s->outputDev[outputDev];
+                if (w->struts->left.width > device->workRegion.extents.x1) { 
+			device->workRegion.extents.x1 =
+                       	device->region.extents.x1 +
+                       	w->struts->left.width;
+			device->workRegion.extents.x1 += device->region.extents.x1; 
+		} 
+
+                if (w->struts->top.height > device->workRegion.extents.y1) { 
+			device->workRegion.extents.y1 =
+        	        w->struts->top.height;
+		} 
+
+                size = device->region.extents.x2 - device->workRegion.extents.x2;
+                if (w->struts->right.width > size) {
+			device->workRegion.extents.x2 =
+                       	device->region.extents.x2 - w->struts->right.width;
+			device->workRegion.extents.x2 += s->width - device->region.extents.x2; 
+		} 
+
+                size = device->region.extents.y2 - device->workRegion.extents.y2;
+                if (w->struts->bottom.height > size) {
+			device->workRegion.extents.y2 =
+                       	device->region.extents.y2 - w->struts->bottom.height;
+			device->workRegion.extents.y2 += s->height - device->height;
+		}
+		outputDev++;
+	}
+} 
+
 void
 updateWorkareaForScreen (CompScreen * s)
 {
@@ -2821,34 +2905,9 @@
 
             if (w->struts)
             {
-                outputDev = screenGetOutputDevForWindow (w);
+	    	
+		updateWorkareaForScreen_outputWindow (s, w);
 
-                device = &s->outputDev[outputDev - 1];
-
-                // Left strut
-                if (w->struts->left.width > device->workRegion.extents.x1)
-                    device->workRegion.extents.x1 =
-                        device->region.extents.x1 +
-                        w->struts->left.width;
-
-                // Top strut
-                if (w->struts->top.height > device->workRegion.extents.y1)
-                    device->workRegion.extents.y1 =
-                        device->region.extents.y1 +
-                        w->struts->top.height;
-
-                // Right strut
-                size = device->region.extents.x2 - device->workRegion.extents.x2;
-                if (w->struts->right.width > size)
-                    device->workRegion.extents.x2 =
-                        device->region.extents.x2 - w->struts->right.width;
-
-                // Bottom strut
-                size = device->region.extents.y2 - device->workRegion.extents.y2;
-                if (w->struts->bottom.height > size)
-                    device->workRegion.extents.y2 =
-                        device->region.extents.y2 - w->struts->bottom.height;
-
                 if (w->struts->left.width > leftStrut)
                     leftStrut = w->struts->left.width;
 

Modified: trunk/beryl-core/src/window.c
===================================================================
--- trunk/beryl-core/src/window.c	2006-12-05 19:23:04 UTC (rev 1554)
+++ trunk/beryl-core/src/window.c	2006-12-05 19:38:45 UTC (rev 1555)
@@ -1523,8 +1523,6 @@
 
             new.top.height = (int)struts[2] + MIN (0, gap / 2);
             new.bottom.height = (int)struts[3] + MIN (0, gap / 2);
-	    /* Adjust for mixed res multihead */
-	    new.bottom.height -= w->screen->height - w->screen->outputDev[w->screen->currentOutputDev].height;
 
             new.right.x = w->screen->width - new.right.width;
             new.bottom.y = w->screen->height - new.bottom.height;




More information about the commits mailing list