WerWolv / ImHex

🔍 A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.
https://imhex.werwolv.net
GNU General Public License v2.0
39.54k stars 1.74k forks source link

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

Closed mentlerd closed 1 month ago

mentlerd commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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: https://github.com/WerWolv/ImHex/pull/1689/commits/66223e09dd8f4b2f028c01c2e1331b4739e852dd

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

codecov-commenter commented 1 month ago

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 :warning:

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.