raysan5 / raylib

A simple and easy-to-use library to enjoy videogames programming
http://www.raylib.com
zlib License
22.27k stars 2.24k forks source link

[rcore] Allow opening wayland layer surfaces with raylib #4009

Closed coffeeispower closed 4 months ago

coffeeispower commented 4 months ago

Issue description

I'm developing a project called woomer which is a clone of tsoding's boomer but for wayland using raylib, it allows you to zoom into your desktop using your mouse wheel and move around by dragging.

However i ran into a bit of an issue in coffeeispower/woomer#5 , which is that as it says in the issue, if you open woomer while having a fullscreen application, it makes the other application exit fullscreen mode because woomer is just a fullscreen window opened with raylib.

The solution to this is using wayland layer surfaces which are special windows that applications can open to make themselves part of the desktop like for example bars, menus, application launchers and etc, they're not tiled by tiling window managers, you can make them always appear on top of all applications and you can make them fullscreen without excluding normal windows.

I think we can probably use a config flag in SetConfigFlag, something like SetConfigFlag(FLAG_OPEN_WAYLAND_LAYER)

raysan5 commented 4 months ago

@coffeeispower I'm afraid I try to avoid platform-specific code in the main raylib API but beside that, I don't know the complexity of implementing that kind of feature, raylib is not ready to support multi-window contexts.

Please, let me know if you further investigate this feature implementation.

coffeeispower commented 4 months ago

Well, i'm not asking to open multiple windows, what i'm asking is to be able to just change the way raylib opens the window, it's still a single window, just opened differently. Also a important thing i forgot is that layers can be anchored to specific places on the screen like in the middle, top, bottom, left, right, the corners and etc and choose to make the window manager reserve space specifically for the layer so windows from other applications don't overlap with it like in the case of taskbars

raysan5 commented 4 months ago

@coffeeispower What is the code complexity involved for this issue and how many users will really benefit from it? In any case, I recommend implementin this feature on user fork to cover the specific needs and after testing it can be considered for raylib.

coffeeispower commented 4 months ago

It's really not that complicated, i'm considering making a pull request if you would accept it. The code complexity of it would just add a couple config flags, then pull the wayland surface handle from glfw and then use libwayland-client to convert it into a layer surface when opening the window. raylib already depends on libwayland-client indirectly because of glfw, so we're not going to add anymore dependencies if you're afraid of that.

coffeeispower commented 4 months ago

About how many people will benefit from it is people who want to build widgets and parts of their wayland desktop using raylib, because raylib is a really good abstraction on top of opengl. Like a good use case would be to have a keybind on hyprland that opens a dashboard thingy with common actions, applications, system monitor and etc, if you could use raylib for that it would be kinda cool Or for example screenshotting tools, things like hyprpaper for wallpapers on hyprland also use wayland surface layers

coffeeispower commented 4 months ago

Adding this kind of feature could open the gate for many cool projects and utilities on linux

raysan5 commented 4 months ago

@coffeeispower If you implement it, feel free to send a PR for review but I can't assure it will be accepted, but it will be reviewed.

coffeeispower commented 4 months ago

If you implement it, feel free to send a PR for review but I can assure it will be accepted

Cool! I'll do it once i can!

but it will be reviewed

No problem, every PR has to be reviewed to match the standards of the project

raysan5 commented 4 months ago

@coffeeispower Sorry, I wrote it wrong, I can't assure it will be accepted.

coffeeispower commented 4 months ago

That was the worst mistake ever :skull:

raysan5 commented 4 months ago

@coffeeispower Sorry, I did not pretend to create false expectations...

Peter0x44 commented 4 months ago

The code complexity of it would just add a couple config flags, then pull the wayland surface handle from glfw and then use libwayland-client to convert it into a layer surface when opening the window. raylib already depends on libwayland-client indirectly because of glfw, so we're not going to add anymore dependencies if you're afraid of that.

We don't currently have any platform specific config flags. This feature sounds like it would be better suited for a user fork, but I'm not completely sure what is involved.

davawen commented 4 months ago

As someone making an application launcher with raylib (and hoping to make it wayland first), this feature would be really great!
Of course, raysan decides what goes in, and if I have to use a user fork for it, I will.
But, if the required code is not too complex and adds very little api surface, it would be a waste not to have it, given how useful it would be to anyone developing wayland widgets, as @coffeeispower said.

raysan5 commented 4 months ago

@davawen if you really need it, feel free to implement it and send a PR for review.

colesnicov commented 1 month ago

I agree. This functionality is essential!