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

[Client side decorations] Implement window drag handles. #80891

Closed
wants to merge 1 commit into from

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Aug 22, 2023

Based on #16512

Implements more features for godotengine/godot-proposals#4846

Adds support for adding custom native window move / resize handles.

  • X11
  • Windows
  • macOS
Screen.Recording.2023-08-22.at.16.00.21.mov

Test Project: test.zip

Fixes godotengine/godot-proposals#11214
Fixes window moving lag issues on macOS.

@ryanabx
Copy link
Contributor

ryanabx commented Aug 22, 2023

Interesting! As this is marked as a draft, what is still left to work on?

@bruvzg bruvzg force-pushed the client_decor branch 2 times, most recently from 855e909 to 8a50347 Compare August 22, 2023 21:03
@Calinou
Copy link
Member

Calinou commented Aug 22, 2023

@bruvzg Can you upload the project you used for testing? Thanks in advance 🙂

@Riteo
Copy link
Contributor

Riteo commented Aug 23, 2023

This looks amazing! It would be extremely useful with the Wayland backend as not all compositors have SSDs and we're relying on a third party library for CSDs with all the implication that brings.

I know that this is WIP, but I notice that you're including a WindowDecoration class and an associated editor plugin. Does this imply that you're actually finalizing CSDs or is this just an iterative step towards them?

I'd be very interested giving some help if needed.

@bruvzg
Copy link
Member Author

bruvzg commented Aug 23, 2023

Can you upload the project you used for testing?

Added test project to the first post.

I know that this is WIP, but I notice that you're including a WindowDecoration class and an associated editor plugin. Does this imply that you're actually finalizing CSDs or is this just an iterative step towards them?

For now, it's just a mover / resizer. I'm not sure if there is anything else necessary for the CSDs. I guess window min/max/close buttons, but the only platform specific about them is snap/display switch popup menu for the maximize button on macOS/Windows, and checking if how minimized/minimized states works with the borderless window.

@Riteo
Copy link
Contributor

Riteo commented Aug 23, 2023

I'm not sure if there is anything else necessary for the CSDs.

The only thing I'm not really sure about is how you plan to actually frame some pretty decoration. Will the decoration object be a parent of Window?

@ryanabx
Copy link
Contributor

ryanabx commented Aug 24, 2023

The only thing I'm not really sure about is how you plan to actually frame some pretty decoration. Will the decoration object be a parent of Window?

Is the framing of the decorations necessary for this PR? Or could it be a separate PR

@bruvzg
Copy link
Member Author

bruvzg commented Aug 24, 2023

The only thing I'm not really sure about is how you plan to actually frame some pretty decoration. Will the decoration object be a parent of Window?

Currently, it's children of the Window. WindowDecoration is a normal Control node, can be placed anywhere (and optionally hold a polygonal region for more customization), so any drawing methods can be used. I do not see any reason to restrict it to the actual frame around the window. But I guess something similar to GTK HeaderBar control might be useful as well.

@Riteo
Copy link
Contributor

Riteo commented Aug 25, 2023

@bruvgz oh I see, so it's more of a sort of optional pretty thing one can add. Am I understanding correctly?

For my use-case I'd prefer a default case but I'm aware that this is very annoying if not impossible with the way that windows are implemented (pretty much fancy viewports).

@Mervius
Copy link

Mervius commented Aug 13, 2024

So I tested this and that project a bit and there seems to be an issue with the resize bottom handles where they either stop working completely or stop working until you resize using a different handle.
However, they do appear to still work if you click and drag where they used to be before resizing, so maybe the location just isn't updating properly.
It might also just be an issue with the project as it seems to work in a new one

There is one thing I don't quite like, and it's that you can't tell if the region is actually being clicked on or if the mouse button is pressed while dragging or moving, which means you can't really implement double click maximise/restore for the custom titlebar(technically, you can use a janky method, since you can get a mouse movement event when releasing the mouse button on the titlebar. So you can setup two timers to detect two mouse movement events with a click mask of 0 within a certain timeframe, but not too fast as to accidentally trigger on the buggy double-input you sometimes get from a single mouse release).

Edit: It seems that the window decorations do not appear to properly update their position if they are inside containers, which makes some more complex layouts difficult and/or impossible

@bruvzg bruvzg force-pushed the client_decor branch 3 times, most recently from 3edfade to c5311ca Compare November 24, 2024 10:18
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on Windows 11 23H2 (rebased on top of master 0eadbdb), there's an issue:

I can see the mouse cursor changing when hovering one of the corners (the area outside the red triangle here):

image

However, left-clicking and dragging does nothing.

I also don't see a horizontal/vertical resize cursor appearing when hovering the window edges, only the diagonal resize cursors at the corners.

PS: The resize cursors appear even if Resizable is disabled in the Project Settings, which is strange.

@bruvzg
Copy link
Member Author

bruvzg commented Nov 28, 2024

However, left-clicking and dragging does nothing.

Yes, I have noticed that after last rebase, something seems to change and resize handles only work if window have think border enabled (not sure if it's Windows change or something with our window style flags).

@bruvzg
Copy link
Member Author

bruvzg commented Dec 17, 2024

Superseded #100464 and #100532 (works on all platforms and allow implementing custom decorations in more Wayland friendly way).

@bruvzg bruvzg closed this Dec 17, 2024
@AThousandShips AThousandShips removed this from the 4.x milestone Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use native window drag handles on macOS when Expand to Title is enabled, making window tiling functional
6 participants