SDL icon indicating copy to clipboard operation
SDL copied to clipboard

wayland: Implement Non-Zenity MessageBox

Open flibitijibibo opened this issue 4 years ago • 8 comments

With libdecor coming together it really seems like we're close to getting Wayland fully production ready... except oh crap I completely forgot there's no MessageBox implementation at all. This is pretty important to have if we want to preserve application error handling, the SDL_assert UI, and various other things like that.

Unlike lots of other parts of the video subsystem we can't really take notes from X11, since I don't think there's anything remotely close to what we do for that driver:

https://github.com/libsdl-org/SDL/blob/main/src/video/x11/SDL_x11messagebox.c

If we got desperate we could run a zenity subprocess, but that's if there's genuinely no way to do bare-bones popups through Wayland.

flibitijibibo avatar Mar 23 '21 19:03 flibitijibibo

I think we're absolutely going to have to use zenity, as there's no barebones widgets and no built-in font rendering at all that we can build on top of, and we're not going to want to link against something like GTK or Cairo to get those things.

The best solution here is likely going to be adding a function to libdecoration.

But we could build out the world's simplest UI, using SDL's render API to draw rectangles for buttons, and pack an extremely small and low-ASCII-only bitmap font into static data. It's not out of the question, it just wouldn't look remotely good.

icculus avatar Mar 25 '21 20:03 icculus

Considering what the X11 box looks like I guess appearance isn't everything... but the font is the scary part since we do in a lot of cases have to go way beyond ASCII support. Rendering stuff is easy, rendering text not so much.

But if zenity is on the table, I would just go straight for that. Not sure how hard it is to do a whole complete implementation but ShowSimpleMessageBox would be dead simple to scribble together!

flibitijibibo avatar Mar 25 '21 22:03 flibitijibibo

Definitely start with zenity. We can rip it out or keep it as a fallback as better options arise in the future.

If zenity fails to launch, just return -1.

icculus avatar Mar 25 '21 22:03 icculus

Wrote up the implementation... it was less work than I was expecting!

flibitijibibo avatar Mar 26 '21 03:03 flibitijibibo

Going to leave this issue open for now, as a "this isn't meant to be the final result," but I'll absolutely accept it for the time being!

Thanks Ethan!

icculus avatar Mar 26 '21 03:03 icculus

Opened up #4236 to fix something I didn't copy over in my test program... what I get for trying to work on this in an X environment!

flibitijibibo avatar Mar 26 '21 04:03 flibitijibibo

Since there's a Zenity one, can we also support KDialog too?

Conan-Kudo avatar Sep 12 '21 20:09 Conan-Kudo

It probably could, this is the only file you have to worry about:

https://github.com/libsdl-org/SDL/blob/main/src/video/wayland/SDL_waylandmessagebox.c

flibitijibibo avatar Sep 13 '21 20:09 flibitijibibo

I've looked through the Kdialog options, and it doesn't support adding arbitrary buttons like Zenity does. It only supports some premade message box formats, like --yesno, --yesnocancel, --menu, etc. The only Kdialog option I think might be usable to implement SDL's MessageBox API is --radiolist, with a separate entry for each button the user provides. But that probably doesn't look like what the user is expecting to see:

kdialog --radiolist radiolist tag0 item0 off tag1 item1 off tag2 item2 off tag3 item3 off

image

diagonalisability avatar Oct 20 '22 22:10 diagonalisability

With the above in mind, going to change this into a new issue: #6422

Aside from that, Wayland doesn't really have anything special about it... zenity is near-ubiquitous and we have an emergency fallback for the unsupported case; KDialog is the only alternative I'm aware of that doesn't involve GTK/Qt/handmade text rendering and it's too limited to support the API as-is.

With that in mind, closing as WONTFIX, any option that would fix this would fit into #6422.

flibitijibibo avatar Oct 20 '22 22:10 flibitijibibo