Debian Codegraph @

distro/dev-tools/patches/rxvt-unicode-9.14.diff

raw
1 Copyright (C) 2007 Kan-Ru Chen <koster AT debian DOT org>
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
17 This patch will make rxvt-unicode to use hime protocol, make rxvt-unicode to
18 depend on libhime-im-client.so.1, and let hime works like GTK+ / Qt immodule.
19
20 Unpatched rxvt-unicode still can use hime via XIM protocol.
21
22 Usage: ./configure --disable-xim
23
24 Note that you need hime's headers: hime-im-client.h
25 hime-im-client-attr.h
26 Also make sure that your library path can found libhime-im-client.so.1.
27
28 --- rxvt-unicode-9.14.orig/README.hime
29 +++ rxvt-unicode-9.14/README.hime
30 @@ -0,0 +1 @@
31 +./configure --disable-xim
32 --- rxvt-unicode-9.14.orig/src/Makefile.in
33 +++ rxvt-unicode-9.14/src/Makefile.in
34 @@ -17,8 +17,8 @@
35 CXXFLAGS = @CXXFLAGS@
36 CPPFLAGS = @CPPFLAGS@
37 LDFLAGS = @LDFLAGS@
38 -DEFS = @DEFS@
39 -LIBS = @LIBS@
40 +DEFS = @DEFS@ -DUSE_HIME -DUNIX=1
41 +LIBS = @LIBS@ -lhime-im-client -L$(libdir)/hime
42 XINC = @X_CFLAGS@ @AFTERIMAGE_CFLAGS@ @PIXBUF_CFLAGS@ @STARTUP_NOTIFICATION_CFLAGS@
43 XLIB = @X_LIBS@ @AFTERIMAGE_LIBS@ -lX11 @X_EXTRA_LIBS@ @PIXBUF_LIBS@ @STARTUP_NOTIFICATION_LIBS@
44 COMPILE = $(CXX) -I.. -I$(srcdir) -I. -I$(srcdir)/../libev -I$(srcdir)/../libptytty/src -I$(srcdir)/../libecb $(DEFS) $(CPPFLAGS) $(CXXFLAGS) $(XINC)
45 --- rxvt-unicode-9.14.orig/src/command.C
46 +++ rxvt-unicode-9.14/src/command.C
47 @@ -475,6 +475,36 @@
48 valid_keysym = status_return == XLookupKeySym
49 || status_return == XLookupBoth;
50 }
51 +#endif
52 +#ifdef USE_HIME
53 + if (Hime_Handle)
54 + {
55 + char *rstr = NULL;
56 + len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose);
57 + // valid_keysym = 1;
58 + valid_keysym = keysym != NoSymbol;
59 + if (hime_im_client_forward_key_press (Hime_Handle, keysym, ev.state, &rstr))
60 + {
61 + if (rstr)
62 + {
63 + len = strlen (rstr);
64 + strncpy (kbuf, rstr, len);
65 + kbuf[len] = '\0';
66 + keysym = ' ';
67 + shft = ctrl = meta = 0;
68 + }
69 + else
70 + {
71 +#if 0
72 + len = 0;
73 + valid_keysym = 0;
74 +#endif
75 + return;
76 + }
77 + }
78 + if (rstr)
79 + free (rstr);
80 + }
81 else
82 #endif
83 {
84 @@ -860,10 +890,13 @@
85 void
86 rxvt_term::key_release (XKeyEvent &ev)
87 {
88 -#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL
89 +#ifdef USE_HIME
90 KeySym keysym;
91
92 keysym = XLookupKeysym (&ev, ev.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/
93 + char *rstr = NULL;
94 + hime_im_client_forward_key_release (Hime_Handle, keysym, ev.state, &rstr);
95 + free (rstr);
96 #endif
97
98 #if ENABLE_FRILLS || ISO_14755
99 @@ -989,7 +1022,7 @@
100
101 scr_refresh ();
102 scrollBar.show (1);
103 -#ifdef USE_XIM
104 +#ifdef USE_HIME
105 im_send_spot ();
106 #endif
107 }
108 @@ -1739,6 +1772,15 @@
109 XSetICFocus (Input_Context);
110 }
111 #endif
112 +#ifdef USE_HIME
113 + if (Hime_Handle != NULL)
114 + {
115 +#if 0
116 + IMSetPosition ();
117 +#endif
118 + hime_im_client_focus_in(Hime_Handle);
119 + }
120 +#endif
121 #if CURSOR_BLINK
122 if (option (Opt_cursorBlink))
123 cursor_blink_ev.again ();
124 @@ -1784,6 +1826,10 @@
125 if (Input_Context != NULL)
126 XUnsetICFocus (Input_Context);
127 #endif
128 +#ifdef USE_HIME
129 + if (Hime_Handle != NULL)
130 + hime_im_client_focus_out(Hime_Handle);
131 +#endif
132 #if CURSOR_BLINK
133 if (option (Opt_cursorBlink))
134 cursor_blink_ev.stop ();
135 --- rxvt-unicode-9.14.orig/src/init.C
136 +++ rxvt-unicode-9.14/src/init.C
137 @@ -1022,7 +1022,7 @@
138 {
139 set_environ (envv);
140
141 -#ifdef USE_XIM
142 +#ifdef USE_HIME
143 if (!locale)
144 rxvt_warn ("setting locale failed, continuing without locale support.\n");
145 else
146 @@ -1536,7 +1536,7 @@
147
148 XSelectInput (dpy, top,
149 KeyPressMask
150 -#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ENABLE_FRILLS || ISO_14755
151 +#ifdef USE_HIME
152 | KeyReleaseMask
153 #endif
154 | FocusChangeMask | VisibilityChangeMask
155 @@ -1669,6 +1669,9 @@
156 if ((*t)->pty->pty > 2) close ((*t)->pty->pty);
157 if ((*t)->pty->tty > 2) close ((*t)->pty->tty);
158 }
159 +#ifdef USE_HIME
160 + close (Hime_Handle->fd);
161 +#endif
162
163 run_child (argv);
164 fprintf (stderr, "%s: unable to exec child.", RESNAME);
165 --- rxvt-unicode-9.14.orig/src/main.C
166 +++ rxvt-unicode-9.14/src/main.C
167 @@ -176,7 +176,7 @@
168 rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this),
169 #endif
170 scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this),
171 -#ifdef USE_XIM
172 +#ifdef USE_HIME
173 im_ev.set <rxvt_term, &rxvt_term::im_cb> (this),
174 #endif
175 #ifdef POINTER_BLANK
176 @@ -314,7 +314,7 @@
177
178 if (display)
179 {
180 -#if USE_XIM
181 +#ifdef USE_HIME
182 im_ev.stop (display);
183 #endif
184 scrollbar_ev.stop (display);
185 @@ -1123,7 +1123,7 @@
186 /* -------------------------------------------------------------------- *
187 * - X INPUT METHOD ROUTINES - *
188 * -------------------------------------------------------------------- */
189 -#ifdef USE_XIM
190 +#ifdef USE_HIME
191
192 void
193 rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg)
194 @@ -1166,6 +1166,11 @@
195 Window win;
196 char server[IMBUFSIZ];
197
198 +#ifdef USE_HIME
199 + if (Hime_Handle)
200 + return True;
201 +#endif
202 +#ifdef USE_XIM
203 /* get current locale modifier */
204 if (char *p = XSetLocaleModifiers (0))
205 {
206 @@ -1181,6 +1186,7 @@
207 if (win != None)
208 return true;
209 }
210 +#endif
211
212 return false;
213 }
214 @@ -1191,9 +1197,7 @@
215 XPoint nspot;
216 XVaNestedList preedit_attr;
217
218 - if (!Input_Context
219 - || !focus
220 - || !(input_style & (XIMPreeditPosition | XIMPreeditCallbacks)))
221 + if (!focus || !Hime_Handle)
222 return;
223
224 im_set_position (nspot);
225 @@ -1203,11 +1207,13 @@
226
227 spot = nspot;
228
229 - preedit_attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL);
230 - XSetICValues (Input_Context, XNPreeditAttributes, preedit_attr, NULL);
231 - XFree (preedit_attr);
232 +#ifdef USE_HIME
233 + if (Hime_Handle)
234 + hime_im_client_set_cursor_location(Hime_Handle, nspot.x, nspot.y);
235 +#endif
236 }
237
238 +#ifdef USE_XIM
239 void
240 rxvt_term::im_destroy ()
241 {
242 @@ -1222,6 +1228,7 @@
243
244 Input_Context = 0;
245 }
246 +#endif
247
248 #ifdef ENABLE_XIM_ONTHESPOT
249
250 @@ -1304,6 +1311,10 @@
251 bool
252 rxvt_term::im_get_ic (const char *modifiers)
253 {
254 +#ifdef USE_HIME
255 + Hime_Handle = hime_im_client_open(display->dpy);
256 + hime_im_client_set_window(Hime_Handle, parent);
257 +#else
258 int i, j, found;
259 XIM xim;
260 XPoint spot;
261 @@ -1511,6 +1522,7 @@
262 #endif
263
264 im_set_position ();
265 +#endif
266
267 return true;
268 }
269 @@ -1518,6 +1530,7 @@
270 void
271 rxvt_term::im_cb ()
272 {
273 +#ifdef USE_XIM
274 int i;
275 const char *p;
276 char **s;
277 @@ -1561,6 +1574,7 @@
278 if (found)
279 goto done;
280 }
281 +#endif
282
283 /* try with XMODIFIERS env. var. */
284 if (im_get_ic (""))
285 @@ -1577,6 +1591,7 @@
286 #endif
287 }
288
289 +#ifdef USE_XIM
290 void
291 rxvt_term::im_set_position ()
292 {
293 @@ -1620,6 +1635,7 @@
294
295 XFree (preedit_attr);
296 }
297 +#endif
298 #endif /* USE_XIM */
299
300 void
301 --- rxvt-unicode-9.14.orig/src/rxvt.h
302 +++ rxvt-unicode-9.14/src/rxvt.h
303 @@ -90,6 +90,10 @@
304 # define HAVE_BG_PIXMAP 1
305 #endif
306
307 +#ifdef USE_HIME
308 +#include <hime-im-client.h>
309 +#endif
310 +
311 #include "encoding.h"
312 #include "rxvtutil.h"
313 #include "rxvtfont.h"
314 @@ -1329,6 +1333,8 @@
315 rxvt_xim *input_method;
316 XIC Input_Context;
317 XIMStyle input_style;
318 +#endif
319 +#ifdef USE_HIME
320 XPoint spot; // most recently sent spot position
321
322 void im_destroy ();
323 @@ -1343,6 +1349,9 @@
324 bool im_get_ic (const char *modifiers);
325 void im_set_position ();
326 #endif
327 +#ifdef USE_HIME
328 + HIME_client_handle *Hime_Handle;
329 +#endif
330
331 // command.C
332 void key_press (XKeyEvent &ev);
333 --- rxvt-unicode-9.14.orig/src/rxvttoolkit.C
334 +++ rxvt-unicode-9.14/src/rxvttoolkit.C
335 @@ -64,8 +64,10 @@
336 "_NET_WM_PING",
337 "_NET_WM_ICON",
338 #endif
339 -#if USE_XIM
340 +#ifdef USE_HIME
341 "WM_LOCALE_NAME",
342 +#endif
343 +#ifdef USE_XIM
344 "XIM_SERVERS",
345 #endif
346 #ifdef ENABLE_TRANSPARENCY
347 @@ -520,13 +522,15 @@
348 XCloseDisplay (dpy);
349 }
350
351 -#ifdef USE_XIM
352 +#ifdef USE_HIME
353 void rxvt_display::im_change_cb ()
354 {
355 for (im_watcher **i = imw.begin (); i != imw.end (); ++i)
356 (*i)->call ();
357 }
358 +#endif
359
360 +#ifdef USE_XIM
361 void rxvt_display::im_change_check ()
362 {
363 // try to only call im_change_cb when a new input method
364 @@ -625,7 +629,7 @@
365 cur_owner = owner;
366 }
367
368 -#ifdef USE_XIM
369 +#ifdef USE_HIME
370
371 void rxvt_display::reg (im_watcher *w)
372 {
373 @@ -636,7 +640,9 @@
374 {
375 imw.erase (find (imw.begin (), imw.end (), w));
376 }
377 +#endif
378
379 +#ifdef USE_XIM
380 rxvt_xim *rxvt_display::get_xim (const char *locale, const char *modifiers)
381 {
382 char *id;
383 --- rxvt-unicode-9.14.orig/src/rxvttoolkit.h
384 +++ rxvt-unicode-9.14/src/rxvttoolkit.h
385 @@ -64,8 +64,10 @@
386 XA_NET_WM_PING,
387 XA_NET_WM_ICON,
388 #endif
389 -#if USE_XIM
390 +#ifdef USE_HIME
391 XA_WM_LOCALE_NAME,
392 +#endif
393 +#ifdef USE_XIM
394 XA_XIM_SERVERS,
395 #endif
396 #if ENABLE_TRANSPARENCY
397 @@ -227,9 +229,13 @@
398
399 #ifdef USE_XIM
400 refcache<rxvt_xim> xims;
401 +#endif
402 +#ifdef USE_HIME
403 vector<im_watcher *> imw;
404
405 void im_change_cb ();
406 +#endif
407 +#ifdef USE_XIM
408 void im_change_check ();
409 #endif
410
411 @@ -262,16 +268,18 @@
412 void reg (xevent_watcher *w);
413 void unreg (xevent_watcher *w);
414
415 -#ifdef USE_XIM
416 +#ifdef USE_HIME
417 void reg (im_watcher *w);
418 void unreg (im_watcher *w);
419 +#endif
420
421 +#ifdef USE_XIM
422 rxvt_xim *get_xim (const char *locale, const char *modifiers);
423 void put_xim (rxvt_xim *xim);
424 #endif
425 };
426
427 -#ifdef USE_XIM
428 +#ifdef USE_HIME
429 struct im_watcher : rxvt_watcher, callback<void (void)>
430 {
431 void start (rxvt_display *display)
432 --- rxvt-unicode-9.14.orig/src/screen.C
433 +++ rxvt-unicode-9.14/src/screen.C
434 @@ -3531,7 +3531,7 @@
435 }
436
437 /* ------------------------------------------------------------------------- */
438 -#ifdef USE_XIM
439 +#ifdef USE_HIME
440 void
441 rxvt_term::im_set_position (XPoint &pos) NOTHROW
442 {