~eliasnaur/gio#8: X11 support

IIUC, gio currently requires Wayland, which I don’t (yet) have in any of my Linux environments for various reasons.

I suspect I’m not the only one with this issue. Is there any chance X11 support could be added?

Thanks in advance,

Status
REPORTED
Submitter
~stapelberg
Assigned to
No-one
Submitted
22 days ago
Updated
10 days ago
Labels
No labels applied.

~eliasnaur 22 days ago

I had hoped to avoid X11 support altogether given the stage of the Wayland transition. However, given enough interest, there is no technical reason X11 couldn't be added.

~stapelberg 21 days ago

I think you might be over-estimating how far the Wayland transition is along :)

I certainly will have to use X11 in various environments for years to come.

~dolanor 21 days ago

Same here, still on Ubuntu 16.04, and given the feedbacks of breakage with 18.04, I'm hesitant to migrate.

~rkanchan 18 days ago

Same with elementaryOS Juno. Wayland is yet to arrive.

~theclapp 13 days ago

I don't know much about Wayland. Is there some docker- or vm-based solution y'all could run? That is, some docker image or virtual machine image that runs Wayland, that you could use to run Gio? What's a few gig of disk among friends? :)

Failing that, I've had some luck getting Gio to run in Chrome on the Mac, so running via your browser might be a possibility.

Failing that ... there's only (he said naively) about 1500 lines of Go and C (mostly Go) in the Wayland-specific code. (There's about 3400 lines of generated C.) Are Wayland and X11 similar enough that the Wayland code would make the X11 port comparatively easy? (Compared to developing it from scratch.)

~mvdan 10 days ago

Yesterday, I successfully ran sway out of the box within X11, fired a terminal, and ran a couple of gio examples in Wayland. Ctrl+D allows you to run any program via dmenu, so that let me start my terminal emulator.

It's a bit clunky, because the parent window manager takes precedence with keyboard shortcuts, but it mostly works.

Having said this, I agree X11 support would be good. We all have plans to move to Wayland eventually, but I think X11 support would be key to Gio's success in the short term.

~eliasnaur could you write a short doc with the steps one would have to follow to implement X11 support? Perhaps then someone with enough interest could step in and start contributing patches.

~eliasnaur 10 days ago

~eliasnaur could you write a short doc with the steps one would have to follow to implement X11 support? Perhaps then someone with enough interest could step in and start contributing patches.

Good idea.

The platform specific packages in Gio are ui/app and ui/app/internal/gl.

I don't think you need anything X11 specific in the gl package.

The app package takes care of creating a native window, binding an OpenGL ES context and handling input. I suggest you use the Wayland port as a starting point.

Dynamic switching between the Wayland and X11 backends would be nice, but as a first goal I suggest defining a build tag, say x11, that switches from Wayland to X11 at build time.

So the first step is adding

// +build !x11

to every wayland-specific Go and C files. You'll have to modify the go:generate directives in oswayland.go to add the x11 condition to the generated Wayland C files (waylandxdgshell.c, waylandxdgdecoration.c, waylandtext_input.c).

What I usually do at this point of adding a new port is to make minimal changes and empty types, functions, methods etc. to make a Gio program build and run. Use the hello or gophers example for that.

Then, I work through the necessary steps for creating a Window and binding a context. The goal is to get the drawing to show up in a window. Note that Gio programs won't draw before Window.setStage(StateRunning) has been called.

For input I wire up event handling to route mouse and keyboard input back to the Gio program. My experience with X11 tells that this is where most of the issues will be. Things like key code translation, scroll wheel etc. were fiddly when I did the X11 port for LWJGL.

Finally, polish: lifecycle for minimizing/maxizing, setting the window title and size and so on.

Hope that helps. I'll gladly expand on any issues you run into.

  • elias