diff options
| author | Anselm R. Garbe <arg@suckless.org> | 2007-02-19 14:57:32 +0100 |
|---|---|---|
| committer | Anselm R. Garbe <arg@suckless.org> | 2007-02-19 14:57:32 +0100 |
| commit | 64871a7045077bb2ec4cbcd62a74cabbe6b45096 (patch) | |
| tree | 7e9d0fbab49039b32bf99924546edbe41392842e /client.c | |
| parent | renamed Rule members, renamed RReg into Regexps (diff) | |
| download | dwm-64871a7045077bb2ec4cbcd62a74cabbe6b45096.tar.gz dwm-64871a7045077bb2ec4cbcd62a74cabbe6b45096.zip | |
renamed manage.c to view.c
Diffstat (limited to '')
| -rw-r--r-- | client.c | 96 |
1 files changed, 85 insertions, 11 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 |
