* $XConsortium: XICGetVal.c,v 1.16 91/12/02 17:29:37 rws Exp $
* Copyright 1990, 1991 by OMRON Corporation
* Copyright 1991 by the Massachusetts Institute of Technology
* 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 names of OMRON and MIT not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OMRON and MIT make no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
* OMRON AND MIT DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OMRON OR MIT 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
* TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
* Author: Seiji Kuwari OMRON Corporation
* kuwa%omron.co.jp@uunet.uu.net
#if NeedVarargsPrototypes
# define Va_start(a,b) va_start(a,b)
# define Va_start(a,b) va_start(a)
* Get a attributes of input context depended on the nested argument list.
_ICGetAttrValues(im
, args
, attr
, mask
, offset
, mask_only
)
register XIMrmResourceList xrmres
;
register unsigned int num_resources
= im
->core
.ic_num_attr_resources
;
XrmPermStringToQuark(XNSpotLocation
);
XrmQuark area_needed_name
=
XrmPermStringToQuark(XNAreaNeeded
);
XrmPermStringToQuark(XNArea
);
for (arg
= args
; arg
&& arg
->name
&& *(arg
->name
) ; arg
++) {
Name
= XrmStringToName(arg
->name
);
for (xrmres
= im
->core
.ic_attr_resources
, i
= 0;
i
< num_resources
; i
++, xrmres
++) {
if (Name
== xrmres
->xrm_name
) {
if (!(xrmres
->mode
& IMResourceRead
)) {
if (Name
== area_needed_name
|| Name
== area_name
||
location
= (XPointer
*)arg
->value
;
*location
= (XPointer
)Xmalloc(xrmres
->xrm_size
);
location
= (XPointer
*)&arg
->value
;
(void)_XCopyToArg((char *)attr
- xrmres
->xrm_offset
- 1,
(unsigned int)xrmres
->xrm_size
);
*mask
|= (1L << (xrmres
->mask
+ offset
));
if (i
>= num_resources
) return(arg
->name
);
* Get input context specified by the nested argument list.
_XipICGetValues(ic
, args
, mask
, mask_only
)
register XIMrmResourceList xrmres
;
register unsigned int num_resources
= im
->core
.ic_num_resources
;
XrmPermStringToQuark(XNPreeditAttributes
);
XrmPermStringToQuark(XNStatusAttributes
);
for (arg
= args
; arg
&& arg
->name
&& *(arg
->name
); arg
++) {
Name
= XrmStringToName(arg
->name
);
for (xrmres
= im
->core
.ic_resources
, i
= 0;
i
< num_resources
; i
++, xrmres
++) {
if (Name
== xrmres
->xrm_name
) {
if (Name
== preedit_name
) {
if ((err
= _ICGetAttrValues(im
, (XIMArg
*)arg
->value
,
mask
, 0, mask_only
)) != NULL
) {
} else if (Name
== status_name
) {
if ((err
= _ICGetAttrValues(im
, (XIMArg
*)arg
->value
,
if (!(xrmres
->mode
& IMResourceRead
)) {
(void) _XCopyToArg((char *)ic
- xrmres
->xrm_offset
- 1,
(unsigned int)xrmres
->xrm_size
);
*mask
|= (1L << (xrmres
->mask
));
if (i
>= num_resources
) return(arg
->name
);
_ReceiveICAttrValues(im
, attr
, mask
, offset
)
register ICAttributes
*attr
;
ximICAttributesReq reply
;
if (_XipReadFromIM(im
, (char *)&reply
, sz_ximICAttributesReq
) < 0)
if (mask
& (1L << (ICArea
+ offset
))) {
attr
->area
.x
= reply
.area_x
;
attr
->area
.y
= reply
.area_y
;
attr
->area
.width
= reply
.area_width
;
attr
->area
.height
= reply
.area_height
;
if (mask
& (1L << (ICAreaNeeded
+ offset
))) {
attr
->area_needed
.width
= reply
.areaneeded_width
;
attr
->area_needed
.height
= reply
.areaneeded_height
;
if (mask
& (1L << ICSpotLocation
+ offset
)) {
attr
->spot_location
.x
= reply
.spot_x
;
attr
->spot_location
.y
= reply
.spot_y
;
if (mask
& (1L << (ICColormap
+ offset
))) {
attr
->colormap
= reply
.colormap
;
if (mask
& (1L << (ICStdColormap
+ offset
))) {
attr
->std_colormap
= reply
.std_colormap
;
if (mask
& (1L << (ICForeground
+ offset
))) {
attr
->foreground
= reply
.foreground
;
if (mask
& (1L << (ICBackground
+ offset
))) {
attr
->background
= reply
.background
;
if (mask
& (1L << (ICBackgroundPixmap
+ offset
))) {
attr
->background_pixmap
= reply
.pixmap
;
if (mask
& (1L << (ICLineSpace
+ offset
))) {
attr
->line_space
= reply
.line_space
;
if (mask
& (1L << (ICCursor
+ offset
))) {
attr
->cursor
= reply
.cursor
;
_XipReceiveICValues(ic
, mask
)
register char *p
= NULL
, *p2
= NULL
;
req
.length
= sz_ximGetICReq
;
if ((_XipWriteToIM(im
, (char *)&req
, sz_ximGetICReq
) < 0) ||
(_XipFlushToIM(im
) < 0)) {
if (_XipReadFromIM(im
, (char *)&reply
, sz_ximGetICReply
) < 0) {
if (_XipReadFromIM(im
, (char *)&ic_req
, sz_ximICValuesReq
) < 0) {
if ((p
= Xmalloc((unsigned)(ic_req
.nbytes
+ 1))) == NULL
) return(-1);
if (_XipReadFromIM(im
, p
, ic_req
.nbytes
) < 0) {
if (ic_req
.nbytes2
> 0) {
if ((p2
= Xmalloc((unsigned)(ic_req
.nbytes2
+ 1))) == NULL
) return(-1);
if (_XipReadFromIM(im
, p2
, ic_req
.nbytes2
) < 0) {
p2
[ic_req
.nbytes2
] = '\0';
if (mask
& (1L << ICInputStyle
)) {
ic
->core
.input_style
= ic_req
.input_style
;
if (mask
& (1L << ICClientWindow
)) {
ic
->core
.client_window
= ic_req
.c_window
;
if (mask
& (1L << ICFocusWindow
)) {
ic
->core
.focus_window
= ic_req
.focus_window
;
if (mask
& (1L << ICFilterEvents
)) {
ic
->core
.filter_events
= ic_req
.filter_events
;
if (mask
& (1L << ICUsingLanguage
)) {
if (ic
->values
.using_language
) Xfree(ic
->values
.using_language
);
ic
->values
.using_language
= NULL
;
ic
->values
.using_language
= p
;
if (mask
& (1L << ICCurrentLanguage
)) {
if (ic
->values
.current_language
) Xfree(ic
->values
.current_language
);
ic
->values
.current_language
= NULL
;
ic
->values
.current_language
= p2
;
if (ic_req
.nbytes
> 0) Xfree(p
);
if (ic_req
.nbytes2
> 0) Xfree(p2
);
if ((_ReceiveICAttrValues(im
, &ic
->core
.preedit_attr
, mask
, 0) < 0) ||
(_ReceiveICAttrValues(im
, &ic
->core
.status_attr
, mask
, StatusOffset
) < 0)) {
_XipGetICValues(supic
, args
)
if (im
->fd
< 0) return(NULL
);
err
= _XipICGetValues(ic
, args
, &mask
, 1);
* Attempt to receive current IC data from the input manager.
if (!_XipReceiveICValues(ic
, mask
))
(void)_XipICGetValues(ic
, args
, &mask
, 0);