-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Two clicks required to show window with "Minimize qBittorrent to notification area" active only for maximised window. #13016
Comments
I'd also like to add that sometimes, after locking qBT, the UI lock password window won't be visible, even when the main window isn't maximised. I can type in my password and then press enter as if it were visible, and it functions normally, but it's just not visible. |
A big update for Manjaro was released, and it seems like the locking issue was fixed by it. However, minimising a maximised window to the tray still needs two clicks to re-open. |
No need, it's already tracked here: #13030. |
I can confirm that this happens exactly as @azsorlex described it. Window must be first maximized and then minimized to tray. First attempt to raise it from tray results in window only blinking and getting hidden in tray again. Second time it raises properly. I did some debugging and found the root of the problem - bug in QT or somewhere deeper. When raising from tray (unminimize+show) the window state changes 3 times: ->not minimized->minimized->not minimized. The window enters "minimized" state for a while which triggers auto-hiding. Now the window is hidden but it's no longer in "minimized" state. When raising it for the second time the state doesn't change (the window is already "unminimized") and the window appears. I made a test program: #include <QApplication>
#include <QMainWindow>
#include <QWindowStateChangeEvent>
#include <QDebug>
#include <QTimer>
#include <QElapsedTimer>
int t = 0;
const int period = 2000;
template <typename F> void shoot(F f) { QTimer::singleShot(t += period, f); }
QElapsedTimer timer;
auto dbg = [] () { return qDebug() << timer.elapsed(); };
class MainWindow : public QMainWindow
{
public:
bool autoHideEnabled = true;
void changeEvent(QEvent *e) override
{
if (e->type() == QEvent::WindowStateChange) {
dbg()
<< "state change event (spontaneous:" << e->spontaneous()
<< "):" << static_cast<QWindowStateChangeEvent*>(e)->oldState()
<< "-->" << this->windowState();
if (autoHideEnabled && isMinimized()) {
dbg() << "window got minimized, scheduling auto-hide";
QTimer::singleShot(0, [this] () { dbg() << "auto-hiding"; hide(); });
}
}
return QMainWindow::changeEvent(e);
}
};
int main(int argc, char** argv)
{
QApplication app(argc, argv);
MainWindow w;
timer.start();
shoot([&w] () {
qDebug() << "--- SIMULATION 1 - mimic qBittorrent ---"; w.autoHideEnabled = true;
qDebug() << "--- Window must be maximized to observe the effect ---";
dbg() << "showing maximized"; w.showMaximized();
});
shoot([&w] () {
qDebug() << "--- Minimize it to trigger auto-hiding ---";
dbg() << "minimising"; w.setWindowState(w.windowState() | Qt::WindowMinimized);
});
shoot([&w] () {
qDebug() << "--- Show it for the first time. ---";
dbg() << "un-mininimsing showing"; w.setWindowState(w.windowState() & ~Qt::WindowMinimized); w.show();
});
shoot([&w] () {
qDebug() << "--- Show it for the seond time. ---";
dbg() << "un-mininimsing showing"; w.setWindowState(w.windowState() & ~Qt::WindowMinimized); w.show();
});
shoot([&w] () { qDebug() << "--- SIMULATION 2 - narrow ---"; w.autoHideEnabled = false; });
shoot([&w] () { dbg() << "showing maximized"; w.showMaximized(); });
shoot([&w] () { dbg() << "minimising"; w.setWindowState(w.windowState() | Qt::WindowMinimized); });
shoot([&w] () { dbg() << "hiding"; w.hide(); });
shoot([&w] () { dbg() << "showing maximized"; w.showMaximized(); });
return app.exec();
}
Focus on the last three lines of the output. If a window is maximized+minimized+hidden and you un-minimize it and show it, three QWindowStateChangeEvent events will follow. There is definitely something bad happening here. Beside the fact that we get 3 events, the "old state" has invalid value (WindowMaximized two times in a row). I tried different combinations - swapping calls, adding 0-time one-shot timers, un-minimizing while hiding - nothing helped to get rid of the window state change events tandem. Finally my workaround is this: do not decide to hide the window right after it enters minimized state, instead check if it is still minimized after a while (see my commit a-sum-duma@ef795fb). |
Fixes/workarounds the need of raising from tray twice after window got minimized to tray while being maximized (qbittorrent#13016)
4.5.0 is still affected. #18099 |
See #19940 |
qBittorrent version and Operating System
v4.2.5 (64 bit)
Manjaro (KDE)
Plasma version: 5.18.5
If on linux, libtorrent-rasterbar and Qt version
libtorrent-rasterbar: ?
Qt: 5.15.0
What is the problem
As the title says, two clicks are needed to show the window again when the "Minimize qBittorrent to notification area" is active, but the problem only applies when the window is maximised. Every other combination of actions, such as minimising and showing a non-maximised window, closing the window with the "Close qBittorrent to notification area" active, and clicking on the tray icon to hide and show it works as expected. This problem also applies to "Start qBittorrent minimized", which isn't that surprising.
Below is a screen recording demonstrating the behaviours of the above scenarios. First, I minimise the window using the minimise button and attempt to show it again (needs two clicks). Then I do the same for a non-maximised window, closing the window instead of minimising it (close to notification area is active), and using the tray icon to hide and show the window. And then I end by repeating the problem.
2020-06-14 13-29-50.zip
What is the expected behavior
When the "Minimize qBittorrent to notification area" option is active, and I either click minimise button or "Start qBittorrent minimized" is active, then I should be able to show the (maximised) window again by clicking the tray icon once, not twice.
Steps to reproduce
Enable "Minimize qBittorrent to notification area" in settings. Make sure the window is maximised, then minimise the window (either by clicking 'minimise' or having "Start qBittorrent minimized" enabled and starting up qBittorrent), and then attempt to show it again by clicking on the tray icon once (which will fail).
The text was updated successfully, but these errors were encountered: