mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-15 11:25:13 +00:00
sdl: Respect text input main thread requirements. (#2138)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
This commit is contained in:
parent
4f2f9494b0
commit
4719d32295
2
externals/sdl3
vendored
2
externals/sdl3
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 3a1d76d298db023f6cf37fb08ee766f20a4e12ab
|
Subproject commit 22422f7748d5128135995ed34c8f8012861c7332
|
|
@ -11,7 +11,6 @@
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#include <TargetConditionals.h>
|
#include <TargetConditionals.h>
|
||||||
#include <dispatch/dispatch.h>
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
@ -72,33 +71,25 @@ static void PlatformSetImeData(ImGuiContext*, ImGuiViewport* viewport, ImGuiPlat
|
||||||
auto window_id = (SDL_WindowID)(intptr_t)viewport->PlatformHandle;
|
auto window_id = (SDL_WindowID)(intptr_t)viewport->PlatformHandle;
|
||||||
SDL_Window* window = SDL_GetWindowFromID(window_id);
|
SDL_Window* window = SDL_GetWindowFromID(window_id);
|
||||||
if ((!data->WantVisible || bd->ime_window != window) && bd->ime_window != nullptr) {
|
if ((!data->WantVisible || bd->ime_window != window) && bd->ime_window != nullptr) {
|
||||||
auto stop_input = [&bd] { SDL_StopTextInput(bd->ime_window); };
|
SDL_RunOnMainThread(
|
||||||
#ifdef __APPLE__
|
[](void* userdata) { SDL_StopTextInput(static_cast<SDL_Window*>(userdata)); },
|
||||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
bd->ime_window, true);
|
||||||
stop_input();
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
stop_input();
|
|
||||||
#endif
|
|
||||||
bd->ime_window = nullptr;
|
bd->ime_window = nullptr;
|
||||||
}
|
}
|
||||||
if (data->WantVisible) {
|
if (data->WantVisible) {
|
||||||
SDL_Rect r;
|
std::pair<SDL_Window*, SDL_Rect> usr_data;
|
||||||
r.x = (int)data->InputPos.x;
|
usr_data.first = window;
|
||||||
r.y = (int)data->InputPos.y;
|
usr_data.second.x = (int)data->InputPos.x;
|
||||||
r.w = 1;
|
usr_data.second.y = (int)data->InputPos.y;
|
||||||
r.h = (int)data->InputLineHeight;
|
usr_data.second.w = 1;
|
||||||
const auto start_input = [&window, &r] {
|
usr_data.second.h = (int)data->InputLineHeight;
|
||||||
SDL_SetTextInputArea(window, &r, 0);
|
SDL_RunOnMainThread(
|
||||||
SDL_StartTextInput(window);
|
[](void* userdata) {
|
||||||
};
|
auto* params = static_cast<std::pair<SDL_Window*, SDL_Rect>*>(userdata);
|
||||||
#ifdef __APPLE__
|
SDL_SetTextInputArea(params->first, ¶ms->second, 0);
|
||||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
SDL_StartTextInput(params->first);
|
||||||
start_input();
|
},
|
||||||
});
|
&usr_data, true);
|
||||||
#else
|
|
||||||
start_input();
|
|
||||||
#endif
|
|
||||||
bd->ime_window = window;
|
bd->ime_window = window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,9 @@ void WindowSDL::InitTimers() {
|
||||||
|
|
||||||
void WindowSDL::RequestKeyboard() {
|
void WindowSDL::RequestKeyboard() {
|
||||||
if (keyboard_grab == 0) {
|
if (keyboard_grab == 0) {
|
||||||
SDL_StartTextInput(window);
|
SDL_RunOnMainThread(
|
||||||
|
[](void* userdata) { SDL_StartTextInput(static_cast<SDL_Window*>(userdata)); }, window,
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
keyboard_grab++;
|
keyboard_grab++;
|
||||||
}
|
}
|
||||||
|
@ -214,7 +216,9 @@ void WindowSDL::ReleaseKeyboard() {
|
||||||
ASSERT(keyboard_grab > 0);
|
ASSERT(keyboard_grab > 0);
|
||||||
keyboard_grab--;
|
keyboard_grab--;
|
||||||
if (keyboard_grab == 0) {
|
if (keyboard_grab == 0) {
|
||||||
SDL_StopTextInput(window);
|
SDL_RunOnMainThread(
|
||||||
|
[](void* userdata) { SDL_StopTextInput(static_cast<SDL_Window*>(userdata)); }, window,
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue