From 3562e78743202e43aec8727005182a2558117eca Mon Sep 17 00:00:00 2001 From: marha Date: Sun, 28 Jun 2009 22:07:26 +0000 Subject: Checked in the following released items: xkeyboard-config-1.4.tar.gz ttf-bitstream-vera-1.10.tar.gz font-alias-1.0.1.tar.gz font-sun-misc-1.0.0.tar.gz font-sun-misc-1.0.0.tar.gz font-sony-misc-1.0.0.tar.gz font-schumacher-misc-1.0.0.tar.gz font-mutt-misc-1.0.0.tar.gz font-misc-misc-1.0.0.tar.gz font-misc-meltho-1.0.0.tar.gz font-micro-misc-1.0.0.tar.gz font-jis-misc-1.0.0.tar.gz font-isas-misc-1.0.0.tar.gz font-dec-misc-1.0.0.tar.gz font-daewoo-misc-1.0.0.tar.gz font-cursor-misc-1.0.0.tar.gz font-arabic-misc-1.0.0.tar.gz font-winitzki-cyrillic-1.0.0.tar.gz font-misc-cyrillic-1.0.0.tar.gz font-cronyx-cyrillic-1.0.0.tar.gz font-screen-cyrillic-1.0.1.tar.gz font-xfree86-type1-1.0.1.tar.gz font-adobe-utopia-type1-1.0.1.tar.gz font-ibm-type1-1.0.0.tar.gz font-bitstream-type1-1.0.0.tar.gz font-bitstream-speedo-1.0.0.tar.gz font-bh-ttf-1.0.0.tar.gz font-bh-type1-1.0.0.tar.gz font-bitstream-100dpi-1.0.0.tar.gz font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz font-bh-100dpi-1.0.0.tar.gz font-adobe-utopia-100dpi-1.0.1.tar.gz font-adobe-100dpi-1.0.0.tar.gz font-util-1.0.1.tar.gz font-bitstream-75dpi-1.0.0.tar.gz font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz font-adobe-utopia-75dpi-1.0.1.tar.gz font-bh-75dpi-1.0.0.tar.gz bdftopcf-1.0.1.tar.gz font-adobe-75dpi-1.0.0.tar.gz mkfontscale-1.0.6.tar.gz openssl-0.9.8k.tar.gz bigreqsproto-1.0.2.tar.gz xtrans-1.2.2.tar.gz resourceproto-1.0.2.tar.gz inputproto-1.4.4.tar.gz compositeproto-0.4.tar.gz damageproto-1.1.0.tar.gz zlib-1.2.3.tar.gz xkbcomp-1.0.5.tar.gz freetype-2.3.9.tar.gz pthreads-w32-2-8-0-release.tar.gz pixman-0.12.0.tar.gz kbproto-1.0.3.tar.gz evieext-1.0.2.tar.gz fixesproto-4.0.tar.gz recordproto-1.13.2.tar.gz randrproto-1.2.2.tar.gz scrnsaverproto-1.1.0.tar.gz renderproto-0.9.3.tar.gz xcmiscproto-1.1.2.tar.gz fontsproto-2.0.2.tar.gz xextproto-7.0.3.tar.gz xproto-7.0.14.tar.gz libXdmcp-1.0.2.tar.gz libxkbfile-1.0.5.tar.gz libfontenc-1.0.4.tar.gz libXfont-1.3.4.tar.gz libX11-1.1.5.tar.gz libXau-1.0.4.tar.gz libxcb-1.1.tar.gz xorg-server-1.5.3.tar.gz --- libX11/modules/im/ximcp/imInsClbk.c | 292 ++++++++++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 libX11/modules/im/ximcp/imInsClbk.c (limited to 'libX11/modules/im/ximcp/imInsClbk.c') diff --git a/libX11/modules/im/ximcp/imInsClbk.c b/libX11/modules/im/ximcp/imInsClbk.c new file mode 100644 index 000000000..ac39f9dfd --- /dev/null +++ b/libX11/modules/im/ximcp/imInsClbk.c @@ -0,0 +1,292 @@ +/* $Xorg: imInsClbk.c,v 1.3 2000/08/17 19:45:13 cpqbld Exp $ */ +/****************************************************************** + + Copyright 1993, 1994 by Sony Corporation + +Permission to use, copy, modify, distribute, and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation, and that the name of Sony Corporation + not be used in advertising or publicity pertaining to distribution + of the software without specific, written prior permission. +Sony Corporation makes no representations about the suitability of + this software for any purpose. It is provided "as is" without + express or implied warranty. + +SONY CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + + Author: Makoto Wakamatsu Sony Corporation + makoto@sm.sony.co.jp + +******************************************************************/ +/* $XFree86: xc/lib/X11/imInsClbk.c,v 3.3 2003/05/27 22:26:26 tsi Exp $ */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#define NEED_EVENTS +#include "Xlibint.h" +#include "Xlcint.h" +#include "XlcPublic.h" +#include "Ximint.h" + + +typedef struct _XimInstCallback { + Bool call; + Bool destroy; + Display *display; + XLCd lcd; + char name[XIM_MAXLCNAMELEN]; + char *modifiers; + XrmDatabase rdb; + char *res_name; + char *res_class; + XIDProc callback; + XPointer client_data; + struct _XimInstCallback *next; +} XimInstCallbackRec, *XimInstCallback; + + +Private XimInstCallback callback_list = NULL; +Private Bool lock = False; + + +Private void +MakeLocale( XLCd lcd, char locale[] ) +{ + char *language, *territory, *codeset; + + _XGetLCValues( lcd, XlcNLanguage, &language, XlcNTerritory, &territory, + XlcNCodeset, &codeset, NULL ); + + strcpy( locale, language ); + if( territory && *territory ) { + strcat( locale, "_" ); + strcat( locale, territory ); + } + if( codeset && *codeset ) { + strcat( locale, "." ); + strcat( locale, codeset ); + } +} + + +Private Bool +_XimFilterPropertyNotify( + Display *display, + Window window, + XEvent *event, + XPointer client_data) +{ + Atom ims, actual_type, *atoms; + int actual_format; + unsigned long nitems, bytes_after; + int ii; + XIM xim; + Bool flag = False; + XimInstCallback icb, picb, tmp; + + if( (ims = XInternAtom( display, XIM_SERVERS, True )) == None || + event->xproperty.atom != ims || + event->xproperty.state == PropertyDelete ) + return( False ); + + if( XGetWindowProperty( display, RootWindow(display, 0), ims, 0L, 1000000L, + False, XA_ATOM, &actual_type, &actual_format, + &nitems, &bytes_after, (unsigned char **)&atoms ) + != Success ) { + return( False ); + } + if( actual_type != XA_ATOM || actual_format != 32 ) { + XFree( atoms ); + return( False ); + } + + lock = True; + for( ii = 0; ii < nitems; ii++, atoms ) { + if(XGetSelectionOwner (display, atoms[ii])) { + for( icb = callback_list; icb; icb = icb->next ) { + if( !icb->call && !icb->destroy ) { + xim = (*icb->lcd->methods->open_im)( icb->lcd, display, + icb->rdb, + icb->res_name, + icb->res_class ); + if( xim ) { + xim->methods->close( (XIM)xim ); + flag = True; + icb->call = True; + icb->callback( icb->display, icb->client_data, NULL ); + } + } + } + break; + } + } + XFree( atoms ); + + for( icb = callback_list, picb = NULL; icb; ) { + if( icb->destroy ) { + if( picb ) + picb->next = icb->next; + else + callback_list = icb->next; + tmp = icb; + icb = icb->next; + XFree( tmp ); + } + else { + picb = icb; + icb = icb->next; + } + } + lock = False; + + return( flag ); +} + + +Public Bool +_XimRegisterIMInstantiateCallback( + XLCd lcd, + Display *display, + XrmDatabase rdb, + char *res_name, + char *res_class, + XIDProc callback, + XPointer client_data) +{ + XimInstCallback icb, tmp; + XIM xim; + Window root; + XWindowAttributes attr; + + if( lock ) + return( False ); + + icb = (XimInstCallback)Xmalloc(sizeof(XimInstCallbackRec)); + if( !icb ) + return( False ); + icb->call = icb->destroy = False; + icb->display = display; + icb->lcd = lcd; + MakeLocale( lcd, icb->name ); + icb->modifiers = lcd->core->modifiers; /* XXXXX */ + icb->rdb = rdb; + icb->res_name = res_name; + icb->res_class = res_class; + icb->callback = callback; + icb->client_data = client_data; + icb->next = NULL; + + if( !callback_list ) + callback_list = icb; + else { + for( tmp = callback_list; tmp->next; tmp = tmp->next ); + tmp->next = icb; + } + + xim = (*lcd->methods->open_im)( lcd, display, rdb, res_name, res_class ); + + if( icb == callback_list ) { + root = RootWindow( display, 0 ); + XGetWindowAttributes( display, root, &attr ); + _XRegisterFilterByType( display, root, PropertyNotify, PropertyNotify, + _XimFilterPropertyNotify, (XPointer)NULL ); + XSelectInput( display, root, + attr.your_event_mask | PropertyChangeMask ); + } + + if( xim ) { + lock = True; + xim->methods->close( (XIM)xim ); + lock = False; + icb->call = True; + callback( display, client_data, NULL ); + } + + return( True ); +} + + +Public Bool +_XimUnRegisterIMInstantiateCallback( + XLCd lcd, + Display *display, + XrmDatabase rdb, + char *res_name, + char *res_class, + XIDProc callback, + XPointer client_data) +{ + char locale[XIM_MAXLCNAMELEN]; + XimInstCallback icb, picb; + + if( !callback_list ) + return( False ); + + MakeLocale( lcd, locale ); + + for( icb = callback_list, picb = NULL; icb; picb = icb, icb = icb->next ) { + if( !strcmp( locale, icb->name ) && + (lcd->core->modifiers == icb->modifiers || /* XXXXX */ + (lcd->core->modifiers && icb->modifiers && + !strcmp( lcd->core->modifiers, icb->modifiers ))) && + rdb == icb->rdb && /* XXXXX */ + ((res_name == NULL && icb->res_name == NULL) || + (res_name != NULL && icb->res_name != NULL && + !strcmp( res_name, icb->res_name ))) && + ((res_class == NULL && icb->res_class == NULL) || + (res_class != NULL && icb->res_class != NULL && + !strcmp( res_class, icb->res_class ))) && + (callback == icb->callback) && + (client_data == icb->client_data) && /* XXXXX */ + !icb->destroy ) { + if( lock ) + icb->destroy = True; + else { + if( !picb ) { + callback_list = icb->next; + _XUnregisterFilter( display, RootWindow(display, 0), + _XimFilterPropertyNotify, + (XPointer)NULL ); + } + else + picb->next = icb->next; + _XCloseLC( icb->lcd ); + XFree( icb ); + } + return( True ); + } + } + return( False ); +} + + +Public void +_XimResetIMInstantiateCallback( xim ) + Xim xim; +{ + char locale[XIM_MAXLCNAMELEN]; + XimInstCallback icb; + XLCd lcd = xim->core.lcd; + + if( !callback_list && lock ) + return; + + MakeLocale( lcd, locale ); + + for( icb = callback_list; icb; icb = icb->next ) + if( !strcmp( locale, icb->name ) && + (lcd->core->modifiers == icb->modifiers || + (lcd->core->modifiers && icb->modifiers && + !strcmp( lcd->core->modifiers, icb->modifiers ))) ) + icb->call = False; +} -- cgit v1.2.3