[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg
Subject:    input context attribute "XNFocusWindow"
From:       Lucien Gentis <lucien.gentis () univ-lorraine ! fr>
Date:       2016-04-28 12:40:38
Message-ID: 1917aa2c-1abf-80d6-1fdf-ef0c17138ab7 () univ-lorraine ! fr
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi to all,

My system : Linux - Ubuntu 14.04

I am developing an application which relies on Xlib Library and I try to 
internationalize it.

In order to be able to type in accented character, some of them with 
dead keys, I use XmbLookupString function and a unique Input Context.

Since my app has several X windows, each time one of them gets input 
focus, I must set "XNFocusWindow" attribute  to it through XSetICValues 
function, but it doesn't seem to work:

If "w" is the X window I want to set as "XNFocusWindow" attribute of the 
IC, when I reread this attribute through XGetICValues function, I don't 
obtain the same value:

XSetICValues(ic,XNFocusWindow,w,NULL);
Window winicfocus;
XGetICValues(ic,XNFocusWindow,&winicfocus,NULL);
printf ("Window w id : %ld - IC focus window : %ld\n",w,winicfocus);

I get:

Window w id : 77594625 - IC focus window : 0

To illustrate that, I have joined a little programme you should compile 
through this command:
gcc -g -Wall prog-1.cc -o prog-1 -lX11

-- 
Lucien GENTIS
UNIVERSITE DE LORRAINE - ESPE
Centre de Ressources Informatiques
5, Rue Paul Richard
C.O. 3 - MAXEVILLE
54528 LAXOU-CEDEX

Tél. 03 72 74 13 28
Email : lucien.gentis@univ-lorraine.fr


[Attachment #5 (text/html)]

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi to all,<br>
    <br>
    My system : Linux - Ubuntu 14.04<br>
    <br>
    I am developing an application which relies on Xlib Library and I
    try to internationalize it.<br>
    <br>
    In order to be able to type in accented character, some of them with
    dead keys, I use XmbLookupString function and a unique Input
    Context.<br>
    <br>
    Since my app has several X windows, each time one of them gets input
    focus, I must set "XNFocusWindow" attribute   to it through
    XSetICValues function, but it doesn't seem to work:<br>
    <br>
    If "w" is the X window I want to set as "XNFocusWindow" attribute of
    the IC, when I reread this attribute through XGetICValues function,
    I don't obtain the same value:<br>
    <br>
    XSetICValues(ic,XNFocusWindow,w,NULL);<br>
    Window winicfocus;<br>
    XGetICValues(ic,XNFocusWindow,&amp;winicfocus,NULL);<br>
    printf ("Window w id : %ld - IC focus window : %ld\n",w,winicfocus);<br>
    <br>
    I get:<br>
    <br>
    Window w id : 77594625 - IC focus window : 0<br>
    <br>
    To illustrate that, I have joined a little programme you should
    compile through this command:<br>
    gcc -g -Wall prog-1.cc -o prog-1 -lX11<br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Lucien GENTIS
UNIVERSITE DE LORRAINE - ESPE
Centre de Ressources Informatiques
5, Rue Paul Richard
C.O. 3 - MAXEVILLE
54528 LAXOU-CEDEX

Tél. 03 72 74 13 28
Email : <a class="moz-txt-link-abbreviated" \
href="mailto:lucien.gentis@univ-lorraine.fr">lucien.gentis@univ-lorraine.fr</a></pre> \
</body> </html>


["prog-1.cc" (text/plain)]

// Written by Ch. Tronche (http://tronche.lri.fr:8000/)
// Copyright by the author. This is unmaintained, no-warranty free software. 
// Please use freely. It is appreciated (but by no means mandatory) to
// acknowledge the author's contribution. Thank you.
// Started on Thu Jun 26 23:29:03 1997

//
// Xlib tutorial: 1st program
// Make a window appear on the screen.
//

#include <X11/Xlib.h> // Every Xlib program must include this
#include <locale.h>
#include <stdlib.h>
#include <stdio.h>

#define NIL (0)       // A name for the void pointer

int main()
{
	// Opening the display
        Display *dpy = XOpenDisplay(NIL);
      
        // Creating a new window
	Window w = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 
			       200, 100, 0, 
			       CopyFromParent, CopyFromParent, CopyFromParent,
			       NIL, 0);

	// Setting locale : mine is fr_FR.UTF-8
    	if (setlocale(LC_ALL, "") == NULL) {
    	    printf("cannot set locale.\n");
	    exit(1);
    	}
	// is my locale supported ?
    	if (!XSupportsLocale()) {
    	    printf("X does not support locale %s.\n",setlocale(LC_ALL, NULL));
	    exit(1);
  	}
	// setting modifiers
  	if (XSetLocaleModifiers("") == NULL) {
  	    printf("Warning: cannot set locale modifiers.\n");
 	}

	// opening input method
	XIM im = XOpenIM(dpy, NULL, NULL, NULL);
	if (im == NULL) {
        	printf("Couldn't open input method.\n");
        	exit(1);
    	}
	
	// creating input context
	XIC ic=XCreateIC(im,XNInputStyle,XIMPreeditNothing|XIMStatusNothing,NULL);
	if (ic == NULL) {
        	printf("Couldn't create input context.\n");
        	exit(1);
	}

	// newly created IC gains focus
	XSetICFocus(ic);

	// set window focus for the IC
	XSetICValues(ic,XNFocusWindow,w,NULL);

	// rereads window focus for the IC
	Window winicfocus;
	XGetICValues(ic,XNFocusWindow,&winicfocus,NULL);

	// Here comes the problem:
	// I have set XNFocusWindow attribute to "w"
	// So, if I reread it through XGetICValues function into winicfocus variable,
	// winicfocus should contain window "w" 's id, but it's not the case :



	// shows there's something wrong . . .
      	printf ("Window w id : %ld - IC focus window : %ld\n",w,winicfocus);

	return 0;
}

[Attachment #7 (text/plain)]

_______________________________________________
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: https://lists.x.org/mailman/listinfo/xorg
Your subscription address: %(user_address)s

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic