update sdl Merge commit '4d48f9d23713d94b861da7b5d41baf2a41334994'

This commit is contained in:
2023-08-12 20:17:29 +02:00
215 changed files with 12672 additions and 17114 deletions

View File

@ -352,18 +352,27 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI
// 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 = _this->displays[i].driverdata;
SDL_DisplayData *driverdata = _this->displays[i]->driverdata;
if (SDL_wcscmp(driverdata->DeviceName, info->szDevice) == 0) {
SDL_bool moved = (index != i);
SDL_bool changed_bounds = SDL_FALSE;
if (moved) {
SDL_VideoDisplay tmp;
if (driverdata->state != DisplayRemoved) {
/* We've already enumerated this display, don't move it */
return;
}
SDL_assert(index < _this->num_displays);
SDL_memcpy(&tmp, &_this->displays[index], sizeof(tmp));
SDL_memcpy(&_this->displays[index], &_this->displays[i], sizeof(tmp));
SDL_memcpy(&_this->displays[i], &tmp, sizeof(tmp));
if (index >= _this->num_displays) {
/* This should never happen due to the check above, but just in case... */
return;
}
if (moved) {
SDL_VideoDisplay *tmp;
tmp = _this->displays[index];
_this->displays[index] = _this->displays[i];
_this->displays[i] = tmp;
i = index;
}
@ -371,7 +380,7 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI
driverdata->state = DisplayUnchanged;
if (!_this->setting_display_mode) {
SDL_VideoDisplay *existing_display = &_this->displays[i];
SDL_VideoDisplay *existing_display = _this->displays[i];
SDL_Rect bounds;
SDL_ResetFullscreenDisplayModes(existing_display);
@ -645,7 +654,7 @@ void WIN_RefreshDisplays(SDL_VideoDevice *_this)
// 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 = _this->displays[i].driverdata;
SDL_DisplayData *driverdata = _this->displays[i]->driverdata;
driverdata->state = DisplayRemoved;
}
@ -656,7 +665,7 @@ void WIN_RefreshDisplays(SDL_VideoDevice *_this)
// 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_VideoDisplay *display = &_this->displays[i];
SDL_VideoDisplay *display = _this->displays[i];
SDL_DisplayData *driverdata = display->driverdata;
if (driverdata->state == DisplayRemoved) {
SDL_DelVideoDisplay(display->id, SDL_TRUE);
@ -665,7 +674,7 @@ void WIN_RefreshDisplays(SDL_VideoDevice *_this)
// Send events for any newly added displays
for (i = 0; i < _this->num_displays; ++i) {
SDL_VideoDisplay *display = &_this->displays[i];
SDL_VideoDisplay *display = _this->displays[i];
SDL_DisplayData *driverdata = display->driverdata;
if (driverdata->state == DisplayAdded) {
SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_CONNECTED, 0);

View File

@ -207,6 +207,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void)
device->SetWindowHitTest = WIN_SetWindowHitTest;
device->AcceptDragAndDrop = WIN_AcceptDragAndDrop;
device->FlashWindow = WIN_FlashWindow;
device->ShowWindowSystemMenu = WIN_ShowWindowSystemMenu;
device->shape_driver.CreateShaper = Win32_CreateShaper;
device->shape_driver.SetWindowShape = Win32_SetWindowShape;

View File

@ -51,6 +51,14 @@ typedef HRESULT (WINAPI *DwmSetWindowAttribute_t)(HWND hwnd, DWORD dwAttribute,
#define SWP_NOCOPYBITS 0
#endif
/* An undocumented message to create a popup system menu
* - wParam is always 0
* - lParam = MAKELONG(x, y) where x and y are the screen coordinates where the menu should be displayed
*/
#ifndef WM_POPUPSYSTEMMENU
#define WM_POPUPSYSTEMMENU 0x313
#endif
/* #define HIGHDPI_DEBUG */
/* Fake window to help with DirectInput events. */
@ -845,7 +853,6 @@ void WIN_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
{
DWORD style;
HWND hwnd;
int nCmdShow;
SDL_bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, SDL_TRUE);
@ -855,13 +862,16 @@ void WIN_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
}
hwnd = window->driverdata->hwnd;
nCmdShow = bActivate ? SW_SHOW : SW_SHOWNA;
style = GetWindowLong(hwnd, GWL_EXSTYLE);
if (style & WS_EX_NOACTIVATE) {
nCmdShow = SW_SHOWNOACTIVATE;
bActivate = SDL_FALSE;
}
ShowWindow(hwnd, nCmdShow);
if (bActivate) {
ShowWindow(hwnd, SW_SHOW);
} else {
/* Use SetWindowPos instead of ShowWindow to avoid activating the parent window if this is a child window */
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, window->driverdata->copybits_flag | SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
}
if (window->flags & SDL_WINDOW_POPUP_MENU && bActivate) {
if (window->parent == SDL_GetKeyboardFocus()) {
@ -1483,6 +1493,17 @@ int WIN_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperati
return 0;
}
void WIN_ShowWindowSystemMenu(SDL_Window *window, int x, int y)
{
const SDL_WindowData *data = window->driverdata;
POINT pt;
pt.x = x;
pt.y = y;
ClientToScreen(data->hwnd, &pt);
SendMessage(data->hwnd, WM_POPUPSYSTEMMENU, 0, MAKELPARAM(pt.x, pt.y));
}
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
void WIN_UpdateDarkModeForHWND(HWND hwnd)

View File

@ -108,6 +108,7 @@ extern void WIN_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept);
extern int WIN_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation);
extern void WIN_UpdateDarkModeForHWND(HWND hwnd);
extern int WIN_SetWindowPositionInternal(SDL_Window *window, UINT flags);
extern void WIN_ShowWindowSystemMenu(SDL_Window *window, int x, int y);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus