23 #if SDL_VIDEO_DRIVER_WINDOWS
26 #include "../SDL_sysvideo.h"
27 #include "../SDL_pixels_c.h"
28 #include "../../events/SDL_keyboard_c.h"
40 #ifndef SWP_NOCOPYBITS
41 #define SWP_NOCOPYBITS 0
45 HWND SDL_HelperWindow =
NULL;
46 static WCHAR *SDL_HelperWindowClassName = TEXT(
"SDLHelperWindowInputCatcher");
47 static WCHAR *SDL_HelperWindowName = TEXT(
"SDLHelperWindowInputMsgWindow");
48 static ATOM SDL_HelperWindowClass = 0;
50 #define STYLE_BASIC (WS_CLIPSIBLINGS | WS_CLIPCHILDREN)
51 #define STYLE_FULLSCREEN (WS_POPUP)
52 #define STYLE_BORDERLESS (WS_POPUP)
53 #define STYLE_NORMAL (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX)
54 #define STYLE_RESIZABLE (WS_THICKFRAME | WS_MAXIMIZEBOX)
55 #define STYLE_MASK (STYLE_FULLSCREEN | STYLE_BORDERLESS | STYLE_NORMAL | STYLE_RESIZABLE)
63 style |= STYLE_FULLSCREEN;
66 style |= STYLE_BORDERLESS;
68 style |= STYLE_NORMAL;
71 style |= STYLE_RESIZABLE;
94 style = GetWindowLong(hwnd, GWL_STYLE);
97 rect.right = window->
w;
98 rect.bottom = window->
h;
99 menu = (style & WS_CHILDWINDOW) ?
FALSE : (GetMenu(hwnd) !=
NULL);
100 AdjustWindowRectEx(&rect, style, menu, 0);
101 w = (rect.right - rect.left);
102 h = (rect.bottom - rect.top);
103 x = window->
x + rect.left;
104 y = window->
y + rect.top;
106 SetWindowPos(hwnd, top, x, y, w, h, flags);
120 data->window = window;
122 data->hdc = GetDC(hwnd);
123 data->created = created;
124 data->mouse_button_flags = 0;
125 data->videodata = videodata;
130 if (!SetProp(hwnd, TEXT(
"SDL_WindowData"),
data)) {
131 ReleaseDC(hwnd,
data->hdc);
138 data->wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC);
145 data->wndproc = (WNDPROC) GetWindowLong(hwnd, GWL_WNDPROC);
156 if (GetClientRect(hwnd, &rect)) {
159 if ((window->
w && window->
w != w) || (window->
h && window->
h != h)) {
161 WIN_SetWindowPositionInternal(
_this, window, SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOACTIVATE);
172 if (ClientToScreen(hwnd, &point)) {
178 DWORD style = GetWindowLong(hwnd, GWL_STYLE);
179 if (style & WS_VISIBLE) {
184 if (style & (WS_BORDER | WS_THICKFRAME)) {
189 if (style & WS_THICKFRAME) {
195 if (style & WS_MAXIMIZE) {
203 if (style & WS_MINIMIZE) {
211 if (GetFocus() == hwnd) {
217 GetClientRect(hwnd, &rect);
218 ClientToScreen(hwnd, (LPPOINT) & rect);
219 ClientToScreen(hwnd, (LPPOINT) & rect + 1);
225 if (videodata->RegisterTouchWindow) {
226 videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM));
230 DragAcceptFiles(hwnd,
TRUE);
241 DWORD style = STYLE_BASIC;
245 style |= GetWindowStyle(window);
248 rect.left = window->
x;
249 rect.top = window->
y;
250 rect.right = window->
x + window->
w;
251 rect.bottom = window->
y + window->
h;
252 AdjustWindowRectEx(&rect, style,
FALSE, 0);
255 w = (rect.right - rect.left);
256 h = (rect.bottom - rect.top);
271 #if SDL_VIDEO_OPENGL_WGL
273 if (WIN_GL_SetupWindow(
_this, window) < 0) {
285 HWND hwnd = (HWND) data;
290 titleLen = GetWindowTextLength(hwnd);
293 titleLen = GetWindowText(hwnd, title, titleLen);
321 SetWindowText(hwnd, title ? title : TEXT(
""));
335 icon_len = 40 + icon->
h * icon->
w * 4;
364 hicon = CreateIconFromResource(icon_bmp, icon_len,
TRUE, 0x00030000);
370 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM) hicon);
373 SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM) hicon);
379 WIN_SetWindowPositionInternal(
_this, window, SWP_NOCOPYBITS | SWP_NOSIZE | SWP_NOACTIVATE);
385 WIN_SetWindowPositionInternal(
_this, window, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOACTIVATE);
392 ShowWindow(hwnd, SW_SHOW);
399 ShowWindow(hwnd, SW_HIDE);
405 WIN_SetWindowPositionInternal(
_this, window, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOSIZE);
412 ShowWindow(hwnd, SW_MAXIMIZE);
419 ShowWindow(hwnd, SW_MINIMIZE);
426 DWORD style = GetWindowLong(hwnd, GWL_STYLE);
429 style &= ~STYLE_BORDERLESS;
430 style |= STYLE_NORMAL;
432 style &= ~STYLE_NORMAL;
433 style |= STYLE_BORDERLESS;
436 SetWindowLong(hwnd, GWL_STYLE, style);
437 WIN_SetWindowPositionInternal(
_this, window, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_NOREPOSITION | SWP_NOZORDER |SWP_NOACTIVATE | SWP_NOSENDCHANGING);
445 ShowWindow(hwnd, SW_RESTORE);
452 HWND hwnd = data->
hwnd;
464 top = HWND_NOTOPMOST;
467 style = GetWindowLong(hwnd, GWL_STYLE);
468 style &= ~STYLE_MASK;
469 style |= GetWindowStyle(window);
483 menu = (style & WS_CHILDWINDOW) ?
FALSE : (GetMenu(hwnd) !=
NULL);
484 AdjustWindowRectEx(&rect, style, menu, 0);
485 w = (rect.right - rect.left);
486 h = (rect.bottom - rect.top);
490 SetWindowLong(hwnd, GWL_STYLE, style);
491 SetWindowPos(hwnd, top, x, y, w, h, SWP_NOCOPYBITS);
504 succeeded = SetDeviceGammaRamp(hdc, (
LPVOID)ramp);
510 return succeeded ? 0 : -1;
523 succeeded = GetDeviceGammaRamp(hdc, (
LPVOID)ramp);
529 return succeeded ? 0 : -1;
539 GetClientRect(hwnd, &rect);
540 ClientToScreen(hwnd, (LPPOINT) & rect);
541 ClientToScreen(hwnd, (LPPOINT) & rect + 1);
548 UINT flags = SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOSIZE;
551 flags |= SWP_NOACTIVATE;
553 WIN_SetWindowPositionInternal(
_this, window, flags);
563 ReleaseDC(data->
hwnd, data->
hdc);
565 DestroyWindow(data->
hwnd);
570 SetWindowLongPtr(data->
hwnd, GWLP_WNDPROC,
573 SetWindowLong(data->
hwnd, GWL_WNDPROC,
588 info->
info.win.window = hwnd;
591 SDL_SetError(
"Application not compiled with SDL %d.%d\n",
602 SDL_HelperWindowCreate(
void)
604 HINSTANCE hInstance = GetModuleHandle(
NULL);
608 if (SDL_HelperWindow !=
NULL) {
614 wce.lpfnWndProc = DefWindowProc;
615 wce.lpszClassName = (LPCWSTR) SDL_HelperWindowClassName;
616 wce.hInstance = hInstance;
619 SDL_HelperWindowClass = RegisterClass(&wce);
620 if (SDL_HelperWindowClass == 0) {
621 return WIN_SetError(
"Unable to create Helper Window Class");
625 SDL_HelperWindow = CreateWindowEx(0, SDL_HelperWindowClassName,
626 SDL_HelperWindowName,
627 WS_OVERLAPPED, CW_USEDEFAULT,
628 CW_USEDEFAULT, CW_USEDEFAULT,
629 CW_USEDEFAULT, HWND_MESSAGE,
NULL,
631 if (SDL_HelperWindow ==
NULL) {
632 UnregisterClass(SDL_HelperWindowClassName, hInstance);
644 SDL_HelperWindowDestroy(
void)
646 HINSTANCE hInstance = GetModuleHandle(
NULL);
649 if (SDL_HelperWindow !=
NULL) {
650 if (DestroyWindow(SDL_HelperWindow) == 0) {
654 SDL_HelperWindow =
NULL;
658 if (SDL_HelperWindowClass != 0) {
659 if ((UnregisterClass(SDL_HelperWindowClassName, hInstance)) == 0) {
663 SDL_HelperWindowClass = 0;
671 TRACKMOUSEEVENT trackMouseEvent;
673 if (!data || !data->
hwnd) {
678 trackMouseEvent.cbSize =
sizeof(TRACKMOUSEEVENT);
679 trackMouseEvent.dwFlags = TME_LEAVE;
680 trackMouseEvent.hwndTrack = data->
hwnd;
682 TrackMouseEvent(&trackMouseEvent);
#define SDL_MINOR_VERSION
#define WIN_UTF8ToString(S)
void WIN_SetWindowSize(_THIS, SDL_Window *window)
GLfloat GLfloat GLfloat GLfloat h
void SDL_SetKeyboardFocus(SDL_Window *window)
#define SDL_stack_free(data)
#define SDL_RWwrite(ctx, ptr, size, n)
#define SDL_MAJOR_VERSION
void WIN_RaiseWindow(_THIS, SDL_Window *window)
int WIN_GetWindowGammaRamp(_THIS, SDL_Window *window, Uint16 *ramp)
LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
void WIN_DestroyWindow(_THIS, SDL_Window *window)
SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
A collection of pixels used in software blitting.
void WIN_MaximizeWindow(_THIS, SDL_Window *window)
DECLSPEC void SDLCALL SDL_free(void *mem)
typedef UINT(WINAPI *PFNWGLGETCONTEXTGPUIDAMDPROC)(HGLRC hglrc)
DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value)
void WIN_OnWindowEnter(_THIS, SDL_Window *window)
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(VOID)
void WIN_SetWindowPosition(_THIS, SDL_Window *window)
int WIN_CreateWindow(_THIS, SDL_Window *window)
static SDL_VideoDevice * _this
DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size)
int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void WIN_MinimizeWindow(_THIS, SDL_Window *window)
void WIN_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
void WIN_ShowWindow(_THIS, SDL_Window *window)
#define WIN_StringToUTF8(S)
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
GLfloat GLfloat GLfloat top
union SDL_SysWMinfo::@78 info
void WIN_RestoreWindow(_THIS, SDL_Window *window)
typedef LPVOID(WINAPI *PFNWGLCREATEIMAGEBUFFERI3DPROC)(HDC hDC
#define SDL_assert(condition)
int WIN_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
SDL_bool SDL_ShouldAllowTopmost(void)
EGLSurface EGLint EGLint y
#define SDL_OutOfMemory()
int WIN_SetError(const char *prefix)
void WIN_SetWindowTitle(_THIS, SDL_Window *window)
void WIN_PumpEvents(_THIS)
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
void WIN_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
uint8_t Uint8
An unsigned 8-bit integer type.
typedef DWORD(WINAPI *XInputGetState_t)(DWORD dwUserIndex
DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value)
void WIN_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
GLint GLint GLint GLint GLint w
#define SDL_stack_alloc(type, count)
uint16_t Uint16
An unsigned 16-bit integer type.
void WIN_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
int WIN_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
void WIN_HideWindow(_THIS, SDL_Window *window)
A rectangle, with the origin at the upper left.
typedef BOOL(WINAPI *PFNWGLSETSTEREOEMITTERSTATE3DLPROC)(HDC hDC