Multi-monitor: window position corrupted on secondary screens when _NET_WORKAREA excludes upper desktop area (XFCE/X11)
I maintainer di solito rispondono entro 13 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- cpp
- Ambito
- desktop, operating-systems
Direzione di ricerca
Inizia leggendo src/gui/screen.cpp, in particolare screenGeometry() e screenAvailableGeometry(), quindi segui i relativi chiamanti in src/gui/geometry.cpp, inclusi ensureWindowOnScreen() e resolutionTagForScreen(). Riproduci il problema con le diagnostiche xprop e xrandr fornite e verifica che le finestre mantengano la propria posizione e che le chiavi della geometria rimangano stabili nei layout multi-monitor interessati, senza introdurre regressioni nelle altre posizioni dello schermo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Title
Multi-monitor: window position corrupted on secondary screens when _NET_WORKAREA excludes upper desktop area (XFCE/X11)
Environment
- CopyQ version: 6.0.1 (confirmed via
copyq --version) - Qt: 5.15.2
- OS: Pop!_OS 22.04 LTS (Ubuntu 22.04 base)
- Desktop: XFCE 4 with xfwm4
- Display setup: 4 monitors
Symptom
On a 4-monitor setup where the laptop screen is not at virtual desktop position (0,0),
the CopyQ main window placed in the upper area of the 4K monitor always reopens at the
bottom of that monitor, height clamped to roughly the laptop screen height.
Horizontal position and width are preserved correctly — only vertical position and
height are wrong.
Screen Layout
$ xrandr --query (relevant outputs):
DP-1-3 1920x1200 at (0, 0)
DP-1-1 3840x2160 at (1920, 120) ← 4K, affected screen
DP-1-2 1920x1200 at (5760, 120)
eDP-1 1920x1080 at (0, 1200) ← laptop, has XFCE panel
The laptop (eDP-1) sits below the other three screens in the virtual desktop.
Root Cause
Note: The
_NET_WORKAREAvalue and screen layout below are confirmed by running
xpropandxrandr. The code path analysis is based on source inspection, not
runtime-confirmed with debug logging.
_NET_WORKAREA is wrong for secondary monitors
$ xprop -root _NET_WORKAREA
_NET_WORKAREA(CARDINAL) = 0, 1227, 7680, 1053
_NET_WORKAREA is a single rectangle per the EWMH spec — it cannot represent
per-monitor available areas. XFCE sets it to the laptop screen's usable area:
y=1227 (laptop top minus panel), height=1053 (1080 minus 27px panel).
This is not an XFCE misconfiguration. The panels are already set to individual
screens (not spanning). _NET_WORKAREA has no per-monitor variant in the spec —
there is nothing to fix on the XFCE side.
How Qt computes availableGeometry()
Qt's QScreen::availableGeometry() intersects _NET_WORKAREA with each screen's
physical rect. For the 4K monitor (physical: x=1920, y=120, w=3840, h=2160):
workarea bottom = 1227 + 1053 = 2280
screen bottom = 120 + 2160 = 2280
intersection top = max(120, 1227) = 1227
intersection bottom = min(2280, 2280) = 2280
intersection height = 2280 - 1227 = 1053
Qt reports availableGeometry = (1920, 1227, 3840, 1053) for the 4K screen.
The entire upper portion of the 4K (y=120 to y=1227) appears "unavailable".
How CopyQ uses this — ensureWindowOnScreen() (geometry.cpp:114)
ensureWindowOnScreen() calls screenAvailableGeometry() (screen.cpp:39) which
returns screen->availableGeometry(). The clamping then in ensureWindowOnScreen:
Height clamp (geometry.cpp:127):
h = qMin(h, availableGeometry.height()); // → h clamped to 1053
Y floor (geometry.cpp:138-139):
if ( y < availableGeometry.top() )
y = availableGeometry.top(); // → y forced to 1227
Any saved Y position above 1227 (the entire upper portion of the 4K screen) gets
pushed to y=1227, and height is clamped to 1053. This is deterministic — it happens
every single time.
Secondary issue: unstable resolution key tags
screenGeometry() (screen.cpp:33) also calls screen->availableGeometry() and is
used exclusively by resolutionTagForScreen() (geometry.cpp:88-93, only caller) to
build the geometry key suffix (e.g. _3840x1053).
Because the intersection height depends on both the workarea and the XFCE panel size
(which may vary between sessions as system tray icon count changes), the tag suffix
changes and the correct saved key is not found, triggering fallback to stale geometry.
This is visible in the user's copyq_geometry.ini which contains entries for the
same 4K screen at many different "heights" across sessions:
_3840x2160, _3840x2139, _3840x2133, _3840x1173, _3840x1059, _3840x1053,
_3840x1052, _3840x939, _3840x938 — all caused by the fluctuating
workarea/panel intersection.
Proposed Fix
In src/gui/screen.cpp, use physical screen geometry (screen->geometry()) instead
of screen->availableGeometry():
QRect screenGeometry(int i)
{
// Use physical geometry so the resolution tag used in geometry keys is stable
// across sessions regardless of panel size or _NET_WORKAREA changes.
auto screen = screenFromNumber(i);
return screen ? screen->geometry() : QRect();
}
QRect screenAvailableGeometry(const QWidget &w)
{
// Use physical geometry to avoid _NET_WORKAREA misreporting secondary monitors
// as partially unavailable on multi-monitor XFCE/X11 setups.
auto screen = QGuiApplication::screenAt(w.pos());
if (!screen)
screen = QGuiApplication::primaryScreen();
return screen ? screen->geometry() : QRect();
}
Note: the fallback in screenAvailableGeometry changes from screenGeometry(0)
(screen 0's availableGeometry) to primaryScreen()->geometry() (physical). This
avoids returning a potentially broken availableGeometry as a fallback.
Trade-off: Windows may be placed a few pixels behind panels on the primary screen
in edge cases. This is far less severe than forcing all secondary-monitor windows to
the bottom half of the screen every time.
To Reproduce
- Multi-monitor setup where at least one non-primary screen starts at a virtual Y
coordinate below the value of_NET_WORKAREA's y origin - XFCE (or any DE that sets _NET_WORKAREA to only the primary monitor's workarea)
- Place CopyQ main window in the upper half of a secondary monitor
- Hide and reopen CopyQ
Expected: window reopens where it was placed
Actual: window appears at the bottom of the secondary monitor with height clamped
Quick Diagnostic
xprop -root _NET_WORKAREA
# If y > 0 or the rectangle doesn't cover all your screens, this bug likely applies.
To capture runtime geometry decisions:
COPYQ_LOG_LEVEL=DEBUG copyq 2>&1 | grep -i geometry
- Lingua principale
- C++
- Stelle
- 12.7k
- Fork
- 648
- Merge medio
- 11g 12h
- PR unite (30g)
- 5
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hluk/CopyQ
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
I maintainer di solito rispondono entro 13 giorni
-
feature
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
hluk/CopyQ#3703 · 3 commenti ·
I maintainer di solito rispondono entro 13 giorni
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 13 giorni
-
feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
hluk/CopyQ#3618 · 4 commenti ·
I maintainer di solito rispondono entro 13 giorni
-
Documentation: The Basics―First Start assumes desktop icon and presence in `PATH`Forse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug help wanted Windows
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
hluk/CopyQ#3354 · 1 commento ·
I maintainer di solito rispondono entro 13 giorni
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ros-navigation/navigation2#6883 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
riscv-software-src/riscv-isa-sim#2640 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: long names cut mid-character end in "???" instead of being trimmed at a character boundaryApertabug triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
meshtastic/firmware#12551 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Helldez/BigMoeOnEdge#767 ·
I maintainer di solito rispondono entro 1 giorno