diff options
author | Marcus Lundblad <ml@dfupdate.se> | 2022-11-22 23:49:55 +0100 |
---|---|---|
committer | Marcus Lundblad <ml@dfupdate.se> | 2022-11-23 22:04:40 +0100 |
commit | 1f6271805851f0a20763170556fe1f132eacc8f4 (patch) | |
tree | 413b27a6a0626e3d6db46a8955d82747b57c9b2d | |
parent | c6be97003d57a7a28eb3a4bc3d212f8a3888a61b (diff) | |
download | gnome-maps-wip/mlundblad/determine-adaptive-on-surface.tar.gz |
mainWindow: Use notify::width on GdkSurface track adaptive changeswip/mlundblad/determine-adaptive-on-surface
Use the width of the backing GdkSurface to determine when the
application is in adaptive mode.
-rw-r--r-- | src/mainWindow.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mainWindow.js b/src/mainWindow.js index cf771082..494cacfb 100644 --- a/src/mainWindow.js +++ b/src/mainWindow.js @@ -330,17 +330,22 @@ export class MainWindow extends Gtk.ApplicationWindow { this._actionBarRight = new HeaderBarRight({ mapView: this._mapView }); this._actionBar.pack_end(this._actionBarRight); + } + + vfunc_realize() { + super.vfunc_realize(); + this._surface = this.get_native().get_surface(); // update adaptive status based on initial geometry this._updateAdaptiveMode(); - this.connect('notify::default-width', () => { + this._surface.connect('notify::width', () => { this._updateAdaptiveMode(); }); } _updateAdaptiveMode() { - let width = this.default_width; + let width = this._surface.width; if (width < _ADAPTIVE_VIEW_WIDTH) { this.application.adaptive_mode = true; |