Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[rotation] fix ScreenGestureArea when rotating
  • Loading branch information
filippz committed Nov 17, 2014
1 parent 17859ef commit f57c736
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/qml/compositor/ScreenGestureArea.qml
Expand Up @@ -21,6 +21,7 @@
// SOFTWARE.

import QtQuick 2.0
import org.nemomobile.lipstick 0.1

MouseArea {
id: root
Expand All @@ -42,36 +43,44 @@ MouseArea {

// Internal
property int _mouseStart
property Item _mapTo: Lipstick.compositor.topmostWindow.window

function mouseToMouseReal(m) {
return mapToItem(_mapTo, m.x, m.y)
}

onPressed: {
if (mouse.x < boundary) {
var mouseReal = mouseToMouseReal(mouse)

if (mouseReal.x < boundary) {
gesture = "right"
max = width - mouse.x
} else if (width - mouse.x < boundary) {
max = _mapTo.width - mouseReal.x
} else if (_mapTo.width - mouseReal.x < boundary) {
gesture = "left"
max = mouse.x
} else if (mouse.y < boundary) {
max = mouseReal.x
} else if (mouseReal.y < boundary) {
gesture = "down"
max = height - mouse.y
} else if (height - mouse.y < boundary) {
max = _mapTo.height - mouseReal.y
} else if (_mapTo.height - mouseReal.y < boundary) {
gesture = "up"
max = mouse.y
max = mouseReal.y
} else {
mouse.accepted = false
return
}

value = 0
if (horizontal)
_mouseStart = mouse.x
_mouseStart = mouseReal.x
else
_mouseStart = mouse.y
_mouseStart = mouseReal.y

gestureStarted(gesture)
}

onPositionChanged: {
var p = horizontal ? mouse.x : mouse.y
var mouseReal = mouseToMouseReal(mouse)
var p = horizontal ? mouseReal.x : mouseReal.y
value = Math.max(Math.min(p - _mouseStart, max), -max)
}

Expand Down

0 comments on commit f57c736

Please sign in to comment.