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,26 +538,20 @@ export const VirtualDisplaysActor = GObject.registerClass({
this._all_monitors = [ this._all_monitors = [
this.target_monitor, this.target_monitor,
...this.virtual_monitors ...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 calibratingBanner = GdkPixbuf.Pixbuf.new_from_file(`${Globals.extension_dir}/textures/calibrating.png`);
const calibratingImage = new Clutter.Image(); const calibratingImage = new Clutter.Image();
calibratingImage.set_data(calibratingBanner.get_pixels(), Cogl.PixelFormat.RGB_888, calibratingImage.set_data(calibratingBanner.get_pixels(), Cogl.PixelFormat.RGB_888,
calibratingBanner.width, calibratingBanner.height, calibratingBanner.rowstride); calibratingBanner.width, calibratingBanner.height, calibratingBanner.rowstride);
this.bannerContent = Clutter.TextureContent.new_from_texture(calibratingImage.get_texture(), bannerTextureClippingRect); this.bannerContent = Clutter.TextureContent.new_from_texture(calibratingImage.get_texture(), null);
const customBanner = GdkPixbuf.Pixbuf.new_from_file(`${Globals.extension_dir}/textures/custom_banner.png`); const customBanner = GdkPixbuf.Pixbuf.new_from_file(`${Globals.extension_dir}/textures/custom_banner.png`);
const customBannerImage = new Clutter.Image(); const customBannerImage = new Clutter.Image();
customBannerImage.set_data(customBanner.get_pixels(), Cogl.PixelFormat.RGB_888, customBannerImage.set_data(customBanner.get_pixels(), Cogl.PixelFormat.RGB_888,
customBanner.width, customBanner.height, customBanner.rowstride); customBanner.width, customBanner.height, customBanner.rowstride);
this.customBannerContent = Clutter.TextureContent.new_from_texture(customBannerImage.get_texture(), bannerTextureClippingRect); this.customBannerContent = Clutter.TextureContent.new_from_texture(customBannerImage.get_texture(), null);
this.bannerActor = new Clutter.Actor({ this.bannerActor = new Clutter.Actor({
width: calibratingBanner.width, width: calibratingBanner.width,
@ -570,6 +564,9 @@ export const VirtualDisplaysActor = GObject.registerClass({
); );
this.bannerActor.set_content(this.custom_banner_enabled ? this.customBannerContent : this.bannerContent); this.bannerActor.set_content(this.custom_banner_enabled ? this.customBannerContent : this.bannerContent);
this.bannerActor.hide(); this.bannerActor.hide();
} catch (e) {
Globals.logger.log(`ERROR: virtualdisplaysactor.js ${e.message}\n${e.stack}`);
}
this.monitor_actors = []; this.monitor_actors = [];
} }
@ -690,16 +687,18 @@ export const VirtualDisplaysActor = GObject.registerClass({
effect.connect('notify::is-closest', ((actor, _pspec) => { effect.connect('notify::is-closest', ((actor, _pspec) => {
if (!this._is_disposed && actor.is_closest) { if (!this._is_disposed && actor.is_closest) {
this.set_child_above_sibling(viewport, null); 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));
}).bind(this)); }).bind(this));
if (this.bannerActor) {
this.add_child(this.bannerActor); this.add_child(this.bannerActor);
if (this.show_banner) { if (this.show_banner) {
this.set_child_above_sibling(this.bannerActor, null); this.set_child_above_sibling(this.bannerActor, null);
this.bannerActor.show(); this.bannerActor.show();
} }
}
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 250, (() => { GLib.timeout_add(GLib.PRIORITY_DEFAULT, 250, (() => {
if (this._is_disposed) return GLib.SOURCE_REMOVE; if (this._is_disposed) return GLib.SOURCE_REMOVE;
@ -852,6 +851,7 @@ export const VirtualDisplaysActor = GObject.registerClass({
} }
_handle_banner_update() { _handle_banner_update() {
if (this.bannerActor) {
if (this.show_banner) { if (this.show_banner) {
this.bannerActor.set_content(this.custom_banner_enabled ? this.customBannerContent : this.bannerContent); this.bannerActor.set_content(this.custom_banner_enabled ? this.customBannerContent : this.bannerContent);
this.bannerActor.show(); this.bannerActor.show();
@ -859,6 +859,7 @@ export const VirtualDisplaysActor = GObject.registerClass({
this.bannerActor.hide(); this.bannerActor.hide();
} }
} }
}
_handle_frame_rate_cap_change() { _handle_frame_rate_cap_change() {
// add a margin to the cap time so we don't cut off frames that come in close // add a margin to the cap time so we don't cut off frames that come in close