diff options
| -rw-r--r-- | client.c | 96 | ||||
| -rw-r--r-- | dwm.h | 14 | ||||
| -rw-r--r-- | view.c (renamed from manage.c) | 74 |
3 files changed, 92 insertions, 92 deletions
| @@ -46,6 +46,21 @@ grabbuttons(Client *c, Bool focused) { | |||
| 46 | GrabModeAsync, GrabModeSync, None, None); | 46 | GrabModeAsync, GrabModeSync, None, None); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | static Bool | ||
| 50 | isprotodel(Client *c) { | ||
| 51 | int i, n; | ||
| 52 | Atom *protocols; | ||
| 53 | Bool ret = False; | ||
| 54 | |||
| 55 | if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { | ||
| 56 | for(i = 0; !ret && i < n; i++) | ||
| 57 | if(protocols[i] == wmatom[WMDelete]) | ||
| 58 | ret = True; | ||
| 59 | XFree(protocols); | ||
| 60 | } | ||
| 61 | return ret; | ||
| 62 | } | ||
| 63 | |||
| 49 | static void | 64 | static void |
| 50 | setclientstate(Client *c, long state) { | 65 | setclientstate(Client *c, long state) { |
| 51 | long data[] = {state, None}; | 66 | long data[] = {state, None}; |
| @@ -61,6 +76,20 @@ xerrordummy(Display *dsply, XErrorEvent *ee) { | |||
| 61 | /* extern */ | 76 | /* extern */ |
| 62 | 77 | ||
| 63 | void | 78 | void |
| 79 | attach(Client *c) { | ||
| 80 | if(clients) | ||
| 81 | clients->prev = c; | ||
| 82 | c->next = clients; | ||
| 83 | clients = c; | ||
| 84 | } | ||
| 85 | |||
| 86 | void | ||
| 87 | attachstack(Client *c) { | ||
| 88 | c->snext = stack; | ||
| 89 | stack = c; | ||
| 90 | } | ||
| 91 | |||
| 92 | void | ||
| 64 | configure(Client *c) { | 93 | configure(Client *c) { |
| 65 | XConfigureEvent ce; | 94 | XConfigureEvent ce; |
| 66 | 95 | ||
| @@ -79,6 +108,24 @@ configure(Client *c) { | |||
| 79 | } | 108 | } |
| 80 | 109 | ||
| 81 | void | 110 | void |
| 111 | detach(Client *c) { | ||
| 112 | if(c->prev) | ||
| 113 | c->prev->next = c->next; | ||
| 114 | if(c->next) | ||
| 115 | c->next->prev = c->prev; | ||
| 116 | if(c == clients) | ||
| 117 | clients = c->next; | ||
| 118 | c->next = c->prev = NULL; | ||
| 119 | } | ||
| 120 | |||
| 121 | void | ||
| 122 | detachstack(Client *c) { | ||
| 123 | Client **tc; | ||
| 124 | for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); | ||
| 125 | *tc = c->snext; | ||
| 126 | } | ||
| 127 | |||
| 128 | void | ||
| 82 | focus(Client *c) { | 129 | focus(Client *c) { |
| 83 | if(c && !isvisible(c)) | 130 | if(c && !isvisible(c)) |
| 84 | return; | 131 | return; |
| @@ -103,19 +150,46 @@ focus(Client *c) { | |||
| 103 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); | 150 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
| 104 | } | 151 | } |
| 105 | 152 | ||
| 106 | Bool | 153 | void |
| 107 | isprotodel(Client *c) { | 154 | focusnext(Arg *arg) { |
| 108 | int i, n; | 155 | Client *c; |
| 109 | Atom *protocols; | 156 | |
| 110 | Bool ret = False; | 157 | if(!sel) |
| 158 | return; | ||
| 159 | for(c = sel->next; c && !isvisible(c); c = c->next); | ||
| 160 | if(!c) | ||
| 161 | for(c = clients; c && !isvisible(c); c = c->next); | ||
| 162 | if(c) { | ||
| 163 | focus(c); | ||
| 164 | restack(); | ||
| 165 | } | ||
| 166 | } | ||
| 111 | 167 | ||
| 112 | if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { | 168 | void |
| 113 | for(i = 0; !ret && i < n; i++) | 169 | focusprev(Arg *arg) { |
| 114 | if(protocols[i] == wmatom[WMDelete]) | 170 | Client *c; |
| 115 | ret = True; | 171 | |
| 116 | XFree(protocols); | 172 | if(!sel) |
| 173 | return; | ||
| 174 | for(c = sel->prev; c && !isvisible(c); c = c->prev); | ||
| 175 | if(!c) { | ||
| 176 | for(c = clients; c && c->next; c = c->next); | ||
| 177 | for(; c && !isvisible(c); c = c->prev); | ||
| 117 | } | 178 | } |
| 118 | return ret; | 179 | if(c) { |
| 180 | focus(c); | ||
| 181 | restack(); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 185 | Client * | ||
| 186 | getclient(Window w) { | ||
| 187 | Client *c; | ||
| 188 | |||
| 189 | for(c = clients; c; c = c->next) | ||
| 190 | if(c->win == w) | ||
| 191 | return c; | ||
| 192 | return NULL; | ||
| 119 | } | 193 | } |
| 120 | 194 | ||
| 121 | void | 195 | void |
| @@ -99,8 +99,15 @@ extern Display *dpy; | |||
| 99 | extern Window root, barwin; | 99 | extern Window root, barwin; |
| 100 | 100 | ||
| 101 | /* client.c */ | 101 | /* client.c */ |
| 102 | extern void attach(Client *c); /* attaches c to global client list */ | ||
| 103 | extern void attachstack(Client *c); /* attaches client to stack */ | ||
| 102 | extern void configure(Client *c); /* send synthetic configure event */ | 104 | extern void configure(Client *c); /* send synthetic configure event */ |
| 105 | extern void detach(Client *c); /* detaches c from global client list */ | ||
| 106 | extern void detachstack(Client *c); /* detaches client from stack */ | ||
| 103 | extern void focus(Client *c); /* focus c, c may be NULL */ | 107 | extern void focus(Client *c); /* focus c, c may be NULL */ |
| 108 | extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ | ||
| 109 | extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ | ||
| 110 | extern Client *getclient(Window w); /* return client of w */ | ||
| 104 | extern void killclient(Arg *arg); /* kill c nicely */ | 111 | extern void killclient(Arg *arg); /* kill c nicely */ |
| 105 | extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ | 112 | extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ |
| 106 | extern void resize(Client *c, int x, int y, | 113 | extern void resize(Client *c, int x, int y, |
| @@ -125,16 +132,9 @@ extern void sendevent(Window w, Atom a, long value); /* send synthetic event to | |||
| 125 | extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ | 132 | extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ |
| 126 | 133 | ||
| 127 | /* manage.c */ | 134 | /* manage.c */ |
| 128 | extern void attach(Client *c); /* attaches c to global client list */ | ||
| 129 | extern void attachstack(Client *c); /* attaches client to stack */ | ||
| 130 | extern void compileregexps(void); /* initialize regexps of rules defined in config.h */ | 135 | extern void compileregexps(void); /* initialize regexps of rules defined in config.h */ |
| 131 | extern void detach(Client *c); /* detaches c from global client list */ | ||
| 132 | extern void detachstack(Client *c); /* detaches client from stack */ | ||
| 133 | extern void dofloat(void); /* arranges all windows floating */ | 136 | extern void dofloat(void); /* arranges all windows floating */ |
| 134 | extern void dotile(void); /* arranges all windows tiled */ | 137 | extern void dotile(void); /* arranges all windows tiled */ |
| 135 | extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ | ||
| 136 | extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ | ||
| 137 | extern Client *getclient(Window w); /* return client of w */ | ||
| 138 | extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */ | 138 | extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */ |
| 139 | extern Bool isvisible(Client *c); /* returns True if client is visible */ | 139 | extern Bool isvisible(Client *c); /* returns True if client is visible */ |
| 140 | extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */ | 140 | extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */ |
| @@ -59,20 +59,6 @@ togglemax(Client *c) { | |||
| 59 | /* extern */ | 59 | /* extern */ |
| 60 | 60 | ||
| 61 | void | 61 | void |
| 62 | attach(Client *c) { | ||
| 63 | if(clients) | ||
| 64 | clients->prev = c; | ||
| 65 | c->next = clients; | ||
| 66 | clients = c; | ||
| 67 | } | ||
| 68 | |||
| 69 | void | ||
| 70 | attachstack(Client *c) { | ||
| 71 | c->snext = stack; | ||
| 72 | stack = c; | ||
| 73 | } | ||
| 74 | |||
| 75 | void | ||
| 76 | compileregexps(void) { | 62 | compileregexps(void) { |
| 77 | unsigned int i; | 63 | unsigned int i; |
| 78 | regex_t *reg; | 64 | regex_t *reg; |
| @@ -100,24 +86,6 @@ compileregexps(void) { | |||
| 100 | } | 86 | } |
| 101 | 87 | ||
| 102 | void | 88 | void |
| 103 | detach(Client *c) { | ||
| 104 | if(c->prev) | ||
| 105 | c->prev->next = c->next; | ||
| 106 | if(c->next) | ||
| 107 | c->next->prev = c->prev; | ||
| 108 | if(c == clients) | ||
| 109 | clients = c->next; | ||
| 110 | c->next = c->prev = NULL; | ||
| 111 | } | ||
| 112 | |||
| 113 | void | ||
| 114 | detachstack(Client *c) { | ||
| 115 | Client **tc; | ||
| 116 | for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); | ||
| 117 | *tc = c->snext; | ||
| 118 | } | ||
| 119 | |||
| 120 | void | ||
| 121 | dofloat(void) { | 89 | dofloat(void) { |
| 122 | Client *c; | 90 | Client *c; |
| 123 | 91 | ||
| @@ -192,48 +160,6 @@ dotile(void) { | |||
| 192 | } | 160 | } |
| 193 | 161 | ||
| 194 | void | 162 | void |
| 195 | focusnext(Arg *arg) { | ||
| 196 | Client *c; | ||
| 197 | |||
| 198 | if(!sel) | ||
| 199 | return; | ||
| 200 | for(c = sel->next; c && !isvisible(c); c = c->next); | ||
| 201 | if(!c) | ||
| 202 | for(c = clients; c && !isvisible(c); c = c->next); | ||
| 203 | if(c) { | ||
| 204 | focus(c); | ||
| 205 | restack(); | ||
| 206 | } | ||
| 207 | } | ||
| 208 | |||
| 209 | void | ||
| 210 | focusprev(Arg *arg) { | ||
| 211 | Client *c; | ||
| 212 | |||
| 213 | if(!sel) | ||
| 214 | return; | ||
| 215 | for(c = sel->prev; c && !isvisible(c); c = c->prev); | ||
| 216 | if(!c) { | ||
| 217 | for(c = clients; c && c->next; c = c->next); | ||
| 218 | for(; c && !isvisible(c); c = c->prev); | ||
| 219 | } | ||
| 220 | if(c) { | ||
| 221 | focus(c); | ||
| 222 | restack(); | ||
| 223 | } | ||
| 224 | } | ||
| 225 | |||
| 226 | Client * | ||
| 227 | getclient(Window w) { | ||
| 228 | Client *c; | ||
| 229 | |||
| 230 | for(c = clients; c; c = c->next) | ||
| 231 | if(c->win == w) | ||
| 232 | return c; | ||
| 233 | return NULL; | ||
| 234 | } | ||
| 235 | |||
| 236 | void | ||
| 237 | incnmaster(Arg *arg) { | 163 | incnmaster(Arg *arg) { |
| 238 | if((arrange == dofloat) || (nmaster + arg->i < 1) | 164 | if((arrange == dofloat) || (nmaster + arg->i < 1) |
| 239 | || (wah / (nmaster + arg->i) <= 2 * BORDERPX)) | 165 | || (wah / (nmaster + arg->i) <= 2 * BORDERPX)) |
