mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-09 17:18:11 +03:00
drag active window when moving mouse fast
--when the user trys to drag the active window from panel and moves the mouse fast dragging starts immediately without waiting the drag timer to end.
This commit is contained in:
parent
6e91a5aae6
commit
a14c265006
@ -30,6 +30,9 @@ MouseArea{
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
|
||||
property int lastPressX: -1
|
||||
property int lastPressY: -1
|
||||
|
||||
onContainsMouseChanged: {
|
||||
if (mouseInHoverableArea()) {
|
||||
stopCheckRestoreZoomTimer();
|
||||
@ -41,24 +44,48 @@ MouseArea{
|
||||
|
||||
onPressed: {
|
||||
if (dock.visibility.activeWindowCanBeDragged()) {
|
||||
lastPressX = mouse.x;
|
||||
lastPressY = mouse.y;
|
||||
drawWindowTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
lastPressX = -1;
|
||||
lastPressY = -1;
|
||||
}
|
||||
|
||||
onPositionChanged: {
|
||||
var stepX = Math.abs(lastPressX-mouse.x);
|
||||
var stepY = Math.abs(lastPressY-mouse.y);
|
||||
var threshold = 5;
|
||||
|
||||
var tryDrag = mainArea.pressed && (stepX>threshold || stepY>threshold);
|
||||
|
||||
if ( tryDrag && dock.visibility.activeWindowCanBeDragged()) {
|
||||
drawWindowTimer.stop();
|
||||
activateDragging();
|
||||
}
|
||||
}
|
||||
|
||||
onDoubleClicked: {
|
||||
drawWindowTimer.stop();
|
||||
restoreGrabberTimer.stop();
|
||||
tasksModel.requestToggleMaximized(tasksModel.activeTask);
|
||||
}
|
||||
|
||||
function activateDragging(){
|
||||
dock.disableGrabItemBehavior();
|
||||
dock.visibility.requestMoveActiveWindow(mainArea.mouseX, mainArea.mouseY);
|
||||
restoreGrabberTimer.start();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: drawWindowTimer
|
||||
interval: 350
|
||||
interval: 500
|
||||
onTriggered: {
|
||||
if (mainArea.pressed && dock.visibility.activeWindowCanBeDragged()) {
|
||||
dock.disableGrabItemBehavior();
|
||||
dock.visibility.requestMoveActiveWindow(mainArea.mouseX, mainArea.mouseY);
|
||||
restoreGrabberTimer.start();
|
||||
mainArea.activateDragging();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,6 +95,8 @@ MouseArea{
|
||||
interval: 50
|
||||
onTriggered: {
|
||||
dock.restoreGrabItemBehavior();
|
||||
mainArea.lastPressX = -1;
|
||||
mainArea.lastPressY = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user