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

Bugfix decorated window on windows - clickable components inside title area should work now #731

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MFlisar
Copy link

@MFlisar MFlisar commented Dec 15, 2024

Idea

Place a background composable behind the title content that handles all windows draggable header related stuff. This way, everything inside the title bar is placed on top of the composable that forwards the events to the draggable header.

Issues this solves

when clicking a dropdown menu in the title bar, the popup did not pop up until the next mouse move => fixed

TODO

  • I added a Box around the title content, apply the modifier to it instead of the title bar composable and place the title bar composable inside the box with a simple fillMaxSize Modifier - I'm pretty sure it does not change anything, still, it needs to be tested on mac and linux as well once
  • the macos implementation does use customTitleBarMouseEventHandler as well - it may be necessary to use the same fix there? I don't know, I don't have a mac and I don't know if the mac has the same issues
  • for the sake of minimal adjustments I kept the customTitleBarMouseEventHandler as is (also because I don't know how it is used on mac) - it may be possible to simplifiy it like following as there is no need to try to detect if we are over a user control or not anymore because of the layerig of the background composable and the content.
internal fun Modifier.customTitleBarMouseEventHandler(titleBar: CustomTitleBar): Modifier =
    pointerInput(Unit) {
        val currentContext = currentCoroutineContext()
        awaitPointerEventScope {
            while (currentContext.isActive) {
                awaitPointerEvent(PointerEventPass.Main)
                titleBar.forceHitTest(false)
            }
        }
    }

Fix #368

@rock3r rock3r self-requested a review December 15, 2024 12:51
@rock3r rock3r added the bug Something isn't working label Dec 15, 2024
@rock3r
Copy link
Collaborator

rock3r commented Dec 16, 2024

Hi, I ported & tested the change on macOS and it doesn't seem to make any difference with the previous behaviour. Dragging the title bar sometimes works, and sometimes it doesn't. I can't figure out what the reason is... there doesn't seem to be much of a pattern. I also tried mucking around a bit with the code to see if I could get it to work, but it still has the same issue. This needs some more investigation...

rock3r added a commit that referenced this pull request Dec 16, 2024
@rock3r
Copy link
Collaborator

rock3r commented Dec 16, 2024

@MFlisar I pushed the tweaks I did locally to a PR on your fork, if you want to incorporate them: MFlisar#1

@MFlisar
Copy link
Author

MFlisar commented Dec 16, 2024

Can you tell me if the click behavior on the dropdown menu is the same as for me (before and after)? If so, can you reproduce the improvement in this case?

Actually I can't see any issues with drag&drop, it behaves as it should for me when I play around for a few minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dragging on the TitleBar to move the window does not always work
2 participants