early-access version 1617
This commit is contained in:
136
externals/SDL/src/video/windows/SDL_windowsevents.c
vendored
136
externals/SDL/src/video/windows/SDL_windowsevents.c
vendored
@@ -32,7 +32,6 @@
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
#include "../../events/scancodes_windows.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
/* Dropfile support */
|
||||
@@ -75,22 +74,30 @@
|
||||
#ifndef WM_MOUSEHWHEEL
|
||||
#define WM_MOUSEHWHEEL 0x020E
|
||||
#endif
|
||||
#ifndef WM_POINTERUPDATE
|
||||
#define WM_POINTERUPDATE 0x0245
|
||||
#endif
|
||||
#ifndef WM_UNICHAR
|
||||
#define WM_UNICHAR 0x0109
|
||||
#endif
|
||||
|
||||
static SDL_Scancode
|
||||
VKeytoScancode(WPARAM vkey)
|
||||
VKeytoScancodeFallback(WPARAM vkey)
|
||||
{
|
||||
switch (vkey) {
|
||||
/* Windows generates this virtual keycode for Keypad 5 when NumLock is off.
|
||||
case VK_CLEAR: return SDL_SCANCODE_CLEAR;
|
||||
*/
|
||||
case VK_LEFT: return SDL_SCANCODE_LEFT;
|
||||
case VK_UP: return SDL_SCANCODE_UP;
|
||||
case VK_RIGHT: return SDL_SCANCODE_RIGHT;
|
||||
case VK_DOWN: return SDL_SCANCODE_DOWN;
|
||||
|
||||
default: return SDL_SCANCODE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_Scancode
|
||||
VKeytoScancode(WPARAM vkey)
|
||||
{
|
||||
switch (vkey) {
|
||||
case VK_MODECHANGE: return SDL_SCANCODE_MODE;
|
||||
case VK_SELECT: return SDL_SCANCODE_SELECT;
|
||||
case VK_EXECUTE: return SDL_SCANCODE_EXECUTE;
|
||||
@@ -216,6 +223,16 @@ WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The on-screen keyboard can generate VK_LEFT and VK_RIGHT events without a scancode
|
||||
* value set, however we cannot simply map these in VKeytoScancode() or we will be
|
||||
* incorrectly handling the arrow keys on the number pad when NumLock is disabled
|
||||
* (which also generate VK_LEFT, VK_RIGHT, etc in that scenario). Instead, we'll only
|
||||
* map them if none of the above special number pad mappings applied. */
|
||||
if (code == SDL_SCANCODE_UNKNOWN) {
|
||||
code = VKeytoScancodeFallback(wParam);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -226,8 +243,17 @@ WIN_ShouldIgnoreFocusClick()
|
||||
}
|
||||
|
||||
static void
|
||||
WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, SDL_bool bSDLMousePressed, SDL_WindowData *data, Uint8 button, SDL_MouseID mouseID)
|
||||
WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, Uint32 mouseFlags, SDL_bool bSwapButtons, SDL_WindowData *data, Uint8 button, SDL_MouseID mouseID)
|
||||
{
|
||||
if (bSwapButtons) {
|
||||
if (button == SDL_BUTTON_LEFT) {
|
||||
button = SDL_BUTTON_RIGHT;
|
||||
}
|
||||
else if (button == SDL_BUTTON_RIGHT) {
|
||||
button = SDL_BUTTON_LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
if (data->focus_click_pending & SDL_BUTTON(button)) {
|
||||
/* Ignore the button click for activation */
|
||||
if (!bwParamMousePressed) {
|
||||
@@ -239,9 +265,9 @@ WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, SDL_bool bSDLMousePress
|
||||
}
|
||||
}
|
||||
|
||||
if (bwParamMousePressed && !bSDLMousePressed) {
|
||||
if (bwParamMousePressed && !(mouseFlags & SDL_BUTTON(button))) {
|
||||
SDL_SendMouseButton(data->window, mouseID, SDL_PRESSED, button);
|
||||
} else if (!bwParamMousePressed && bSDLMousePressed) {
|
||||
} else if (!bwParamMousePressed && (mouseFlags & SDL_BUTTON(button))) {
|
||||
SDL_SendMouseButton(data->window, mouseID, SDL_RELEASED, button);
|
||||
}
|
||||
}
|
||||
@@ -255,11 +281,14 @@ WIN_CheckWParamMouseButtons(WPARAM wParam, SDL_WindowData *data, SDL_MouseID mou
|
||||
{
|
||||
if (wParam != data->mouse_button_flags) {
|
||||
Uint32 mouseFlags = SDL_GetMouseState(NULL, NULL);
|
||||
WIN_CheckWParamMouseButton((wParam & MK_LBUTTON), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT, mouseID);
|
||||
WIN_CheckWParamMouseButton((wParam & MK_MBUTTON), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE, mouseID);
|
||||
WIN_CheckWParamMouseButton((wParam & MK_RBUTTON), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT, mouseID);
|
||||
WIN_CheckWParamMouseButton((wParam & MK_XBUTTON1), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1, mouseID);
|
||||
WIN_CheckWParamMouseButton((wParam & MK_XBUTTON2), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2, mouseID);
|
||||
|
||||
/* WM_LBUTTONDOWN and friends handle button swapping for us. No need to check SM_SWAPBUTTON here. */
|
||||
WIN_CheckWParamMouseButton((wParam & MK_LBUTTON), mouseFlags, SDL_FALSE, data, SDL_BUTTON_LEFT, mouseID);
|
||||
WIN_CheckWParamMouseButton((wParam & MK_MBUTTON), mouseFlags, SDL_FALSE, data, SDL_BUTTON_MIDDLE, mouseID);
|
||||
WIN_CheckWParamMouseButton((wParam & MK_RBUTTON), mouseFlags, SDL_FALSE, data, SDL_BUTTON_RIGHT, mouseID);
|
||||
WIN_CheckWParamMouseButton((wParam & MK_XBUTTON1), mouseFlags, SDL_FALSE, data, SDL_BUTTON_X1, mouseID);
|
||||
WIN_CheckWParamMouseButton((wParam & MK_XBUTTON2), mouseFlags, SDL_FALSE, data, SDL_BUTTON_X2, mouseID);
|
||||
|
||||
data->mouse_button_flags = wParam;
|
||||
}
|
||||
}
|
||||
@@ -269,26 +298,27 @@ WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data)
|
||||
{
|
||||
if (rawButtons != data->mouse_button_flags) {
|
||||
Uint32 mouseFlags = SDL_GetMouseState(NULL, NULL);
|
||||
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_1_DOWN))
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_1_DOWN), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT, 0);
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_1_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, 0);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_1_UP))
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_1_UP), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT, 0);
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_1_UP), mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, 0);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_2_DOWN))
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_2_DOWN), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT, 0);
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_2_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_RIGHT, 0);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_2_UP))
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_2_UP), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT, 0);
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_2_UP), mouseFlags, swapButtons, data, SDL_BUTTON_RIGHT, 0);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_3_DOWN))
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_3_DOWN), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE, 0);
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_3_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_MIDDLE, 0);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_3_UP))
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_3_UP), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE, 0);
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_3_UP), mouseFlags, swapButtons, data, SDL_BUTTON_MIDDLE, 0);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_4_DOWN))
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_4_DOWN), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1, 0);
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_4_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_X1, 0);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_4_UP))
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_4_UP), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1, 0);
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_4_UP), mouseFlags, swapButtons, data, SDL_BUTTON_X1, 0);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_5_DOWN))
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_5_DOWN), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2, 0);
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_5_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_X2, 0);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_5_UP))
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_5_UP), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2, 0);
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_5_UP), mouseFlags, swapButtons, data, SDL_BUTTON_X2, 0);
|
||||
data->mouse_button_flags = rawButtons;
|
||||
}
|
||||
}
|
||||
@@ -298,31 +328,33 @@ WIN_CheckAsyncMouseRelease(SDL_WindowData *data)
|
||||
{
|
||||
Uint32 mouseFlags;
|
||||
SHORT keyState;
|
||||
SDL_bool swapButtons;
|
||||
|
||||
/* mouse buttons may have changed state here, we need to resync them,
|
||||
but we will get a WM_MOUSEMOVE right away which will fix things up if in non raw mode also
|
||||
*/
|
||||
mouseFlags = SDL_GetMouseState(NULL, NULL);
|
||||
swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
||||
|
||||
keyState = GetAsyncKeyState(VK_LBUTTON);
|
||||
if (!(keyState & 0x8000)) {
|
||||
WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT, 0);
|
||||
WIN_CheckWParamMouseButton(SDL_FALSE, mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, 0);
|
||||
}
|
||||
keyState = GetAsyncKeyState(VK_RBUTTON);
|
||||
if (!(keyState & 0x8000)) {
|
||||
WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT, 0);
|
||||
WIN_CheckWParamMouseButton(SDL_FALSE, mouseFlags, swapButtons, data, SDL_BUTTON_RIGHT, 0);
|
||||
}
|
||||
keyState = GetAsyncKeyState(VK_MBUTTON);
|
||||
if (!(keyState & 0x8000)) {
|
||||
WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE, 0);
|
||||
WIN_CheckWParamMouseButton(SDL_FALSE, mouseFlags, swapButtons, data, SDL_BUTTON_MIDDLE, 0);
|
||||
}
|
||||
keyState = GetAsyncKeyState(VK_XBUTTON1);
|
||||
if (!(keyState & 0x8000)) {
|
||||
WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1, 0);
|
||||
WIN_CheckWParamMouseButton(SDL_FALSE, mouseFlags, swapButtons, data, SDL_BUTTON_X1, 0);
|
||||
}
|
||||
keyState = GetAsyncKeyState(VK_XBUTTON2);
|
||||
if (!(keyState & 0x8000)) {
|
||||
WIN_CheckWParamMouseButton(SDL_FALSE, (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2, 0);
|
||||
WIN_CheckWParamMouseButton(SDL_FALSE, mouseFlags, swapButtons, data, SDL_BUTTON_X2, 0);
|
||||
}
|
||||
data->mouse_button_flags = 0;
|
||||
}
|
||||
@@ -467,11 +499,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
}
|
||||
if (LOWORD(wParam) == WA_CLICKACTIVE) {
|
||||
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
||||
if (GetAsyncKeyState(VK_LBUTTON)) {
|
||||
data->focus_click_pending |= SDL_BUTTON_LMASK;
|
||||
data->focus_click_pending |= !swapButtons ? SDL_BUTTON_LMASK : SDL_BUTTON_RMASK;
|
||||
}
|
||||
if (GetAsyncKeyState(VK_RBUTTON)) {
|
||||
data->focus_click_pending |= SDL_BUTTON_RMASK;
|
||||
data->focus_click_pending |= !swapButtons ? SDL_BUTTON_RMASK : SDL_BUTTON_LMASK;
|
||||
}
|
||||
if (GetAsyncKeyState(VK_MBUTTON)) {
|
||||
data->focus_click_pending |= SDL_BUTTON_MMASK;
|
||||
@@ -494,6 +527,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y);
|
||||
|
||||
WIN_CheckAsyncMouseRelease(data);
|
||||
WIN_UpdateClipCursor(data->window);
|
||||
|
||||
/*
|
||||
* FIXME: Update keyboard state
|
||||
@@ -523,12 +557,19 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
returnCode = 0;
|
||||
break;
|
||||
|
||||
case WM_POINTERUPDATE:
|
||||
{
|
||||
data->last_pointer_update = lParam;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
if (!mouse->relative_mode || mouse->relative_mode_warp) {
|
||||
/* Only generate mouse events for real mouse */
|
||||
if (GetMouseMessageSource() != SDL_MOUSE_EVENT_SOURCE_TOUCH) {
|
||||
if (GetMouseMessageSource() != SDL_MOUSE_EVENT_SOURCE_TOUCH &&
|
||||
lParam != data->last_pointer_update) {
|
||||
SDL_SendMouseMotion(data->window, 0, 0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
if (isWin10FCUorNewer && mouse->relative_mode_warp) {
|
||||
/* To work around #3931, Win10 bug introduced in Fall Creators Update, where
|
||||
@@ -563,7 +604,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
if (!mouse->relative_mode || mouse->relative_mode_warp) {
|
||||
if (GetMouseMessageSource() != SDL_MOUSE_EVENT_SOURCE_TOUCH) {
|
||||
if (GetMouseMessageSource() != SDL_MOUSE_EVENT_SOURCE_TOUCH &&
|
||||
lParam != data->last_pointer_update) {
|
||||
WIN_CheckWParamMouseButtons(wParam, data, 0);
|
||||
}
|
||||
}
|
||||
@@ -589,7 +631,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
/* Mouse data (ignoring synthetic mouse events generated for touchscreens) */
|
||||
if (inp.header.dwType == RIM_TYPEMOUSE) {
|
||||
if (GetMouseMessageSource() == SDL_MOUSE_EVENT_SOURCE_TOUCH) {
|
||||
if (GetMouseMessageSource() == SDL_MOUSE_EVENT_SOURCE_TOUCH ||
|
||||
(GetMessageExtraInfo() & 0x82) == 0x82) {
|
||||
break;
|
||||
}
|
||||
if (isRelative) {
|
||||
@@ -597,7 +640,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if ((rawmouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) {
|
||||
SDL_SendMouseMotion(data->window, 0, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY);
|
||||
} else {
|
||||
} else if (rawmouse->lLastX || rawmouse->lLastY) {
|
||||
/* synthesize relative moves from the abs position */
|
||||
static SDL_Point lastMousePoint;
|
||||
SDL_bool virtual_desktop = (rawmouse->usFlags & MOUSE_VIRTUAL_DESKTOP) ? SDL_TRUE : SDL_FALSE;
|
||||
@@ -630,9 +673,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
/* if in the window, WM_MOUSEMOVE, etc, will cover it. */
|
||||
if(currentHnd != hwnd || pt.x < 0 || pt.y < 0 || pt.x > hwndRect.right || pt.y > hwndRect.right) {
|
||||
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
||||
|
||||
SDL_SendMouseMotion(data->window, 0, 0, (int)pt.x, (int)pt.y);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_XBUTTON1) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X1);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_XBUTTON2) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X2);
|
||||
@@ -1044,6 +1089,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DISPLAYCHANGE:
|
||||
{
|
||||
// Reacquire displays if any were added or removed
|
||||
WIN_RefreshDisplays(SDL_GetVideoDevice());
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NCCALCSIZE:
|
||||
{
|
||||
Uint32 window_flags = SDL_GetWindowFlags(data->window);
|
||||
@@ -1105,11 +1157,19 @@ static void WIN_UpdateClipCursorForWindows()
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
SDL_Window *window;
|
||||
Uint32 now = SDL_GetTicks();
|
||||
const Uint32 CLIPCURSOR_UPDATE_INTERVAL_MS = 3000;
|
||||
|
||||
if (_this) {
|
||||
for (window = _this->windows; window; window = window->next) {
|
||||
if (window->driverdata) {
|
||||
WIN_UpdateClipCursor(window);
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
if (data) {
|
||||
if (data->skip_update_clipcursor) {
|
||||
data->skip_update_clipcursor = SDL_FALSE;
|
||||
WIN_UpdateClipCursor(window);
|
||||
} else if ((now - data->last_updated_clipcursor) >= CLIPCURSOR_UPDATE_INTERVAL_MS) {
|
||||
WIN_UpdateClipCursor(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -99,8 +99,12 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi
|
||||
int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
int i;
|
||||
|
||||
BitBlt(data->hdc, 0, 0, window->w, window->h, data->mdc, 0, 0, SRCCOPY);
|
||||
for (i = 0; i < numrects; ++i) {
|
||||
BitBlt(data->hdc, rects[i].x, rects[i].y, rects[i].w, rects[i].h,
|
||||
data->mdc, rects[i].x, rects[i].y, SRCCOPY);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -24,15 +24,13 @@
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#else
|
||||
#endif
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX ((size_t)-1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowstaskdialog.h"
|
||||
|
||||
@@ -586,7 +584,6 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
}
|
||||
|
||||
/* Jan 25th, 2013 - dant@fleetsa.com
|
||||
*
|
||||
*
|
||||
* I've tried to make this more reasonable, but I've run in to a lot
|
||||
* of nonsense.
|
||||
@@ -611,8 +608,6 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
* somewhat correct.
|
||||
*
|
||||
* Honestly, a long term solution is to use CreateWindow, not CreateDialog.
|
||||
*
|
||||
|
||||
*
|
||||
* In order to get text dimensions we need to have a DC with the desired font.
|
||||
* I'm assuming a dialog box in SDL is rare enough we can to the create.
|
||||
|
@@ -23,8 +23,6 @@
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "../../../include/SDL_assert.h"
|
||||
#include "../../../include/SDL_log.h"
|
||||
|
||||
/* Windows CE compatibility */
|
||||
#ifndef CDS_FULLSCREEN
|
||||
@@ -141,8 +139,9 @@ WIN_GetDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mod
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEX *info)
|
||||
WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_bool send_event)
|
||||
{
|
||||
int i;
|
||||
SDL_VideoDisplay display;
|
||||
SDL_DisplayData *displaydata;
|
||||
SDL_DisplayMode mode;
|
||||
@@ -156,6 +155,18 @@ WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEX *info)
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
// Prevent adding duplicate displays. Do this after we know the display is
|
||||
// ready to be added to allow any displays that we can't fully query to be
|
||||
// removed
|
||||
for(i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_DisplayData *driverdata = (SDL_DisplayData *)_this->displays[i].driverdata;
|
||||
if (SDL_wcscmp(driverdata->DeviceName, info->szDevice) == 0) {
|
||||
driverdata->MonitorHandle = hMonitor;
|
||||
driverdata->IsValid = SDL_TRUE;
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
|
||||
if (!displaydata) {
|
||||
return SDL_FALSE;
|
||||
@@ -163,6 +174,7 @@ WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEX *info)
|
||||
SDL_memcpy(displaydata->DeviceName, info->szDevice,
|
||||
sizeof(displaydata->DeviceName));
|
||||
displaydata->MonitorHandle = hMonitor;
|
||||
displaydata->IsValid = SDL_TRUE;
|
||||
|
||||
SDL_zero(display);
|
||||
device.cb = sizeof(device);
|
||||
@@ -172,13 +184,14 @@ WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEX *info)
|
||||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
display.driverdata = displaydata;
|
||||
SDL_AddVideoDisplay(&display);
|
||||
SDL_AddVideoDisplay(&display, send_event);
|
||||
SDL_free(display.name);
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
typedef struct _WIN_AddDisplaysData {
|
||||
SDL_VideoDevice *video_device;
|
||||
SDL_bool send_event;
|
||||
SDL_bool want_primary;
|
||||
} WIN_AddDisplaysData;
|
||||
|
||||
@@ -189,16 +202,16 @@ WIN_AddDisplaysCallback(HMONITOR hMonitor,
|
||||
LPARAM dwData)
|
||||
{
|
||||
WIN_AddDisplaysData *data = (WIN_AddDisplaysData*)dwData;
|
||||
MONITORINFOEX info;
|
||||
MONITORINFOEXW info;
|
||||
|
||||
SDL_zero(info);
|
||||
info.cbSize = sizeof(info);
|
||||
|
||||
if (GetMonitorInfo(hMonitor, (LPMONITORINFO)&info) != 0) {
|
||||
if (GetMonitorInfoW(hMonitor, (LPMONITORINFO)&info) != 0) {
|
||||
const SDL_bool is_primary = ((info.dwFlags & MONITORINFOF_PRIMARY) == MONITORINFOF_PRIMARY);
|
||||
|
||||
if (is_primary == data->want_primary) {
|
||||
WIN_AddDisplay(data->video_device, hMonitor, &info);
|
||||
WIN_AddDisplay(data->video_device, hMonitor, &info, data->send_event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,10 +220,11 @@ WIN_AddDisplaysCallback(HMONITOR hMonitor,
|
||||
}
|
||||
|
||||
static void
|
||||
WIN_AddDisplays(_THIS)
|
||||
WIN_AddDisplays(_THIS, SDL_bool send_event)
|
||||
{
|
||||
WIN_AddDisplaysData callback_data;
|
||||
callback_data.video_device = _this;
|
||||
callback_data.send_event = send_event;
|
||||
|
||||
callback_data.want_primary = SDL_TRUE;
|
||||
EnumDisplayMonitors(NULL, NULL, WIN_AddDisplaysCallback, (LPARAM)&callback_data);
|
||||
@@ -222,7 +236,7 @@ WIN_AddDisplays(_THIS)
|
||||
int
|
||||
WIN_InitModes(_THIS)
|
||||
{
|
||||
WIN_AddDisplays(_this);
|
||||
WIN_AddDisplays(_this, SDL_FALSE);
|
||||
|
||||
if (_this->num_displays == 0) {
|
||||
return SDL_SetError("No displays available");
|
||||
@@ -396,6 +410,32 @@ WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_RefreshDisplays(_THIS)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Mark all displays as potentially invalid to detect
|
||||
// entries that have actually been removed
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_DisplayData *driverdata = (SDL_DisplayData *)_this->displays[i].driverdata;
|
||||
driverdata->IsValid = SDL_FALSE;
|
||||
}
|
||||
|
||||
// Enumerate displays to add any new ones and mark still
|
||||
// connected entries as valid
|
||||
WIN_AddDisplays(_this, SDL_TRUE);
|
||||
|
||||
// Delete any entries still marked as invalid, iterate
|
||||
// in reverse as each delete takes effect immediately
|
||||
for (i = _this->num_displays - 1; i >= 0; --i) {
|
||||
SDL_DisplayData *driverdata = (SDL_DisplayData *)_this->displays[i].driverdata;
|
||||
if (driverdata->IsValid == SDL_FALSE) {
|
||||
SDL_DelVideoDisplay(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WIN_QuitModes(_THIS)
|
||||
{
|
||||
|
@@ -25,8 +25,9 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TCHAR DeviceName[32];
|
||||
WCHAR DeviceName[32];
|
||||
HMONITOR MonitorHandle;
|
||||
SDL_bool IsValid;
|
||||
} SDL_DisplayData;
|
||||
|
||||
typedef struct
|
||||
@@ -40,6 +41,7 @@ extern int WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rec
|
||||
extern int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
|
||||
extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
|
||||
extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
extern void WIN_RefreshDisplays(_THIS);
|
||||
extern void WIN_QuitModes(_THIS);
|
||||
|
||||
#endif /* SDL_windowsmodes_h_ */
|
||||
|
@@ -22,7 +22,6 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_windowsvideo.h"
|
||||
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
@@ -276,12 +275,14 @@ WIN_GetGlobalMouseState(int *x, int *y)
|
||||
{
|
||||
Uint32 retval = 0;
|
||||
POINT pt = { 0, 0 };
|
||||
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
||||
|
||||
GetCursorPos(&pt);
|
||||
*x = (int) pt.x;
|
||||
*y = (int) pt.y;
|
||||
|
||||
retval |= GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_BUTTON_LMASK : 0;
|
||||
retval |= GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_BUTTON_RMASK : 0;
|
||||
retval |= GetAsyncKeyState(!swapButtons ? VK_LBUTTON : VK_RBUTTON) & 0x8000 ? SDL_BUTTON_LMASK : 0;
|
||||
retval |= GetAsyncKeyState(!swapButtons ? VK_RBUTTON : VK_LBUTTON) & 0x8000 ? SDL_BUTTON_RMASK : 0;
|
||||
retval |= GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_BUTTON_MMASK : 0;
|
||||
retval |= GetAsyncKeyState(VK_XBUTTON1) & 0x8000 ? SDL_BUTTON_X1MASK : 0;
|
||||
retval |= GetAsyncKeyState(VK_XBUTTON2) & 0x8000 ? SDL_BUTTON_X2MASK : 0;
|
||||
|
@@ -22,7 +22,6 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowsopengles.h"
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowsopengles.h"
|
||||
#include "SDL_windowsopengl.h"
|
||||
#include "SDL_log.h"
|
||||
|
||||
/* EGL implementation of SDL OpenGL support */
|
||||
|
||||
@@ -108,12 +107,13 @@ WIN_GLES_SetupWindow(_THIS, SDL_Window * window)
|
||||
SDL_Window *current_win = SDL_GL_GetCurrentWindow();
|
||||
SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
|
||||
|
||||
|
||||
if (_this->egl_data == NULL) {
|
||||
SDL_assert(!_this->gl_config.driver_loaded);
|
||||
if (SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0) < 0) {
|
||||
SDL_EGL_UnloadLibrary(_this);
|
||||
return -1;
|
||||
}
|
||||
_this->gl_config.driver_loaded = 1;
|
||||
}
|
||||
|
||||
/* Create the GLES window surface */
|
||||
|
@@ -22,7 +22,6 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_windowsshape.h"
|
||||
#include "SDL_windowsvideo.h"
|
||||
|
||||
|
@@ -75,12 +75,6 @@ static void WIN_SuspendScreenSaver(_THIS)
|
||||
|
||||
/* Windows driver bootstrap functions */
|
||||
|
||||
static int
|
||||
WIN_Available(void)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
WIN_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
@@ -224,7 +218,7 @@ WIN_CreateDevice(int devindex)
|
||||
|
||||
|
||||
VideoBootStrap WINDOWS_bootstrap = {
|
||||
"windows", "SDL Windows video driver", WIN_Available, WIN_CreateDevice
|
||||
"windows", "SDL Windows video driver", WIN_CreateDevice
|
||||
};
|
||||
|
||||
int
|
||||
|
@@ -30,7 +30,6 @@
|
||||
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowswindow.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_windowsvulkan.h"
|
||||
|
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_pixels_c.h"
|
||||
#include "../../events/SDL_keyboard_c.h"
|
||||
@@ -33,6 +32,7 @@
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowswindow.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_timer.h"
|
||||
|
||||
/* Dropfile support */
|
||||
#include <shellapi.h>
|
||||
@@ -187,6 +187,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre
|
||||
data->hinstance = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||
data->created = created;
|
||||
data->mouse_button_flags = 0;
|
||||
data->last_pointer_update = (LPARAM)-1;
|
||||
data->videodata = videodata;
|
||||
data->initializing = SDL_TRUE;
|
||||
|
||||
@@ -808,9 +809,8 @@ WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Creates a HelperWindow used for DirectInput events.
|
||||
* Creates a HelperWindow used for DirectInput.
|
||||
*/
|
||||
int
|
||||
SDL_HelperWindowCreate(void)
|
||||
@@ -915,7 +915,6 @@ WIN_UpdateClipCursor(SDL_Window *window)
|
||||
return;
|
||||
}
|
||||
if (data->skip_update_clipcursor) {
|
||||
data->skip_update_clipcursor = SDL_FALSE;
|
||||
return;
|
||||
}
|
||||
if (!GetClipCursor(&clipped_rect)) {
|
||||
@@ -954,10 +953,20 @@ WIN_UpdateClipCursor(SDL_Window *window)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (SDL_memcmp(&clipped_rect, &data->cursor_clipped_rect, sizeof(clipped_rect)) == 0) {
|
||||
ClipCursor(NULL);
|
||||
SDL_zero(data->cursor_clipped_rect);
|
||||
} else {
|
||||
POINT first, second;
|
||||
|
||||
first.x = clipped_rect.left;
|
||||
first.y = clipped_rect.top;
|
||||
second.x = clipped_rect.right - 1;
|
||||
second.y = clipped_rect.bottom - 1;
|
||||
if (PtInRect(&data->cursor_clipped_rect, first) &&
|
||||
PtInRect(&data->cursor_clipped_rect, second)) {
|
||||
ClipCursor(NULL);
|
||||
SDL_zero(data->cursor_clipped_rect);
|
||||
}
|
||||
}
|
||||
data->last_updated_clipcursor = SDL_GetTicks();
|
||||
}
|
||||
|
||||
int
|
||||
|
@@ -39,12 +39,14 @@ typedef struct
|
||||
WNDPROC wndproc;
|
||||
SDL_bool created;
|
||||
WPARAM mouse_button_flags;
|
||||
LPARAM last_pointer_update;
|
||||
SDL_bool initializing;
|
||||
SDL_bool expected_resize;
|
||||
SDL_bool in_border_change;
|
||||
SDL_bool in_title_click;
|
||||
Uint8 focus_click_pending;
|
||||
SDL_bool skip_update_clipcursor;
|
||||
Uint32 last_updated_clipcursor;
|
||||
SDL_bool windowed_mode_was_maximized;
|
||||
SDL_bool in_window_deactivation;
|
||||
RECT cursor_clipped_rect;
|
||||
|
Reference in New Issue
Block a user