From: Michael D. Lowis Date: Mon, 9 Mar 2020 02:13:44 +0000 (-0400) Subject: mild refactoring X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=78ba2fe9b62a735261d7e58824fb105da33add8d;p=proto%2Flwm.git mild refactoring --- diff --git a/.gitignore b/.gitignore index 4829287..e7d2224 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ tags lwm +lwm.dSYM/ diff --git a/disp.c b/disp.c index 44c9189..e9f2c87 100644 --- a/disp.c +++ b/disp.c @@ -273,8 +273,22 @@ unmap(XEvent *ev) { return; } - /* This is a plain unmap, so withdraw the window. */ - withdraw(c); + if (c->parent != c->screen->root) { + XUnmapWindow(dpy, c->parent); + XReparentWindow(dpy, c->parent, c->screen->root, c->size.x, c->size.y); + } + + XRemoveFromSaveSet(dpy, c->window); + Client_SetState(c, WithdrawnState); + + /* + * Flush and ignore any errors. X11 sends us an UnmapNotify before it + * sends us a DestroyNotify. That means we can get here without knowing + * whether the relevant window still exists. + */ + ignore_badwindow = 1; + XSync(dpy, False); + ignore_badwindow = 0; c->internal_state = INormal; } @@ -514,7 +528,8 @@ property(XEvent * ev) { getWindowName(c); Client_SetActive(c, c == current, 0L); } else if (e->atom == XA_WM_TRANSIENT_FOR) { - getTransientFor(c); + c->trans = None; + XGetTransientForHint(dpy, c->window, &(c->trans)); } else if (e->atom == XA_WM_NORMAL_HINTS) { getNormalHints(c); } diff --git a/lwm b/lwm index d0ecf68..b02fcae 100755 Binary files a/lwm and b/lwm differ diff --git a/lwm.h b/lwm.h index 30de4e4..8bba70b 100644 --- a/lwm.h +++ b/lwm.h @@ -25,18 +25,7 @@ /* --- End of administrator-configurable defaults. --- */ -/* - * Window manager mode. wm is in one of five modes: it's either getting - * user input to move/reshape a window, getting user input to make a - * selection from the menu, waiting for user input to confirm a window close - * (by releasing a mouse button after prssing it in a window's box), - * waiting for user input to confirm a window hide (by releasing a mouse - * button after prssing it in a window's frame), - * or it's `idle' --- responding to events arriving - * from the server, but not directly interacting with the user. - * OK, so I lied: there's a sixth mode so that we can tell when wm's still - * initialising. - */ +/* Set of states the window manager can be in. */ typedef enum { wm_initialising, wm_idle, @@ -94,7 +83,6 @@ struct ScreenInfo { unsigned long black; /* Black pixel value. */ unsigned long white; /* White pixel value. */ unsigned long gray; /* Gray pixel value. */ - Cursor root_cursor; Cursor box_cursor; Cursor cursor_map[E_LAST]; @@ -110,7 +98,7 @@ enum { }; typedef struct Client { - strcut Client* next; /* Next window in client list. */ + struct Client* next; /* Next window in client list. */ Window window; /* Client's window. */ Window parent; /* Window manager frame. */ Window trans; /* Window that client is a transient for. */ @@ -198,8 +186,6 @@ extern void panic(char*); extern void getWindowName(Client *); extern void getNormalHints(Client *); extern void manage(Client *, int); -extern void withdraw(Client *); -extern void getTransientFor(Client *); /* mouse.c */ extern void getMousePosition(int *, int *); diff --git a/manage.c b/manage.c index 26ba3b5..9558033 100644 --- a/manage.c +++ b/manage.c @@ -92,7 +92,8 @@ manage(Client * c, int mapped) } /* Get the WM_TRANSIENT_FOR property (see ICCCM section 4.1.2.6). */ - getTransientFor(c); + c->trans = None; + XGetTransientForHint(dpy, c->window, &(c->trans)); /* Work out details for the Client structure from the hints. */ if (hints && (hints->flags & InputHint)) @@ -241,34 +242,6 @@ applyGravity(Client *c) { } } -void -getTransientFor(Client *c) { - Window trans = None; - - XGetTransientForHint(dpy, c->window, &trans); - c->trans = trans; -} - -void -withdraw(Client *c) { - if (c->parent != c->screen->root) { - XUnmapWindow(dpy, c->parent); - XReparentWindow(dpy, c->parent, c->screen->root, c->size.x, c->size.y); - } - - XRemoveFromSaveSet(dpy, c->window); - Client_SetState(c, WithdrawnState); - - /* - * Flush and ignore any errors. X11 sends us an UnmapNotify before it - * sends us a DestroyNotify. That means we can get here without knowing - * whether the relevant window still exists. - */ - ignore_badwindow = 1; - XSync(dpy, False); - ignore_badwindow = 0; -} - static int getProperty(Window w, Atom a, Atom type, long len, unsigned char **p) { Atom real_type;