Repository navigation
fix: latch X11 layer surfaces to target screens - #1893
Conversation
Reviewer's GuideData structuresStore the emulation’s latched screen and expose it through the layer-shell window’s new screen binding API.
APIProvide explicit screen rebinding so callers can move an existing layer surface to another output.
Uses of the APIUpdate the dock and notification center to rebind their layer surfaces when their selected screen changes.
ImplementationUse the latched output for X11 geometry and exclusion regions, update it on explicit rebind, and select a valid remaining output when one is removed.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="frame/layershell/x11dlayershellemulation.cpp" line_range="161" />
<code_context>
+ // QWindow::screen() 是 Qt 依据窗口几何推导出来的,排列变化后窗口一旦
+ // 落进相邻屏就会被判成"属于那块屏",再把几何铺满那块屏,形成
+ // "错位 → 判成邻屏 → 更错位" 的正反馈,副屏桌面会永久跑到主屏上。
+ auto screen = targetScreen();
if (!screen) {
return;
</code_context>
<issue_to_address>
**X11 docks stay on old display**
When an existing X11 surface or dock changes displays through `QWindow::setScreen()` after emulation is created, `targetScreen()` keeps returning the latched `m_screen` because that call does not emit `DLayerShellWindow::screenChanged`, so `LayerShellEmulation` continues positioning the surface on its original output.
Route these screen changes through `DLayerShellWindow::setScreen()` so the emulation receives the explicit rebind.
Also at `frame/layershell/x11dlayershellemulation.cpp:30`, `frame/layershell/x11dlayershellemulation.cpp:79-85`.
</issue_to_address>
### Comment 2
<location path="frame/layershell/dlayershellwindow.h" line_range="128" />
<code_context>
+ * call this, a plain QWindow::setScreen() is no longer enough once the
+ * emulation has been created.
+ */
+ void setScreen(QScreen *screen);
+ QScreen *screen() const;
+
</code_context>
<issue_to_address>
**QML clients cannot rebind surfaces**
When a QML client needs to move an existing layer surface, `DLayerShellWindow::setScreen()` is neither `Q_INVOKABLE` nor a slot, so QML cannot call the rebinding API and the surface remains on its original output.
Expose `setScreen()` to QML as an invokable method or slot.
</issue_to_address>
### Comment 3
<location path="frame/layershell/dlayershellwindow.cpp" line_range="164" />
<code_context>
+void DLayerShellWindow::setScreen(QScreen *screen)
+{
+ if (d->screen == screen) {
+ return;
+ }
</code_context>
<issue_to_address>
**Repeated screen bind is ignored**
When a caller previously bound a Wayland window to a screen, its `QWindow` screen subsequently changes, and the caller invokes `DLayerShellWindow::setScreen()` with the original target to restore it, `setScreen()` returns based only on the cached `d->screen`, without checking `parentWindow->screen()`. On Wayland, after the window’s screen changes independently, calling the API again with the original target leaves the window and layer surface on the other screen.
Only return early when both the cached target and `parentWindow->screen()` already equal the requested screen.
</issue_to_address>
|
mhduiy
left a comment
There was a problem hiding this comment.
锁存目标屏的方向没问题,能解决调整排列后桌面互换或叠屏的问题。但新接口目前没有调用方,X11 下任务栏换屏会失效,具体见行内评论。
1. Latch X11 layer surfaces to their selected output. 2. Rebind Dock and notification center when screens change. 3. Select a valid remaining output when a screen is removed. Log: Keep layer-shell windows on the intended display. PMS: TASK-384487, TASK-384649 fix: 保持 layer surface 的屏幕绑定 1. 锁存 X11 layer surface 创建时指定的屏幕。 2. Dock 和通知中心换屏时显式更新屏幕绑定。 3. 屏幕移除后选择仍有效的显示器。 Log: 修复多屏布局调整后窗口错屏及 Dock 迁屏问题。 PMS: TASK-384487, TASK-384649
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy, xujin177 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: behind) |
7c03f9c
into
linuxdeepin:release/2500u2
Log: Prevent desktop windows from migrating to the wrong display.
PMS: TASK-384487, TASK-384649
fix: 锁存 X11 layer surface 的目标屏幕
Log: 修复调整显示器布局后桌面窗口跑到错误屏幕的问题。
PMS: TASK-384487, TASK-384649
Summary by Sourcery
Keep layer surfaces latched to their intended displays while supporting explicit rebinding and safe recovery when outputs are removed.
New Features:
Bug Fixes:
Enhancements: