The following shows the diffstat and patchsets between
5c5fbdc..4701eec^
----------------------------------------------------------------
commit 4701eec50d810341f41d1cead6fc30b0188e7c7b
Author: Thomas Adam <[email protected]>
Date:   Sun Dec 21 14:32:31 2014 +0000

    parsing:  Update ABNF to reflect BaseStruts/NumOfDesktops change
    
    Update the grammar of the EWMHBaseStrut/EWMHNumberOfDesktops command to 
reflect
    the change in grammar.
---
 rewrite-notes/parsing | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rewrite-notes/parsing b/rewrite-notes/parsing
index 8555c62..db6a4a7 100644
--- a/rewrite-notes/parsing
+++ b/rewrite-notes/parsing
@@ -900,9 +900,9 @@ EMULATEVAL =/ "Win"
 
 CMD_ESCAPEFUNC = "EscapeFunc"
 
-CMD_EWMHBASESTRUTS = "EwmhBaseStruts" INT INT INT INT
+CMD_EWMHBASESTRUTS = "EwmhBaseStruts" ["screen" XRANDRMONITORNAME] INT INT INT 
INT
 
-CMD_EWMHNUMBEROFDESKTOPS = "EwmhNumberOfDesktops" INT INT
+CMD_EWMHNUMBEROFDESKTOPS = "EwmhNumberOfDesktops" ["screen" XRANDRMONITORNAME] 
INT INT
 
 CMD_EXEC = "Exec" RESTOFLINE_COMMAND
 

commit bd88a7846b31b37205ad0f1b4b142d7b714c0887
Author: Thomas Adam <[email protected]>
Date:   Sun Dec 21 14:29:25 2014 +0000

    EWMHBaseStruts/EWMHNumberOfDesktops: per-monitor
    
    Introduce helper functions, set_ewmhc_strut_values(), and
    ewmhc_desktop_values() which can set the per-monitor base struts.  Switch
    CMD_EwmhBaseStruts() and CMD_EwmhNumberOfDesktops() over to using them,
    respectively.
---
 mvwm/ewmh_conf.c | 131 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 100 insertions(+), 31 deletions(-)

diff --git a/mvwm/ewmh_conf.c b/mvwm/ewmh_conf.c
index e2359e7..dc7d8d1 100644
--- a/mvwm/ewmh_conf.c
+++ b/mvwm/ewmh_conf.c
@@ -39,6 +39,10 @@
 #include "ewmh_intern.h"
 #include "move_resize.h"
 
+/* Forward declarations */
+static void set_ewmhc_strut_values(struct monitor *, int *);
+static void set_ewmhc_desktop_values(struct monitor *, int, int *);
+
 /*
  * CMDS
  */
@@ -97,10 +101,24 @@ Bool EWMH_BugOpts(char *opt, Bool toggle)
 
 void CMD_EwmhNumberOfDesktops(F_CMD_ARGS)
 {
-       struct monitor  *m;
+       struct monitor  *m = NULL;
+       char *option;
        int val[2];
        int num;
 
+       option = PeekToken(action, NULL);
+       if (StrEquals(option, "screen")) {
+               /* Skip literal 'screen' */
+               option = PeekToken(action, &action);
+               /* Actually get the screen value. */
+               option = PeekToken(action, &action);
+
+               if ((m = monitor_by_name(option)) == NULL) {
+                       mvwm_msg(ERR, "CMD_EwmhNumberOfDesktops",
+                               "Invalid screen: %s", option);
+               }
+       }
+
        num = GetIntegerArguments(action, NULL, val, 2);
        if ((num != 1 && num != 2) || val[0] < 1 ||
            (num == 2 && val[1] < val[0] && val[1] != 0))
@@ -110,38 +128,42 @@ void CMD_EwmhNumberOfDesktops(F_CMD_ARGS)
                return;
        }
 
+       /* If m is still NULL, then no monitor was specified, therefore assume
+        * all monitors will be used.
+        */
+       if (m != NULL) {
+               set_ewmhc_desktop_values(m, num, val);
+               return;
+       }
+
        TAILQ_FOREACH(m, &monitor_q, entry) {
                if (monitor_should_ignore_global(m))
                        continue;
-               if (num == 2 && m->ewmhc.MaxDesktops != val[1])
-               {
-                       m->ewmhc.MaxDesktops = val[1];
-                       num = 3;
-               }
-               else if (num == 1 && m->ewmhc.MaxDesktops != 0)
-               {
-                       m->ewmhc.MaxDesktops = 0;
-                       num = 3;
-               }
 
-               if (m->ewmhc.NumberOfDesktops != val[0])
-               {
-                       m->ewmhc.NumberOfDesktops = val[0];
-                       num = 3;
-               }
-
-               if (num == 3)
-               {
-                       m->ewmhc.NeedsToCheckDesk = True;
-                       EWMH_SetNumberOfDesktops(m);
-               }
+               set_ewmhc_desktop_values(m, num, val);
        }
+
 }
 
 void CMD_EwmhBaseStruts(F_CMD_ARGS)
 {
+       struct monitor *m = NULL;
+       char *option;
        int val[4];
 
+       option = PeekToken(action, NULL);
+       if (StrEquals(option, "screen")) {
+               /* Skip literal 'screen' */
+               option = PeekToken(action, &action);
+               /* Actually get the screen value. */
+               option = PeekToken(action, &action);
+
+               if ((m = monitor_by_name(option)) == NULL) {
+                       mvwm_msg(ERR, "CMD_EwmhBaseStruts",
+                               "Invalid screen: %s", option);
+               }
+       }
+
        if (GetIntegerArguments(action, NULL, val, 4) != 4 ||
            val[0] < 0 || val[1] < 0 || val[2] < 0 || val[3] < 0)
        {
@@ -150,19 +172,66 @@ void CMD_EwmhBaseStruts(F_CMD_ARGS)
                return;
        }
 
-       if (ewmhc.BaseStrut.left != val[0] ||
-           ewmhc.BaseStrut.right != val[1] ||
-           ewmhc.BaseStrut.top != val[2] ||
-           ewmhc.BaseStrut.bottom != val[3])
+       /* If m is still NULL, then no monitor was specified, therefore assume
+        * all monitors will be used.
+        */
+       if (m != NULL) {
+               set_ewmhc_strut_values(m, val);
+               return;
+       }
+
+       TAILQ_FOREACH(m, &monitor_q, entry) {
+               if (monitor_should_ignore_global(m))
+                       continue;
+
+               set_ewmhc_strut_values(m, val);
+       }
+}
+
+static void
+set_ewmhc_desktop_values(struct monitor *m, int num, int *val)
+{
+       if (num == 2 && m->ewmhc.MaxDesktops != val[1])
        {
-               ewmhc.BaseStrut.left   = val[0];
-               ewmhc.BaseStrut.right  = val[1];
-               ewmhc.BaseStrut.top    = val[2];
-               ewmhc.BaseStrut.bottom = val[3];
+               m->ewmhc.MaxDesktops = val[1];
+               num = 3;
+       }
+       else if (num == 1 && m->ewmhc.MaxDesktops != 0)
+       {
+               m->ewmhc.MaxDesktops = 0;
+               num = 3;
+       }
 
-               EWMH_UpdateWorkArea();
+       if (m->ewmhc.NumberOfDesktops != val[0])
+       {
+               m->ewmhc.NumberOfDesktops = val[0];
+               num = 3;
+       }
+
+       if (num == 3)
+       {
+               m->ewmhc.NeedsToCheckDesk = True;
+               EWMH_SetNumberOfDesktops(m);
        }
 }
+
+static void
+set_ewmhc_strut_values(struct monitor *m, int *val)
+{
+       if (m->ewmhc.BaseStrut.left != val[0] ||
+           m->ewmhc.BaseStrut.right != val[1] ||
+           m->ewmhc.BaseStrut.top != val[2] ||
+           m->ewmhc.BaseStrut.bottom != val[3])
+       {
+               m->ewmhc.BaseStrut.left   = val[0];
+               m->ewmhc.BaseStrut.right  = val[1];
+               m->ewmhc.BaseStrut.top    = val[2];
+               m->ewmhc.BaseStrut.bottom = val[3];
+
+               EWMH_UpdateWorkArea(m);
+       }
+}
+
 /*
  * Styles
  */

commit 2a10bb4b172d77f9f7651ac58687648f3f4c5e08
Author: Thomas Adam <[email protected]>
Date:   Sun Dec 21 14:21:04 2014 +0000

    ewmhInfo: move into struct monitor, update callers
    
    Remove the extern ewmhc definition, moving it into struct monitor so that 
it can
    be referenced on a per-monitor basis.
    
    In doing this, and because certain callers assumed ewmhc was global, rework 
them
    to get the values out the appropriate monitor.
---
 libs/FScreen.h     |  7 +++++
 mvwm/ewmh.c        | 88 +++++++++++++++++++++++-------------------------------
 mvwm/ewmh.h        |  2 +-
 mvwm/ewmh_conf.c   | 42 +++++++++++++-------------
 mvwm/ewmh_events.c | 43 +++++++++++++-------------
 mvwm/ewmh_intern.h |  3 +-
 mvwm/update.c      |  2 +-
 7 files changed, 92 insertions(+), 95 deletions(-)

diff --git a/libs/FScreen.h b/libs/FScreen.h
index 624d8ab..5129b1a 100644
--- a/libs/FScreen.h
+++ b/libs/FScreen.h
@@ -2,10 +2,14 @@
 #ifndef MVWMLIB_FSCRREN_H
 #define MVWMLIB_FSCRREN_H
 
+/* For CARD32 */
+#include <X11/Xproto.h>
+
 #include "mvwm/mvwm.h"
 #include "mvwm/execcontext.h"
 #include "mvwm/misc.h"
 #include "mvwm/screen.h"
+#include "mvwm/ewmh_intern.h"
 
 typedef union
 {
@@ -41,6 +45,9 @@ struct monitor {
         */
        DesktopsInfo    *Desktops;
 
+       /* Information about EWMH */
+       ewmhInfo ewmhc;
+
        struct {
                int VxMax;
                int VyMax;
diff --git a/mvwm/ewmh.c b/mvwm/ewmh.c
index d9e171b..3fccf1d 100644
--- a/mvwm/ewmh.c
+++ b/mvwm/ewmh.c
@@ -519,34 +519,35 @@ void EWMH_SetNumberOfDesktops(struct monitor *m)
 {
        long val;
 
-       if (ewmhc.CurrentNumberOfDesktops < ewmhc.NumberOfDesktops)
+       if (m->ewmhc.CurrentNumberOfDesktops < m->ewmhc.NumberOfDesktops)
        {
-               ewmhc.CurrentNumberOfDesktops = ewmhc.NumberOfDesktops;
+               m->ewmhc.CurrentNumberOfDesktops = m->ewmhc.NumberOfDesktops;
        }
 
-       if (ewmhc.CurrentNumberOfDesktops > ewmhc.NumberOfDesktops ||
-           ewmhc.NeedsToCheckDesk)
+       if (m->ewmhc.CurrentNumberOfDesktops > m->ewmhc.NumberOfDesktops ||
+           m->ewmhc.NeedsToCheckDesk)
        {
                int d = check_desk();
 
-               ewmhc.NeedsToCheckDesk = False;
-               if (d >= ewmhc.MaxDesktops && ewmhc.MaxDesktops != 0)
+               m->ewmhc.NeedsToCheckDesk = False;
+               if (d >= m->ewmhc.MaxDesktops && m->ewmhc.MaxDesktops != 0)
                        d = 0;
-               ewmhc.CurrentNumberOfDesktops =
-                       max(ewmhc.NumberOfDesktops, d+1);
+               m->ewmhc.CurrentNumberOfDesktops =
+                       max(m->ewmhc.NumberOfDesktops, d+1);
        }
 
-       if (m->virtual_scr.CurrentDesk >= ewmhc.CurrentNumberOfDesktops &&
-           (m->virtual_scr.CurrentDesk < ewmhc.MaxDesktops || 
ewmhc.MaxDesktops == 0))
+       if (m->virtual_scr.CurrentDesk >= m->ewmhc.CurrentNumberOfDesktops &&
+           (m->virtual_scr.CurrentDesk < m->ewmhc.MaxDesktops ||
+           ewmhc.MaxDesktops == 0))
        {
                ewmhc.CurrentNumberOfDesktops = m->virtual_scr.CurrentDesk + 1;
        }
 
-       val = (long)ewmhc.CurrentNumberOfDesktops;
+       val = (long)m->ewmhc.CurrentNumberOfDesktops;
        ewmh_ChangeProperty(Scr.Root, "_NET_NUMBER_OF_DESKTOPS",
                            EWMH_ATOM_LIST_CLIENT_ROOT,
                            (unsigned char *)&val, 1);
-       ewmh_SetWorkArea();
+       ewmh_SetWorkArea(m);
 
        return;
 }
@@ -931,41 +932,35 @@ void EWMH_SetClientListStacking(struct monitor *m)
 /**** Working Area stuff ****/
 /**** At present time we support only sticky windows with strut ****/
 
-void ewmh_SetWorkArea(void)
+void ewmh_SetWorkArea(struct monitor *m)
 {
-       struct monitor  *m;
        long val[256][4]; /* no more than 256 desktops */
        int i = 0;
 
-       TAILQ_FOREACH(m, &monitor_q, entry) {
-               if (monitor_should_ignore_global(m))
-                       continue;
-
-               if (m->Desktops == NULL)
-                       continue;
+       if (m->Desktops == NULL)
+               return;
 
-               while(i < ewmhc.NumberOfDesktops && i < 256)
-               {
-                       val[i][0] = m->Desktops->ewmh_working_area.x;
-                       val[i][1] = m->Desktops->ewmh_working_area.y;
-                       val[i][2] = m->Desktops->ewmh_working_area.width;
-                       val[i][3] = m->Desktops->ewmh_working_area.height;
-                       i++;
-               }
-               ewmh_ChangeProperty(
-                       Scr.Root, "_NET_WORKAREA", EWMH_ATOM_LIST_MVWM_ROOT,
-                       (unsigned char *)&val, i*4);
+       while(i < ewmhc.NumberOfDesktops && i < 256)
+       {
+               val[i][0] = m->Desktops->ewmh_working_area.x;
+               val[i][1] = m->Desktops->ewmh_working_area.y;
+               val[i][2] = m->Desktops->ewmh_working_area.width;
+               val[i][3] = m->Desktops->ewmh_working_area.height;
+               i++;
        }
+       ewmh_ChangeProperty(
+               Scr.Root, "_NET_WORKAREA", EWMH_ATOM_LIST_MVWM_ROOT,
+               (unsigned char *)&val, i*4);
 
        return;
 }
 
 void ewmh_ComputeAndSetWorkArea(struct monitor *m)
 {
-       int left = ewmhc.BaseStrut.left;
-       int right = ewmhc.BaseStrut.right;
-       int top = ewmhc.BaseStrut.top;
-       int bottom = ewmhc.BaseStrut.bottom;
+       int left = m->ewmhc.BaseStrut.left;
+       int right = m->ewmhc.BaseStrut.right;
+       int top = m->ewmhc.BaseStrut.top;
+       int bottom = m->ewmhc.BaseStrut.bottom;
        int x,y,width,height;
        MvwmWindow *fw;
 
@@ -1001,16 +996,16 @@ void ewmh_ComputeAndSetWorkArea(struct monitor *m)
                m->Desktops->ewmh_working_area.y = y;
                m->Desktops->ewmh_working_area.width = width;
                m->Desktops->ewmh_working_area.height = height;
-               ewmh_SetWorkArea();
+               ewmh_SetWorkArea(m);
        }
 }
 
 void ewmh_HandleDynamicWorkArea(struct monitor *m)
 {
-       int dyn_left = ewmhc.BaseStrut.left;
-       int dyn_right = ewmhc.BaseStrut.right;
-       int dyn_top = ewmhc.BaseStrut.top;
-       int dyn_bottom = ewmhc.BaseStrut.bottom;
+       int dyn_left = m->ewmhc.BaseStrut.left;
+       int dyn_right = m->ewmhc.BaseStrut.right;
+       int dyn_top = m->ewmhc.BaseStrut.top;
+       int dyn_bottom = m->ewmhc.BaseStrut.bottom;
        int x,y,width,height;
        MvwmWindow *fw;
 
@@ -1049,17 +1044,10 @@ void ewmh_HandleDynamicWorkArea(struct monitor *m)
        }
 }
 
-void EWMH_UpdateWorkArea(void)
+void EWMH_UpdateWorkArea(struct monitor *m)
 {
-       struct monitor  *m;
-
-       TAILQ_FOREACH(m, &monitor_q, entry) {
-               if (monitor_should_ignore_global(m))
-                       continue;
-
-               ewmh_ComputeAndSetWorkArea(m);
-               ewmh_HandleDynamicWorkArea(m);
-       }
+       ewmh_ComputeAndSetWorkArea(m);
+       ewmh_HandleDynamicWorkArea(m);
 }
 
 void EWMH_GetWorkAreaIntersection(
diff --git a/mvwm/ewmh.h b/mvwm/ewmh.h
index 988d9e6..1c8678c 100644
--- a/mvwm/ewmh.h
+++ b/mvwm/ewmh.h
@@ -36,7 +36,7 @@ int EWMH_IsKdeSysTrayWindow(Window w);
 void EWMH_ManageKdeSysTray(Window w, int type);
 void EWMH_SetClientList(struct monitor *);
 void EWMH_SetClientListStacking(struct monitor *);
-void EWMH_UpdateWorkArea(void);
+void EWMH_UpdateWorkArea(struct monitor *);
 void EWMH_GetWorkAreaIntersection(
        MvwmWindow *fw, int *x, int *y, int *w, int *h, int type);
 float EWMH_GetBaseStrutIntersection(struct monitor *,
diff --git a/mvwm/ewmh_conf.c b/mvwm/ewmh_conf.c
index 170fd90..e2359e7 100644
--- a/mvwm/ewmh_conf.c
+++ b/mvwm/ewmh_conf.c
@@ -110,29 +110,29 @@ void CMD_EwmhNumberOfDesktops(F_CMD_ARGS)
                return;
        }
 
-       if (num == 2 && ewmhc.MaxDesktops != val[1])
-       {
-               ewmhc.MaxDesktops = val[1];
-               num = 3;
-       }
-       else if (num == 1 && ewmhc.MaxDesktops != 0)
-       {
-               ewmhc.MaxDesktops = 0;
-               num = 3;
-       }
+       TAILQ_FOREACH(m, &monitor_q, entry) {
+               if (monitor_should_ignore_global(m))
+                       continue;
+               if (num == 2 && m->ewmhc.MaxDesktops != val[1])
+               {
+                       m->ewmhc.MaxDesktops = val[1];
+                       num = 3;
+               }
+               else if (num == 1 && m->ewmhc.MaxDesktops != 0)
+               {
+                       m->ewmhc.MaxDesktops = 0;
+                       num = 3;
+               }
 
-       if (ewmhc.NumberOfDesktops != val[0])
-       {
-               ewmhc.NumberOfDesktops = val[0];
-               num = 3;
-       }
+               if (m->ewmhc.NumberOfDesktops != val[0])
+               {
+                       m->ewmhc.NumberOfDesktops = val[0];
+                       num = 3;
+               }
 
-       if (num == 3)
-       {
-               ewmhc.NeedsToCheckDesk = True;
-               TAILQ_FOREACH(m, &monitor_q, entry) {
-                       if (monitor_should_ignore_global(m))
-                               continue;
+               if (num == 3)
+               {
+                       m->ewmhc.NeedsToCheckDesk = True;
                        EWMH_SetNumberOfDesktops(m);
                }
        }
diff --git a/mvwm/ewmh_events.c b/mvwm/ewmh_events.c
index f5f6906..000ca8f 100644
--- a/mvwm/ewmh_events.c
+++ b/mvwm/ewmh_events.c
@@ -135,27 +135,30 @@ int ewmh_NumberOfDesktops(EWMH_CMD_ARGS)
        struct monitor  *m;
 
        /* not a lot of sinification for mvwm */
-       if (d > 0 && (d <= ewmhc.MaxDesktops || ewmhc.MaxDesktops == 0))
-       {
-               ewmhc.NumberOfDesktops = d;
-               TAILQ_FOREACH(m, &monitor_q, entry) {
-                       if (monitor_should_ignore_global(m))
-                               continue;
-                       EWMH_SetNumberOfDesktops(m);
+       TAILQ_FOREACH(m, &monitor_q, entry) {
+               if (monitor_should_ignore_global(m))
+                       continue;
+
+               EWMH_SetNumberOfDesktops(m);
+
+               if (d > 0 &&
+                   (d <= m->ewmhc.MaxDesktops || m->ewmhc.MaxDesktops == 0))
+               {
+                       m->ewmhc.NumberOfDesktops = d;
+               }
+               else
+               {
+                       mvwm_msg(
+                               WARN, "ewmh_NumberOfDesktops",
+                               "The application window (id %#lx)\n"
+                               "  \"%s\" tried to set an invalid number of 
desktops"
+                               " (%ld)\n"
+                               "  using an EWMH client message.\n"
+                               "    mvwm is ignoring this request.\n",
+                               fw ? FW_W(fw) : 0, fw ? fw->name.name : 
"(none)",
+                               ev->xclient.data.l[0]);
+                       mvwm_msg_report_app_and_workers();
                }
-       }
-       else
-       {
-               mvwm_msg(
-                       WARN, "ewmh_NumberOfDesktops",
-                       "The application window (id %#lx)\n"
-                       "  \"%s\" tried to set an invalid number of desktops"
-                       " (%ld)\n"
-                       "  using an EWMH client message.\n"
-                       "    mvwm is ignoring this request.\n",
-                       fw ? FW_W(fw) : 0, fw ? fw->name.name : "(none)",
-                       ev->xclient.data.l[0]);
-               mvwm_msg_report_app_and_workers();
        }
 
        return -1;
diff --git a/mvwm/ewmh_intern.h b/mvwm/ewmh_intern.h
index 60b4ded..170371e 100644
--- a/mvwm/ewmh_intern.h
+++ b/mvwm/ewmh_intern.h
@@ -83,7 +83,6 @@ typedef struct ewmh_info
        ewmh_strut BaseStrut;
 } ewmhInfo;
 
-extern ewmhInfo ewmhc;
 
 
 ewmh_atom *ewmh_GetEwmhAtomByAtom(Atom atom, ewmh_atom_list_name list_name);
@@ -105,7 +104,7 @@ int ewmh_HandleToolBar(EWMH_CMD_ARGS);
 int ewmh_HandleNotification(EWMH_CMD_ARGS);
 
 void ewmh_AddToKdeSysTray(MvwmWindow *fw);
-void ewmh_SetWorkArea(void);
+void ewmh_SetWorkArea(struct monitor *);
 void ewmh_ComputeAndSetWorkArea(struct monitor *);
 void ewmh_HandleDynamicWorkArea(struct monitor *);
 void ewmh_HandleWindowType(MvwmWindow *fw, window_style *style);
diff --git a/mvwm/update.c b/mvwm/update.c
index 1326f60..cc63f10 100644
--- a/mvwm/update.c
+++ b/mvwm/update.c
@@ -519,7 +519,7 @@ static void apply_window_updates(
        }
        if (flags->do_update_working_area)
        {
-               EWMH_UpdateWorkArea();
+               EWMH_UpdateWorkArea(t->m ? t->m : monitor_get_current());
        }
        if (flags->do_update_ewmh_stacking_hints)
        {

----------------------------------------------------------------

Diffstat:

----------------------------------------------------------------
 libs/FScreen.h        |   7 +++
 mvwm/ewmh.c           |  88 +++++++++++++++------------------
 mvwm/ewmh.h           |   2 +-
 mvwm/ewmh_conf.c      | 133 ++++++++++++++++++++++++++++++++++++++------------
 mvwm/ewmh_events.c    |  43 ++++++++--------
 mvwm/ewmh_intern.h    |   3 +-
 mvwm/update.c         |   2 +-
 rewrite-notes/parsing |   4 +-
 8 files changed, 174 insertions(+), 108 deletions(-)

----------------------------------------------------------------

Reply via email to