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 2 commits 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 #424

@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.

@rock3r
Copy link
Collaborator

rock3r commented Dec 17, 2024

@MFlisar the dropdown in the standalone sample works fine for me on the main branch if that's what you're asking

@MFlisar
Copy link
Author

MFlisar commented Dec 17, 2024

Sorry for being so detailed, but does that mean that the popup always opens immediately without the need to move the mouse after the click for one pixel?

Because that is the issue this pull requests solves for me on windows 11, latest release version...

@rock3r
Copy link
Collaborator

rock3r commented Dec 17, 2024

@MFlisar ah, no — I thought this was a fix for #368, but you're saying it's for #424 instead? I have been trying to repro and assess it as a fix for the former, as you started the discussion on #368

@rock3r
Copy link
Collaborator

rock3r commented Dec 17, 2024

To be clear, #424 is only happening on Windows, not on Mac nor Linux

@MFlisar
Copy link
Author

MFlisar commented Dec 17, 2024

To be clear, #424 is only happening on Windows, not on Mac nor Linux

Yes, that's the issue... I'm sorry, I commented in the wrong issue because you linked to it from my issue (#729) - with this fix I can use a menu that works on windows.

@rock3r
Copy link
Collaborator

rock3r commented Dec 17, 2024

Ah, sorry for the confusion! @hamen since you reported #424, can you check if this PR solves the issue for you?

@rock3r rock3r requested a review from hamen December 17, 2024 13:54
@hamen
Copy link
Collaborator

hamen commented Dec 17, 2024

It seems to be working on Windows 👍🏻

Recording2024-12-17160316-ezgif com-video-to-gif-converter

Copy link
Collaborator

@hamen hamen left a comment

Choose a reason for hiding this comment

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

Tested successfully on Windows 11

Signed-off-by: Ivan Morgillo <[email protected]>
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.

Welcome menu glitch on Windows 11
3 participants