[polari/gnome-3-36] mainWindow: Cache view-height to avoid notifying unconditionally on it
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/gnome-3-36] mainWindow: Cache view-height to avoid notifying unconditionally on it
- Date: Thu, 7 May 2020 10:08:23 +0000 (UTC)
commit 955c9f844cfb4dabd8fb8b7eba36f20e4fbe738d
Author: Philip Withnall <withnall endlessm com>
Date: Wed May 6 17:02:00 2020 +0100
mainWindow: Cache view-height to avoid notifying unconditionally on it
If the code notifies of changes to view-height unconditionally (i.e.
even if the actual value of view-height hasn’t changed), it can lead to
a lot of unnecessary resize cycles.
Avoid that by storing the old value and only emitting a notification if
it’s changed.
Signed-off-by: Philip Withnall <withnall endlessm com>
https://gitlab.gnome.org/GNOME/polari/-/merge_requests/157
src/mainWindow.js | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index dccf327f..bae235e2 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -140,8 +140,14 @@ var MainWindow = GObject.registerClass({
if (GLib.get_application_name().toLowerCase().includes('snapshot'))
this.get_style_context().add_class('snapshot');
+ this._viewHeight = this._calculateViewHeight();
this._roomStack.connect('size-allocate', () => {
- this.notify('view-height');
+ let oldViewHeight = this._viewHeight;
+ let newViewHeight = this._calculateViewHeight();
+ if (oldViewHeight !== newViewHeight) {
+ this._viewHeight = newViewHeight;
+ this.notify('view-height');
+ }
});
// command output notifications should not pop up over
@@ -219,9 +225,13 @@ var MainWindow = GObject.registerClass({
return this._subtitle.length > 0;
}
+ _calculateViewHeight() {
+ return this._roomStack.get_allocated_height() - this._roomStack.entry_area_height;
+ }
+
// eslint-disable-next-line camelcase
get view_height() {
- return this._roomStack.get_allocated_height() - this._roomStack.entry_area_height;
+ return this._viewHeight;
}
_onAccountsReachableChanged() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]