Bug 351399

Summary: Newly started application windows randomly positioned on primary or extended screen
Product: [Plasma] kwin Reporter: Armin K. <krejzi>
Component: xrandrAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal CC: david.alston, hello, kairo, kde, plasma-bugs, zhaixiang
Priority: NOR    
Version: 5.7.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Armin K. 2015-08-17 14:20:35 UTC
I didn't know how to explain my issue shortly, so I apologize for a bit confusing Summary.

The issue is, that on my multi monitor setup (where the second monitor is an extended monitor to the primary one, and is a TV connected via HDMI), an app (no matter which), when started, sometimes ends up on primary screen, sometimes on the extended (second screen). I have no way of predicting where it will be displayed, so the process is entirely random.

Reproducible: Sometimes

Steps to Reproduce:
I don't know, as I said it's random. I didn't move cursor to the second screen when the app window was loading.

Actual Results:  
App window sometimes displays on the primary monitor, sometimes on the extended monitor

Expected Results:  
App window displays on the "Primary Monitor" (as on Windows and GNOME) and I can drag it on the extended monitor if necessary.

Plasma Git Master after 5.4 branching, Qt-5.5.0, Intel Graphics
Comment 1 David Alston 2016-04-13 20:24:07 UTC
I have exactly the same setup and exactly the same problem.  This is especially annoying when the TV is off and the new window invisibly pops up on that display instead of the one my mouse is on.

There used to be a "Pop up window on screen with mouse" option that I can't find anymore.. but that didn't seem to work for me either.
Comment 2 Martin Flöser 2016-07-11 11:53:48 UTC
Sorry for the late response.

> App window sometimes displays on the primary monitor, sometimes on the extended monitor

This is something we do not really control. Windows have the possibility to position themselves when they show. They indicate this through window hints to the window manager and KWin (Plasma's window manager) honors this request. See https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.3 for more information. If KWin sees a window with a position set it assumes that the window has more information about where to go than the window manager. Apparently this seems to be wrong in some cases. I appreciate any information about windows which show this behavior.

For windows showing incorrect behavior you can override this with a window specific rule to ignore the requested position. With that KWin places the window and for that follows the "active screen" - that's to KWin either the window with the currently active window or the screen containing the mouse cursor (depending on config option).
Comment 3 Leslie Zhai 2016-07-12 03:27:48 UTC
Hi Martin,

Thanks for your reply and your great job ;-)

KDE/Openbox session (or just run openbox --replace in your konsole) is able to fix such issue: GIMP and LibreOffice's splash will NOT shown in the extended (but correctly in the primary) screen any more https://pbs.twimg.com/media/CnIQr9DUMAQCuRO.jpg

And I find setScreen(QScreen*) is not able to work for Qt-5.7.0 https://github.com/xiangzhai/qwx/commit/9419eabf0fa689fba5046b7e606b0007db7a90a6

Regards,
Leslie Zhai
Comment 4 Leslie Zhai 2016-07-12 04:29:05 UTC
Hi Armin,

As Martin suggested the active screen is configurable https://blog.martin-graesslin.com/blog/2016/07/multi-screen-woes-in-plasma-5-7/ Newly opened windows not placed on the primary screen

kcmshell5 kwinoptions for the Multiscreen behaviour, both check separateScreenFocus && activeMouseScreen shown as https://pbs.twimg.com/media/CnIya4IUkAAc72h.jpg then newly opened window will shown in the PRIMARY screen ;-)
Comment 5 Martin Flöser 2016-07-12 06:15:04 UTC
> And I find setScreen(QScreen*) is not able to work for Qt-5.7.0

Can you please xprop such a window. I would like to see what it sets in the normal hints.
Comment 6 Leslie Zhai 2016-07-12 09:04:04 UTC
Hi Martin,

I pasted xprop here https://forum.isoft-linux.org/viewtopic.php?f=4&t=32&p=134#p134

> kcmshell5 kwinoptions for the Multiscreen behaviour, both check separateScreenFocus && activeMouseScreen shown as https://pbs.twimg.com/media/CnIya4IUkAAc72h.jpg then newly opened window will shown in the PRIMARY screen ;-)

but kwinoptions works happily!
Comment 7 Martin Flöser 2016-07-12 09:15:06 UTC
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                user specified size: 480 by 822
                window gravity: Static

that doesn't specify a position. Uh oh, what's going on there?
Comment 8 Leslie Zhai 2016-07-12 09:31:35 UTC
app.primaryScreen()->availableGeometry() output is QRect(0,0 1366x732)

PS: kwinoptions separateScreenFocus && activeMouseScreen works happily!
Comment 9 Thomas Lübking 2016-07-12 10:18:13 UTC
(In reply to Martin Gräßlin from comment #7)

> that doesn't specify a position. Uh oh, what's going on there?

Either the window doesn't specify a position (what's good) or yet another QWidget/Window call ending nowhere.
Since netwm is completely multiscreen unaware, it would afaics require some call like KStartupInfoData::setXinerama(.) to define a specific screen - there's no real protocol.

One could btw. specify a blind rule to have all windows always show on screen 1.
Comment 10 Leslie Zhai 2016-07-13 01:11:11 UTC
> One could btw. specify a blind rule to have all windows always show on screen 1

kwinoptions separateScreenFocus && activeMouseScreen helps to have all windows always show on screen with activeMouse ;-)
Comment 11 Thomas Lübking 2016-07-13 07:15:03 UTC
Yes, even if I had not known, I would have heard - but that is not the same as enforcing the primary screen :-)
Comment 12 fanzhuyifan 2024-01-25 18:36:55 UTC
*** Bug 480330 has been marked as a duplicate of this bug. ***