summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Dreßler <verdre@v0yd.nl>2023-04-26 12:29:57 +0200
committerJonas Dreßler <verdre@v0yd.nl>2023-04-26 13:35:57 +0200
commitc494597a910a22b861a6736919316bad8d2c8eab (patch)
tree55a37787bf909fd590d8db7dd0db327c990647ec
parent80d72cfd32e40cdb28e3df49f96f7336113bfd82 (diff)
downloadgnome-shell-c494597a910a22b861a6736919316bad8d2c8eab.tar.gz
screencastService: Signal errors via the internal dbus interface
Make sure gnome-shell gets notified of errors that happen during screen recording using the screencastService, so that it can properly notify the user about the error and tear down its state, too. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2752>
-rw-r--r--data/dbus-interfaces/org.gnome.Shell.Screencast.xml4
-rw-r--r--js/dbusServices/org.gnome.Shell.Screencast.src.gresource.xml2
-rw-r--r--js/dbusServices/screencast/screencastService.js34
3 files changed, 27 insertions, 13 deletions
diff --git a/data/dbus-interfaces/org.gnome.Shell.Screencast.xml b/data/dbus-interfaces/org.gnome.Shell.Screencast.xml
index b4cd592ab..6512396d9 100644
--- a/data/dbus-interfaces/org.gnome.Shell.Screencast.xml
+++ b/data/dbus-interfaces/org.gnome.Shell.Screencast.xml
@@ -92,5 +92,9 @@
<arg type="b" direction="out" name="success"/>
</method>
+ <signal name="Error">
+ <arg type="s" name="message"/>
+ </signal>
+
</interface>
</node>
diff --git a/js/dbusServices/org.gnome.Shell.Screencast.src.gresource.xml b/js/dbusServices/org.gnome.Shell.Screencast.src.gresource.xml
index 292f0f160..a247050e3 100644
--- a/js/dbusServices/org.gnome.Shell.Screencast.src.gresource.xml
+++ b/js/dbusServices/org.gnome.Shell.Screencast.src.gresource.xml
@@ -7,5 +7,7 @@
<file>misc/config.js</file>
<file>misc/dbusUtils.js</file>
+ <file>misc/signals.js</file>
+ <file>misc/signalTracker.js</file>
</gresource>
</gresources>
diff --git a/js/dbusServices/screencast/screencastService.js b/js/dbusServices/screencast/screencastService.js
index 3183a0093..37327e24c 100644
--- a/js/dbusServices/screencast/screencastService.js
+++ b/js/dbusServices/screencast/screencastService.js
@@ -7,6 +7,7 @@ imports.gi.versions.Gtk = '4.0';
const { Gio, GLib, Gst, Gtk } = imports.gi;
const { loadInterfaceXML, loadSubInterfaceXML } = imports.misc.dbusUtils;
+const Signals = imports.misc.signals;
const { ServiceImplementation } = imports.dbusService;
const ScreencastIface = loadInterfaceXML('org.gnome.Shell.Screencast');
@@ -54,13 +55,13 @@ const SessionState = {
STOPPED: 'STOPPED',
};
-var Recorder = class {
+var Recorder = class extends Signals.EventEmitter {
constructor(sessionPath, x, y, width, height, filePath, options,
- invocation,
- onErrorCallback) {
+ invocation) {
+ super();
+
this._startInvocation = invocation;
this._dbusConnection = invocation.get_connection();
- this._onErrorCallback = onErrorCallback;
this._stopInvocation = null;
this._x = x;
@@ -147,11 +148,6 @@ var Recorder = class {
log(`Recorder error: ${error.message}`);
- if (this._onErrorCallback) {
- this._onErrorCallback();
- delete this._onErrorCallback;
- }
-
if (this._startRequest) {
this._startRequest.reject(error);
delete this._startRequest;
@@ -161,6 +157,8 @@ var Recorder = class {
this._stopRequest.reject(error);
delete this._stopRequest;
}
+
+ this.emit('error', error);
}
_handleFatalPipelineError(message) {
@@ -529,8 +527,7 @@ var ScreencastService = class extends ServiceImplementation {
screenWidth, screenHeight,
filePath,
options,
- invocation,
- () => this._removeRecorder(sender));
+ invocation);
} catch (error) {
log(`Failed to create recorder: ${error.message}`);
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
@@ -548,6 +545,12 @@ var ScreencastService = class extends ServiceImplementation {
} finally {
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
}
+
+ recorder.connect('error', (r, error) => {
+ this._removeRecorder(sender);
+ this._dbusImpl.emit_signal('Error',
+ new GLib.Variant('(s)', [error.message]));
+ });
}
async ScreencastAreaAsync(params, invocation) {
@@ -579,8 +582,7 @@ var ScreencastService = class extends ServiceImplementation {
width, height,
filePath,
options,
- invocation,
- () => this._removeRecorder(sender));
+ invocation);
} catch (error) {
log(`Failed to create recorder: ${error.message}`);
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
@@ -598,6 +600,12 @@ var ScreencastService = class extends ServiceImplementation {
} finally {
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
}
+
+ recorder.connect('error', (r, error) => {
+ this._removeRecorder(sender);
+ this._dbusImpl.emit_signal('Error',
+ new GLib.Variant('(s)', [error.message]));
+ });
}
async StopScreencastAsync(params, invocation) {