Bug 458886 - QWindow::setScreen() no longer works with layer-shell-qt
Summary: QWindow::setScreen() no longer works with layer-shell-qt
Status: REPORTED
Alias: None
Product: layer-shell-qt
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Aleix Pol
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-08 17:47 UTC by Aleksei Bavshin
Modified: 2022-11-27 21:48 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksei Bavshin 2022-09-08 17:47:24 UTC
SUMMARY
Before 9f8b8c97[1] it was possible to use layer-shell-qt with only `QT_WAYLAND_SHELL_INTEGRATION=layer-shell`. Existing code with QWindow->setScreen() was assigning the screens without any changes.

Now any application that uses multiple screens MUST use layer-shell-qt explicitly and implement an additional, ifdef'ed code path to set the screens for only that scenario. And by the way, layer-shell-qt lacks the way to check if wlr-layer-shell is actually supported by the compositor, which makes that code path even more complicated.

For the record, I perfectly realize the purpose of desiredScreen -- lack of the way to request a compositor default screen with setScreen.
I don't have a good solution for that, just a random idea to throw at you:
Can we set primaryScreen to QPlaceholderPlatformScreen from layer-shell-qt init code or otherwise keep it in sync with the compositor default?
Are there other, better ways to check that the window's screen was set explicitly by user?

[1]: https://invent.kde.org/plasma/layer-shell-qt/-/merge_requests/15

STEPS TO REPRODUCE
```
for (QScreen *screen : qGuiApp->primaryScreen()->virtualSiblings()) {
  QQuickView *view = new QQuickView();
  // ...
  view->setScreen(screen);
  view->setResizeMode(QQuickView::SizeRootObjectToView);
  view->setGeometry(screen->geometry());
  view->show();
}
```

(if this code looks familiar - yes, it's a simplified snippet from sddm GreeterApp)

OBSERVED RESULT
All the surfaces are created on the same screen, only one is visible.

EXPECTED RESULT
I expect to see one surface per screen.

SOFTWARE/OS VERSIONS
Qt Version: 5.15.5
Layer-shell-qt version: 5.25.4

ADDITIONAL INFORMATION