summaryrefslogtreecommitdiff
path: root/x11-plugins/fvwmkb/files/fvwmkb-0.3.2-r1.patch
blob: 2428c08aeb211ebcdeef1dd22bcfa9b12578f78d (plain)
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
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..01ddd90
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,23 @@
+aclocal.m4
+autom4te.cache
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+install-sh
+missing
+mkinstalldirs
+stamp-h
+stamp-h.in
+depcomp
+stamp-h1
+
+Makefile
+Makefile.in
+.deps
+
+FvwmKb
+*.o
diff --git a/TODO b/TODO
index e1345e3..d930f10 100644
--- a/TODO
+++ b/TODO
@@ -3,12 +3,10 @@ This file is a part of FvwmKb.
   Copyright (C) 1999 Alexander Vorobiev 
   $Id: TODO,v 1.1.1.1 1999/04/16 14:55:26 sparrow Exp $ 
 
-* Add an ability to accept messages from Fvwm to change locked group - 
-  so it will be possible to change group from menu or clicking
-  titlebar button 
-
 * Make man page
 
 * Add more pixmaps
 
 * Add support for other window managers
+
+* Add suport for autoconf-ing fvwm modules dir
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..82808f9
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+WANT_AUTOMAKE=1.8
+export WANT_AUTOMAKE
+aclocal \
+&& autoheader \
+&& automake -a \
+&& autoheader \
+&& autoconf \
+&& ./configure "$@"
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..1149343
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,82 @@
+dnl This file is a part of FvwmKb.
+dnl   Copyright (C) 1999 Alexander Vorobiev 
+dnl   $Id: configure.in,v 1.4 1999/10/26 20:28:03 sparrow Exp $
+
+AC_INIT([FvwmKb],[0.3.2-git],[hacker@klever.net])
+AC_CONFIG_SRCDIR([src/FvwmKb.cpp])
+AC_CONFIG_HEADER([config.h])
+AM_INIT_AUTOMAKE([dist-bzip2])
+
+AC_MSG_CHECKING([for fvwm module install directory])
+AC_ARG_WITH(moduledir,
+  [  --with-moduledir=DIR    directory in which fvwm modules are installed ],
+  [ case "$withval" in
+    no)
+      AC_MSG_ERROR(Can not disable moduledir.)
+      ;;
+    yes)
+      ;;
+    *)
+      val="$withval"
+      ;;
+    esac ])
+
+FVWM_MODULEDIR="$val"
+AC_MSG_RESULT($FVWM_MODULEDIR)
+AC_SUBST(FVWM_MODULEDIR)
+
+dnl Checks for programs.
+AC_LANG_CPLUSPLUS
+AC_PROG_CXX
+AC_PROG_CXXCPP
+AC_PROG_INSTALL
+
+dnl Checks for libraries.
+AC_CHECK_LIB(stdc++, main)
+
+AC_PATH_X
+AC_PATH_XTRA
+CFLAGS="$X_CFLAGS"
+LDFLAGS="$X_LDFLAGS $X_LIBS" 
+
+AC_CHECK_LIB(X11, XkbOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS")
+x_cflags="$X_CFLAGS"
+x_ldflags="$X_LDFLAGS $X_LIBS"
+
+if test -z "$x_includes"; then
+   x_includes="/usr/include"
+fi
+  
+AC_SUBST(x_cflags)
+AC_SUBST(x_includes)
+AC_SUBST(x_ldflags)
+AC_SUBST(x_libs)       
+
+dnl Checks for header files.
+AC_CHECK_HEADERS(errno.h stdio.h fcntl.h unistd.h limits.h X11/XKBlib.h)
+AC_CHECK_HEADERS(sys/time.h signal.h)
+AC_CHECK_HEADERS(hash_map)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_SIZE_T
+
+AC_MSG_CHECKING([for debug flag])
+dodebug=false
+AC_ARG_ENABLE([debug],
+ AC_HELP_STRING([--enable-debug],[enable debugging code]),
+ [ test "${enableval}" != "no" && dodebug=true ]
+)
+AC_MSG_RESULT([$dodebug])
+AH_TEMPLATE(DEBUG,[ Turning on debugging code ])
+if ${dodebug} ; then
+ AC_DEFINE_UNQUOTED([DEBUG],[1])
+fi
+
+AC_CONFIG_FILES([
+ Makefile
+ src/Makefile
+ doc/Makefile
+ pixmaps/Makefile
+])
+AC_OUTPUT
diff --git a/src/FvwmKb.cpp b/src/FvwmKb.cpp
index 9e7baa9..73b2382 100644
--- a/src/FvwmKb.cpp
+++ b/src/FvwmKb.cpp
@@ -21,7 +21,9 @@
 // Boston, MA 02111-1307 USA 
 
 
-#include <hash_map.h>
+#include <ext/hash_map>
+#include <string>
+using namespace __gnu_cxx;
 #include "FvwmKb.h"
 #include "messages.h"
 #include "ex.h"
@@ -49,7 +51,7 @@ int main(int argc, char **argv)
     
     try {
 	// set up connection
-	Fvwm fvwm(argv[1], argv[2], M_FOCUS_CHANGE | M_DESTROY_WINDOW);
+	Fvwm fvwm(argv[1], argv[2], M_FOCUS_CHANGE | M_DESTROY_WINDOW | M_STRING);
 	
 #ifdef DEBUG
 	fprintf(stderr,"fvwm initialized ok\n", argv[1], argv[2]);
@@ -191,9 +193,27 @@ int main(int argc, char **argv)
 			}
 		    };
 		    break;
+		case evString:
+		    if(ev.strString.find("ToggleGroup")) {
+			// FIXME: At the very beginning ev.windows means nothing
+			if(ev.window != fvwm_no_app_window) {
+				XkbGetState(dpy, XkbUseCoreKbd, &xkbstate);
+				XkbLockGroup(dpy,XkbUseCoreKbd, xkbstate.locked_group^1);
+				XkbGetState(dpy, XkbUseCoreKbd, &xkbstate);
+				WinRecordPtr = WinGroup.find(ev.window);
+				if(WinRecordPtr != WinGroup.end()) {
+				    WinGroup[ev.window] = xkbstate.locked_group;
+				    fvwm.ChangeXkbDecor(xkbstate.locked_group);
+				    last_group = xkbstate.locked_group;
+				}
+			}
+		    }else{
+			fprintf(stderr, "unknown string received from fvwm: %s\n", ev.strString.c_str());
+		    }
+		    break;
 		
 		default: 
-		    fprintf(stderr, "unknown event for window: %ul\n", ev.window);
+		    //fprintf(stderr, "unknown event for window: %ul\n", ev.window);
 		    break;
 		};
 
diff --git a/src/wm.cpp b/src/wm.cpp
index d6973d1..d2f8de5 100644
--- a/src/wm.cpp
+++ b/src/wm.cpp
@@ -22,6 +22,7 @@
 
 
 #include <string.h>
+#include <string>
 #include "FvwmKb.h"
 #include "messages.h"
 #include "ex.h"
@@ -54,7 +55,7 @@ Fvwm::Fvwm(char *sfd, char *rfd, unsigned long mask)
 #ifdef DEBUG
     fprintf(stderr,"message mask sent ok\n");
 #endif // DEBUG    
-   
+    SendPacket("NOP FINISHED STARTUP",0);
 }
 
 Bool Fvwm::PeekEvent(void)
@@ -93,7 +94,7 @@ void Fvwm::ReadEvent(wmEvent *ev)
     readexactE(recfd, header, FVWM_HEADER_SIZE * sizeof(unsigned long));
 
 #ifdef DEBUG
-    fprintf(stderr,"header: [0] = %ul; [1] = %ul; [2] = %ul\n",
+    fprintf(stderr,"header: [0] = 0x%08lX ; [1] = %lu; [2] = %lu\n",
 	    header[0], header[1], header[2]);
 #endif // DEBUG
 
@@ -112,7 +113,19 @@ void Fvwm::ReadEvent(wmEvent *ev)
 	ev->window = Window(body[0]);
     };
     break;
-    default:
+    case M_STRING: {
+	static unsigned long body[sizeof(unsigned long)*256]; // Max body size
+	if(header[1]>=256)
+		// FIXME: Wrong exception to throw
+		throw FvwmUnknownMessageTypeEx(header[0]);
+	else{
+		memset(body,0,sizeof(body));
+		readexactE(recfd,body,(header[1]-4)*sizeof(unsigned long));
+		ev->type = evString;
+		ev->strString = (const char*)body;
+	}
+    };
+    break;
 	throw FvwmUnknownMessageTypeEx(header[0]);
     };
 }
@@ -135,7 +148,7 @@ void Fvwm::ChangeXkbDecor(XkbGroup group)
 // source - http://www.fvwm.org/mod_m2f_communication.html
 // It might be better to rewrite this function accumulating an entire packet
 // in some intermediate buffer (as real SendText does).
-void Fvwm::SendPacket(char *message, Window window)
+void Fvwm::SendPacket(char *message, unsigned long window)
 {
   if (message == NULL)
       return;
@@ -148,16 +161,16 @@ void Fvwm::SendPacket(char *message, Window window)
   writeexactE(sendfd, &window, sizeof(window));
 
 #ifdef DEBUG
-    fprintf(stderr,"window id %ul sent\n", window);
+    fprintf(stderr,"window id %lu sent\n", window);
 #endif // DEBUG  
    
-  size_t len=strlen(message);               // calc the length of the message 
+  unsigned long len=strlen(message);               // calc the length of the message 
   writeexactE(sendfd, &len, sizeof(len));   // send the message length
   writeexactE(sendfd, message, len);        // send the message itself
   
   // send a 1, indicating that this module will keep going 
   // a 0 would mean that this module is done 
-  int flag = 1;
+  unsigned long flag = 1;
   writeexactE(sendfd, &flag, sizeof(flag));
 }
 
diff --git a/src/wm.h b/src/wm.h
index c16ea08..4b584d7 100644
--- a/src/wm.h
+++ b/src/wm.h
@@ -32,12 +32,15 @@
 // generic way though as we have to pass wm-specific arguments.
 
 // generic interface to wm events
-enum wmEventType { evFocusWindow,           // window is focused
-		   evDestroyWindow };       // window is destroyed
+enum wmEventType { evUnknown,
+	           evFocusWindow,           // window is focused
+		   evDestroyWindow,
+		   evString };              // window is destroyed
 
 struct wmEvent {
     wmEventType type;
     Window      window;
+    std::string strString;
 };
 
 
@@ -59,6 +62,7 @@ public:
                                                   // input focus
 #define M_DESTROY_WINDOW ((unsigned long)(1<<7))  // The window has just
                                                   // been destroyed
+#define	M_STRING	 ((unsigned long)(1<<22)) // String has been sent to module
 
 #define FVWM_HEADER_SIZE          3               // fvwm message header size
                                                   // without starting flag