Protect against banner texture issues in GNOME 42

This commit is contained in:
wheaney 2025-03-06 18:58:03 -08:00
parent a3807f247a
commit ff3c03f142
1 changed files with 40 additions and 39 deletions

View File

@ -538,38 +538,35 @@ export const VirtualDisplaysActor = GObject.registerClass({
this._all_monitors = [
this.target_monitor,
...this.virtual_monitors
]
];
const bannerTextureClippingRect = new Mtk.Rectangle({
x: 0,
y: 0,
width: 800,
height: 200
});
try {
const calibratingBanner = GdkPixbuf.Pixbuf.new_from_file(`${Globals.extension_dir}/textures/calibrating.png`);
const calibratingImage = new Clutter.Image();
calibratingImage.set_data(calibratingBanner.get_pixels(), Cogl.PixelFormat.RGB_888,
calibratingBanner.width, calibratingBanner.height, calibratingBanner.rowstride);
this.bannerContent = Clutter.TextureContent.new_from_texture(calibratingImage.get_texture(), null);
const calibratingBanner = GdkPixbuf.Pixbuf.new_from_file(`${Globals.extension_dir}/textures/calibrating.png`);
const calibratingImage = new Clutter.Image();
calibratingImage.set_data(calibratingBanner.get_pixels(), Cogl.PixelFormat.RGB_888,
calibratingBanner.width, calibratingBanner.height, calibratingBanner.rowstride);
this.bannerContent = Clutter.TextureContent.new_from_texture(calibratingImage.get_texture(), bannerTextureClippingRect);
const customBanner = GdkPixbuf.Pixbuf.new_from_file(`${Globals.extension_dir}/textures/custom_banner.png`);
const customBannerImage = new Clutter.Image();
customBannerImage.set_data(customBanner.get_pixels(), Cogl.PixelFormat.RGB_888,
customBanner.width, customBanner.height, customBanner.rowstride);
this.customBannerContent = Clutter.TextureContent.new_from_texture(customBannerImage.get_texture(), null);
const customBanner = GdkPixbuf.Pixbuf.new_from_file(`${Globals.extension_dir}/textures/custom_banner.png`);
const customBannerImage = new Clutter.Image();
customBannerImage.set_data(customBanner.get_pixels(), Cogl.PixelFormat.RGB_888,
customBanner.width, customBanner.height, customBanner.rowstride);
this.customBannerContent = Clutter.TextureContent.new_from_texture(customBannerImage.get_texture(), bannerTextureClippingRect);
this.bannerActor = new Clutter.Actor({
width: calibratingBanner.width,
height: calibratingBanner.height,
reactive: false
});
this.bannerActor.set_position(
(this.target_monitor.width - this.bannerActor.width) / 2,
this.target_monitor.height * 0.75 - this.bannerActor.height / 2
);
this.bannerActor.set_content(this.custom_banner_enabled ? this.customBannerContent : this.bannerContent);
this.bannerActor.hide();
this.bannerActor = new Clutter.Actor({
width: calibratingBanner.width,
height: calibratingBanner.height,
reactive: false
});
this.bannerActor.set_position(
(this.target_monitor.width - this.bannerActor.width) / 2,
this.target_monitor.height * 0.75 - this.bannerActor.height / 2
);
this.bannerActor.set_content(this.custom_banner_enabled ? this.customBannerContent : this.bannerContent);
this.bannerActor.hide();
} catch (e) {
Globals.logger.log(`ERROR: virtualdisplaysactor.js ${e.message}\n${e.stack}`);
}
this.monitor_actors = [];
}
@ -690,15 +687,17 @@ export const VirtualDisplaysActor = GObject.registerClass({
effect.connect('notify::is-closest', ((actor, _pspec) => {
if (!this._is_disposed && actor.is_closest) {
this.set_child_above_sibling(viewport, null);
if (this.show_banner) this.set_child_above_sibling(this.bannerActor, null);
if (this.show_banner && this.bannerActor) this.set_child_above_sibling(this.bannerActor, null);
}
}).bind(this));
}).bind(this));
this.add_child(this.bannerActor);
if (this.show_banner) {
this.set_child_above_sibling(this.bannerActor, null);
this.bannerActor.show();
if (this.bannerActor) {
this.add_child(this.bannerActor);
if (this.show_banner) {
this.set_child_above_sibling(this.bannerActor, null);
this.bannerActor.show();
}
}
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 250, (() => {
@ -852,11 +851,13 @@ export const VirtualDisplaysActor = GObject.registerClass({
}
_handle_banner_update() {
if (this.show_banner) {
this.bannerActor.set_content(this.custom_banner_enabled ? this.customBannerContent : this.bannerContent);
this.bannerActor.show();
} else {
this.bannerActor.hide();
if (this.bannerActor) {
if (this.show_banner) {
this.bannerActor.set_content(this.custom_banner_enabled ? this.customBannerContent : this.bannerContent);
this.bannerActor.show();
} else {
this.bannerActor.hide();
}
}
}