Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWayland #20

Closed
coderextreme opened this issue Dec 4, 2023 · 27 comments
Closed

XWayland #20

coderextreme opened this issue Dec 4, 2023 · 27 comments

Comments

@coderextreme
Copy link

Any thoughts for a port to XWayland? I don't know what it would entail, probably changes to imake and upgrade C++ to latest gcc/llvm/what have you.

John

@barak
Copy link
Collaborator

barak commented Dec 4, 2023

I don't think there's any changes necessary for XWayland, that's just another X11R4 server that happens to back-end on Wayland rather than directly to a device. A port to native Wayland, now that's another question... Probably easiest to do it via switching graphics libraries to gtk4, which can use either X or Wayland APIs transparently.

@vectaport
Copy link
Owner

As long as XWayland supports the X11 protocol I don't think there will be any porting needed. But I'm sure there will be a challenge getting it built on the latest compiler/library/OS delivery of RedHat, as has consistently been the case for the past 3 decades. The C++ code remains the same but the language keeps on drifting. I will offer support to anyone who tries to build ivtools so it can use XWayland. Good luck.

@barak
Copy link
Collaborator

barak commented Dec 4, 2023

The Redhat announcement about getting rid of Xorg means they're no longer going to package the X servers for various GPUs. The only X server they'll package will be XWayland, which back-ends on Wayland instead of directly onto a GPU or frame buffer. That's been the default configuration for Debian and Ubuntu and Redhat for years. They all default to running a Wayland server to deal with the hardware, and provide the X11 API via XWayland. The device-specific X servers are installed, but unused by default.

To my knowledge, there are no plans to get rid of XWayland; that would break all kinds of programs that do their graphics via the X11 API and have no Wayland port. So I think you can relax.

Well, you can relax about that! There are other sticking points with 1.2, namely getting it to compile with up-to-date GCC etc. Which I'm working on...

@coderextreme
Copy link
Author

coderextreme commented Dec 4, 2023 via email

@coderextreme
Copy link
Author

coderextreme commented Dec 4, 2023 via email

@coderextreme
Copy link
Author

coderextreme commented Dec 4, 2023 via email

@coderextreme
Copy link
Author

coderextreme commented Dec 4, 2023 via email

@coderextreme
Copy link
Author

coderextreme commented Dec 4, 2023 via email

@barak
Copy link
Collaborator

barak commented Dec 5, 2023

Unless you go to strenuous effort, your Wayland session is very likely to have Xwayland running. Here's what I see:

$ ps x|egrep -i 'way()land'
   1903 tty2     Ssl+   0:00 /usr/libexec/gdm-wayland-session /usr/bin/gnome-session
   3953 ?        Sl     0:08 /usr/bin/Xwayland :0 -rootless -noreset -accessx -core -auth /run/user/1000/.mutter-Xwaylandauth.4HJFF2 -listenfd 4 -listenfd 5 -displayfd 6 -initfd 7

If you just run xlsclients or something like that you'll likely see that you do have X11 available in your Wayland session.

That said, there are programs that can run directly on Wayland without using the X11 API. These include Firefox (which is about to switch to default to Wayland instead of X11 when both are available), GNU Emacs (which can use either when set up with gtk, albeit with a compile-time option; the debian package emacs-gtk prefers X11 while emacs-pgtk prefers Wayland), etc.

The quick way to tell if foo is using X11 or Wayland APIs is to run xeyes and see if they follow the cursor when you're in the foo window. I just used this: if I run xournalpp it uses Wayland, but env GDK_BACKEND=x11 xournalpp uses X11.

The "right" way to port ivtools, I think, would be to slip in something that has multiple backends instead of libx11. Gtk being the obvious candidate, see https://docs.gtk.org/gdk4/func.set_allowed_backends.html for available back-ends:

  • broadway
  • macos
  • wayland
  • win32
  • x11

but note that not all programs can use all backends: there is backend-specific code, and you have to take care if you want to be generic over all backends.

@vectaport
Copy link
Owner

John,

Thanks for the patch to comterp.c etc.. to get things built on your latest environment. I have just pushed a commit to ivtools that incorporates this change.

As for porting ivtools to "native" Wayland, I would consider not porting the glyph toolkit that came with InterViews (gtk and Java Swing became the future, not InterViews or Fresco) but instead port the core of the Unidraw framework currently built on top of InterViews/X11. This would mean just the canvas of the drawing editor would carry on, and with the built-in networked scripting language that ivtools added it makes for a vector graphic drawing server.

But as far as I'm concerned this is a project for the distant future. Thanks for your feedback and interest in ivtools.

Scott Johnston
johnston@vectaport.com

@barak
Copy link
Collaborator

barak commented Dec 5, 2023

This seems like a reasonably mechanical job; I wonder if one of those LLM-based tools could mostly automate the port.

@coderextreme
Copy link
Author

Good question about LLMs. I have not tried them for C++.

About Fresco, the X11R6 version. Here it is running in WSL 2. I almost gave up, so this is terrific to see. Let me know if you want it, or need help setting it up or anything. I have not tried the Fujitsu or Berlin or any follow-up version recently.

image

Let me know if you want a version, I can zip up a few folders, but I had to tweak Makefiles. I set it up for Linux, so I don't know how it would work in your environments!

John

@coderextreme
Copy link
Author

Barak wrote:

ps x|egrep -i 'way()land'

Apparently, this is not how WSL 2 works. I saw Remote Desktop in my Task Manager when I had an X11 Client running
$ ps x|egrep -i 'way()land'
$ env |grep DIS
WSL_DISTRO_NAME=Ubuntu
WAYLAND_DISPLAY=wayland-0
DISPLAY=:0
$ xeyes &
[2] 71785
$ xlsclients
DESKTOP-8OPL3IE xeyes

@coderextreme
Copy link
Author

coderextreme commented Dec 6, 2023

port the core of the Unidraw framework

As I have not used much C++ for years, and never looked at the code for the Unidraw framework, this is not a task for me. Perhaps porting Unidraw to ImGui would be something approachable for a seasoned C++ porter. https://github.com/ocornut/imgui/ I agree that X11 still has applicability for accessing Linux servers, but tools like RDP and VNC are also competitors. I think there may be a place for connecting to multiple displays, but that seems less secure, and susceptible to confused deputy issues. Perhaps your drawing server eliminates the issue.

I don't know if broadway and Unidraw fit will together, or even broadway and ImGUI, but I'm willing to be corrected.

@coderextreme
Copy link
Author

If you’re interested in licensing or sublicensing the TWB, I’m pinging the LLNL Industrial Partnerships Office: https://ipo.llnl.gov.

They said the software was "unavailable." I contacted someone who did license it, and they turned their version in to their employer.

@coderextreme
Copy link
Author

coderextreme commented Dec 6, 2023 via email

@coderextreme
Copy link
Author

coderextreme commented Dec 6, 2023 via email

@coderextreme
Copy link
Author

coderextreme commented Dec 6, 2023 via email

@barak
Copy link
Collaborator

barak commented Dec 6, 2023

Yes, by gtk I really meant gdk/gtk. Maybe all the calls could be plain gdk, I dunno. The URL that I gave for specifying backends, https://docs.gtk.org/gdk4/func.set_allowed_backends.html, actually points to a gdk routine, not a gtk one.

If someone has done a port of X11 inside WSL, please push to a fork here on github? I might be able to pick up some of it for the Debian package. I did a port of the build system from xmkmf to autoconf, but that's probably orthogonal.

@coderextreme
Copy link
Author

coderextreme commented Dec 6, 2023 via email

@coderextreme
Copy link
Author

coderextreme commented Dec 6, 2023 via email

@barak
Copy link
Collaborator

barak commented Dec 6, 2023

Sorry, I meant a port of ivtools 2.1 to X11/WSL. I didn't mean a port of X11 itself.

@coderextreme
Copy link
Author

coderextreme commented Dec 6, 2023 via email

@barak
Copy link
Collaborator

barak commented Dec 6, 2023

Sorry, didn't see the patch. Got it now, thanks!

@coderextreme
Copy link
Author

coderextreme commented Dec 6, 2023 via email

@coderextreme
Copy link
Author

coderextreme commented Dec 6, 2023 via email

@coderextreme
Copy link
Author

coderextreme commented May 14, 2024

I am doing more research into GTK. I liked that it’s C based. There’s GDK for windowing, GSK for Cairo, OpenGL and Vulkan, and GTK for the GUI toolkit. I don’t know if GTK relies on GSK. There’s probably stuff like Atoms in X11 that don’t translate well. If someone can recommend an MVP for porting, that would be cool.

Scott says:

As for porting ivtools to "native" Wayland, I would consider not porting the glyph toolkit that came with InterViews (gtk and Java Swing became the future, not InterViews or Fresco) but instead port the core of the Unidraw framework currently built on top of InterViews/X11. This would mean just the canvas of the drawing editor would carry on, and with the built-in networked scripting language that ivtools added it makes for a vector graphic drawing server.

Since you guys are making more use of Unidraw than I every will, I will try porting Unidraw to GSK, and leave other possibilities alone.

Note that GTK has moved to a CSS-like way of doing things. So this may be a very different kind of port, especially if Cairo uses CSS.

I am also in looking at your network scripting language, as I have written CPPON (C++ Object Notation).

I hear there’s a bit of rebellion against GTK4, but I will continue with GSK, if it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants