src/video/windows


Log

Author Commit Date CI Message
Sam Lantinga 98bac00d 2022-08-08T11:26:52 Add `SDL_GetPointDisplayIndex` and `SDL_GetRectDisplayIndex` and re-implement `SDL_GetWindowDisplayIndex` in terms of `SDL_GetRectDisplayIndex` - This allows looking up the display index for an arbitrary location rather than requiring an active window to do so. - This change also reimplements the fallback display lookup that found the display with center closest to the window's center to instead find the display rect edge closest to the window center (this was done in the almost identical display lookup used in SDL_windowsmodes.c, which now uses `SDL_GetPointDisplayIndex`). In practice this should almost never be hit as it requires the window's center to not be enclosed by any display rect.
Shootfast 60d1944e 2022-07-06T20:12:30 SDL_video: Added SDL_GL_FLOATBUFFERS to allow Cocoa GL contexts to use EDR
Sam Lantinga 602b7dd0 2022-08-01T17:47:26 Made the window ICMProfile filename per-window The event no longer spams each time a window gets focus if there are windows on monitors with different color profiles. This also has the side effect that you no longer get a color profile event at window creation, which is consistent with other events that communicate state changes.
Sam Lantinga cb107bef 2022-08-01T14:23:50 Fixed crash if all displays have been disconnected Fixes https://github.com/libsdl-org/SDL/issues/5867
Sam Lantinga 15bcf58d 2022-08-01T08:14:40 Fixed memory leak in the Windows driver
Cameron Gutman 8b438f7b 2022-07-31T15:34:03 keyboard: Only send SDL_KEYMAPCHANGED when the keymap actually changes
Ryan C. Gordon 20a76b0e 2022-07-25T23:06:58 video: removed unused devindex argument from bootstrap's create method.
Sam Lantinga 4d8bb89c 2022-07-24T11:50:14 Fixed mouse clip rect bounds on Windows Fixes https://github.com/libsdl-org/SDL/issues/5946
Sam Lantinga adf3ce7c 2022-07-05T21:42:24 Don't drop mouse focus on WM_MOUSELEAVE if the mouse is in relative mode; mouse-level is not meaningful for that case. Do drop mouse focus when keyboard focus is lost if the mouse is in relative mode.
Sam Lantinga 0253a450 2022-07-05T21:42:20 Fix format specifiers for WPARAM/LPARAM values, they are UINT_PTR.
rohlem b085c182 2022-07-04T16:38:05 make SDL_SetTextInputRect take a pointer to const The documentation doesn't state that the argument is ever modified, and no implementation does so currently. This is a non-breaking change to guarantee as much to callers.
chalonverse 85bbf8ee 2022-07-03T12:19:33 Fixed coment after #endif
chalonverse f317d619 2022-07-01T13:59:14 Xbox GDKX support (#5869) * Xbox GDK support (14 squashed commits) * Added basic keyboard testing * Update readme * Code review fixes * Fixed issue where controller add/removal wasn't working (since the device notification events don't work on Xbox, have to use the joystick thread to poll XInput)
chalonverse 3b191580 2022-06-27T17:19:39 Windows GDK Support (#5830) * Added GDK * Simplfied checks in SDL_config_wingdk.h * Added testgdk sample * Added GDK readme * Fixed error in merge of SDL_windows.h * Additional GDK fixes * OpenWatcom should not export _SDL_GDKGetTaskQueue * Formatting fixes * Moved initialization code into SDL_GDKRunApp
unknown 51c6488f 2022-06-26T18:47:34 Add support for SDL_render_d3d12.c to compile in C++ mode
Pieter-Jan Briers 9914e87f 2022-06-20T12:53:10 Also send DPI change when expected resize.
Pieter-Jan Briers af733c7a 2022-06-20T02:26:40 Fix DPI-raised SDL_WINDOWEVENT_SIZE_CHANGED with event callback. Move the sending of this event down so stuff like calling SDL_GL_GetDrawableSize() from a callback reports the new size instead of the old one.
Ozkan Sezer a8d41b3b 2022-06-18T21:51:32 check for shellscalingapi.h presence instead of WINVER >= 0x0603
Sam Lantinga a5949d7b 2022-06-15T23:00:28 Fixed crash on Windows These functions really are WINAPI
Ozkan Sezer 714502d3 2022-06-13T22:15:56 minor windows warning fixes.
Ryan C. Gordon 9a036767 2022-06-12T15:28:49 windows: Get better name for the physical display, for Vista and later. Fixes #5321.
Eric Wasylishen ab81a559 2022-06-07T02:01:27 Windows DPI scaling/highdpi support Adds hint "SDL_WINDOWS_DPI_SCALING" which can be set to "1" to change the SDL coordinate system units to be DPI-scaled points, rather than pixels everywhere. This means windows will be appropriately sized, even when created on high-DPI displays with scaling. e.g. requesting a 640x480 window from SDL, on a display with 125% scaling in Windows display settings, will create a window with an 800x600 client area (in pixels). Setting this to "1" implicitly requests process DPI awareness (setting SDL_WINDOWS_DPI_AWARENESS is unnecessary), and forces SDL_WINDOW_ALLOW_HIGHDPI on all windows.
Eric Wasylishen 448e05e3 2022-06-05T12:51:57 add DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED define
Eric Wasylishen 1b797957 2022-06-05T12:36:58 SDL_windowsvideo.c: add HIGHDPI_DEBUG ifdef, print DPI awareness at startup if defined document some additional quirks
Eric Wasylishen 1488c408 2022-06-05T12:01:32 WM_DPICHANGED: remove some dead code, add comment
Eric Wasylishen 60ef11b3 2022-06-03T00:21:36 Fix Watcom compile errors
Eric Wasylishen d3b970d4 2022-05-29T21:56:37 HighDPI: remove SWP_NOSIZE in WIN_SetWindowPosition If the move results in a DPI change, we need to allow the window to resize (e.g. AdjustWindowRectExForDpi frame sizes are different). - WM_DPICHANGED: Don't assume WM_GETDPISCALEDSIZE is always called for PMv2 awareness - it's only called during interactive dragging. - WIN_AdjustWindowRectWithStyle: always calculate final window size including frame based on the destination rect, not based on the current window DPI. - Update wmmsg.h to include WM_GETDPISCALEDSIZE (for WMMSG_DEBUG) - WIN_AdjustWindowRectWithStyle: add optional logging - WM_GETMINMAXINFO: add optional HIGHDPI_DEBUG logging - WM_DPICHANGED: fix potentially clobbering data->expected_resize Together these changes fix the following scenario: - launch testwm2 with the SDL_WINDOWS_DPI_AWARENESS=permonitorv2 environment variable - Windows 10 21H2 (OS Build 19044.1706) - Left (primary) monitor: 3840x2160, 125% scaling - Right (secondary) monitor: 2560x1440, 100% scaling - Alt+Enter, Alt+Enter (to enter + leave desktop fullscreen), Alt+Right (to move window to right monitor). Ensure the window client area stays 640x480. Drag the window back to the 125% monitor, ensure client area stays 640x480.
Eric Wasylishen 51ebefee 2022-02-28T00:43:43 Support PMv2 DPI awareness, add SDL_HINT_WINDOWS_DPI_AWARENESS The hint allows setting a specific DPI awareness ("unaware", "system", "permonitor", "permonitorv2"). This is the first part of High-DPI support on Windows ( https://github.com/libsdl-org/SDL/issues/2119 ). It doesn't implement a virtualized SDL coordinate system, which will be addressed in a later commit. (This hint could be useful for SDL apps that want 1 SDL unit = 1 pixel, though.) Detecting and behaving correctly under per-monitor V2 (calling AdjustWindowRectExForDpi where needed) should fix the following issues: https://github.com/libsdl-org/SDL/issues/3286 https://github.com/libsdl-org/SDL/issues/4712
Guldoman f78f7752 2022-05-28T03:53:43 ime: windows: allocate space for null terminator
Simon McVittie 412ceb84 2022-05-24T16:27:54 video: Only check major version in SDL_GetWindowWMInfo Since #5602, SDL is intended to have the same ABI across the whole major-version 2 cycle, so we should not check that the minor version matches the one that was used to compile an application. There are two checks that could make sense here. The first check is that the major version matches the expected major version. This is usually unnecessary and is not usually done (if we're calling into the wrong library we'll likely crash anyway), but since we have the information, we might as well continue to use it. The second check is whether the version provided by the caller is equal to or greater than a threshold version at which additional fields were added to the struct. If it is, we should populate those fields; if it is not, then we cannot. This is only useful on platforms where additional fields have genuinely been added during the lifetime of SDL 2, like Windows and DirectFB (but not X11). This commit changes the first check to be consistent about only looking at the minor version, while leaving the second check using SDL_VERSIONNUM (which will be removed or widened in SDL 3, but it's fine for now). Resolves: https://github.com/libsdl-org/SDL/issues/5711 Fixes: cd7c2f1 "Switch versioning scheme to be the same as GLib and Flatpak" Signed-off-by: Simon McVittie <smcv@collabora.com>
Cameron Cawley b798e49c 2022-05-19T21:44:38 Fix build warning with MSVC
Cameron Cawley 9dfa000b 2022-05-18T20:20:03 Initial support for building for Windows with OpenWatcom
Cameron Cawley c8eea020 2022-05-18T21:14:20 Fix C89 build errors in Windows builds
Cameron Cawley 0cca71a8 2022-05-18T22:12:05 Use SDLCALL for callbacks in public APIs
Sam Lantinga 9919d1a7 2022-04-18T11:51:09 Remove HWND_TOPMOST for fullscreen windows Fixes https://github.com/libsdl-org/SDL/issues/5509
Sam Lantinga 268c2fa8 2022-04-05T18:42:17 Don't resize fullscreen windows when hiding or minimizing them (thanks @madewokherd!) This has the benefit of window previews (mousing over the icon) having the correct size and contents. Fixes https://github.com/libsdl-org/SDL/issues/5320
Esme Povirk def27267 2022-02-05T12:32:06 Ignore focus change messages that contradict GetForegroundWindow. On Wine, when a window is programmatically minimized in response to losing focus, we receive a WM_ACTIVATE for the deactivation, but GetForegroundWindow still indicates that our window is focused. This causes an incorrect SDL_WINDOWEVENT_FOCUS_GAINED. This is probably a Wine bug, but it may take a while to fix and then for the fix to make its way to users.
Sam Lantinga 6c962177 2022-03-18T10:07:59 Added the hint SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, controlling whether the mouse should be constrained to the center of the window or the whole window in relative mode. For further info about the pros and cons, check out the discussion in https://github.com/libsdl-org/SDL/issues/5271
Sam Lantinga 3167ba34 2022-03-17T17:58:35 Fixed freeing the Windows blank cursor
Sam Lantinga 0387bf82 2022-03-17T17:55:28 Fixed memory leak in WIN_CreateBlankCursor()
Sam Lantinga d4062785 2022-03-17T17:01:36 Try not forcing activation when grabbing the mouse in fullscreen windows
Sam Lantinga 4e784fce 2022-03-17T16:57:33 When updating grab state, only activate windows that are grabbed, fullscreen, and shown. Fixes https://github.com/libsdl-org/SDL/issues/5371
Sam Lantinga e5f45455 2022-03-17T14:44:34 Added a hint to mark a foreign window as usable with OpenGL Fixes https://github.com/libsdl-org/SDL/issues/2942
Sam Lantinga 4e49b78a 2022-03-17T14:44:17 Fixed compile warning and comment typo
Esme Povirk 829e15a4 2022-02-05T14:38:39 Ignore unknown WM_SIZE types. According to MSDN, we can also get SIZE_MAXHIDE and SIZE_MAXSHOW, based on state changes to other windows. It's not clear under what circumstances this will happen (I saw some docs indicating it may require multiple application windows), but it doesn't seem right to treat them as RESTORED.
Ozkan Sezer d1e4367f 2022-03-15T21:41:02 SDL_windowskeyboard.c: fix build with SDL_DISABLE_WINDOWS_IME defined. Fixes https://github.com/libsdl-org/SDL/issues/5408
Zach Reedy 363c3678 2022-03-10T17:12:33 Fixed: Incorrect assumption that mouse button is released when window is allocated
Ozkan Sezer 072db7b0 2022-03-12T01:56:40 SDL_windowskeyboard.c (IME_IsTextInputShown): remove unused local vars.
Zach Reedy d14a1263 2022-03-11T17:45:17 IME Composition Truncation + SDL_IsTextInputShown + SDL_ClearComposition (#5398) * Fixes for IME Composition Truncation + Addition of SDL_ClearComposition, SDL_IsTextInputShown * Fixed: Documentation and code style issues raised during code review.
Jo Bates 01d38e7a 2022-03-09T14:03:52 Make Win32 fullscreen and borderless windows minimizable
pionere 97269e14 2022-01-18T17:51:17 adjustments to ime_candidates - allocate ime_candidates on demand - allow write to the whole allocated memory of ime_candidates - ensure ime_candcount is set to zero in case the candidates can not be queried for any reason
pionere 6f404d0f 2022-01-18T17:49:33 cleanup IME_GetCandidateList / UILess_GetCandidateList - move IME_ShowCandidateList, ImmGetContext and ImmReleaseContext to this function - set ime_candpgsize to MAX_CANDLIST if dwPageSize is zero - comment out deselection of ime_candsel in case of korean language for the moment (LANG_CHT does not work anyway)
pionere 32c7d5d3 2022-01-18T17:44:51 cleanup IME_UpdateInputLocale - do not store the HKL in a static variable - always set the ime_candvertical value in case the HKL is changed
pionere 25aa7244 2022-01-18T17:43:31 cleanup IME_GetId - use assert instead of a check (it is a static function with constant parameter) - assume it is called with 0 first (simplifies the logic) - reuse dwLang value instead of a new 'call' to LANG()
pionere 3c85cef4 2022-01-17T09:58:16 cleanup SDL_RegisterApp - fix memory leak when RegisterClassEx fails - set style according to the documentation - eliminate duplicated SDL_Instance setter
pionere 014e2bbd 2022-01-12T16:40:52 use SDL_COMPILE_TIME_ASSERT instead of SDL_STATIC_ASSERT
pionere 942b01a5 2022-01-09T15:08:21 do not use RWOps in WIN_SetWindowIcon
ulatekh 57bc9040 2022-01-07T08:54:08 Add hint to optionally forcibly raise the window under MS Windows.
ulatekh d7873e65 2022-01-04T15:47:29 Disable tablet flicks under MS Windows.
ulatekh 53df0e66 2022-01-21T17:15:18 Fix the erroneous generation of mouse-down events from touch-move events. The issue is that MS Windows synthesizes a mouse-move event in response to touch-move events, and those mouse-move events are NOT labeled as coming from a touch (e.g. GetMouseMessageSource() will not return SDL_MOUSE_EVENT_SOURCE_TOUCH for those synthesized mouse-move events). In addition, there seems to be no way to prevent this from happening; https://gist.github.com/vbfox/1339671 claims to demonstrate a technique to prevent it, but in my experience, it doesn't work. Because of this, the "fallthrough" case can't test that the synthesized mouse-move came from a touch-move, and starts erroneously pressing down the mouse-button, leading to massive confusion in the client application.
Sam Lantinga 1085c317 2022-01-07T16:43:53 Use the requested cursor size instead of the default cursor size CopyImage() will scale based on the system accessibility settings automatically. Fixes https://github.com/libsdl-org/SDL/issues/5198
Sam Lantinga 957c48b4 2022-01-07T10:58:04 Fixed detecting focus change to child dialogs Fixes https://github.com/libsdl-org/SDL/issues/5157
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Sam Lantinga 8f816998 2021-12-31T08:46:54 Only clear IME display options if SDL_HINT_IME_SHOW_UI is off (thanks opxdo!) Fixes https://github.com/libsdl-org/SDL/issues/5153
Sam Lantinga ca18bf11 2021-12-16T12:01:18 Don't compare raw mouse button state with windows message button state When mouse buttons are swapped, right mouse button down is the same value as raw mouse button up, and conceptually the two systems use different button masks, so never cache state between the two. Fixes https://github.com/libsdl-org/SDL/issues/5108
Hanseul Jun e7f84c20 2021-12-09T10:40:53 Fix a typo in comment.
Cameron Gutman 715d4812 2021-11-29T22:43:25 windows: Fix GUI key state when grabbing the keyboard When our keyboard grab hook is installed, GetKeyState() will return 0 for the GUI keys even when they are pressed. This leads to spurious key up events when holding down the GUI keys and the inability to use any key combos involving those modifier keys.
Sam Lantinga 942973dd 2021-11-28T09:27:28 Use mouse ID 0 for raw mouse events We don't track state for each mouse individually, so we should just use the global mouse ID for all events. Fixes https://github.com/libsdl-org/SDL/issues/5026
Ozkan Sezer 8a6e48d4 2021-11-14T04:40:50 constified SDL_RegisterApp()
Misa 3bf7994f 2021-09-27T14:38:12 Add and use `SDL_FALLTHROUGH` for fallthroughs Case fallthrough warnings can be suppressed using the __fallthrough__ compiler attribute. Unfortunately, not all compilers have this attribute, or even have __has_attribute to check if they have the __fallthrough__ attribute. [[fallthrough]] is also available in C++17 and the next C2x, but not everyone uses C++17 or C2x. So define the SDL_FALLTHROUGH macro to deal with those problems - if we are using C++17 or C2x, it expands to [[fallthrough]]; else if the compiler has __has_attribute and has the __fallthrough__ attribute, then it expands to __attribute__((__fallthrough__)); else it expands to an empty statement, with a /* fallthrough */ comment (it's a do {} while (0) statement, because users of this macro need to use a semicolon, because [[fallthrough]] and __attribute__((__fallthrough__)) require a semicolon). Clang before Clang 10 and GCC before GCC 7 have problems with using __attribute__ as a sole statement and warn about a "declaration not declaring anything", so fall back to using the /* fallthrough */ comment if we are using those older compiler versions. Applications using SDL are also free to use this macro (because it is defined in begin_code.h). All existing /* fallthrough */ comments have been replaced with this macro. Some of them were unnecessary because they were the last case in a switch; using SDL_FALLTHROUGH in those cases would result in a compile error on compilers that support __fallthrough__, for having a __attribute__((__fallthrough__)) statement that didn't immediately precede a case label.
Sam Lantinga abc12a83 2021-11-11T15:58:44 Revert "Add and use `SDL_FALLTHROUGH` for fallthroughs" This reverts commit 66a08aa3914a98667f212e79b4f0b9453203d656. This causes problems with older compilers: https://github.com/libsdl-org/SDL/pull/4791#issuecomment-966630997
Misa 66a08aa3 2021-09-27T14:38:12 Add and use `SDL_FALLTHROUGH` for fallthroughs Case fallthrough warnings can be suppressed using the __fallthrough__ compiler attribute. Unfortunately, not all compilers have this attribute, or even have __has_attribute to check if they have the __fallthrough__ attribute. [[fallthrough]] is also available in C++17 and the next C2x, but not everyone uses C++17 or C2x. So define the SDL_FALLTHROUGH macro to deal with those problems - if we are using C++17 or C2x, it expands to [[fallthrough]]; else if the compiler has __has_attribute and has the __fallthrough__ attribute, then it expands to __attribute__((__fallthrough__)); else it expands to an empty statement, with a /* fallthrough */ comment (it's a do {} while (0) statement, because users of this macro need to use a semicolon, because [[fallthrough]] and __attribute__((__fallthrough__)) require a semicolon). Applications using SDL are also free to use this macro (because it is defined in begin_code.h). All existing /* fallthrough */ comments have been replaced with this macro. Some of them were unnecessary because they were the last case in a switch; using SDL_FALLTHROUGH in those cases would result in a compile error on compilers that support __fallthrough__, for having a __attribute__((__fallthrough__)) statement that didn't immediately precede a case label.
Sam Lantinga fed85778 2021-11-10T08:47:39 Update the orientation and display modes when the display settings change on Windows Fixes https://github.com/libsdl-org/SDL/issues/1061
Sam Lantinga c0f1109b 2021-11-10T06:03:01 Implemented querying the orientation of displays on Windows
Susko3 1fc25bd8 2021-11-08T22:04:34 Properly position the IME window(s) on windows
Yufei Huang 881f747d 2021-11-09T13:35:18 Always destroy icon
Yufei Huang 7fea557b 2021-11-09T12:03:09 SDL_windowsmouse.c: Remove LR_COPYDELETEORG flag
Sam Lantinga 67c42cb4 2021-11-08T22:16:01 Fixed Windows build
Sam Lantinga fd79607e 2021-11-08T21:34:48 Added SDL_GetWindowMouseRect() Also guarantee that we won't get mouse movement outside the confining area, even if the OS implementation allows it (e.g. macOS)
Sam Lantinga 4db546b0 2021-11-08T20:35:12 Implemented SDL_SetWindowMouseRect() on macOS
Sam Lantinga 2d23d66a 2021-11-08T16:33:50 Fixed SetWindowMouseRect return value on Windows
Sam Lantinga 7d21322d 2021-11-08T16:29:19 Implemented SDL_SetWindowMouseRect() on Windows
Yufei Huang 301819cd 2021-11-08T20:34:20 SDL_windowsmouse.c: Fix WIN_CreateCursor does not scale with system cursor size preference
Sam Lantinga 2248a549 2021-11-05T22:48:46 Update the focus in case we changed focus to a child window and then away from the application In this case we'll get WM_KILLFOCUS when the child window is focused, but we'll retain focus on the top level window, but when we Alt-Tab away, we won't get another WM_KILLFOCUS or WM_NCACTIVATE, we get WM_ACTIVATE instead, so we need to check for focus updates in response to that as well.
Cacodemon345 19dee1cd 2021-10-22T06:37:20 Add SDL_GetWindowICCProfile(). (#4314) * Add SDL_GetWindowICCProfile * Add new SDL display events * Implement ICC profile change event for macOS * Implement ICC profile notification for Windows * Fix SDL_GetWindowICCProfile() for X11 * Fix compile errors
Sam Lantinga bfd2f899 2021-10-19T17:29:23 Fixed grab handling when focus changes between windows in the same application
Sam Lantinga 7fb43643 2021-10-17T13:56:31 Don't process WM_INPUT when handling relative mode by warping the mouse cursor
DomGries 06824b18 2021-10-17T19:50:39 Cleanup windows events after recent changes Improves clarity without any functional changes
Sam Lantinga a70a94e0 2021-10-15T18:11:19 Don't send a mouse leave event if the mouse is outside the window when gaining focus and in relative mode.
Ozkan Sezer c583055a 2021-10-15T10:11:24 SDL_windowsevents.c (WIN_WindowProc): remove SAFE_AREA_X and SAFE_AREA_Y Not used since commit https://github.com/libsdl-org/SDL/commit/a1fabca162091b50d6f7dd71879d028319e09d80
Sam Lantinga a1fabca1 2021-10-14T16:52:21 Removed mouse warping for local mice and improved warp handling for mouse over RDP
Sam Lantinga 5e89b3c8 2021-10-14T11:46:07 Don't need to use raw input to track the mouse during mouse capture (thanks Brick!)
Brick 0b6a8211 2021-10-12T14:08:20 Messages posted on the same tick are not new
Rémy Tassoux 0789610c 2021-10-14T00:52:05 Add SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN
Ozkan Sezer 6149e601 2021-10-13T00:03:56 remove IsWin10FCUorNewer() -- not used since commit 40ed9f75c9e1ed
Ozkan Sezer 311671a0 2021-10-12T23:50:02 fixed build after commit 6e356e20ad
Rémy Tassoux 6e356e20 2021-10-12T18:35:52 Fix mouse focus being set to null when a captured mouse cursor leaves the window.
Sam Lantinga 40ed9f75 2021-10-08T10:05:27 Workaround for Windows occasionally ignoring SetCursorPos() calls Also, since we're flushing mouse motion before and including the warp, we don't need the isWin10FCUorNewer hack to simulate mouse warp motion. Fixes https://github.com/libsdl-org/SDL/issues/4339 and https://github.com/libsdl-org/SDL/issues/4165
Sam Lantinga 16aeb8d0 2021-10-07T15:04:06 Guarantee that we don't dispatch any mouse motion from before or including the last mouse warp
Sam Lantinga 649466f4 2021-10-07T13:28:44 Flush any pending mouse motion when warping the mouse cursor Fixes https://github.com/libsdl-org/SDL/issues/4165