From: Michael D. Lowis Date: Mon, 9 Mar 2020 20:55:11 +0000 (-0400) Subject: removed screen type and lots of related logic X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=e11632d35ccb9869060b49a8a66f95abd2516a23;p=proto%2Flwm.git removed screen type and lots of related logic --- diff --git a/client.c b/client.c index 1cdc8da..377e53d 100644 --- 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 6136e63..1b45274 100644 --- 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 52deac7..e5bb131 100644 --- 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 d3ee85e..2dc9610 100644 --- 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;