~saviq/unity8/build-arm64

« back to all changes in this revision

Viewing changes to qml/Stages/DesktopStage.qml

  • Committer: Michał Sawicz
  • Date: 2016-07-15 09:51:02 UTC
  • mfrom: (2400.1.142 unity8)
  • Revision ID: michal.sawicz@canonical.com-20160715095102-hf5ac4iqnfn1itpw
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
    GlobalShortcut {
91
91
        id: minimizeRestoreShortcut
92
92
        shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Down
93
 
        onTriggered: priv.focusedAppDelegate.maximized || priv.focusedAppDelegate.maximizedLeft || priv.focusedAppDelegate.maximizedRight
 
93
        onTriggered: priv.focusedAppDelegate.maximized || priv.focusedAppDelegate.maximizedLeft || priv.focusedAppDelegate.maximizedRight ||
 
94
                     priv.focusedAppDelegate.maximizedHorizontally || priv.focusedAppDelegate.maximizedVertically
94
95
                     ? priv.focusedAppDelegate.restoreFromMaximized() : priv.focusedAppDelegate.minimize()
95
96
        active: priv.focusedAppDelegate !== null
96
97
    }
159
160
 
160
161
    Connections {
161
162
        target: PanelState
162
 
        onClose: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
163
 
        onMinimize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
164
 
        onMaximize: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
 
163
        onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
 
164
        onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
 
165
        onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
165
166
        onFocusMaximizedApp: {
166
167
            if (priv.foregroundMaximizedAppDelegate) {
167
168
                priv.foregroundMaximizedAppDelegate.focus = true;
262
263
                    }
263
264
                }
264
265
                z: normalZ
265
 
                x: priv.focusedAppDelegate ? priv.focusedAppDelegate.x + units.gu(3) : (normalZ - 1) * units.gu(3)
266
 
                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
                                    Math.max(0, UbuntuKeyboardInfo.height - (appContainer.height - (appDelegate.requestedY + appDelegate.height))))
 
277
                    when: root.oskEnabled && appDelegate.focus && appDelegate.state == "normal"
 
278
                          && SurfaceManager.inputMethodSurface
 
279
                          && SurfaceManager.inputMethodSurface.state != Mir.HiddenState
 
280
                          && SurfaceManager.inputMethodSurface.state != Mir.MinimizedState
 
281
 
 
282
                }
267
283
 
268
284
                width: decoratedWindow.width
269
285
                height: decoratedWindow.height
 
286
 
 
287
                Connections {
 
288
                    target: root
 
289
                    onShellOrientationAngleChanged: {
 
290
                        // at this point decoratedWindow.surfaceOrientationAngle is the old shellOrientationAngle
 
291
                        if (application && application.rotatesWindowContents) {
 
292
                            if (state == "normal") {
 
293
                                var angleDiff = decoratedWindow.surfaceOrientationAngle - shellOrientationAngle;
 
294
                                angleDiff = (360 + angleDiff) % 360;
 
295
                                if (angleDiff === 90 || angleDiff === 270) {
 
296
                                    var aux = decoratedWindow.requestedHeight;
 
297
                                    decoratedWindow.requestedHeight = decoratedWindow.requestedWidth + decoratedWindow.visibleDecorationHeight;
 
298
                                    decoratedWindow.requestedWidth = aux - decoratedWindow.visibleDecorationHeight;
 
299
                                }
 
300
                            }
 
301
                            decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
 
302
                        } else {
 
303
                            decoratedWindow.surfaceOrientationAngle = 0;
 
304
                        }
 
305
                    }
 
306
                }
 
307
 
 
308
                readonly property alias application: decoratedWindow.application
 
309
                readonly property alias minimumWidth: decoratedWindow.minimumWidth
 
310
                readonly property alias minimumHeight: decoratedWindow.minimumHeight
 
311
                readonly property alias maximumWidth: decoratedWindow.maximumWidth
 
312
                readonly property alias maximumHeight: decoratedWindow.maximumHeight
 
313
                readonly property alias widthIncrement: decoratedWindow.widthIncrement
 
314
                readonly property alias heightIncrement: decoratedWindow.heightIncrement
270
315
                property int requestedWidth: -1
271
316
                property int requestedHeight: -1
272
 
                property alias minimumWidth: decoratedWindow.minimumWidth
273
 
                property alias minimumHeight: decoratedWindow.minimumHeight
274
 
                property alias maximumWidth: decoratedWindow.maximumWidth
275
 
                property alias maximumHeight: decoratedWindow.maximumHeight
276
 
                property alias widthIncrement: decoratedWindow.widthIncrement
277
 
                property alias heightIncrement: decoratedWindow.heightIncrement
278
317
 
279
 
                QtObject {
280
 
                    id: appDelegatePrivate
281
 
                    property bool maximized: false
282
 
                    property bool maximizedLeft: false
283
 
                    property bool maximizedRight: false
284
 
                    property bool minimized: false
285
 
                }
286
 
                readonly property alias maximized: appDelegatePrivate.maximized
287
 
                readonly property alias maximizedLeft: appDelegatePrivate.maximizedLeft
288
 
                readonly property alias maximizedRight: appDelegatePrivate.maximizedRight
289
 
                readonly property alias minimized: appDelegatePrivate.minimized
 
318
                readonly property bool maximized: windowState & WindowStateStorage.WindowStateMaximized
 
319
                readonly property bool maximizedLeft: windowState & WindowStateStorage.WindowStateMaximizedLeft
 
320
                readonly property bool maximizedRight: windowState & WindowStateStorage.WindowStateMaximizedRight
 
321
                readonly property bool maximizedHorizontally: windowState & WindowStateStorage.WindowStateMaximizedHorizontally
 
322
                readonly property bool maximizedVertically: windowState & WindowStateStorage.WindowStateMaximizedVertically
 
323
                readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
290
324
                readonly property alias fullscreen: decoratedWindow.fullscreen
291
325
 
292
 
                readonly property var application: model.application
 
326
                property int windowState: WindowStateStorage.WindowStateNormal
293
327
                property bool animationsEnabled: true
294
328
                property alias title: decoratedWindow.title
295
329
                readonly property string appName: model.application ? model.application.name : ""
297
331
                property bool visuallyMinimized: false
298
332
 
299
333
                readonly property var surface: model.surface
 
334
                readonly property alias resizeArea: resizeArea
300
335
 
301
336
                function claimFocus() {
302
337
                    if (spread.state == "altTab") {
326
361
                        return;
327
362
 
328
363
                    if (focus) {
329
 
                        priv.focusedAppDelegate = appDelegate;
330
 
 
331
364
                        // If we're orphan (!parent) it means this stage is no longer the current one
332
365
                        // and will be deleted shortly. So we should no longer have a say over the model
333
366
                        if (root.parent) {
334
367
                            topLevelSurfaceList.raiseId(model.id);
335
368
                        }
 
369
 
 
370
                        priv.focusedAppDelegate = appDelegate;
336
371
                    } else if (!focus && priv.focusedAppDelegate === appDelegate) {
337
372
                        priv.focusedAppDelegate = null;
338
373
                        // FIXME: No idea why the Binding{} doens't update when focusedAppDelegate turns null
340
375
                    }
341
376
                }
342
377
                Component.onCompleted: {
 
378
                    if (application && application.rotatesWindowContents) {
 
379
                        decoratedWindow.surfaceOrientationAngle = shellOrientationAngle;
 
380
                    } else {
 
381
                        decoratedWindow.surfaceOrientationAngle = 0;
 
382
                    }
 
383
 
343
384
                    // NB: We're differentiating if this delegate was created in response to a new entry in the model
344
385
                    //     or if the Repeater is just populating itself with delegates to match the model it received.
345
386
                    if (!appRepeater.startingUp) {
386
427
 
387
428
                function maximize(animated) {
388
429
                    animationsEnabled = (animated === undefined) || animated;
389
 
                    appDelegatePrivate.minimized = false;
390
 
                    appDelegatePrivate.maximized = true;
391
 
                    appDelegatePrivate.maximizedLeft = false;
392
 
                    appDelegatePrivate.maximizedRight = false;
393
 
                }
394
 
                function maximizeLeft() {
395
 
                    appDelegatePrivate.minimized = false;
396
 
                    appDelegatePrivate.maximized = false;
397
 
                    appDelegatePrivate.maximizedLeft = true;
398
 
                    appDelegatePrivate.maximizedRight = false;
399
 
                }
400
 
                function maximizeRight() {
401
 
                    appDelegatePrivate.minimized = false;
402
 
                    appDelegatePrivate.maximized = false;
403
 
                    appDelegatePrivate.maximizedLeft = false;
404
 
                    appDelegatePrivate.maximizedRight = true;
 
430
                    windowState = WindowStateStorage.WindowStateMaximized;
 
431
                }
 
432
                function maximizeLeft(animated) {
 
433
                    animationsEnabled = (animated === undefined) || animated;
 
434
                    windowState = WindowStateStorage.WindowStateMaximizedLeft;
 
435
                }
 
436
                function maximizeRight(animated) {
 
437
                    animationsEnabled = (animated === undefined) || animated;
 
438
                    windowState = WindowStateStorage.WindowStateMaximizedRight;
 
439
                }
 
440
                function maximizeHorizontally(animated) {
 
441
                    animationsEnabled = (animated === undefined) || animated;
 
442
                    windowState = WindowStateStorage.WindowStateMaximizedHorizontally;
 
443
                }
 
444
                function maximizeVertically(animated) {
 
445
                    animationsEnabled = (animated === undefined) || animated;
 
446
                    windowState = WindowStateStorage.WindowStateMaximizedVertically;
405
447
                }
406
448
                function minimize(animated) {
407
449
                    animationsEnabled = (animated === undefined) || animated;
408
 
                    appDelegatePrivate.minimized = true;
 
450
                    windowState |= WindowStateStorage.WindowStateMinimized; // add the minimized bit
409
451
                }
410
452
                function restoreFromMaximized(animated) {
411
453
                    animationsEnabled = (animated === undefined) || animated;
412
 
                    appDelegatePrivate.minimized = false;
413
 
                    appDelegatePrivate.maximized = false;
414
 
                    appDelegatePrivate.maximizedLeft = false;
415
 
                    appDelegatePrivate.maximizedRight = false;
 
454
                    windowState = WindowStateStorage.WindowStateNormal;
416
455
                }
417
456
                function restore(animated) {
418
457
                    animationsEnabled = (animated === undefined) || animated;
419
 
                    appDelegatePrivate.minimized = false;
 
458
                    windowState &= ~WindowStateStorage.WindowStateMinimized; // clear the minimized bit
420
459
                    if (maximized)
421
460
                        maximize();
422
461
                    else if (maximizedLeft)
423
462
                        maximizeLeft();
424
463
                    else if (maximizedRight)
425
464
                        maximizeRight();
 
465
                    else if (maximizedHorizontally)
 
466
                        maximizeHorizontally();
 
467
                    else if (maximizedVertically)
 
468
                        maximizeVertically();
426
469
 
427
470
                    focus = true;
428
471
                }
445
488
                        name: "fullscreen"; when: decoratedWindow.fullscreen && !appDelegate.minimized
446
489
                        PropertyChanges {
447
490
                            target: appDelegate;
448
 
                            x: 0;
449
 
                            y: -PanelState.panelHeight
 
491
                            x: rotation == 0 ? 0 : (parent.width - width) / 2 + (shellOrientationAngle == 90 ? -PanelState.panelHeight : PanelState.panelHeight)
 
492
                            y: rotation == 0 ? -PanelState.panelHeight : (parent.height - height) / 2
450
493
                            requestedWidth: appContainer.width;
451
494
                            requestedHeight: appContainer.height;
452
495
                        }
453
496
                    },
454
497
                    State {
455
498
                        name: "normal";
456
 
                        when: !appDelegate.maximized && !appDelegate.minimized
457
 
                              && !appDelegate.maximizedLeft && !appDelegate.maximizedRight
 
499
                        when: appDelegate.windowState == WindowStateStorage.WindowStateNormal
458
500
                        PropertyChanges {
459
501
                            target: appDelegate;
460
502
                            visuallyMinimized: false;
503
545
                        }
504
546
                    },
505
547
                    State {
 
548
                        name: "maximizedHorizontally"; when: appDelegate.maximizedHorizontally && !appDelegate.minimized
 
549
                        PropertyChanges { target: appDelegate; x: root.leftMargin }
 
550
                        PropertyChanges { target: decoratedWindow; requestedWidth: appContainer.width - root.leftMargin }
 
551
                    },
 
552
                    State {
 
553
                        name: "maximizedVertically"; when: appDelegate.maximizedVertically && !appDelegate.minimized
 
554
                        PropertyChanges { target: appDelegate; y: PanelState.panelHeight }
 
555
                        PropertyChanges { target: decoratedWindow; requestedHeight: appContainer.height - PanelState.panelHeight }
 
556
                    },
 
557
                    State {
506
558
                        name: "minimized"; when: appDelegate.minimized
507
559
                        PropertyChanges {
508
560
                            target: appDelegate;
509
561
                            x: -appDelegate.width / 2;
510
562
                            scale: units.gu(5) / appDelegate.width;
511
 
                            opacity: 0
 
563
                            opacity: 0;
512
564
                            visuallyMinimized: true;
513
565
                            visuallyMaximized: false
514
566
                        }
564
616
                    when: index == spread.highlightedIndex && spread.ready
565
617
                }
566
618
 
 
619
                Binding {
 
620
                    target: PanelState
 
621
                    property: "buttonsAlwaysVisible"
 
622
                    value: appDelegate && appDelegate.maximized && touchControls.overlayShown
 
623
                }
 
624
 
567
625
                WindowResizeArea {
568
626
                    id: resizeArea
569
627
                    objectName: "windowResizeArea"
 
628
 
 
629
                    // workaround so that it chooses the correct resize borders when you drag from a corner ResizeGrip
 
630
                    anchors.margins: touchControls.overlayShown ? borderThickness/2 : -borderThickness
 
631
 
570
632
                    target: appDelegate
571
633
                    minWidth: units.gu(10)
572
634
                    minHeight: units.gu(10)
607
669
                    surface: model.surface
608
670
                    active: appDelegate.focus
609
671
                    focus: true
 
672
                    maximizeButtonShown: (maximumWidth == 0 || maximumWidth >= appContainer.width) &&
 
673
                                         (maximumHeight == 0 || maximumHeight >= appContainer.height)
 
674
                    overlayShown: touchControls.overlayShown
610
675
 
611
676
                    requestedWidth: appDelegate.requestedWidth
612
677
                    requestedHeight: appDelegate.requestedHeight
613
678
 
614
 
                    onClose: { appDelegate.close(); }
615
 
                    onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
616
 
                                ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
617
 
                    onMinimize: appDelegate.minimize()
 
679
                    onCloseClicked: { appDelegate.close(); }
 
680
                    onMaximizeClicked: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
 
681
                                       || appDelegate.maximizedHorizontally || appDelegate.maximizedVertically
 
682
                                       ? appDelegate.restoreFromMaximized() : appDelegate.maximize()
 
683
                    onMaximizeHorizontallyClicked: appDelegate.maximizedHorizontally ? appDelegate.restoreFromMaximized() : appDelegate.maximizeHorizontally()
 
684
                    onMaximizeVerticallyClicked: appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
 
685
                    onMinimizeClicked: appDelegate.minimize()
618
686
                    onDecorationPressed: { appDelegate.focus = true; }
619
687
                }
620
688
 
 
689
                WindowControlsOverlay {
 
690
                    id: touchControls
 
691
                    anchors.fill: appDelegate
 
692
                    target: appDelegate
 
693
                }
 
694
 
621
695
                WindowedFullscreenPolicy {
622
696
                    id: fullscreenPolicy
623
697
                    active: true
650
724
        }
651
725
    }
652
726
 
653
 
    DirectionalDragArea {
 
727
    SwipeArea {
654
728
        direction: Direction.Leftwards
655
729
        anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
656
730
        width: units.gu(1)