src/video/windows/SDL_windowswindow.c
author Sam Lantinga <slouken@libsdl.org>
Thu, 10 Nov 2011 06:38:26 -0500
changeset 6078 718b49ec039e
parent 6044 35448a5ea044
child 6138 4c64952a58fb
permissions -rw-r--r--
Fixed whitespace
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
     2
  Simple DirectMedia Layer
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
     7
  arising from the use of this software.
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
    11
  freely, subject to the following restrictions:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5495
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#include "SDL_config.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5980
diff changeset
    23
#if SDL_VIDEO_DRIVER_WINDOWS
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5980
diff changeset
    24
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
#include "../SDL_sysvideo.h"
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
    26
#include "../SDL_pixels_c.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#include "../../events/SDL_keyboard_c.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
5062
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    29
#include "SDL_windowsvideo.h"
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    30
#include "SDL_windowswindow.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
5062
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    32
/* This is included after SDL_windowsvideo.h, which includes windows.h */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
#include "SDL_syswm.h"
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
    34
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
    35
/* Windows CE compatibility */
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
    36
#ifndef SWP_NOCOPYBITS
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
    37
#define SWP_NOCOPYBITS 0
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
    38
#endif
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
    39
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
    40
/* Fake window to help with DirectInput events. */
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
    41
HWND SDL_HelperWindow = NULL;
2714
1d1be6137875 Merged last minute fixes from force feedback branch (r4031, r4033, r4034)
Sam Lantinga <slouken@libsdl.org>
parents: 2713
diff changeset
    42
static WCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher");
1d1be6137875 Merged last minute fixes from force feedback branch (r4031, r4033, r4034)
Sam Lantinga <slouken@libsdl.org>
parents: 2713
diff changeset
    43
static WCHAR *SDL_HelperWindowName = TEXT("SDLHelperWindowInputMsgWindow");
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
    44
static ATOM SDL_HelperWindowClass = 0;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
    45
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    46
#define STYLE_BASIC         (WS_CLIPSIBLINGS | WS_CLIPCHILDREN)
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    47
#define STYLE_FULLSCREEN    (WS_POPUP)
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    48
#define STYLE_BORDERLESS    (WS_POPUP)
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    49
#define STYLE_NORMAL        (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX)
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    50
#define STYLE_RESIZABLE     (WS_THICKFRAME | WS_MAXIMIZEBOX)
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    51
#define STYLE_MASK          (STYLE_FULLSCREEN | STYLE_BORDERLESS | STYLE_NORMAL | STYLE_RESIZABLE)
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    52
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    53
static DWORD
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    54
GetWindowStyle(SDL_Window * window)
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    55
{
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    56
    DWORD style = 0;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    57
6078
718b49ec039e Fixed whitespace
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
    58
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    59
        style |= STYLE_FULLSCREEN;
6078
718b49ec039e Fixed whitespace
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
    60
    } else {
718b49ec039e Fixed whitespace
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
    61
        if (window->flags & SDL_WINDOW_BORDERLESS) {
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    62
            style |= STYLE_BORDERLESS;
6078
718b49ec039e Fixed whitespace
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
    63
        } else {
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    64
            style |= STYLE_NORMAL;
6078
718b49ec039e Fixed whitespace
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
    65
        }
718b49ec039e Fixed whitespace
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
    66
        if (window->flags & SDL_WINDOW_RESIZABLE) {
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    67
            style |= STYLE_RESIZABLE;
6078
718b49ec039e Fixed whitespace
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
    68
        }
718b49ec039e Fixed whitespace
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
    69
    }
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    70
    return style;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    71
}
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
    72
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
static int
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
    74
SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
{
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
    76
    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
5246
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
    77
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
    SDL_WindowData *data;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
    /* Allocate the window data */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
    data = (SDL_WindowData *) SDL_malloc(sizeof(*data));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
    if (!data) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
        SDL_OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
        return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
    }
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
    86
    data->window = window;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
    data->hwnd = hwnd;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    88
    data->hdc = GetDC(hwnd);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
    data->created = created;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
    data->mouse_pressed = SDL_FALSE;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
    91
    data->videodata = videodata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
5980
612b41c44af1 Make sure window->driverdata is set before we might need it.
Ryan C. Gordon <icculus@icculus.org>
parents: 5581
diff changeset
    93
    window->driverdata = data;
612b41c44af1 Make sure window->driverdata is set before we might need it.
Ryan C. Gordon <icculus@icculus.org>
parents: 5581
diff changeset
    94
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
    /* Associate the data with the window */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
    if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    97
        ReleaseDC(hwnd, data->hdc);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
        SDL_free(data);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
        WIN_SetError("SetProp() failed");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
        return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
    /* Set up the window proc function */
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   104
#ifdef GWLP_WNDPROC
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
    data->wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC);
4733
983eb9d5ed31 Change SDL to not use DefWindowProc as the window class' window procedure.
dewyatt
parents: 3697
diff changeset
   106
    if (data->wndproc == WIN_WindowProc) {
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3530
diff changeset
   107
        data->wndproc = NULL;
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   108
    } else {
4735
8568ebdb5f1f Added else to make things clear.
dewyatt
parents: 4733
diff changeset
   109
        SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) WIN_WindowProc);
8568ebdb5f1f Added else to make things clear.
dewyatt
parents: 4733
diff changeset
   110
    }
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   111
#else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   112
    data->wndproc = (WNDPROC) GetWindowLong(hwnd, GWL_WNDPROC);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   113
    if (data->wndproc == WIN_WindowProc) {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   114
        data->wndproc = NULL;
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   115
    } else {
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   116
        SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR) WIN_WindowProc);
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   117
    }
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   118
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
    /* Fill in the SDL window with the window data */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
    {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
        POINT point;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
        point.x = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
        point.y = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
        if (ClientToScreen(hwnd, &point)) {
5246
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   126
            window->x = point.x;
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   127
            window->y = point.y;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
    {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
        RECT rect;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
        if (GetClientRect(hwnd, &rect)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
            window->w = rect.right;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
            window->h = rect.bottom;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
    {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
        DWORD style = GetWindowLong(hwnd, GWL_STYLE);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
        if (style & WS_VISIBLE) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
            window->flags |= SDL_WINDOW_SHOWN;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
        } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
            window->flags &= ~SDL_WINDOW_SHOWN;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
        if (style & (WS_BORDER | WS_THICKFRAME)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
            window->flags &= ~SDL_WINDOW_BORDERLESS;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
        } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
            window->flags |= SDL_WINDOW_BORDERLESS;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
        if (style & WS_THICKFRAME) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
            window->flags |= SDL_WINDOW_RESIZABLE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
        } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
            window->flags &= ~SDL_WINDOW_RESIZABLE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
        }
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   154
#ifdef WS_MAXIMIZE
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
        if (style & WS_MAXIMIZE) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
            window->flags |= SDL_WINDOW_MAXIMIZED;
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   157
        } else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   158
#endif
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   159
        {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
            window->flags &= ~SDL_WINDOW_MAXIMIZED;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
        }
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   162
#ifdef WS_MINIMIZE
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
        if (style & WS_MINIMIZE) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
            window->flags |= SDL_WINDOW_MINIMIZED;
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   165
        } else
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   166
#endif
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   167
        {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
            window->flags &= ~SDL_WINDOW_MINIMIZED;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
    if (GetFocus() == hwnd) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
        window->flags |= SDL_WINDOW_INPUT_FOCUS;
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
   173
        SDL_SetKeyboardFocus(data->window);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
        if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
            RECT rect;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
            GetClientRect(hwnd, &rect);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
            ClientToScreen(hwnd, (LPPOINT) & rect);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
            ClientToScreen(hwnd, (LPPOINT) & rect + 1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
            ClipCursor(&rect);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
6078
718b49ec039e Fixed whitespace
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
   184
    /* Enable multi-touch */
4948
6546eaa20271 Fixed crash on Windows XP
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
   185
    if (videodata->RegisterTouchWindow) {
6546eaa20271 Fixed crash on Windows XP
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
   186
        videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM));
6546eaa20271 Fixed crash on Windows XP
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
   187
    }
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
   188
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
    /* All done! */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
    return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
WIN_CreateWindow(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
{
5246
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   196
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
    HWND hwnd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
    RECT rect;
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   199
    DWORD style = STYLE_BASIC;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
    int x, y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
    int w, h;
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   202
    
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   203
    style |= GetWindowStyle(window);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
    /* Figure out what the window area will be */
5382
fd9a7a0afcbf Simplified Windows window creation.
Sam Lantinga <slouken@libsdl.org>
parents: 5305
diff changeset
   206
    rect.left = window->x;
fd9a7a0afcbf Simplified Windows window creation.
Sam Lantinga <slouken@libsdl.org>
parents: 5305
diff changeset
   207
    rect.top = window->y;
fd9a7a0afcbf Simplified Windows window creation.
Sam Lantinga <slouken@libsdl.org>
parents: 5305
diff changeset
   208
    rect.right = window->x + window->w;
fd9a7a0afcbf Simplified Windows window creation.
Sam Lantinga <slouken@libsdl.org>
parents: 5305
diff changeset
   209
    rect.bottom = window->y + window->h;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   210
    AdjustWindowRectEx(&rect, style, FALSE, 0);
5382
fd9a7a0afcbf Simplified Windows window creation.
Sam Lantinga <slouken@libsdl.org>
parents: 5305
diff changeset
   211
    x = rect.left;
fd9a7a0afcbf Simplified Windows window creation.
Sam Lantinga <slouken@libsdl.org>
parents: 5305
diff changeset
   212
    y = rect.top;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   213
    w = (rect.right - rect.left);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
    h = (rect.bottom - rect.top);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   215
1956
ba0d62354872 Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents: 1952
diff changeset
   216
    hwnd =
ba0d62354872 Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents: 1952
diff changeset
   217
        CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL,
ba0d62354872 Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents: 1952
diff changeset
   218
                     SDL_Instance, NULL);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
    if (!hwnd) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
        WIN_SetError("Couldn't create window");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
        return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   222
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   223
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
   224
    WIN_PumpEvents(_this);
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
   225
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
   226
    if (SetupWindowData(_this, window, hwnd, SDL_TRUE) < 0) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
        DestroyWindow(hwnd);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   228
        return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
    }
5088
455bc74f7034 Fixed bug #1100
Sam Lantinga <slouken@libsdl.org>
parents: 5086
diff changeset
   230
#if SDL_VIDEO_OPENGL_WGL
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   231
    if (window->flags & SDL_WINDOW_OPENGL) {
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   232
        if (WIN_GL_SetupWindow(_this, window) < 0) {
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   233
            WIN_DestroyWindow(_this, window);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   234
            return -1;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   235
        }
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   236
    }
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   237
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
    return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   239
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
    HWND hwnd = (HWND) data;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   245
    LPTSTR title;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
    int titleLen;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
    /* Query the title from the existing window */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
    titleLen = GetWindowTextLength(hwnd);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
    title = SDL_stack_alloc(TCHAR, titleLen + 1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
    if (title) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
        titleLen = GetWindowText(hwnd, title, titleLen);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
    } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
        titleLen = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
    if (titleLen > 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
        window->title = WIN_StringToUTF8(title);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
    if (title) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
        SDL_stack_free(title);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   261
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   262
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
   263
    if (SetupWindowData(_this, window, hwnd, SDL_FALSE) < 0) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
        return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   266
    return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
WIN_SetWindowTitle(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
    LPTSTR title;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
    if (window->title) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
        title = WIN_UTF8ToString(window->title);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
    } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
        title = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   280
    SetWindowText(hwnd, title ? title : TEXT(""));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   281
    if (title) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
        SDL_free(title);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   284
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   285
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
void
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   287
WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   288
{
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   289
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   290
    HICON hicon = NULL;
5418
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   291
    BYTE *icon_bmp;
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   292
    int icon_len;
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   293
    SDL_RWops *dst;
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   294
    SDL_Surface *surface;
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   295
5418
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   296
    /* Create temporary bitmap buffer */
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   297
    icon_len = 40 + icon->h * icon->w * 4;
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   298
    icon_bmp = SDL_stack_alloc(BYTE, icon_len);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   299
    dst = SDL_RWFromMem(icon_bmp, icon_len);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   300
    if (!dst) {
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   301
        SDL_stack_free(icon_bmp);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   302
        return;
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   303
    }
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   304
5418
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   305
    /* Write the BITMAPINFO header */
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   306
    SDL_WriteLE32(dst, 40);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   307
    SDL_WriteLE32(dst, icon->w);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   308
    SDL_WriteLE32(dst, icon->h * 2);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   309
    SDL_WriteLE16(dst, 1);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   310
    SDL_WriteLE16(dst, 32);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   311
    SDL_WriteLE32(dst, BI_RGB);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   312
    SDL_WriteLE32(dst, icon->h * icon->w * 4);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   313
    SDL_WriteLE32(dst, 0);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   314
    SDL_WriteLE32(dst, 0);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   315
    SDL_WriteLE32(dst, 0);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   316
    SDL_WriteLE32(dst, 0);
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   317
5418
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   318
    /* Convert the icon to a 32-bit surface with alpha channel */
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   319
    surface = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888, 0);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   320
    if (surface) {
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   321
        /* Write the pixels upside down into the bitmap buffer */
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   322
        int y = surface->h;
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   323
        while (y--) {
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   324
            Uint8 *src = (Uint8 *) surface->pixels + y * surface->pitch;
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   325
            SDL_RWwrite(dst, src, surface->pitch, 1);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   326
        }
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   327
        SDL_FreeSurface(surface);
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   328
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
   329
/* TODO: create the icon in WinCE (CreateIconFromResource isn't available) */
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
   330
#ifndef _WIN32_WCE
5418
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   331
        hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000);
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
   332
#endif
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   333
    }
5418
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   334
    SDL_RWclose(dst);
f8ecf0869cc9 You can use SDL_ConvertSurfaceFormat() now
Sam Lantinga <slouken@libsdl.org>
parents: 5416
diff changeset
   335
    SDL_stack_free(icon_bmp);
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   336
2971
a3012c6652ff Should we also set the icon in the task manager?
Sam Lantinga <slouken@libsdl.org>
parents: 2970
diff changeset
   337
    /* Set the icon for the window */
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2971
diff changeset
   338
    SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM) hicon);
2971
a3012c6652ff Should we also set the icon in the task manager?
Sam Lantinga <slouken@libsdl.org>
parents: 2970
diff changeset
   339
a3012c6652ff Should we also set the icon in the task manager?
Sam Lantinga <slouken@libsdl.org>
parents: 2970
diff changeset
   340
    /* Set the icon in the task manager (should we do this?) */
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2971
diff changeset
   341
    SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM) hicon);
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   342
}
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   343
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
   344
void
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   345
WIN_SetWindowPosition(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   346
{
5246
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   347
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   348
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   349
    RECT rect;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   350
    DWORD style;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   351
    HWND top;
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   352
    BOOL menu;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   353
    int x, y;
4486
237b1eb53e4d Fixed fullscreen window position
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   354
    int w, h;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   355
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   356
    /* Figure out what the window area will be */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   357
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   358
        top = HWND_TOPMOST;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   359
    } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   360
        top = HWND_NOTOPMOST;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   361
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   362
    style = GetWindowLong(hwnd, GWL_STYLE);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   363
    rect.left = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   364
    rect.top = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   365
    rect.right = window->w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   366
    rect.bottom = window->h;
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   367
#ifdef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   368
    menu = FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   369
#else
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   370
    menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   371
#endif
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   372
    AdjustWindowRectEx(&rect, style, menu, 0);
4486
237b1eb53e4d Fixed fullscreen window position
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   373
    w = (rect.right - rect.left);
237b1eb53e4d Fixed fullscreen window position
Sam Lantinga <slouken@libsdl.org>
parents: 4465
diff changeset
   374
    h = (rect.bottom - rect.top);
5495
b3680e05286d Removed obsolete window positioning code.
Sam Lantinga <slouken@libsdl.org>
parents: 5494
diff changeset
   375
    x = window->x + rect.left;
b3680e05286d Removed obsolete window positioning code.
Sam Lantinga <slouken@libsdl.org>
parents: 5494
diff changeset
   376
    y = window->y + rect.top;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   377
1956
ba0d62354872 Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents: 1952
diff changeset
   378
    SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   382
WIN_SetWindowSize(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   383
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   384
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   385
    RECT rect;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   386
    DWORD style;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
    HWND top;
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   388
    BOOL menu;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   389
    int w, h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   390
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   391
    /* Figure out what the window area will be */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   392
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   393
        top = HWND_TOPMOST;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   394
    } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   395
        top = HWND_NOTOPMOST;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   396
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   397
    style = GetWindowLong(hwnd, GWL_STYLE);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   398
    rect.left = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   399
    rect.top = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   400
    rect.right = window->w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   401
    rect.bottom = window->h;
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   402
#ifdef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   403
    menu = FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   404
#else
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   405
    menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   406
#endif
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   407
    AdjustWindowRectEx(&rect, style, menu, 0);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   408
    w = (rect.right - rect.left);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   409
    h = (rect.bottom - rect.top);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   410
2968
efe4d0ce2e97 Date: Fri, 02 Jan 2009 23:22:39 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
   411
    SetWindowPos(hwnd, top, 0, 0, w, h, (SWP_NOCOPYBITS | SWP_NOMOVE));
5246
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   412
}
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   413
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   414
#ifdef _WIN32_WCE
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   415
void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible)
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   416
{
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   417
    SDL_WindowData* windowdata = (SDL_WindowData*) window->driverdata;
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   418
    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   419
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   420
    if(visible) {
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   421
        if(window->flags & SDL_WINDOW_FULLSCREEN) {
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   422
            if(videodata->SHFullScreen)
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   423
                videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
5178
4191af605cb0 Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents: 5139
diff changeset
   424
5246
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   425
            ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE);
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   426
        }
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   427
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   428
        ShowWindow(windowdata->hwnd, SW_SHOW);
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   429
        SetForegroundWindow(windowdata->hwnd);
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   430
    } else {
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   431
        ShowWindow(windowdata->hwnd, SW_HIDE);
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   432
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   433
        if(window->flags & SDL_WINDOW_FULLSCREEN) {
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   434
            if(videodata->SHFullScreen)
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   435
                videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   436
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   437
            ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW);
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   438
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   439
        }
58265e606e4e Window coordinates are in the global space and windows are not tied to a particular display.
Sam Lantinga <slouken@libsdl.org>
parents: 5178
diff changeset
   440
    }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   441
}
5178
4191af605cb0 Fixed compiling on Windows CE
Sam Lantinga <slouken@libsdl.org>
parents: 5139
diff changeset
   442
#endif /* _WIN32_WCE */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   443
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   444
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   445
WIN_ShowWindow(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   446
{
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   447
#ifdef _WIN32_WCE
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   448
    WINCE_ShowWindow(_this, window, 1);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   449
#else
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   450
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   451
    ShowWindow(hwnd, SW_SHOW);
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   452
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   453
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   454
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   455
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   456
WIN_HideWindow(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   457
{
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   458
#ifdef _WIN32_WCE
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   459
    WINCE_ShowWindow(_this, window, 0);
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   460
#else
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   461
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   462
    ShowWindow(hwnd, SW_HIDE);
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   463
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   464
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   465
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   466
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   467
WIN_RaiseWindow(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   468
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   469
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   470
    HWND top;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   471
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   472
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   473
        top = HWND_TOPMOST;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   474
    } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   475
        top = HWND_NOTOPMOST;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   476
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   477
    SetWindowPos(hwnd, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   478
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   479
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   480
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   481
WIN_MaximizeWindow(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   482
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   483
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   484
    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   485
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   486
#ifdef _WIN32_WCE
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   487
    if((window->flags & SDL_WINDOW_FULLSCREEN) && videodata->SHFullScreen)
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   488
        videodata->SHFullScreen(hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   489
#endif
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   490
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   491
    ShowWindow(hwnd, SW_MAXIMIZE);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   492
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   493
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   494
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   495
WIN_MinimizeWindow(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   496
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   497
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   498
    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   499
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   500
    ShowWindow(hwnd, SW_MINIMIZE);
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   501
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   502
#ifdef _WIN32_WCE
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   503
    if((window->flags & SDL_WINDOW_FULLSCREEN) && videodata->SHFullScreen)
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   504
        videodata->SHFullScreen(hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   505
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   506
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   507
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   508
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   509
WIN_RestoreWindow(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   510
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   511
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   512
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   513
    ShowWindow(hwnd, SW_RESTORE);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   514
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   515
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   516
void
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   517
WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   518
{
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   519
    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   520
    HWND hwnd = data->hwnd;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   521
    RECT rect;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   522
    SDL_Rect bounds;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   523
    DWORD style;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   524
    HWND top;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   525
    BOOL menu;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   526
    int x, y;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   527
    int w, h;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   528
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   529
    if (fullscreen) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   530
        top = HWND_TOPMOST;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   531
    } else {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   532
        top = HWND_NOTOPMOST;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   533
    }
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   534
    style = GetWindowLong(hwnd, GWL_STYLE);
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   535
    style &= ~STYLE_MASK;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   536
    style |= GetWindowStyle(window);
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   537
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   538
    WIN_GetDisplayBounds(_this, display, &bounds);
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   539
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   540
    if (fullscreen) {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   541
        x = bounds.x;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   542
        y = bounds.y;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   543
        w = bounds.w;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   544
        h = bounds.h;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   545
    } else {
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   546
        rect.left = 0;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   547
        rect.top = 0;
5398
83816c8a2b58 Restore the windowed position and size when coming back from fullscreen.
Sam Lantinga <slouken@libsdl.org>
parents: 5382
diff changeset
   548
        rect.right = window->windowed.w;
83816c8a2b58 Restore the windowed position and size when coming back from fullscreen.
Sam Lantinga <slouken@libsdl.org>
parents: 5382
diff changeset
   549
        rect.bottom = window->windowed.h;
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   550
#ifdef _WIN32_WCE
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   551
        menu = FALSE;
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   552
#else
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   553
        menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   554
#endif
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   555
        AdjustWindowRectEx(&rect, style, menu, 0);
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   556
        w = (rect.right - rect.left);
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   557
        h = (rect.bottom - rect.top);
5398
83816c8a2b58 Restore the windowed position and size when coming back from fullscreen.
Sam Lantinga <slouken@libsdl.org>
parents: 5382
diff changeset
   558
        x = window->windowed.x + rect.left;
83816c8a2b58 Restore the windowed position and size when coming back from fullscreen.
Sam Lantinga <slouken@libsdl.org>
parents: 5382
diff changeset
   559
        y = window->windowed.y + rect.top;
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   560
    }
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   561
    SetWindowLong(hwnd, GWL_STYLE, style);
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   562
    SetWindowPos(hwnd, top, x, y, w, h, SWP_NOCOPYBITS);
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   563
}
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   564
5466
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   565
int
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   566
WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   567
{
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   568
#ifdef _WIN32_WCE
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   569
    SDL_Unsupported();
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   570
    return -1;
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   571
#else
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   572
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   573
    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   574
    HDC hdc;
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   575
    BOOL succeeded = FALSE;
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   576
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   577
    hdc = CreateDC(data->DeviceName, NULL, NULL, NULL);
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   578
    if (hdc) {
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   579
        succeeded = SetDeviceGammaRamp(hdc, (LPVOID)ramp);
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   580
        if (!succeeded) {
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   581
            WIN_SetError("SetDeviceGammaRamp()");
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   582
        }
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   583
        DeleteDC(hdc);
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   584
    }
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   585
    return succeeded ? 0 : -1;
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   586
#endif
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   587
}
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   588
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   589
int
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   590
WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   591
{
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   592
#ifdef _WIN32_WCE
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   593
    SDL_Unsupported();
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   594
    return -1;
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   595
#else
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   596
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   597
    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   598
    HDC hdc;
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   599
    BOOL succeeded = FALSE;
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   600
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   601
    hdc = CreateDC(data->DeviceName, NULL, NULL, NULL);
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   602
    if (hdc) {
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   603
        succeeded = GetDeviceGammaRamp(hdc, (LPVOID)ramp);
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   604
        if (!succeeded) {
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   605
            WIN_SetError("GetDeviceGammaRamp()");
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   606
        }
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   607
        DeleteDC(hdc);
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   608
    }
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   609
    return succeeded ? 0 : -1;
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   610
#endif
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   611
}
006883d5fa51 Gamma support is back!
Sam Lantinga <slouken@libsdl.org>
parents: 5418
diff changeset
   612
5305
75f5ff92ad08 Fixed a host of issues with Windows fullscreen modes. Toggling fullscreen OpenGL works now in my test environment.
Sam Lantinga <slouken@libsdl.org>
parents: 5288
diff changeset
   613
void
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   614
WIN_SetWindowGrab(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   615
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   616
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   617
5416
1b085f890c44 Fullscreen doesn't automatically grab the cursor.
Sam Lantinga <slouken@libsdl.org>
parents: 5398
diff changeset
   618
    if ((window->flags & SDL_WINDOW_INPUT_GRABBED) &&
1b085f890c44 Fullscreen doesn't automatically grab the cursor.
Sam Lantinga <slouken@libsdl.org>
parents: 5398
diff changeset
   619
        (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   620
        RECT rect;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   621
        GetClientRect(hwnd, &rect);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   622
        ClientToScreen(hwnd, (LPPOINT) & rect);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   623
        ClientToScreen(hwnd, (LPPOINT) & rect + 1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   624
        ClipCursor(&rect);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   625
    } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   626
        ClipCursor(NULL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   627
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   628
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   629
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   630
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   631
WIN_DestroyWindow(_THIS, SDL_Window * window)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   632
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   633
    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   634
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   635
    if (data) {
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   636
#ifdef _WIN32_WCE
6078
718b49ec039e Fixed whitespace
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
   637
        WINCE_ShowWindow(_this, window, 0);
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   638
#endif
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
   639
        ReleaseDC(data->hwnd, data->hdc);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   640
        if (data->created) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   641
            DestroyWindow(data->hwnd);
5580
0c407e6d14a9 If we didn't create win32 window, restore its event procedure on destruction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   642
        } else {
0c407e6d14a9 If we didn't create win32 window, restore its event procedure on destruction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   643
            /* Restore any original event handler... */
0c407e6d14a9 If we didn't create win32 window, restore its event procedure on destruction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   644
            if (data->wndproc != NULL) {
0c407e6d14a9 If we didn't create win32 window, restore its event procedure on destruction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   645
#ifdef GWLP_WNDPROC
5581
f40f9d3ca2bc Patched to compile (I hope).
Ryan C. Gordon <icculus@icculus.org>
parents: 5580
diff changeset
   646
                SetWindowLongPtr(data->hwnd, GWLP_WNDPROC,
f40f9d3ca2bc Patched to compile (I hope).
Ryan C. Gordon <icculus@icculus.org>
parents: 5580
diff changeset
   647
                                 (LONG_PTR) data->wndproc);
5580
0c407e6d14a9 If we didn't create win32 window, restore its event procedure on destruction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   648
#else
5581
f40f9d3ca2bc Patched to compile (I hope).
Ryan C. Gordon <icculus@icculus.org>
parents: 5580
diff changeset
   649
                SetWindowLong(data->hwnd, GWL_WNDPROC,
f40f9d3ca2bc Patched to compile (I hope).
Ryan C. Gordon <icculus@icculus.org>
parents: 5580
diff changeset
   650
                              (LONG_PTR) data->wndproc);
5580
0c407e6d14a9 If we didn't create win32 window, restore its event procedure on destruction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   651
#endif
0c407e6d14a9 If we didn't create win32 window, restore its event procedure on destruction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   652
            }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   653
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   654
        SDL_free(data);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   655
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   656
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   657
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   658
SDL_bool
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   659
WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   660
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   661
    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   662
    if (info->version.major <= SDL_MAJOR_VERSION) {
4900
69d9db65f248 Merged the Windows custom window system hooks into the union used by X11.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
   663
        info->subsystem = SDL_SYSWM_WINDOWS;
5056
8b7988f42fcb Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents: 5037
diff changeset
   664
        info->info.win.window = hwnd;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   665
        return SDL_TRUE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   666
    } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   667
        SDL_SetError("Application not compiled with SDL %d.%d\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   668
                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   669
        return SDL_FALSE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   670
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   671
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   672
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   673
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   674
/*
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   675
 * Creates a HelperWindow used for DirectInput events.
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   676
 */
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   677
int
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   678
SDL_HelperWindowCreate(void)
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   679
{
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
   680
    HINSTANCE hInstance = GetModuleHandle(NULL);
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
   681
    WNDCLASS wce;
3196
413672b09bb3 Fixed some compile errors and warnings under Visual C++
Sam Lantinga <slouken@libsdl.org>
parents: 3168
diff changeset
   682
    HWND hWndParent = NULL;
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   683
3045
9acb9f0f7f0d Some more safety around the SDL_HelperWindow stuff to avoid double creations.
Edgar Simo <bobbens@gmail.com>
parents: 2990
diff changeset
   684
    /* Make sure window isn't created twice. */
9acb9f0f7f0d Some more safety around the SDL_HelperWindow stuff to avoid double creations.
Edgar Simo <bobbens@gmail.com>
parents: 2990
diff changeset
   685
    if (SDL_HelperWindow != NULL) {
9acb9f0f7f0d Some more safety around the SDL_HelperWindow stuff to avoid double creations.
Edgar Simo <bobbens@gmail.com>
parents: 2990
diff changeset
   686
        return 0;
9acb9f0f7f0d Some more safety around the SDL_HelperWindow stuff to avoid double creations.
Edgar Simo <bobbens@gmail.com>
parents: 2990
diff changeset
   687
    }
9acb9f0f7f0d Some more safety around the SDL_HelperWindow stuff to avoid double creations.
Edgar Simo <bobbens@gmail.com>
parents: 2990
diff changeset
   688
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   689
    /* Create the class. */
2714
1d1be6137875 Merged last minute fixes from force feedback branch (r4031, r4033, r4034)
Sam Lantinga <slouken@libsdl.org>
parents: 2713
diff changeset
   690
    SDL_zero(wce);
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
   691
    wce.lpfnWndProc = DefWindowProc;
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   692
    wce.lpszClassName = (LPCWSTR) SDL_HelperWindowClassName;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   693
    wce.hInstance = hInstance;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   694
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   695
    /* Register the class. */
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
   696
    SDL_HelperWindowClass = RegisterClass(&wce);
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   697
    if (SDL_HelperWindowClass == 0) {
4500
eff4e88cc1e8 Added Windows clipboard support
Sam Lantinga <slouken@libsdl.org>
parents: 4486
diff changeset
   698
        WIN_SetError("Unable to create Helper Window Class");
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   699
        return -1;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   700
    }
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   701
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   702
#ifndef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   703
    /* WinCE doesn't have HWND_MESSAGE */
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   704
    hWndParent = HWND_MESSAGE;
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   705
#endif
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   706
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   707
    /* Create the window. */
2714
1d1be6137875 Merged last minute fixes from force feedback branch (r4031, r4033, r4034)
Sam Lantinga <slouken@libsdl.org>
parents: 2713
diff changeset
   708
    SDL_HelperWindow = CreateWindowEx(0, SDL_HelperWindowClassName,
1d1be6137875 Merged last minute fixes from force feedback branch (r4031, r4033, r4034)
Sam Lantinga <slouken@libsdl.org>
parents: 2713
diff changeset
   709
                                      SDL_HelperWindowName,
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   710
                                      WS_OVERLAPPED, CW_USEDEFAULT,
2714
1d1be6137875 Merged last minute fixes from force feedback branch (r4031, r4033, r4034)
Sam Lantinga <slouken@libsdl.org>
parents: 2713
diff changeset
   711
                                      CW_USEDEFAULT, CW_USEDEFAULT,
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   712
                                      CW_USEDEFAULT, hWndParent, NULL,
2714
1d1be6137875 Merged last minute fixes from force feedback branch (r4031, r4033, r4034)
Sam Lantinga <slouken@libsdl.org>
parents: 2713
diff changeset
   713
                                      hInstance, NULL);
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   714
    if (SDL_HelperWindow == NULL) {
3045
9acb9f0f7f0d Some more safety around the SDL_HelperWindow stuff to avoid double creations.
Edgar Simo <bobbens@gmail.com>
parents: 2990
diff changeset
   715
        UnregisterClass(SDL_HelperWindowClassName, hInstance);
4500
eff4e88cc1e8 Added Windows clipboard support
Sam Lantinga <slouken@libsdl.org>
parents: 4486
diff changeset
   716
        WIN_SetError("Unable to create Helper Window");
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   717
        return -1;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   718
    }
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   719
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   720
    return 0;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   721
}
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   722
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   723
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   724
/*
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   725
 * Destroys the HelperWindow previously created with SDL_HelperWindowCreate.
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   726
 */
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   727
void
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   728
SDL_HelperWindowDestroy(void)
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   729
{
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
   730
    HINSTANCE hInstance = GetModuleHandle(NULL);
2863
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
   731
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   732
    /* Destroy the window. */
2863
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
   733
    if (SDL_HelperWindow != NULL) {
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
   734
        if (DestroyWindow(SDL_HelperWindow) == 0) {
4500
eff4e88cc1e8 Added Windows clipboard support
Sam Lantinga <slouken@libsdl.org>
parents: 4486
diff changeset
   735
            WIN_SetError("Unable to destroy Helper Window");
2865
Sam Lantinga <slouken@libsdl.org>
parents: 2863
diff changeset
   736
            return;
2863
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
   737
        }
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   738
        SDL_HelperWindow = NULL;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   739
    }
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   740
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   741
    /* Unregister the class. */
2863
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
   742
    if (SDL_HelperWindowClass != 0) {
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
   743
        if ((UnregisterClass(SDL_HelperWindowClassName, hInstance)) == 0) {
4500
eff4e88cc1e8 Added Windows clipboard support
Sam Lantinga <slouken@libsdl.org>
parents: 4486
diff changeset
   744
            WIN_SetError("Unable to destroy Helper Window Class");
2865
Sam Lantinga <slouken@libsdl.org>
parents: 2863
diff changeset
   745
            return;
2863
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
   746
        }
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   747
        SDL_HelperWindowClass = 0;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   748
    }
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   749
}
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
   750
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5980
diff changeset
   751
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5980
diff changeset
   752
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   753
/* vi: set ts=4 sw=4 expandtab: */