Mercurial > hg > xemacs-beta
annotate src/input-method-xlib.c @ 5391:f9dc75bdbdc4
Implement #'load-time-value less hackishly, by modifying the byte compiler.
2011-04-02 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-output-preface): New.
* bytecomp.el (byte-compile-output-file-form):
* bytecomp.el (byte-compile-output-docform):
* bytecomp.el (byte-compile-file-form):
* bytecomp.el (byte-compile-file-form-defmumble):
* bytecomp.el (symbol-value):
* bytecomp.el (byte-compile-symbol-value): New.
* cl-macs.el (load-time-value):
No longer implement load-time-value by very hackishly redefining
#'byte-compile-file-form-defmumble, instead make the appropriate
changes in #'byte-compile-file-form-defmumble and
#'byte-compile-file-form instead. We also add a specific byte-compile
method for #'symbol-value, using the add-properties-to-a-gensym
approach that worked for #'block and #'return-from.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Sat, 02 Apr 2011 16:13:20 +0100 |
| parents | 0ca81354c4c7 |
| children | 308d34e9f07d |
| rev | line source |
|---|---|
| 428 | 1 /* Various functions for X11R5+ input methods, using the Xlib interface. |
| 2 Copyright (C) 1996 Sun Microsystems. | |
| 5090 | 3 Copyright (C) 2002, 2010 Ben Wing. |
| 428 | 4 |
| 5 This file is part of XEmacs. | |
| 6 | |
| 7 XEmacs is free software; you can redistribute it and/or modify it | |
| 8 under the terms of the GNU General Public License as published by the | |
| 9 Free Software Foundation; either version 2, or (at your option) any | |
| 10 later version. | |
| 11 | |
| 12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 15 for more details. | |
| 16 | |
| 17 You should have received a copy of the GNU General Public License | |
| 18 along with XEmacs; see the file COPYING. If not, write to | |
| 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 20 Boston, MA 02111-1307, USA. */ | |
| 21 | |
| 22 /* Synched up with: Not in FSF. */ | |
| 23 | |
| 24 /* Written by Martin Buchholz. */ | |
| 25 | |
| 26 /* This file implements an interface to X input methods, available | |
| 27 with X11R5 and above. See O'Reilly, Xlib programmer's guide, | |
| 28 and X11 R6 release guide chapters on internationalized input, | |
| 29 for further details */ | |
| 30 | |
| 31 /* | |
| 32 Policy: | |
| 33 | |
| 34 The XIM is of the device, by the device, for the device. | |
| 35 The XIC is of each frame, by each frame, for each frame. | |
| 36 The exceptions are: | |
| 37 1. Activate XICs on poor frames when the XIM is back. | |
| 444 | 38 2. Deactivate all the XICs when the XIM goes down. |
| 428 | 39 |
| 444 | 40 Implementation: |
| 428 | 41 |
| 42 - Register a callback for an XIM when the X device is being initialized. | |
| 43 XIM_init_device (d) { XRegisterIMInstantiateCallback (); } | |
| 44 The "XRegisterIMInstantiateCallback" is called when an XIM become | |
| 45 available on the X display. | |
| 46 | |
| 47 - Catch the XIC when the frame is being initialized if XIM was available. | |
| 48 XIM_init_frame (f) { ... XCreateIC (); ... } | |
| 49 | |
| 50 - Release the XIC when the frame is being closed. | |
| 51 XIM_delete_frame (f) { ... FRAME_X_XIC (f) = NULL; ... } | |
| 52 "XIM_delete_frame" is a "DestroyCallback" function declared in | |
| 53 XIM_init_frame (); | |
| 54 | |
| 55 - Release all the XICs when the XIM was down accidentally. | |
| 56 In IMDestroyCallback: | |
| 57 DEVICE_FRAME_LOOP (...) { FRAME_X_XIC (f) = NULL; } | |
| 58 | |
| 444 | 59 - Re-enable XIC for all the frames which don't have XIC when the XIM |
| 428 | 60 is back. |
| 61 In IMInstantiateCallback: | |
| 62 DEVICE_FRAME_LOOP (...) { XIM_init_frame (f); } | |
| 63 | |
| 64 | |
| 65 Note: | |
| 66 | |
| 67 - Currently, we don't use XDestroyIC because of _XimProtoCloseIM | |
| 68 (internally registered as im->methods->close) does "Xfree (ic)". | |
| 69 | |
| 70 */ | |
| 71 | |
| 72 #include <config.h> | |
| 73 #include "lisp.h" | |
| 872 | 74 |
| 75 #include "buffer.h" | |
| 76 #include "device-impl.h" | |
| 77 #include "events.h" | |
| 78 #include "frame-impl.h" | |
| 79 #include "window-impl.h" | |
| 80 | |
| 81 #include "console-x-impl.h" | |
| 82 #include "EmacsFrame.h" | |
| 83 | |
| 428 | 84 #include <X11/Xlocale.h> /* More portable than <locale.h> ? */ |
| 444 | 85 #include <X11/Xlib.h> |
| 428 | 86 |
| 448 | 87 #if !defined (XIM_XLIB) && !defined (USE_XFONTSET) |
| 88 #error neither XIM_XLIB nor USE_XFONTSET is defined?? | |
| 428 | 89 #endif |
| 90 | |
| 771 | 91 #ifdef XIM_XLIB /* XIM_XLIB specific */ |
| 428 | 92 |
| 93 /* Get/Set IC values for just one attribute */ | |
| 94 #ifdef DEBUG_XEMACS | |
| 95 #define XIC_Value(Get_Set, xic, name, attr, value) \ | |
| 96 do { \ | |
| 97 char *bad_arg; \ | |
| 98 XVaNestedList list = XVaCreateNestedList (0, attr, value, NULL); \ | |
| 99 if ((bad_arg = X##Get_Set##ICValues (xic, name, list, NULL)) != NULL) \ | |
| 100 stderr_out ("X" #Get_Set "ICValues " "bad Arg: %s\n", bad_arg); \ | |
| 101 XFree (list); \ | |
| 102 } while (0) | |
| 103 #else /* ! DEBUG_XEMACS */ | |
| 104 #define XIC_Value(Get_Set, xic, name, attr, value) \ | |
| 105 do { \ | |
| 106 XVaNestedList list = XVaCreateNestedList (0, attr, value, NULL); \ | |
| 107 X##Get_Set##ICValues (xic, name, list, NULL); \ | |
| 108 XFree (list); \ | |
| 109 } while (0) | |
| 110 #endif /* DEBUG_XEMACS */ | |
| 111 | |
| 112 static char DefaultXIMStyles[] = | |
| 113 "XIMPreeditPosition|XIMStatusArea\n" | |
| 114 "XIMPreeditPosition|XIMStatusNone\n" | |
| 115 "XIMPreeditPosition|XIMStatusNothing\n" | |
| 116 "XIMPreeditNothing|XIMStatusArea\n" | |
| 117 "XIMPreeditNothing|XIMStatusNothing\n" | |
| 118 "XIMPreeditNothing|XIMStatusNone\n" | |
| 119 "XIMPreeditNone|XIMStatusArea\n" | |
| 120 "XIMPreeditNone|XIMStatusNothing\n" | |
| 121 "XIMPreeditNone|XIMStatusNone"; | |
| 122 | |
| 123 static XIMStyle best_style (XIMStyles *user, XIMStyles *xim); | |
| 771 | 124 |
| 448 | 125 #endif /* XIM_XLIB only */ |
| 428 | 126 |
| 444 | 127 /* This function is documented, but no prototype in the header files */ |
| 128 EXTERN_C char * XSetIMValues(XIM, ...); | |
| 442 | 129 |
| 448 | 130 #ifdef XIM_XLIB /* starting XIM specific codes */ |
| 131 | |
| 444 | 132 /* Callbacks for IM are supported from X11R6 or later. */ |
| 133 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK | |
| 134 | |
| 135 static Boolean xim_initted = False; | |
| 136 | |
| 428 | 137 /* Called from when XIM is destroying. |
| 138 Clear all the XIC when the XIM was destroying... */ | |
| 139 static void | |
| 2286 | 140 IMDestroyCallback (XIM UNUSED (im), XPointer client_data, |
| 141 XPointer UNUSED (call_data)) | |
| 428 | 142 { |
| 143 struct device *d = (struct device *)client_data; | |
| 144 Lisp_Object tail; | |
| 145 | |
| 146 DEVICE_FRAME_LOOP (tail, d) | |
| 147 { | |
| 148 struct frame *target_frame = XFRAME (XCAR (tail)); | |
| 149 if (FRAME_X_P (target_frame) && FRAME_X_XIC (target_frame)) | |
| 150 { | |
| 151 /* XDestroyIC (FRAME_X_XIC (target_frame)); */ | |
| 152 FRAME_X_XIC (target_frame) = NULL; | |
| 153 } | |
| 154 } | |
| 155 | |
| 156 DEVICE_X_XIM (d) = NULL; | |
| 157 xim_initted = False; | |
| 158 return; | |
| 159 } | |
| 160 | |
| 161 /* This is registered in XIM_init_device (when DEVICE is initializing). | |
| 162 This activates XIM when XIM becomes available. */ | |
| 163 static void | |
| 2286 | 164 IMInstantiateCallback (Display *dpy, XPointer client_data, |
| 165 XPointer UNUSED (call_data)) | |
| 428 | 166 { |
| 167 struct device *d = (struct device *)client_data; | |
| 168 XIM xim; | |
| 1204 | 169 char *name, *class_; |
| 428 | 170 XIMCallback ximcallback; |
| 171 Lisp_Object tail; | |
| 172 | |
| 173 /* if no xim is presented, initialize xim ... */ | |
| 174 if ( xim_initted == False ) | |
| 175 { | |
| 176 xim_initted = True; | |
| 1204 | 177 XtGetApplicationNameAndClass (dpy, &name, &class_); |
| 178 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class_); | |
| 428 | 179 |
| 180 /* destroy callback for im */ | |
| 444 | 181 ximcallback.callback = (XIMProc) IMDestroyCallback; |
| 428 | 182 ximcallback.client_data = (XPointer) d; |
| 183 XSetIMValues (xim, XNDestroyCallback, &ximcallback, NULL); | |
| 184 } | |
| 185 | |
| 186 /* activate XIC on all the X frames... */ | |
| 187 DEVICE_FRAME_LOOP (tail, d) | |
| 188 { | |
| 189 struct frame *target_frame = XFRAME (XCAR (tail)); | |
| 190 if (FRAME_X_P (target_frame) && !FRAME_X_XIC (target_frame)) | |
| 191 { | |
| 192 XIM_init_frame (target_frame); | |
| 193 } | |
| 194 } | |
| 195 return; | |
| 196 } | |
| 444 | 197 #endif /* HAVE_XREGISTERIMINSTANTIATECALLBACK */ |
| 428 | 198 |
| 199 /* Initialize XIM for X device. | |
| 200 Register the use of XIM using XRegisterIMInstantiateCallback. */ | |
| 201 void | |
| 202 XIM_init_device (struct device *d) | |
| 203 { | |
| 444 | 204 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK /* X11R6+ */ |
| 428 | 205 DEVICE_X_XIM (d) = NULL; |
| 206 XRegisterIMInstantiateCallback (DEVICE_X_DISPLAY (d), NULL, NULL, NULL, | |
| 444 | 207 #ifdef XREGISTERIMINSTANTIATECALLBACK_NONSTANDARD_PROTOTYPE |
| 442 | 208 /* The sixth parameter is of type |
| 209 XPointer in XFree86 but (XPointer *) | |
| 210 on most other X11's. */ | |
| 444 | 211 (XIDProc) IMInstantiateCallback, |
| 212 (XPointer) d | |
| 213 #else /* X Consortium prototype */ | |
| 214 (XIMProc) IMInstantiateCallback, | |
| 215 (XPointer *) d | |
| 216 #endif /* XREGISTERIMINSTANTIATECALLBACK_NONSTANDARD_PROTOTYPE */ | |
| 217 ); | |
| 428 | 218 return; |
| 444 | 219 #else /* pre-X11R6 */ |
| 428 | 220 Display *dpy = DEVICE_X_DISPLAY (d); |
| 1204 | 221 char *name, *class_; |
| 428 | 222 XIM xim; |
| 223 | |
| 1204 | 224 XtGetApplicationNameAndClass (dpy, &name, &class_); |
| 225 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class_); | |
| 428 | 226 if (xim == NULL) |
| 227 { | |
| 793 | 228 warn_when_safe |
| 229 (Qxintl, Qerror, | |
| 230 "Can't initialize XIM: XOpenIM() failed, no input server available"); | |
| 428 | 231 return; |
| 232 } | |
| 233 else | |
| 234 { | |
| 235 XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES (d), NULL); | |
| 236 return; | |
| 237 } | |
| 444 | 238 #endif /* HAVE_XREGISTERIMINSTANTIATECALLBACK */ |
| 428 | 239 } |
| 240 | |
| 241 | |
| 242 /* | |
| 243 * For the frames | |
| 244 */ | |
| 245 | |
| 246 /* Callback for the deleting frame. */ | |
| 247 static void | |
| 2286 | 248 XIM_delete_frame (Widget UNUSED (w), XtPointer client_data, |
| 249 XtPointer UNUSED (call_data)) | |
| 428 | 250 { |
| 251 struct frame *f = (struct frame *) client_data; | |
| 252 struct device *d = XDEVICE (FRAME_DEVICE (f)); | |
| 253 | |
| 254 if (DEVICE_X_XIM (d)) | |
| 255 { | |
| 256 if (FRAME_X_XIC (f)) | |
| 257 { | |
| 258 XDestroyIC (FRAME_X_XIC (f)); | |
| 259 FRAME_X_XIC (f) = NULL; | |
| 260 } | |
| 261 } | |
| 262 return; | |
| 263 } | |
| 264 | |
| 265 /* Initialize XIC for new frame. | |
| 266 Create an X input context (XIC) for this frame. */ | |
| 267 void | |
| 268 XIM_init_frame (struct frame *f) | |
| 269 { | |
| 270 struct device *d = XDEVICE (FRAME_DEVICE (f)); | |
| 271 XIM xim; | |
| 272 Widget w = FRAME_X_TEXT_WIDGET (f); | |
| 273 Window win = XtWindow (w); | |
| 274 XRectangle p_area = {0,0,1,1}, s_area = {0,0,1,1}; | |
| 275 XPoint spot = {0,0}; | |
| 276 XIMStyle style; | |
| 277 XVaNestedList p_list, s_list; | |
| 278 typedef struct | |
| 279 { | |
| 280 XIMStyles styles; | |
| 281 XFontSet fontset; | |
| 282 Pixel fg; | |
| 283 Pixel bg; | |
| 284 char *inputmethod; | |
| 285 } xic_vars_t; | |
| 286 xic_vars_t xic_vars; | |
| 287 XIC xic; | |
| 288 | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
289 #define res(name, class_, representation, field, default_value) \ |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
290 Xt_RESOURCE (name, class_, representation, xic_vars.field, \ |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
291 XtOffsetOf(xic_vars_t, field), XtRString, default_value) |
| 428 | 292 |
| 293 static XtResource resources[] = | |
| 294 { | |
| 295 /* name class represent'n field default value */ | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
296 res(XtNximStyles, XtCXimStyles, XtRXimStyles, styles, DefaultXIMStyles), |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
297 res(XtNfontSet, XtCFontSet, XtRFontSet, fontset, XtDefaultFontSet), |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
298 res(XtNximForeground, XtCForeground, XtRPixel, fg, XtDefaultForeground), |
|
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
299 res(XtNximBackground, XtCBackground, XtRPixel, bg, XtDefaultBackground) |
| 428 | 300 }; |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
301 #undef res |
| 428 | 302 |
| 303 xim = DEVICE_X_XIM (d); | |
| 304 | |
| 305 if (!xim) | |
| 306 { | |
| 307 return; | |
| 308 } | |
| 309 | |
| 310 w = FRAME_X_TEXT_WIDGET (f); | |
| 311 | |
| 312 /* | |
| 313 * initialize XIC | |
| 314 */ | |
| 315 if (FRAME_X_XIC (f)) return; | |
| 316 XtGetApplicationResources (w, &xic_vars, | |
| 317 resources, XtNumber (resources), | |
| 318 NULL, 0); | |
| 319 if (!xic_vars.fontset) | |
| 320 { | |
| 793 | 321 warn_when_safe |
| 322 (Qxintl, Qerror, | |
| 323 "Can't initialize XIM: Can't get fontset resource for Input Method"); | |
| 428 | 324 FRAME_X_XIC (f) = NULL; |
| 325 return; | |
| 326 } | |
| 327 | |
| 328 /* construct xic */ | |
| 329 XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES(d), NULL); | |
| 330 FRAME_X_XIC_STYLE (f) = style = | |
| 331 best_style (&xic_vars.styles, (XIMStyles *)DEVICE_X_XIM_STYLES(d)); | |
| 332 | |
| 333 p_list = XVaCreateNestedList (0, | |
| 334 XNArea, &p_area, | |
| 335 XNSpotLocation, &spot, | |
| 336 XNForeground, xic_vars.fg, | |
| 337 XNBackground, xic_vars.bg, | |
| 338 XNFontSet, xic_vars.fontset, | |
| 339 NULL); | |
| 340 | |
| 341 s_list = XVaCreateNestedList (0, | |
| 342 XNArea, &s_area, | |
| 343 XNForeground, xic_vars.fg, | |
| 344 XNBackground, xic_vars.bg, | |
| 345 XNFontSet, xic_vars.fontset, | |
| 346 NULL); | |
| 347 | |
| 348 FRAME_X_XIC (f) = xic = | |
| 349 XCreateIC (xim, | |
| 350 XNInputStyle, style, | |
| 351 XNClientWindow, win, | |
| 352 XNFocusWindow, win, | |
| 353 XNPreeditAttributes, p_list, | |
| 354 XNStatusAttributes, s_list, | |
| 355 NULL); | |
| 356 XFree (p_list); | |
| 357 XFree (s_list); | |
| 358 | |
| 359 if (!xic) | |
| 360 { | |
| 793 | 361 warn_when_safe (Qxintl, Qerror, |
| 362 "Can't initialize XIM: XCreateIC failed"); | |
| 428 | 363 return; |
| 364 } | |
| 365 | |
| 366 if (style & XIMPreeditPosition) | |
| 367 { | |
| 368 XPoint *frame_spot = &(FRAME_X_XIC_SPOT(f)); | |
| 369 frame_spot->x = frame_spot->y = -1; | |
| 370 } | |
| 371 | |
| 372 XIM_SetGeometry (f); | |
| 373 | |
| 374 XSetICFocus (xic); | |
| 375 | |
| 444 | 376 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK |
| 428 | 377 /* when frame is going to be destroyed (closed) */ |
| 793 | 378 XtAddCallback (FRAME_X_TEXT_WIDGET (f), XNDestroyCallback, |
| 379 XIM_delete_frame, (XtPointer)f ); | |
| 428 | 380 #endif |
| 381 } | |
| 382 | |
| 383 | |
| 384 void | |
| 385 XIM_SetGeometry (struct frame *f) | |
| 386 { | |
| 3462 | 387 XIC xic; |
| 388 XIMStyle style; | |
| 428 | 389 XRectangle area; |
| 390 | |
| 3462 | 391 if (!f) |
| 428 | 392 return; |
| 393 | |
| 3462 | 394 xic = FRAME_X_XIC (f); |
| 395 if (!xic) | |
| 396 return; | |
| 397 | |
| 398 style = FRAME_X_XIC_STYLE (f); | |
| 428 | 399 if (style & XIMStatusArea) |
| 400 { | |
| 401 /* Place Status Area in bottom right corner */ | |
| 402 /* Negotiate geometry of status area */ | |
| 403 /* See O'Reilly Xlib XIM chapter (but beware, it's buggy) */ | |
| 404 XRectangle *needed; | |
| 405 | |
| 406 /* If input method has existing status area, use its current size */ | |
| 407 /* The following at least works for Sun's htt */ | |
| 408 area.x = area.y = area.width = area.height = 0; | |
| 409 XIC_Value (Set, xic, XNStatusAttributes, XNAreaNeeded, &area); | |
| 410 XIC_Value (Get, xic, XNStatusAttributes, XNAreaNeeded, &needed); | |
| 411 if (needed->width == 0) /* Use XNArea instead of XNAreaNeeded */ | |
| 412 XIC_Value (Get, xic, XNStatusAttributes, XNArea, &needed); | |
| 413 | |
| 5090 | 414 /* #### This will partially cover the gutter if there is a bottom |
| 415 gutter. Perhaps what was intended was FRAME_PANED_RIGHT_EDGE() | |
| 416 and FRAME_PANED_BOTTOM_EDGE()? That will actually place itself | |
| 417 in the paned area (covering the right edge of the minibuffer) | |
| 418 in all circumstances. */ | |
| 428 | 419 area.width = needed->width; |
| 420 area.height = needed->height; | |
| 5090 | 421 area.x = FRAME_RIGHT_INTERNAL_BORDER_START (f) - area.width; |
| 422 area.y = FRAME_BOTTOM_INTERNAL_BORDER_START (f) - area.height; | |
| 428 | 423 |
| 424 #ifdef DEBUG_XIM | |
| 425 stderr_out ("Putting StatusArea in x=%d y=%d w=%d h=%d\n", | |
| 426 area.x, area.y, area.width, area.height); | |
| 427 #endif /* DEBUG_XIM */ | |
| 428 | |
| 429 XIC_Value (Set, xic, XNStatusAttributes, XNArea, &area); | |
| 430 } | |
| 431 | |
| 432 if (style & XIMPreeditPosition) | |
| 433 { | |
| 434 /* Set Preedit Area to whole frame size (sans border) */ | |
| 435 /* We include the border because Preedit window might be larger | |
| 436 than display line at edge. #### FIX: we should adjust to make | |
| 437 sure that there is always room for the spot sub-window */ | |
| 5090 | 438 area.x = FRAME_LEFT_INTERNAL_BORDER_START (f); |
| 439 area.y = FRAME_TOP_INTERNAL_BORDER_START (f); | |
| 440 area.width = FRAME_RIGHT_INTERNAL_BORDER_END (f) - area.x; | |
| 441 area.height = FRAME_BOTTOM_INTERNAL_BORDER_END (f) - area.y; | |
| 428 | 442 XIC_Value(Set, xic, XNPreeditAttributes, XNArea, &area); |
| 443 } | |
| 444 | |
| 445 #ifdef DEBUG_XIM | |
| 446 describe_XIC (xic); | |
| 447 #endif | |
| 448 } | |
| 449 | |
| 450 void | |
| 451 XIM_SetSpotLocation (struct frame *f, int x, int y) | |
| 452 { | |
| 453 XIC xic = FRAME_X_XIC (f); | |
| 454 XPoint *spot = &(FRAME_X_XIC_SPOT (f)); | |
| 455 | |
| 456 /* Only care if we have a valid XIC using Over the Spot in | |
| 457 * a different location */ | |
| 458 if (!xic || | |
| 459 !(FRAME_X_XIC_STYLE (f) & XIMPreeditPosition) || | |
| 460 (spot->x == (short) x && | |
| 461 spot->y == (short) y)) | |
| 462 return; | |
| 463 | |
| 464 spot->x = (short) x; | |
| 465 spot->y = (short) y; | |
| 466 | |
| 440 | 467 /* #### FIX: Must make sure spot fits within Preedit Area */ |
| 428 | 468 XIC_Value (Set, xic, XNPreeditAttributes, XNSpotLocation, spot); |
| 469 #ifdef DEBUG_XIM | |
| 470 stderr_out ("Spot: %d %d\n", spot->x, spot->y); | |
| 471 #endif | |
| 472 } | |
| 473 | |
| 474 void | |
| 475 XIM_focus_event (struct frame *f, int in_p) | |
| 476 { | |
| 477 if (FRAME_X_XIC (f) /* && FRAME_X_XIM_REGISTERED(f) */) | |
| 478 (in_p ? XSetICFocus : XUnsetICFocus) (FRAME_X_XIC (f)); | |
| 479 } | |
| 480 | |
| 481 #if 0 | |
| 482 #define XIM_Composed_Text_BUFSIZE 64 | |
| 483 typedef struct XIM_Composed_Text | |
| 484 { | |
| 485 int size; | |
| 486 wchar_t data [XIM_Composed_Text_BUFSIZE]; | |
| 487 } XIM_Composed_Text; | |
| 488 | |
| 489 static XIM_Composed_Text composed_input_buf = {XIM_Composed_Text_BUFSIZE, {0}}; | |
| 490 Window main_window; | |
| 491 | |
| 492 /* get_XIM_input -- Process results of input method composition. | |
| 493 | |
| 494 This function copies the results of the input method composition to | |
| 495 composed_input_buf. Then for each character, a custom event of type | |
| 496 wc_atom is sent with the character as its data. | |
| 497 | |
| 498 It is probably more efficient to copy the composition results to some | |
| 499 allocated memory and send a single event pointing to that memory. | |
| 500 That would cut down on the event processing as well as allow quick | |
| 501 insertion into the buffer of the whole string. It might require some | |
| 502 care, though, to avoid fragmenting memory through the allocation and | |
| 503 freeing of many small chunks. Maybe the existing system for | |
| 504 (single-byte) string allocation can be used, multiplying the length by | |
| 505 sizeof (wchar_t) to get the right size. | |
| 506 */ | |
| 507 void | |
| 508 get_XIM_input (XKeyPressedEvent *x_key_event, XIC ic, Display *dpy) | |
| 509 { | |
| 510 KeySym keysym; | |
| 511 Status status; | |
| 512 int len; | |
| 513 int i; | |
| 514 XClientMessageEvent new_event; | |
| 515 | |
| 516 retry: | |
| 517 len = XwcLookupString (ic, x_key_event, composed_input_buf.data, | |
| 518 composed_input_buf.size, &keysym, &status); | |
| 519 switch (status) | |
| 520 { | |
| 521 case XBufferOverflow: | |
| 522 /* GROW_WC_STRING (&composed_input_buf, 32); mrb */ | |
| 523 goto retry; | |
| 524 case XLookupChars: | |
| 525 break; | |
| 526 default: | |
| 2500 | 527 ABORT (); |
| 428 | 528 } |
| 529 | |
| 530 new_event.type = ClientMessage; | |
| 531 new_event.display = x_key_event->display; | |
| 532 new_event.window = x_key_event->window; | |
| 533 new_event.message_type = wc_atom; | |
| 534 new_event.format = 32; /* 32-bit wide data */ | |
| 535 new_event.data.l[2] = new_event.data.l[3] = new_event.data.l[4] = 0L; | |
| 536 new_event.data.l[0] = x_key_event->time; | |
| 537 for (i = 0; i < len; i++) | |
| 538 { | |
| 539 new_event.data.l[1] = ((wchar_t *) composed_input_buf.data)[i]; | |
| 540 XSendEvent (display, main_window, False, 0L, (XEvent *) &new_event); | |
| 541 } | |
| 542 } | |
| 543 #endif /* 0 */ | |
| 544 | |
| 545 /* ============================================================== */ | |
| 546 /* X input method style determination */ | |
| 547 /* ============================================================== */ | |
| 548 | |
| 549 #if 0 | |
| 550 #define done(type, value) \ | |
| 551 if (toVal->addr != NULL) { \ | |
| 552 if (toVal->size < sizeof(type)) { \ | |
| 553 toVal->size = sizeof(type); \ | |
| 554 return False; \ | |
| 555 } \ | |
| 556 *(type*)toVal->addr = (value); \ | |
| 557 } else { \ | |
| 558 static type static_val; \ | |
| 559 static_val = (value); \ | |
| 560 toVal->addr = (XPointer)&static_val; \ | |
| 561 } \ | |
| 562 toVal->size = sizeof(type); \ | |
| 563 return True /* Caller supplies `;' */ | |
| 564 #endif /* 0 */ | |
| 565 | |
| 566 /* | |
| 567 * This is a standard Xt type converter, except that the caller MUST | |
| 568 * supply a proper non-NULL toVal XIMStyles structure that we will | |
| 569 * fill in. | |
| 570 * | |
| 571 * fromVal points to a string like | |
| 572 * | |
| 573 "XIMPreeditPosition|XIMStatusArea, | |
| 574 XIMPreeditPosition|XIMStatusNothing | |
| 575 XIMPreeditNothing|XIMStatusNothing" | |
| 576 * | |
| 577 * This is converted in the obvious way to a XIMStyles structure. | |
| 578 * | |
| 579 * mrb: #### Fix this to handle Motif-style specifications for | |
| 580 * XIMStyles as well: overTheSpot, rootWindow, none */ | |
| 581 | |
| 582 /* XtTypeConverter */ | |
| 583 Boolean | |
| 584 EmacsXtCvtStringToXIMStyles ( | |
| 585 Display *dpy, | |
| 586 XrmValuePtr args, | |
| 587 Cardinal *num_args, | |
| 588 XrmValuePtr fromVal, | |
| 589 XrmValuePtr toVal, | |
| 590 XtPointer *converter_data) | |
| 591 { | |
| 592 #define STYLE_INFO(style) { style, #style, sizeof(#style) } | |
| 593 static struct XIMStyleInfo | |
| 594 { | |
| 442 | 595 const XIMStyle style; |
| 596 const char * const name; | |
| 597 const int namelen; | |
| 428 | 598 } emacs_XIMStyleInfo[] = { |
| 599 STYLE_INFO (XIMPreeditPosition|XIMStatusArea), | |
| 600 STYLE_INFO (XIMPreeditPosition|XIMStatusNothing), | |
| 601 STYLE_INFO (XIMPreeditPosition|XIMStatusNone), | |
| 602 STYLE_INFO (XIMPreeditNothing|XIMStatusArea), | |
| 603 STYLE_INFO (XIMPreeditNothing|XIMStatusNothing), | |
| 604 STYLE_INFO (XIMPreeditNothing|XIMStatusNone), | |
| 605 STYLE_INFO (XIMPreeditNone|XIMStatusArea), | |
| 606 STYLE_INFO (XIMPreeditNone|XIMStatusNothing), | |
| 607 STYLE_INFO (XIMPreeditNone|XIMStatusNone) | |
| 608 }; | |
| 609 #undef STYLE_INFO | |
| 610 | |
| 611 char *s = (char *) fromVal->addr; | |
| 612 char *end = s + fromVal->size; | |
| 442 | 613 XIMStyles * const p = (XIMStyles *) toVal->addr; |
| 614 const char * const delimiter = " \t\n\r:;," ; | |
| 615 const int max_styles = XtNumber(emacs_XIMStyleInfo); | |
| 428 | 616 int i; |
| 617 char *c; | |
| 618 | |
| 619 #ifdef DEBUG_XIM | |
| 620 stderr_out ("EmacsCvtStringToXIMStyles called with size=%d, string=\"%s\"\n", | |
| 621 fromVal->size, (char *) fromVal->addr); | |
| 622 #endif /* DEBUG_XIM */ | |
| 623 | |
| 624 if (*num_args != 0) | |
| 625 { | |
| 626 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy); | |
| 627 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle", | |
| 628 "XtToolkitError", | |
| 629 "String to XIMStyle conversion requires exactly 0 parameters", | |
| 630 (String *)NULL, (Cardinal *)NULL); | |
| 631 return False; | |
| 632 } | |
| 633 | |
| 634 #ifdef DEBUG_XEMACS | |
| 635 /* Make sure caller is giving us good data */ | |
| 636 assert (fromVal->addr != NULL); | |
| 637 assert (fromVal->size == strlen(fromVal->addr)+1); | |
| 638 assert (toVal->addr != NULL); | |
| 639 assert (toVal->size == sizeof(XIMStyles)); | |
| 640 #endif /* DEBUG_XEMACS */ | |
| 641 | |
| 642 p->count_styles = 0; | |
| 643 p->supported_styles = xnew_array (XIMStyle, max_styles); | |
| 644 | |
| 645 /* | |
| 646 * The following routine assumes that the style name resource is | |
| 647 * identical with the programmatic name of style. For example, | |
| 648 * "XIMPreeditPosition|XIMStatusArea" means the | |
| 649 * XIMPreeditPosition|XIMStatusArea value is specified. If the | |
| 650 * style name is changed, such as "OverTheSpot|imDisplaysInClient", | |
| 651 * the parsing logic below should be modified as well. */ | |
| 652 | |
| 653 if ((c = strtok(s, delimiter)) == NULL) | |
| 654 c = end; | |
| 655 | |
| 656 while (c < end) | |
| 657 { | |
| 658 for(i=0 ; i<max_styles ; i++) | |
| 659 { | |
| 660 struct XIMStyleInfo *rec = emacs_XIMStyleInfo + i; | |
| 661 if(!strncmp(c, rec->name, rec->namelen - 1)) { | |
| 662 p->supported_styles[p->count_styles] = rec->style; | |
| 663 p->count_styles++; | |
| 664 break; | |
| 665 } | |
| 666 } | |
| 667 if((c = strtok(NULL, delimiter)) == NULL) { | |
| 668 break ; | |
| 669 } | |
| 670 } | |
| 671 | |
| 672 if (p->count_styles == 0) | |
| 673 { /* No valid styles? */ | |
| 2367 | 674 /* !!#### */ |
| 675 char *buf = (char *) ALLOCA (strlen (fromVal->addr) | |
| 676 + strlen (DefaultXIMStyles) | |
| 677 + 100); | |
| 428 | 678 XrmValue new_from; |
| 679 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy); | |
| 680 | |
| 681 sprintf(buf, "Cannot convert string \"%s\" to type XIMStyles.\n" | |
| 682 "Using default string \"%s\" instead.\n", | |
| 683 fromVal->addr, DefaultXIMStyles); | |
| 684 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle", | |
| 685 "XtToolkitError", | |
| 686 buf, (String *)NULL, (Cardinal *)NULL); | |
| 687 new_from.addr = DefaultXIMStyles; | |
| 688 new_from.size = sizeof(DefaultXIMStyles); | |
| 689 return EmacsXtCvtStringToXIMStyles (dpy, args, num_args, | |
| 690 &new_from, toVal, converter_data); | |
| 691 } | |
| 692 XREALLOC_ARRAY (p->supported_styles, XIMStyle, p->count_styles); | |
| 693 *converter_data = (char *) True; | |
| 694 return True; | |
| 695 } | |
| 696 | |
| 697 /* XtDestructor */ | |
| 698 void | |
| 699 EmacsFreeXIMStyles ( | |
| 700 XtAppContext app, | |
| 701 XrmValuePtr toVal, | |
| 702 XtPointer converter_data, | |
| 2286 | 703 XrmValuePtr UNUSED (args), |
| 428 | 704 Cardinal *num_args) |
| 705 { | |
| 706 #ifdef DEBUG_XIM | |
| 707 stderr_out ("Converter data: %x\n", converter_data); | |
| 708 stderr_out ("EmacsFreeXIMStyles called\n"); | |
| 709 #endif /* DEBUG_XIM */ | |
| 710 | |
| 711 if (*num_args != 0) | |
| 712 { | |
| 713 XtAppWarningMsg(app, "wrongParameters","freeXIMStyles","XtToolkitError", | |
| 714 "Freeing an XIMStyles requires that zero arguments be passwd", | |
| 715 (String *)NULL, (Cardinal *)NULL); | |
| 716 return; | |
| 717 } | |
| 718 | |
| 719 if (converter_data) | |
| 720 { | |
| 4123 | 721 Boolean free_p = (Boolean) (EMACS_INT) converter_data; |
| 428 | 722 XIMStyles *styles = (XIMStyles *) toVal->addr; |
| 723 if (free_p) | |
| 724 XFree ( styles->supported_styles ); | |
| 725 } | |
| 726 } | |
| 727 | |
| 728 #if 0 | |
| 729 /* O'Reilly XLib Programming Manual, pg. 371 */ | |
| 730 /* Much nicer implementation than O'Reilly */ | |
| 731 /* Choose the more `complicated', hence nicer, XIM input style */ | |
| 732 static XIMStyle | |
| 733 BetterStyle (XIMStyle s, XIMStyle t) | |
| 734 { | |
| 735 #define CHECK_XIMStyle_BIT(bit) \ | |
| 736 if ((s ^ t) & bit) { return (s & bit) ? s : t; } | |
| 737 | |
| 738 CHECK_XIMStyle_BIT (XIMPreeditCallbacks); | |
| 739 CHECK_XIMStyle_BIT (XIMPreeditPosition); | |
| 740 CHECK_XIMStyle_BIT (XIMPreeditArea); | |
| 741 CHECK_XIMStyle_BIT (XIMPreeditNothing); | |
| 742 CHECK_XIMStyle_BIT (XIMStatusCallbacks); | |
| 743 CHECK_XIMStyle_BIT (XIMStatusArea); | |
| 744 CHECK_XIMStyle_BIT (XIMStatusNothing); | |
| 745 #undef CHECK_XIMStyle_BIT | |
| 746 return s ? s : t ; | |
| 747 } | |
| 748 #endif /* 0 */ | |
| 749 | |
| 750 /* Choose the best style, given: | |
| 751 * - user preferences (already checked to be supported by XEmacs) | |
| 752 * - styles supported by the input method */ | |
| 753 #define DEFAULTStyle (XIMPreeditNothing|XIMStatusNothing) | |
| 754 static XIMStyle | |
| 755 best_style (XIMStyles *user, XIMStyles *xim) | |
| 756 { | |
| 757 REGISTER int i, j; | |
| 758 for (i=0 ; i<user->count_styles ; i++) | |
| 759 { | |
| 760 for (j=0 ; j<xim->count_styles ; j++) | |
| 761 { | |
| 762 if (user->supported_styles[i] == xim->supported_styles[j]) | |
| 763 return user->supported_styles[i]; | |
| 764 } | |
| 765 } | |
| 766 return DEFAULTStyle; /* Default Style */ | |
| 767 } | |
| 768 | |
| 769 /* These lisp-callable functions will be sealed until xim-leim is needed. | |
| 770 Oct 22 1999 - kazz */ | |
| 771 #if 0 | |
| 772 /* | |
| 773 * External callable function for XIM | |
| 774 */ | |
| 775 DEFUN ("x-open-xim", Fx_open_xim, 1, 1, 0, /* | |
| 776 Open the XIC on the frame if XIM is available. | |
| 777 Commonly, use this as \(x-open-xim \(selected-frame)). | |
| 778 If the frame is not on X device, return signal. | |
| 779 If XIC is created successfully return t. If not return nil. | |
| 780 */ | |
| 781 (frame)) | |
| 782 { | |
| 783 struct frame *f; | |
| 784 | |
| 785 CHECK_LIVE_FRAME (frame); | |
| 786 f = XFRAME (frame); | |
| 787 if (!FRAME_X_P (f)) | |
| 563 | 788 invalid_argument ("This frame is not on X device", frame); |
| 428 | 789 |
| 790 XIM_init_frame (f); | |
| 791 return FRAME_X_XIC (f) ? Qt : Qnil; | |
| 792 } | |
| 793 | |
| 794 DEFUN ("x-close-xim", Fx_close_xim, 1, 1, 0, /* | |
| 795 Close the XIC on the frame if it exists. | |
| 796 Commonly, use this as \(x-close-xim \(selected-frame)). | |
| 797 If the frame is not on X device, return signal. | |
| 798 Otherwise, it destroys the XIC if it exists, then returns t anyway. | |
| 799 */ | |
| 800 (frame)) | |
| 801 { | |
| 802 struct frame *f; | |
| 803 struct device *d; | |
| 804 | |
| 805 CHECK_LIVE_FRAME (frame); | |
| 806 f = XFRAME (frame); | |
| 807 if (!FRAME_X_P (f)) | |
| 563 | 808 invalid_argument ("This frame is not on X device", frame); |
| 428 | 809 |
| 810 d = XDEVICE (FRAME_DEVICE (f)); | |
| 811 if (DEVICE_X_XIM (d)) { | |
| 812 /* XDestroyIC (FRAME_X_XIC (XFRAME (f))); */ | |
| 813 FRAME_X_XIC (XFRAME (f)) = NULL; | |
| 814 } | |
| 815 return Qt; | |
| 816 } | |
| 817 #endif /* if 0 */ | |
| 818 | |
| 819 void | |
| 820 syms_of_input_method_xlib (void) | |
| 821 { | |
| 822 #if 0 /* see above */ | |
| 823 DEFSUBR (Fx_open_xim); | |
| 824 DEFSUBR (Fx_close_xim); | |
| 825 #endif | |
| 826 } | |
| 827 | |
| 828 void | |
| 829 vars_of_input_method_xlib (void) | |
| 830 { | |
| 831 Fprovide (intern ("xim")); | |
| 832 } | |
| 833 | |
| 834 | |
| 835 /* ====================================================================== */ | |
| 836 /* Internal Debugging Routines */ | |
| 837 /* ====================================================================== */ | |
| 838 #ifdef DEBUG_XEMACS | |
| 839 | |
| 840 void | |
| 841 describe_XIM (XIM xim) | |
| 842 { | |
| 843 XIMStyles *styles; | |
| 844 | |
| 845 /* Print locale of XIM */ | |
| 846 stderr_out ("\nXIM Locale of IM: %s\n", XLocaleOfIM(xim)); | |
| 847 | |
| 848 /* List supported input method styles */ | |
| 849 XGetIMValues(xim, XNQueryInputStyle, &styles, NULL); | |
| 850 | |
| 851 stderr_out ("\n%d input style(s) supported by input method.\n", | |
| 852 styles->count_styles); | |
| 853 | |
| 854 #ifdef DEBUG_XIM | |
| 855 { | |
| 856 int i; | |
| 857 for (i=0; i < styles->count_styles; i++) | |
| 858 describe_XIMStyle (styles->supported_styles[i]); | |
| 859 } | |
| 860 #endif /* DEBUG_XIM */ | |
| 861 XFree(styles); | |
| 862 } | |
| 863 | |
| 864 void | |
| 865 describe_XFontSet (XFontSet fontset) | |
| 866 { | |
| 867 XFontStruct **font_struct_list; | |
| 868 char **font_name_list; | |
| 869 int count, i; | |
| 870 | |
| 871 if (fontset == NULL) | |
| 872 { | |
| 873 stderr_out ("NULL\n"); | |
| 874 return; | |
| 875 } | |
| 876 | |
| 877 count = XFontsOfFontSet (fontset, &font_struct_list, &font_name_list); | |
| 878 stderr_out ( "%d font(s) available:\n", count); | |
| 879 for (i=0 ; i < count ; i++) | |
| 880 stderr_out ("Font: %s\n", *(font_name_list+i)); | |
| 881 } | |
| 882 | |
| 883 void | |
| 884 describe_Status (Status status) | |
| 885 { | |
| 886 #define DESCRIBE_STATUS(value) \ | |
| 887 if (status == value) stderr_out ("Status: " #value "\n") | |
| 888 | |
| 889 DESCRIBE_STATUS (XBufferOverflow); | |
| 890 DESCRIBE_STATUS (XLookupNone); | |
| 891 DESCRIBE_STATUS (XLookupKeySym); | |
| 892 DESCRIBE_STATUS (XLookupBoth); | |
| 893 DESCRIBE_STATUS (XLookupChars); | |
| 894 #undef DESCRIBE_STATUS | |
| 895 } | |
| 896 | |
| 897 void | |
| 898 describe_Window (Window win) | |
| 899 { | |
| 900 char xwincmd[128]; | |
| 901 sprintf (xwincmd, "xwininfo -id 0x%x >&2; xwininfo -events -id 0x%x >&2", | |
| 902 (int) win, (int) win); | |
|
4710
3a87551bfeb5
Fixes for a number of minor warnings issued by gcc. See xemacs-patches message
Jerry James <james@xemacs.org>
parents:
4528
diff
changeset
|
903 if (system (xwincmd) == -1) |
|
3a87551bfeb5
Fixes for a number of minor warnings issued by gcc. See xemacs-patches message
Jerry James <james@xemacs.org>
parents:
4528
diff
changeset
|
904 stderr_out ("Unable to execute xwininfo\n"); |
| 428 | 905 } |
| 906 | |
| 907 void | |
| 908 describe_XIC (XIC xic) | |
| 909 { | |
| 910 XIMStyle style; | |
| 911 Window client_win=0, focus_win=0; | |
| 912 char *resourceName = NULL; | |
| 913 char *resourceClass = NULL; | |
| 914 char *bad_arg = NULL; | |
| 915 unsigned long filter_mask = NoEventMask; | |
| 916 XVaNestedList p_list, s_list; | |
| 917 XFontSet p_fontset = NULL, s_fontset = NULL; | |
| 918 Pixel p_fg=0, p_bg = 0, s_fg=0, s_bg = 0; | |
| 919 XRectangle *p_area = NULL, *s_area = NULL; | |
| 920 XRectangle *p_needed = NULL, *s_needed = NULL; | |
| 921 XPoint *p_spot = NULL; | |
| 922 | |
| 923 /* Check for valid input context and method */ | |
| 924 if (!xic) | |
| 925 stderr_out ("Input method is NULL\n"); | |
| 926 | |
| 927 if (!XIMOfIC(xic)) | |
| 928 stderr_out ("XIMOfIC() returns NULL\n"); | |
| 929 | |
| 930 /* Print out Input Context Attributes */ | |
| 931 p_list = XVaCreateNestedList (0, | |
| 932 XNFontSet, &p_fontset, | |
| 933 XNArea, &p_area, | |
| 934 XNAreaNeeded, &p_needed, | |
| 935 XNSpotLocation, &p_spot, | |
| 936 XNForeground, &p_fg, | |
| 937 XNBackground, &p_bg, | |
| 938 NULL); | |
| 939 | |
| 940 s_list = XVaCreateNestedList (0, | |
| 941 XNFontSet, &s_fontset, | |
| 942 XNArea, &s_area, | |
| 943 XNAreaNeeded, &s_needed, | |
| 944 XNForeground, &s_fg, | |
| 945 XNBackground, &s_bg, | |
| 946 NULL); | |
| 947 | |
| 948 bad_arg = XGetICValues(xic, | |
| 949 XNInputStyle, &style, | |
| 950 XNFilterEvents, &filter_mask, | |
| 951 XNClientWindow, &client_win, | |
| 952 XNFocusWindow, &focus_win, | |
| 953 XNResourceName, &resourceName, | |
| 954 XNResourceClass, &resourceClass, | |
| 955 XNPreeditAttributes, p_list, | |
| 956 XNStatusAttributes, s_list, | |
| 957 NULL); | |
| 958 XFree(p_list); | |
| 959 XFree(s_list); | |
| 960 | |
| 961 if (bad_arg != NULL) | |
| 962 stderr_out ("Couldn't get IC value: %s\n", bad_arg); | |
| 963 | |
| 964 stderr_out ("\nInput method context attributes:\n"); | |
| 965 stderr_out ("Style: "); describe_XIMStyle (style); | |
| 966 stderr_out ("Client window: %lx\n", (unsigned long int)client_win); | |
| 967 stderr_out ("Focus window: %lx\n", (unsigned long int)focus_win); | |
| 968 stderr_out ("Preedit:\n"); | |
| 969 describe_XRectangle (" Area", p_area); | |
| 970 describe_XRectangle (" Area needed", p_needed); | |
| 971 stderr_out (" foreground: %lx\n", (unsigned long int)p_fg); | |
| 972 stderr_out (" background: %lx\n", (unsigned long int)p_bg); | |
| 973 stderr_out (" fontset: "); describe_XFontSet (p_fontset); | |
| 974 stderr_out ("Status:\n"); | |
| 975 describe_XRectangle (" Area", s_area); | |
| 976 describe_XRectangle (" Area needed", s_needed); | |
| 977 stderr_out (" foreground: %lx\n", (unsigned long int)s_fg); | |
| 978 stderr_out (" background: %lx\n", (unsigned long int)s_bg); | |
| 979 stderr_out (" fontset: \n"); describe_XFontSet (s_fontset); | |
| 980 stderr_out ("XNResourceName: %s\n", resourceName ? resourceName : "NULL"); | |
| 981 stderr_out ("XNResourceClass: %s\n", resourceClass ? resourceClass : "NULL"); | |
| 982 stderr_out ("XNFilterEvents: "); describe_event_mask (filter_mask); | |
| 983 } | |
| 984 | |
| 985 void | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
986 describe_XRectangle (const char *name, XRectangle *r) |
| 428 | 987 { |
| 988 if (r == NULL) | |
| 989 stderr_out ("%s: NULL\n", name); | |
| 990 else | |
| 991 stderr_out ("%s: x=%d y=%d w=%d h=%d\n", | |
| 992 name, r->x, r->y, r->width, r->height); | |
| 993 } | |
| 994 | |
| 995 /* Print out elements of Event mask */ | |
| 996 /* Defines from X11/X.h */ | |
| 997 void | |
| 998 describe_event_mask (unsigned long mask) | |
| 999 { | |
| 1000 #define DESCRIBE_EVENT_MASK(bit) if ((bit) & mask) stderr_out (#bit " ") | |
| 1001 DESCRIBE_EVENT_MASK (NoEventMask); | |
| 1002 DESCRIBE_EVENT_MASK (KeyPressMask); | |
| 1003 DESCRIBE_EVENT_MASK (KeyReleaseMask); | |
| 1004 DESCRIBE_EVENT_MASK (ButtonPressMask); | |
| 1005 DESCRIBE_EVENT_MASK (ButtonReleaseMask); | |
| 1006 DESCRIBE_EVENT_MASK (EnterWindowMask); | |
| 1007 DESCRIBE_EVENT_MASK (LeaveWindowMask); | |
| 1008 DESCRIBE_EVENT_MASK (PointerMotionMask); | |
| 1009 DESCRIBE_EVENT_MASK (PointerMotionHintMask); | |
| 1010 DESCRIBE_EVENT_MASK (Button1MotionMask); | |
| 1011 DESCRIBE_EVENT_MASK (Button2MotionMask); | |
| 1012 DESCRIBE_EVENT_MASK (Button3MotionMask); | |
| 1013 DESCRIBE_EVENT_MASK (Button4MotionMask); | |
| 1014 DESCRIBE_EVENT_MASK (Button5MotionMask); | |
| 1015 DESCRIBE_EVENT_MASK (ButtonMotionMask); | |
| 1016 DESCRIBE_EVENT_MASK (KeymapStateMask); | |
| 1017 DESCRIBE_EVENT_MASK (ExposureMask); | |
| 1018 DESCRIBE_EVENT_MASK (VisibilityChangeMask); | |
| 1019 DESCRIBE_EVENT_MASK (StructureNotifyMask); | |
| 1020 DESCRIBE_EVENT_MASK (ResizeRedirectMask); | |
| 1021 DESCRIBE_EVENT_MASK (SubstructureNotifyMask); | |
| 1022 DESCRIBE_EVENT_MASK (SubstructureRedirectMask); | |
| 1023 DESCRIBE_EVENT_MASK (FocusChangeMask); | |
| 1024 DESCRIBE_EVENT_MASK (PropertyChangeMask); | |
| 1025 DESCRIBE_EVENT_MASK (ColormapChangeMask); | |
| 1026 DESCRIBE_EVENT_MASK (OwnerGrabButtonMask); | |
| 1027 #undef DESCRIBE_EVENT_MASK | |
| 1028 stderr_out("\n"); | |
| 1029 } | |
| 1030 | |
| 1031 void | |
| 1032 describe_XIMStyle (XIMStyle style) | |
| 1033 { | |
| 1034 #define DESCRIBE_STYLE(bit) \ | |
| 1035 if (bit & style) \ | |
| 1036 stderr_out (#bit " "); | |
| 1037 | |
| 1038 DESCRIBE_STYLE (XIMPreeditArea); | |
| 1039 DESCRIBE_STYLE (XIMPreeditCallbacks); | |
| 1040 DESCRIBE_STYLE (XIMPreeditPosition); | |
| 1041 DESCRIBE_STYLE (XIMPreeditNothing); | |
| 1042 DESCRIBE_STYLE (XIMPreeditNone); | |
| 1043 DESCRIBE_STYLE (XIMStatusArea); | |
| 1044 DESCRIBE_STYLE (XIMStatusCallbacks); | |
| 1045 DESCRIBE_STYLE (XIMStatusNothing); | |
| 1046 DESCRIBE_STYLE (XIMStatusNone); | |
| 1047 #undef DESCRIBE_STYLE | |
| 1048 stderr_out("\n"); | |
| 1049 } | |
| 1050 | |
| 1051 void | |
| 1052 describe_XIMStyles (XIMStyles *p) | |
| 1053 { | |
| 1054 int i; | |
| 1055 stderr_out ("%d Style(s):\n", p->count_styles); | |
| 1056 for (i=0; i<p->count_styles ; i++) | |
| 1057 { | |
| 1058 describe_XIMStyle (p->supported_styles[i]); | |
| 1059 } | |
| 1060 } | |
| 1061 | |
| 1062 #endif /* DEBUG_XEMACS */ | |
| 1063 | |
| 1064 /* Random cruft follows */ | |
| 1065 | |
| 1066 #if 0 | |
| 1067 static void | |
| 1068 Unit_Test (struct frame *f, char * s) | |
| 1069 /* mrb unit testing */ | |
| 1070 { | |
| 1071 XrmValue fromVal, toVal; | |
| 1072 | |
| 1073 fromVal.addr = s; | |
| 1074 fromVal.size = strlen (s); | |
| 1075 toVal.addr = (XtPointer) &user_preferred_XIMStyles; | |
| 1076 toVal.size = sizeof (XIMStyles); | |
| 1077 | |
| 1078 if (XtConvertAndStore (FRAME_X_TEXT_WIDGET (f), XtRString, &fromVal, | |
| 1079 XtRXimStyles, &toVal) != False) | |
| 1080 { | |
| 1081 stderr_out ("Unit_Test: fromVal.addr=0x%x\n",fromVal.addr); | |
| 1082 stderr_out ("Unit_Test: fromVal.size=%d\n", fromVal.size); | |
| 1083 stderr_out ("Unit_Test: toVal.addr=0x%x\n", toVal.addr); | |
| 1084 stderr_out ("Unit_Test: toVal.size=%d\n", toVal.size); | |
| 1085 describe_XIMStyles ((XIMStyles *) toVal.addr); | |
| 1086 } | |
| 1087 } | |
| 1088 #endif | |
| 448 | 1089 #endif /* XIM_XLIB only */ |
| 428 | 1090 |
| 1091 #if 0 | |
| 1092 /* Get a fontset for IM to use */ | |
| 1093 void | |
| 1094 x_init_fontset (struct device *d) | |
| 1095 { | |
| 1096 Display *dpy = DEVICE_X_DISPLAY (d); | |
| 1097 XFontSet fontset; | |
| 1098 char ** missing_charsets; | |
| 1099 int num_missing_charsets; | |
| 1100 char * default_string; | |
| 1101 /* char * font_set_string = "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*";*/ | |
| 1102 char * font_set_string = "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*, -misc-fixed-medium-r-normal--14-130-75-75-c-70-jisx0201.1976-0,-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-0, -misc-fixed-medium-r-normal--14-130-75-75-c-70-jisx0201.1976-0" ; | |
| 1103 | |
| 1104 DEVICE_X_FONTSET (d) = fontset = | |
| 1105 XCreateFontSet (dpy, | |
| 1106 font_set_string, | |
| 1107 &missing_charsets, | |
| 1108 &num_missing_charsets, | |
| 1109 &default_string); | |
| 1110 | |
| 1111 if (fontset == NULL) | |
| 1112 { | |
| 1113 stderr_out ("Unable to create fontset from string:\n%s\n", font_set_string); | |
| 1114 return; | |
| 1115 } | |
| 1116 if (num_missing_charsets > 0) | |
| 1117 { | |
| 1118 int i; | |
| 1119 stderr_out ("\nMissing charsets for fontset %s:\n", font_set_string); | |
| 1120 for (i=0; i < num_missing_charsets; i++) | |
| 1121 { | |
| 1122 stderr_out ("%s\n", missing_charsets[i]); | |
| 1123 } | |
| 1124 XFreeStringList (missing_charsets); | |
| 1125 stderr_out ("Default string: %s\n", default_string); | |
| 1126 } | |
| 1127 | |
| 1128 #ifdef DEBUG_XIM | |
| 1129 describe_XFontSet (fontset); | |
| 1130 #endif | |
| 1131 } | |
| 1132 #endif /* 0 */ |
