Skip to content

Commit a886df9

Browse files
committed
Merge branch 'main' of github.com:libsdl-org/SDL
2 parents ec58846 + d9af41b commit a886df9

26 files changed

+1090
-510
lines changed

cmake/sdlchecks.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ endmacro()
826826
macro(CheckPTHREAD)
827827
cmake_push_check_state()
828828
if(SDL_PTHREADS)
829-
if(ANDROID)
829+
if(ANDROID OR SDL_PTHREADS_PRIVATE)
830830
# the android libc provides built-in support for pthreads, so no
831831
# additional linking or compile flags are necessary
832832
elseif(LINUX)

include/SDL3/SDL_filesystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo
444444
* Enumerate a directory tree, filtered by pattern, and return a list.
445445
*
446446
* Files are filtered out if they don't match the string in `pattern`, which
447-
* may contain wildcard characters '\*' (match everything) and '?' (match one
447+
* may contain wildcard characters `*` (match everything) and `?` (match one
448448
* character). If pattern is NULL, no filtering is done and all results are
449449
* returned. Subdirectories are permitted, and are specified with a path
450-
* separator of '/'. Wildcard characters '\*' and '?' never match a path
450+
* separator of `/`. Wildcard characters `*` and `?` never match a path
451451
* separator.
452452
*
453453
* `flags` may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching

include/SDL3/SDL_mouse.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -578,15 +578,16 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 *data,
578578
/**
579579
* Create a color cursor.
580580
*
581-
* If this function is passed a surface with alternate representations, the
582-
* surface will be interpreted as the content to be used for 100% display
583-
* scale, and the alternate representations will be used for high DPI
584-
* situations. For example, if the original surface is 32x32, then on a 2x
585-
* macOS display or 200% display scale on Windows, a 64x64 version of the
586-
* image will be used, if available. If a matching version of the image isn't
587-
* available, the closest larger size image will be downscaled to the
588-
* appropriate size and be used instead, if available. Otherwise, the closest
589-
* smaller image will be upscaled and be used instead.
581+
* If this function is passed a surface with alternate representations added
582+
* with SDL_AddSurfaceAlternateImage(), the surface will be interpreted as the
583+
* content to be used for 100% display scale, and the alternate
584+
* representations will be used for high DPI situations. For example, if the
585+
* original surface is 32x32, then on a 2x macOS display or 200% display scale
586+
* on Windows, a 64x64 version of the image will be used, if available. If a
587+
* matching version of the image isn't available, the closest larger size
588+
* image will be downscaled to the appropriate size and be used instead, if
589+
* available. Otherwise, the closest smaller image will be upscaled and be
590+
* used instead.
590591
*
591592
* \param surface an SDL_Surface structure representing the cursor image.
592593
* \param hot_x the x position of the cursor hot spot.
@@ -598,6 +599,7 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 *data,
598599
*
599600
* \since This function is available since SDL 3.2.0.
600601
*
602+
* \sa SDL_AddSurfaceAlternateImage
601603
* \sa SDL_CreateCursor
602604
* \sa SDL_CreateSystemCursor
603605
* \sa SDL_DestroyCursor

include/SDL3/SDL_video.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,15 +1680,16 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window);
16801680
/**
16811681
* Set the icon for a window.
16821682
*
1683-
* If this function is passed a surface with alternate representations, the
1684-
* surface will be interpreted as the content to be used for 100% display
1685-
* scale, and the alternate representations will be used for high DPI
1686-
* situations. For example, if the original surface is 32x32, then on a 2x
1687-
* macOS display or 200% display scale on Windows, a 64x64 version of the
1688-
* image will be used, if available. If a matching version of the image isn't
1689-
* available, the closest larger size image will be downscaled to the
1690-
* appropriate size and be used instead, if available. Otherwise, the closest
1691-
* smaller image will be upscaled and be used instead.
1683+
* If this function is passed a surface with alternate representations added
1684+
* using SDL_AddSurfaceAlternateImage(), the surface will be interpreted as
1685+
* the content to be used for 100% display scale, and the alternate
1686+
* representations will be used for high DPI situations. For example, if the
1687+
* original surface is 32x32, then on a 2x macOS display or 200% display scale
1688+
* on Windows, a 64x64 version of the image will be used, if available. If a
1689+
* matching version of the image isn't available, the closest larger size
1690+
* image will be downscaled to the appropriate size and be used instead, if
1691+
* available. Otherwise, the closest smaller image will be upscaled and be
1692+
* used instead.
16921693
*
16931694
* \param window the window to change.
16941695
* \param icon an SDL_Surface structure containing the icon for the window.
@@ -1698,6 +1699,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window);
16981699
* \threadsafety This function should only be called on the main thread.
16991700
*
17001701
* \since This function is available since SDL 3.2.0.
1702+
*
1703+
* \sa SDL_AddSurfaceAlternateImage
17011704
*/
17021705
extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
17031706

include/build_config/SDL_build_config.h.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333

3434
#cmakedefine SDL_PLATFORM_PRIVATE 1
3535

36+
#ifdef SDL_PLATFORM_PRIVATE
37+
#include "SDL_begin_config_private.h"
38+
#endif
39+
3640
#cmakedefine HAVE_GCC_ATOMICS 1
3741
#cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1
3842

@@ -369,6 +373,8 @@
369373
#cmakedefine SDL_TIME_N3DS 1
370374
#cmakedefine SDL_TIME_NGAGE 1
371375

376+
#cmakedefine SDL_TIME_PRIVATE 1
377+
372378
/* Enable various timer systems */
373379
#cmakedefine SDL_TIMER_HAIKU 1
374380
#cmakedefine SDL_TIMER_UNIX 1
@@ -473,6 +479,8 @@
473479
#cmakedefine SDL_GPU_VULKAN 1
474480
#cmakedefine SDL_GPU_METAL 1
475481

482+
#cmakedefine SDL_GPU_PRIVATE 1
483+
476484
/* Enable system power support */
477485
#cmakedefine SDL_POWER_ANDROID 1
478486
#cmakedefine SDL_POWER_LINUX 1
@@ -507,6 +515,8 @@
507515
/* Enable system storage support */
508516
#cmakedefine SDL_STORAGE_STEAM @SDL_STORAGE_STEAM@
509517

518+
#cmakedefine SDL_STORAGE_PRIVATE 1
519+
510520
/* Enable system FSops support */
511521
#cmakedefine SDL_FSOPS_POSIX 1
512522
#cmakedefine SDL_FSOPS_WINDOWS 1

src/camera/emscripten/SDL_camera_emscripten.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static SDL_CameraFrameResult EMSCRIPTENCAMERA_AcquireFrame(SDL_Camera *device, S
6161

6262
SDL3.camera.ctx2d.drawImage(SDL3.camera.video, 0, 0, w, h);
6363
const imgrgba = SDL3.camera.ctx2d.getImageData(0, 0, w, h).data;
64-
Module.HEAPU8.set(imgrgba, rgba);
64+
HEAPU8.set(imgrgba, rgba);
6565

6666
return 1;
6767
}, device->actual_spec.width, device->actual_spec.height, rgba);

src/core/gdk/SDL_gdk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ bool GDK_RegisterChangeNotifications(void)
105105
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppConstrainedChangeNotification handler");
106106
SDL_VideoDevice *_this = SDL_GetVideoDevice();
107107
if (_this) {
108-
if (constrained) {
108+
if (constrained && !((_this->windows) && _this->windows->text_input_active)) {
109109
SDL_SetKeyboardFocus(NULL);
110110
} else {
111111
SDL_SetKeyboardFocus(_this->windows);

src/events/SDL_keymap.c

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,74 @@ void SDL_SetKeymapEntry(SDL_Keymap *keymap, SDL_Scancode scancode, SDL_Keymod mo
9797

9898
SDL_Keycode SDL_GetKeymapKeycode(SDL_Keymap *keymap, SDL_Scancode scancode, SDL_Keymod modstate)
9999
{
100-
SDL_Keycode keycode;
100+
if (keymap) {
101+
const void *value;
102+
const SDL_Keymod normalized_modstate = NormalizeModifierStateForKeymap(modstate);
103+
Uint32 key = ((Uint32)normalized_modstate << 16) | scancode;
101104

102-
const Uint32 key = ((Uint32)NormalizeModifierStateForKeymap(modstate) << 16) | scancode;
103-
const void *value;
104-
if (keymap && SDL_FindInHashTable(keymap->scancode_to_keycode, (void *)(uintptr_t)key, &value)) {
105-
keycode = (SDL_Keycode)(uintptr_t)value;
106-
} else {
107-
keycode = SDL_GetDefaultKeyFromScancode(scancode, modstate);
105+
// First, try the requested set of modifiers.
106+
if (SDL_FindInHashTable(keymap->scancode_to_keycode, (void *)(uintptr_t)key, &value)) {
107+
return (SDL_Keycode)(uintptr_t)value;
108+
}
109+
110+
// If the requested set of modifiers was not found, search for the key from the highest to lowest modifier levels.
111+
if (normalized_modstate) {
112+
SDL_Keymod caps_mask = normalized_modstate & SDL_KMOD_CAPS;
113+
114+
for (int i = caps_mask ? 2 : 1; i; --i) {
115+
// Shift level 5
116+
if (normalized_modstate & SDL_KMOD_LEVEL5) {
117+
const SDL_Keymod shifted_modstate = SDL_KMOD_LEVEL5 | caps_mask;
118+
key = ((Uint32)shifted_modstate << 16) | scancode;
119+
120+
if (shifted_modstate != normalized_modstate && SDL_FindInHashTable(keymap->scancode_to_keycode, (void *)(uintptr_t)key, &value)) {
121+
return (SDL_Keycode)(uintptr_t)value;
122+
}
123+
}
124+
125+
// Shift level 4 (Level 3 + Shift)
126+
if ((normalized_modstate & (SDL_KMOD_MODE | SDL_KMOD_SHIFT)) == (SDL_KMOD_MODE | SDL_KMOD_SHIFT)) {
127+
const SDL_Keymod shifted_modstate = SDL_KMOD_MODE | SDL_KMOD_SHIFT | caps_mask;
128+
key = ((Uint32)shifted_modstate << 16) | scancode;
129+
130+
if (shifted_modstate != normalized_modstate && SDL_FindInHashTable(keymap->scancode_to_keycode, (void *)(uintptr_t)key, &value)) {
131+
return (SDL_Keycode)(uintptr_t)value;
132+
}
133+
}
134+
135+
// Shift level 3
136+
if (normalized_modstate & SDL_KMOD_MODE) {
137+
const SDL_Keymod shifted_modstate = SDL_KMOD_MODE | caps_mask;
138+
key = ((Uint32)shifted_modstate << 16) | scancode;
139+
140+
if (shifted_modstate != normalized_modstate && SDL_FindInHashTable(keymap->scancode_to_keycode, (void *)(uintptr_t)key, &value)) {
141+
return (SDL_Keycode)(uintptr_t)value;
142+
}
143+
}
144+
145+
// Shift level 2
146+
if (normalized_modstate & SDL_KMOD_SHIFT) {
147+
const SDL_Keymod shifted_modstate = SDL_KMOD_SHIFT | caps_mask;
148+
key = ((Uint32)shifted_modstate << 16) | scancode;
149+
150+
if (shifted_modstate != normalized_modstate && SDL_FindInHashTable(keymap->scancode_to_keycode, (void *)(uintptr_t)key, &value)) {
151+
return (SDL_Keycode)(uintptr_t)value;
152+
}
153+
}
154+
155+
// Shift Level 1 (unmodified)
156+
key = ((Uint32)caps_mask << 16) | scancode;
157+
if (SDL_FindInHashTable(keymap->scancode_to_keycode, (void *)(uintptr_t)key, &value)) {
158+
return (SDL_Keycode)(uintptr_t)value;
159+
}
160+
161+
// Clear the capslock mask, if set.
162+
caps_mask = SDL_KMOD_NONE;
163+
}
164+
}
108165
}
109-
return keycode;
166+
167+
return SDL_GetDefaultKeyFromScancode(scancode, modstate);
110168
}
111169

112170
SDL_Scancode SDL_GetKeymapScancode(SDL_Keymap *keymap, SDL_Keycode keycode, SDL_Keymod *modstate)

0 commit comments

Comments
 (0)