[PATCH xim] modules/im/ximcp: Send display and screen number to XIM server

Peter Hutterer peter.hutterer at who-t.net
Tue Jun 20 00:24:43 UTC 2017


On Sat, Feb 18, 2017 at 12:22:34PM +0900, Takao Fujiwara wrote:
> Enables that client application sends its screen number to XIM server.
> In ZaphodHeads environment, XIM server needs to know the screen
> number to launch the lookup window in the right screen.
> I think this way keeps the back compatibility.


for the archives, Takao and I worked on this on IRC last week:
this patch isn't generic enough to really handle all possible use-cases (and
thus justify a protocol change) but it looks like it's not needed anyway.
XIM server and client communicate using a Window, based on that the XIM
server can get the screen the client is on, there's no need for an extra
channel here.

Cheers,
   Peter

> 
> Signed-off-by: Takao Fujiwara <takao.fujiwara1 at gmail.com>
> ---
>  modules/im/ximcp/imDefIm.c | 32 ++++++++++++++++++++++++++++++++
>  src/xlibi18n/XimProto.h    |  2 +-
>  2 files changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/modules/im/ximcp/imDefIm.c b/modules/im/ximcp/imDefIm.c
> index 9e877c0..d0b8368 100644
> --- a/modules/im/ximcp/imDefIm.c
> +++ b/modules/im/ximcp/imDefIm.c
> @@ -794,6 +794,35 @@ _XimOpenCheck(
>      return False;
>  }
>  
> +static INT16
> +_XimSetDisplayNumber(
> +    Xim  		 im,
> +    CARD8		*buf_b,
> +    INT16		 len)
> +{
> +    const char *display_string =  DisplayString(im->core.display);
> +    buf_b[len] = 0;
> +    buf_b[len+1] = 0;
> +
> +    if (display_string && (display_string = strchr(display_string, ':')) != NULL) {
> +	display_string++;
> +	if (*display_string != '\0') {
> +	    int number = atoi(display_string);
> +	    buf_b[len] = (number < 0) ? 0 : (number % 256);
> +	    display_string++;
> +	    if ((display_string = strchr(display_string, '.')) != NULL) {
> +		display_string++;
> +		if (*display_string != '\0') {
> +		    number = atoi(display_string);
> +		    buf_b[len+1] = (number < 0) ? 0 : (number % 256);
> +		}
> +	    }
> +	}
> +    }
> +
> +    return sizeof(CARD8) * 2;
> +}
> +
>  static Bool
>  _XimOpen(
>      Xim			 im)
> @@ -803,6 +832,7 @@ _XimOpen(
>      CARD8		*buf_b = &buf[XIM_HEADER_SIZE];
>      CARD16		*buf_s;
>      INT16		 len;
> +    INT16		 version_len;
>      CARD32		 reply32[BUFSIZE/4];
>      char		*reply = (char *)reply32;
>      XPointer		 preply;
> @@ -816,6 +846,8 @@ _XimOpen(
>      (void)strcpy((char *)&buf_b[1], locale_name);  /* locale name */
>      len += sizeof(BYTE);			   /* sizeof length */
>      XIM_SET_PAD(buf_b, len);			   /* pad */
> +    version_len = _XimSetDisplayNumber(im, buf_b, len);
> +    len += (version_len + XIM_PAD(version_len));
>  
>      _XimSetHeader((XPointer)buf, XIM_OPEN, 0, &len);
>      if (!(_XimWrite(im, len, (XPointer)buf)))
> diff --git a/src/xlibi18n/XimProto.h b/src/xlibi18n/XimProto.h
> index 6b0096d..881f975 100644
> --- a/src/xlibi18n/XimProto.h
> +++ b/src/xlibi18n/XimProto.h
> @@ -47,7 +47,7 @@ PERFORMANCE OF THIS SOFTWARE.
>   * Xim implementation revision
>   */
>  #define PROTOCOLMAJORVERSION		1
> -#define PROTOCOLMINORVERSION		0
> +#define PROTOCOLMINORVERSION		1
>  
>  /*
>   * Major Protocol number
> -- 
> 70DC79EC
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list