mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-27 14:50:21 +03:00
Fix autohide behaviour after dragging a panel
Summary: Currently, when dragging a window from the panel to move it, it breaks the autohide behaviour of active docks/panels. This change imitates a release event on X11 to circumvent these problems. BUG: 403104 Reviewers: mvourlakos Reviewed By: mvourlakos Subscribers: plasma-devel Tags: #latte_dock, #plasma Differential Revision: https://phabricator.kde.org/D18194
This commit is contained in:
parent
cf6641a089
commit
56cfb42734
@ -1151,7 +1151,17 @@ void VisibilityManager::requestMoveActiveWindow(int localX, int localY)
|
||||
//active window can be dragged only when it is in the same screen
|
||||
if (actInfo.isValid() && !actInfo.geometry().isNull() && m_latteView->screenGeometry().contains(actInfo.geometry().center())) {
|
||||
QPoint globalPoint{m_latteView->x() + localX, m_latteView->y() + localY};
|
||||
|
||||
wm->requestMoveWindow(actInfo.wid(), globalPoint);
|
||||
|
||||
//! This timer is needed because otherwise the mouse position
|
||||
//! in the dragged window changes to TopLeft corner
|
||||
QTimer::singleShot(250, this, [&, actInfo, globalPoint]() {
|
||||
wm->releaseMouseEventFor(m_latteView->winId());
|
||||
});
|
||||
|
||||
setContainsMouse(false);
|
||||
updateHiddenState();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,7 @@ public:
|
||||
virtual void enableBlurBehind(QWindow &view) const = 0;
|
||||
virtual void setEdgeStateFor(QWindow *view, bool active) const = 0;
|
||||
|
||||
virtual void releaseMouseEventFor(WindowId wid) const = 0;
|
||||
virtual void requestToggleMaximized(WindowId wid) const = 0;
|
||||
virtual void requestMoveWindow(WindowId wid, QPoint from) const = 0;
|
||||
virtual bool windowCanBeDragged(WindowId wid) const = 0;
|
||||
|
@ -370,6 +370,11 @@ bool WaylandInterface::windowCanBeDragged(WindowId wid) const
|
||||
return (winfo.isValid() && !winfo.isPlasmaDesktop() && !winfo.hasSkipTaskbar());
|
||||
}
|
||||
|
||||
void WaylandInterface::releaseMouseEventFor(WindowId wid) const
|
||||
{
|
||||
// this isnt really needed under wayland
|
||||
}
|
||||
|
||||
void WaylandInterface::requestMoveWindow(WindowId wid, QPoint from) const
|
||||
{
|
||||
if (windowCanBeDragged(wid)) {
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
void slideWindow(QWindow &view, Slide location) const override;
|
||||
void enableBlurBehind(QWindow &view) const override;
|
||||
|
||||
void releaseMouseEventFor(WindowId wid) const override;
|
||||
void requestToggleMaximized(WindowId wid) const override;
|
||||
void requestMoveWindow(WindowId wid, QPoint from) const override;
|
||||
bool windowCanBeDragged(WindowId wid) const;
|
||||
|
@ -333,6 +333,28 @@ bool XWindowInterface::windowCanBeDragged(WindowId wid) const
|
||||
return (winfo.isValid() && !winfo.isPlasmaDesktop() && !winfo.hasSkipTaskbar());
|
||||
}
|
||||
|
||||
void XWindowInterface::releaseMouseEventFor(WindowId wid) const
|
||||
{
|
||||
auto connection = QX11Info::connection();
|
||||
|
||||
xcb_button_release_event_t releaseEvent;
|
||||
memset(&releaseEvent, 0, sizeof(releaseEvent));
|
||||
|
||||
releaseEvent.response_type = XCB_BUTTON_RELEASE;
|
||||
releaseEvent.event = wid.toInt();
|
||||
releaseEvent.child = XCB_WINDOW_NONE;
|
||||
releaseEvent.root = QX11Info::appRootWindow();
|
||||
releaseEvent.event_x = -1;
|
||||
releaseEvent.event_y = -1;
|
||||
releaseEvent.root_x = -1;
|
||||
releaseEvent.root_y = -1;
|
||||
releaseEvent.detail = XCB_BUTTON_INDEX_1;
|
||||
releaseEvent.state = XCB_BUTTON_MASK_1;
|
||||
releaseEvent.time = XCB_CURRENT_TIME;
|
||||
releaseEvent.same_screen = true;
|
||||
xcb_send_event( connection, false, wid.toInt(), XCB_EVENT_MASK_BUTTON_RELEASE, reinterpret_cast<const char*>(&releaseEvent));
|
||||
}
|
||||
|
||||
void XWindowInterface::requestMoveWindow(WindowId wid, QPoint from) const
|
||||
{
|
||||
WindowInfoWrap wInfo = requestInfo(wid);
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
void slideWindow(QWindow &view, Slide location) const override;
|
||||
void enableBlurBehind(QWindow &view) const override;
|
||||
|
||||
void releaseMouseEventFor(WindowId wid) const override;
|
||||
void requestToggleMaximized(WindowId wid) const override;
|
||||
void requestMoveWindow(WindowId wid, QPoint from) const override;
|
||||
bool windowCanBeDragged(WindowId wid) const override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user