Package: xwit / 3.4-16

0011-some-code-cleanup.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
From 0cada55f2cb31e423ab83269f4052c67a270bcd8 Mon Sep 17 00:00:00 2001
From: "Bernhard R. Link" <brlink@debian.org>
Date: Sun, 3 Jan 2010 21:11:07 +0100
Subject: some code cleanup

---
 ClientWin.c |   12 ++-----
 ClientWin.h |    2 +
 dsimple.c   |   76 +-------------------------------------------------
 xwit.c      |   89 ++++++++++++++++++----------------------------------------
 4 files changed, 35 insertions(+), 144 deletions(-)
 create mode 100644 ClientWin.h

diff --git a/ClientWin.c b/ClientWin.c
index d472fbf..973eaef 100644
--- a/ClientWin.c
+++ b/ClientWin.c
@@ -17,14 +17,13 @@
 
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
+#include "ClientWin.h"
 
-static Window TryChildren();
+static Window TryChildren(Display *,Window,Atom);
 
 /* Find a window with WM_STATE, else return win itself, as per ICCCM */
 
-Window XmuClientWindow (dpy, win)
-    Display *dpy;
-    Window win;
+Window XmuClientWindow (Display *dpy,Window win)
 {
     Atom WM_STATE;
     Atom type = None;
@@ -47,10 +46,7 @@ Window XmuClientWindow (dpy, win)
 }
 
 static
-Window TryChildren (dpy, win, WM_STATE)
-    Display *dpy;
-    Window win;
-    Atom WM_STATE;
+Window TryChildren (Display *dpy, Window win, Atom WM_STATE)
 {
     Window root, parent;
     Window *children;
diff --git a/ClientWin.h b/ClientWin.h
new file mode 100644
index 0000000..6bab5f5
--- /dev/null
+++ b/ClientWin.h
@@ -0,0 +1,2 @@
+
+Window XmuClientWindow (Display *dpy,Window win);
diff --git a/dsimple.c b/dsimple.c
index b4819cd..5dc11f2 100644
--- a/dsimple.c
+++ b/dsimple.c
@@ -59,8 +59,6 @@ char *program_name = "unknown_program";
 Display *dpy;
 int screen;
 
-static void _bitmap_error(int, char *);
-
 /*
  * Malloc: like malloc but handles out of memory using Fatal_Error.
  */
@@ -184,59 +182,6 @@ void Beep()
 	XBell(dpy, 50);
 }
 
-
-/*
- * ReadBitmapFile: same as XReadBitmapFile except it returns the bitmap
- *                 directly and handles errors using Fatal_Error.
- */
-static void _bitmap_error(status, filename)
-     int status;
-     char *filename;
-{
-  if (status == BitmapOpenFailed)
-    Fatal_Error("Can't open file %s!", filename);
-  else if (status == BitmapFileInvalid)
-    Fatal_Error("file %s: Bad bitmap format.", filename);
-  else
-    Fatal_Error("Out of memory!");
-}
-
-Pixmap ReadBitmapFile(d, filename, width, height, x_hot, y_hot)
-     Drawable d;
-     char *filename;
-     int *width, *height, *x_hot, *y_hot;
-{
-  Pixmap bitmap;
-  int status;
-
-  status = XReadBitmapFile(dpy, RootWindow(dpy, screen), filename,
-			   (unsigned int *)width, (unsigned int *)height,
-			   &bitmap, x_hot, y_hot);
-  if (status != BitmapSuccess)
-    _bitmap_error(status, filename);
-
-  return(bitmap);
-}
-
-
-/*
- * WriteBitmapFile: same as XWriteBitmapFile except it handles errors
- *                  using Fatal_Error.
- */
-void WriteBitmapFile(filename, bitmap, width, height, x_hot, y_hot)
-     char *filename;
-     Pixmap bitmap;
-     int width, height, x_hot, y_hot;
-{
-  int status;
-
-  status= XWriteBitmapFile(dpy, filename, bitmap, width, height, x_hot,
-			   y_hot);
-  if (status != BitmapSuccess)
-    _bitmap_error(status, filename);
-}
-
-
 /*
  * Select_Window_Args: a rountine to provide a common interface for
  *                     applications that need to allow the user to select one
@@ -458,7 +403,7 @@ Window Window_With_Name(dpy, top, name)
 {
 	Window *children, dummy;
 	unsigned int nchildren;
-	int i;
+	unsigned int i;
 	Window w=0;
 	char *window_name;
 
@@ -478,25 +423,6 @@ Window Window_With_Name(dpy, top, name)
 }
 
 /*
- * outl: a debugging routine.  Flushes stdout then prints a message on stderr
- *       and flushes stderr.  Used to print messages when past certain points
- *       in code so we can tell where we are.  Outl may be invoked like
- *       printf with up to 7 arguments.
- */
-void
-outl(char *msg, ...)
-{
-	va_list args;
-	fflush(stdout);
-	va_start(args, msg);
-	vfprintf(stderr, msg, args);
-	va_end(args);
-	fprintf(stderr, "\n");
-	fflush(stderr);
-}
-
-
-/*
  * Standard fatal error routine - call like printf but maximum of 7 arguments.
  * Does not require dpy or screen defined.
  */
diff --git a/xwit.c b/xwit.c
index 4c7e6d6..955eae6 100644
--- a/xwit.c
+++ b/xwit.c
@@ -35,8 +35,7 @@
 #include <stdlib.h>
 #include <sys/time.h>
 #include "dsimple.h"
-
-Window XmuClientWindow();
+#include "ClientWin.h"
 
 /* note: called by dsimple.c code, must be global */
 void
@@ -131,14 +130,13 @@ static int Gbs, Gsu;
 static int Gwinfound;
 
 /* forward declarations */
-static void doit();
+static void doit(Window);
 
 /*
  * sleep for given millisecs for those without usleep
  */
 static void
-mssleep(ms)
-int ms;
+mssleep(int ms)
 {
     struct timeval tv;
     tv.tv_sec = ms/1000;
@@ -156,10 +154,10 @@ static Bool MyFetchName(Display *display, Window w, unsigned char **name)
 	unsigned long bytesAfterReturn;
 	unsigned char *data;
 
-	if( Success != XGetWindowProperty(display, w, property, 
-				0, (long)BUFSIZ, False, 
+	if( Success != XGetWindowProperty(display, w, property,
+				0, (long)BUFSIZ, False,
 				XA_STRING,
-				&returnedType, &returnedFormat, 
+				&returnedType, &returnedFormat,
 				&number, &bytesAfterReturn, &data)) {
 		*name = NULL;
 		return False;
@@ -178,8 +176,7 @@ static Bool MyFetchName(Display *display, Window w, unsigned char **name)
  * find all windows below this and if name matches call doit on it
  */
 static void
-downtree(top)
-Window top;
+downtree(Window top)
 {
     Window *child, dummy;
     unsigned int children, i;
@@ -190,7 +187,7 @@ Window top;
     for (i=0; i<children; i++)
     if(MyFetchName (dpy, child[i], &name)){
 	for(cpp = names;*cpp!=0;cpp++)
-	    if(strncmp(*cpp,name,strlen(*cpp))==0){
+	    if(strncmp(*cpp, (char*)name, strlen(*cpp))==0){
 		doit(child[i]);
 		break;
 	    }
@@ -205,7 +202,7 @@ Window top;
  * [un]set autorepeat for individual keys
  */
 static void
-setrepeat()
+setrepeat(void)
 {
     unsigned long value_mask;
     XKeyboardControl values;
@@ -227,9 +224,7 @@ setrepeat()
  * (based on xwininfo.c)
  */
 static void
-getpos(window, xp, yp)
-	Window window;
-	int *xp, *yp;
+getpos(Window window, int *xp, int *yp)
 {
 	XWindowAttributes attributes;
 	int rx, ry;
@@ -250,9 +245,7 @@ getpos(window, xp, yp)
  * get window size
  */
 static void
-getsize(window, wp, hp)
-	Window window;
-	int *wp, *hp;
+getsize(Window window, int *wp, int *hp)
 {
 	XWindowAttributes attributes;
 
@@ -267,10 +260,7 @@ getsize(window, wp, hp)
  * set window position
  */
 static void
-domove(window, x, y, right, bottom)
-	Window window;
-	int x, y;
-	int right, bottom;
+domove(Window window, int x, int y, int right, int bottom)
 {
 	XWindowChanges values;
 	unsigned int value_mask;
@@ -371,9 +361,7 @@ doprint(Window window)
  * set window size
  */
 static void
-doresize(window, w, h)
-    Window window;
-    int w, h;
+doresize(Window window, int w, int h)
 {
     XWindowChanges values;
     unsigned int value_mask;
@@ -415,9 +403,7 @@ doresize(window, w, h)
  * set row/column size
  */
 static void
-rcresize(what, window)
-    enum functions what;
-    Window window;
+rcresize(enum functions what, Window window)
 {
     XSizeHints *hints;
     long supplied;
@@ -447,10 +433,7 @@ rcresize(what, window)
 }
 
 static void
-loadbitmap(window, file, pmp)
-	Window window;
-	char *file;
-	Pixmap *pmp;
+loadbitmap(Window window, const char *file, Pixmap *pmp)
 {
 	unsigned int w, h;
 	int xhot, yhot;
@@ -461,8 +444,7 @@ loadbitmap(window, file, pmp)
 }
 
 static void
-setbitmap(window)
-	Window window;
+setbitmap(Window window)
 {
 	static XWMHints *hints;
 	static Pixmap bitmap_pm;
@@ -501,8 +483,7 @@ setbitmap(window)
 }
 
 static void
-setwinattr(window)
-	Window window;
+setwinattr(Window window)
 {
 	XSetWindowAttributes swa;
 	unsigned long valuemask;
@@ -526,8 +507,7 @@ setwinattr(window)
  * iconify the given window, or map and raise it, or whatever
  */
 static void
-doit(window)
-	Window window;
+doit(Window window)
 {
 	XWindowChanges values;
 	unsigned int value_mask;
@@ -689,9 +669,7 @@ doit(window)
 
 /* based on xwininfo.c */
 static Window
-xwit_select_window(dpy, current)
-	Display *dpy;
-	int current;
+xwit_select_window(Display *dpy, int current)
 {
 	Window window = None;
 	Window wroot;
@@ -720,8 +698,7 @@ xwit_select_window(dpy, current)
 }
 
 static Window
-getxid(s)
-	char *s;
+getxid(const char *s)
 {
 	XID id;
 
@@ -735,15 +712,12 @@ getxid(s)
 }
 
 static int
-matchopt(key, nargs, argc, argv)
-	char *key;
-	int nargs;
-	int *argc;
-	char **argv;
+matchopt(const char *key, int nargs, int *argc, char **argv)
 {
 	int enough = 0;
 	int match = 1;
-	char *ap, *kp;
+	char *ap;
+	const char *kp;
 
 	ap = *argv;
 	if (*ap == '-')
@@ -808,10 +782,8 @@ matchopt(key, nargs, argc, argv)
 	return match;
 }
 
-void
-FetchBuffer( dpy, nbuf )
-	Display *dpy;
-	int nbuf;
+static void
+FetchBuffer(Display *dpy, int nbuf)
 {
         char *buf;
         int size;
@@ -824,10 +796,8 @@ FetchBuffer( dpy, nbuf )
                 fwrite( buf, 1, size, stdout );
 }
 
-void
-StoreBuffer( dpy, nbuf )
-	Display *dpy;
-	int nbuf;
+static void
+StoreBuffer(Display *dpy, int nbuf)
 {
         char *buf = NULL;
         int bufsize, nread, total=0;
@@ -847,9 +817,7 @@ StoreBuffer( dpy, nbuf )
 char *allwindows[] = {""};
 
 int
-main(argc, argv)
-	int argc;
-	char **argv;
+main(int argc, char *argv[])
 {
 	Window window = 0;
 	int *pargc = &argc;
@@ -1094,7 +1062,6 @@ main(argc, argv)
 	case WID_env:
 		{
 			char *s;
-			extern char *getenv();
 
 			s = getenv("WINDOWID");
 			if (s != 0)