]> git.mdlowis.com Git - proto/lwm.git/commitdiff
removed screen type and lots of related logic
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 9 Mar 2020 20:55:11 +0000 (16:55 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 9 Mar 2020 20:55:11 +0000 (16:55 -0400)
client.c
disp.c
lwm.c
lwm.h

index 1cdc8dacaf23ecebebfe4c5475085369846077e8..377e53ded917a18f62f2d82e975865f83baa3463 100644 (file)
--- a/client.c
+++ b/client.c
@@ -102,7 +102,7 @@ Client *
 Client_Get(Window w) {
     Client * c;
 
-    if (w == 0 || (getScreenFromRoot(w) != 0))
+    if (w == 0 || (w == root))
         return 0;
 
     /* Search for the client corresponding to this window. */
@@ -164,7 +164,7 @@ Client_Remove(Client *c) {
         Client_Focus(focus, CurrentTime);
     }
 
-    if (getScreenFromRoot(c->parent) == 0)
+    if (c->parent != root)
         XDestroyWindow(dpy, c->parent);
 
     if (c->name != 0)
@@ -414,7 +414,7 @@ sendClientMessage(Window w, Atom a, long data0, long data1) {
     ev.xclient.format = 32;
     ev.xclient.data.l[0] = data0;
     ev.xclient.data.l[1] = data1;
-    mask = (getScreenFromRoot(w) != 0) ? SubstructureRedirectMask : 0L;
+    mask = (w == root) ? SubstructureRedirectMask : 0L;
 
     XSendEvent(dpy, w, False, mask, &ev);
 }
diff --git a/disp.c b/disp.c
index 6136e632df2c1d985e4e935287b712771d080381..1b4527429a029b2e7c4c1a957f4da0616f9dba05 100644 (file)
--- a/disp.c
+++ b/disp.c
@@ -119,7 +119,7 @@ expose(XEvent * ev) {
     * We don't draw on the root window so that people can have
     * their favourite Spice Girls backdrop...
     */
-    if (getScreenFromRoot(w) != 0)
+    if (w == root)
         return;
 
     /* redraw window frame */
@@ -220,8 +220,7 @@ maprequest(XEvent *ev) {
 
     if (c == 0 || c->window != e->window) {
         int screen;
-        for (screen = 0; screen < screen_count; screen++)
-            scanWindowTree(screen);
+        scanWindowTree();
         c = Client_Get(e->window);
         if (c == 0 || c->window != e->window) {
             fprintf(stderr, "MapRequest for non-existent window!\n");
@@ -231,7 +230,7 @@ maprequest(XEvent *ev) {
 
     switch (c->state) {
     case WithdrawnState:
-        if (getScreenFromRoot(c->parent) != 0) {
+        if (c->parent == root) {
             manage(c, 0);
             break;
         }
@@ -342,7 +341,7 @@ configurereq(XEvent *ev) {
         if (e->value_mask & CWBorderWidth)
             c->border = e->border_width;
 
-        if (getScreenFromRoot(c->parent) == 0) {
+        if (c->parent != root) {
             wc.x = c->size.x;
             wc.y = c->size.y;
             if (c->framed == True)
@@ -439,11 +438,11 @@ reparent(XEvent *ev) {
     Client * c;
     XReparentEvent * e = &ev->xreparent;
 
-    if (getScreenFromRoot(e->event) == 0 || e->override_redirect || getScreenFromRoot(e->parent) != 0)
+    if (e->event != root || e->override_redirect || e->parent == root)
         return;
 
     c = Client_Get(e->window);
-    if (c != 0 && (getScreenFromRoot(c->parent) != 0 || Client_IsState(c, WithdrawnState)))
+    if (c != 0 && (c->parent == root || Client_IsState(c, WithdrawnState)))
         Client_Remove(c);
 }
 
diff --git a/lwm.c b/lwm.c
index 52deac75c151d94f3b8c5a79c431164b23ab8993..e5bb131a1f072514edd3be327bb316ce9e83aeb4 100644 (file)
--- a/lwm.c
+++ b/lwm.c
@@ -54,9 +54,6 @@ Cursor root_cursor;
 Cursor box_cursor;
 Cursor cursor_map[E_LAST];
 
-int screen_count;       /* The number of screens. */
-ScreenInfo * screens;       /* Information about these screens. */
-
 XFontSet font_set = NULL;   /* Font set for title var */
 XFontSetExtents *font_set_ext = NULL;
 
@@ -147,7 +144,7 @@ sendConfigureNotify(Client *c) {
 }
 
 extern void
-scanWindowTree(int screen) {
+scanWindowTree(void) {
     unsigned int i;
     unsigned int nwins;
     Client * c;
@@ -206,19 +203,10 @@ titleWidth(XFontSet font_set, Client *c) {
 
 static void
 initScreens(void) {
-    int screen;
-
-    /* Find out how many screens we've got, and allocate space for their info. */
-    screen_count = ScreenCount(dpy);
-    printf("screens: %d\n", screen_count);
-    screens = (ScreenInfo *) malloc(screen_count * sizeof(ScreenInfo));
-
     /* Go through the screens one-by-one, initialising them. */
-    for (screen = 0; screen < screen_count; screen++) {
-        initialiseCursors(screen);
-        initScreen(screen);
-        scanWindowTree(screen);
-    }
+    initialiseCursors(0);
+    initScreen(0);
+    scanWindowTree();
 }
 
 static void
@@ -261,17 +249,3 @@ initScreen(int screen) {
     /* Make sure all our communication to the server got through. */
     XSync(dpy, False);
 }
-
-/**
-Find the screen for which root is the root window.
-*/
-ScreenInfo *
-getScreenFromRoot(Window wroot) {
-    int screen;
-
-    for (screen = 0; screen < screen_count; screen++)
-        if (root == wroot)
-            return &screens[screen];
-
-    return 0;
-}
diff --git a/lwm.h b/lwm.h
index d3ee85e29219d6ac5ae26d6222c9cc2b3ea5001a..2dc96101d0105710f7403a8fb6c279a32e8761bc 100644 (file)
--- a/lwm.h
+++ b/lwm.h
@@ -59,13 +59,6 @@ typedef enum {
     DSizeKeyboard,   DMoveKeyboard
 } EWMHDirection;
 
-/**
-* Screen information.
-*/
-typedef struct ScreenInfo ScreenInfo;
-struct ScreenInfo {
-};
-
 /* Client flags for EWMH protocols and window behavior */
 enum {
 //    F_FRAMED          = (1 << 0),
@@ -116,8 +109,6 @@ extern Cursor root_cursor;
 extern Cursor box_cursor;
 extern Cursor cursor_map[E_LAST];
 
-extern int screen_count;
-extern ScreenInfo * screens;
 extern XFontSet font_set;
 extern XFontSetExtents *font_set_ext;
 extern Atom wm_state;
@@ -129,8 +120,7 @@ extern void sendConfigureNotify(Client *);
 extern int titleHeight(void);
 extern int titleWidth(XFontSet font_set, Client *c);
 extern int ascent(XFontSetExtents *font_set_ext);
-extern ScreenInfo * getScreenFromRoot(Window);
-extern void scanWindowTree(int);
+extern void scanWindowTree(void);
 
 /*  client.c */
 extern Edge interacting_edge;