Merge pull request #28 from Rafostar/broadway

Host web application with Broadway backend
This commit is contained in:
Rafostar
2020-12-15 12:01:38 +01:00
committed by GitHub
2 changed files with 67 additions and 1 deletions

64
clapper_src/webapp.js Normal file
View File

@@ -0,0 +1,64 @@
const { Gio, GObject } = imports.gi;
const Debug = imports.clapper_src.debug;
const Misc = imports.clapper_src.misc;
let { debug } = Debug;
var WebApp = GObject.registerClass(
class ClapperWebApp extends Gio.SubprocessLauncher
{
_init()
{
const flags = Gio.SubprocessFlags.STDOUT_SILENCE
| Gio.SubprocessFlags.STDERR_SILENCE;
super._init({ flags });
this.remoteApp = null;
this.isRemoteClosing = false;
this.setenv('GDK_BACKEND', 'broadway', true);
}
startRemoteApp()
{
if(this.remoteApp)
return;
this.remoteApp = this.spawnv([Misc.appId + 'Remote']);
this.remoteApp.wait_async(null, this._onRemoteClosed.bind(this));
debug('remote app started');
}
stopRemoteApp()
{
if(!this.remoteApp || this.isRemoteClosing)
return;
this.isRemoteClosing = true;
this.remoteApp.force_exit();
debug('send stop signal to remote app');
}
_onRemoteClosed(proc, result)
{
let hadError;
try {
hadError = proc.wait_finish(result);
}
catch(err) {
debug(err);
}
this.remoteApp = null;
this.isRemoteClosing = false;
if(hadError)
debug('remote app exited with error');
debug('remote app closed');
}
});

View File

@@ -3,6 +3,7 @@
"buildsystem": "meson",
"config-opts": [
"--wrap-mode=nofallback",
"-Dbroadway-backend=true",
"-Dwin32-backend=false",
"-Dmacos-backend=false",
"-Dmedia-ffmpeg=disabled",
@@ -10,7 +11,8 @@
"-Dprint-cloudprint=disabled",
"-Dintrospection=enabled",
"-Ddemos=false",
"-Dbuild-examples=false"
"-Dbuild-examples=false",
"-Dbuild-tests=false"
],
"sources": [
{