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.gen...@univ-lorraine.fr

// 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;
}
_______________________________________________
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

Reply via email to