Qtox: Focus Window doesn't work, Flashing icon in taskbar stops

Created on 26 Oct 2017  Â·  17Comments  Â·  Source: qTox/qTox

Brief Description

OS: Windows 10
qTox version: v1.11.0
Commit hash: 66b133c8d4a4d8f60e62475b0b56b509527b1488
toxcore: 0.1.9
Qt: 5.6.2

Reproducible: Always

Steps to reproduce
  1. Open the application.
  2. Focus on a window other than qTox.
  3. Have a contact on your contact list message you.
  4. Observe the taskbar.
Observed Behavior

The taskbar icon for qTox only flashes for the duration of the short audio file that plays when you receive a new message. The qTox window outline also flashes for the same very short duration. It appears the same behavior occurs whether audio notifications are enabled or disabled.

Expected Behavior

The taskbar icon and window outline should flash until the qTox window regains focus, indicating that the unread message was read.

Note that this is a similar behavior as mentioned in #2734, except I'm not talking about the system tray (a.k.a. dock) icon, I'm talking about the taskbar and window outline.

C-bug M-ui OS-windows

Most helpful comment

Awesome. I've been using qtox a lot lately and I'd say that fixing this
would elevate it to my preferred IM client. Looking forward to that!

On Thu, Apr 19, 2018, 12:47 PM Anthony Bilinski notifications@github.com
wrote:

Workaround can be unchecking "Focus window", in which case icon flashing
will work correctly. The window will no longer force focus, but that
already doesn't really work, so not much is lost.

For the window not gaining focus, no fix yet but I'll work on one in the
next few days.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/qTox/qTox/issues/4762#issuecomment-382804490, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACnESx9QICnIL2-qYoUclrGqj0otn5Yuks5tqL-mgaJpZM4QGvko
.

All 17 comments

To implement this, probably all, what you need is create timer, connect it to slot, which will call QApplication::alert and stop timer when window will be activated

We call alert now on new message, which plays the new message sound and reports "demandsAttention" on X11, keeping the button orange until activated (OS dependent). According to Qt docs, alert should keep the button orange in windows. I don't think calling alert repeatedly is correct approach, since that will cause constant sound notifications or bouncing of the button on other OSes. It seems like a more fundamental problem of us either using alert incorrectly or alert not doing what it's supposed to.

@anthonybilinski Sorry, maybe I misunderstood you, but from Qt docs: On Windows, this causes the window's taskbar entry to flash for a time. So it not keep it orange. Also there is nothing about sound notification. Currently we don't use alert at all, so we can't use it "incorrectly"

@Diadlo We do call alert right here and we call with duration = 0 (second param, default 0) which means "then the alert is shown indefinitely until the window becomes active again", by Qt docs.

Sorry yes the sound notification is separate, we do that manually. The staying orange / bouncing in task bar is what I see in Ubuntu, and it sits there staying orange until activated, like Qt docs indicate. It seems like we should be getting the same type of behaviour on windows (staying orange) since we're doing the same Qt call regardless of OS.

@anthonybilinski Oh... skip this somehow. Thanks. Currently described behavior seems like a bug

Any updates on this? While I love qTox, this is perhaps the most annoying problem with the client as is.

@drspangle I just stumbled across this issue myself, with the icon flashing orange for ~0.5s then stopping. Is your Settings -> User Interface -> Focus window checked? If so, the new message comes, activates the alert, then the alert stops as soon as the qTox window gains focus (though I didn't notice it actually gaining focus, maybe this is the actual bug).

@anthonybilinski Focus window was checked. And you're right, this is the actual bug, I think. Although it would probably make sense if the window continued to flash until the user actually brought it into focus.

Confirmed. Unchecking the focus window box does allow the icon to continue blinking. Thanks for figuring that out @anthonybilinski!

The real bug is definitely that the window doesn't actually get focus when the box is checked and the window is already open. It remains buried behind all my other windows.

@drspangle it does flash until the window is brought into focus, but with "Focus window" checked that (should) happen automatically which is why it stops right away. For some reason the flashing thinks the window has gained focus even though it hasn't. I noticed the same behaviour of very flaky grabbing focus when "Focus window" was checked on Ubuntu 18.04.

I see. So my mismatch in expectations was just rooted in the symptoms of
the bug. Cool. Is there a fix or a workaround for this that I ought to use?

On Thu, Apr 19, 2018, 12:43 PM Anthony Bilinski notifications@github.com
wrote:

@drspangle https://github.com/drspangle it does flash until the window
is brought into focus, but with "Focus window" checked that (should) happen
automatically which is why it stops right away. For some reason the
flashing thinks the window has gained focus even though it hasn't. I
noticed the same behaviour of very flaky grabbing focus when "Focus window"
was checked on Ubuntu 18.04.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/qTox/qTox/issues/4762#issuecomment-382803121, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACnES-1lj8bvYhTNb8-kOcCXOnv1qf_aks5tqL6XgaJpZM4QGvko
.

Workaround can be unchecking "Focus window", in which case icon flashing will work correctly. The window will no longer force focus, but that already doesn't really work, so not much is lost.

For the window not gaining focus, no fix yet but I'll work on one in the next few days.

Awesome. I've been using qtox a lot lately and I'd say that fixing this
would elevate it to my preferred IM client. Looking forward to that!

On Thu, Apr 19, 2018, 12:47 PM Anthony Bilinski notifications@github.com
wrote:

Workaround can be unchecking "Focus window", in which case icon flashing
will work correctly. The window will no longer force focus, but that
already doesn't really work, so not much is lost.

For the window not gaining focus, no fix yet but I'll work on one in the
next few days.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/qTox/qTox/issues/4762#issuecomment-382804490, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACnESx9QICnIL2-qYoUclrGqj0otn5Yuks5tqL-mgaJpZM4QGvko
.

By default, we have both "notify" and "focus window" enabled. Notify: https://doc.qt.io/qt-5/qapplication.html#alert blinks the icon in the taskbar indefinitely. Grab focus: https://doc.qt.io/qt-5/qwidget.html#activateWindow /should/ pull the window to front, but

On Windows, if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the taskbar entry to indicate that the window has changed in some way. This is because Microsoft does not allow an application to interrupt what the user is currently doing in another application.

So I think what's happening is that we kick off the continuous blink, try to grab focus, Windows blocks us and instead changes the icon in the taskbar, which cancel the indefinite blinking that we had just started.

To enable focus stealing on Windows, Qt added https://doc.qt.io/qt-5/qwindowswindowfunctions.html#setWindowActivationBehavior in Qt 5.7, which allows us to change from "default" (behaviour described above) to "AlwaysActivateWindow" changing the behaviour to "The window is always activated, even when the calling process is not the active process.".

Currently our minimum required Qt version is 5.5. Our options are either to just ignore the "Focus Window" setting for Windows users, which will fix the blinking, or alternatively bump our required Qt version to 5.7, set "AlwaysActivateWindow" and have our "Focus Window" setting work properly on Windows.

The current behaviour is pretty broken, my friend could basically not use qTox until I told him about the workaround because he would never see notifications for new messages. @sudden6 what are you thoughts on a Qt version bump?

Testing this out, I misread the docs. "AlwaysActivateWindow" just activates the individual qTox window (out of multiple qTox windows) even if the qTox application doesn't have focus, but still doesn't allow qTox to steal focus from other applications. All of setWindowState, activateWindow, raise, and settings AlwaysActivateWindow don't work for stealing focus, and that matches up with what I've read online. It looks like the only option is for users to edit registry keys to allow focus stealing, but that's obviously not an option.

So the only option left I think is to disable the "Focus Window" option for Windows users. IMO the feature is so invasive that removing the feature altogether would be reasonable, but might as well keep it unchanged for OSX/Linux users for now to keep existing behaviour.

Though I'm no UI expert, I think disabling this feature on windows seems like the most reasonable decision. About the other OSes, what do you think about disabling and removing the options from settings in the next release, basically deprecating it. If there is not a huge uproar about the removal I guess it's safe to remove entirely.

That seems reasonable to me, I've updated PR appropriately.

Was this page helpful?
0 / 5 - 0 ratings