test/testnativex11.c
author Sam Lantinga <slouken@libsdl.org>
Thu, 25 Apr 2013 00:26:17 -0700
changeset 7110 2a98852fd58d
parent 5535 96594ac5fd1a
child 7517 965d57022c01
permissions -rw-r--r--
Fixed bug 1582 - Allow disabling SDL_VIDEO_DRIVER_WINDOWS

Marcus von Appen

Trying to build SDL 2.x (HG) on Win32 platforms with either VS.NET or MinGW requires one to have the video subsystem and SDL_VIDEO_DRIVER_WINDOWS flag enabled due to the helper window creation routines.

The attached patch changes the helper window creation behaviour, so that one can build SDL2 without the video subsystem or Windows video drivers on Win32 platforms.
     1 /*
     2   Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
     3 
     4   This software is provided 'as-is', without any express or implied
     5   warranty.  In no event will the authors be held liable for any damages
     6   arising from the use of this software.
     7 
     8   Permission is granted to anyone to use this software for any purpose,
     9   including commercial applications, and to alter it and redistribute it
    10   freely.
    11 */
    12 
    13 #include "testnative.h"
    14 
    15 #ifdef TEST_NATIVE_X11
    16 
    17 static void *CreateWindowX11(int w, int h);
    18 static void DestroyWindowX11(void *window);
    19 
    20 NativeWindowFactory X11WindowFactory = {
    21     "x11",
    22     CreateWindowX11,
    23     DestroyWindowX11
    24 };
    25 
    26 static Display *dpy;
    27 
    28 static void *
    29 CreateWindowX11(int w, int h)
    30 {
    31     Window window = 0;
    32 
    33     dpy = XOpenDisplay(NULL);
    34     if (dpy) {
    35         window =
    36             XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, w, h, 0, 0,
    37                                 0);
    38         XMapRaised(dpy, window);
    39         XSync(dpy, False);
    40     }
    41     return (void *) window;
    42 }
    43 
    44 static void
    45 DestroyWindowX11(void *window)
    46 {
    47     if (dpy) {
    48         XDestroyWindow(dpy, (Window) window);
    49         XCloseDisplay(dpy);
    50     }
    51 }
    52 
    53 #endif