linuxmint / cinnamon

A Linux desktop featuring a traditional layout, built from modern technology and introducing brand new innovative features.
GNU General Public License v2.0
4.56k stars 742 forks source link

Preferences->Windows->"Prevent focus stealing" has no effect. #8059

Open crobarcro opened 5 years ago

crobarcro commented 5 years ago
 * Cinnamon version: 3.8.9
 * Distribution - (Mint 19)
 * Graphics hardware: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller
 * Graphics driver: whatever comes by default with Mint Linux 19
 * 64 bit

Issue The setting Preferences->Windows->"Prevent focus stealing" has no effect. When I activate it, it does not prevent focus stealing.

Steps to reproduce

Navigate to Preferences->Windows and activate the "Prevent focus stealing" options as in the screenshot below.

screenshot from 2018-11-22 10-03-17

Luahcn a program, e.g. Firefox web browser, the newly launched program will grab focus (also has no effect after logout/login or full reboot).

Expected behaviour

Programs will be prevented from stealing focus.

Other information

This is on the official release of Mint Linux 19 Cinnamon, with Cinnamon version 3.8.9.

I came across while investigating this?

https://ubuntuforums.org/showthread.php?t=2358571

icarter09 commented 4 years ago

@crobarcro did the merged PR fix this issue?

densha commented 4 years ago

@icarter09 @crobarcro Is there any update on this? This is still an issue with the most recent version of Linux Mint. I enabled the setting and apps still steal focus, even if the app is in a different workspace.

icarter09 commented 4 years ago

@densha thanks for the update that this is still an issue. Sounds like the merged PR did not provide the fix for it.

TheSHEEEP commented 4 years ago

Indeed still an issue.

It is quite annoying to type something in a window, only to have the focus stolen by some other window that just opened. KDE Plasma does this quite nicely.

devgs commented 4 years ago

Come on, guys! How hard it is to disable a feature?

Troi commented 3 years ago

Please, fix this! It is not only unpleasant but it is security issue: i am writing password a lot and if something steals focus, parts of password ends in different app than I wanted.

FibroJedi commented 3 years ago

Just to help keep this issue live, yes it's still an issue. I share @Troi's concern. While normally it's just annoying, when logging into apps, it nearly always happens because I multitask, so yes, often happens when inputting usernames/passwords so is a real security concern.

Viissataa commented 3 years ago

STILL an issue! How hard is it? This is an exceedingly annoying issue, and affects not only cinnamon, but xfce too. This needs attention!

edit: language

mtwebster commented 3 years ago

Does this involve only a single workspace typically? Or only with windows on different workspaces?

Can you guys provide program names to reproduce this please. (The name of the program that steals focus).

devgs commented 3 years ago

@mtwebster Consider Telegram client, as an example (but the list is bottomless). Whenever someone texts you something, client's window draws attention and instantly pops up to the front. When it's on a different workspace, view is automatically switched to that workspace.

Worse still, if at that moment you had some app in fullscreen, there's a chance that, when you switch to the original workspace, that app's window would be shifted by a half of a screen up and to the right, and will become unresponsive: you can't focus it again, only kill. It has something to do with post-effects or something. I'm judging from how it looks: half blurred. Unfortunately, I don't have a screenshot to show.

mtwebster commented 3 years ago

With telegram, what behavior are you after that isn't provided by turning off 'draw attention to the window' in telegram's notification settings?

I'm not saying that's the 'fix' here, It was just an observation and I'm curious. Are there other programs that exhibit this also that don't allow disabling the behavior within their own settings?

If I have that enabled, then it does indeed end up ignoring Cinnamon's setting, but with it disabled it behaves as it should - but regardless of cinnamon's setting (though ideally it should be popping a temporary item in the window list applet that's highlighted and you can click on to raise the window or switch to its workspace).

devgs commented 3 years ago

@mtwebster With notifications disabled, Telegram app simply doesn't emit them. It's like to cut your hand to treat a broken finger. All other app that implement a 'draw attention' action. Another example that comes to mind: Qt Creator, when project build is finished. There are many more apps that I've come across over the years, that I can't specifically remember. Usually, anything that pops a dialog box, while the window is not active, will draw attention and repeat the issue. So, I mean, it's not the app's fault but the system's.

crobarcro commented 3 years ago

Does this involve only a single workspace typically? Or only with windows on different workspaces?

Can you guys provide program names to reproduce this please. (The name of the program that steals focus).

Matlab in my case, if I start loading it, i.e. double click on it#s icon on the desktop, then go do something else, it steals focus when it loads. I'm pretty sure every app does this, and not just when loading. This is on a single workspace, probably also across workspaces (but in this case if you start loading on one workspace, then switch to another, the program ultimately ends up on the current workspace, which I would also prefer to work differrenty actually, but it's a minor issue).

devgs commented 3 years ago

So, ultimately, my expectation as a user is: when "Prevent focus stealing" is on: DE should do just that. Whenever any one app (window) wants to draw attention, instead of giving it an immediate focus, DE should only allow the app (window) to start blinking in the window list panel.

Otherwise that's a huge security issue: I personally had dozens of times when I type some sensitive data (eg password) in one app and then Telegram pops up and grabs all those key presses and consumes them as if I was typing there. Only by a sheer luck have I avoided sending it to the telegram chat.

NikoKrause commented 3 years ago

Consider Telegram client, as an example (but the list is bottomless).

With a bottomless list one would think that you could come up with more than one example. 😁

devgs commented 3 years ago

@NikoKrause I did. You'd see if you'd read more of my replies. As a general rule: any app that that pops dialog box while being minimized or on another workspace. This makes the list bottomless. Probably, because dialog box is interpreted by DE as the need for attention.

Viissataa commented 3 years ago

I have had this happen with JetBrains PyCharm and TI Code composer as recurring offenders.

Besides security issues, I've had probably 20 compilation errors or BUGS because there is something like:

for(int i=0; i<N;i++){ cd ../projectir

[rest of the code] }

C luckily has compile stage but with Python this is insanely annoying and dangerous! It needs to get fixed!

I already attempted using windows virtual machine bc of this.

The only sensible mechanism is that focus is absolutely solely granted by user action. No sane person would ever want anything else, or they should be forced to fork a fucking kernel to do something like that.

On Wed, 24 Feb 2021, 14.56 NikoKrause, notifications@github.com wrote:

Consider Telegram client, as an example (but the list is bottomless).

With a bottomless list one would think that you could come up with more than one example. 😁

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/linuxmint/cinnamon/issues/8059#issuecomment-785055771, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYSR6CUNEG5DNHAMZN3OJLTATZPHANCNFSM4GGBH3GQ .

Viissataa commented 3 years ago

I already looked around and concerningly "[DE name] focus steal prevention doesn't work" gets hits with xfce, kde, and cinnamon at least.

Why in devils name is there such a thing as "focus stealing prevention" anyway?

Focus stealing should be some exotic wild feature that DEs disable by themselves every 10 minutes without asking if the user ever manages to get it enabled.

On Wed, 24 Feb 2021, 15.27 Markus Hiltunen, m.v.hiltunen@gmail.com wrote:

I have had this happen with JetBrains PyCharm and TI Code composer as recurring offenders.

Besides security issues, I've had probably 20 compilation errors or BUGS because there is something like:

for(int i=0; i<N;i++){ cd ../projectir

[rest of the code] }

C luckily has compile stage but with Python this is insanely annoying and dangerous! It needs to get fixed!

I already attempted using windows virtual machine bc of this.

The only sensible mechanism is that focus is absolutely solely granted by user action. No sane person would ever want anything else, or they should be forced to fork a fucking kernel to do something like that.

On Wed, 24 Feb 2021, 14.56 NikoKrause, notifications@github.com wrote:

Consider Telegram client, as an example (but the list is bottomless).

With a bottomless list one would think that you could come up with more than one example. 😁

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/linuxmint/cinnamon/issues/8059#issuecomment-785055771, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYSR6CUNEG5DNHAMZN3OJLTATZPHANCNFSM4GGBH3GQ .

mtwebster commented 3 years ago

@Viissataa can you provide more specific details about pycharm stealing focus, such as when and possibly how to reproduce it, or at least the type of scenario that reproduces it.

I've found some issues that I'm fixing, which resolves this for telegram and should fix any other well-behaved program.

Matlab is not one of those - no matter what, it steals focus when it wants. This seems like a very common complaint and not unique to cinnamon. There's nothing I can do about it on our end without probably breaking everything else - this isn't a simple issue, though it may seem so.

I did test this: https://github.com/joka90/matlab-focus-fixer and can confirm it works (at least with my changes applied on our end).

I have a couple more programs I'd like to test before I push the changes I have.

Viissataa commented 3 years ago

I have installed PyCharm by downloading the newest deb package from JetBrains site.

To reproduce: 1: First open PyCharm, create a project, and close PyCharm.

2: open a console/terminal.

3: Start PyCharm from a shortcut of choise (desktop, toolbar, etc)

4: Focus on terminal and wait.

PyCharm takes some time to load assets, and will soon steal focus from terminal.

On Thu, 25 Feb 2021, 16.09 Michael Webster, notifications@github.com wrote:

@Viissataa https://github.com/Viissataa can you provide more specific details about pycharm stealing focus, such as when and possibly how to reproduce it, or at least the type of scenario that reproduces it.

I've found some issues that I'm fixing, which resolves this for telegram and should fix any other well-behaved program.

Matlab is not one of those - no matter what, it steals focus when it wants. This seems like a very common complaint and not unique to cinnamon. There's nothing I can do about it on our end without probably breaking everything else - this isn't a simple issue, though it may seem so.

I did test this: https://github.com/joka90/matlab-focus-fixer and can confirm it works (at least with my changes applied on our end).

I have a couple more programs I'd like to test before I push the changes I have.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/linuxmint/cinnamon/issues/8059#issuecomment-785922010, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYSR6BRC7HNMZFL44NW3MDTAZK3FANCNFSM4GGBH3GQ .

FibroJedi commented 3 years ago

Just caught up here so I ran my own test

  1. As above, load terminal, type something
  2. Open a document in Libre Office Writer
  3. Re-focus on Terminal and type something
  4. The Libre Office document loads, and steals the focus.

Hope this helps.

Earlier someone did say "the list is bottomless" - while I can't attest to that, I do know it happens a LOT, when you load something and go back to what you were doing until it's loaded.

Viissataa commented 3 years ago

My suggestion for a feature is to completely ignore any and all focus grab requests not originating from user input, without a solitary exception, or provide any way for application api to circumvent this.

On Thu, 25 Feb 2021, 16.52 FibroJedi, notifications@github.com wrote:

Just caught up here so I ran my own test

  1. As above, load terminal, type something
  2. Open a document in Libre Office Writer
  3. Re-focus on Terminal and type something
  4. The Libre Office document loads, and steals the focus.

Hope this helps.

Earlier someone did say "the list is bottomless" - while I can't attest to that, I do know it happens a LOT, when you load something and go back to what you were doing until it's loaded.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/linuxmint/cinnamon/issues/8059#issuecomment-785951684, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYSR6HMJLQPTK7F2JCJWITTAZP2FANCNFSM4GGBH3GQ .

FibroJedi commented 3 years ago

The one I don't mind is when Updates loads and requests authentication, but that's the only excusable one I think.

devgs commented 3 years ago

My current understanding is: X11 protocol is so lax that it allows client to do anything. All clients are fully trusted to behave sanely. That's probably explains such a bizarrely common issue and the one that is so hard to fix. And a ton of more issues, such as some apps causing Xorg to spin on 100% CPU, by simply spamming it with useless events.

Unless it's properly fixed in Xorg, all DE can do is to "apply medical tape to a leaking boat".

Therefore, @mtwebster, my gratitude for taking your time and trying!

mtwebster commented 3 years ago

@devgs is correct (I've been attempting to figure out how to express these realities without being crucified here - thanks :)

I believe I've fixed issues related to focus-stealing by already-running programs such as telegram. Instead of stealing focus, they should merely notify by flashing in the window list. The 'prevent windows..' setting is removed. The 'bring windows which require attention...' setting is still there and functions appropriately.

The focus-fixer I mentioned seems to function well for more than just matlab (it fixed pycharm also for me). Maybe we'll look into that more later to make it simpler to use in Cinnamon. This may not work without the changes I just made, I'll try to test later without them.

There is a potential for regressions here, but I can address them as they come, and hopefully in a more appropriate manner.

I'll leave this issue open for now. Any one wishing to test these changes on Mint can use the daily builds PPA (https://launchpad.net/~linuxmint-daily-build-team/+archive/ubuntu/daily-builds). Anyone else needs to build both cinnamon and muffin to test.

Thanks

devgs commented 3 years ago

@mtwebster Thanks a lot!

I'm gonna be testing PPA as soon as possible.

Viissataa commented 3 years ago

Thank you for spending time on this.

Interesting, a patch at X11 level would then fix this in all DEs. Sounds worth an attempt. Maybe I'll try that.

On Fri, 26 Feb 2021, 13.53 devgs, notifications@github.com wrote:

@mtwebster https://github.com/mtwebster Thanks a lot!

I'm gonna be testing PPA as soon as possible.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/linuxmint/cinnamon/issues/8059#issuecomment-786601819, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYSR6EWWBZ6GNCY3WYGOXTTA6DVPANCNFSM4GGBH3GQ .

devgs commented 3 years ago

@mtwebster kudos! Finally, for both Telegram and Qt Creator the issue is resolved!

Hopefully, the next stable release of cinnamon will contain the fix.

Moini commented 3 years ago

Just came here because I have this problem on Xfce. Will that require a different fix, or is this a general fix for Linux Mint?

FibroJedi commented 3 years ago

Also do we have a vague timeframe on the next stable version of Cinnamon?

invernosantigos commented 2 years ago

Replying to Mtwebster-san, a very practical example of stealing focus in Mint 20.3, is when you open a download box, or an image (with nomacs -- with gthumb or pix it doesn't lose focus) and then just move the mouse to one of the corners of the screen, mostly towards the top (large sensitivity area) and the application window ( nomacs or a dialog box ) immediately goes out of focus. I don't know why, but it happens more with some apps than others. It hardly happens with the ones pre-installed in mint; but on user-installed ones, especially slower ones or those that use a lot of bash, it's fatal. Which suggests that it is more a problem of integration than of focus stealing.

Gaturinho commented 2 years ago

invernosantigos

And another example, this very irritating one, is when you open a box asking for a password. To write the password in the box field, it is necessary to keep the mouse pointer exactly over the box -- if even a millimeter is out of it, it is not possible to enter the text in the field, because the insertion point is only maintained with the mouse strictly on the box, and worse, just a notification or any window pops up asking for focus, that the insertion point has died, and we have to start again, and sometimes, again, and again....

elfeiin commented 2 years ago

This really sucks because some programs open multiple short-lived loading bars, and typing will sometimes abort those loadings.

Moini commented 2 years ago

Yeah, the update manager is the worst of all for me. It interrupts twice for showing a progress bar.

elfeiin commented 2 years ago

It appears the new focus mode option is either "Smart" or "Strict":

image

Neither of those options is what the user wants. The user wants new windows that require focus to .... not steal focus. If anything, the user wants a notification saying that a window requires attention, with options to configure how those notifications play out. Interrupting user input can lead to unpredictable behavior across different windows, so this is a security issue as well.

elfeiin commented 2 years ago

OOF, just read the whole comment chain. I see now what is wrong. Damn it, X.... You've damned us again.

FibroJedi commented 2 years ago

Yes, I don't want anything that's not requiring authorisation (like the update manager prompting for master password) stealing focus. The problem is, for me at least, is that everything seems to "require focus". What I want is for nothing to steal focus, pretty much. And at the moment everything steals focus.

A notification would be a good start - but ofc that would steal focus! But it could lead to an "allow list" - i.e. apps we allow to steal, with the default being "nothing steals" (with the exception of the security authorisation I mentioned, maybe?)

elfeiin commented 2 years ago

Yes, I don't want anything that's not requiring authorisation (like the update manager prompting for master password) stealing focus. The problem is, for me at least, is that everything seems to "require focus". What I want is for nothing to steal focus, pretty much. And at the moment everything steals focus.

A notification would be a good start - but ofc that would steal focus! But it could lead to an "allow list" - i.e. apps we allow to steal, with the default being "nothing steals" (with the exception of the security authorisation I mentioned, maybe?)

Notifications are a small popup in the corner of the screen, similar to those on android.

FibroJedi commented 2 years ago

Ah yes, of course, sorry. Blame the heat wave affecting my brain or some other poor excuse for rushing my reply!

On Mon, 18 Jul 2022, 20:42 Jared Landers, @.***> wrote:

Yes, I don't want anything that's not requiring authorisation (like the update manager prompting for master password) stealing focus. The problem is, for me at least, is that everything seems to "require focus". What I want is for nothing to steal focus, pretty much. And at the moment everything steals focus.

A notification would be a good start - but ofc that would steal focus! But it could lead to an "allow list" - i.e. apps we allow to steal, with the default being "nothing steals" (with the exception of the security authorisation I mentioned, maybe?)

Notifications are a small popup in the corner of the screen, similar to those on android.

— Reply to this email directly, view it on GitHub https://github.com/linuxmint/cinnamon/issues/8059#issuecomment-1188226175, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQRDEIFHBPDQC6H6DT4RU43VUWXTDANCNFSM4GGBH3GQ . You are receiving this because you commented.Message ID: @.***>

NickNackGus commented 1 year ago

Nearly five years later, and I'm still having this issue - I've had to disable notifications in several apps and websites to avoid switching windows when I don't want to. I get that xorg doesn't seem to respond in a way that makes sense under the hood, but Mate doesn't have this issue, so there's got to be some sort of workaround.

FibroJedi commented 1 year ago

Yes, I'm still having the issue also. I often load programs/apps behind what I'm working on, but if that thing has a form element on it (like a login screen), it steals the focus every time, for me.