renamed manage.c to view.c 64871a70
Anselm R. Garbe · 2007-02-19 14:57 3 file(s) · +92 −92
client.c +85 −11
46 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 64
static void
50 65
setclientstate(Client *c, long state) {
51 66
	long data[] = {state, None};
61 76
/* extern */
62 77
63 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 93
configure(Client *c) {
65 94
	XConfigureEvent ce;
66 95
79 108
}
80 109
81 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 129
focus(Client *c) {
83 130
	if(c && !isvisible(c))
84 131
		return;
103 150
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
104 151
}
105 152
106 -
Bool
107 -
isprotodel(Client *c) {
108 -
	int i, n;
109 -
	Atom *protocols;
110 -
	Bool ret = False;
153 +
void
154 +
focusnext(Arg *arg) {
155 +
	Client *c;
156 +
   
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)) {
113 -
		for(i = 0; !ret && i < n; i++)
114 -
			if(protocols[i] == wmatom[WMDelete])
115 -
				ret = True;
116 -
		XFree(protocols);
168 +
void
169 +
focusprev(Arg *arg) {
170 +
	Client *c;
171 +
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 195
void
dwm.h +7 −7
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 */
102 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 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 111
extern void killclient(Arg *arg);		/* kill c nicely */
105 112
extern void manage(Window w, XWindowAttributes *wa);	/* manage new client */
106 113
extern void resize(Client *c, int x, int y,
125 132
extern int xerror(Display *dsply, XErrorEvent *ee);	/* dwm's X error handler */
126 133
127 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 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 136
extern void dofloat(void);			/* arranges all windows floating */
134 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 138
extern void incnmaster(Arg *arg);		/* increments nmaster with arg's index value */
139 139
extern Bool isvisible(Client *c);		/* returns True if client is visible */
140 140
extern void resizemaster(Arg *arg);		/* resizes the master percent with arg's index value */
manage.c → view.c +0 −74
59 59
/* extern */
60 60
61 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 62
compileregexps(void) {
77 63
	unsigned int i;
78 64
	regex_t *reg;
97 83
				regexps[i].tagregex = reg;
98 84
		}
99 85
	}
100 -
}
101 -
102 -
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 86
}
119 87
120 88
void
189 157
		focus(c);
190 158
	}
191 159
	restack();
192 -
}
193 -
194 -
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 160
}
235 161
236 162
void