some more refactoring b3d7e07f
Anselm R. Garbe · 2007-02-19 13:53 3 file(s) · +47 −47
client.c +0 −42
61 61
/* extern */
62 62
63 63
void
64 -
attach(Client *c) {
65 -
	if(clients)
66 -
		clients->prev = c;
67 -
	c->next = clients;
68 -
	clients = c;
69 -
}
70 -
71 -
void
72 -
attachstack(Client *c) {
73 -
	c->snext = stack;
74 -
	stack = c;
75 -
}
76 -
77 -
void
78 64
configure(Client *c) {
79 65
	XConfigureEvent ce;
80 66
93 79
}
94 80
95 81
void
96 -
detach(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 -
106 -
void
107 -
detachstack(Client *c) {
108 -
	Client **tc;
109 -
	for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
110 -
	*tc = c->snext;
111 -
}
112 -
113 -
void
114 82
focus(Client *c) {
115 83
	if(c && !isvisible(c))
116 84
		return;
133 101
	}
134 102
	else
135 103
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
136 -
}
137 -
138 -
Client *
139 -
getclient(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 104
}
147 105
148 106
Bool
dwm.h +5 −5
99 99
extern Window root, barwin;
100 100
101 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 */
104 102
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 */
107 103
extern void focus(Client *c);			/* focus c, c may be NULL */
108 -
extern Client *getclient(Window w);		/* return client of w */
109 104
extern Bool isprotodel(Client *c);		/* returns True if c->win supports wmatom[WMDelete] */
110 105
extern void killclient(Arg *arg);		/* kill c nicely */
111 106
extern void manage(Window w, XWindowAttributes *wa);	/* manage new client */
148 143
extern void spawn(Arg *arg);			/* forks a new subprocess with to arg's cmd */
149 144
150 145
/* view.c */
146 +
extern void attach(Client *c);			/* attaches c to global client list */
147 +
extern void attachstack(Client *c);		/* attaches client to stack */
151 148
extern void dofloat(void);			/* arranges all windows floating */
149 +
extern void detach(Client *c);			/* detaches c from global client list */
150 +
extern void detachstack(Client *c);		/* detaches client from stack */
152 151
extern void focusnext(Arg *arg);		/* focuses next visible client, arg is ignored  */
153 152
extern void focusprev(Arg *arg);		/* focuses previous visible client, arg is ignored */
153 +
extern Client *getclient(Window w);		/* return client of w */
154 154
extern Bool isvisible(Client *c);		/* returns True if client is visible */
155 155
extern Client *nextmanaged(Client *c);		/* returns managed successor of c */
156 156
extern void restack(void);			/* restores z layers of all clients */
view.c +42 −0
8 8
void (*arrange)(void) = DEFMODE;
9 9
10 10
void
11 +
attach(Client *c) {
12 +
	if(clients)
13 +
		clients->prev = c;
14 +
	c->next = clients;
15 +
	clients = c;
16 +
}
17 +
18 +
void
19 +
attachstack(Client *c) {
20 +
	c->snext = stack;
21 +
	stack = c;
22 +
}
23 +
24 +
void
11 25
dofloat(void) {
12 26
	Client *c;
13 27
31 45
}
32 46
33 47
void
48 +
detach(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 +
58 +
void
59 +
detachstack(Client *c) {
60 +
	Client **tc;
61 +
	for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
62 +
	*tc = c->snext;
63 +
}
64 +
65 +
void
34 66
focusnext(Arg *arg) {
35 67
	Client *c;
36 68
   
60 92
		focus(c);
61 93
		restack();
62 94
	}
95 +
}
96 +
97 +
Client *
98 +
getclient(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;
63 105
}
64 106
65 107
Bool