_wayland normal dragging working
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-23 23:55:20 +02:00
parent 319d2cbc63
commit b458a29aba
2 changed files with 25 additions and 17 deletions

View File

@@ -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);

View File

@@ -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);
}