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

Windows without decorations #427

Closed
crsaracco opened this issue Dec 29, 2019 · 9 comments · Fixed by #1583
Closed

Windows without decorations #427

crsaracco opened this issue Dec 29, 2019 · 9 comments · Fixed by #1583
Labels
enhancement adds or requests a new feature help wanted has no one working on it yet

Comments

@crsaracco
Copy link
Contributor

(Priority: super low)

I'd like to be able to create windows without the titlebar or borders, in order to make my own custom thing.

For example, Bitwig made its own titlebar so it could add more stuff to it:

bitwig-no-titlebar

In GTK land, this is done with gtk_window_set_decorated.

@Zarenor
Copy link
Collaborator

Zarenor commented Dec 29, 2019

For Windows, we'd need a way to adjust the window style being provided to CreateWindow - currently it's always WS_OVERLAPPED - we'd need WS_POPUP for borderless, I think. Then we will need to make it clear how to create the minimize, maximize/restore, and close buttons. And any resize border the user wants.

So, maybe a little complex, but definitely something I'd like to see.

In general, if you have the time, I think we're open to seeing something created for one platform and letting the others trail until we can get a good design story and make a workable API. I'm not sure if we're okay with that approach for something this large

@cmyr
Copy link
Member

cmyr commented Dec 30, 2019

So this is totally a goal, and is highly platform dependent.

I see there being two ways of handling this. The first is better API but less flexible: a WindowDescExt traits exposed on a per-platform basis, that allow doing platform-specific customization. This is inspired by the various traits in stdlib like OsStrExt, DirBuilderExt, etcetera. For platform specific behaviour (like setting the NSWindowStyleMask on macOS) you would do that via a method on an extension trait.

The other option is to allow (per-platform) for the WindowDesc to take a closure that will be given a pointer to a window object on that platform, where you can do whatever you want; we would call this right after instantiating the window. This would let you do anything you can do with access to the window object, although it wouldn't work for things that you do during a window creation routine.

It may be but this particular case is general enough that we can just add it to WindowDesc and WindowBuilder directly, in which case you can ignore my comment above, although I still think something like this is something we will want eventually.

@cmyr cmyr added enhancement adds or requests a new feature help wanted has no one working on it yet labels Dec 30, 2019
@futurepaul
Copy link
Collaborator

Here are the related options in Electron for reference: https://electronjs.org/docs/api/frameless-window

@iulianR
Copy link

iulianR commented Jan 6, 2020

winit has some methods on WindowBuilder, including with_decorations() which seem to work for all platforms, so maybe the methods WindowBuilder has should not be part of a WindowDescExt, but instead be available in WindowDesc directly. Then there are additional methods on WindowBuilderExtUnix which only work for Unix platforms and would probably fit in a platform specific extension trait.

Maybe you would like to mirror that in druid as well? I would be glad to implement something which would add support to druid for the attributes available in WindowBuilder (with_*() methods) if you decide what needs to be done and give some indication or outline the API.

@cmyr
Copy link
Member

cmyr commented Jan 7, 2020

Yea, I think this would be welcome; things that are missing in our current API are not design choices, just things we haven't gotten around to yet.

@kelcied
Copy link

kelcied commented Jan 14, 2020

Has any work been done on this? I am not quite sure where to start on it, but I am going to be looking into it during my free time. Currently I have been looking at how winit handles this as an example.

@cmyr
Copy link
Member

cmyr commented Jan 14, 2020

I do not believe anyone is actively working on this, but I could be wrong.

I'm not sure if winit will be a great example for us, but I haven't looked too closely; it's certainly possible. :)

@Ciantic
Copy link
Collaborator

Ciantic commented Feb 11, 2021

IMO, it's not enough to hide the titlebar, when this is done properly, one could draw even a window that is shaped like a circle, even Electron allowes to do that which is kind of cool. In Windows it's trivial to hide the titlebar, but getting semi-transparency effects is much harder.

In Windows 10 this behavior is closely related to composited Window. For instance a non-rectangular windows like tooltips, and or other popups with custom shadows or effects etc.

I toyed around the window creation settings a lot, and figured the perfect combination few years back in my C++ experiments. To get semi-transparency effects with no borders and non-rectangular windows one needs WS_EX_COMPOSITED with D2D drawing surfaces like in Druid. (If I remember correctly, it's not possible to turn the window to composited after creation, so that needs to be set during creation)

@Ciantic
Copy link
Collaborator

Ciantic commented Feb 11, 2021

I have now a fork, where I experiment this:

My intention is to add a following API:

let window = WindowDesc::new(example)
        .show_titlebar(false) // <-- THIS ALREADY EXISTS
        .window_size((823., 823.))
        .transparent_bg(true) // <-- NEW ITEM HERE for transparency
        .resizable(true)
        .title(LocalizedString::new("Fancy Colors"));

I will continue about this in the Zulip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement adds or requests a new feature help wanted has no one working on it yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants