Gtk.jl icon indicating copy to clipboard operation
Gtk.jl copied to clipboard

GDK_BACKEND=broadway

Open mdpetters opened this issue 3 years ago • 3 comments

I have a question about how to set the GDK_BACKEND. The desired behavior is to run the Gtk app remotely and serve it through a browser. The goal is to avoid having to use VNC or ssh with X forwarding, both of which have drawbacks.

For example:

~$ broadwayd -p 8080 :2
listening on /run/user/1001/broadway3.socket
~$ GDK_BACKEND=broadway BROADWAY_DISPLAY=:2 a-compiled-gtk-app

which then displays nicely on http://localhost:8080/. The main advantage is that the browser can be closed, but the app remains attached to the display and can be viewed again later.

When running

GDK_BACKEND=broadway BROADWAY_DISPLAY=:2 julia
julia> using Gtk

I get the following error:

ERROR: InitError: Cannot open display:
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] Gtk.GLib.GError(f::Gtk.var"#318#324")
   @ Gtk.GLib ~/.julia/packages/Gtk/3TfRG/src/GLib/gerror.jl:17
 [3] __init__()
   @ Gtk ~/.julia/packages/Gtk/3TfRG/src/Gtk.jl:125
 [4] _include_from_serialized(path::String, depmods::Vector{Any})
   @ Base ./loading.jl:674
 [5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
   @ Base ./loading.jl:760
 [6] _require(pkg::Base.PkgId)
   @ Base ./loading.jl:998
 [7] require(uuidkey::Base.PkgId)
   @ Base ./loading.jl:914
 [8] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:901
during initialization of module Gtk

I poked through the Gtk.jl source code and could not find any explicity call that sets the GDK_BACKEND (https://developer.gnome.org/gdk3/stable/gdk3-General.html#gdk-set-allowed-backends). I tried to hack a ccall before the gtk_init_with_args in Gtk.jl lines 125-129

GError() do error_check
        ccall((:gtk_init_with_args, libgtk), Bool,
            (Ptr{Nothing}, Ptr{Nothing}, Ptr{UInt8}, Ptr{Nothing}, Ptr{UInt8}, Ptr{GError}),
            C_NULL, C_NULL, "Julia Gtk Bindings", C_NULL, C_NULL, error_check)
    end

However, I have never worked with Gtk in C. I honestly have no idea what I am doing, so unsurprisingly, no luck. Any thoughts if this feature could be had without too much pain?

mdpetters avatar May 13 '21 01:05 mdpetters

@mdpetters, may I ask you whether you somehow progressed on this topic in the meantime - or has it been a dead end?

kschertler avatar Oct 21 '22 06:10 kschertler

This was too much out of my wheelhouse and I did not pursue this further.

mdpetters avatar Oct 21 '22 15:10 mdpetters

OK, I see. Thanks @mdpetters!

kschertler avatar Oct 21 '22 17:10 kschertler