-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

awesome wrote:
> THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
> 
> The following task has a new comment added:
> 
> FS#518 - awesome doesn't detect xrandr screens as independant desktop
> User who did this - Uli Schlachter (psychon)
> 
> ----------
> I just remembered there was a suggestion to provide an environment variable 
> which can override the settings from Xinerama. I can't find the patch 
> anymore, but I guess one could use that as a work-around for this bug.
> Anyone knows what I'm talking about and remembers where to find that patch?
> ----------

Hi list,

no idea where I got the patch from, but I just found it in my local git repo
with a commit message saying "(Broken) patch by Maxdamantus".

Anyway, attached are two patches that implement this a little cleaner.
Comments? Do we want something like this in awesome? Would it be a
"semi-acceptable" work-around for FS#518?

FYI, Patch 1 doesn't contain any actual changes, it just splits the stuff from
screen_scan() out into multiple functions.

Cheers,
Uli
- --
- - Buck, when, exactly, did you lose your mind?
- - Three months ago. I woke up one morning married to a pineapple.
  An ugly pineapple... But I loved her!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAEBCAAGBQJLud/TAAoJECLkKOvLj8sGMOkH/Rt6IWxgJEhhLgmM3cNH+9E/
Z9jXlo8fQF6YeLEPBcW293ZrKamRQWwGoO1sE5vcCyO+jlTKL0WyB2JkrHR+aOm6
yYXBOFCVFz87TK+qIS7YZyoIkNMeaTNEOn6PH8L1AhAkVpio/Kl9OQchYbsxf5HZ
FIvN8viAuBTxgOQye8dfmUmiux2kBLbllZ06Llz1eaAlK7R45Q5ZZUpDHDHtV6TW
pHlDpwpvCa5TnrpvaxwC21GkwCHefH4kXFKrcFQGtyE0/vDoEChnxv92/DrFmpQe
/T3qcAqRGIvwvhEFqPgp8fjNjuxi1ehDUlhZR8pIHzooHpS0nwd2VPoofZz7A1c=
=HKQL
-----END PGP SIGNATURE-----
>From ad5cfa1f9232f846ab2f91578094b988f2c41662 Mon Sep 17 00:00:00 2001
From: Uli Schlachter <[email protected]>
Date: Mon, 5 Apr 2010 14:43:23 +0200
Subject: [PATCH 1/2] Split-up into multiple functions

Signed-off-by: Uli Schlachter <[email protected]>
---
 screen.c |  126 +++++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 71 insertions(+), 55 deletions(-)

diff --git a/screen.c b/screen.c
index e8a0b56..8292e31 100644
--- a/screen.c
+++ b/screen.c
@@ -61,6 +61,75 @@ screen_default_visual(xcb_screen_t *s)
     return NULL;
 }
 
+/** Get screens information from xinerama and fill global configuration.
+ */
+static void
+screen_scan_xinerama(void)
+{
+    xcb_xinerama_query_screens_reply_t *xsq;
+    xcb_xinerama_screen_info_t *xsi;
+    int xinerama_screen_number;
+
+    xsq = xcb_xinerama_query_screens_reply(globalconf.connection,
+                                           xcb_xinerama_query_screens_unchecked(globalconf.connection),
+                                           NULL);
+
+    xsi = xcb_xinerama_query_screens_screen_info(xsq);
+    xinerama_screen_number = xcb_xinerama_query_screens_screen_info_length(xsq);
+
+    /* now check if screens overlaps (same x,y): if so, we take only the biggest one */
+    for(int screen = 0; screen < xinerama_screen_number; screen++)
+    {
+        bool drop = false;
+        foreach(screen_to_test, globalconf.screens)
+            if(xsi[screen].x_org == screen_to_test->geometry.x
+               && xsi[screen].y_org == screen_to_test->geometry.y)
+                {
+                    /* we already have a screen for this area, just check if
+                     * it's not bigger and drop it */
+                    drop = true;
+                    int i = screen_array_indexof(&globalconf.screens, screen_to_test);
+                    screen_to_test->geometry.width =
+                        MAX(xsi[screen].width, xsi[i].width);
+                    screen_to_test->geometry.height =
+                        MAX(xsi[screen].height, xsi[i].height);
+                }
+        if(!drop)
+        {
+            screen_t s;
+            p_clear(&s, 1);
+            s.geometry = screen_xsitoarea(xsi[screen]);
+            screen_array_append(&globalconf.screens, s);
+        }
+    }
+
+    p_delete(&xsq);
+
+    xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
+    globalconf.screens.tab[0].visual = screen_default_visual(s);
+}
+
+/** Get screens information from zaphod mode and fill global configuration.
+ */
+static void
+screen_scan_zaphod(void)
+{
+    for(int screen = 0;
+        screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
+        screen++)
+    {
+        xcb_screen_t *xcb_screen = xutil_screen_get(globalconf.connection, screen);
+        screen_t s;
+        p_clear(&s, 1);
+        s.geometry.x = 0;
+        s.geometry.y = 0;
+        s.geometry.width = xcb_screen->width_in_pixels;
+        s.geometry.height = xcb_screen->height_in_pixels;
+        s.visual = screen_default_visual(xcb_screen);
+        screen_array_append(&globalconf.screens, s);
+    }
+}
+
 /** Get screens informations and fill global configuration.
  */
 void
@@ -77,64 +146,11 @@ screen_scan(void)
 
     if(globalconf.xinerama_is_active)
     {
-        xcb_xinerama_query_screens_reply_t *xsq;
-        xcb_xinerama_screen_info_t *xsi;
-        int xinerama_screen_number;
-
-        xsq = xcb_xinerama_query_screens_reply(globalconf.connection,
-                                               xcb_xinerama_query_screens_unchecked(globalconf.connection),
-                                               NULL);
-
-        xsi = xcb_xinerama_query_screens_screen_info(xsq);
-        xinerama_screen_number = xcb_xinerama_query_screens_screen_info_length(xsq);
-
-        /* now check if screens overlaps (same x,y): if so, we take only the biggest one */
-        for(int screen = 0; screen < xinerama_screen_number; screen++)
-        {
-            bool drop = false;
-            foreach(screen_to_test, globalconf.screens)
-                if(xsi[screen].x_org == screen_to_test->geometry.x
-                   && xsi[screen].y_org == screen_to_test->geometry.y)
-                    {
-                        /* we already have a screen for this area, just check if
-                         * it's not bigger and drop it */
-                        drop = true;
-                        int i = screen_array_indexof(&globalconf.screens, screen_to_test);
-                        screen_to_test->geometry.width =
-                            MAX(xsi[screen].width, xsi[i].width);
-                        screen_to_test->geometry.height =
-                            MAX(xsi[screen].height, xsi[i].height);
-                    }
-            if(!drop)
-            {
-                screen_t s;
-                p_clear(&s, 1);
-                s.geometry = screen_xsitoarea(xsi[screen]);
-                screen_array_append(&globalconf.screens, s);
-            }
-        }
-
-        p_delete(&xsq);
-
-        xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
-        globalconf.screens.tab[0].visual = screen_default_visual(s);
+        screen_scan_xinerama();
     }
     else
         /* One screen only / Zaphod mode */
-        for(int screen = 0;
-            screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
-            screen++)
-        {
-            xcb_screen_t *xcb_screen = xutil_screen_get(globalconf.connection, screen);
-            screen_t s;
-            p_clear(&s, 1);
-            s.geometry.x = 0;
-            s.geometry.y = 0;
-            s.geometry.width = xcb_screen->width_in_pixels;
-            s.geometry.height = xcb_screen->height_in_pixels;
-            s.visual = screen_default_visual(xcb_screen);
-            screen_array_append(&globalconf.screens, s);
-        }
+        screen_scan_zaphod();
 
     globalconf.screen_focus = globalconf.screens.tab;
 }
-- 
1.7.0

>From 14919847aea52e19fd7781214e94fe8b2ac8b6d4 Mon Sep 17 00:00:00 2001
From: Uli Schlachter <[email protected]>
Date: Mon, 5 Apr 2010 14:58:46 +0200
Subject: [PATCH 2/2] Add parsing of $AWESOME_SPLIT

This environment variable describes the geometry of each screen and will be used
instead of the info from the X server. The format is as follows:

  width "x" height "+" x "+" y

Multiple entries are separated via ":". E.g. if you want to split up a 1500x500
screen into three 500x500 ones, you would use this:

AWESOME_SPLIT="500x500+0+0:500x500+500+0:500x500+1000+0"

Signed-off-by: Uli Schlachter <[email protected]>
---
 screen.c |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/screen.c b/screen.c
index 8292e31..7d7f745 100644
--- a/screen.c
+++ b/screen.c
@@ -20,6 +20,7 @@
  */
 
 #include <stdio.h>
+#include <ctype.h>
 
 #include <xcb/xcb.h>
 #include <xcb/xinerama.h>
@@ -130,11 +131,58 @@ screen_scan_zaphod(void)
     }
 }
 
+static char *
+parse_area(area_t *area, char *str)
+{
+    area->width = strtol(str, &str, 10);
+    if (*str == 'x' || *str == 'X')
+        str++;
+    area->height = strtol(str, &str, 10);
+    if (*str == '+')
+        str++;
+    area->x = strtol(str, &str, 10);
+    if (*str == '+')
+        str++;
+    area->y = strtol(str, &str, 10);
+    return str;
+}
+
+/** Get screens information from the environment
+ */
+static void
+screen_scan_env(char *str)
+{
+    xcb_screen_t *xcb_screen = xutil_screen_get(globalconf.connection, 0);
+
+    while (isdigit(str[0])) {
+        screen_t s;
+
+        /* Make sure everything is initialized */
+        p_clear(&s, 1);
+
+        str = parse_area(&s.geometry, str);
+        s.visual = screen_default_visual(xcb_screen);
+
+        if (str[0] == ':')
+            str++;
+
+        screen_array_append(&globalconf.screens, s);
+    }
+
+    if (*str != '\0')
+        fprintf(stderr, "After parsing $AWESOME_SPLIT, \"%s\" was still over.\n", str);
+
+    /* We'll pretend to the rest of the code that we got this info via xinerama */
+    globalconf.xinerama_is_active = true;
+}
+
 /** Get screens informations and fill global configuration.
  */
 void
 screen_scan(void)
 {
+    char *screencfg = getenv("AWESOME_SPLIT");
+
     /* Check for extension before checking for Xinerama */
     if(xcb_get_extension_data(globalconf.connection, &xcb_xinerama_id)->present)
     {
@@ -144,10 +192,10 @@ screen_scan(void)
         p_delete(&xia);
     }
 
-    if(globalconf.xinerama_is_active)
-    {
+    if(screencfg != NULL && screencfg[0] != '\0')
+        screen_scan_env(screencfg);
+    else if(globalconf.xinerama_is_active)
         screen_scan_xinerama();
-    }
     else
         /* One screen only / Zaphod mode */
         screen_scan_zaphod();
-- 
1.7.0

Attachment: 0001-Split-up-into-multiple-functions.patch.sig
Description: Binary data

Attachment: 0002-Add-parsing-of-AWESOME_SPLIT.patch.sig
Description: Binary data

Reply via email to