blob: 33e147870c1cc970fec49ed33495ad37ec58f9e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright (C) 2017 The Qt Company Ltd.
// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtWayland.Compositor
Item {
id: chrome
property alias shellSurface: surfaceItem.shellSurface
property alias surfaceItem: surfaceItem
property alias moveItem: surfaceItem.moveItem
//! [position sync]
x: surfaceItem.moveItem.x - surfaceItem.output.geometry.x
y: surfaceItem.moveItem.y - surfaceItem.output.geometry.y
//! [position sync]
ShellSurfaceItem {
id: surfaceItem
onSurfaceDestroyed: chrome.destroy();
}
onXChanged: updatePrimary()
onYChanged: updatePrimary()
function updatePrimary() {
var w = surfaceItem.width
var h = surfaceItem.height
var area = w * h;
var screenW = surfaceItem.output.geometry.width;
var screenH = surfaceItem.output.geometry.height;
var x1 = Math.max(0, x);
var y1 = Math.max(0, y);
var x2 = Math.min(x + w, screenW);
var y2 = Math.min(y + h, screenH);
var w1 = Math.max(0, x2 - x1);
var h1 = Math.max(0, y2 - y1);
if (w1 * h1 * 2 > area) {
surfaceItem.setPrimary();
}
}
}
|