annotate src/input-method-xlib.c @ 2367:ecf1ebac70d8

[xemacs-hg @ 2004-11-04 23:05:23 by ben] commit mega-patch configure.in: Turn off -Winline and -Wchar-subscripts. Use the right set of cflags when compiling modules. Rewrite ldap configuration to separate the inclusion of lber (needed in recent Cygwin) from the basic checks for the needed libraries. add a function for MAKE_JUNK_C; initially code was added to generate xemacs.def using this, but it will need to be rewritten. add an rm -f for junk.c to avoid weird Cygwin bug with cp -f onto an existing file. Sort list of auto-detected functions and eliminate unused checks for stpcpy, setlocale and getwd. Add autodetection of Cygwin scanf problems BETA: Rewrite section on configure to indicate what flags are important and what not. digest-doc.c, make-dump-id.c, profile.c, sorted-doc.c: Add proper decls for main(). make-msgfile.c: Document that this is old junk. Move proposal to text.c. make-msgfile.lex: Move proposal to text.c. make-mswin-unicode.pl: Convert error-generating code so that the entire message will be seen as a single unrecognized token. mule/mule-ccl.el: Update docs. lispref/mule.texi: Update CCL docs. ldap/eldap.c: Mule-ize. Use EXTERNAL_LIST_LOOP_2 instead of deleted EXTERNAL_LIST_LOOP. * XEmacs 21.5.18 "chestnut" is released. --------------------------------------------------------------- MULE-RELATED WORK: --------------------------------------------------------------- --------------------------- byte-char conversion --------------------------- buffer.c, buffer.h, insdel.c, text.c: Port FSF algorithm for byte-char conversion, replacing broken previous version. Track the char position of the gap. Add functions to do char-byte conversion downwards as well as upwards. Move comments about algorithm workings to internals manual. --------------------------- work on types --------------------------- alloc.c, console-x-impl.h, dump-data.c, dump-data.h, dumper.c, dialog-msw.c, dired-msw.c, doc.c, editfns.c, esd.c, event-gtk.h, event-msw.c, events.c, file-coding.c, file-coding.h, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-shared.c, glyphs-x.c, glyphs.c, glyphs.h, gui.c, hpplay.c, imgproc.c, intl-win32.c, lrecord.h, lstream.c, keymap.c, lisp.h, libsst.c, linuxplay.c, miscplay.c, miscplay.h, mule-coding.c, nas.c, nt.c, ntheap.c, ntplay.c, objects-msw.c, objects-tty.c, objects-x.c, print.c, process-nt.c, process.c, redisplay.h, select-common.h, select-gtk.c, select-x.c, sgiplay.c, sound.c, sound.h, sunplay.c, sysfile.h, sysdep.c, syswindows.h, text.c, unexnt.c, win32.c, xgccache.c: Further work on types. This creates a full set of types for all the basic semantics of `char' that I have so far identified, so that its semantics can always be identified for the purposes of proper Mule-safe code, and the raw use of `char' always avoided. (1) More type renaming, for consistency of naming. Char_ASCII -> Ascbyte UChar_ASCII -> UAscbyte Char_Binary -> CBinbyte UChar_Binary -> Binbyte SChar_Binary -> SBinbyte (2) Introduce Rawbyte, CRawbyte, Boolbyte, Chbyte, UChbyte, and Bitbyte and use them. (3) New types Itext, Wexttext and Textcount for separating out the concepts of bytes and textual units (different under UTF-16 and UTF-32, which are potential internal encodings). (4) qxestr*_c -> qxestr*_ascii. lisp.h: New; goes with other qxe() functions. #### Maybe goes in a different section. lisp.h: Group generic int-type defs together with EMACS_INT defs. lisp.h: * lisp.h (WEXTTEXT_IS_WIDE) New defns. lisp.h: New type to replace places where int occurs as a boolean. It's signed because occasionally people may want to use -1 as an error value, and because unsigned ints are viral -- see comments in the internals manual against using them. dynarr.c: int -> Bytecount. --------------------------- Mule-izing --------------------------- device-x.c: Partially Mule-ize. dumper.c, dumper.h: Mule-ize. Use Rawbyte. Use stderr_out not printf. Use wext_*(). sysdep.c, syswindows.h, text.c: New Wexttext API for manipulation of external text that may be Unicode (e.g. startup code under Windows). emacs.c: Mule-ize. Properly deal with argv in external encoding. Use wext_*() and Wexttext. Use Rawbyte. #if 0 some old junk on SCO that is unlikely to be correct. Rewrite allocation code in run-temacs. emacs.c, symsinit.h, win32.c: Rename win32 init function and call it even earlier, to initialize mswindows_9x_p even earlier, for use in startup code (XEUNICODE_P). process.c: Use _wenviron not environ under Windows, to get Unicode environment variables. event-Xt.c: Mule-ize drag-n-drop related stuff. dragdrop.c, dragdrop.h, frame-x.c: Mule-ize. text.h: Add some more stand-in defines for particular kinds of conversion; use in Mule-ization work in frame-x.c etc. --------------------------- Freshening --------------------------- intl-auto-encap-win32.c, intl-auto-encap-win32.h: Regenerate. --------------------------- Unicode-work --------------------------- intl-win32.c, syswindows.h: Factor out common options to MultiByteToWideChar and WideCharToMultiByte. Add convert_unicode_to_multibyte_malloc() and convert_unicode_to_multibyte_dynarr() and use. Add stuff for alloca() conversion of multibyte/unicode. alloc.c: Use dfc_external_data_len() in case of unicode coding system. alloc.c, mule-charset.c: Don't zero out and reinit charset Unicode tables. This fucks up dump-time loading. Anyway, either we load them at dump time or run time, never both. unicode.c: Dump the blank tables as well. --------------------------------------------------------------- DOCUMENTATION, MOSTLY MULE-RELATED: --------------------------------------------------------------- EmacsFrame.c, emodules.c, event-Xt.c, fileio.c, input-method-xlib.c, mule-wnnfns.c, redisplay-gtk.c, redisplay-tty.c, redisplay-x.c, regex.c, sysdep.c: Add comment about Mule work needed. text.h: Add more documentation describing why DFC routines were not written to return their value. Add some other DFC documentation. console-msw.c, console-msw.h: Add pointer to docs in win32.c. emacs.c: Add comments on sources of doc info. text.c, charset.h, unicode.c, intl-win32.c, intl-encap-win32.c, text.h, file-coding.c, mule-coding.c: Collect background comments and related to text matters and internationalization, and proposals for work to be done, in text.c or Internals manual, stuff related to specific textual API's in text.h, and stuff related to internal implementation of Unicode conversion in unicode.c. Put lots of pointers to the comments to make them easier to find. s/mingw32.h, s/win32-common.h, s/win32-native.h, s/windowsnt.h, win32.c: Add bunches of new documentation on the different kinds of builds and environments under Windows and how they work. Collect this info in win32.c. Add pointers to these docs in the relevant s/* files. emacs.c: Document places with long comments. Remove comment about exiting, move to internals manual, put in pointer. event-stream.c: Move docs about event queues and focus to internals manual, put in pointer. events.h: Move docs about event stream callbacks to internals manual, put in pointer. profile.c, redisplay.c, signal.c: Move documentation to the Internals manual. process-nt.c: Add pointer to comment in win32-native.el. lisp.h: Add comments about some comment conventions. lisp.h: Add comment about the second argument. device-msw.c, redisplay-msw.c: @@#### comments are out-of-date. --------------------------------------------------------------- PDUMP WORK (MOTIVATED BY UNICODE CHANGES) --------------------------------------------------------------- alloc.c, buffer.c, bytecode.c, console-impl.h, console.c, device.c, dumper.c, lrecord.h, elhash.c, emodules.h, events.c, extents.c, frame.c, glyphs.c, glyphs.h, mule-charset.c, mule-coding.c, objects.c, profile.c, rangetab.c, redisplay.c, specifier.c, specifier.h, window.c, lstream.c, file-coding.h, file-coding.c: PDUMP: Properly implement dump_add_root_block(), which never worked before, and is necessary for dumping Unicode tables. Pdump name changes for accuracy: XD_STRUCT_PTR -> XD_BLOCK_PTR. XD_STRUCT_ARRAY -> XD_BLOCK_ARRAY. XD_C_STRING -> XD_ASCII_STRING. *_structure_* -> *_block_*. lrecord.h: some comments added about dump_add_root_block() vs dump_add_root_block_ptr(). extents.c: remove incorrect comment about pdump problems with gap array. --------------------------------------------------------------- ALLOCATION --------------------------------------------------------------- abbrev.c, alloc.c, bytecode.c, casefiddle.c, device-msw.c, device-x.c, dired-msw.c, doc.c, doprnt.c, dragdrop.c, editfns.c, emodules.c, file-coding.c, fileio.c, filelock.c, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-x.c, gui-msw.c, gui-x.c, imgproc.c, intl-win32.c, lread.c, menubar-gtk.c, menubar.c, nt.c, objects-msw.c, objects-x.c, print.c, process-nt.c, process-unix.c, process.c, realpath.c, redisplay.c, search.c, select-common.c, symbols.c, sysdep.c, syswindows.h, text.c, text.h, ui-byhand.c: New macros {alloca,xnew}_{itext,{i,ext,raw,bin,asc}bytes} for more convenient allocation of these commonly requested items. Modify functions to use alloca_ibytes, alloca_array, alloca_extbytes, xnew_ibytes, etc. also XREALLOC_ARRAY, xnew. alloc.c: Rewrite the allocation functions to factor out repeated code. Add assertions for freeing dumped data. lisp.h: Moved down and consolidated with other allocation stuff. lisp.h, dynarr.c: New functions for allocation that's very efficient when mostly in LIFO order. lisp.h, text.c, text.h: Factor out some stuff for general use by alloca()-conversion funs. text.h, lisp.h: Fill out convenience routines for allocating various kinds of bytes and put them in lisp.h. Use them in place of xmalloc(), ALLOCA(). text.h: Fill out the convenience functions so the _MALLOC() kinds match the alloca() kinds. --------------------------------------------------------------- ERROR-CHECKING --------------------------------------------------------------- text.h: Create ASSERT_ASCTEXT_ASCII() and ASSERT_ASCTEXT_ASCII_LEN() from similar Eistring checkers and change the Eistring checkers to use them instead. --------------------------------------------------------------- MACROS IN LISP.H --------------------------------------------------------------- lisp.h: Redo GCPRO declarations. Create a "base" set of functions that can be used to generate any kind of gcpro sets -- regular, ngcpro, nngcpro, private ones used in GC_EXTERNAL_LIST_LOOP_2. buffer.c, callint.c, chartab.c, console-msw.c, device-x.c, dialog-msw.c, dired.c, extents.c, ui-gtk.c, rangetab.c, nt.c, mule-coding.c, minibuf.c, menubar-msw.c, menubar.c, menubar-gtk.c, lread.c, lisp.h, gutter.c, glyphs.c, glyphs-widget.c, fns.c, fileio.c, file-coding.c, specifier.c: Eliminate EXTERNAL_LIST_LOOP, which does not check for circularities. Use EXTERNAL_LIST_LOOP_2 instead or EXTERNAL_LIST_LOOP_3 or EXTERNAL_PROPERTY_LIST_LOOP_3 or GC_EXTERNAL_LIST_LOOP_2 (new macro). Removed/redid comments on EXTERNAL_LIST_LOOP. --------------------------------------------------------------- SPACING FIXES --------------------------------------------------------------- callint.c, hftctl.c, number-gmp.c, process-unix.c: Spacing fixes. --------------------------------------------------------------- FIX FOR GEOMETRY PROBLEM IN FIRST FRAME --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. toolbar.c: bug fix for problem of initial frame being 77 chars wide on Windows. will be overridden by my other ws. --------------------------------------------------------------- FIX FOR LEAKING PROCESS HANDLES: --------------------------------------------------------------- process-nt.c: Fixes for leaking handles. Inspired by work done by Adrian Aichner <adrian@xemacs.org>. --------------------------------------------------------------- FIX FOR CYGWIN BUG (Unicode-related): --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. --------------------------------------------------------------- WARNING FIXES: --------------------------------------------------------------- console-stream.c: `reinit' is unused. compiler.h, event-msw.c, frame-msw.c, intl-encap-win32.c, text.h: Add stuff to deal with ANSI-aliasing warnings I got. regex.c: Gather includes together to avoid warning. --------------------------------------------------------------- CHANGES TO INITIALIZATION ROUTINES: --------------------------------------------------------------- buffer.c, emacs.c, console.c, debug.c, device-x.c, device.c, dragdrop.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, font-lock.c, frame-msw.c, glyphs-widget.c, glyphs.c, gui-x.c, insdel.c, lread.c, lstream.c, menubar-gtk.c, menubar-x.c, minibuf.c, mule-wnnfns.c, objects-msw.c, objects.c, print.c, scrollbar-x.c, search.c, select-x.c, text.c, undo.c, unicode.c, window.c, symsinit.h: Call reinit_*() functions directly from emacs.c, for clarity. Factor out some redundant init code. Move disallowed stuff that had crept into vars_of_glyphs() into complex_vars_of_glyphs(). Call init_eval_semi_early() from eval.c not in the middle of vars_of_() in emacs.c since there should be no order dependency in the latter calls. --------------------------------------------------------------- ARMAGEDDON: --------------------------------------------------------------- alloc.c, emacs.c, lisp.h, print.c: Rename inhibit_non_essential_printing_operations to inhibit_non_essential_conversion_operations. text.c: Assert on !inhibit_non_essential_conversion_operations. console-msw.c, print.c: Don't do conversion in SetConsoleTitle or FindWindow to avoid problems during armageddon. Put #errors for NON_ASCII_INTERNAL_FORMAT in places where problems would arise. --------------------------------------------------------------- CHANGES TO THE BUILD PROCEDURE: --------------------------------------------------------------- config.h.in, s/cxux.h, s/usg5-4-2.h, m/powerpc.h: Add comment about correct ordering of this file. Rearrange everything to follow this -- put all #undefs together and before the s&m files. Add undefs for HAVE_ALLOCA, C_ALLOCA, BROKEN_ALLOCA_IN_FUNCTION_CALLS, STACK_DIRECTION. Remove unused HAVE_STPCPY, HAVE_GETWD, HAVE_SETLOCALE. m/gec63.h: Deleted; totally broken, not used at all, not in FSF. m/7300.h, m/acorn.h, m/alliant-2800.h, m/alliant.h, m/altos.h, m/amdahl.h, m/apollo.h, m/att3b.h, m/aviion.h, m/celerity.h, m/clipper.h, m/cnvrgnt.h, m/convex.h, m/cydra5.h, m/delta.h, m/delta88k.h, m/dpx2.h, m/elxsi.h, m/ews4800r.h, m/gould.h, m/hp300bsd.h, m/hp800.h, m/hp9000s300.h, m/i860.h, m/ibmps2-aix.h, m/ibmrs6000.h, m/ibmrt-aix.h, m/ibmrt.h, m/intel386.h, m/iris4d.h, m/iris5d.h, m/iris6d.h, m/irist.h, m/isi-ov.h, m/luna88k.h, m/m68k.h, m/masscomp.h, m/mg1.h, m/mips-nec.h, m/mips-siemens.h, m/mips.h, m/news.h, m/nh3000.h, m/nh4000.h, m/ns32000.h, m/orion105.h, m/pfa50.h, m/plexus.h, m/pmax.h, m/powerpc.h, m/pyrmips.h, m/sequent-ptx.h, m/sequent.h, m/sgi-challenge.h, m/symmetry.h, m/tad68k.h, m/tahoe.h, m/targon31.h, m/tekxd88.h, m/template.h, m/tower32.h, m/tower32v3.h, m/ustation.h, m/vax.h, m/wicat.h, m/xps100.h: Delete C_ALLOCA, HAVE_ALLOCA, STACK_DIRECTION, BROKEN_ALLOCA_IN_FUNCTION_CALLS. All of this is auto-detected. When in doubt, I followed recent FSF sources, which also have these things deleted.
author ben
date Thu, 04 Nov 2004 23:08:28 +0000
parents 04bc9d2f42c7
children 3d8143fc88e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Various functions for X11R5+ input methods, using the Xlib interface.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1996 Sun Microsystems.
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
3 Copyright (C) 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* Written by Martin Buchholz. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 /* This file implements an interface to X input methods, available
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 with X11R5 and above. See O'Reilly, Xlib programmer's guide,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 and X11 R6 release guide chapters on internationalized input,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 for further details */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 Policy:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 The XIM is of the device, by the device, for the device.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 The XIC is of each frame, by each frame, for each frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 The exceptions are:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 1. Activate XICs on poor frames when the XIM is back.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
38 2. Deactivate all the XICs when the XIM goes down.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
40 Implementation:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 - Register a callback for an XIM when the X device is being initialized.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 XIM_init_device (d) { XRegisterIMInstantiateCallback (); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 The "XRegisterIMInstantiateCallback" is called when an XIM become
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 available on the X display.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 - Catch the XIC when the frame is being initialized if XIM was available.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 XIM_init_frame (f) { ... XCreateIC (); ... }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 - Release the XIC when the frame is being closed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 XIM_delete_frame (f) { ... FRAME_X_XIC (f) = NULL; ... }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 "XIM_delete_frame" is a "DestroyCallback" function declared in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 XIM_init_frame ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 - Release all the XICs when the XIM was down accidentally.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 In IMDestroyCallback:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 DEVICE_FRAME_LOOP (...) { FRAME_X_XIC (f) = NULL; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
59 - Re-enable XIC for all the frames which don't have XIC when the XIM
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 is back.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 In IMInstantiateCallback:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 DEVICE_FRAME_LOOP (...) { XIM_init_frame (f); }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 Note:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 - Currently, we don't use XDestroyIC because of _XimProtoCloseIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 (internally registered as im->methods->close) does "Xfree (ic)".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 #include "lisp.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
74
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
75 #include "buffer.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
76 #include "device-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
77 #include "events.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
78 #include "frame-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
79 #include "window-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
80
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
81 #include "console-x-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
82 #include "EmacsFrame.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 851
diff changeset
83
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #include <X11/Xlocale.h> /* More portable than <locale.h> ? */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
85 #include <X11/Xlib.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
87 #if !defined (XIM_XLIB) && !defined (USE_XFONTSET)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
88 #error neither XIM_XLIB nor USE_XFONTSET is defined??
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
91 #ifdef XIM_XLIB /* XIM_XLIB specific */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 /* Get/Set IC values for just one attribute */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 #ifdef DEBUG_XEMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 #define XIC_Value(Get_Set, xic, name, attr, value) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 char *bad_arg; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 XVaNestedList list = XVaCreateNestedList (0, attr, value, NULL); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 if ((bad_arg = X##Get_Set##ICValues (xic, name, list, NULL)) != NULL) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 stderr_out ("X" #Get_Set "ICValues " "bad Arg: %s\n", bad_arg); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 XFree (list); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 #else /* ! DEBUG_XEMACS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 #define XIC_Value(Get_Set, xic, name, attr, value) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 XVaNestedList list = XVaCreateNestedList (0, attr, value, NULL); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 X##Get_Set##ICValues (xic, name, list, NULL); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 XFree (list); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 #endif /* DEBUG_XEMACS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 static char DefaultXIMStyles[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 "XIMPreeditPosition|XIMStatusArea\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 "XIMPreeditPosition|XIMStatusNone\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 "XIMPreeditPosition|XIMStatusNothing\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 "XIMPreeditNothing|XIMStatusArea\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 "XIMPreeditNothing|XIMStatusNothing\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 "XIMPreeditNothing|XIMStatusNone\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 "XIMPreeditNone|XIMStatusArea\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 "XIMPreeditNone|XIMStatusNothing\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 "XIMPreeditNone|XIMStatusNone";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 static XIMStyle best_style (XIMStyles *user, XIMStyles *xim);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
124
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
125 #endif /* XIM_XLIB only */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
127 /* This function is documented, but no prototype in the header files */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
128 EXTERN_C char * XSetIMValues(XIM, ...);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
129
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
130 #ifdef XIM_XLIB /* starting XIM specific codes */
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
131
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
132 /* Callbacks for IM are supported from X11R6 or later. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
133 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
134
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
135 static Boolean xim_initted = False;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
136
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 /* Called from when XIM is destroying.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 Clear all the XIC when the XIM was destroying... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1204
diff changeset
140 IMDestroyCallback (XIM UNUSED (im), XPointer client_data,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1204
diff changeset
141 XPointer UNUSED (call_data))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 struct device *d = (struct device *)client_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 Lisp_Object tail;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 DEVICE_FRAME_LOOP (tail, d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 struct frame *target_frame = XFRAME (XCAR (tail));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 if (FRAME_X_P (target_frame) && FRAME_X_XIC (target_frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 /* XDestroyIC (FRAME_X_XIC (target_frame)); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 FRAME_X_XIC (target_frame) = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 DEVICE_X_XIM (d) = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 xim_initted = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 /* This is registered in XIM_init_device (when DEVICE is initializing).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 This activates XIM when XIM becomes available. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1204
diff changeset
164 IMInstantiateCallback (Display *dpy, XPointer client_data,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1204
diff changeset
165 XPointer UNUSED (call_data))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 struct device *d = (struct device *)client_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 XIM xim;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
169 char *name, *class_;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 XIMCallback ximcallback;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 Lisp_Object tail;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 /* if no xim is presented, initialize xim ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 if ( xim_initted == False )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 xim_initted = True;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
177 XtGetApplicationNameAndClass (dpy, &name, &class_);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
178 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class_);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 /* destroy callback for im */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
181 ximcallback.callback = (XIMProc) IMDestroyCallback;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 ximcallback.client_data = (XPointer) d;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 XSetIMValues (xim, XNDestroyCallback, &ximcallback, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 /* activate XIC on all the X frames... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 DEVICE_FRAME_LOOP (tail, d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 struct frame *target_frame = XFRAME (XCAR (tail));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 if (FRAME_X_P (target_frame) && !FRAME_X_XIC (target_frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 XIM_init_frame (target_frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
197 #endif /* HAVE_XREGISTERIMINSTANTIATECALLBACK */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 /* Initialize XIM for X device.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 Register the use of XIM using XRegisterIMInstantiateCallback. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 XIM_init_device (struct device *d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
204 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK /* X11R6+ */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 DEVICE_X_XIM (d) = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 XRegisterIMInstantiateCallback (DEVICE_X_DISPLAY (d), NULL, NULL, NULL,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
207 #ifdef XREGISTERIMINSTANTIATECALLBACK_NONSTANDARD_PROTOTYPE
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
208 /* The sixth parameter is of type
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
209 XPointer in XFree86 but (XPointer *)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
210 on most other X11's. */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
211 (XIDProc) IMInstantiateCallback,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
212 (XPointer) d
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
213 #else /* X Consortium prototype */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
214 (XIMProc) IMInstantiateCallback,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
215 (XPointer *) d
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
216 #endif /* XREGISTERIMINSTANTIATECALLBACK_NONSTANDARD_PROTOTYPE */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
217 );
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 return;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
219 #else /* pre-X11R6 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 Display *dpy = DEVICE_X_DISPLAY (d);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
221 char *name, *class_;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 XIM xim;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
224 XtGetApplicationNameAndClass (dpy, &name, &class_);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
225 DEVICE_X_XIM (d) = xim = XOpenIM (dpy, XtDatabase (dpy), name, class_);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 if (xim == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
228 warn_when_safe
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
229 (Qxintl, Qerror,
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
230 "Can't initialize XIM: XOpenIM() failed, no input server available");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES (d), NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
238 #endif /* HAVE_XREGISTERIMINSTANTIATECALLBACK */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 * For the frames
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 /* Callback for the deleting frame. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1204
diff changeset
248 XIM_delete_frame (Widget UNUSED (w), XtPointer client_data,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1204
diff changeset
249 XtPointer UNUSED (call_data))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 struct frame *f = (struct frame *) client_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 struct device *d = XDEVICE (FRAME_DEVICE (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 if (DEVICE_X_XIM (d))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 if (FRAME_X_XIC (f))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 XDestroyIC (FRAME_X_XIC (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 FRAME_X_XIC (f) = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 /* Initialize XIC for new frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 Create an X input context (XIC) for this frame. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 XIM_init_frame (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 struct device *d = XDEVICE (FRAME_DEVICE (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 XIM xim;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 Widget w = FRAME_X_TEXT_WIDGET (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 Window win = XtWindow (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 XRectangle p_area = {0,0,1,1}, s_area = {0,0,1,1};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 XPoint spot = {0,0};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 XIMStyle style;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 XVaNestedList p_list, s_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 XIMStyles styles;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 XFontSet fontset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 Pixel fg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 Pixel bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 char *inputmethod;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 } xic_vars_t;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 xic_vars_t xic_vars;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 XIC xic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
289 #define res(name, class_, representation, field, default_value) \
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
290 { name, class_, representation, sizeof(xic_vars.field), \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 XtOffsetOf(xic_vars_t, field), XtRString, default_value }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 static XtResource resources[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 /* name class represent'n field default value */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 res(XtNximStyles, XtCXimStyles, XtRXimStyles, styles, (XtPointer) DefaultXIMStyles),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 res(XtNfontSet, XtCFontSet, XtRFontSet, fontset, (XtPointer) XtDefaultFontSet),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 res(XtNximForeground, XtCForeground, XtRPixel, fg, (XtPointer) XtDefaultForeground),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 res(XtNximBackground, XtCBackground, XtRPixel, bg, (XtPointer) XtDefaultBackground)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 xim = DEVICE_X_XIM (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 if (!xim)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 w = FRAME_X_TEXT_WIDGET (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 * initialize XIC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 if (FRAME_X_XIC (f)) return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 XtGetApplicationResources (w, &xic_vars,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 resources, XtNumber (resources),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 NULL, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 if (!xic_vars.fontset)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
321 warn_when_safe
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
322 (Qxintl, Qerror,
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
323 "Can't initialize XIM: Can't get fontset resource for Input Method");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 FRAME_X_XIC (f) = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 /* construct xic */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 XGetIMValues (xim, XNQueryInputStyle, &DEVICE_X_XIM_STYLES(d), NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 FRAME_X_XIC_STYLE (f) = style =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 best_style (&xic_vars.styles, (XIMStyles *)DEVICE_X_XIM_STYLES(d));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 p_list = XVaCreateNestedList (0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 XNArea, &p_area,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 XNSpotLocation, &spot,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 XNForeground, xic_vars.fg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 XNBackground, xic_vars.bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 XNFontSet, xic_vars.fontset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 s_list = XVaCreateNestedList (0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 XNArea, &s_area,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 XNForeground, xic_vars.fg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 XNBackground, xic_vars.bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 XNFontSet, xic_vars.fontset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 FRAME_X_XIC (f) = xic =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 XCreateIC (xim,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 XNInputStyle, style,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 XNClientWindow, win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 XNFocusWindow, win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 XNPreeditAttributes, p_list,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 XNStatusAttributes, s_list,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 XFree (p_list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 XFree (s_list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 if (!xic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
361 warn_when_safe (Qxintl, Qerror,
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
362 "Can't initialize XIM: XCreateIC failed");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 if (style & XIMPreeditPosition)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 XPoint *frame_spot = &(FRAME_X_XIC_SPOT(f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 frame_spot->x = frame_spot->y = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 XIM_SetGeometry (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 XSetICFocus (xic);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
376 #ifdef HAVE_XREGISTERIMINSTANTIATECALLBACK
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 /* when frame is going to be destroyed (closed) */
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
378 XtAddCallback (FRAME_X_TEXT_WIDGET (f), XNDestroyCallback,
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
379 XIM_delete_frame, (XtPointer)f );
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 XIM_SetGeometry (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 XIC xic = FRAME_X_XIC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 XIMStyle style = FRAME_X_XIC_STYLE (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 XRectangle area;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 if (!xic || !f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 if (style & XIMStatusArea)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 /* Place Status Area in bottom right corner */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 /* Negotiate geometry of status area */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 /* See O'Reilly Xlib XIM chapter (but beware, it's buggy) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 XRectangle *needed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 /* If input method has existing status area, use its current size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 /* The following at least works for Sun's htt */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 area.x = area.y = area.width = area.height = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 XIC_Value (Set, xic, XNStatusAttributes, XNAreaNeeded, &area);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 XIC_Value (Get, xic, XNStatusAttributes, XNAreaNeeded, &needed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 if (needed->width == 0) /* Use XNArea instead of XNAreaNeeded */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 XIC_Value (Get, xic, XNStatusAttributes, XNArea, &needed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 area.width = needed->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 area.height = needed->height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 area.x = FRAME_RIGHT_BORDER_START (f) - area.width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 area.y = FRAME_BOTTOM_BORDER_START (f) - area.height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 #ifdef DEBUG_XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 stderr_out ("Putting StatusArea in x=%d y=%d w=%d h=%d\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 area.x, area.y, area.width, area.height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 #endif /* DEBUG_XIM */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 XIC_Value (Set, xic, XNStatusAttributes, XNArea, &area);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 if (style & XIMPreeditPosition)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 /* Set Preedit Area to whole frame size (sans border) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 /* We include the border because Preedit window might be larger
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 than display line at edge. #### FIX: we should adjust to make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 sure that there is always room for the spot sub-window */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 area.x = FRAME_LEFT_BORDER_START (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 area.y = FRAME_TOP_BORDER_START (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 area.width = FRAME_RIGHT_BORDER_END (f) - area.x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 area.height = FRAME_BOTTOM_BORDER_END (f) - area.y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 XIC_Value(Set, xic, XNPreeditAttributes, XNArea, &area);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 #ifdef DEBUG_XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 describe_XIC (xic);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 XIM_SetSpotLocation (struct frame *f, int x, int y)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 XIC xic = FRAME_X_XIC (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 XPoint *spot = &(FRAME_X_XIC_SPOT (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 /* Only care if we have a valid XIC using Over the Spot in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 * a different location */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 if (!xic ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 !(FRAME_X_XIC_STYLE (f) & XIMPreeditPosition) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (spot->x == (short) x &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 spot->y == (short) y))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 spot->x = (short) x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 spot->y = (short) y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 432
diff changeset
457 /* #### FIX: Must make sure spot fits within Preedit Area */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 XIC_Value (Set, xic, XNPreeditAttributes, XNSpotLocation, spot);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 #ifdef DEBUG_XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 stderr_out ("Spot: %d %d\n", spot->x, spot->y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 XIM_focus_event (struct frame *f, int in_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 if (FRAME_X_XIC (f) /* && FRAME_X_XIM_REGISTERED(f) */)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 (in_p ? XSetICFocus : XUnsetICFocus) (FRAME_X_XIC (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 #define XIM_Composed_Text_BUFSIZE 64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 typedef struct XIM_Composed_Text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 wchar_t data [XIM_Composed_Text_BUFSIZE];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 } XIM_Composed_Text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 static XIM_Composed_Text composed_input_buf = {XIM_Composed_Text_BUFSIZE, {0}};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 Window main_window;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 /* get_XIM_input -- Process results of input method composition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 This function copies the results of the input method composition to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 composed_input_buf. Then for each character, a custom event of type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 wc_atom is sent with the character as its data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 It is probably more efficient to copy the composition results to some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 allocated memory and send a single event pointing to that memory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 That would cut down on the event processing as well as allow quick
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 insertion into the buffer of the whole string. It might require some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 care, though, to avoid fragmenting memory through the allocation and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 freeing of many small chunks. Maybe the existing system for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (single-byte) string allocation can be used, multiplying the length by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 sizeof (wchar_t) to get the right size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 get_XIM_input (XKeyPressedEvent *x_key_event, XIC ic, Display *dpy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 KeySym keysym;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 Status status;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 XClientMessageEvent new_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 retry:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 len = XwcLookupString (ic, x_key_event, composed_input_buf.data,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 composed_input_buf.size, &keysym, &status);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 switch (status)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 case XBufferOverflow:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 /* GROW_WC_STRING (&composed_input_buf, 32); mrb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 goto retry;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 case XLookupChars:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 new_event.type = ClientMessage;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 new_event.display = x_key_event->display;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 new_event.window = x_key_event->window;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 new_event.message_type = wc_atom;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 new_event.format = 32; /* 32-bit wide data */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 new_event.data.l[2] = new_event.data.l[3] = new_event.data.l[4] = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 new_event.data.l[0] = x_key_event->time;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 for (i = 0; i < len; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 new_event.data.l[1] = ((wchar_t *) composed_input_buf.data)[i];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 XSendEvent (display, main_window, False, 0L, (XEvent *) &new_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 #endif /* 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 /* ============================================================== */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 /* X input method style determination */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 /* ============================================================== */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 #define done(type, value) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 if (toVal->addr != NULL) { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 if (toVal->size < sizeof(type)) { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 toVal->size = sizeof(type); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 return False; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 *(type*)toVal->addr = (value); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 } else { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 static type static_val; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 static_val = (value); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 toVal->addr = (XPointer)&static_val; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 toVal->size = sizeof(type); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 return True /* Caller supplies `;' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 #endif /* 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 * This is a standard Xt type converter, except that the caller MUST
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 * supply a proper non-NULL toVal XIMStyles structure that we will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 * fill in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 * fromVal points to a string like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 "XIMPreeditPosition|XIMStatusArea,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 XIMPreeditPosition|XIMStatusNothing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 XIMPreeditNothing|XIMStatusNothing"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 * This is converted in the obvious way to a XIMStyles structure.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 * mrb: #### Fix this to handle Motif-style specifications for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 * XIMStyles as well: overTheSpot, rootWindow, none */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 /* XtTypeConverter */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 Boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 EmacsXtCvtStringToXIMStyles (
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 Display *dpy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 XrmValuePtr args,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 Cardinal *num_args,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 XrmValuePtr fromVal,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 XrmValuePtr toVal,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 XtPointer *converter_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 #define STYLE_INFO(style) { style, #style, sizeof(#style) }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 static struct XIMStyleInfo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
585 const XIMStyle style;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
586 const char * const name;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
587 const int namelen;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 } emacs_XIMStyleInfo[] = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 STYLE_INFO (XIMPreeditPosition|XIMStatusArea),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 STYLE_INFO (XIMPreeditPosition|XIMStatusNothing),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 STYLE_INFO (XIMPreeditPosition|XIMStatusNone),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 STYLE_INFO (XIMPreeditNothing|XIMStatusArea),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 STYLE_INFO (XIMPreeditNothing|XIMStatusNothing),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 STYLE_INFO (XIMPreeditNothing|XIMStatusNone),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 STYLE_INFO (XIMPreeditNone|XIMStatusArea),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 STYLE_INFO (XIMPreeditNone|XIMStatusNothing),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 STYLE_INFO (XIMPreeditNone|XIMStatusNone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 #undef STYLE_INFO
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 char *s = (char *) fromVal->addr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 char *end = s + fromVal->size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
603 XIMStyles * const p = (XIMStyles *) toVal->addr;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
604 const char * const delimiter = " \t\n\r:;," ;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
605 const int max_styles = XtNumber(emacs_XIMStyleInfo);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 char *c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 #ifdef DEBUG_XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 stderr_out ("EmacsCvtStringToXIMStyles called with size=%d, string=\"%s\"\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 fromVal->size, (char *) fromVal->addr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 #endif /* DEBUG_XIM */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 if (*num_args != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 "XtToolkitError",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 "String to XIMStyle conversion requires exactly 0 parameters",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 (String *)NULL, (Cardinal *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 return False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 #ifdef DEBUG_XEMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 /* Make sure caller is giving us good data */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 assert (fromVal->addr != NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 assert (fromVal->size == strlen(fromVal->addr)+1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 assert (toVal->addr != NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 assert (toVal->size == sizeof(XIMStyles));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 #endif /* DEBUG_XEMACS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 p->count_styles = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 p->supported_styles = xnew_array (XIMStyle, max_styles);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 * The following routine assumes that the style name resource is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 * identical with the programmatic name of style. For example,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 * "XIMPreeditPosition|XIMStatusArea" means the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 * XIMPreeditPosition|XIMStatusArea value is specified. If the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 * style name is changed, such as "OverTheSpot|imDisplaysInClient",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 * the parsing logic below should be modified as well. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 if ((c = strtok(s, delimiter)) == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 c = end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 while (c < end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 for(i=0 ; i<max_styles ; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 struct XIMStyleInfo *rec = emacs_XIMStyleInfo + i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 if(!strncmp(c, rec->name, rec->namelen - 1)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 p->supported_styles[p->count_styles] = rec->style;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 p->count_styles++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 if((c = strtok(NULL, delimiter)) == NULL) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 break ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 if (p->count_styles == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 { /* No valid styles? */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
664 /* !!#### */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
665 char *buf = (char *) ALLOCA (strlen (fromVal->addr)
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
666 + strlen (DefaultXIMStyles)
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
667 + 100);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 XrmValue new_from;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 XtAppContext the_app_con = XtDisplayToApplicationContext (dpy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 sprintf(buf, "Cannot convert string \"%s\" to type XIMStyles.\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 "Using default string \"%s\" instead.\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 fromVal->addr, DefaultXIMStyles);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 "XtToolkitError",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 buf, (String *)NULL, (Cardinal *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 new_from.addr = DefaultXIMStyles;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 new_from.size = sizeof(DefaultXIMStyles);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 return EmacsXtCvtStringToXIMStyles (dpy, args, num_args,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 &new_from, toVal, converter_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 XREALLOC_ARRAY (p->supported_styles, XIMStyle, p->count_styles);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 *converter_data = (char *) True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 return True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 /* XtDestructor */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 EmacsFreeXIMStyles (
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 XtAppContext app,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 XrmValuePtr toVal,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 XtPointer converter_data,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1204
diff changeset
693 XrmValuePtr UNUSED (args),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 Cardinal *num_args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 #ifdef DEBUG_XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 stderr_out ("Converter data: %x\n", converter_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 stderr_out ("EmacsFreeXIMStyles called\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 #endif /* DEBUG_XIM */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 if (*num_args != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 XtAppWarningMsg(app, "wrongParameters","freeXIMStyles","XtToolkitError",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 "Freeing an XIMStyles requires that zero arguments be passwd",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 (String *)NULL, (Cardinal *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 if (converter_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 Boolean free_p = (Boolean) (int) converter_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 XIMStyles *styles = (XIMStyles *) toVal->addr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 if (free_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 XFree ( styles->supported_styles );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 /* O'Reilly XLib Programming Manual, pg. 371 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 /* Much nicer implementation than O'Reilly */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 /* Choose the more `complicated', hence nicer, XIM input style */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 static XIMStyle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 BetterStyle (XIMStyle s, XIMStyle t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 #define CHECK_XIMStyle_BIT(bit) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 if ((s ^ t) & bit) { return (s & bit) ? s : t; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 CHECK_XIMStyle_BIT (XIMPreeditCallbacks);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 CHECK_XIMStyle_BIT (XIMPreeditPosition);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 CHECK_XIMStyle_BIT (XIMPreeditArea);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 CHECK_XIMStyle_BIT (XIMPreeditNothing);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 CHECK_XIMStyle_BIT (XIMStatusCallbacks);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 CHECK_XIMStyle_BIT (XIMStatusArea);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 CHECK_XIMStyle_BIT (XIMStatusNothing);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 #undef CHECK_XIMStyle_BIT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 return s ? s : t ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 #endif /* 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 /* Choose the best style, given:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 * - user preferences (already checked to be supported by XEmacs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 * - styles supported by the input method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 #define DEFAULTStyle (XIMPreeditNothing|XIMStatusNothing)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 static XIMStyle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 best_style (XIMStyles *user, XIMStyles *xim)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 REGISTER int i, j;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 for (i=0 ; i<user->count_styles ; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 for (j=0 ; j<xim->count_styles ; j++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 if (user->supported_styles[i] == xim->supported_styles[j])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 return user->supported_styles[i];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 return DEFAULTStyle; /* Default Style */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 /* These lisp-callable functions will be sealed until xim-leim is needed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 Oct 22 1999 - kazz */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 * External callable function for XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 DEFUN ("x-open-xim", Fx_open_xim, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 Open the XIC on the frame if XIM is available.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 Commonly, use this as \(x-open-xim \(selected-frame)).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 If the frame is not on X device, return signal.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 If XIC is created successfully return t. If not return nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 (frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 struct frame *f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 CHECK_LIVE_FRAME (frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 f = XFRAME (frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 if (!FRAME_X_P (f))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
778 invalid_argument ("This frame is not on X device", frame);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 XIM_init_frame (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 return FRAME_X_XIC (f) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 DEFUN ("x-close-xim", Fx_close_xim, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 Close the XIC on the frame if it exists.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 Commonly, use this as \(x-close-xim \(selected-frame)).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 If the frame is not on X device, return signal.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 Otherwise, it destroys the XIC if it exists, then returns t anyway.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 (frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 struct frame *f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 struct device *d;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 CHECK_LIVE_FRAME (frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 f = XFRAME (frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 if (!FRAME_X_P (f))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
798 invalid_argument ("This frame is not on X device", frame);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 d = XDEVICE (FRAME_DEVICE (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 if (DEVICE_X_XIM (d)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 /* XDestroyIC (FRAME_X_XIC (XFRAME (f))); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 FRAME_X_XIC (XFRAME (f)) = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 #endif /* if 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 syms_of_input_method_xlib (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 #if 0 /* see above */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 DEFSUBR (Fx_open_xim);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 DEFSUBR (Fx_close_xim);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 vars_of_input_method_xlib (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 Fprovide (intern ("xim"));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 /* ====================================================================== */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 /* Internal Debugging Routines */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 /* ====================================================================== */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 #ifdef DEBUG_XEMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 describe_XIM (XIM xim)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 XIMStyles *styles;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 /* Print locale of XIM */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 stderr_out ("\nXIM Locale of IM: %s\n", XLocaleOfIM(xim));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 /* List supported input method styles */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 XGetIMValues(xim, XNQueryInputStyle, &styles, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 stderr_out ("\n%d input style(s) supported by input method.\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 styles->count_styles);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 #ifdef DEBUG_XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 for (i=0; i < styles->count_styles; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 describe_XIMStyle (styles->supported_styles[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 #endif /* DEBUG_XIM */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 XFree(styles);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 describe_XFontSet (XFontSet fontset)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 XFontStruct **font_struct_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 char **font_name_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 int count, i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 if (fontset == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 stderr_out ("NULL\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 count = XFontsOfFontSet (fontset, &font_struct_list, &font_name_list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 stderr_out ( "%d font(s) available:\n", count);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 for (i=0 ; i < count ; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 stderr_out ("Font: %s\n", *(font_name_list+i));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 describe_Status (Status status)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 #define DESCRIBE_STATUS(value) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 if (status == value) stderr_out ("Status: " #value "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 DESCRIBE_STATUS (XBufferOverflow);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 DESCRIBE_STATUS (XLookupNone);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 DESCRIBE_STATUS (XLookupKeySym);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 DESCRIBE_STATUS (XLookupBoth);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 DESCRIBE_STATUS (XLookupChars);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 #undef DESCRIBE_STATUS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 describe_Window (Window win)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 char xwincmd[128];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 sprintf (xwincmd, "xwininfo -id 0x%x >&2; xwininfo -events -id 0x%x >&2",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 (int) win, (int) win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 system (xwincmd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 describe_XIC (XIC xic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 XIMStyle style;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 Window client_win=0, focus_win=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 char *resourceName = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 char *resourceClass = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 char *bad_arg = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 unsigned long filter_mask = NoEventMask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 XVaNestedList p_list, s_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 XFontSet p_fontset = NULL, s_fontset = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 Pixel p_fg=0, p_bg = 0, s_fg=0, s_bg = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 XRectangle *p_area = NULL, *s_area = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 XRectangle *p_needed = NULL, *s_needed = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 XPoint *p_spot = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 /* Check for valid input context and method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 if (!xic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 stderr_out ("Input method is NULL\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 if (!XIMOfIC(xic))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 stderr_out ("XIMOfIC() returns NULL\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 /* Print out Input Context Attributes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 p_list = XVaCreateNestedList (0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 XNFontSet, &p_fontset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 XNArea, &p_area,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 XNAreaNeeded, &p_needed,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 XNSpotLocation, &p_spot,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 XNForeground, &p_fg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 XNBackground, &p_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 s_list = XVaCreateNestedList (0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 XNFontSet, &s_fontset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 XNArea, &s_area,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 XNAreaNeeded, &s_needed,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 XNForeground, &s_fg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 XNBackground, &s_bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 bad_arg = XGetICValues(xic,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 XNInputStyle, &style,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 XNFilterEvents, &filter_mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 XNClientWindow, &client_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 XNFocusWindow, &focus_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 XNResourceName, &resourceName,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 XNResourceClass, &resourceClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 XNPreeditAttributes, p_list,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 XNStatusAttributes, s_list,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 XFree(p_list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 XFree(s_list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 if (bad_arg != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 stderr_out ("Couldn't get IC value: %s\n", bad_arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 stderr_out ("\nInput method context attributes:\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 stderr_out ("Style: "); describe_XIMStyle (style);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 stderr_out ("Client window: %lx\n", (unsigned long int)client_win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 stderr_out ("Focus window: %lx\n", (unsigned long int)focus_win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 stderr_out ("Preedit:\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 describe_XRectangle (" Area", p_area);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 describe_XRectangle (" Area needed", p_needed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 stderr_out (" foreground: %lx\n", (unsigned long int)p_fg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 stderr_out (" background: %lx\n", (unsigned long int)p_bg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 stderr_out (" fontset: "); describe_XFontSet (p_fontset);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 stderr_out ("Status:\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 describe_XRectangle (" Area", s_area);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 describe_XRectangle (" Area needed", s_needed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 stderr_out (" foreground: %lx\n", (unsigned long int)s_fg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 stderr_out (" background: %lx\n", (unsigned long int)s_bg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 stderr_out (" fontset: \n"); describe_XFontSet (s_fontset);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 stderr_out ("XNResourceName: %s\n", resourceName ? resourceName : "NULL");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 stderr_out ("XNResourceClass: %s\n", resourceClass ? resourceClass : "NULL");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 stderr_out ("XNFilterEvents: "); describe_event_mask (filter_mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 describe_XRectangle (char *name, XRectangle *r)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 if (r == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 stderr_out ("%s: NULL\n", name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 stderr_out ("%s: x=%d y=%d w=%d h=%d\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 name, r->x, r->y, r->width, r->height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 /* Print out elements of Event mask */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 /* Defines from X11/X.h */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 describe_event_mask (unsigned long mask)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 #define DESCRIBE_EVENT_MASK(bit) if ((bit) & mask) stderr_out (#bit " ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 DESCRIBE_EVENT_MASK (NoEventMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 DESCRIBE_EVENT_MASK (KeyPressMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 DESCRIBE_EVENT_MASK (KeyReleaseMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 DESCRIBE_EVENT_MASK (ButtonPressMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 DESCRIBE_EVENT_MASK (ButtonReleaseMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 DESCRIBE_EVENT_MASK (EnterWindowMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 DESCRIBE_EVENT_MASK (LeaveWindowMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 DESCRIBE_EVENT_MASK (PointerMotionMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 DESCRIBE_EVENT_MASK (PointerMotionHintMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 DESCRIBE_EVENT_MASK (Button1MotionMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 DESCRIBE_EVENT_MASK (Button2MotionMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 DESCRIBE_EVENT_MASK (Button3MotionMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 DESCRIBE_EVENT_MASK (Button4MotionMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 DESCRIBE_EVENT_MASK (Button5MotionMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 DESCRIBE_EVENT_MASK (ButtonMotionMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 DESCRIBE_EVENT_MASK (KeymapStateMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 DESCRIBE_EVENT_MASK (ExposureMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 DESCRIBE_EVENT_MASK (VisibilityChangeMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 DESCRIBE_EVENT_MASK (StructureNotifyMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 DESCRIBE_EVENT_MASK (ResizeRedirectMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 DESCRIBE_EVENT_MASK (SubstructureNotifyMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 DESCRIBE_EVENT_MASK (SubstructureRedirectMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 DESCRIBE_EVENT_MASK (FocusChangeMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 DESCRIBE_EVENT_MASK (PropertyChangeMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 DESCRIBE_EVENT_MASK (ColormapChangeMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 DESCRIBE_EVENT_MASK (OwnerGrabButtonMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 #undef DESCRIBE_EVENT_MASK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 stderr_out("\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 describe_XIMStyle (XIMStyle style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 #define DESCRIBE_STYLE(bit) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 if (bit & style) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 stderr_out (#bit " ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 DESCRIBE_STYLE (XIMPreeditArea);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 DESCRIBE_STYLE (XIMPreeditCallbacks);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 DESCRIBE_STYLE (XIMPreeditPosition);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 DESCRIBE_STYLE (XIMPreeditNothing);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 DESCRIBE_STYLE (XIMPreeditNone);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 DESCRIBE_STYLE (XIMStatusArea);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 DESCRIBE_STYLE (XIMStatusCallbacks);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 DESCRIBE_STYLE (XIMStatusNothing);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 DESCRIBE_STYLE (XIMStatusNone);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 #undef DESCRIBE_STYLE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 stderr_out("\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 describe_XIMStyles (XIMStyles *p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 stderr_out ("%d Style(s):\n", p->count_styles);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 for (i=0; i<p->count_styles ; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 describe_XIMStyle (p->supported_styles[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 #endif /* DEBUG_XEMACS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 /* Random cruft follows */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 Unit_Test (struct frame *f, char * s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 /* mrb unit testing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 XrmValue fromVal, toVal;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 fromVal.addr = s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 fromVal.size = strlen (s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 toVal.addr = (XtPointer) &user_preferred_XIMStyles;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 toVal.size = sizeof (XIMStyles);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 if (XtConvertAndStore (FRAME_X_TEXT_WIDGET (f), XtRString, &fromVal,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 XtRXimStyles, &toVal) != False)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 stderr_out ("Unit_Test: fromVal.addr=0x%x\n",fromVal.addr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 stderr_out ("Unit_Test: fromVal.size=%d\n", fromVal.size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 stderr_out ("Unit_Test: toVal.addr=0x%x\n", toVal.addr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 stderr_out ("Unit_Test: toVal.size=%d\n", toVal.size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 describe_XIMStyles ((XIMStyles *) toVal.addr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 #endif
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
1078 #endif /* XIM_XLIB only */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 /* Get a fontset for IM to use */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 x_init_fontset (struct device *d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 XFontSet fontset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 char ** missing_charsets;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 int num_missing_charsets;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 char * default_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 /* char * font_set_string = "-dt-interface user-medium-r-normal-s*-*-*-*-*-*-*-*-*";*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 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" ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 DEVICE_X_FONTSET (d) = fontset =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 XCreateFontSet (dpy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 font_set_string,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 &missing_charsets,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 &num_missing_charsets,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 &default_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 if (fontset == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 stderr_out ("Unable to create fontset from string:\n%s\n", font_set_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 if (num_missing_charsets > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 stderr_out ("\nMissing charsets for fontset %s:\n", font_set_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 for (i=0; i < num_missing_charsets; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 stderr_out ("%s\n", missing_charsets[i]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 XFreeStringList (missing_charsets);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 stderr_out ("Default string: %s\n", default_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 #ifdef DEBUG_XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 describe_XFontSet (fontset);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 #endif /* 0 */