File: old.patch

package info (click to toggle)
xwit 3.4-10
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 172 kB
  • ctags: 121
  • sloc: ansic: 1,230; makefile: 65
file content (290 lines) | stat: -rw-r--r-- 6,203 bytes parent folder | download | duplicates (2)
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
This is the patch from the old xwit package from Dima Barsky <dima@debian.org>.

The relevant changelog entries are: 
Added -focus option (Thanks to Michael Mauch <michael.mauch@gmx.de> for the patch)
Added -fetch and -store options to access cutbuffers (Closes: #38379)
Some code clean-up to get rid of compilation warnings

diff -u xwit-3.4.orig/xwit.c xwit-3.4/xwit.c
--- xwit-3.4.orig/xwit.c	1997-10-21 03:32:54.000000000 +0200
+++ xwit-3.4/xwit.c	2005-10-21 12:38:48.000000000 +0200
@@ -31,10 +31,14 @@
 #include <X11/Xutil.h>
 #include <X11/Xproto.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/time.h>
 #include "dsimple.h"
 
+Window XmuClientWindow();
+
 /* note: called by dsimple.c code, must be global */
+void
 usage()
 {
 	static char Revision[] = "$Revision: 3.4 $";
@@ -58,7 +62,7 @@
 
 	fprintf(stderr,
 	"usage: %s -display <display> -sync\n\
-	-pop -iconify -unmap\n\
+	-pop -focus -iconify -unmap\n\
 	-resize w h -rows r -columns c -[r]move x y\n\
 	-[r]warp x y -colormap <colormapid> -[no]save\n\
 	-name <name> -iconname <name>\n\
@@ -72,7 +76,7 @@
 }
 
 enum functions {
-    pop, icon, unmap, colormap,
+    pop, focus, icon, unmap, colormap,
     move, rmove, warp, rwarp,
     resize, save, nosave,
     keyrepeat, nokeyrepeat,
@@ -114,6 +118,7 @@
 static int Giconx, Gicony;
 static int nrows;
 static int ncolumns;
+static int nbuffer;
 static char *bitmapname;
 static char *maskname;
 static int Gbs, Gsu;
@@ -127,20 +132,20 @@
 /*
  * sleep for given millisecs for those without usleep
  */
-static
+static void
 mssleep(ms)
 int ms;
 {
     struct timeval tv;
     tv.tv_sec = ms/1000;
     tv.tv_usec = (ms%1000)*1000;
-    select(0,(int*)0,(int*)0,(int*)0,&tv);
+    select(0,NULL,NULL,NULL,&tv);
 }
 
 /*
  * find all windows below this and if name matches call doit on it
  */
-static
+static void
 downtree(top)
 Window top;
 {
@@ -164,7 +169,7 @@
 /*
  * [un]set autorepeat for individual keys
  */
-static
+static void
 setrepeat()
 {
     unsigned long value_mask;
@@ -186,7 +191,7 @@
  * get window position, compensating for decorations
  * (based on xwininfo.c)
  */
-static
+static void
 getpos(window, xp, yp)
 	Window window;
 	int *xp, *yp;
@@ -209,7 +214,7 @@
 /*
  * get window size
  */
-static
+static void
 getsize(window, wp, hp)
 	Window window;
 	int *wp, *hp;
@@ -226,7 +231,7 @@
 /*
  * set window position
  */
-static
+static void
 domove(window, x, y, right, bottom)
 	Window window;
 	int x, y;
@@ -299,7 +304,7 @@
 /*
  * set window size
  */
-static
+static void
 doresize(window, w, h)
     Window window;
     int w, h;
@@ -343,7 +348,7 @@
 /*
  * set row/column size
  */
-static
+static void
 rcresize(what, window)
     enum functions what;
     Window window;
@@ -375,7 +380,7 @@
     XFree(hints);
 }
 
-static
+static void
 loadbitmap(window, file, pmp)
 	Window window;
 	char *file;
@@ -389,7 +394,7 @@
 		Fatal_Error("XReadBitmapFile failed");
 }
 
-static
+static void
 setbitmap(window)
 	Window window;
 {
@@ -418,7 +423,7 @@
 		XSetCloseDownMode(dpy, RetainTemporary);
 	}
 
-	if (ohints = XGetWMHints(dpy, window)) {
+	if ((ohints = XGetWMHints(dpy, window)) != NULL ) {
 		if (ohints->icon_pixmap && hints->icon_pixmap)
 			XFreePixmap(dpy, ohints->icon_pixmap);
 		if (ohints->icon_mask && hints->icon_mask)
@@ -429,7 +434,7 @@
 	XSetWMHints(dpy, window, hints);
 }
 
-static
+static void
 setwinattr(window)
 	Window window;
 {
@@ -501,6 +506,9 @@
 		case pop:
 			XMapRaised(dpy, window);
 			break;
+		case focus:
+		        XSetInputFocus(dpy, window, CurrentTime, RevertToNone);
+			break;
 		case unmap:
 			XUnmapWindow(dpy, window);
 			break;
@@ -633,6 +641,7 @@
 		return id;
 	Fatal_Error("Invalid ID format: %s", s);
 	/* NOTREACHED */
+        return -1;
 }
 
 static int
@@ -709,6 +718,43 @@
 	return match;
 }
 
+void
+FetchBuffer( dpy, nbuf )
+	Display *dpy;
+	int nbuf;
+{
+        char *buf;
+        int size;
+
+        buf = XFetchBuffer(dpy, &size, nbuf);
+
+        if( size == 0 )
+                fprintf( stderr, "Could not fetch cutbuffer %d\n", nbuf );
+        else
+                fwrite( buf, 1, size, stdout );
+}
+
+void
+StoreBuffer( dpy, nbuf )
+	Display *dpy;
+	int nbuf;
+{
+        char *buf = NULL;
+        int bufsize, nread, total=0;
+
+        bufsize = 10;
+        buf = malloc( bufsize );
+        while( (nread=read(0,buf+total,bufsize-total)) > 0 )
+        {
+                total+=nread;
+                bufsize *= 2;
+                buf = realloc( buf, bufsize );
+        }
+        XStoreBuffer(dpy, buf, total, nbuf);
+        free(buf);
+}
+
+int
 main(argc, argv)
 	int argc;
 	char **argv;
@@ -745,6 +791,14 @@
 			function |= FBIT(columns);
 			ncolumns = atoi(*++argv);
 		}
+		else if (matchopt("store*buffer", 1, pargc, argv)) {
+			nbuffer = atoi(*++argv);
+                        StoreBuffer( dpy, nbuffer );
+		}
+		else if (matchopt("fetch*buffer", 1, pargc, argv)) {
+			nbuffer = atoi(*++argv);
+                        FetchBuffer( dpy, nbuffer );
+		}
 		else if (matchopt("c*urrent", 0, pargc, argv)) {
 			Winidmode = WID_curr;
 		}
@@ -845,6 +899,9 @@
 		else if (matchopt("p*op", 0, pargc, argv)) {
 			function |= FBIT(pop);
 		}
+		else if (matchopt("f*ocus", 0, pargc, argv)) {
+			function |= FBIT(focus);
+		}
 		else if (matchopt("ri*conmove", 2, pargc, argv)) {
 			function |= FBIT(riconmove);
 			Giconx = atoi(argv[1]);
@@ -938,6 +995,8 @@
 	case WID_select:
 		window = xwit_select_window(dpy, 0);
 		break;
+	default:
+	        break;
 	}
 
 	switch (Winidmode) {
@@ -956,5 +1015,6 @@
 
 	XSync(dpy, True);
 	(void) XCloseDisplay(dpy);
-	exit(!Gwinfound);
+	return(!Gwinfound);
 }
+
diff -u xwit-3.4.orig/xwit.man xwit-3.4/xwit.man
--- xwit-3.4.orig/xwit.man	1997-11-12 08:32:56.000000000 +0100
+++ xwit-3.4/xwit.man	2005-10-21 12:38:48.000000000 +0200
@@ -10,6 +10,7 @@
 .IR display ]
 .RB [ -sync ]
 .RB [ -pop ]
+.RB [ -focus ]
 .RB [ -iconify ]
 .RB [ -unmap ]
 .br
@@ -77,6 +78,9 @@
 is the default action.
 It need only be given if it is wanted as well as some other function.
 .TP
+-focus
+will give the input focus to the specified window.
+.TP
 -iconify
 will iconify the windows instead of popping them.
 .TP