Fix startup window size on XOrg

The window size was restored too early which caused the window to be a little bigger then it should on each launch. Restore window size after that window was mapped.
This commit is contained in:
Rafał Dzięgiel
2021-04-07 20:07:05 +02:00
parent b5e1b3ab86
commit cca3077936
2 changed files with 15 additions and 12 deletions

View File

@@ -30,6 +30,8 @@ class ClapperApp extends AppBase
window.add_css_class('nobackground'); window.add_css_class('nobackground');
window.set_child(clapperWidget); window.set_child(clapperWidget);
window.set_titlebar(dummyHeaderbar); window.set_titlebar(dummyHeaderbar);
this.mapSignal = window.connect('map', this._onWindowMap.bind(this));
} }
vfunc_open(files, hint) vfunc_open(files, hint)
@@ -39,4 +41,12 @@ class ClapperApp extends AppBase
this._openFiles(files); this._openFiles(files);
this.activate(); this.activate();
} }
_onWindowMap(window)
{
window.disconnect(this.mapSignal);
this.mapSignal = null;
window.child._onWindowMap(window);
}
}); });

View File

@@ -23,8 +23,6 @@ class ClapperWidget extends Gtk.Grid
this.posX = 0; this.posX = 0;
this.posY = 0; this.posY = 0;
this.windowSize = JSON.parse(settings.get_string('window-size'));
this.layoutWidth = 0; this.layoutWidth = 0;
this.isFullscreenMode = false; this.isFullscreenMode = false;
@@ -59,8 +57,6 @@ class ClapperWidget extends Gtk.Grid
this.attach(this.overlay, 0, 0, 1, 1); this.attach(this.overlay, 0, 0, 1, 1);
this.attach(this.controlsRevealer, 0, 1, 1, 1); this.attach(this.controlsRevealer, 0, 1, 1, 1);
this.mapSignal = this.connect('map', this._onMap.bind(this));
this.player = new Player(); this.player = new Player();
const playerWidget = this.player.widget; const playerWidget = this.player.widget;
@@ -549,20 +545,17 @@ class ClapperWidget extends Gtk.Grid
this.controls._onPlayerResize(width, height); this.controls._onPlayerResize(width, height);
} }
_onMap() _onWindowMap(window)
{ {
this.disconnect(this.mapSignal); const surface = window.get_surface();
const monitor = window.display.get_monitor_at_surface(surface);
const root = this.get_root();
const surface = root.get_surface();
const monitor = root.display.get_monitor_at_surface(surface);
const geometry = monitor.geometry; const geometry = monitor.geometry;
const size = this.windowSize; const size = JSON.parse(settings.get_string('window-size'));
debug(`monitor application-pixels: ${geometry.width}x${geometry.height}`); debug(`monitor application-pixels: ${geometry.width}x${geometry.height}`);
if(geometry.width >= size[0] && geometry.height >= size[1]) { if(geometry.width >= size[0] && geometry.height >= size[1]) {
root.set_default_size(size[0], size[1]); window.set_default_size(size[0], size[1]);
debug(`restored window size: ${size[0]}x${size[1]}`); debug(`restored window size: ${size[0]}x${size[1]}`);
} }