Merge pull request #508 from Schneegans/fix/gnome-48

Fix #507
This commit is contained in:
Simon Schneegans
2025-03-08 13:58:58 +01:00
committed by GitHub
7 changed files with 37 additions and 37 deletions
+8
View File
@@ -5,6 +5,14 @@ SPDX-License-Identifier: CC-BY-4.0
# Changelog of the Burn-My-Windows Extension
## [unreleased]
**Release Date:** TBD
#### Bug Fixes
- Fixed an issue introduced by the GNOME 48 Beta release which caused some effects to break (Broken Glass, Matrix, Paint Brush, Snap of Disintegration, T-Rex Attack).
## [Burn My Windows 45](https://github.com/schneegans/Burn-My-Windows/releases/tag/v45)
**Release Date:** 2025-02-21
+1 -7
View File
@@ -20,8 +20,6 @@ import * as utils from '../utils.js';
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const St = await utils.importInShellOnly('gi://St');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
const _ = await utils.importGettext();
@@ -55,11 +53,7 @@ export default class Effect {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// Create the texture in the first call.
if (!this._shardTexture) {
const shardData = GdkPixbuf.Pixbuf.new_from_resource('/img/shards.png');
this._shardTexture = new St.ImageContent();
this._shardTexture.set_data(shardData.get_pixels(), Cogl.PixelFormat.RGB_888,
shardData.width, shardData.height,
shardData.rowstride);
this._shardTexture = utils.getImageResource('/img/shards.png');
}
// Store all uniform locations.
+1 -9
View File
@@ -20,9 +20,6 @@ import * as utils from '../utils.js';
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const St = await utils.importInShellOnly('gi://St');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
const _ = await utils.importGettext();
@@ -47,12 +44,7 @@ export default class Effect {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// Create the texture in the first call.
if (!this._fontTexture) {
const fontData = GdkPixbuf.Pixbuf.new_from_resource('/img/matrixFont.png');
this._fontTexture = new St.ImageContent();
this._fontTexture.set_data(
fontData.get_pixels(),
fontData.has_alpha ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888,
fontData.width, fontData.height, fontData.rowstride);
this._fontTexture = utils.getImageResource('/img/matrixFont.png');
}
// Store uniform locations of newly created shaders.
+1 -7
View File
@@ -20,8 +20,6 @@ import * as utils from '../utils.js';
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const St = await utils.importInShellOnly('gi://St');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
const _ = await utils.importGettext();
@@ -45,11 +43,7 @@ export default class Effect {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// Create the texture in the first call.
if (!this._brushTexture) {
const brushData = GdkPixbuf.Pixbuf.new_from_resource('/img/brush.png');
this._brushTexture = new St.ImageContent();
this._brushTexture.set_data(brushData.get_pixels(),
Cogl.PixelFormat.RGBA_8888_PRE, brushData.width,
brushData.height, brushData.rowstride);
this._brushTexture = utils.getImageResource('/img/brush.png', true);
}
// Store uniform locations of newly created shaders.
+1 -6
View File
@@ -20,8 +20,6 @@ import * as utils from '../utils.js';
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const St = await utils.importInShellOnly('gi://St');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
const _ = await utils.importGettext();
@@ -49,10 +47,7 @@ export default class Effect {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// Create the texture in the first call.
if (!this._dustTexture) {
const dustData = GdkPixbuf.Pixbuf.new_from_resource('/img/dust.png');
this._dustTexture = new St.ImageContent();
this._dustTexture.set_data(dustData.get_pixels(), Cogl.PixelFormat.RGB_888,
dustData.width, dustData.height, dustData.rowstride);
this._dustTexture = utils.getImageResource('/img/dust.png');
}
// Store uniform locations of newly created shaders.
+1 -6
View File
@@ -20,8 +20,6 @@ import * as utils from '../utils.js';
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const St = await utils.importInShellOnly('gi://St');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
const _ = await utils.importGettext();
@@ -45,10 +43,7 @@ export default class Effect {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// Create the texture in the first call.
if (!this._clawTexture) {
const clawData = GdkPixbuf.Pixbuf.new_from_resource('/img/claws.png');
this._clawTexture = new St.ImageContent();
this._clawTexture.set_data(clawData.get_pixels(), Cogl.PixelFormat.RGB_888,
clawData.width, clawData.height, clawData.rowstride);
this._clawTexture = utils.getImageResource('/img/claws.png');
}
// Store uniform locations of newly created shaders.
+24 -2
View File
@@ -20,8 +20,10 @@ import GLib from 'gi://GLib';
// We import some modules optionally. This file is used in the preferences process as well
// as in the GNOME Shell process. Some modules are only available or required in one of
// these processes.
const Clutter = await importInShellOnly('gi://Clutter');
const Cogl = await importInShellOnly('gi://Cogl');
const GdkPixbuf = await importInShellOnly('gi://GdkPixbuf');
const Clutter = await importInShellOnly('gi://Clutter');
const Cogl = await importInShellOnly('gi://Cogl');
const St = await importInShellOnly('gi://St');
// We import the Config module. This is done differently in the GNOME Shell process and in
// the preferences process.
@@ -117,6 +119,26 @@ export function getStringResource(path) {
return new TextDecoder().decode(data.get_data());
}
// Reads the contents of an image file contained in the global resources archive. The data
// is returned as a St.ImageContent.
export function getImageResource(path, premultiplied = false) {
const data = GdkPixbuf.Pixbuf.new_from_resource(path);
const texture = St.ImageContent.new_with_preferred_size(data.width, data.height);
const format = data.has_alpha ?
(premultiplied ? Cogl.PixelFormat.RGBA_8888_PRE : Cogl.PixelFormat.RGBA_8888) :
Cogl.PixelFormat.RGB_888;
// https://gitlab.gnome.org/GNOME/gnome-shell/-/commit/44b84e458a22046fedb85701ea25ad08ecc0d43f
if (shellVersionIsAtLeast(48, 'beta')) {
texture.set_data(global.stage.context.get_backend().get_cogl_context(),
data.get_pixels(), format, data.width, data.height, data.rowstride);
} else {
texture.set_data(data.get_pixels(), format, data.width, data.height, data.rowstride);
}
return texture;
}
// Executes a command asynchronously and returns the output from 'stdout' on success or
// throw an error with output from 'stderr' on failure. If given, input will be passed to
// 'stdin' and cancellable can be used to stop the process before it finishes.