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

impr: Restore native macOS title bar double click gesture in borderless mode #1689

Merged
merged 5 commits into from
May 20, 2024

Conversation

mentlerd
Copy link
Contributor

@mentlerd mentlerd commented May 19, 2024

Problem description

Problem 1

In borderless mode ImHex disables the standard macOS titlebar rendering and input processing. As a result double clicking the titlebar does not trigger the native macOS behavior set in System Settings -> Desktop & Dock -> Double-click a window's title bar to [Zoom/Minimize/Do nothing].

Problem 2

The ImHex window shows up as blank/transparent when de-minimizing it from the dock.

Problem 3

Widgets experience ghost hover inputs from the past position of the cursor during live resizing.

Implementation description

ImGui elements consume input events in the order they are drawn. As a result by "drawing" an InvisibleButton over the content area of the titlebar we can catch unprocessed clicks in the titlebar area. Connecting this button's double clicks to the native window is then a trivial endeavour.

The blank windows was caused by the rendering stack clearing the GL buffer, but proceeding to draw nothing in it. I have short circuited this path.

Ghost hover inputs were squelched by consistently moving the ImGui cursor to 0, 0 during a live resize. The OS will dispatch a cursor positioning event once the resizing ends, restoring normal behavior.

Screenshots

N/A

Additional things

N/A

@WerWolv
Copy link
Owner

WerWolv commented May 19, 2024

Is this really a native macOS feature? None of my Windows allow for that by default. I'm using the Rectangle app though that adds gestures like that which seems to work fine on ImHex as well.
Are you using a tool like that as well maybe?

@mentlerd
Copy link
Contributor Author

mentlerd commented May 20, 2024

Is this really a native macOS feature? None of my Windows allow for that by default. I'm using the Rectangle app though that adds gestures like that which seems to work fine on ImHex as well. Are you using a tool like that as well maybe?

It is, you can find the setting here:
image

On the other hand I was not aware that there are multiple options here. The code now handles them all: 66223e0

While testing I have also found a couple of small bugs relating to window resizing/minimizing. Squashed those too. I'll update the PR description in a moment

@WerWolv WerWolv enabled auto-merge (squash) May 20, 2024 08:49
@codecov-commenter
Copy link

codecov-commenter commented May 20, 2024

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 1.51%. Comparing base (666dc7d) to head (a62127a).

Files Patch % Lines
main/gui/source/window/window.cpp 0.00% 9 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #1689      +/-   ##
=========================================
- Coverage    1.51%   1.51%   -0.01%     
=========================================
  Files         275     275              
  Lines       27006   27008       +2     
  Branches    14473   14474       +1     
=========================================
  Hits          409     409              
- Misses      26339   26341       +2     
  Partials      258     258              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@WerWolv WerWolv disabled auto-merge May 20, 2024 09:27
@WerWolv WerWolv merged commit 751eff0 into WerWolv:master May 20, 2024
16 of 17 checks passed
@mentlerd mentlerd deleted the titlebar_click_PR branch May 20, 2024 10:25
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

3 participants