Do not restore window size if it exceeds screen size #38

This commit is contained in:
Rafał Dzięgiel
2021-02-06 23:13:29 +01:00
parent 6b6777ffba
commit 4debed92fe
2 changed files with 11 additions and 6 deletions

View File

@@ -31,10 +31,6 @@ class ClapperApp extends AppBase
const headerBar = new HeaderBar(this.active_window);
this.active_window.set_titlebar(headerBar);
const size = clapperWidget.windowSize;
this.active_window.set_default_size(size[0], size[1]);
debug(`restored window size: ${size[0]}x${size[1]}`);
}
vfunc_open(files, hint)

View File

@@ -566,9 +566,18 @@ class ClapperWidget extends Gtk.Grid
this.disconnect(this.mapSignal);
const root = this.get_root();
if(!root) return;
const surface = root.get_surface();
const monitor = root.display.get_monitor_at_surface(surface);
const geometry = monitor.geometry;
const size = this.windowSize;
debug(`detected monitor resolution: ${geometry.width}x${geometry.height}`);
if(geometry.width >= size[0] && geometry.height >= size[1]) {
root.set_default_size(size[0], size[1]);
debug(`restored window size: ${size[0]}x${size[1]}`);
}
surface.connect('notify::state', this._onStateNotify.bind(this));
}
});