mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Merge pull request #28 from Rafostar/broadway
Host web application with Broadway backend
This commit is contained in:
64
clapper_src/webapp.js
Normal file
64
clapper_src/webapp.js
Normal 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');
|
||||
}
|
||||
});
|
@@ -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": [
|
||||
{
|
||||
|
Reference in New Issue
Block a user