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

Implement tooltip level on Windows platform #1737

Merged
merged 3 commits into from
May 2, 2021
Merged

Conversation

djeedai
Copy link
Contributor

@djeedai djeedai commented Apr 25, 2021

Implement WindowLevel::Tooltip on Windows platform.

Before change:

  • Tooltip window appear in taskbar
  • Window has strange min-size (probably due to OS min constraints)
  • Window steals focus from main app window (see grayed out title bar of main app)

image

After change:

  • Tooltip window doesn't appear in taskbar
  • Window fits any size (tested with nursery's tooltip.rs)
  • Window doesn't steal focus from main app window

image

Details

The change adds SWP_NOACTIVATE in many calls to ShowWindow() to prevent unwanted Win32 activation stealing the focus. SWP_NOOWNERZORDER is also added, inspired by Qt5 (see here).

Some is_focusable boolean is added to the state to discriminate between a regular "restore" and a non-activating show when ShowWindow() is called, because the former implicitly activates the window, stealing focus from the main app window and giving it to the tooltip.

Tentative WS_ and WS_EX_ flags are set for WindowLevel::Modal and WindowLevel::DropDown. They have not been tested, but feel like a good starting point for whoever's coming next to implement those. In particular note that DropDown almost surely wants to be WS_CHILD to allow keyboard focus while not graying out the main app window title bar. However, because they have not been tested, WindowBuilder::set_level() continues to emit a warning for those levels, and ignore them for now for consistency with the current behavior.

Implement `WindowLevel::Tooltip` on Windows platform.

Before change:
- Tooltip window appear in taskbar
- Window has strange min-size (probably due to OS min constraints)
- Window steals focus from main app window

After change:
- Tooltip window doesn't appear in taskbar
- Window fits any size (tested with nursery's `tooltip.rs`)
- Window doesn't steal focus from main app window
@arthmis
Copy link
Collaborator

arthmis commented Apr 28, 2021

Ok where did you find how to make the tooltip not steal focus? I was searching on how to do that but I came up empty. Where did you find about the calls to ShowWindow() stealing focus? And thank you for doing this!

@arthmis arthmis added the S-needs-review waits for review label Apr 28, 2021
@arthmis
Copy link
Collaborator

arthmis commented Apr 28, 2021

I'm putting this here because this pr addresses some issues from this issue #1626

@djeedai
Copy link
Contributor Author

djeedai commented Apr 28, 2021

Many trial and error with most WS_ and WS_EX_, followed by some what-would-qt5-do look at QWidget source code. Eventually found the right combination. 😏

Copy link
Collaborator

@jneem jneem left a comment

Choose a reason for hiding this comment

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

I'd be happier if someone who knows windows took a look, but I think it's been sitting long enough and it looks pretty much fine to me.

druid-shell/src/platform/windows/window.rs Show resolved Hide resolved
@jneem jneem added S-waiting-on-author waits for changes from the submitter and removed S-needs-review waits for review labels May 1, 2021
@jneem jneem merged commit 2ab1d75 into linebender:master May 2, 2021
@djeedai djeedai deleted the tooltip branch May 2, 2021 18:30
@djeedai
Copy link
Contributor Author

djeedai commented May 2, 2021

Thanks! 👍

@xStrom xStrom removed the S-waiting-on-author waits for changes from the submitter label May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants