annotate src/video/win32/SDL_win32window.c @ 3528:59ff7a2beb57

Added an API function to query geometry of multiple monitors: SDL_GetDisplayBounds() Implemented multi-monitor window positions on Windows
author Sam Lantinga <slouken@libsdl.org>
date Sun, 06 Dec 2009 08:03:38 +0000
parents 413672b09bb3
children e96be66e3673
rev   line source
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 /*
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
2859
99210400e8b9 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 2767
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
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
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
c121d94672cb 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 version 2.1 of the License, or (at your option) any later 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
9
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c121d94672cb 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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
c121d94672cb 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 slouken@libsdl.org
c121d94672cb 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 */
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
22
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
23 /* we need to define it, so that raw input is included */
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
24
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
25 #if (_WIN32_WINNT < 0x0501)
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
26 #undef _WIN32_WINNT
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
27 #define _WIN32_WINNT 0x0501
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
28 #endif
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
29
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
30 #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
31
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include "../SDL_sysvideo.h"
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
33 #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
34 #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
35
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include "SDL_win32video.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
37
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 /* This is included after SDL_win32video.h, which includes windows.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
39 #include "SDL_syswm.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
40
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
41
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
42 #define SHFS_SHOWTASKBAR 0x0001
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
43 #define SHFS_HIDETASKBAR 0x0002
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
44 #define SHFS_SHOWSIPBUTTON 0x0004
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
45 #define SHFS_HIDESIPBUTTON 0x0008
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
46 #define SHFS_SHOWSTARTICON 0x0010
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
47 #define SHFS_HIDESTARTICON 0x0020
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
48
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
49 #ifdef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
50 // dynamically load aygshell dll because we want SDL to work on HPC and be300
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
51 int aygshell_loaded = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
52 BOOL(WINAPI * SHFullScreen) (HWND hwndRequester, DWORD dwState) = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
53
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
54
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
55 static BOOL
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
56 CE_SHFullScreen(HWND hwndRequester, DWORD dwState)
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
57 {
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
58 if (SHFullScreen == 0 && aygshell_loaded == 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
59 aygshell_loaded = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
60 void *lib = SDL_LoadObject("aygshell.dll");
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
61 if (lib) {
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
62 SHFullScreen =
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
63 (BOOL(WINAPI *) (HWND, DWORD)) SDL_LoadFunction(lib,
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
64 "SHFullScreen");
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
65 }
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
66 }
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
67
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
68 if (SHFullScreen) {
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
69 SHFullScreen(hwndRequester, dwState);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
70 //printf("SHFullscreen(%i)\n",dwState);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
71 }
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
72 }
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
73
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
74 #endif
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
75
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
76 extern HCTX *g_hCtx; /* the table of tablet event contexts, each windows has to have it's own tablet context */
2767
73b9f5fc6690 This can be static
Sam Lantinga <slouken@libsdl.org>
parents: 2728
diff changeset
77 static Uint32 highestId = 0; /* the highest id of the tablet context */
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
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
79 /* 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
80 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
81 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
82 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
83 static ATOM SDL_HelperWindowClass = 0;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
84
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
85 static int
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
86 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
87 {
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
88 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
89 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
90
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 /* 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
92 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
93 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
94 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
95 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
96 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 data->windowID = window->id;
c121d94672cb 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 data->hwnd = hwnd;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
99 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
100 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
101 data->mouse_pressed = SDL_FALSE;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
102 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
103
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 /* 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
105 if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
106 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
107 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
108 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
109 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
110 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 /* Set up the window proc function */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 data->wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 if (data->wndproc == 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
115 data->wndproc = DefWindowProc;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 } 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
117 SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) WIN_WindowProc);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 }
c121d94672cb 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)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 window->x = point.x;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 window->y = point.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
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 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 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
155 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
156 } 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
157 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
158 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 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
160 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
161 } 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
162 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
163 }
c121d94672cb 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 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 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
166 int index = data->videodata->keyboard;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 window->flags |= SDL_WINDOW_INPUT_FOCUS;
c121d94672cb 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 SDL_SetKeyboardFocus(index, data->windowID);
c121d94672cb 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 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
171 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
172 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
173 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
174 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
175 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
176 }
c121d94672cb 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 }
c121d94672cb 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
c121d94672cb 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 /* 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
180 window->driverdata = 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
181 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
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
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 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
185 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
186 {
2726
f23ebf1ddac4 Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents: 2724
diff changeset
187 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
188 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
189 RAWINPUTDEVICE Rid;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
190 AXIS TabX, TabY;
2728
2768bd7281e0 Fixed Visual Studio compilation problems
Sam Lantinga <slouken@libsdl.org>
parents: 2726
diff changeset
191 LOGCONTEXTA lc;
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
192 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
193 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
194 RECT rect;
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
195 SDL_Rect bounds;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
196 DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
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 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
198 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
199
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
200 if (window->flags & (SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN)) {
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
201 style |= WS_POPUP;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 } 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
203 style |= (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX);
c121d94672cb 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 }
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
205 if ((window->flags & SDL_WINDOW_RESIZABLE)
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
206 && !(window->flags & SDL_WINDOW_FULLSCREEN)) {
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
207 style |= (WS_THICKFRAME | WS_MAXIMIZEBOX);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209
c121d94672cb 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 /* 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
211 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
212 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
213 } 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
214 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
215 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 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
217 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
218 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
219 rect.bottom = window->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
220 AdjustWindowRectEx(&rect, style, FALSE, 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
221 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
222 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
223
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
224 WIN_GetDisplayBounds(_this, display, &bounds);
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
225 if ((window->flags & SDL_WINDOW_FULLSCREEN)
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
226 || window->x == SDL_WINDOWPOS_CENTERED) {
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
227 x = bounds.x + (bounds.w - window->w) / 2;
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
228 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
229 if (bounds.x == 0) {
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
230 x = CW_USEDEFAULT;
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
231 } else {
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
232 x = bounds.x;
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
233 }
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
234 } 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
235 x = window->x + 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
236 }
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
237 if ((window->flags & SDL_WINDOW_FULLSCREEN)
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
238 || window->y == SDL_WINDOWPOS_CENTERED) {
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
239 y = bounds.y + (bounds.h - window->h) / 2;
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
240 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
241 if (bounds.x == 0) {
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
242 y = CW_USEDEFAULT;
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
243 } else {
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
244 y = bounds.y;
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
245 }
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
246 } 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
247 y = window->y + 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
248 }
c121d94672cb 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
1956
ba0d62354872 Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents: 1952
diff changeset
250 hwnd =
ba0d62354872 Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents: 1952
diff changeset
251 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
252 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
253 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
254 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
255 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
256 }
c121d94672cb 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
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
258 /* we're configuring the tablet data. See Wintab reference for more info */
2728
2768bd7281e0 Fixed Visual Studio compilation problems
Sam Lantinga <slouken@libsdl.org>
parents: 2726
diff changeset
259 if (videodata->wintabDLL
2768bd7281e0 Fixed Visual Studio compilation problems
Sam Lantinga <slouken@libsdl.org>
parents: 2726
diff changeset
260 && videodata->WTInfoA(WTI_DEFSYSCTX, 0, &lc) != 0) {
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
261 lc.lcPktData = PACKETDATA;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
262 lc.lcPktMode = PACKETMODE;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
263 lc.lcOptions |= CXO_MESSAGES;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
264 lc.lcOptions |= CXO_SYSTEM;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
265 lc.lcMoveMask = PACKETDATA;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
266 lc.lcBtnDnMask = lc.lcBtnUpMask = PACKETDATA;
2728
2768bd7281e0 Fixed Visual Studio compilation problems
Sam Lantinga <slouken@libsdl.org>
parents: 2726
diff changeset
267 videodata->WTInfoA(WTI_DEVICES, DVC_X, &TabX);
2768bd7281e0 Fixed Visual Studio compilation problems
Sam Lantinga <slouken@libsdl.org>
parents: 2726
diff changeset
268 videodata->WTInfoA(WTI_DEVICES, DVC_Y, &TabY);
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
269 lc.lcInOrgX = 0;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
270 lc.lcInOrgY = 0;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
271 lc.lcInExtX = TabX.axMax;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
272 lc.lcInExtY = TabY.axMax;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
273 lc.lcOutOrgX = 0;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
274 lc.lcOutOrgY = 0;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
275 lc.lcOutExtX = GetSystemMetrics(SM_CXSCREEN);
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
276 lc.lcOutExtY = -GetSystemMetrics(SM_CYSCREEN);
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
277 if (window->id > highestId) {
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
278 HCTX *tmp_hctx;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
279 highestId = window->id;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
280 tmp_hctx =
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
281 (HCTX *) SDL_realloc(g_hCtx, (highestId + 1) * sizeof(HCTX));
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
282 if (!tmp_hctx) {
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
283 SDL_OutOfMemory();
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
284 DestroyWindow(hwnd);
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
285 return -1;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
286 }
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
287 g_hCtx = tmp_hctx;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
288 }
2728
2768bd7281e0 Fixed Visual Studio compilation problems
Sam Lantinga <slouken@libsdl.org>
parents: 2726
diff changeset
289 g_hCtx[window->id] = videodata->WTOpenA(hwnd, &lc, TRUE);
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
290 }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3097
diff changeset
291 #ifndef _WIN32_WCE /* has no RawInput */
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
292 /* we're telling the window, we want it to report raw input events from mice */
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
293 Rid.usUsagePage = 0x01;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
294 Rid.usUsage = 0x02;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
295 Rid.dwFlags = RIDEV_INPUTSINK;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
296 Rid.hwndTarget = hwnd;
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
297 RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
298 #endif
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
299
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
300 WIN_PumpEvents(_this);
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 1956
diff changeset
301
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
302 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
303 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
304 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
305 }
1952
420716272158 Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents: 1951
diff changeset
306 #ifdef SDL_VIDEO_OPENGL_WGL
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
307 if (window->flags & SDL_WINDOW_OPENGL) {
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
308 if (WIN_GL_SetupWindow(_this, window) < 0) {
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
309 WIN_DestroyWindow(_this, window);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
310 return -1;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
311 }
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
312 }
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
313 #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
314 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
315 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 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
318 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
319 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 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
321 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
322 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
323
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 /* 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
325 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
326 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
327 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
328 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
329 } 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
330 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
331 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 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
333 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
334 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 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
336 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
337 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
339 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
340 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
341 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 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
343 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344
c121d94672cb 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 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
346 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
347 {
c121d94672cb 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 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
350
c121d94672cb 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 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
352 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
353 } 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
354 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
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 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
357 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
358 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
359 }
c121d94672cb 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 }
c121d94672cb 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 void
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
363 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
364 {
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
365 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
366 HICON hicon = NULL;
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
367
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2971
diff changeset
368 if (icon) {
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
369 BYTE *icon_bmp;
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
370 int icon_len;
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
371 SDL_RWops *dst;
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
372 SDL_PixelFormat format;
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
373 SDL_Surface *surface;
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
374
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
375 /* Create temporary bitmap buffer */
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
376 icon_len = 40 + icon->h * icon->w * 4;
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
377 icon_bmp = SDL_stack_alloc(BYTE, icon_len);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
378 dst = SDL_RWFromMem(icon_bmp, icon_len);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
379 if (!dst) {
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
380 SDL_stack_free(icon_bmp);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
381 return;
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
382 }
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
383
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
384 /* Write the BITMAPINFO header */
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
385 SDL_WriteLE32(dst, 40);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
386 SDL_WriteLE32(dst, icon->w);
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2971
diff changeset
387 SDL_WriteLE32(dst, icon->h * 2);
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
388 SDL_WriteLE16(dst, 1);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
389 SDL_WriteLE16(dst, 32);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
390 SDL_WriteLE32(dst, BI_RGB);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
391 SDL_WriteLE32(dst, icon->h * icon->w * 4);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
392 SDL_WriteLE32(dst, 0);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
393 SDL_WriteLE32(dst, 0);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
394 SDL_WriteLE32(dst, 0);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
395 SDL_WriteLE32(dst, 0);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
396
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
397 /* Convert the icon to a 32-bit surface with alpha channel */
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
398 SDL_InitFormat(&format, 32,
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
399 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
400 surface = SDL_ConvertSurface(icon, &format, 0);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
401 if (surface) {
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
402 /* Write the pixels upside down into the bitmap buffer */
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
403 int y = surface->h;
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
404 while (y--) {
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2971
diff changeset
405 Uint8 *src = (Uint8 *) surface->pixels + y * surface->pitch;
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
406 SDL_RWwrite(dst, src, surface->pitch, 1);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
407 }
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
408 SDL_FreeSurface(surface);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
409
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
410 /* 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
411 #ifndef _WIN32_WCE
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2971
diff changeset
412 hicon =
Sam Lantinga <slouken@libsdl.org>
parents: 2971
diff changeset
413 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
414 #endif
2970
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
415 }
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
416 SDL_RWclose(dst);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
417 SDL_stack_free(icon_bmp);
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
418 }
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
419
2971
a3012c6652ff Should we also set the icon in the task manager?
Sam Lantinga <slouken@libsdl.org>
parents: 2970
diff changeset
420 /* Set the icon for the window */
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2971
diff changeset
421 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
422
a3012c6652ff Should we also set the icon in the task manager?
Sam Lantinga <slouken@libsdl.org>
parents: 2970
diff changeset
423 /* Set the icon in the task manager (should we do this?) */
2990
Sam Lantinga <slouken@libsdl.org>
parents: 2971
diff changeset
424 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
425 }
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
426
94b634c56455 Added support for translucent icons on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 2968
diff changeset
427 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
428 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
429 {
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
430 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(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
431 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
432 RECT rect;
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
433 SDL_Rect bounds;
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
434 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
435 HWND top;
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
436 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
437 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
438
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 /* 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
440 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
441 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
442 } 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
443 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
444 }
c121d94672cb 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 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
446 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
447 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
448 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
449 rect.bottom = window->h;
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
450 #ifdef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
451 menu = FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
452 #else
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
453 menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
454 #endif
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
455 AdjustWindowRectEx(&rect, style, menu, 0);
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2865
diff changeset
456
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
457 WIN_GetDisplayBounds(_this, display, &bounds);
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
458 if ((window->flags & SDL_WINDOW_FULLSCREEN)
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
459 || window->x == SDL_WINDOWPOS_CENTERED) {
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
460 x = bounds.x + (bounds.w - window->w) / 2;
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2865
diff changeset
461 } else {
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2865
diff changeset
462 x = window->x + rect.left;
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2865
diff changeset
463 }
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
464 if ((window->flags & SDL_WINDOW_FULLSCREEN)
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
465 || window->y == SDL_WINDOWPOS_CENTERED) {
3528
59ff7a2beb57 Added an API function to query geometry of multiple monitors:
Sam Lantinga <slouken@libsdl.org>
parents: 3196
diff changeset
466 y = bounds.y + (bounds.h - window->h) / 2;
2875
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2865
diff changeset
467 } else {
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2865
diff changeset
468 y = window->y + rect.top;
91a7e08cd238 * Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents: 2865
diff changeset
469 }
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
470
1956
ba0d62354872 Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents: 1952
diff changeset
471 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
472 }
c121d94672cb 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
c121d94672cb 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 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
475 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
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 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
478 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
479 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
480 HWND top;
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
481 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
482 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
483
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 /* 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
485 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
486 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
487 } 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
488 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
489 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 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
491 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
492 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
493 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
494 rect.bottom = window->h;
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
495 #ifdef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
496 menu = FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
497 #else
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
498 menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
499 #endif
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
500 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
501 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
502 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
503
2968
efe4d0ce2e97 Date: Fri, 02 Jan 2009 23:22:39 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2876
diff changeset
504 SetWindowPos(hwnd, top, 0, 0, w, h, (SWP_NOCOPYBITS | SWP_NOMOVE));
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
505 }
c121d94672cb 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 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
508 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
509 {
c121d94672cb 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 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
511
c121d94672cb 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 ShowWindow(hwnd, SW_SHOW);
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
513
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
514 #ifdef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
515 if (window->flags & SDL_WINDOW_FULLSCREEN) {
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
516 CE_SHFullScreen(hwnd,
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
517 SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
518 SHFS_HIDESIPBUTTON);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
519 }
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
520 #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
521 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 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
524 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
525 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
526 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
527
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 ShowWindow(hwnd, SW_HIDE);
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
529
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
530 #ifdef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
531 if (window->flags & SDL_WINDOW_FULLSCREEN) {
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
532 CE_SHFullScreen(hwnd,
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
533 SHFS_SHOWSTARTICON | SHFS_SHOWTASKBAR |
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
534 SHFS_SHOWSIPBUTTON);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
535 }
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
536 #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
537 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 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
540 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
541 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 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
543 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
544
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 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
546 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
547 } 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
548 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
549 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550 SetWindowPos(hwnd, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE));
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
551
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
552 #ifdef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
553 if (window->flags & SDL_WINDOW_FULLSCREEN) {
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
554 CE_SHFullScreen(hwnd,
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
555 SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
556 SHFS_HIDESIPBUTTON);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
557 }
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
558 #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
559 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 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
562 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
563 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564 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
565
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566 ShowWindow(hwnd, SW_MAXIMIZE);
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
567
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
568 #ifdef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
569 if (window->flags & SDL_WINDOW_FULLSCREEN) {
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
570 CE_SHFullScreen(hwnd,
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
571 SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
572 SHFS_HIDESIPBUTTON);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
573 }
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
574 #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
575 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577 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
578 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
579 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580 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
581
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
582 ShowWindow(hwnd, SW_MINIMIZE);
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
583
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
584 #ifdef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
585 if (window->flags & SDL_WINDOW_FULLSCREEN) {
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
586 CE_SHFullScreen(hwnd,
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
587 SHFS_SHOWSTARTICON | SHFS_SHOWTASKBAR |
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
588 SHFS_SHOWSIPBUTTON);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
589 }
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
590 #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
591 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 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
594 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
595 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 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
597
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598 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
599 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
600
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
601 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
602 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
603 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
604 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
605
2876
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
606 if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
Sam Lantinga <slouken@libsdl.org>
parents: 2875
diff changeset
607 && (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
608 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
609 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
610 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
611 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
612 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
613 } 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
614 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
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 }
c121d94672cb 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
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
618 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
619 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
620 {
2726
f23ebf1ddac4 Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents: 2724
diff changeset
621 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
622 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
623
c121d94672cb 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 if (data) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
625 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
626 if (data->created) {
2726
f23ebf1ddac4 Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents: 2724
diff changeset
627 if (videodata->wintabDLL) {
f23ebf1ddac4 Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents: 2724
diff changeset
628 videodata->WTClose(g_hCtx[window->id]);
f23ebf1ddac4 Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents: 2724
diff changeset
629 }
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
630 DestroyWindow(data->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
631 }
c121d94672cb 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 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
633 }
c121d94672cb 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
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
636 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
637 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
638 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
639 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
640 if (info->version.major <= SDL_MAJOR_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
641 info->window = 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
642 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
643 } 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
644 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
645 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
646 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
647 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
649
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
650
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
651 /*
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
652 * 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
653 */
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
654 int
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
655 SDL_HelperWindowCreate(void)
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
656 {
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
657 HINSTANCE hInstance = GetModuleHandle(NULL);
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
658 WNDCLASS wce;
3196
413672b09bb3 Fixed some compile errors and warnings under Visual C++
Sam Lantinga <slouken@libsdl.org>
parents: 3168
diff changeset
659 HWND hWndParent = NULL;
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
660
3045
9acb9f0f7f0d Some more safety around the SDL_HelperWindow stuff to avoid double creations.
Edgar Simo <bobbens@gmail.com>
parents: 2990
diff changeset
661 /* 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
662 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
663 return 0;
9acb9f0f7f0d Some more safety around the SDL_HelperWindow stuff to avoid double creations.
Edgar Simo <bobbens@gmail.com>
parents: 2990
diff changeset
664 }
9acb9f0f7f0d Some more safety around the SDL_HelperWindow stuff to avoid double creations.
Edgar Simo <bobbens@gmail.com>
parents: 2990
diff changeset
665
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
666 /* 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
667 SDL_zero(wce);
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
668 wce.lpfnWndProc = DefWindowProc;
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
669 wce.lpszClassName = (LPCWSTR) SDL_HelperWindowClassName;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
670 wce.hInstance = hInstance;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
671
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
672 /* Register the class. */
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
673 SDL_HelperWindowClass = RegisterClass(&wce);
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
674 if (SDL_HelperWindowClass == 0) {
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
675 SDL_SetError("Unable to create Helper Window Class: error %d.",
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
676 GetLastError());
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
677 return -1;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
678 }
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
679
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
680 #ifndef _WIN32_WCE
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
681 /* WinCE doesn't have HWND_MESSAGE */
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
682 hWndParent = HWND_MESSAGE;
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
683 #endif
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
684
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
685 /* 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
686 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
687 SDL_HelperWindowName,
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
688 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
689 CW_USEDEFAULT, CW_USEDEFAULT,
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
690 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
691 hInstance, NULL);
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
692 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
693 UnregisterClass(SDL_HelperWindowClassName, hInstance);
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
694 SDL_SetError("Unable to create Helper Window: error %d.",
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
695 GetLastError());
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
696 return -1;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
697 }
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
698
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
699 return 0;
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
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
702
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
703 /*
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
704 * 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
705 */
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
706 void
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
707 SDL_HelperWindowDestroy(void)
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
708 {
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
709 HINSTANCE hInstance = GetModuleHandle(NULL);
2863
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
710
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
711 /* Destroy the window. */
2863
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
712 if (SDL_HelperWindow != NULL) {
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
713 if (DestroyWindow(SDL_HelperWindow) == 0) {
2865
Sam Lantinga <slouken@libsdl.org>
parents: 2863
diff changeset
714 SDL_SetError("Unable to destroy Helper Window: error %d.",
Sam Lantinga <slouken@libsdl.org>
parents: 2863
diff changeset
715 GetLastError());
Sam Lantinga <slouken@libsdl.org>
parents: 2863
diff changeset
716 return;
2863
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
717 }
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
718 SDL_HelperWindow = NULL;
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
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
721 /* Unregister the class. */
2863
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
722 if (SDL_HelperWindowClass != 0) {
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
723 if ((UnregisterClass(SDL_HelperWindowClassName, hInstance)) == 0) {
2865
Sam Lantinga <slouken@libsdl.org>
parents: 2863
diff changeset
724 SDL_SetError("Unable to destroy Helper Window Class: error %d.",
Sam Lantinga <slouken@libsdl.org>
parents: 2863
diff changeset
725 GetLastError());
Sam Lantinga <slouken@libsdl.org>
parents: 2863
diff changeset
726 return;
2863
b632927c28c8 Some error checking when destroying the HelperWindow.
Edgar Simo <bobbens@gmail.com>
parents: 2859
diff changeset
727 }
2713
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
728 SDL_HelperWindowClass = 0;
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
729 }
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
730 }
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
731
0906692aa6a4 Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2710
diff changeset
732
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
733 /* vi: set ts=4 sw=4 expandtab: */