p0deje / Maccy

Lightweight clipboard manager for macOS
https://maccy.app
MIT License
13.05k stars 549 forks source link

[V2] Remember position when moving the popup if mode is set to center of screen #826

Closed weisJ closed 3 months ago

weisJ commented 3 months ago

If the positioning mode is set to "Screen center" after moving the Maccy-window manually the position should be saved just as for spotlight. Of course a "reset position" button in the settings would then be beneficial.

weisJ commented 3 months ago

It needs to be considered how the custom position should be interpreted on different screens. Either have it be in percentage of the width height of the screen or remember the position per screen. WDYT?

p0deje commented 3 months ago

I suppose the implementation might look similar to screen center.

  1. The user chooses "Last position".
  2. If there are multiple screens, the option has a submenu allow to either select "Active screen" or specify an exact screen to choose.
  3. For "Active screen", we need to somehow calculate the position of the window on the current screen relative to its resolution. For example, if window origin is (500,500) and resolution is (1000,1000), the relative origin would be saved in a format that ensures it will be interpreted as (1000,1000) on a screen with resolution of (2000,2000). This probably can be expressed as a multiplier for screen resolution (e.g. for the example we'll save originMultiplier=(0.5,0.5). Later, when Maccy pops up it would place window on the active screen and will use the multiplier to offset accordingly.
  4. For specific screen, we can still keep the multiplier but place window on the configured screen.
p0deje commented 3 months ago

As I am writing this, I realized that 2.0 misses "Active screen" in "Screen center" - it's a bug that needs to be fixed.

p0deje commented 3 months ago

I've fixed screen center logic in https://github.com/p0deje/Maccy/commit/7c844aa250fdf64466e7ce9391cfb1ceca7499d3, you can implement a similar SwiftUI logic for "Last position".

weisJ commented 3 months ago

829