Skip to content

Commit

Permalink
appwindow: connect/disconnect 'draw' handler according to 'app-painta…
Browse files Browse the repository at this point in the history
…ble'

Partially fixes #20 if background opacity is set to 100%.
  • Loading branch information
amezin committed Jan 26, 2021
1 parent 924efd6 commit dac5670
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions appwindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ var AppWindow = GObject.registerClass(
super._init(params);

this.method_handler(this, 'realize', this.set_wm_functions);
this.method_handler(this, 'screen-changed', this.setup_rgba_visual);
this.method_handler(this, 'draw', this.draw);

this.method_handler(this, 'screen-changed', this.setup_rgba_visual);
this.setup_rgba_visual();

this.draw_handler_id = null;
this.run_on_destroy(() => {
if (this.draw_handler_id)
this.disconnect(this.draw_handler_id);
});

this.method_handler(this.settings, 'changed::background-opacity', this.update_app_paintable);
this.update_app_paintable();

Expand Down Expand Up @@ -146,6 +151,15 @@ var AppWindow = GObject.registerClass(

update_app_paintable() {
this.app_paintable = this.settings.get_double('background-opacity') < 1.0;

if (this.app_paintable) {
if (this.draw_handler_id === null)
this.draw_handler_id = this.connect('draw', this.draw.bind(this));

} else if (this.draw_handler_id !== null) {
this.disconnect(this.draw_handler_id);
this.draw_handler_id = null;
}
}

remove_page(page) {
Expand Down

0 comments on commit dac5670

Please sign in to comment.