]> git.mdlowis.com Git - proto/lwm.git/commitdiff
mild refactoring
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 9 Mar 2020 02:13:44 +0000 (22:13 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 9 Mar 2020 02:13:44 +0000 (22:13 -0400)
.gitignore
disp.c
lwm
lwm.h
manage.c

index 4829287c7f32cfee581dab157c428fd87af03e61..e7d22245244db4e935a9a8167dd0eb7229d5a4ce 100644 (file)
@@ -1,2 +1,3 @@
 tags
 lwm
+lwm.dSYM/
diff --git a/disp.c b/disp.c
index 44c9189e75cc6b2f29f2f4d86d5fe0385533f266..e9f2c87b8e855c1c90ff698c2d036ee05d58fb19 100644 (file)
--- 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 d0ecf68d598e589a12bc46b677fa1e993a4febb2..b02fcae26d1ba14a9ca9560cc344f0ac365e9f49 100755 (executable)
Binary files a/lwm and b/lwm differ
diff --git a/lwm.h b/lwm.h
index 30de4e4a10ea9ab7e341d9b4394503e8f6ddf20f..8bba70bba35ec29cb47506c9f389ca9d9a06e8ea 100644 (file)
--- a/lwm.h
+++ b/lwm.h
 
 /* --- 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 *);
index 26ba3b53af6e7fb3bc1e1fa021e100cd2f23cd8b..95580331104ff33baad9c4a3770996775b1b8e04 100644 (file)
--- 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;