helmerapp / micro

top notch GIFs, right from your desktop
https://www.helmer.app/micro
Other
25 stars 5 forks source link

feat: multi-display support (macOS) #95

Open vasusharma7 opened 1 month ago

vasusharma7 commented 1 month ago

This PR contributes to https://github.com/helmerapp/micro/issues/59 with following changes:

image
vasusharma7 commented 1 month ago

@Pranav2612000 @clearlysid , PTAL

clearlysid commented 1 month ago

Thanks for the PR!

A more efficient way to get multi-display to work is to just spawn the record button (and cropper, etc.) on the display that the mouse cursor is present on instead of making 4 croppers and 4 record buttons.

  1. on hotkey press or tray icon clicked
  2. check mouse cursor position
  3. detect monitor cursor is on
  4. spawn cropper (and record button) on the detected monitor instead of primary monitor
  5. pass on detected monitor as the scap target

You can use the monitor_from_point method to implement this, docs here: https://docs.rs/tauri/2.0.0-beta.22/tauri/struct.App.html#method.monitor_from_point

vasusharma7 commented 1 month ago

Yes that was my intention to begin with and I resonate with the process and all the steps you mentioned !

But there were a few issues ,firstly, e-spawning of windows is not possible ( that same label cant be reused even after destroying windows)

Then I tried to use the same window spawned before and just to reposition it on the correct monitor and change its inner width and other properties but certain properties were not modifiable after the window is built (.build() method is called ).

I don't correctly remember the issue( I think it was the width not getting modified ) but spent some time on this and then I tried to ship an MVP with a static number of screens.

That being said , I know it's a bad code design and bad UX to have a fixed number of screens

I feel it's the time that I take a step back now and try the above things again.

Please give me some time and I will post an update soon.

Thanks

clearlysid commented 1 month ago

certain properties were not modifiable after the window is built (.build() method is called ).

you can use the following methods:

  1. set_size: https://docs.rs/tauri/2.0.0-beta.22/tauri/window/struct.Window.html#method.set_size
  2. set_position: https://docs.rs/tauri/2.0.0-beta.22/tauri/window/struct.Window.html#method.set_position
vasusharma7 commented 1 month ago

I think I saw this Let me zoom out and give this a try again .... Will post an update soon

vasusharma7 commented 1 month ago

I have updated a few things ( few optimisations still pending ) ; however I don't have second monitor with me for 2 weeks ( in my hometown ) - so could not test it thoroughly - Still, I will try to do some hack to test it and post an update soon.

vasusharma7 commented 1 month ago

To be honest, I don't remember why I added this dependency on core graphics at first place. Me and Pranav had some initial conversations quite some time back and we realised taking this dependency from core graphics and now I don't recall why we came to this conclusion ( that was the reason behind my other initial PR on scap to expose CG deduced properties )

Anyways, I changed it to just take everything from tauri::Monitor including the position, size, scale factor etc.. now But again I couldn't test it to work on multiple monitors as I don't currently have access to those :(