From a9b803f0755ca84c0a45406ee4ac94602cb9f4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 22 Jul 2020 18:38:22 +0200 Subject: [PATCH] introspect: Introspect screen size To be used by the screen cast service. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1372 --- .../org.gnome.Shell.Introspect.xml | 8 ++++++ js/misc/introspect.js | 25 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/data/dbus-interfaces/org.gnome.Shell.Introspect.xml b/data/dbus-interfaces/org.gnome.Shell.Introspect.xml index d71f2414b..47fd7efdc 100644 --- a/data/dbus-interfaces/org.gnome.Shell.Introspect.xml +++ b/data/dbus-interfaces/org.gnome.Shell.Introspect.xml @@ -70,6 +70,14 @@ --> + + + diff --git a/js/misc/introspect.js b/js/misc/introspect.js index e592fb3cf..6578e2b76 100644 --- a/js/misc/introspect.js +++ b/js/misc/introspect.js @@ -5,7 +5,7 @@ const INTROSPECT_SCHEMA = 'org.gnome.shell'; const INTROSPECT_KEY = 'introspect'; const APP_WHITELIST = ['org.freedesktop.impl.portal.desktop.gtk']; -const INTROSPECT_DBUS_API_VERSION = 2; +const INTROSPECT_DBUS_API_VERSION = 3; const { loadInterfaceXML } = imports.misc.fileUtils; @@ -59,6 +59,11 @@ var IntrospectService = class { this._settings.connect('notify::enable-animations', this._syncAnimationsEnabled.bind(this)); this._syncAnimationsEnabled(); + + const monitorManager = Meta.MonitorManager.get(); + monitorManager.connect('monitors-changed', + this._syncScreenSize.bind(this)); + this._syncScreenSize(); } _isStandaloneApp(app) { @@ -209,10 +214,28 @@ var IntrospectService = class { } } + _syncScreenSize() { + const oldScreenWidth = this._screenWidth; + const oldScreenHeight = this._screenHeight; + this._screenWidth = global.screen_width; + this._screenHeight = global.screen_height; + + if (oldScreenWidth !== this._screenWidth || + oldScreenHeight !== this._screenHeight) { + const variant = new GLib.Variant('(ii)', + [this._screenWidth, this._screenHeight]); + this._dbusImpl.emit_property_changed('ScreenSize', variant); + } + } + get AnimationsEnabled() { return this._animationsEnabled; } + get ScreenSize() { + return [this._screenWidth, this._screenHeight]; + } + get version() { return INTROSPECT_DBUS_API_VERSION; }