focus-editor / focus

A simple and fast text editor
GNU General Public License v3.0
1.81k stars 99 forks source link

[MacOS] Caret is offset on second monitor #454

Open MrStevns opened 3 weeks ago

MrStevns commented 3 weeks ago

Describe the bug When I move a focus window onto a second monitor and start selecting something or just click on a line, the caret is offset from the cursor.

To Reproduce

  1. Open Focus and start a file with multiple lines
  2. Move the focus window to a second monitor
  3. Select or click somewhere

Expected behavior Caret position matches the cursor position

Actual behavior Caret position is offset from the cursor position.

Video

https://github.com/user-attachments/assets/6b6503af-1efd-48d0-9eb7-8b1e3cea1d85

focus-editor commented 3 weeks ago

Does it happen every time?

It doesn't reproduce on my mac, hmmm

MrStevns commented 3 weeks ago

Yes it happens consistently. I have tried to close and reopen focus too, it happens every time for me.

Ah another thing, my macbook is retina (2560x1600) while my second monitor is 1080p. Maybe the issue is caused by the difference in resolution.

focus-editor commented 3 weeks ago

Latest nightly too?

On Tue, 29 Oct 2024 at 07:41, Oliver Stevns @.***> wrote:

Yes it happens consistently. I have tried to close and reopen focus too, it happens every time for me.

Ah another thing, my macbook is retina (2560x1600) while my second monitor is 1080p. Maybe the issue is caused by the difference in resolution.

— Reply to this email directly, view it on GitHub https://github.com/focus-editor/focus/issues/454#issuecomment-2442354022, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4OX77WIT22REU5ZTAASHETZ5ZZLVAVCNFSM6AAAAABQX53UMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBSGM2TIMBSGI . You are receiving this because you commented.Message ID: @.***>

focus-editor commented 3 weeks ago

https://drive.google.com/file/d/1h1PO-Ft1_ad5-FekbvYOxr81qIt8aYvZ/view?usp=drive_link here's a build

On Tue, 29 Oct 2024 at 08:36, Ivan Ivanov @.***> wrote:

Latest nightly too?

On Tue, 29 Oct 2024 at 07:41, Oliver Stevns @.***> wrote:

Yes it happens consistently. I have tried to close and reopen focus too, it happens every time for me.

Ah another thing, my macbook is retina (2560x1600) while my second monitor is 1080p. Maybe the issue is caused by the difference in resolution.

— Reply to this email directly, view it on GitHub https://github.com/focus-editor/focus/issues/454#issuecomment-2442354022, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4OX77WIT22REU5ZTAASHETZ5ZZLVAVCNFSM6AAAAABQX53UMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBSGM2TIMBSGI . You are receiving this because you commented.Message ID: @.***>

MrStevns commented 3 weeks ago

Yep, In nightly too.

I however just discovered that when you put the application in fullscreen, the problem gets resolved temporarily for that monitor and i can now also go back to windowed mode and it still works as expected.

When I move the window back to first monitor, the caret has been offset again but only for that monitor.

So the workaround for now is to put the application In fullscreen, whenever I move the window between monitors.

focus-editor commented 3 weeks ago

I have tried it on my macOS Sequoia with different monitors and different display resolutions, can't reproduce. Could be an older macOS issue, but unfortunately I don't have a Monterey machine to test it on.

simonvallz commented 1 week ago

I am able to reproduce this and it seems to happen when the window is moved to a display with a different backing scale factor. Here is a PR with a fix that at least works for me: #467

focus-editor commented 1 week ago

On my mac there seems to be no way to select a scaling factor for a display, but I played with different resolutions and wasn't able to reproduce it. Maybe they "fixed" it in newer macOS's, but your fix seems reasonable, so we'll merge it, thanks!

focus-editor commented 1 week ago

@MrStevns please try this build https://drive.google.com/file/d/1Ue4L-zpOUs2Qc2WeN2MFuucIL-MCjV9F/view?usp=drive_link

simonvallz commented 1 week ago

I have macOS Sequoia 15.1 so I don't think it is "fixed" in newer versions. It is a 16 inch MacBook Pro with an external display with the resolution 2560x1440. I have not changed any other settings.

I also noticed the same issue when I "mirrored" my screen on a couple of different TVs. Not sure about the resolution of those.

simonvallz commented 1 week ago

(contd.) The MacBook screen reports a backing scale factor of 2 and the external display 1 with that configuration.