on xenial help sign in
displace windows when the OSK shows up
commit866d754255e6c7dd15e57a87262ee59271e9ce17 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 23 Jun 2016, 12:31 (10 years ago) parent8d03570
5 files changed+40−16
qml/Stages/DesktopStage.qml+13−2 qml/Stages/WindowDecoration.qml+2−2 qml/Stages/WindowResizeArea.qml+11−11 tests/mocks/Unity/Application/UbuntuKeyboardInfo.cpp+1−1 tests/qmltests/Stages/tst_DesktopStage.qml+13
qml/Stages/DesktopStage.qml+13−2
@@ -263,8 +263,19 @@ AbstractStage {
263263 }
264264 }
265265 z: normalZ
266− x: priv.focusedAppDelegate ? priv.focusedAppDelegate.x + units.gu(3) : (normalZ - 1) * units.gu(3)
267− y: priv.focusedAppDelegate ? priv.focusedAppDelegate.y + units.gu(3) : normalZ * units.gu(3)
266+ x: requestedX // may be overridden in some states. Do not directly write to this.
267+ y: requestedY // may be overridden in some states. Do not directly write to this.
268+ property real requestedX: priv.focusedAppDelegate ? priv.focusedAppDelegate.x + units.gu(3) : (normalZ - 1) * units.gu(3)
269+ property real requestedY: priv.focusedAppDelegate ? priv.focusedAppDelegate.y + units.gu(3) : normalZ * units.gu(3)
270+
271+ Binding {
272+ target: appDelegate
273+ property: "y"
274+ value: appDelegate.requestedY -
275+ Math.min(appDelegate.requestedY - PanelState.panelHeight,
276+ UbuntuKeyboardInfo.height)
277+ when: appDelegate.focus
278+ }
268279
269280 width: decoratedWindow.width
270281 height: decoratedWindow.height
qml/Stages/WindowDecoration.qml+2−2
@@ -65,8 +65,8 @@ MouseArea {
6565 // Use integer coordinate values to ensure that target is left in a pixel-aligned
6666 // position. Mouse movement could have subpixel precision, yielding a fractional
6767 // mouse position.
68− root.target.x = Math.round(pos.x - priv.distanceX);
69− root.target.y = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
68+ root.target.requestedX = Math.round(pos.x - priv.distanceX);
69+ root.target.requestedY = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
7070 }
7171 }
7272
qml/Stages/WindowResizeArea.qml+11−11
@@ -55,8 +55,8 @@ MouseArea {
5555
5656 function updateNormalGeometry() {
5757 if (root.target.state == "normal") {
58− normalX = root.target.x
59− normalY = root.target.y
58+ normalX = root.target.requestedX
59+ normalY = root.target.requestedY
6060 normalWidth = root.target.width
6161 normalHeight = root.target.height
6262 }
@@ -73,14 +73,14 @@ MouseArea {
7373
7474 function loadWindowState() {
7575 var windowGeometry = windowStateStorage.getGeometry(root.windowId,
76− Qt.rect(target.x, target.y, defaultWidth, defaultHeight));
76+ Qt.rect(target.requestedX, target.requestedY, defaultWidth, defaultHeight));
7777
7878 target.requestedWidth = Qt.binding(function() { return Math.min(Math.max(windowGeometry.width, d.minimumWidth), screenWidth - root.leftMargin); });
7979 target.requestedHeight = Qt.binding(function() { return Math.min(Math.max(windowGeometry.height, d.minimumHeight),
8080 root.screenHeight - (target.fullscreen ? 0 : PanelState.panelHeight)); });
81− target.x = Qt.binding(function() { return Math.max(Math.min(windowGeometry.x, root.screenWidth - root.leftMargin - target.requestedWidth),
81+ target.requestedX = Qt.binding(function() { return Math.max(Math.min(windowGeometry.x, root.screenWidth - root.leftMargin - target.requestedWidth),
8282 (target.fullscreen ? 0 : root.leftMargin)); });
83− target.y = Qt.binding(function() { return Math.max(Math.min(windowGeometry.y, root.screenHeight - target.requestedHeight), PanelState.panelHeight); });
83+ target.requestedY = Qt.binding(function() { return Math.max(Math.min(windowGeometry.y, root.screenHeight - target.requestedHeight), PanelState.panelHeight); });
8484
8585 var windowState = windowStateStorage.getState(root.windowId, WindowStateStorage.WindowStateNormal)
8686 switch (windowState) {
@@ -258,8 +258,8 @@ MouseArea {
258258 var pos = mapToItem(root.target.parent, mouseX, mouseY);
259259 d.startMousePosX = pos.x;
260260 d.startMousePosY = pos.y;
261− d.startX = target.x;
262− d.startY = target.y;
261+ d.startX = target.requestedX;
262+ d.startY = target.requestedY;
263263 d.startWidth = target.width;
264264 d.startHeight = target.height;
265265 d.currentWidth = target.width;
@@ -296,7 +296,7 @@ MouseArea {
296296
297297 if (d.leftBorder) {
298298 var newTargetX = d.startX + deltaX;
299− var rightBorderX = target.x + target.width;
299+ var rightBorderX = target.requestedX + target.width;
300300 if (rightBorderX > newTargetX + d.minimumWidth) {
301301 if (rightBorderX < newTargetX + d.maximumWidth) {
302302 target.requestedWidth = rightBorderX - newTargetX;
@@ -322,7 +322,7 @@ MouseArea {
322322
323323 if (d.topBorder) {
324324 var newTargetY = Math.max(d.startY + deltaY, PanelState.panelHeight); // disallow resizing up past Panel
325− var bottomBorderY = target.y + target.height;
325+ var bottomBorderY = target.requestedY + target.height;
326326 if (bottomBorderY > newTargetY + d.minimumHeight) {
327327 if (bottomBorderY < newTargetY + d.maximumHeight) {
328328 target.requestedHeight = bottomBorderY - newTargetY;
@@ -351,13 +351,13 @@ MouseArea {
351351 target: root.target
352352 onWidthChanged: {
353353 if (d.moveLeftBorder) {
354− target.x += d.currentWidth - target.width;
354+ target.requestedX += d.currentWidth - target.width;
355355 }
356356 d.currentWidth = target.width;
357357 }
358358 onHeightChanged: {
359359 if (d.moveTopBorder) {
360− target.y += d.currentHeight - target.height;
360+ target.requestedY += d.currentHeight - target.height;
361361 }
362362 d.currentHeight = target.height;
363363 }
tests/mocks/Unity/Application/UbuntuKeyboardInfo.cpp+1−1
@@ -21,7 +21,7 @@ UbuntuKeyboardInfo::UbuntuKeyboardInfo(QObject *parent)
2121 m_x(0),
2222 m_y(0),
2323 m_width(200),
24− m_height(200)
24+ m_height(0)
2525{
2626}
2727
tests/qmltests/Stages/tst_DesktopStage.qml+13
@@ -677,5 +677,18 @@ Item {
677677 var closeButton = findChild(dashAppDelegate, "closeWindowButton");
678678 tryCompare(closeButton, "visible", false);
679679 }
680+
681+ function test_oskDisplacesWindow() {
682+ var dashAppDelegate = startApplication("unity8-dash");
683+ verify(dashAppDelegate);
684+ var initialY = dashAppDelegate.y;
685+ verify(initialY > PanelState.panelHeight);
686+
687+ UbuntuKeyboardInfo.height = units.gu(10);
688+ tryCompare(dashAppDelegate, "y", PanelState.panelHeight);
689+
690+ UbuntuKeyboardInfo.height = 0;
691+ tryCompare(dashAppDelegate, "y", initialY);
692+ }
680693 }
681694}