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

List:       wine-devel
Subject:    Re: Traditional Chinese (CP950) not displaying in WINE
From:       "Dmitry Timoshkov" <dmitry () baikal ! ru>
Date:       2002-02-27 15:00:51
[Download RAW message or body]

"leanne" <leanne@thizlinux.com> wrote:

> I am sorry that I am newbie to Xlib, wine and xcin.  
> I would like to ask if I should modify dlls/x11drv/x11drv_main.c,
> in process_attach(), continue the call of TSXOpenIM(display, NULL, NULL, 
> NULL);

I'm not an X expert either. But at least I have a working (for me)
test program created by Ivan Pascal (attached). You could use it
as a start.

-- 
Dmitry.

["intest.c" (application/octet-stream)]

#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xlocale.h>

static Display *dpy;
static GC gc;

static XIM im;
static XIC ic;

static void do_FocusIn(XEvent *event)
{
    char *a;

    printf("FocusIn for %lx\n", event->xany.window);
    XUnsetICFocus(ic);
    if((a = XSetICValues(ic, XNFocusWindow, event->xany.window, 0)))
	fprintf(stderr, "Could not set IC value %s!\n", a);
    XSetICFocus(ic);
}

static void prologue(XEvent *eventp, char *event_name)
{
    XAnyEvent *e = (XAnyEvent *) eventp;

    printf ("\n%s event, serial %ld, synthetic %s, window 0x%lx,\n",
	    event_name, e->serial, e->send_event ? "Yes" : "No", e->window);
}

static void do_KeyPress(XEvent *eventp)
{
    XKeyEvent *e = (XKeyEvent *) eventp;
    KeySym ks;
    char *ksname;
    int nbytes, n;
    unsigned char str[256+1];
    Bool filtered;
    Window w;

    if(XGetICValues(ic, XNFocusWindow, &w, 0))
	printf("Could not get current XNFocusWindow!\n");
    else
	printf("Current XNFocusWindow = %lx\n", w);

//    nbytes = XLookupString (e, str, 256, &ks, NULL);

    filtered = XFilterEvent(eventp, None);
    if(!filtered)
	nbytes = XmbLookupString (ic, e, str, 256, &ks, NULL);
    else
	nbytes = 0;

    if (ks == NoSymbol)
	ksname = "NoSymbol";
    else if (!(ksname = XKeysymToString (ks)))
	ksname = "(no name)";
    printf ("    root 0x%lx, subw 0x%lx, time %lu, (%d,%d), root:(%d,%d),\n",
	    e->root, e->subwindow, e->time, e->x, e->y, e->x_root, e->y_root);
    printf ("    state 0x%x, keycode %u (keysym 0x%lx, %s), same_screen %s,\n",
	    e->state, e->keycode, ks, ksname, e->same_screen ? "Yes" : "No");
    printf("     XFilterEvent returns: %s\n", filtered? "True":"False");

    if (nbytes < 0) nbytes = 0;
    if (nbytes > 256) nbytes = 256;
    str[nbytes] = '\0';
    printf ("    XLookupString gives %d characters:  \"%s\" : ", nbytes, str);
    for(n = 0; n < nbytes; n++) {
	 printf ("%x ", str[n]);
    }
    printf("\n");

    XDrawImageString(dpy, eventp->xany.window, gc, 20, 20, str, nbytes);
}

static void do_KeyRelease(XEvent *eventp)
{
//    do_KeyPress (eventp);		/* since it has the same info */
}

int main(int argc, char *argv[])
{
    XSizeHints hints;
    int borderwidth = 2;
    XSetWindowAttributes attr;
    unsigned long mask;
    char *name = "Input Tester";
    unsigned long back, fore;
    XGCValues values;
    Window w;

    printf("Current locale: %s\n", setlocale(LC_CTYPE, ""));

    dpy = XOpenDisplay (NULL);
    if (!dpy) {
	fprintf (stderr, "Unable to open display\n");
	exit (1);
    }

    im = XOpenIM(dpy, NULL, NULL, NULL);
    if (im == NULL) {
       printf("Can't open IM\n"); exit(1);
    }

    printf("XLocaleOfIM: %s\n", XLocaleOfIM(im));

    ic = XCreateIC(im,  XNInputStyle, XIMPreeditNothing|XIMStatusNothing, 0);
    if (ic == NULL) {
       printf("Can't create IC\n"); exit(1);
    }

    /* select for all events */
    attr.event_mask = FocusChangeMask | KeyPressMask | KeyReleaseMask;

    hints.width = hints.min_width = 200;
    hints.height = hints.min_height = 200;
    hints.flags = PMinSize;
    hints.x = hints.y = 0;
    
    back = WhitePixel(dpy, DefaultScreen(dpy));
    fore = BlackPixel(dpy, DefaultScreen(dpy));

    attr.background_pixel = back;
    attr.border_pixel = fore;
    mask = (CWBackPixel | CWBorderPixel | CWEventMask);

    w = XCreateWindow (dpy, RootWindow (dpy, DefaultScreen(dpy)),
			   hints.x, hints.y,
			   hints.width, hints.height, borderwidth, 0,
			   InputOutput, (Visual *)CopyFromParent,
			   mask, &attr);
    printf("Window 1 = %lx\n", w);
    XSetStandardProperties (dpy, w, name, NULL, (Pixmap) 0,
				argv, argc, &hints);
    gc = XCreateGC(dpy, w, 0, &values);
    XSetForeground(dpy, gc, fore);
    XSetBackground(dpy, gc, back);
    XMapWindow (dpy, w);

    w = XCreateWindow (dpy, RootWindow (dpy, DefaultScreen(dpy)), hints.x, hints.y,
			   hints.width, hints.height, borderwidth, 0,
			   InputOutput, (Visual *)CopyFromParent,
			   mask, &attr);
    printf("Window 2 = %lx\n", w);
    XSetStandardProperties (dpy, w, name, NULL, (Pixmap) 0,
				argv, argc, &hints);
    gc = XCreateGC(dpy, w, 0, &values);
    XSetForeground(dpy, gc, fore);
    XSetBackground(dpy, gc, back);
    XMapWindow (dpy, w);

    for (;;) {
	XEvent event;

	XNextEvent (dpy, &event);

	switch (event.type) {
	  case FocusOut:
	    break;
	  case FocusIn:
	    do_FocusIn(&event);
	    break;
	  case KeyPress:
	    prologue (&event, "KeyPress");
	    do_KeyPress (&event);
	    break;
	  case KeyRelease:
	    prologue (&event, "KeyRelease");
	    do_KeyRelease (&event);
	    break;
	  default:
	    printf ("Unknown event type %d\n", event.type);
	    break;
	}
    }

    XCloseDisplay (dpy);
    return 0;
}


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

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