Bug 471195 - [libkscreen] primary display is always on for all displays
Summary: [libkscreen] primary display is always on for all displays
Status: RESOLVED FIXED
Alias: None
Product: KScreen
Classification: Plasma
Component: common (show other bugs)
Version: 5.27.5
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: kscreen-bugs-null@kde.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-18 16:26 UTC by Loader009
Modified: 2023-07-01 17:11 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.7
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Loader009 2023-06-18 16:26:06 UTC
SUMMARY
The title says it - no matter which display is set to primary, all displays are set to primary.


STEPS TO REPRODUCE
1. set one of two (or more) displays to primary

OBSERVED RESULT
check config - all displays are primary now

EXPECTED RESULT
only one display should be primary

SOFTWARE/OS VERSIONS
Linux: ArchLinux - up2date - no KDE instead LXQT
(available in About System)
KDE Frameworks Version: libkscreen - 2.27.5
Qt Version: 5.15.10

ADDITIONAL INFORMATION
code which is probably wrong -> https://github.com/KDE/libkscreen/blob/v5.27.5/src/output.cpp#L499
working version -> https://github.com/KDE/libkscreen/blob/v5.26.5/src/output.cpp#L513
Thanks for pointing out to tsujan from the lxqt team!
The github issue with the post -> https://github.com/lxqt/lxqt-config/issues/925#issuecomment-1465060151
Comment 1 Loader009 2023-06-18 16:33:45 UTC
KDE Frameworks Version: libkscreen - 5.27.5-1

wrong version entered
Comment 2 Loader009 2023-07-01 05:53:18 UTC
@ratijas - could you please have a look?
thx
Comment 3 ratijas 2023-07-01 10:20:04 UTC
[[replied on GitHub, copy-pasting my reply here]]

I apologize for the mistake we made during refactoring.

> setPrimary() ignores its argument. My guess is that it's an incomplete draft that has popped up in the release by mistake

Less like a draft, and more like a rotten piece that was left around unused by libkscreen and thus untested. 🥴

The call to `setPriority(1)` should be guarded by an `if (primary)` condition. But there's not much meaningful we can do for the reverse `!primary` case.

> they have a plan to give priorities to outputs, instead of making one of them primary

Indeed, the new and more robust way is to set priorities, which are also maintained to be unique and sequential by the Config object. One should not call priority-related methods on Outputs directly. I wanted to make them protected from outside access (`friend class Config`)  but that proposal got rejected.

>  Maybe the "bug" was introduced to get people to migrate to a "new API"?

Most certainly not. But if your code calls `Output::setPrimary`, it better be ported to `config->setPrimaryOutput`
Comment 4 Bug Janitor Service 2023-07-01 10:34:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/libkscreen/-/merge_requests/143
Comment 5 ratijas 2023-07-01 11:51:51 UTC
Git commit a302c17e95df535bde9232516092d77b34143503 by ivan tkachenko.
Committed on 01/07/2023 at 10:33.
Pushed by ratijas into branch 'master'.

Guard the deprecated Output::setPrimary

Unsetting primary state directly on an output is not supported, but at
least we should properly warn about it instead of silently ignoring
the meaningless argument.
FIXED-IN: 5.27.7

M  +6    -1    src/output.cpp

https://invent.kde.org/plasma/libkscreen/-/commit/a302c17e95df535bde9232516092d77b34143503
Comment 6 ratijas 2023-07-01 12:18:52 UTC
Git commit b51a11b9030f70af2f114470bebf0ae70c082d9e by ivan tkachenko.
Committed on 01/07/2023 at 12:14.
Pushed by ratijas into branch 'Plasma/5.27'.

Guard the deprecated Output::setPrimary

Unsetting primary state directly on an output is not supported, but at
least we should properly warn about it instead of silently ignoring
the meaningless argument.
FIXED-IN: 5.27.7
(cherry picked from commit a302c17e95df535bde9232516092d77b34143503)

M  +6    -1    src/output.cpp

https://invent.kde.org/plasma/libkscreen/-/commit/b51a11b9030f70af2f114470bebf0ae70c082d9e
Comment 7 Loader009 2023-07-01 13:19:22 UTC
Great, thanks alot!