wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.03k stars 1.2k forks source link

Show Windows 11 SnapAssist on hover of Max #2237

Open merlindru opened 1 year ago

merlindru commented 1 year ago

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

in Win 11 when you hover over the Maximize button you should see snapassist image

This doesn't fire in VS Code, Teams (electron apps) or Windows Terminal (custom owner draw title bar)

The Electron Core (whomever is responsible for the Maximize button) needs to implement WM_NCHITTEST and reply with HTMAXBUTTON when the hit test is over top of the max button. That will tell Windows it's a Max button which helps Accessibility AND fires SnapAssist.

minimize button image

We could expose a CSS variable to mark minimize/maximize/close buttons, just like --wails-draggable

https://github.com/microsoft/vscode/issues/140932

Describe alternatives you've considered

No response

Additional context

No response

leaanthony commented 1 year ago

Thanks for opening this. Wails uses native controls so I'm curious about your thinking with CSS variables

merlindru commented 1 year ago

@leaanthony I'm not sure how --wails-draggable: drag is implemented, but couldn't we add --wails-window-control: maxbutton and then respond like this in WndProc WM_NCHITTEST?

I don't know anything about Win32 API development, I just found these ^ thru googling and saw that Wails implements a function called "WndProc" in it's win32 internals

merlindru commented 1 year ago

This would put Wails one step ahead of Electron, I think, because you can designate any element as a window control.

Electron only supports PWA-style controls:

leaanthony commented 1 year ago

Oh, you're talking about frameless windows? I'll come back to you when all this Christmas stuff is over 🤣

merlindru commented 1 year ago

Yes!! Sorry, should've made that more clear :P

leaanthony commented 1 year ago

@merlindru - Oops this totally slipped off the radar. I'm very keen on adding this to v3.

stffabi commented 1 year ago

IIRC this is pretty hard to achieve in the current way the WebView2 is hosted on the Window and goes more or less down the same route as for frameless dragging. The problem is the WM_NCHITTEST never gets fired on the Window because it is directly catched by the WebView2 when using frameless. I think this is only achievable by using composition hosting of the WebView2, which is a greater refactoring. But it would be awesome to support this, we would take some efforts to test composition hosting and for testing if it is really going to allow us to support this.