mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 01:33:50 +03:00
remove obsolete draggingStarted signals/slots
--draggingStarted signals/slots were used in order to handle the active window dragging from empty areas. The new approach ungrabs the mouse properly through View relevant function and at the same time sends a QEvent::Leave event to inform applets that the mouse has left the view. This is enough in order to remove any older draggingStarted workarounds and hacks.
This commit is contained in:
parent
057edb87f1
commit
8cf49b672c
@ -96,6 +96,10 @@ View::View(Plasma::Corona *corona, QScreen *targetScreen, bool byPassWM)
|
||||
else
|
||||
m_positioner->setScreenToFollow(qGuiApp->primaryScreen());
|
||||
|
||||
m_releaseGrabTimer.setInterval(400);
|
||||
m_releaseGrabTimer.setSingleShot(true);
|
||||
connect(&m_releaseGrabTimer, &QTimer::timeout, this, &View::releaseGrab);
|
||||
|
||||
connect(this, &View::containmentChanged
|
||||
, this, [ &, byPassWM]() {
|
||||
qDebug() << "dock view c++ containment changed 1...";
|
||||
@ -1215,6 +1219,32 @@ bool View::event(QEvent *e)
|
||||
return ContainmentView::event(e);
|
||||
}
|
||||
|
||||
//! release grab and restore mouse state
|
||||
void View::unblockMouse(int x, int y)
|
||||
{
|
||||
setMouseGrabEnabled(false);
|
||||
|
||||
m_releaseGrab_x = x;
|
||||
m_releaseGrab_y = y;
|
||||
m_releaseGrabTimer.start();
|
||||
}
|
||||
|
||||
void View::releaseGrab()
|
||||
{
|
||||
//! ungrab mouse
|
||||
if (mouseGrabberItem()) {
|
||||
mouseGrabberItem()->ungrabMouse();
|
||||
}
|
||||
|
||||
//! properly release grabbed mouse in order to inform all views
|
||||
setMouseGrabEnabled(true);
|
||||
setMouseGrabEnabled(false);
|
||||
|
||||
//! Send a fake QEvent::Leave to inform applets for mouse leaving the view
|
||||
QHoverEvent e(QEvent::Leave, QPoint(-5,-5), QPoint(m_releaseGrab_x, m_releaseGrab_y));
|
||||
QCoreApplication::instance()->sendEvent(this, &e);
|
||||
}
|
||||
|
||||
void View::deactivateApplets()
|
||||
{
|
||||
if (!containment()) {
|
||||
@ -1282,21 +1312,6 @@ QVariantList View::containmentActions()
|
||||
return actions;
|
||||
}
|
||||
|
||||
void View::disableGrabItemBehavior()
|
||||
{
|
||||
setMouseGrabEnabled(false);
|
||||
}
|
||||
|
||||
void View::restoreGrabItemBehavior()
|
||||
{
|
||||
if (mouseGrabberItem()) {
|
||||
mouseGrabberItem()->ungrabMouse();
|
||||
}
|
||||
|
||||
setMouseGrabEnabled(true);
|
||||
setMouseGrabEnabled(false);
|
||||
}
|
||||
|
||||
bool View::isHighestPriorityView() {
|
||||
if (m_layout) {
|
||||
return this == m_layout->highestPriorityView();
|
||||
|
@ -206,6 +206,9 @@ public:
|
||||
|
||||
KWayland::Client::PlasmaShellSurface *surface();
|
||||
|
||||
//! release grab and restore mouse state
|
||||
void unblockMouse(int x, int y);
|
||||
|
||||
void reconsiderScreen();
|
||||
|
||||
//! these are signals that create crashes, such a example is the availableScreenRectChanged from corona
|
||||
@ -229,9 +232,6 @@ public slots:
|
||||
|
||||
void updateAbsoluteGeometry(bool bypassChecks = false);
|
||||
|
||||
Q_INVOKABLE void disableGrabItemBehavior();
|
||||
Q_INVOKABLE void restoreGrabItemBehavior();
|
||||
|
||||
Q_INVOKABLE bool isHighestPriorityView();
|
||||
|
||||
protected slots:
|
||||
@ -293,6 +293,7 @@ private slots:
|
||||
void configViewCreatedFor(Latte::View *view);
|
||||
void hideWindowsForSlidingOut();
|
||||
void preferredViewForShortcutsChangedSlot(Latte::View *view);
|
||||
void releaseGrab();
|
||||
void reloadSource();
|
||||
void statusChanged(Plasma::Types::ItemStatus);
|
||||
|
||||
@ -345,6 +346,10 @@ private:
|
||||
QTimer m_visibleHackTimer1;
|
||||
QTimer m_visibleHackTimer2;
|
||||
|
||||
QTimer m_releaseGrabTimer;
|
||||
int m_releaseGrab_x;
|
||||
int m_releaseGrab_y;
|
||||
|
||||
Layout::GenericLayout *m_layout{nullptr};
|
||||
QPointer<PlasmaQuick::ConfigView> m_configView;
|
||||
|
||||
|
@ -72,9 +72,6 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view)
|
||||
updateStrutsBasedOnLayoutsAndActivities();
|
||||
}
|
||||
});
|
||||
|
||||
connect(m_latteView->windowsTracker(), &WindowsTracker::activeWindowDraggingStarted,
|
||||
this, &VisibilityManager::activeWindowDraggingStarted);
|
||||
}
|
||||
|
||||
if (m_corona) {
|
||||
@ -526,13 +523,6 @@ void VisibilityManager::applyActivitiesToHiddenWindows(const QStringList &activi
|
||||
}
|
||||
}
|
||||
|
||||
void VisibilityManager::activeWindowDraggingStarted()
|
||||
{
|
||||
//! Send a fake QEvent::LEAVE to inform applets for mouse leaving the view
|
||||
QHoverEvent e(QEvent::Leave, QPoint(-5,-5), m_latteView->geometry().center());
|
||||
QCoreApplication::instance()->sendEvent(m_latteView, &e);
|
||||
}
|
||||
|
||||
void VisibilityManager::dodgeActive()
|
||||
{
|
||||
if (m_raiseTemporarily)
|
||||
|
@ -101,9 +101,6 @@ public:
|
||||
|
||||
bool supportsKWinEdges() const;
|
||||
|
||||
//! called for windowTracker to reset values
|
||||
void activeWindowDraggingStarted();
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void hide();
|
||||
Q_INVOKABLE void show();
|
||||
|
@ -87,14 +87,7 @@ void AllScreensTracker::init()
|
||||
|
||||
void AllScreensTracker::initSignalsForInformation()
|
||||
{
|
||||
if (m_currentLastActiveWindow) {
|
||||
disconnect(m_currentLastActiveWindow, &WindowSystem::Tracker::LastActiveWindow::draggingStarted,
|
||||
this, &AllScreensTracker::activeWindowDraggingStarted);
|
||||
}
|
||||
|
||||
m_currentLastActiveWindow = lastActiveWindow();
|
||||
connect(m_currentLastActiveWindow, &WindowSystem::Tracker::LastActiveWindow::draggingStarted,
|
||||
this, &AllScreensTracker::activeWindowDraggingStarted);
|
||||
|
||||
emit lastActiveWindowChanged();
|
||||
emit activeWindowMaximizedChanged();
|
||||
|
@ -71,7 +71,6 @@ public slots:
|
||||
Q_INVOKABLE void requestMoveLastWindow(int localX, int localY);
|
||||
|
||||
signals:
|
||||
void activeWindowDraggingStarted();
|
||||
void activeWindowMaximizedChanged();
|
||||
void existsWindowActiveChanged();
|
||||
void existsWindowMaximizedChanged();
|
||||
|
@ -111,13 +111,6 @@ void CurrentScreenTracker::init()
|
||||
|
||||
void CurrentScreenTracker::initSignalsForInformation()
|
||||
{
|
||||
if (!m_initialized) {
|
||||
connect(lastActiveWindow(), &WindowSystem::Tracker::LastActiveWindow::draggingStarted,
|
||||
this, &CurrentScreenTracker::activeWindowDraggingStarted);
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
emit lastActiveWindowChanged();
|
||||
emit activeWindowMaximizedChanged();
|
||||
emit activeWindowTouchingChanged();
|
||||
|
@ -80,7 +80,6 @@ public slots:
|
||||
Q_INVOKABLE void requestMoveLastWindow(int localX, int localY);
|
||||
|
||||
signals:
|
||||
void activeWindowDraggingStarted();
|
||||
void activeWindowMaximizedChanged();
|
||||
void activeWindowTouchingChanged();
|
||||
void existsWindowActiveChanged();
|
||||
@ -100,8 +99,6 @@ private:
|
||||
void init();
|
||||
|
||||
private:
|
||||
bool m_initialized{false};
|
||||
|
||||
Latte::View *m_latteView{nullptr};
|
||||
WindowSystem::AbstractWindowInterface *m_wm{nullptr};
|
||||
};
|
||||
|
@ -48,11 +48,6 @@ WindowsTracker::WindowsTracker(Latte::View *parent)
|
||||
}
|
||||
});
|
||||
|
||||
connect(m_allScreensTracker, &TrackerPart::AllScreensTracker::activeWindowDraggingStarted,
|
||||
this, &WindowsTracker::activeWindowDraggingStarted);
|
||||
connect(m_currentScreenTracker, &TrackerPart::CurrentScreenTracker::activeWindowDraggingStarted,
|
||||
this, &WindowsTracker::activeWindowDraggingStarted);
|
||||
|
||||
m_wm->windowsTracker()->addView(m_latteView);
|
||||
|
||||
emit allScreensChanged();
|
||||
|
@ -74,7 +74,6 @@ public slots:
|
||||
|
||||
signals:
|
||||
void enabledChanged();
|
||||
void activeWindowDraggingStarted();
|
||||
void allScreensChanged();
|
||||
void currentScreenChanged();
|
||||
|
||||
|
@ -98,8 +98,6 @@ 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 requestActivate(WindowId wid) const = 0;
|
||||
virtual void requestClose(WindowId wid) const = 0;
|
||||
virtual void requestMoveWindow(WindowId wid, QPoint from) const = 0;
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
// Qt
|
||||
#include <QDebug>
|
||||
#include <QHoverEvent>
|
||||
#include <QPoint>
|
||||
#include <QTimer>
|
||||
|
||||
@ -391,23 +392,14 @@ void LastActiveWindow::requestClose()
|
||||
|
||||
void LastActiveWindow::requestMove(Latte::View *fromView, int localX, int localY)
|
||||
{
|
||||
if (!canBeDragged()) {
|
||||
if (!fromView || !canBeDragged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPoint globalPoint{fromView->x() + localX, fromView->y() + localY};
|
||||
|
||||
m_wm->requestMoveWindow(m_winId, globalPoint);
|
||||
|
||||
auto viewId = m_winId;
|
||||
|
||||
//! This timer is needed because otherwise the mouse position
|
||||
//! in the dragged window changes to TopLeft corner
|
||||
QTimer::singleShot(250, this, [&, viewId]() {
|
||||
m_wm->releaseMouseEventFor(viewId);
|
||||
});
|
||||
|
||||
emit draggingStarted();
|
||||
fromView->unblockMouse(localX, localY);
|
||||
}
|
||||
|
||||
void LastActiveWindow::requestToggleIsOnAllDesktops()
|
||||
|
@ -105,8 +105,6 @@ private slots:
|
||||
|
||||
|
||||
signals:
|
||||
void draggingStarted();
|
||||
|
||||
void iconChanged();
|
||||
void isActiveChanged();
|
||||
void isMinimizedChanged();
|
||||
|
@ -538,11 +538,6 @@ bool WaylandInterface::windowCanBeMaximized(WindowId wid) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void WaylandInterface::releaseMouseEventFor(WindowId wid) const
|
||||
{
|
||||
// this isnt really needed under wayland
|
||||
}
|
||||
|
||||
void WaylandInterface::requestActivate(WindowId wid) const
|
||||
{
|
||||
auto w = windowFor(wid);
|
||||
|
@ -76,8 +76,6 @@ public:
|
||||
void slideWindow(QWindow &view, Slide location) const override;
|
||||
void enableBlurBehind(QWindow &view) const override;
|
||||
|
||||
void releaseMouseEventFor(WindowId wid) const override;
|
||||
|
||||
void requestActivate(WindowId wid) const override;
|
||||
void requestClose(WindowId wid) const override;
|
||||
void requestMoveWindow(WindowId wid, QPoint from) const override;
|
||||
|
@ -424,28 +424,6 @@ bool XWindowInterface::windowCanBeMaximized(WindowId wid) const
|
||||
return false;
|
||||
}
|
||||
|
||||
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::requestActivate(WindowId wid) const
|
||||
{
|
||||
KWindowSystem::activateWindow(wid.toInt());
|
||||
|
@ -60,8 +60,6 @@ public:
|
||||
void slideWindow(QWindow &view, Slide location) const override;
|
||||
void enableBlurBehind(QWindow &view) const override;
|
||||
|
||||
void releaseMouseEventFor(WindowId wid) const override;
|
||||
|
||||
void requestActivate(WindowId wid) const override;
|
||||
void requestClose(WindowId wid) const override;
|
||||
void requestMoveWindow(WindowId wid, QPoint from) const override;
|
||||
|
@ -104,7 +104,6 @@ Loader {
|
||||
}
|
||||
|
||||
dragWindowTimer.stop();
|
||||
restoreGrabberTimer.stop();
|
||||
selectedWindowsTracker.lastActiveWindow.requestToggleMaximized();
|
||||
}
|
||||
|
||||
@ -148,9 +147,9 @@ Loader {
|
||||
}
|
||||
|
||||
function activateDragging(){
|
||||
latteView.disableGrabItemBehavior();
|
||||
selectedWindowsTracker.requestMoveLastWindow(mainArea.mouseX, mainArea.mouseY);
|
||||
restoreGrabberTimer.start();
|
||||
mainArea.lastPressX = -1;
|
||||
mainArea.lastPressY = -1;
|
||||
}
|
||||
|
||||
//! Timers
|
||||
@ -164,16 +163,6 @@ Loader {
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: restoreGrabberTimer
|
||||
interval: 50
|
||||
onTriggered: {
|
||||
latteView.restoreGrabItemBehavior();
|
||||
mainArea.lastPressX = -1;
|
||||
mainArea.lastPressY = -1;
|
||||
}
|
||||
}
|
||||
|
||||
states:[
|
||||
State {
|
||||
name: "bottom"
|
||||
|
Loading…
Reference in New Issue
Block a user