|
|
@ -17,6 +17,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
// CHANGELOG
|
|
|
|
// CHANGELOG
|
|
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
|
|
|
|
|
|
// 2019-12-17: Inputs: Use SDL_GetMouseState, because there is no global mouse state on Wayland.
|
|
|
|
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
|
|
|
|
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
|
|
|
|
// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
|
|
|
|
// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
|
|
|
|
// 2019-04-23: Inputs: Added support for SDL_GameController (if ImGuiConfigFlags_NavEnableGamepad is set by user application).
|
|
|
|
// 2019-04-23: Inputs: Added support for SDL_GameController (if ImGuiConfigFlags_NavEnableGamepad is set by user application).
|
|
|
@ -60,6 +61,7 @@ static Uint64 g_Time = 0;
|
|
|
|
static bool g_MousePressed[3] = { false, false, false };
|
|
|
|
static bool g_MousePressed[3] = { false, false, false };
|
|
|
|
static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
|
|
|
|
static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
|
|
|
|
static char* g_ClipboardTextData = NULL;
|
|
|
|
static char* g_ClipboardTextData = NULL;
|
|
|
|
|
|
|
|
static bool g_VideoDriverIsWayland = false;
|
|
|
|
|
|
|
|
|
|
|
|
static const char* ImGui_ImplSDL2_GetClipboardText(void*)
|
|
|
|
static const char* ImGui_ImplSDL2_GetClipboardText(void*)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -124,6 +126,9 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
g_Window = window;
|
|
|
|
g_Window = window;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check and store if we are on Wayland to not check on every frame.
|
|
|
|
|
|
|
|
g_VideoDriverIsWayland = strncmp(SDL_GetCurrentVideoDriver(), "wayland", 7) == 0;
|
|
|
|
|
|
|
|
|
|
|
|
// Setup back-end capabilities flags
|
|
|
|
// Setup back-end capabilities flags
|
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
|
|
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
|
|
@ -237,14 +242,18 @@ static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
|
|
|
|
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS)
|
|
|
|
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS)
|
|
|
|
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
|
|
|
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
|
|
|
if (g_Window == focused_window)
|
|
|
|
if (g_Window == focused_window)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!g_VideoDriverIsWayland)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
|
|
|
|
// SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
|
|
|
|
// The creation of a new windows at runtime and SDL_CaptureMouse both seems to severely mess up with that, so we retrieve that position globally.
|
|
|
|
// The creation of a new windows at runtime and SDL_CaptureMouse both seems to severely mess up with that, so we retrieve that position globally.
|
|
|
|
|
|
|
|
// Won't use this workaround when on Wayland, as there is no global mouse position.
|
|
|
|
int wx, wy;
|
|
|
|
int wx, wy;
|
|
|
|
SDL_GetWindowPosition(focused_window, &wx, &wy);
|
|
|
|
SDL_GetWindowPosition(focused_window, &wx, &wy);
|
|
|
|
SDL_GetGlobalMouseState(&mx, &my);
|
|
|
|
SDL_GetGlobalMouseState(&mx, &my);
|
|
|
|
mx -= wx;
|
|
|
|
mx -= wx;
|
|
|
|
my -= wy;
|
|
|
|
my -= wy;
|
|
|
|
|
|
|
|
}
|
|
|
|
io.MousePos = ImVec2((float)mx, (float)my);
|
|
|
|
io.MousePos = ImVec2((float)mx, (float)my);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|