diff --git a/docs/changelog.md b/docs/changelog.md index b21eee1..efb1715 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,6 +5,14 @@ SPDX-License-Identifier: CC-BY-4.0 # Changelog of the Desktop Cube Extension +## [unreleased] + +**Release Date:** TBD + +#### Bug Fixes + +- Fixed a crash on GNOME 46 when using background panoramas. + ## [Desktop Cube 23 [backport release]](https://github.com/schneegans/Desktop-Cube/releases/tag/v23) **Release Date:** 2024-02-27 diff --git a/src/Skybox.js b/src/Skybox.js index 8b5145b..022c881 100644 --- a/src/Skybox.js +++ b/src/Skybox.js @@ -14,6 +14,7 @@ import Gio from 'gi://Gio'; import Clutter from 'gi://Clutter'; import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; import GdkPixbuf from 'gi://GdkPixbuf'; import Cogl from 'gi://Cogl'; @@ -39,7 +40,7 @@ var SkyboxEffect = GObject.registerClass({ 'pitch': GObject.ParamSpec.double('pitch', 'pitch', 'pitch', GObject.ParamFlags.READWRITE, -0.5 * Math.PI, 0.5 * Math.PI, 0), }, -}, class SkyboxEffect extends Clutter.Effect { + }, class SkyboxEffect extends Shell.GLSLEffect { // clang-format on _init(file) { super._init(); @@ -59,16 +60,14 @@ var SkyboxEffect = GObject.registerClass({ // Redraw if either the pitch or the yaw changes. this.connect('notify::yaw', () => {this.queue_repaint()}); this.connect('notify::pitch', () => {this.queue_repaint()}); + }; - const backend = Clutter.get_default_backend(); - const coglContext = backend.get_cogl_context(); - - this._pipeline = new Cogl.Pipeline(coglContext); + // This is called once to setup the Cogl.Pipeline. + vfunc_build_pipeline() { // In the vertex shader, we compute the view space position of the actor's corners. - this._pipeline.add_snippet( - Cogl.Snippet.new(Cogl.SnippetHook.VERTEX, 'varying vec4 vsPos;', - 'vsPos = cogl_modelview_matrix * cogl_position_in;')); + this.add_glsl_snippet(Shell.SnippetHook.VERTEX, 'varying vec4 vsPos;', + 'vsPos = cogl_modelview_matrix * cogl_position_in;', false); const fragmentDeclares = ` varying vec4 vsPos; @@ -103,28 +102,19 @@ var SkyboxEffect = GObject.registerClass({ cogl_color_out = texture2D(uTexture, vec2(x, y)); `; - this._pipeline.add_snippet( - Cogl.Snippet.new(Cogl.SnippetHook.FRAGMENT, fragmentDeclares, fragmentCode)); - }; + this.add_glsl_snippet(Shell.SnippetHook.FRAGMENT, fragmentDeclares, fragmentCode, + false); + } // For each draw call, we have to set some uniform values. - vfunc_paint_node(node, paintContext) { + vfunc_paint_target(node, paintContext) { if (this._texture) { - this._pipeline.set_layer_texture(0, this._texture.get_texture()); - - this._pipeline.set_uniform_1i(this._pipeline.get_uniform_location('uTexture'), 0); - this._pipeline.set_uniform_1f(this._pipeline.get_uniform_location('uPitch'), - this.pitch); - this._pipeline.set_uniform_1f(this._pipeline.get_uniform_location('uYaw'), - this.yaw); - - const pipelineNode = new Clutter.PipelineNode(this._pipeline); - pipelineNode.set_name('Dekstop-Cube Skybox'); - node.add_child(pipelineNode); + this.get_pipeline().set_layer_texture(0, this._texture.get_texture()); + this.set_uniform_float(this.get_uniform_location('uTexture'), 1, [0]); + this.set_uniform_float(this.get_uniform_location('uPitch'), 1, [this.pitch]); + this.set_uniform_float(this.get_uniform_location('uYaw'), 1, [this.yaw]); - const actor = this.get_actor(); - const alloc = actor.get_allocation_box(); - pipelineNode.add_texture_rectangle(alloc, 0, 0, 1, 1); + super.vfunc_paint_target(node, paintContext); } }