diff --git a/clapper_src/webapp.js b/clapper_src/webapp.js new file mode 100644 index 00000000..e5bd1168 --- /dev/null +++ b/clapper_src/webapp.js @@ -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'); + } +}); diff --git a/pkgs/flatpak/lib/gtk4.json b/pkgs/flatpak/lib/gtk4.json index 5f2a38eb..4a8da02a 100644 --- a/pkgs/flatpak/lib/gtk4.json +++ b/pkgs/flatpak/lib/gtk4.json @@ -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": [ {