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>
This commit is contained in:
parent
80d72cfd32
commit
c494597a91
@ -92,5 +92,9 @@
|
|||||||
<arg type="b" direction="out" name="success"/>
|
<arg type="b" direction="out" name="success"/>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
|
<signal name="Error">
|
||||||
|
<arg type="s" name="message"/>
|
||||||
|
</signal>
|
||||||
|
|
||||||
</interface>
|
</interface>
|
||||||
</node>
|
</node>
|
||||||
|
@ -7,5 +7,7 @@
|
|||||||
|
|
||||||
<file>misc/config.js</file>
|
<file>misc/config.js</file>
|
||||||
<file>misc/dbusUtils.js</file>
|
<file>misc/dbusUtils.js</file>
|
||||||
|
<file>misc/signals.js</file>
|
||||||
|
<file>misc/signalTracker.js</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
</gresources>
|
</gresources>
|
||||||
|
@ -7,6 +7,7 @@ imports.gi.versions.Gtk = '4.0';
|
|||||||
const { Gio, GLib, Gst, Gtk } = imports.gi;
|
const { Gio, GLib, Gst, Gtk } = imports.gi;
|
||||||
|
|
||||||
const { loadInterfaceXML, loadSubInterfaceXML } = imports.misc.dbusUtils;
|
const { loadInterfaceXML, loadSubInterfaceXML } = imports.misc.dbusUtils;
|
||||||
|
const Signals = imports.misc.signals;
|
||||||
const { ServiceImplementation } = imports.dbusService;
|
const { ServiceImplementation } = imports.dbusService;
|
||||||
|
|
||||||
const ScreencastIface = loadInterfaceXML('org.gnome.Shell.Screencast');
|
const ScreencastIface = loadInterfaceXML('org.gnome.Shell.Screencast');
|
||||||
@ -54,13 +55,13 @@ const SessionState = {
|
|||||||
STOPPED: 'STOPPED',
|
STOPPED: 'STOPPED',
|
||||||
};
|
};
|
||||||
|
|
||||||
var Recorder = class {
|
var Recorder = class extends Signals.EventEmitter {
|
||||||
constructor(sessionPath, x, y, width, height, filePath, options,
|
constructor(sessionPath, x, y, width, height, filePath, options,
|
||||||
invocation,
|
invocation) {
|
||||||
onErrorCallback) {
|
super();
|
||||||
|
|
||||||
this._startInvocation = invocation;
|
this._startInvocation = invocation;
|
||||||
this._dbusConnection = invocation.get_connection();
|
this._dbusConnection = invocation.get_connection();
|
||||||
this._onErrorCallback = onErrorCallback;
|
|
||||||
this._stopInvocation = null;
|
this._stopInvocation = null;
|
||||||
|
|
||||||
this._x = x;
|
this._x = x;
|
||||||
@ -147,11 +148,6 @@ var Recorder = class {
|
|||||||
|
|
||||||
log(`Recorder error: ${error.message}`);
|
log(`Recorder error: ${error.message}`);
|
||||||
|
|
||||||
if (this._onErrorCallback) {
|
|
||||||
this._onErrorCallback();
|
|
||||||
delete this._onErrorCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._startRequest) {
|
if (this._startRequest) {
|
||||||
this._startRequest.reject(error);
|
this._startRequest.reject(error);
|
||||||
delete this._startRequest;
|
delete this._startRequest;
|
||||||
@ -161,6 +157,8 @@ var Recorder = class {
|
|||||||
this._stopRequest.reject(error);
|
this._stopRequest.reject(error);
|
||||||
delete this._stopRequest;
|
delete this._stopRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.emit('error', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleFatalPipelineError(message) {
|
_handleFatalPipelineError(message) {
|
||||||
@ -529,8 +527,7 @@ var ScreencastService = class extends ServiceImplementation {
|
|||||||
screenWidth, screenHeight,
|
screenWidth, screenHeight,
|
||||||
filePath,
|
filePath,
|
||||||
options,
|
options,
|
||||||
invocation,
|
invocation);
|
||||||
() => this._removeRecorder(sender));
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log(`Failed to create recorder: ${error.message}`);
|
log(`Failed to create recorder: ${error.message}`);
|
||||||
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
|
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
|
||||||
@ -548,6 +545,12 @@ var ScreencastService = class extends ServiceImplementation {
|
|||||||
} finally {
|
} finally {
|
||||||
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
|
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) {
|
async ScreencastAreaAsync(params, invocation) {
|
||||||
@ -579,8 +582,7 @@ var ScreencastService = class extends ServiceImplementation {
|
|||||||
width, height,
|
width, height,
|
||||||
filePath,
|
filePath,
|
||||||
options,
|
options,
|
||||||
invocation,
|
invocation);
|
||||||
() => this._removeRecorder(sender));
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log(`Failed to create recorder: ${error.message}`);
|
log(`Failed to create recorder: ${error.message}`);
|
||||||
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
|
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
|
||||||
@ -598,6 +600,12 @@ var ScreencastService = class extends ServiceImplementation {
|
|||||||
} finally {
|
} finally {
|
||||||
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
|
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) {
|
async StopScreencastAsync(params, invocation) {
|
||||||
|
Loading…
Reference in New Issue
Block a user