src/video/windows/SDL_windowsevents.c


Log

Author Commit Date CI Message
Pierre Wendling d0bbfdbf 2022-12-01T16:07:03 Clang-Tidy fixes (#6725) (cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
Sylvain Becker fb0ce375 2022-11-27T17:38:43 Cleanup add brace (#6545) * Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Steven Noonan 053b5f85 2022-08-25T20:18:03 SDL_windowsevents: minimize white screen flash on window creation Clear the window to black on the initial window draw, to avoid a really obnoxious white flash. This doesn't always eliminate it, but it definitely minimizes it.
Sam Lantinga 61b5360e 2022-10-10T08:27:42 Only check to see if the ICC profile changes when the display changes or we gain focus Fixes https://github.com/libsdl-org/SDL/issues/6366
past-due 301912a5 2022-09-18T21:25:55 Fix: Use WIN_ClientPointToSDL for converting additional mouse coordinates
Sam Lantinga 92b3c53c 2022-08-22T16:25:25 Added a hint SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE to control whether to use system mouse acceleration on raw relative motion. This is currently only implemented on Windows, and "Enhanced pointer precision" mode is not quite correct.
Sam Lantinga ffab1396 2022-08-19T17:28:31 Fixed minimized window detection when handling WM_WINDOWPOSCHANGED When minimizing a window, we get this sequence of events: WM_WINDOWPOSCHANGING WM_GETMINMAXINFO WM_NCCALCSIZE WM_WINDOWPOSCHANGED - IsIconic() is true WM_MOVE WM_SIZE - SDL sees minimized state here When restoring a window, we get this sequence of events: WM_WINDOWPOSCHANGING WM_GETMINMAXINFO WM_NCCALCSIZE WM_NCPAINT WM_ERASEBKGND WM_WINDOWPOSCHANGED - IsIconic() is false WM_MOVE WM_SIZE - SDL sees restored state here On Windows 10 a minimized window has a non-empty client rect, so we were delivering a minimized size before SDL knows that the window is minimized, and then ignoring the restored size when handling the restore message. The fix is to use IsIconic() which returns the correct window state when WM_WINDOWPOSCHANGED is actually delivered.
Sam Lantinga be0cf257 2022-08-12T18:13:42 Only force the resize event in the DPI changed case OpenGL windows don't actually get the WM_WINDOWPOSCHANGED event in the SetWindowPos() call in WIN_SetWindowFullscreen(), so setting the window size to zero never gets reset and we're stuck with a zero sized window. Instead, just force the resize event in WM_DPICHANGED handling, where we know we need it. If we end up needing to force it in WIN_SetWindowFullscreen(), just set a flag in the window data and respond to that in WM_WINDOWPOSCHANGED, but that's a fairly risky behavior change as suddenly all applications would start getting SDL_WINDOWEVENT_SIZE_CHANGED when going fullscreen, and they may respond to that in expensive and potentially disruptive ways. For later we'll probably create a DPI changed event and respond to that in the renderer instead of this window size changed hack. This fixes https://github.com/libsdl-org/SDL/issues/6033 @ericwa
Sam Lantinga a1e34b5e 2022-08-11T08:52:51 Don't send a resize event when the window is resized to the dock icon Partially addresses https://github.com/libsdl-org/SDL/issues/6033
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
Cameron Gutman 8b438f7b 2022-07-31T15:34:03 keyboard: Only send SDL_KEYMAPCHANGED when the keymap actually changes
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.
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
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.
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 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
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
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.
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.
Zach Reedy 363c3678 2022-03-10T17:12:33 Fixed: Incorrect assumption that mouse button is released when window is allocated
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
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 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 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
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 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
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 dd95c9c8 2021-10-06T09:09:39 Moved focus click check into WIN_UpdateFocus() so we have the correct state when setting keyboard focus Fixes https://github.com/libsdl-org/SDL/issues/4817
DomGries 0d541e5a 2021-10-06T00:36:27 Revert "Fixed relative mode mouse events stopping if you click on the title bar" This has been better fixed by b28ed02 or another related relative mouse mode change of @slouken in SDL 2.0.17 and as such can be reverted to reduce unneeded processing in WM_MOUSEMOVE
Sam Lantinga c542de92 2021-10-05T14:08:36 React to WM_NCACTIVATE instead of WM_SETFOCUS or WM_ACTIVATE for focus changes See https://github.com/libsdl-org/SDL/pull/4293 and https://github.com/libsdl-org/SDL/issues/4450 for details
Sam Lantinga 632aca29 2021-10-01T16:17:38 Window input focus is based on WM_SETFOCUS and WM_KILLFOCUS as WM_ACTIVATE doesn't necessarily imply focus. Hopefully resolves https://github.com/libsdl-org/SDL/issues/4450 and https://github.com/libsdl-org/SDL/pull/4293
Sam Lantinga 477fcf52 2021-09-24T10:49:46 Fixed whitespace
Sam Lantinga db68af80 2021-09-24T10:49:44 Reduce the likelyhood that the mouse will hover over the taskbar or toast notification while in relative mode, which causes a mouse leave event. This will still happen occasionally as the mouse is whipped around, if there is a window overlapping the game window, but it should happen less often now. This could even happen with the original code that warped the mouse every frame, so this should be a good compromise where we don't warp the mouse continously and we still keep the mouse in the safe area of the game window. Note that notifications can be any size, so the safe area may need to be adjusted or even dynamically defined via a hint.
Sam Lantinga 287571fb 2021-09-22T17:40:57 Limit effect of in_title_click and focus_click_pending to only blocking cursor warping; without this all relative mouse motion was getting ignored when a window was activated via a mouse button
Sam Lantinga 5d455cab 2021-09-21T18:15:11 Don't process raw input when the window is being dragged or clicked on.
Sam Lantinga 0fd54f91 2021-09-21T18:15:11 Fixed using a tablet with raw input relative motion Tested with a Wacom Cintiq Pro 16"
Sam Lantinga 8fee82d1 2021-09-21T18:15:09 Improve relative motion handling over RDP CR and research: @danielj
Ozkan Sezer ccb06296 2021-08-19T03:15:02 SDL_windowsevents.c: fix build against older SDKs.
Sam Lantinga 91a55a02 2021-08-13T23:59:39 Relative mouse motion is delivered to the window with keyboard focus This was the original intent (note SDL_UpdateWindowGrab() in SDL_OnWindowFocusGained() and SDL_OnWindowFocusLost()) and fixes a bug where relative motion unexpectedly stops if the task bar is covering the bottom of the game window and the mouse happens to move over it while relative mode is enabled. Another alternative would be to confine the mouse when relative mode is enabled, but that generates mouse motion which would need to be ignored, and it's possible for the user moving the mouse to combine with the mouse moving into the confined area so you can't easily tell whether to ignore the mouse motion. See https://github.com/libsdl-org/SDL/issues/4165 for a case where this is problematic.
Sam Lantinga 4d9efcb5 2021-08-13T11:52:25 Fixed flag test for boolean correctness
Sam Lantinga b28ed028 2021-08-13T11:39:41 Don't warp the mouse for relative mode when the window doesn't have focus
Sam Lantinga cb1e20b0 2021-08-10T17:50:17 Added KMOD_SCROLL to track the scroll lock state Fixes https://github.com/libsdl-org/SDL/issues/4566
hgs3 cb0fd05e 2021-08-07T22:41:54 Adding a clarifying comment in case a programmer unfamiliar with UTF-16 and UTF-32's relationship chances upon the code.
Henry G. Stratmann III 34701129 2021-08-07T20:51:49 Optimizing the implementation.
Henry G. Stratmann III 712e0d1f 2021-08-07T16:23:15 Fixing WM_CHAR event handling for Unicode characters outside the Basic Multilingual Plane.
Sam Lantinga 41e1a236 2021-07-27T16:50:06 Correct the maximized size and position for borderless resizable windows This fixes bug https://github.com/libsdl-org/SDL/issues/4043
Sam Lantinga 3b85e3fd 2021-07-24T15:47:11 Fixed internal Windows key state when using Windows+Space or Windows+G shortcuts This fixes bugs: https://github.com/libsdl-org/SDL/issues/4369 https://github.com/libsdl-org/SDL/issues/4500
scribam c2e8a791 2021-06-12T16:20:47 SDL_windowsevents: add support for multiple mice
Cameron Gutman 85b51e6c 2021-06-05T11:46:47 Fall back to polling normally if not operating the win32 message loop In this condition, we cannot safely wait/wake on events.
Francesco Abbate 0dd7024d 2021-03-12T21:58:20 Modifies WaitEvent and WaitEventTimeout to actually wait instead of polling When possible use native os functions to make a blocking call waiting for an incoming event. Previous behavior was to continuously poll the event queue with a small delay between each poll. The blocking call uses a new optional video driver event, WaitEventTimeout, if available. It is called only if an window already shown is available. If present the window is designated using the variable wakeup_window to receive a wakeup event if needed. The WaitEventTimeout function accept a timeout parameter. If positive the call will wait for an event or return if the timeout expired without any event. If the timeout is zero it will implement a polling behavior. If the timeout is negative the function will block indefinetely waiting for an event. To let the main thread sees events sent form a different thread a "wake-up" signal is sent to the main thread if the main thread is in a blocking state. The wake-up event is sent to the designated wakeup_window if present. The wake-up event is sent only if the PushEvent call is coming from a different thread. Before sending the wake-up event the ID of the thread making the blocking call is saved using the variable blocking_thread_id and it is compared to the current thread's id to decide if the wake-up event should be sent. Two new optional video device methods are introduced: WaitEventTimeout SendWakeupEvent in addition the mutex wakeup_lock which is defined and initialized but only for the drivers supporting the methods above. If the methods are not present the system behaves as previously performing a periodic polling of the events queue. The blocking call is disabled if a joystick or sensor is detected and falls back to previous behavior.
Sam Lantinga 157c3f80 2021-05-21T09:45:08 [SDL] Minimize number of system calls when handling WM_INPUT raw input messages. Details: Currently doing 4 system calls per WM_INPUT message, which can cause the thread handling the message loop to be swapped out several times: * GetProp - to get window data from the window handle * GetRawInputData - to retrieve the raw input data * 2 calls to GetMessageExtraInfo - to ignore synthetic mouse events generated for touchscreens In this change: * Replaced GetProp by iterating the list of windows maintained by SDL (with a fallback to GetProp). Note that this will affect all messages and not just WM_INPUT * only calling GetMessageExtraInfo if a touchscreen has been detected Fix for https://jira.valve.org/browse/CSGO-4855 @saml
Dean Herbert 89b62093 2021-04-01T14:17:53 Fix race condition that can lead to ENTER/LEAVE window events never firing On windows, when toggling the state of RelativeMode rapidly, there is a high chance that SDL_WINDOWEVENT_ENTER / SDL_WINDOWEVENT_LEAVE events will stop firing indefinitely. This aims to resolve that shortcoming by ensuring mouse focus state is correctly updated via WM_MOUSELEAVE events arriving via the windows event hook.
Cameron Gutman a78bce9e 2021-01-28T20:02:01 Properly handle keys already down when the hook is installed For keys that are already down when we install the keyboard hook, we need to allow the WM_KEYUP/WM_SYSKEYUP message to be processed normally. This ensures that other applications see the key up, which prevents the key from being stuck down from the perspective of other apps when our grab is released.
Cameron Gutman 2793c9cf 2021-01-25T18:40:26 Fix grabbing Alt+Tab and Alt+Esc on Windows 7
Brandon DeRosier 141f4416 2021-01-24T03:55:04 fix build failure due to -Werror=declaration-after-statement (bug #5500)
Cameron Gutman 8c921d82 2021-01-22T19:40:26 Implement keyboard grab support for Windows This is implemented via a low-level keyboard hook. Unfortunately, this is rather invasive, but it's how Microsoft recommends that it be done [0]. We want to do as little as possible in the hook, so we only intercept a few crucial modifier keys there, while leaving other keys to the normal event processing flow. We will only install this hook if SDL_HINT_GRAB_KEYBOARD=1, which is not the default. This will reduce any compatibility concerns to just the SDL applications that explicitly ask for this behavior. We also remove the hook when the grab is terminated to ensure that we're not unnecessarily staying involved in key event processing when it's not required anymore. [0]: https://docs.microsoft.com/en-us/windows/win32/dxtecharts/disabling-shortcut-keys-in-games
Ozkan Sezer 01a2f276 2021-01-04T01:23:50 consistently use TEXT() macro with LoadLibrary() and GetModuleHandle() cf. bug #5435.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Sam Lantinga b9cbea35 2020-10-13T21:08:20 video: Refresh Windows display list on WM_DISPLAYCHANGE - Displays may have been added, removed or changed and all cached monitor handles are invalidated as a result. - Display events are handled in three steps: 1. Mark all currently know displays as invalid 2. Enumerate all displays, adding new ones and marking known displays as valid 3. Remove all displays still invalid after enumeration - Display connect/disconnect events are sent when displays are added or removed after initial setup
Cameron Gutman 771732ed 2020-08-27T17:54:52 windows: Fix numpad arrow key scancodes with numlock off We should only perform the VK_LEFT, VK_UP, etc. mapping if none of the other special mappings apply. This allows the scancode normalization for the number pad to take place as intended.
Cameron Gutman 72379ba5 2020-08-25T21:22:00 windows: Fix handling of swapped mouse buttons GetAsyncKeyState() and GetRawInputData() report the state of the physical buttons without applying the user's primary/secondary mouse button swap preference. Swap the buttons returned from these functions, so we expose a consistent view of the buttons to SDL callers. This new behavior also matches the behavior of macOS and X11 backends. See the Remarks section of the GetAsyncKeyState() function on MSDN.
Sam Lantinga 44f50c64 2020-06-09T21:47:41 Fixed bug 5171 - PollEvent impacts performance in 2.0.12 On some systems, GetClipCursor() impacts performance when called frequently, so only call it every once in a while to make sure we haven't lost our capture.
Sam Lantinga 488b94cb 2020-04-07T09:18:19 Don't interpret raw input messages with no mouse position This happens occasionally on touch devices when raw input is enabled
Sam Lantinga 0721931f 2020-04-06T19:21:56 Avoid sending regular mouse messages for touch input
Sam Lantinga 6fe6946a 2020-02-11T21:19:05 Fixed relative mode mouse events stopping if you click on the title bar
Sam Lantinga f867cebb 2020-02-11T08:36:13 Fixed bug 4709 - incorrect (not) handling of windows on-screen cursor keys Alex Denisov When using Win10 on-screen keyboard (tooltip.exe), the left and right cursor keys in it do not produce SDLK_LEFT and SDLK_RIGHT events. Windows messages generated by the on-screen keyboard, for some reason, have their scancodes set to zeroes. Here is the log from Spy++: WM_KEYDOWN nVirtKey:VK_LEFT cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:0 fUp:0 WM_KEYUP nVirtKey:VK_LEFT cRepeat:1 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:1 fUp:1 Regular physical keyboard produces VK_LEFT (ScanCode:4B) and VK_RIGHT (ScanCode:4D) which are interpreted correctly. With on-screen keyboard, the switch statement in VKeytoScancode() does not check for VK_LEFT and VK_RIGHT, returning SDL_SCANCODE_UNKNOWN, which in turn does not get mapped to anything (because the scan codes are zeroes).
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sylvain Becker 758badff 2019-10-23T08:58:52 Fixed bug 4841 - Misplaced parenthesis WIN_WindowProc / WM_ACTIVATE / ClipCursor (Thanks!)
Ozkan Sezer 8a394209 2019-09-05T20:47:20 SDL_windowsevents.c: remove isVistaOrNewer (not used since 8cb1dc50bb28)