test/testnativex11.c
changeset 3057 089a77aebb7d
child 5535 96594ac5fd1a
equal deleted inserted replaced
3056:a434fe6360df 3057:089a77aebb7d
       
     1 
       
     2 #include "testnative.h"
       
     3 
       
     4 #ifdef TEST_NATIVE_X11
       
     5 
       
     6 static void *CreateWindowX11(int w, int h);
       
     7 static void DestroyWindowX11(void *window);
       
     8 
       
     9 NativeWindowFactory X11WindowFactory = {
       
    10     "x11",
       
    11     CreateWindowX11,
       
    12     DestroyWindowX11
       
    13 };
       
    14 
       
    15 static Display *dpy;
       
    16 
       
    17 static void *
       
    18 CreateWindowX11(int w, int h)
       
    19 {
       
    20     Window window = 0;
       
    21 
       
    22     dpy = XOpenDisplay(NULL);
       
    23     if (dpy) {
       
    24         window =
       
    25             XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, w, h, 0, 0,
       
    26                                 0);
       
    27         XMapRaised(dpy, window);
       
    28         XSync(dpy, False);
       
    29     }
       
    30     return (void *) window;
       
    31 }
       
    32 
       
    33 static void
       
    34 DestroyWindowX11(void *window)
       
    35 {
       
    36     if (dpy) {
       
    37         XDestroyWindow(dpy, (Window) window);
       
    38         XCloseDisplay(dpy);
       
    39     }
       
    40 }
       
    41 
       
    42 #endif