Protect against banner texture issues in GNOME 42
This commit is contained in:
parent
a3807f247a
commit
ff3c03f142
|
|
@ -538,38 +538,35 @@ 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({
|
try {
|
||||||
x: 0,
|
const calibratingBanner = GdkPixbuf.Pixbuf.new_from_file(`${Globals.extension_dir}/textures/calibrating.png`);
|
||||||
y: 0,
|
const calibratingImage = new Clutter.Image();
|
||||||
width: 800,
|
calibratingImage.set_data(calibratingBanner.get_pixels(), Cogl.PixelFormat.RGB_888,
|
||||||
height: 200
|
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 customBanner = GdkPixbuf.Pixbuf.new_from_file(`${Globals.extension_dir}/textures/custom_banner.png`);
|
||||||
const calibratingImage = new Clutter.Image();
|
const customBannerImage = new Clutter.Image();
|
||||||
calibratingImage.set_data(calibratingBanner.get_pixels(), Cogl.PixelFormat.RGB_888,
|
customBannerImage.set_data(customBanner.get_pixels(), Cogl.PixelFormat.RGB_888,
|
||||||
calibratingBanner.width, calibratingBanner.height, calibratingBanner.rowstride);
|
customBanner.width, customBanner.height, customBanner.rowstride);
|
||||||
this.bannerContent = Clutter.TextureContent.new_from_texture(calibratingImage.get_texture(), bannerTextureClippingRect);
|
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`);
|
this.bannerActor = new Clutter.Actor({
|
||||||
const customBannerImage = new Clutter.Image();
|
width: calibratingBanner.width,
|
||||||
customBannerImage.set_data(customBanner.get_pixels(), Cogl.PixelFormat.RGB_888,
|
height: calibratingBanner.height,
|
||||||
customBanner.width, customBanner.height, customBanner.rowstride);
|
reactive: false
|
||||||
this.customBannerContent = Clutter.TextureContent.new_from_texture(customBannerImage.get_texture(), bannerTextureClippingRect);
|
});
|
||||||
|
this.bannerActor.set_position(
|
||||||
this.bannerActor = new Clutter.Actor({
|
(this.target_monitor.width - this.bannerActor.width) / 2,
|
||||||
width: calibratingBanner.width,
|
this.target_monitor.height * 0.75 - this.bannerActor.height / 2
|
||||||
height: calibratingBanner.height,
|
);
|
||||||
reactive: false
|
this.bannerActor.set_content(this.custom_banner_enabled ? this.customBannerContent : this.bannerContent);
|
||||||
});
|
this.bannerActor.hide();
|
||||||
this.bannerActor.set_position(
|
} catch (e) {
|
||||||
(this.target_monitor.width - this.bannerActor.width) / 2,
|
Globals.logger.log(`ERROR: virtualdisplaysactor.js ${e.message}\n${e.stack}`);
|
||||||
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.monitor_actors = [];
|
this.monitor_actors = [];
|
||||||
}
|
}
|
||||||
|
|
@ -690,15 +687,17 @@ 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));
|
||||||
|
|
||||||
this.add_child(this.bannerActor);
|
if (this.bannerActor) {
|
||||||
if (this.show_banner) {
|
this.add_child(this.bannerActor);
|
||||||
this.set_child_above_sibling(this.bannerActor, null);
|
if (this.show_banner) {
|
||||||
this.bannerActor.show();
|
this.set_child_above_sibling(this.bannerActor, null);
|
||||||
|
this.bannerActor.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 250, (() => {
|
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 250, (() => {
|
||||||
|
|
@ -852,11 +851,13 @@ export const VirtualDisplaysActor = GObject.registerClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
_handle_banner_update() {
|
_handle_banner_update() {
|
||||||
if (this.show_banner) {
|
if (this.bannerActor) {
|
||||||
this.bannerActor.set_content(this.custom_banner_enabled ? this.customBannerContent : this.bannerContent);
|
if (this.show_banner) {
|
||||||
this.bannerActor.show();
|
this.bannerActor.set_content(this.custom_banner_enabled ? this.customBannerContent : this.bannerContent);
|
||||||
} else {
|
this.bannerActor.show();
|
||||||
this.bannerActor.hide();
|
} else {
|
||||||
|
this.bannerActor.hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue