Create panel on current screen
Needs ReviewPublic

Authored by hoffmannrobert on Feb 6 2018, 2:58 PM.

Details

Reviewers
None
Group Reviewers
Plasma
Summary

In multi-monitor environments panels are always created on screen number 0.
There is no easy way to have panels on the other screens besides editing
plasma-org.kde.plasma.desktop-appletsrc and modifying lastScreen.

This patch identifies the screen where the right-click 'Add Panel' happened
and adds a panel to this particular screen.

Depends on the changes in plasma-framework ( see https://phabricator.kde.org/D10343 ) providing
Containment *createContainmentForScreen(int screenNum, const QString &name, const QVariantList &args = QVariantList());
Containment *addContainmentForScreen(int screenNum, const QString &name, const QVariantList &args, uint id, bool delayedInit = false);
void Containment::setLastScreen(int screen);

Test Plan

More than one monitor connected: Right-click on empty desktop, "Add Panel", choose any ("Empty", "Standard",...). Panel appears on monitor where you opened the context menu.

Diff Detail

Repository
R120 Plasma Workspace
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 1273
Build 1287: arc lint + arc unit
hoffmannrobert created this revision.Feb 6 2018, 2:58 PM
Restricted Application added a project: Plasma. · View Herald TranscriptFeb 6 2018, 2:58 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
hoffmannrobert requested review of this revision.Feb 6 2018, 2:58 PM
hoffmannrobert edited the test plan for this revision. (Show Details)Feb 6 2018, 3:09 PM
ngraham added a subscriber: ngraham.Feb 6 2018, 7:13 PM
mart added a subscriber: mart.Mar 23 2018, 2:46 PM

I like the idea, needs a bit of thinking to work on wayland

shell/shellcorona.cpp
1821

this is probably going to break in Wayland.. maybe with an heuristic which takes the current focus window of the app?

mart added a reviewer: Plasma.Mar 23 2018, 2:46 PM

btw, this was ignored for a long time as there weren't reviewers specified

Regard focus window position only if manually creating panels.

This fixes initial panel placement on wrong screen in dual monitor setup.

hoffmannrobert marked an inline comment as done.Jul 25 2018, 11:59 AM

Sorry for the delay.

In Wayland there seems to be a problem with QScreen: creating a panel on the second screen crashes plasmashell in QScreen::size(), called by PanelView::panelConfig() (shell/panelview.cpp:130).

In Wayland there seems to be a problem with QScreen: creating a panel on the second screen crashes plasmashell in QScreen::size(), called by PanelView::panelConfig() (shell/panelview.cpp:130).

While debugging a crash which occured when creating a panel on the second screen, I found that in certain screen/graphics hardware configurations (e.g. two screens connected to integrated Intel graphics controller, no screens connected to ext. Nvidia graphics controller) there are screen numbers like 3 or 4. This cannot work, because QGuiApplication::screens() is a QList and Panel:panelConfig() wants to do QScreen *s = QGuiApplication::screens().at(screenNum):

In Panel::panelConfig():
int screenNum = qMax(screen(), 0); // screenNum is 4 here

if (QGuiApplication::screens().size() < screenNum) { // 2 < 4

return KConfigGroup();      // returns empty KConfigGroup --> Crash in Panel::setHeight()

}

This happens in X11 and in Wayland.

Still looking where these screen numbers come from...

mvourlakos added a subscriber: mvourlakos.EditedJul 27 2018, 11:09 AM

Still looking where these screen numbers come from...

working in Latte I had to understand how Plasma is working with screens, it might help you to understand it...

There is a plasma-workspace/app/screenpool.h class which is responsible for the ids you are mentioning.
This class keeps a record and creates a table in form:
ScreenName=id (e.g. 1,2,3,4, ... etc.)

That table can be found at ~/.config/plasmashellrc e.g.:

[ScreenConnectors]
0=HDMI-1
1=eDP-1
2=eDP-1-unknown
3=eDP-1-1
4=:0.0
5=Screen26
6=Screen36

screenpool class is responsible to maintain that table and also to inform applets, containments, coronas etc for
associations between ids and screens

the Corona class has a screenForContainment() function that helps at that communication between applets<->screens

screen() and lastScreen() : functions usually return the id of the screen based on ScreenConnectors

Thank you. If these non-consecutive screen numbers are legitimate, then getting the QScreen via QGuiApplication::screens().at(screenNum) is wrong. I found a solution using ShellCorona::m_desktopViewforId.

Fix crash if screen numbers are not consecutive.
Add ShellCorona::screenForId(int screenNum) for easy access to a panel's QScreen replacing wrong access via QGuiApplication::screens().at(screenNum).

Thank you. If these non-consecutive screen numbers are legitimate, then getting the QScreen via QGuiApplication::screens().at(screenNum) is wrong. I found a solution using ShellCorona::m_desktopViewforId.

yes, QGuiApplication::screens().at(screenNum) doesnt make sense in plasma environment