[Interest] MouseArea failed to handle onPositionChanged to a frameless ApplicationWindow in Qt 5.2.1

Rutledge Shawn Shawn.Rutledge at digia.com
Wed May 7 09:47:13 CEST 2014


On 7 May 2014, at 8:52 AM, Leslie Zhai wrote:

> Hi Rutledge,
> 
> Thanks for your reply :)
> 
> It is might be the WINDOW MANAGER issue, for example, KWin (the KDE`s) is not able to handle QML frameless Window correctly, when you drag the window title over the borders (for example, over the top of screen)

Yes, it looks like KWin doesn't allow any part of the window to go outside the edge of the desktop, and it's the same with gnome 3, even though you can drag the window by its titlebar such that part of the window goes outside.  OpenBox does allow it.  I'm not sure if we can force it somehow on window managers which don't.  I wish we could, because it enables slide-out windows without needing to resize them on the fly.

Being able to do this is also uncertain on wayland, BTW; last time I tried I was not able to drag the window this way at all, but I don't understand yet if that's a bug or is intentional.

Is that the only issue that you've found?

> 
> Regards,
> Leslie Zhai <xiang.zhai at i-soft.com.cn>
> 
>> On 7 May 2014, at 4:50 AM, Leslie Zhai wrote:
>> 
>>> Hi qt developers,
>>> 
>>> I use MouseArea to act like DragArea to move the frameless
>>> ApplicationWindow in Qt5.2.1
>>> https://github.com/AOSC-Dev/QJade/blob/master/qml/DragArea.qml#L17
>>> 
>>> But Window Cannot Be Moved Over the Borders the Screen
>>> https://github.com/AOSC-Dev/QJade/issues/5
>>> 
>>> Please someone show me how to fix it, thanks a lot!
>> I was testing that a couple of years ago, as follows:
>> 
>> import QtQuick 2.1
>> import QtQuick.Window 2.0
>> 
>> Window {
>>     id: window
>>     visible: true
>>     width: 100
>>     height: 100
>>     flags: Qt.FramelessWindowHint
>> 
>>     Rectangle {
>>         color: "steelblue"
>>         anchors.top: parent.top
>>         width: parent.width
>>         height: 20
>>         MouseArea {
>>             anchors.fill: parent
>>             property real lastMouseX: 0
>>             property real lastMouseY: 0
>>             onPressed: {
>>                 lastMouseX = mouseX
>>                 lastMouseY = mouseY
>>             }
>>             onMouseXChanged: window.x += (mouseX - lastMouseX)
>>             onMouseYChanged: window.y += (mouseY - lastMouseY)
>>         }
>>     }
>> }
>> 
>> I can drag this across both monitors on a dual-head system, either OSX or Linux; and if I wrap your code into a standalone test, it also works:
>> 
>> import QtQuick 2.2
>> import QtQuick.Window 2.1
>> 
>> Window {
>>     id: rootWindow
>>     visible: true
>>     width: 100
>>     height: 100
>>     MouseArea {
>>         cursorShape: Qt.ArrowCursor
>>         anchors.fill: parent
>> 
>>         property variant clickPos: "1, 1"
>> 
>>         onPressed: {
>>             cursorShape = Qt.SizeAllCursor
>>             clickPos = Qt.point(mouse.x, mouse.y)
>>         }
>> 
>>         onPositionChanged: {
>>             var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y)
>>             rootWindow.x += delta.x
>>             rootWindow.y += delta.y
>>         }
>> 
>>         onExited: cursorShape = Qt.ArrowCursor
>>     }
>> }
>> 
> 




More information about the Interest mailing list