You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#ifdef GLFW_RESIZE_NESW_CURSOR //let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
58
+
#ifdef GLFW_RESIZE_NESW_CURSOR //Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
io.MouseDown[0] = bd->MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
SDL_Window* focused_window = SDL_GetKeyboardFocus(); // Mouse position won't be reported unless window is focused.
299
-
#if SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH
300
-
SDL_Window* hovered_window = SDL_GetMouseFocus(); // This is better but is only reliably useful with SDL 2.0.5+ and SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH enabled.
SDL_Window* hovered_window = SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH ? SDL_GetMouseFocus() : NULL; // This is better but is only reliably useful with SDL 2.0.5+ and SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH.
303
+
SDL_Window* mouse_window = NULL;
304
+
if (hovered_window && bd->Window == hovered_window)
// Set Dear ImGui mouse position from OS position + get buttons. (this is the common behavior)
324
+
if (bd->MouseCanUseGlobalState)
306
325
{
307
-
if (bd->MouseCanUseGlobalState)
308
-
{
309
-
// SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
310
-
// 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.
311
-
// Won't use this workaround on SDL backends that have no global mouse position, like Wayland or RPI
312
-
int wx, wy;
313
-
SDL_GetWindowPosition(mouse_window, &wx, &wy);
314
-
SDL_GetGlobalMouseState(&mx, &my);
315
-
mx -= wx;
316
-
my -= wy;
317
-
}
318
-
io.MousePos = ImVec2((float)mx, (float)my);
326
+
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
327
+
// Unlike local position obtained earlier this will be valid when straying out of bounds.
0 commit comments