tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[feat] Snap layouts support on Windows when using frameless windows

Open grislux55 opened this issue 2 years ago • 3 comments

Describe the problem

Details about snap layouts

If I use the window decorations provided by Tauri, then I can use snap layouts.

snap layouts

If I set the window to "decorations": false, the window will not be able to use snap layouts.

no snap layouts

Describe the solution you'd like

Tauri already uses data-tauri-drag-region to support window dragging, so we might consider introducing a attribute like data-tauri-maximize-button-region to support this feature.

This should work as follows.

<div data-tauri-drag-region class="titlebar">
  --- omitted ---
  <div data-tauri-maximize-button-region class="titlebar-button" id="titlebar-maximize">
    <img
      src="https://api.iconify.design/mdi:window-maximize.svg"
      alt="maximize"
    />
  </div>
  --- omitted ---
</div>

Alternatives considered

Platform-specific window behavior is very complex, and leaving window behavior to the user can be tricky to implement.

Electron provides BrowserWindow to handle similar issues.

Tauri can provide similar built-in components, which will also be easy to manage and optimize.

Additional context

No response

grislux55 avatar Jun 30 '22 07:06 grislux55

This would be something very interesting to have, it's then easier to make an app look Window's native

AZProductions avatar Jul 10 '22 07:07 AZProductions

Are there any plans on supporting snap layouts?

AZProductions avatar Jun 22 '23 12:06 AZProductions

Yes, or maybe "wishes" instead of "plans". Anyway, the lack of information is my bad, i only ever talked about this in other issues and on discord. So here's a tldr: The snap layout can only be openend by reacting to the NC_HITTEST message. Unfortunately these messages are not sent for clicks inside the webview. The webview2 team is working on an api proposal that should help us here though: https://github.com/MicrosoftEdge/WebView2Feedback/pull/3367 but who knows when it will be merged and actually implemented.

FabianLars avatar Jun 22 '23 13:06 FabianLars

Waiting for webview2 to open the api I think is irrational, although there are compatibility issues with adaptation.

mchao123 avatar Sep 30 '23 04:09 mchao123

Yes, or maybe "wishes" instead of "plans". Anyway, the lack of information is my bad, i only ever talked about this in other issues and on discord. So here's a tldr: The snap layout can only be openend by reacting to the NC_HITTEST message. Unfortunately these messages are not sent for clicks inside the webview. The webview2 team is working on an api proposal that should help us here though: MicrosoftEdge/WebView2Feedback#3367 but who knows when it will be merged and actually implemented.

Looks like it has been merged now.

hazre avatar Nov 06 '23 01:11 hazre

Wish it will be implemented in the standard tauri v2 :)

AClon314 avatar Mar 30 '24 03:03 AClon314

This won't be implemented for v2 since we're still blocked by webview2. The pr from their repo I linked above was sadly for their composition based apis only and we currently can't use those.

FabianLars avatar Mar 30 '24 09:03 FabianLars