~mzanetti/unity8/fix-1648251

« back to all changes in this revision

Viewing changes to qml/Stage/WindowResizeArea.qml

  • Committer: Michael Zanetti
  • Date: 2016-12-01 12:20:34 UTC
  • mfrom: (2525.1.179 unity8)
  • Revision ID: michael.zanetti@canonical.com-20161201122034-cpvbf7webbhg2wph
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
 
76
76
    function loadWindowState() {
77
77
        var windowGeometry = windowStateStorage.getGeometry(root.windowId,
78
 
                                                            Qt.rect(target.requestedX, target.requestedY, defaultWidth, defaultHeight));
79
 
 
80
 
        target.requestedWidth = Qt.binding(function() { return Math.min(Math.max(windowGeometry.width, d.minimumWidth), screenWidth - root.leftMargin); });
81
 
        target.requestedHeight = Qt.binding(function() { return Math.min(Math.max(windowGeometry.height, d.minimumHeight),
 
78
                                                            Qt.rect(target.windowedX, target.windowedY, defaultWidth, defaultHeight));
 
79
 
 
80
 
 
81
        target.windowedWidth = Qt.binding(function() { return Math.min(Math.max(windowGeometry.width, d.minimumWidth), screenWidth - root.leftMargin); });
 
82
        target.windowedHeight = Qt.binding(function() { return Math.min(Math.max(windowGeometry.height, d.minimumHeight),
82
83
                                                                         root.screenHeight - (target.fullscreen ? 0 : PanelState.panelHeight)); });
83
 
        target.requestedX = Qt.binding(function() { return Math.max(Math.min(windowGeometry.x, root.screenWidth - root.leftMargin - target.requestedWidth),
 
84
        target.windowedX = Qt.binding(function() { return Math.max(Math.min(windowGeometry.x, root.screenWidth - root.leftMargin - target.windowedWidth),
84
85
                                                           (target.fullscreen ? 0 : root.leftMargin)); });
85
 
        target.requestedY = Qt.binding(function() { return Math.max(Math.min(windowGeometry.y, root.screenHeight - target.requestedHeight), PanelState.panelHeight); });
 
86
        target.windowedY = Qt.binding(function() { return Math.max(Math.min(windowGeometry.y, root.screenHeight - target.windowedHeight), PanelState.panelHeight); });
86
87
 
87
88
        var windowState = windowStateStorage.getState(root.windowId, WindowStateStorage.WindowStateNormal)
88
89
        target.restore(false /* animated */, windowState);
111
112
 
112
113
        readonly property int minimumWidth: root.target ? Math.max(root.minWidth, root.target.minimumWidth) : root.minWidth
113
114
        onMinimumWidthChanged: {
114
 
            if (target.requestedWidth < minimumWidth) {
115
 
                target.requestedWidth = minimumWidth;
 
115
            if (target.windowedWidth < minimumWidth) {
 
116
                target.windowedWidth = minimumWidth;
116
117
            }
117
118
        }
118
119
        readonly property int minimumHeight: root.target ? Math.max(root.minHeight, root.target.minimumHeight) : root.minHeight
119
120
        onMinimumHeightChanged: {
120
 
            if (target.requestedHeight < minimumHeight) {
121
 
                target.requestedHeight = minimumHeight;
 
121
            if (target.windowedHeight < minimumHeight) {
 
122
                target.windowedHeight = minimumHeight;
122
123
            }
123
124
        }
124
125
        readonly property int maximumWidth: root.target && root.target.maximumWidth >= minimumWidth && root.target.maximumWidth > 0
125
126
            ? root.target.maximumWidth : maxSafeInt
126
127
        onMaximumWidthChanged: {
127
 
            if (target.requestedWidth > maximumWidth) {
128
 
                target.requestedWidth = maximumWidth;
 
128
            if (target.windowedWidth > maximumWidth) {
 
129
                target.windowedWidth = maximumWidth;
129
130
            }
130
131
        }
131
132
        readonly property int maximumHeight: root.target && root.target.maximumHeight >= minimumHeight && root.target.maximumHeight > 0
132
133
            ? root.target.maximumHeight : maxSafeInt
133
134
        onMaximumHeightChanged: {
134
 
            if (target.requestedHeight > maximumHeight) {
135
 
                target.requestedHeight = maximumHeight;
 
135
            if (target.windowedHeight > maximumHeight) {
 
136
                target.windowedHeight = maximumHeight;
136
137
            }
137
138
        }
138
139
        readonly property int widthIncrement: {
247
248
            var pos = mapToItem(root.target.parent, mouseX, mouseY);
248
249
            d.startMousePosX = pos.x;
249
250
            d.startMousePosY = pos.y;
250
 
            d.startX = target.requestedX;
251
 
            d.startY = target.requestedY;
 
251
            d.startX = target.windowedX;
 
252
            d.startY = target.windowedY;
252
253
            d.startWidth = target.width;
253
254
            d.startHeight = target.height;
254
255
            d.currentWidth = target.width;
285
286
 
286
287
        if (d.leftBorder) {
287
288
            var newTargetX = d.startX + deltaX;
288
 
            var rightBorderX = target.requestedX + target.width;
 
289
            var rightBorderX = target.windowedX + target.width;
289
290
            if (rightBorderX > newTargetX + d.minimumWidth) {
290
291
                if (rightBorderX  < newTargetX + d.maximumWidth) {
291
 
                    target.requestedWidth = rightBorderX - newTargetX;
 
292
                    target.windowedWidth = rightBorderX - newTargetX;
292
293
                } else {
293
 
                    target.requestedWidth = d.maximumWidth;
 
294
                    target.windowedWidth = d.maximumWidth;
294
295
                }
295
296
            } else {
296
 
                target.requestedWidth = d.minimumWidth;
 
297
                target.windowedWidth = d.minimumWidth;
297
298
            }
298
299
 
299
300
        } else if (d.rightBorder) {
300
301
            var newWidth = d.startWidth + deltaX;
301
302
            if (newWidth > d.minimumWidth) {
302
303
                if (newWidth < d.maximumWidth) {
303
 
                    target.requestedWidth = newWidth;
 
304
                    target.windowedWidth = newWidth;
304
305
                } else {
305
 
                    target.requestedWidth = d.maximumWidth;
 
306
                    target.windowedWidth = d.maximumWidth;
306
307
                }
307
308
            } else {
308
 
                target.requestedWidth = d.minimumWidth;
 
309
                target.windowedWidth = d.minimumWidth;
309
310
            }
310
311
        }
311
312
 
312
313
        if (d.topBorder) {
313
314
            var newTargetY = Math.max(d.startY + deltaY, PanelState.panelHeight); // disallow resizing up past Panel
314
 
            var bottomBorderY = target.requestedY + target.height;
 
315
            var bottomBorderY = target.windowedY + target.height;
315
316
            if (bottomBorderY > newTargetY + d.minimumHeight) {
316
317
                if (bottomBorderY < newTargetY + d.maximumHeight) {
317
 
                    target.requestedHeight = bottomBorderY - newTargetY;
 
318
                    target.windowedHeight = bottomBorderY - newTargetY;
318
319
                } else {
319
 
                    target.requestedHeight = d.maximumHeight;
 
320
                    target.windowedHeight = d.maximumHeight;
320
321
                }
321
322
            } else {
322
 
                target.requestedHeight = d.minimumHeight;
 
323
                target.windowedHeight = d.minimumHeight;
323
324
            }
324
325
 
325
326
        } else if (d.bottomBorder) {
326
327
            var newHeight = d.startHeight + deltaY;
327
328
            if (newHeight > d.minimumHeight) {
328
329
                if (newHeight < d.maximumHeight) {
329
 
                    target.requestedHeight = newHeight;
 
330
                    target.windowedHeight = newHeight;
330
331
                } else {
331
 
                    target.requestedHeight = d.maximumHeight;
 
332
                    target.windowedHeight = d.maximumHeight;
332
333
                }
333
334
            } else {
334
 
                target.requestedHeight = d.minimumHeight;
 
335
                target.windowedHeight = d.minimumHeight;
335
336
            }
336
337
        }
337
338
    }
340
341
        target: root.target
341
342
        onWidthChanged: {
342
343
            if (d.moveLeftBorder) {
343
 
                target.requestedX += d.currentWidth - target.width;
 
344
                target.windowedX += d.currentWidth - target.width;
344
345
            }
345
346
            d.currentWidth = target.width;
346
347
        }
347
348
        onHeightChanged: {
348
349
            if (d.moveTopBorder) {
349
 
                target.requestedY += d.currentHeight - target.height;
 
350
                target.windowedY += d.currentHeight - target.height;
350
351
            }
351
352
            d.currentHeight = target.height;
352
353
        }