summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-02-19 13:53:40 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-02-19 13:53:40 +0100
commitb3d7e07f18f0f69f8c3b3542615da62dfc4c6175 (patch)
tree55ef91ea3249738001b2f60aa80fb8d68af32862
parentadded some new convenience functions (diff)
downloaddwm-b3d7e07f18f0f69f8c3b3542615da62dfc4c6175.tar.gz
dwm-b3d7e07f18f0f69f8c3b3542615da62dfc4c6175.zip
some more refactoring
Diffstat (limited to '')
-rw-r--r--client.c42
-rw-r--r--dwm.h10
-rw-r--r--view.c42
3 files changed, 47 insertions, 47 deletions
diff --git a/client.c b/client.c
index 9a30526..e7a3864 100644
--- a/client.c
+++ b/client.c
@@ -61,20 +61,6 @@ xerrordummy(Display *dsply, XErrorEvent *ee) {
61/* extern */ 61/* extern */
62 62
63void 63void
64attach(Client *c) {
65 if(clients)
66 clients->prev = c;
67 c->next = clients;
68 clients = c;
69}
70
71void
72attachstack(Client *c) {
73 c->snext = stack;
74 stack = c;
75}
76
77void
78configure(Client *c) { 64configure(Client *c) {
79 XConfigureEvent ce; 65 XConfigureEvent ce;
80 66
@@ -93,24 +79,6 @@ configure(Client *c) {
93} 79}
94 80
95void 81void
96detach(Client *c) {
97 if(c->prev)
98 c->prev->next = c->next;
99 if(c->next)
100 c->next->prev = c->prev;
101 if(c == clients)
102 clients = c->next;
103 c->next = c->prev = NULL;
104}
105
106void
107detachstack(Client *c) {
108 Client **tc;
109 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
110 *tc = c->snext;
111}
112
113void
114focus(Client *c) { 82focus(Client *c) {
115 if(c && !isvisible(c)) 83 if(c && !isvisible(c))
116 return; 84 return;
@@ -135,16 +103,6 @@ focus(Client *c) {
135 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 103 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
136} 104}
137 105
138Client *
139getclient(Window w) {
140 Client *c;
141
142 for(c = clients; c; c = c->next)
143 if(c->win == w)
144 return c;
145 return NULL;
146}
147
148Bool 106Bool
149isprotodel(Client *c) { 107isprotodel(Client *c) {
150 int i, n; 108 int i, n;
diff --git a/dwm.h b/dwm.h
index 35950a6..4a820b0 100644
--- a/dwm.h
+++ b/dwm.h
@@ -99,13 +99,8 @@ extern Display *dpy;
99extern Window root, barwin; 99extern Window root, barwin;
100 100
101/* client.c */ 101/* client.c */
102extern void attach(Client *c); /* attaches c to global client list */
103extern void attachstack(Client *c); /* attaches client to stack */
104extern void configure(Client *c); /* send synthetic configure event */ 102extern void configure(Client *c); /* send synthetic configure event */
105extern void detach(Client *c); /* detaches c from global client list */
106extern void detachstack(Client *c); /* detaches client from stack */
107extern void focus(Client *c); /* focus c, c may be NULL */ 103extern void focus(Client *c); /* focus c, c may be NULL */
108extern Client *getclient(Window w); /* return client of w */
109extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */ 104extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */
110extern void killclient(Arg *arg); /* kill c nicely */ 105extern void killclient(Arg *arg); /* kill c nicely */
111extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ 106extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
@@ -148,9 +143,14 @@ extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 *
148extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ 143extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
149 144
150/* view.c */ 145/* view.c */
146extern void attach(Client *c); /* attaches c to global client list */
147extern void attachstack(Client *c); /* attaches client to stack */
151extern void dofloat(void); /* arranges all windows floating */ 148extern void dofloat(void); /* arranges all windows floating */
149extern void detach(Client *c); /* detaches c from global client list */
150extern void detachstack(Client *c); /* detaches client from stack */
152extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ 151extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
153extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ 152extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
153extern Client *getclient(Window w); /* return client of w */
154extern Bool isvisible(Client *c); /* returns True if client is visible */ 154extern Bool isvisible(Client *c); /* returns True if client is visible */
155extern Client *nextmanaged(Client *c); /* returns managed successor of c */ 155extern Client *nextmanaged(Client *c); /* returns managed successor of c */
156extern void restack(void); /* restores z layers of all clients */ 156extern void restack(void); /* restores z layers of all clients */
diff --git a/view.c b/view.c
index cd07b94..4781b4e 100644
--- a/view.c
+++ b/view.c
@@ -8,6 +8,20 @@
8void (*arrange)(void) = DEFMODE; 8void (*arrange)(void) = DEFMODE;
9 9
10void 10void
11attach(Client *c) {
12 if(clients)
13 clients->prev = c;
14 c->next = clients;
15 clients = c;
16}
17
18void
19attachstack(Client *c) {
20 c->snext = stack;
21 stack = c;
22}
23
24void
11dofloat(void) { 25dofloat(void) {
12 Client *c; 26 Client *c;
13 27
@@ -31,6 +45,24 @@ dofloat(void) {
31} 45}
32 46
33void 47void
48detach(Client *c) {
49 if(c->prev)
50 c->prev->next = c->next;
51 if(c->next)
52 c->next->prev = c->prev;
53 if(c == clients)
54 clients = c->next;
55 c->next = c->prev = NULL;
56}
57
58void
59detachstack(Client *c) {
60 Client **tc;
61 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
62 *tc = c->snext;
63}
64
65void
34focusnext(Arg *arg) { 66focusnext(Arg *arg) {
35 Client *c; 67 Client *c;
36 68
@@ -62,6 +94,16 @@ focusprev(Arg *arg) {
62 } 94 }
63} 95}
64 96
97Client *
98getclient(Window w) {
99 Client *c;
100
101 for(c = clients; c; c = c->next)
102 if(c->win == w)
103 return c;
104 return NULL;
105}
106
65Bool 107Bool
66isvisible(Client *c) { 108isvisible(Client *c) {
67 unsigned int i; 109 unsigned int i;