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

Dynamically selecting between X11 and Wayland backend #686

Open
Vendicated opened this issue Aug 9, 2023 · 7 comments
Open

Dynamically selecting between X11 and Wayland backend #686

Vendicated opened this issue Aug 9, 2023 · 7 comments
Labels
question Further information is requested

Comments

@Vendicated
Copy link

Using --tags wayland, it is possible to create a wayland binary

However, I haven't found a way to create one binary that will run on both x11 and wayland, dynamically selecting the correct backend.

Is there any good way to do so? It seems like go-glfw doesn't even let you specify both x11 and wayland tag at once

GLFW itself does seem to support this though, see glfw/glfw@56a4cb0

@gucio321
Copy link
Collaborator

@Vendicated I can't reproduce.
For me one giu binary works on both wayland and xorg

@gucio321 gucio321 added the invalid This doesn't seem right label Aug 11, 2023
@gucio321 gucio321 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 24, 2023
@Vendicated
Copy link
Author

Vendicated commented Dec 25, 2023

Apologies for the late reply, I'm only now looking into this again

Are you sure you're not just running the binary through XWayland?

For me, when compiling with -tags wayland, it will fail to open on X11 with

2023/12/25 00:49:35 PlatformError: Wayland: Failed to connect to display
panic: NotInitialized: The GLFW library is not initialized

When compiling without the tag and using Wayland, it will open in XWayland. Or, if you are not using XWayland, error with

2023/12/25 00:59:38 PlatformError: X11: The DISPLAY environment variable is missing
panic: NotInitialized: The GLFW library is not initialized

glfw has a GLFW_PLATFORM hint you can set to explicitly pick wayland/x11, introduced by the above linked commit that adds automatic platform selection, but go-glfw doesn't seem to even have this code. Does that mean it hasn't updated its glfw files to have that commit?

I tried to hardcode the values in my code (glfw.InitHint(0x00050003, 0x00060003)) but it paniced with panic: InvalidEnum: Invalid init hint 0x00050003

Looking more at go-glfw source, it seems like X11 and Wayland are mutually exclusive:

So it seems this is something that needs to be fixed by go-glfw?

I'm sorry if i'm missing anything. Help would be greatly appreciated

@gucio321
Copy link
Collaborator

Could you try with the latest code?
We're not using gogl glfw anymore

@Vendicated
Copy link
Author

Vendicated commented Dec 25, 2023

Oh I missed that. I did a go get -u but it didn't upgrade to that

Anyway, I updated to latest main and it's still failing without XWayland. Do i have to pass any specific build tags?

Glfw Error 65544: X11: The DISPLAY environment variable is missing
panic: Failed to initialize GLFW

goroutine 1 [running, locked to thread]:
github.com/AllenDang/cimgui-go.NewGLFWBackend(...)
	/home/vee/go/pkg/mod/github.com/!allen!dang/[email protected]/glfw_backend.go:201
github.com/AllenDang/giu.NewMasterWindow({0xd13a6a, 0x11}, 0x4b0, 0x320, 0xc000030000?)
	/home/vee/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:88 +0x4ac
main.main()
	/home/vee/Coding/Installer/gui.go:70 +0x9c

(On a side note, Text is also really messed up but you might already be aware of this?)

@gucio321
Copy link
Collaborator

Ok, let me check this

@gucio321 gucio321 reopened this Dec 25, 2023
@gucio321

This comment was marked as off-topic.

@gucio321 gucio321 added question Further information is requested and removed invalid This doesn't seem right labels Jul 7, 2024
@gucio321
Copy link
Collaborator

giu uses glfw v3.3.
TO support wayland we need v3.4+ which has however no full wayland support yet (I mean multiviewpor feature. see AllenDang/cimgui-go#314).
Waiting for next glfw release then.

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

No branches or pull requests

2 participants