Bug 445106 - "Screen" setting reverts from a fixed screen to "At mouse location" when Yakuake restarted
Summary: "Screen" setting reverts from a fixed screen to "At mouse location" when Yaku...
Status: RESOLVED FIXED
Alias: None
Product: yakuake
Classification: Applications
Component: general (show other bugs)
Version: Git (Frameworks 5)
Platform: Gentoo Packages Linux
: NOR minor
Target Milestone: ---
Assignee: Eike Hein
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-07 09:07 UTC by jonoerik
Modified: 2022-05-09 15:43 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 22.04.1


Attachments
Patch to fix this bug (692 bytes, patch)
2021-11-07 09:13 UTC, jonoerik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jonoerik 2021-11-07 09:07:12 UTC
SUMMARY
On a multi-monitor setup, Yakuake is configured to open on a fixed screen.
After Yakuake is exited and restarted, the setting changes to open Yakuake on the same screen as the mouse cursor.

STEPS TO REPRODUCE
* Run Yakuake
* In the Quick Menu, set Screen to Screen 1
* Quit Yakuake with Alt-F4
* Run Yakuake
* Press hotkey to show Yakuake

OBSERVED RESULT
* Yakuake opens on the screen of the mouse cursor, not necessarily screen 1
* The "At mouse location" setting is then saved out to user's yakuakerc

EXPECTED RESULT
* Yakuake should open on screen 1
* The user's yakuakerc should retain the setting of "Screen 1"

SOFTWARE/OS VERSIONS
Yakuake 21.04.3
KDE Frameworks 5.85.0
Qt 5.15.2
Gentoo Linux + KDE Plasma
amd64

Bug also confirmed in git commits f21268b35f6bb2a853f8961e1daa9f8a001d4573 and 57167242ece3da352d026bb31712364414e298e9

---

UNDERLYING CAUSE
MainWindow::moveEvent seems to be called not only when the user moves the window, but also once immediately before the window is first shown, after the user first presses the show/hide hotkey.
In moveEvent, QApplication::desktop()->screenNumber is called to get the screen to which the window has been moved, but this function can return -1 if the widget isn't currently on a screen.
https://doc.qt.io/qt-5/qdesktopwidget.html#screenNumber
During this first call to moveEvent, screenNumber returns -1, causing moveEvent to call `Settings::setScreen(0)`, i.e. "Screen=At mouse location". This change is then immediately saved to yakuakerc. This setting remains until the user switches it back to a fixed screen.
Comment 1 jonoerik 2021-11-07 09:13:54 UTC
Created attachment 143306 [details]
Patch to fix this bug

Have been testing this patch on Yakuake 21.04.3 for nearly a month now, and haven't had any issues with it.
Let me know if you'd rather I file this as a merge request.
Comment 2 jonoerik 2022-05-09 14:31:36 UTC
Git commit 554ca4bc41ba9018cc0819707c788fb02447a906 by Jonathan F.
Committed on 09/05/2022 at 12:49.
Pushed by nicolasfella into branch 'master'.

Fix screen index preference resetting unexpectedly

Update MainWindow::moveEvent() to correctly handle a result of -1 from
QApplication::desktop()->screenNumber() ("widget is not on any screen"),
which was previously causing a user preference for "show yakuake on a
fixed screen" to revert to "show yakuake on the same screen as the
mouse".

M  +4    -2    app/mainwindow.cpp

https://invent.kde.org/utilities/yakuake/commit/554ca4bc41ba9018cc0819707c788fb02447a906
Comment 3 Nicolas Fella 2022-05-09 14:32:33 UTC
Git commit 06cd7566630c2652f06b5059cc427f95f033e194 by Nicolas Fella, on behalf of Jonathan F.
Committed on 09/05/2022 at 14:32.
Pushed by nicolasfella into branch 'release/22.04'.

Fix screen index preference resetting unexpectedly

Update MainWindow::moveEvent() to correctly handle a result of -1 from
QApplication::desktop()->screenNumber() ("widget is not on any screen"),
which was previously causing a user preference for "show yakuake on a
fixed screen" to revert to "show yakuake on the same screen as the
mouse".
(cherry picked from commit 554ca4bc41ba9018cc0819707c788fb02447a906)

M  +4    -2    app/mainwindow.cpp

https://invent.kde.org/utilities/yakuake/commit/06cd7566630c2652f06b5059cc427f95f033e194