diff --git a/Source/Engine/Platform/SDL/SDLPlatform.cpp b/Source/Engine/Platform/SDL/SDLPlatform.cpp index b83598d7d..49f57e5e9 100644 --- a/Source/Engine/Platform/SDL/SDLPlatform.cpp +++ b/Source/Engine/Platform/SDL/SDLPlatform.cpp @@ -50,8 +50,8 @@ bool SDLPlatform::Init() SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "x11", SDL_HINT_OVERRIDE); else if (CommandLine::Options.Wayland) SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_OVERRIDE); - //else - // SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_OVERRIDE); + else + SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_DEFAULT); #endif #if PLATFORM_LINUX @@ -82,19 +82,6 @@ bool SDLPlatform::Init() SDL_SetHint(SDL_HINT_WINDOWS_RAW_KEYBOARD, "1"); SDL_SetHint(SDL_HINT_VIDEO_WAYLAND_SCALE_TO_DISPLAY, "1"); - - if (UsesWindows() || UsesX11()) - { - // Disable SDL clipboard support - SDL_SetEventEnabled(SDL_EVENT_CLIPBOARD_UPDATE, false); - - // Disable SDL drag and drop support - SDL_SetEventEnabled(SDL_EVENT_DROP_FILE, false); - SDL_SetEventEnabled(SDL_EVENT_DROP_TEXT, false); - SDL_SetEventEnabled(SDL_EVENT_DROP_BEGIN, false); - SDL_SetEventEnabled(SDL_EVENT_DROP_COMPLETE, false); - SDL_SetEventEnabled(SDL_EVENT_DROP_POSITION, false); - } //if (InitPlatform()) // return true; @@ -122,6 +109,19 @@ bool SDLPlatform::Init() if (InitPlatform()) return true; + if (UsesWindows() || UsesX11()) + { + // Disable SDL clipboard support + SDL_SetEventEnabled(SDL_EVENT_CLIPBOARD_UPDATE, false); + + // Disable SDL drag and drop support + SDL_SetEventEnabled(SDL_EVENT_DROP_FILE, false); + SDL_SetEventEnabled(SDL_EVENT_DROP_TEXT, false); + SDL_SetEventEnabled(SDL_EVENT_DROP_BEGIN, false); + SDL_SetEventEnabled(SDL_EVENT_DROP_COMPLETE, false); + SDL_SetEventEnabled(SDL_EVENT_DROP_POSITION, false); + } + SDLInput::Init(); SystemDpi = (int)(SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay()) * DefaultDPI); diff --git a/Source/Engine/Platform/SDL/SDLWindow.cpp b/Source/Engine/Platform/SDL/SDLWindow.cpp index 2e7c5d2d9..5a9b075c7 100644 --- a/Source/Engine/Platform/SDL/SDLWindow.cpp +++ b/Source/Engine/Platform/SDL/SDLWindow.cpp @@ -46,6 +46,8 @@ extern wl_seat* WaylandSeat; extern wl_data_device_manager* WaylandDataDeviceManager; extern xdg_wm_base* WaylandXdgWmBase; extern bool waylandDraggingActive; +extern bool waylandDraggingWindow; +extern StringView waylandDraggingData; #endif extern Window* draggedWindow; @@ -592,15 +594,21 @@ void SDLWindow::HandleEvent(SDL_Event& event) //const Float2 mousePos = ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale}); const Float2 mousePos = dragStartPosition + Float2(event.drop.x * dpiScale, event.drop.y * dpiScale); DragDropEffect effect = DragDropEffect::None; - auto daata = event.drop.data; + String text(event.drop.data); SDLDropTextData dropData; + dropData.Text = text; + if (event.type == SDL_EVENT_DROP_BEGIN || event.type == SDL_EVENT_DROP_POSITION) + { + // We don't have the drag data during these events... + dropData.Text = waylandDraggingData; + } if (event.type == SDL_EVENT_DROP_BEGIN) { - dragStartPosition = GetPosition();//Platform::GetMousePosition(); + dragStartPosition = waylandDraggingWindow ? GetPosition() : Float2::Zero;//Platform::GetMousePosition(); LOG(Info, "SDL_EVENT_DROP_BEGIN: {}, mousepos: {}", dragStartPosition, mousePos); OnDragEnter(&dropData, mousePos, effect); }