This repository has been archived by the owner on Apr 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.qml
111 lines (96 loc) · 3.42 KB
/
main.qml
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import QtQuick 2.4
import QtQuick.Window 2.2
import QtGraphicalEffects 1.0
import Compositor 1.0
Item {
id: root
Component {
id: windowComponent
Item {
id: windowRoot
property var clientWindow
x: clientWindow.geometry.x
y: clientWindow.geometry.y
width: windowPixmap.implicitWidth
height: windowPixmap.implicitHeight
opacity: 0
scale: 0
z: clientWindow.zIndex
Component.onCompleted: {
opacity = Qt.binding(function() { return clientWindow.mapped ? 1 : 0 })
scale = Qt.binding(function() { return clientWindow.mapped ? 1 : 0 })
}
Connections {
target: windowRoot.clientWindow
onInvalidated: {
windowRoot.destroy(1000)
}
onWmTypeChanged: {
console.log(wmType)
}
}
Behavior on opacity {
OpacityAnimator { }
}
Behavior on scale {
ScaleAnimator { }
}
RectangularGlow {
cached: true
color: "black"
opacity: 0.5
glowRadius: 10
anchors.fill: parent
anchors.leftMargin: -glowRadius / 4
anchors.topMargin: -glowRadius / 4
anchors.rightMargin: -glowRadius
anchors.bottomMargin: -glowRadius
}
WindowPixmap {
id: windowPixmap
clientWindow: windowRoot.clientWindow
visible: !dimEffect.visible
}
property bool normalWindow: clientWindow.wmType === ClientWindow.NONE ||
clientWindow.wmType === ClientWindow.UNKNOWN ||
clientWindow.wmType === ClientWindow.NORMAL ||
clientWindow.wmType === ClientWindow.DIALOG
property bool noDim: clientWindow.overrideRedirect ||
clientWindow.transient ||
!normalWindow ||
!compositor.activeWindow
property bool activeWindow: compositor.activeWindow === clientWindow
property bool dim: !noDim && !activeWindow
BrightnessContrast {
id: dimEffect
brightness: dim ? -0.5 : 0
source: windowPixmap
anchors.fill: source
visible: brightness != 0
cached: true
Behavior on brightness {
NumberAnimation { }
}
}
}
}
Connections {
target: compositor
function createWindow(clientWindow) {
windowComponent.createObject(root, { clientWindow: clientWindow })
}
onWindowCreated: {
if (clientWindow.mapped) {
createWindow(clientWindow)
} else {
var handler = (function (mapped) {
if (mapped) {
this.mapStateChanged.disconnect(handler)
createWindow(this)
}
}).bind(clientWindow)
clientWindow.mapStateChanged.connect(handler)
}
}
}
}