|
18 | 18 |
|
19 | 19 | // CHANGELOG
|
20 | 20 | // (minor and older changes stripped away, please see git history for details)
|
| 21 | +// 2022-09-26: Inputs: Disable SDL 2.0.22 new "auto capture" (SDL_HINT_MOUSE_AUTO_CAPTURE) which prevents drag and drop across windows for multi-viewport support + don't capture when drag and dropping. (#5710) |
21 | 22 | // 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
|
22 | 23 | // 2022-03-22: Inputs: Fix mouse position issues when dragging outside of boundaries. SDL_CaptureMouse() erroneously still gives out LEAVE events when hovering OS decorations.
|
23 | 24 | // 2022-03-22: Inputs: Added support for extra mouse buttons (SDL_BUTTON_X1/SDL_BUTTON_X2).
|
|
76 | 77 | #else
|
77 | 78 | #define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
|
78 | 79 | #endif
|
79 |
| -#define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5) |
80 | 80 | #define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
|
81 | 81 |
|
82 | 82 | // SDL Data
|
@@ -367,15 +367,20 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
367 | 367 | (void)window;
|
368 | 368 | #endif
|
369 | 369 |
|
370 |
| - // Set SDL hint to receive mouse click events on window focus, otherwise SDL doesn't emit the event. |
| 370 | + // From 2.0.5: Set SDL hint to receive mouse click events on window focus, otherwise SDL doesn't emit the event. |
371 | 371 | // Without this, when clicking to gain focus, our widgets wouldn't activate even though they showed as hovered.
|
372 | 372 | // (This is unfortunately a global SDL setting, so enabling it might have a side-effect on your application.
|
373 | 373 | // It is unlikely to make a difference, but if your app absolutely needs to ignore the initial on-focus click:
|
374 | 374 | // you can ignore SDL_MOUSEBUTTONDOWN events coming right after a SDL_WINDOWEVENT_FOCUS_GAINED)
|
375 |
| -#if SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH |
| 375 | +#ifdef SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH |
376 | 376 | SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
|
377 | 377 | #endif
|
378 | 378 |
|
| 379 | + // From 2.0.22: Disable auto-capture, this is preventing drag and drop across multiple windows (see #5710) |
| 380 | +#ifdef SDL_HINT_MOUSE_AUTO_CAPTURE |
| 381 | + SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0"); |
| 382 | +#endif |
| 383 | + |
379 | 384 | return true;
|
380 | 385 | }
|
381 | 386 |
|
@@ -435,7 +440,7 @@ static void ImGui_ImplSDL2_UpdateMouseData()
|
435 | 440 | // We forward mouse input when hovered or captured (via SDL_MOUSEMOTION) or when focused (below)
|
436 | 441 | #if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
|
437 | 442 | // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
|
438 |
| - SDL_CaptureMouse(bd->MouseButtonsDown != 0 ? SDL_TRUE : SDL_FALSE); |
| 443 | + SDL_CaptureMouse((bd->MouseButtonsDown != 0 && ImGui::GetDragDropPayload() == NULL) ? SDL_TRUE : SDL_FALSE); |
439 | 444 | SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
440 | 445 | const bool is_app_focused = (bd->Window == focused_window);
|
441 | 446 | #else
|
|
0 commit comments