test/testnativex11.c
author David Ludwig <dludwig@pobox.com>
Tue, 12 Feb 2013 12:57:06 -0500
changeset 8424 3cf9501008f1
parent 5535 96594ac5fd1a
child 7517 965d57022c01
permissions -rw-r--r--
WinRT: fixed bug: SDL_CreateWindow wouldn't work after an initial window was created + destroyed
slouken@5535
     1
/*
slouken@5535
     2
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
slouken@5535
     3
slouken@5535
     4
  This software is provided 'as-is', without any express or implied
slouken@5535
     5
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     6
  arising from the use of this software.
slouken@5535
     7
slouken@5535
     8
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
     9
  including commercial applications, and to alter it and redistribute it
slouken@5535
    10
  freely.
slouken@5535
    11
*/
slouken@3057
    12
slouken@3057
    13
#include "testnative.h"
slouken@3057
    14
slouken@3057
    15
#ifdef TEST_NATIVE_X11
slouken@3057
    16
slouken@3057
    17
static void *CreateWindowX11(int w, int h);
slouken@3057
    18
static void DestroyWindowX11(void *window);
slouken@3057
    19
slouken@3057
    20
NativeWindowFactory X11WindowFactory = {
slouken@3057
    21
    "x11",
slouken@3057
    22
    CreateWindowX11,
slouken@3057
    23
    DestroyWindowX11
slouken@3057
    24
};
slouken@3057
    25
slouken@3057
    26
static Display *dpy;
slouken@3057
    27
slouken@3057
    28
static void *
slouken@3057
    29
CreateWindowX11(int w, int h)
slouken@3057
    30
{
slouken@3057
    31
    Window window = 0;
slouken@3057
    32
slouken@3057
    33
    dpy = XOpenDisplay(NULL);
slouken@3057
    34
    if (dpy) {
slouken@3057
    35
        window =
slouken@3057
    36
            XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, w, h, 0, 0,
slouken@3057
    37
                                0);
slouken@3057
    38
        XMapRaised(dpy, window);
slouken@3057
    39
        XSync(dpy, False);
slouken@3057
    40
    }
slouken@3057
    41
    return (void *) window;
slouken@3057
    42
}
slouken@3057
    43
slouken@3057
    44
static void
slouken@3057
    45
DestroyWindowX11(void *window)
slouken@3057
    46
{
slouken@3057
    47
    if (dpy) {
slouken@3057
    48
        XDestroyWindow(dpy, (Window) window);
slouken@3057
    49
        XCloseDisplay(dpy);
slouken@3057
    50
    }
slouken@3057
    51
}
slouken@3057
    52
slouken@3057
    53
#endif