🪲 Fix some effects on GNOME 48
This commit is contained in:
@@ -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 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,30 @@ 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.
|
||||
|
||||
Reference in New Issue
Block a user