From 42b516b56777bb7b87fa97534a2e9d0b84cbdc18 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Sun, 29 Aug 2021 17:08:43 +0200 Subject: [PATCH] fix drag and drop raise with Xwayland windows They shouldn't be raised immediately. The same strategy as with Wayland native clients should be used. BUG: 440534 --- src/input.cpp | 24 +++++++++++++++--------- src/xwl/drag_wl.cpp | 1 - src/xwl/drag_x.cpp | 6 ------ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index e46eea5ece..66c48fa327 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1953,6 +1953,20 @@ public: const auto eventPos = event->globalPos(); // TODO: use InputDeviceHandler::at() here and check isClient()? Toplevel *t = input()->findManagedToplevel(eventPos); + const auto dragTarget = qobject_cast(t); + if (dragTarget) { + if (dragTarget != m_dragTarget) { + workspace()->takeActivity(dragTarget, Workspace::ActivityFlag::ActivityFocus); + m_raiseTimer.start(); + } + if ((pos - m_lastPos).manhattanLength() > 10) { + m_lastPos = pos; + // reset timer to delay raising the window + m_raiseTimer.start(); + } + } + m_dragTarget = dragTarget; + if (auto *xwl = xwayland()) { const auto ret = xwl->dragMoveFilter(t, eventPos); if (ret == Xwl::DragEventReply::Ignore) { @@ -1965,17 +1979,8 @@ public: if (t) { // TODO: consider decorations if (t->surface() != seat->dragSurface()) { - if ((m_dragTarget = qobject_cast(t))) { - workspace()->takeActivity(m_dragTarget, Workspace::ActivityFlag::ActivityFocus); - m_raiseTimer.start(); - } seat->setDragTarget(t->surface(), t->inputTransformation()); } - if ((pos - m_lastPos).manhattanLength() > 10) { - m_lastPos = pos; - // reset timer to delay raising the window - m_raiseTimer.start(); - } } else { // no window at that place, if we have a surface we need to reset seat->setDragTarget(nullptr); @@ -1989,6 +1994,7 @@ public: break; case QEvent::MouseButtonRelease: raiseDragTarget(); + m_dragTarget = nullptr; seat->notifyPointerButton(nativeButton, KWaylandServer::PointerButtonState::Released); seat->notifyPointerFrame(); break; diff --git a/src/xwl/drag_wl.cpp b/src/xwl/drag_wl.cpp index 283af0a28f..7a0aa0a01a 100644 --- a/src/xwl/drag_wl.cpp +++ b/src/xwl/drag_wl.cpp @@ -87,7 +87,6 @@ DragEventReply WlToXDrag::moveFilter(Toplevel *target, const QPoint &pos) return DragEventReply::Wayland; } // new target - workspace()->activateClient(ac, false); seat->setDragTarget(DataBridge::self()->dnd()->surfaceIface(), pos, ac->inputTransformation()); m_visit = new Xvisit(this, ac); return DragEventReply::Take; diff --git a/src/xwl/drag_x.cpp b/src/xwl/drag_x.cpp index feaeb1fdfd..fcca9321ca 100644 --- a/src/xwl/drag_x.cpp +++ b/src/xwl/drag_x.cpp @@ -191,11 +191,6 @@ DragEventReply XToWlDrag::moveFilter(Toplevel *target, const QPoint &pos) target->surface()->client() == waylandServer()->xWaylandConnection()) { // currently there is no target or target is an Xwayland window // handled here and by X directly - if (AbstractClient *ac = qobject_cast(target)) { - if (workspace()->activeClient() != ac) { - workspace()->activateClient(ac); - } - } if (hasCurrent) { // last received enter event is now void, // wait for the next one @@ -277,7 +272,6 @@ void XToWlDrag::offerCallback(const QString &mime) void XToWlDrag::setDragTarget() { auto *ac = m_visit->target(); - workspace()->activateClient(ac); waylandServer()->seat()->setDragTarget(ac->surface(), ac->inputTransformation()); }