on xenial help sign in
add workspaces snapshotting through a shader effect
commit35fe40404f825656e448f320d99001645f14e4de authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 21 Apr 2015, 15:41 (12 years ago) parentec403a5
1 file changed+39−8
qml/Stages/DesktopStage.qml+39−8
qml/Stages/DesktopStage.qml+39−8
@@ -124,6 +124,8 @@ FocusScope {
124124 }
125125
126126 Item {
127+ id: appContainer
128+ anchors.fill: parent
127129 Repeater {
128130 id: appRepeater
129131 model: ApplicationManager
@@ -157,7 +159,7 @@ FocusScope {
157159 PropertyChanges { target: appDelegate; x: -appDelegate.width / 2; scale: units.gu(5) / appDelegate.width; opacity: 0 }
158160 },
159161 State {
160− name: "altTab"; when: root.state == "altTab"
162+ name: "altTab"; when: root.state == "altTab" && root.workspacesUpdated
161163 PropertyChanges {
162164 target: appDelegate
163165 x: spreadMaths.animatedX
@@ -351,7 +353,8 @@ FocusScope {
351353 }
352354 height: root.height * 0.25
353355 color: "#55000000"
354− opacity: 0
356+// opacity: 0
357+ visible: false
355358
356359 RowLayout {
357360 anchors.fill: parent
@@ -362,14 +365,33 @@ FocusScope {
362365 Item {
363366 Layout.fillHeight: true
364367 Layout.preferredWidth: ((height - units.gu(6)) * root.width / root.height)
365−
366368 Image {
369+ source: root.background
367370 anchors {
368371 fill: parent;
369372 topMargin: units.gu(2);
370373 bottomMargin: units.gu(2);
371374 }
372− source: root.background
375+
376+ ShaderEffect {
377+ anchors.fill: parent
378+
379+ property var source: ShaderEffectSource {
380+ id: shaderEffectSource
381+ live: false
382+ sourceItem: appContainer
383+ Connections { target: root; onUpdateWorkspaces: shaderEffectSource.scheduleUpdate() }
384+ }
385+
386+ fragmentShader: "
387+ varying highp vec2 qt_TexCoord0;
388+ uniform sampler2D source;
389+ void main(void)
390+ {
391+ highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
392+ gl_FragColor = sourceColor;
393+ }"
394+ }
373395 }
374396
375397 Rectangle {
@@ -421,24 +443,33 @@ FocusScope {
421443 },
422444 State {
423445 name: "altTab"; when: root.altTabPressed
446+ PropertyChanges { target: workspaceSelector; visible: true }
424447 PropertyChanges { target: spreadFlickable; visible: true }
425− PropertyChanges { target: workspaceSelector; opacity: 1 }
426448 }
427449 ]
450+ signal updateWorkspaces();
451+ property bool workspacesUpdated: false
428452 transitions: [
429453 Transition {
430454 from: "*"
431455 to: "altTab"
432− PropertyAction { target: spreadFlickable; property: "contentX";
433− value: ((spreadFlickable.contentWidth) / (ApplicationManager.count + 1)) * Math.max(0, Math.min(ApplicationManager.count - 3, 1));
456+ SequentialAnimation {
457+ PropertyAction { target: workspaceSelector; property: "visible" }
458+ ScriptAction { script: root.updateWorkspaces() }
459+ PauseAnimation { duration: 50 }
460+ PropertyAction { target: root; property: "workspacesUpdated"; value: true }
461+ PropertyAction { target: spreadFlickable; property: "visible" }
462+ PropertyAction { target: spreadFlickable; property: "contentX";
463+ value: ((spreadFlickable.contentWidth) / (ApplicationManager.count + 1)) * Math.max(0, Math.min(ApplicationManager.count - 3, 1));
434464
465+ }
435466 }
436− PropertyAnimation { property: "opacity" }
437467 },
438468 Transition {
439469 from: "*"
440470 to: "*"
441471 PropertyAnimation { property: "opacity" }
472+ PropertyAction { target: root; property: "workspacesUpdated"; value: false }
442473 }
443474
444475 ]