slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.94k stars 568 forks source link

Override redirect type of root Window (force floating, force geometry)? #2289

Closed Animeshz closed 8 months ago

Animeshz commented 1 year ago

Applications like rofi / dmenu / launcy / alfred / wox, etc uses something called as override-redirect to make them appear at the middle (or some specific location) on the screen bypassing the interference of the window-manager and other utilities.

(PS: We can also start rofi as normal window with rofi -normal-window to see the difference)

It allows them to draw custom popup menu anywhere on the screen, including on tiling window managers, on their own decision.

It is very useful for applications including:

Is there support for this in slint already, or can there be support for this? I would like to make a few applications on this purpose, and finding it difficult to find a good fit framework instead of going system-specific library for each platform...

I'm open for any discussion!

Animeshz commented 1 year ago

e.g. For x11, implementation in dmenu

tronical commented 1 year ago

I think that's a very reasonable request. I can think of two ways of fitting this in:

  1. You run your own event loop, create the window with winit and use low-level winit API to configure the window. The downside is that this requires also using low-level Slint platform API and at the moment only the Software Renderer is available for use here. We're working on splitting out the Skia and FemtoVG renderers (in #2142) into separate crates, but they don't have public API yet.

  2. We expose the raw window handle (as per #877) and then you configure window attributes after creation.

I think 2. is the cleaner approach in a way, but it's not ready yet. 1. is more flexible in the long run, but requires the use of private API at the moment :(

What do you think?

tronical commented 1 year ago

In https://github.com/slint-ui/slint/pull/2617 we added a third way: provide access to the winit window.

ogoffart commented 8 months ago

I discussed with @tronical and we thought that this is an exotic API and it can only be done using the internal API and using winit API.