_window dragging X11 fixed
Some checks are pending
Build Android / Game (Android, Release ARM64) (push) Waiting to run
Build iOS / Game (iOS, Release ARM64) (push) Waiting to run
Build Linux / Editor (Linux, Development x64) (push) Waiting to run
Build Linux / Game (Linux, Release x64) (push) Waiting to run
Build macOS / Editor (Mac, Development ARM64) (push) Waiting to run
Build macOS / Game (Mac, Release ARM64) (push) Waiting to run
Build Windows / Editor (Windows, Development x64) (push) Waiting to run
Build Windows / Game (Windows, Release x64) (push) Waiting to run
Cooker / Cook (Mac) (push) Waiting to run
Tests / Tests (Linux) (push) Waiting to run
Tests / Tests (Windows) (push) Waiting to run

This commit is contained in:
2025-01-20 22:31:13 +02:00
parent e45075f7d8
commit 3dd9612ae4
7 changed files with 97 additions and 57 deletions

View File

@@ -48,6 +48,8 @@ extern xdg_wm_base* WaylandXdgWmBase;
extern bool waylandDraggingActive;
#endif
extern Window* draggedWindow;
#define DefaultDPI 96
namespace
@@ -406,8 +408,6 @@ SDLWindow* SDLWindow::GetWindowWithSDLWindow(SDL_Window* window)
return nullptr;
}
extern Window* draggedWindow;
void SDLWindow::HandleEvent(SDL_Event& event)
{
if (_isClosing)
@@ -467,13 +467,19 @@ void SDLWindow::HandleEvent(SDL_Event& event)
{
_cachedClientRectangle.Location = Float2(static_cast<float>(event.window.data1), static_cast<float>(event.window.data2));
#if PLATFORM_LINUX
if (SDLPlatform::UsesX11() && !SDLPlatform::UsesXWayland())
if (SDLPlatform::UsesX11())
{
// X11 doesn't report any mouse events when mouse is over the caption area, send a simulated event instead...
Float2 mousePosition;
auto buttons = SDL_GetGlobalMouseState(&mousePosition.X, &mousePosition.Y);
if ((buttons & SDL_BUTTON_MASK(SDL_BUTTON_LEFT)) != 0)
SDLPlatform::CheckWindowDragging(this, WindowHitCodes::Caption);
if ((buttons & SDL_BUTTON_MASK(SDL_BUTTON_LEFT)) != 0 && draggedWindow == nullptr)
{
// TODO: verify mouse position, window focus
bool result = false;
OnLeftButtonHit(WindowHitCodes::Caption, result);
if (result)
draggedWindow = this;
}
}
#endif
return;
@@ -764,6 +770,7 @@ void SDLWindow::HandleEvent(SDL_Event& event)
#endif
{
LOG(Info, "SDL_EVENT_MOUSE_BUTTON_UP: {}", GetTitle());
#if PLATFORM_WINDOWS
if (draggedWindow != nullptr && draggedWindow->_windowId != event.button.windowID)
{
// Send the button event to dragged window as well
@@ -777,6 +784,7 @@ void SDLWindow::HandleEvent(SDL_Event& event)
SDLInput::HandleEvent(draggedWindow, event2);
}
#endif
}
break;
}
@@ -839,8 +847,8 @@ void SDLWindow::Hide()
SDL_HideWindow(_window);
#if PLATFORM_LINUX
if (SDLPlatform::UsesWayland() && _dragOver)
StopDragging();
//if (SDLPlatform::UsesWayland() && _dragOver)
// StopDragging();
#endif
WindowBase::Hide();
@@ -951,6 +959,14 @@ void SDLWindow::BringToFront(bool force)
SDL_RaiseWindow(_window);
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, activateWhenRaised);
#endif
if (SDLPlatform::UsesX11())
{
auto activateWhenRaised = SDL_GetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED);
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, "0");
SDL_RaiseWindow(_window);
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, activateWhenRaised);
SDL_SyncWindow(_window);
}
}
void SDLWindow::SetClientBounds(const Rectangle& clientArea)
@@ -1311,12 +1327,14 @@ DragDropEffect SDLWindow::DoDragDrop(const StringView& data, const Float2& offse
}
#if PLATFORM_LINUX
if (SDLPlatform::UsesWayland()
if (SDLPlatform::UsesWayland())
DoDragDropWayland(String("notawindow"), dragSourceWindow, dragOffset);
else
#endif
{
SDL_SetWindowAlwaysOnTop(_window, true);
Show();
//draggingActive = true;
/*auto watch = [](void* userdata, SDL_Event* event) -> bool