From 78ba2fe9b62a735261d7e58824fb105da33add8d Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sun, 8 Mar 2020 22:13:44 -0400 Subject: [PATCH] mild refactoring --- .gitignore | 1 + disp.c | 21 ++++++++++++++++++--- lwm | Bin 56428 -> 56428 bytes lwm.h | 18 ++---------------- manage.c | 31 ++----------------------------- 5 files changed, 23 insertions(+), 48 deletions(-) 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 d0ecf68d598e589a12bc46b677fa1e993a4febb2..b02fcae26d1ba14a9ca9560cc344f0ac365e9f49 100755 GIT binary patch delta 2070 zcmaE}gZa%4<_#IF0v|E!hRGUIbvz9W3=AIKp+8)@ zyE-;+lDf{QGl7ADfe|d~`oQCO14sb_lzY6Phk=2C1GJ|@n%VDtGXQFg`&lb3YGV+x10vN5|&1NtvvS3pR^q=&&<3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01q&fPsO51xH8#dcp=`aa_+|0n=DhzSKhvN+mlWT3H85=gw zw8>**T(FtL`ItE4lFjF%MA;b|CO=Kw$q%-u)AfQ!x9f}UjtQIBCS|fRF4-)ep~KGD zvDqd6kG0_zb_RwNkk_GjFFON68Z#q<`|Q*>kPs-4^cWc!6vQ9__HT0GYI{cR$s1SO zGs;f>xZ0jkZ?fSUdq&5}g=_2?gC}oXW6u~r`QsXU#_Y+4Ywa1UCKs-?XY81~ajiY$ z%*h|u+A}VnY`D&zaqHy5b@q&hCvRM5&v<3>$949MZzdbAw`XGDoLsctj!|Or#`X4$ zs*^viw`Vk+Y`8(+(20|QK>_3b+`C?A~)whj?$#QWo^jS>#x3@Yizhp7v1i;gxp9j<6KhPm9RCY0bX;e!{%gw2y5ZnJ0HH(7DJJ>$j6iQDZNpHE)6-JbF9L99#mU1d9b_NAqHaW^2v@n?HSij zZro|lxNGvkouIg3+yx2?$6cT#)40o?@yq0cyX=`5cqcRMwqq2Y?6_OMUY-}#axFBz z5gOkHjqioV4@Bc9pz#Y(`SlE?r~(YtX#7qz{vap3!}>;a+>ju*rpc?HSW1Z`^CoSU&mV zUVFy&$%gyv8K+Jz+-J`?fAYqC`hsit7#P$z7#QA6hUnit`Qtu)!&7{ywqD}HZmU2U zM3>Oy!2S01D*Ox#e2feX2@()db146UDunM3tBgAMlIrp+Nn?;(brJ=>`D zHX}=e)YQbu|E{I8B^sNhrlwBLzW$EQ%p%RmJY{qIjY*7bhN&h=DQT0x-#p7^lwxR{ LnzH%St%ZyL8Thi- 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; -- 2.54.0