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

Wrong cursor on Context menu #3331

Closed
kud opened this issue May 10, 2020 · 57 comments
Closed

Wrong cursor on Context menu #3331

kud opened this issue May 10, 2020 · 57 comments

Comments

@kud
Copy link

kud commented May 10, 2020

Description

Context menu keeps the cursor of what it comes from (like text selection for instance)

Steps to reproduce

  1. Go on a part of the application where your cursor is a "text" one
  2. Right-click
  3. You'll keep your cursor as text and not default one

Expected behavior

Having the default cursor

Actual behavior

Having the previous cursor where it comes from

https://imgur.com/a/Ssqmuas

Environment

  • Build: 4074
  • Operating system and version: OS X 10.15.4
@michaelblyons
Copy link

michaelblyons commented May 11, 2020

Something has been screwing with my cursor, forcing it to the I text-selection one, in all sorts of programs for weeks. I blamed Adobe and uninstalled all their software, but it still happened. I wonder if it's ST.

Edit: It certainly seems to be ST. I quit ST and it stopped happening. I can't reliably get it to start happening, but when it does, my cursor in every program (even the desktop) is the last cursor that ST assigned.

Same Build/OS as above.

@TerminalFi
Copy link

Echoing that this happens outside of just the context menu.

@rchl
Copy link

rchl commented Jun 2, 2020

I'm not sure if initial report is the same issue but I definitively have the same issue as @michaelblyons and probably @TheSecEng .

In fact, I just diagnosed it a bit more and found out that it's probably related to Terminus. Filed issue there: randy3k/Terminus#219

@pvanb
Copy link

pvanb commented Jun 2, 2020

I can trigger this consistently when switching between macOS desktop spaces:

https://imgur.com/a/zYmSRyL

Build: 4074
OS: macOS 10.15.3

@michaelblyons
Copy link

@rchl I do not have Terminus installed, so it's not specifically that. It could conceivably be some other thing that Terminus and some package I do use have in common.

@pvanb Doing something like your screencast is how I realized it was ST. But sometimes when I first restart ST, it doesn't happen right away.

@wbond
Copy link
Member

wbond commented Jun 2, 2020

There are two issues being discussed here:

  1. the cursor being "stuck" in its state when invoking a context menu
  2. the cursor being stuck in the inverse I-beam cursor when outside of Sublime Text

Situation 2 should not be possible, based on my understanding. Cocoa apps get to tell the OS what cursor to use when the cursor is over an application window. The can't manage the global system cursor. That is managed by the OS in concert with the active application.

@wbond
Copy link
Member

wbond commented Jun 2, 2020

It might be interesting to know what sort of display configuration you are all running.

I am using macOS 10.15.5 with a rMBP 15" and an external 32" 4k display running at around 1.5 scale. I regularly have cursor issues on my external, using all different apps. I just got it stuck two different times in Safari.

@TerminalFi
Copy link

Macbook Info

image

External Display
LG ULTRAWIDE Display (2K)
34-inch (3440 x 1440)

@michaelblyons
Copy link

michaelblyons commented Jun 2, 2020

MacBook Pro (Retina, 15-inch, Mid 2015)

Has happened each with

  • an old 1080p ViewSonic (with tbolt-to-hdmi-to-dvi)
  • an LG UM95 34-Inch (tbolt)
  • no external screen

It's kind of amusing to mouse around in this very textarea (Firefox Beta) and see the cursor go from a black-with-white-border I to a white-with-black-border I.

@pvanb
Copy link

pvanb commented Jun 2, 2020

MacBook, resolution set to "Default for display"
Screen Shot 2020-06-02 at 3 29 51 PM

External Displays (2 displays, connected via HDMI):
BenQ PD2500Q
25-inch (1440x2560)

The above-linked screencast was on my MacBook's display, not an external one.

@wbond
Copy link
Member

wbond commented Jun 2, 2020

@michaelblyons Can you reproduce if you reboot your machine and don't connect an external at all?

So far everyone seems to be using mixed scales with external displays…

@pvanb
Copy link

pvanb commented Jun 2, 2020

@michaelblyons I just restarted Sublime Text and you're right, it doesn't happen right away.

@michaelblyons
Copy link

michaelblyons commented Jun 2, 2020

@wbond I'll try to reboot out of business hours, but restarting ST itself immediately cleared the problem for the moment. So far, it's been 40 minutes with no trouble.

All of us would love to know what specifically triggers the weird behavior, but my suspicion is that it will be hard to track down. Also, I'm eventually going to have to plug in a monitor.

Edit: 30 minutes after this was posted, I've started getting the weird cursor flickers in Sublime Merge. Firefox only maintains control of the cursor shape after it crosses a transition area (e.g. from cursor: text to cursor: default) for about a second. Then it becomes the ST I-beam.

@rchl
Copy link

rchl commented Jun 2, 2020

Anyone who has the issue could confirm whether it's the same one I'm having by killing zsh/bash process that is a child of plugin_host process. If the problem goes away then it should be the same as randy3k/Terminus#219

And if it's not that, one can still keep killing subprocesses of plugin_host to see which process is triggering the problem.

@TerminalFi
Copy link

I’ve not got terminus installed. But I will try selectively killing the processes within plugin host

@kud
Copy link
Author

kud commented Jun 2, 2020

I don't have either terminus. But yeah I've got the same behaviour that @michaelblyons has.

@michaelblyons
Copy link

michaelblyons commented Jun 2, 2020

And if it's not that, one can still keep killing subprocesses of plugin_host to see which process is triggering the problem.

I killed the 2 Python processes under plugin_host-3.3 (which made LSP complain about pyls) and the problem went away. But I've had this problem longer than I've had LSP installed.

I don't know a lot about plugin_host, but I restarted ST and attempted to trigger LSP to do something. Now I have a couple Python processes under plugin_host-3.3 again, but the problem is not back yet.

@godbout
Copy link

godbout commented Jun 24, 2020

i join the party. a similar thing happens to me constantly with ST4, and on ST3 ONLY in fullscreen mode, with other floating apps on top of ST, on 3 devices. no external displays.

you can see below the issue with ST4. ST3 works fine.

ST3: https://share.getcloudapp.com/kpu5Dz2m
ST4: https://share.getcloudapp.com/04uY2DrA

  • iMac 27 2012. resolution default for display.

About_This_Mac

  • MacBook 12 2016. resolution default for display. no external monitor.

About_This_Mac

  • MacBook Pro 13 2020. resolution default for display. no external monitor.

About_This_Mac

@wbond
Copy link
Member

wbond commented Jun 24, 2020

The primary difference for you @godbout would be that ST4 uses OpenGL by default on Mac. Try setting "hardware_acceleration" to "none" in your Settings and restart Sublime Text to see if that helps.

@wbond
Copy link
Member

wbond commented Jun 24, 2020

If anyone else wants to try with OpenGL turned off, it may help in further refining what causes the issue.

@michaelblyons
Copy link

michaelblyons commented Jun 24, 2020

If anyone else wants to try with OpenGL turned off, it may help in further refining what causes the issue.

Will do.

@godbout
Copy link

godbout commented Jun 24, 2020

@wbond same issue, sorry. and i confirm that OpenGL is not launched (when setting to none, no OpenGL info before the first pain in the console).

@wbond
Copy link
Member

wbond commented Jun 24, 2020

Hmm, off of the top of my head I can't think why ST4 would cause the issue and ST3 wouldn't, then. What is the app that is doing the overlay? Is it possible it has a work-around in place for ST3?

@godbout
Copy link

godbout commented Jun 24, 2020

not sure if that helps but just in case i'll say again: ST3 also gives the same issue in fullscreen only. maybe that gives some idea?

@godbout
Copy link

godbout commented Jun 24, 2020

@wbond i thought about that. the app is Dash, and i thought at the first the issue was coming from it. but i've also noticed the issue with Alfred, then HazeOver, etc... hence i posted here. i could see with Dash ultimately because it's where it's the most annoying, but definitely something weird is coming from ST.

thanks for the help!

@wbond
Copy link
Member

wbond commented Jun 24, 2020

Only that it is probably some arcane macOS bug.

The core issue here is that we can't control the pointer, except for our window. That is how the macOS NSCursor API works. If Sublime Text is affecting the cursor for another app, or when a menu is showing, as far as I can tell, that is due to some sort of issue with macOS.

If you think about it, it would not be good for an app to mess with the cursor within another app. Granted, I don't know how the macOS screenshot cursor is controlled - but it seems to be implemented at the window manager level since hitting space will draw a blue overlay over the window that will be captured.

Right now I'm just trying to figure out if we can pin down any special circumstances that mitigate the issue.

My hunch is that the bug is triggered in macOS by the fact that we have a custom cursor for the I-Beam. I believe the screenshots and videos I've seen so far all show the I-Beam. I don't have any of those apps installed, but I will try at some point to reproduce in an effort to see if disabling the custom I-Beam helps.

@michaelblyons
Copy link

In case it is relevant, one of my ST4 windows is full-screened, pretty much continuously.

@godbout
Copy link

godbout commented Jun 24, 2020

@wbond no worries. although it does seem to happen only with ST. maybe you guys could ping Apple? with the exposure you have they'd probably listen.

reminds me of another issue i have with ST. sometimes i open it, it's the focused app, but i can't type. if i type i just does a beep. i have to click on ST to get the cursor, even if i was the focused app. usually i need to reboot to get rid of this. haven't found a particular pattern yet.

@michaelblyons
Copy link

If anyone else wants to try with OpenGL turned off, it may help in further refining what causes the issue.

3 days with OpenGL off, and no recurrence yet.

@godbout
Copy link

godbout commented Jun 28, 2020

nice, thanks. will try then too. found out after posting here that it's wasn't just Dash (or Alfred, HazeOver, etc...). the whole system is affected, even Finder 😭️

@godbout
Copy link

godbout commented Jun 28, 2020

OpenGL off, same issue with my three machines (rebooted). iMac 27 works the same, MacBook 12 works the same (2016), but MacBook Pro (2020, 32gb ram, highest CPU) is sluggish. definitely OpenGL off. no OpenGL message in the console at startup, and the 3 ST share the same settings file.

@godbout
Copy link

godbout commented Jun 28, 2020

also quit all apps btw, in menu bar and all. didn't help.

@wbond wbond self-assigned this Jun 29, 2020
@godbout
Copy link

godbout commented Jun 30, 2020

@michaelblyons OpenGL off actually seems to solve the issue if ST is not in fullscreen mode. so basically it makes it behave like ST3. still (for both) not working if in fullscreen mode.

@michaelblyons
Copy link

michaelblyons commented Jun 30, 2020

I still have my permanently-fullscreened window open, but I haven't used an external monitor since I turned off OGL. [Still no recurrence]

@willrowe
Copy link

willrowe commented Jun 30, 2020

I have been seeing the issue with the text select cursor showing in other applications. OpenGL is on, MacBook Pro 16" with 1920x1080 external monitor where ST is usually displayed.

@rchl
Copy link

rchl commented Jun 30, 2020

Maybe related maybe not but opening the Open dialog on Mac (cmd+o) is also problematic in regards to the cursor. It seems like the cursor is stuck to the shape that was used before dialog has been opened. If it was "I-beam" cursor then it will stay as one even when hovering different elements in the dialog.

I can't see such behavior in other apps.

This seems to happen regardless of hardware acceleration.

@wbond
Copy link
Member

wbond commented Jun 30, 2020

I think we've established that macOS has a bug here - I need to look into what version of macOS they changed the IBeam to work reasonably on dark backgrounds. The reason we run a custom one is because at least in some versions it was very hard to see: https://apple.stackexchange.com/questions/107737/i-beam-cursor-color-in-maverickss-terminal.

@rchl
Copy link

rchl commented Jun 30, 2020

he reason we run a custom one is because at least in some versions it was very hard to see

So maybe it was fixed already (10.15.5):
Screenshot 2020-06-30 at 16 33 41

Probably makes sense to disable that workaround for newer MacOS versions.

@wbond
Copy link
Member

wbond commented Jun 30, 2020

Hence:

I need to look into what version of macOS they changed the IBeam to work reasonably on dark backgrounds

@wbond
Copy link
Member

wbond commented Jun 30, 2020

Based on checking a 10.12 and 10.14 VM I have, it seems 10.14 fixes the contrast issue with the default I-Beam. This seems to be reinforced by this comment: macvim-dev/macvim#910 (comment). I did not test 10.13 since I don't happen to have a VM of that.

Next I'll see if I can reproduce the issue before and after changing with cursor we use to see if it helps.

@michaelblyons
Copy link

3 days with OpenGL off, and no recurrence yet.

Came back with OpenGL off. 😞

@godbout
Copy link

godbout commented Jul 25, 2020

it does really affect the whole system. Chrome, Safari, iTerm. anything. so it's a system wide cursor robbery :o

@godbout
Copy link

godbout commented Jul 27, 2020

not sure if i'm only noticing now, but it seems it's only an issue in fullscreen, and when ST has the focus.

i was trying to make a GIF showing that it works fine when i focus on chrome but my tools doesn't handle recording two apps in fullscreen (time to change app), so i exited the fullscreen. the issue is gone.

  • so, no fullscreen, all is fine. even when ST has the focus
  • fullscreen, not working fine when ST has the focus. else it's fine

hope this helps a bit.

@michaelblyons
Copy link

so i exited the fullscreen. the issue is gone.

I just un-fullscreened the window I have that is (almost) permanently fullscreened, but I'm still getting the weird stuff here in Firefox. New hardware, though: 2020 MBP 13", MacOS 10.15.6

@godbout
Copy link

godbout commented Jul 29, 2020

ahhh. yeah you're right. it's more complicated. in fullscreen in my case, ST always steals the cursor right away. but if not in fullscreen, it steals it after about a second if i don't move it.

@willrowe
Copy link

I almost never use fullscreen and constantly have this issue.

@andremacola
Copy link

andremacola commented Aug 11, 2020

My god, I thought I was going crazy and founded this issue.

Not only in context menus but in for example hover links in the browser have a text cursor

Basically I always have 2 windows (projects) open in Sublime. Never used fullscreen.

This always happens when I leave Sublime (ST4) open for a long time. Restarting fix the issue.

I thought at the beginning that it could be some problem related to theme customization that I did.

This is my setup.
Captura de Tela 2020-08-11 às 18 39 58
Captura de Tela 2020-08-11 às 18 39 54

@andremacola
Copy link

Here is one more example ( I close sublime with cmd + q at the end )

cursor

@wbond
Copy link
Member

wbond commented Aug 12, 2020

Alright, I found a number of little things that contributed to this. Everything should hopefully be working properly in the next build.

@godbout
Copy link

godbout commented Aug 12, 2020

🤩️

@godbout
Copy link

godbout commented Aug 19, 2020

FIXED!

thank you! the update of August 19 solves this issue (although breaks some other stuff 😬️). but that one is solved! 😗️😗️😗️

@wbond wbond added the R: fixed label Aug 19, 2020
@wbond wbond added this to the Build 4083 milestone Aug 19, 2020
@wbond
Copy link
Member

wbond commented Aug 19, 2020

The three following issues were fixed in build 4083:

  • We use the default IBeam cursor with dark editor panes for macOS 10.14+ now, since it now has a strong white border
  • The cursor is set properly when a context menu is shown from an editor pane
  • If Sublime Text is not the window with input focus, we no longer manipulate the cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants