Bug 264041 - "Switch to Screen" shortcuts are broken when using three or more monitors.
Summary: "Switch to Screen" shortcuts are broken when using three or more monitors.
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: xinerama (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-23 08:29 UTC by goo
Modified: 2012-11-29 19:58 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.9.4


Attachments
"kwin --replace" full debug output (8.31 KB, text/x-log)
2012-11-22 22:24 UTC, goo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description goo 2011-01-23 08:29:46 UTC
Version:           unspecified (using KDE 4.5.95) 
OS:                Linux

In "Global Keyboard Shorcuts" for KWin component the shortcuts

Switch to Screen 0
Switch to Screen 1

work as expected with a dual display setup.
With a three or more displays they are broken:
"Switch to Screen 1" switches the focus to the screen where the previous focused application was on, while it should always switch to the second screen. Furthermore, "Switch to Screen 2" which should switch to the third screen is not parsed at all.


Summary:


Three Monitors Setup:

"Switch to Screen 0" --> switches to the first screen, as expecetd.
"Switch to Screen 1" --> switches to the second or third screen, depending on which of the two was used last.
"Switch to Screen 2" --> does nothing (should have switched to the third screen)

Dual Monitor Setup:

"Switch to Screen 0" --> switches to the first screen, as expected.
"Switch to Screen 1" --> switches to the second screen, as expected.


This misbehavior is reproduced with a three monitor setup with nvidia driver  with xinerama enabled and with fglrx driver via xrandr.


Reproducible: Always

Steps to Reproduce:
A setup composed of three displays driven by either xinerama or xrandr.
In "global keyboard shortcuts" add a keybinding for KWin for action "Switch to Screen 2".


Actual Results:  
"Switch to Screen 2" will not switch focus to the third monitor. It is not parsed at all.
Furthermore "Switch to Screen 1" switches to the second or third screen, while it should always switch to the second screen.

Expected Results:  
"Switch to Screen 1" and "Switch to Screen 2" are expected to switch the focus respectively to the second and third screen.
Comment 1 Matthias Fuchs 2011-07-27 20:27:20 UTC
Unfortunately I do not have that many monitors so I can't reproduce this issue.

Do you have applications open on all screens?
Is there a way you could try a patch that would add some debugging output?
Comment 2 Thomas Lübking 2011-07-27 21:44:00 UTC
It sounds as if only 2 screens are registered, esp. because of the behaviour of the "Switch to Screen 1" shortcut.

@goo: please run "kdebugdialog" and activate "1212 kwin", then run kwin from konsole: "kwin --replace &" and watch the output for the debug line containing "screens" - in doubt try to grep it ;-)
Ensure there are actually 3 screens reported.
Comment 3 goo 2012-11-22 00:35:02 UTC
I'm very very sorry for being away so much time!!
Anyway, time goes on and the misbehaviour continues to be reproduceable also with 4.9.3.

Yes, I have windows all over the 3 screens and here is the debug you requested so long ago:

kwin(14356) KWin::Extensions::init: Extensions: shape: 0x "11"  composite: 0x "4"  render: 0x "b"  fixes: 0x "60"  non_native_pixmaps:  true
kwin(14356) KDecorationPlugins::canLoad: kwin : path  "/usr/lib/kde4/kwin3_oxygen.so"  for  "kwin3_oxygen"
kwin(14356) KWin::Workspace::updateClientArea: screens:  3 desktops:  4
kwin(14356) KWin::Workspace::updateClientArea: Done.
kwin(14356) KWin::Client::readUserTimeMapTimestamp: User timestamp, ASN: 24336506
kwin(14356) KWin::Client::readUserTimeMapTimestamp: User timestamp, final: 'ID: 41943740 ;WMCLASS: "plasma" : "plasma" ;Caption: "plasma-desktop" ' : 24336506
kwin(14356) KWin::Workspace::allowClientActivation: Activation: No client active, allowing
kwin(14356) KWin::Workspace::updateClientArea: screens:  3 desktops:  4
kwin(14356) KWin::Workspace::updateClientArea: Done.
kwin(14356) KWin::Client::readUserTimeMapTimestamp: User timestamp, ASN: 98087643
kwin(14356) KWin::Client::readUserTimeMapTimestamp: User timestamp, final: 'ID: 41943758 ;WMCLASS: "plasma" : "plasma" ;Caption: "plasma-desktop" ' : 98087643
kwin(14356) KWin::Workspace::allowClientActivation: Activation: No client active, allowing
kwin(14356) KWin::Workspace::updateClientArea: screens:  3 desktops:  4
kwin(14356) KWin::Workspace::updateClientArea: Done.
kwin(14356) KWin::Client::readUserTimeMapTimestamp: User timestamp, ASN: 99949161
kwin(14356) KWin::Client::readUserTimeMapTimestamp: User timestamp, final: 'ID: 41943749 ;WMCLASS: "plasma" : "plasma" ;Caption: "plasma-desktop" ' : 99949161
kwin(14356) KWin::Workspace::allowClientActivation: Activation: No client active, allowing
kwin(14356) KWin::Workspace::updateClientArea: screens:  3 desktops:  4

Meanwhile I managed to find a workaround by binding "xdotool" command to custom shortcuts:

Screen0 (Meta+F1): xdotool mousemove 960 540
Screen1 (Meta+F2): xdotool mousemove 720 1530
Screen2 (Meta+F3): xdotool mousemove 2445 1350

Anyway, it does not work as the original feature would have worked because the focus goes to the window that is found under the pointer and not to the last focused window of the new focused monitor. That is still annoying, though.
Comment 4 Thomas Lübking 2012-11-22 01:32:23 UTC
(In reply to comment #3)
> I'm very very sorry for being away so much time!!
Well, pressure drives action =)

> kwin(14356) KWin::Client::readUserTimeMapTimestamp: User timestamp, final:
> 'ID: 41943740 ;WMCLASS: "plasma" : "plasma" ;Caption: "plasma-desktop" ' :
> 24336506
> kwin(14356) KWin::Workspace::allowClientActivation: Activation: No client
> active, allowing
> kwin(14356) KWin::Client::readUserTimeMapTimestamp: User timestamp, final:
> 'ID: 41943758 ;WMCLASS: "plasma" : "plasma" ;Caption: "plasma-desktop" ' :
> 98087643
> kwin(14356) KWin::Workspace::allowClientActivation: Activation: No client
> active, allowing
> kwin(14356) KWin::Client::readUserTimeMapTimestamp: User timestamp, final:
> 'ID: 41943749 ;WMCLASS: "plasma" : "plasma" ;Caption: "plasma-desktop" ' :
> 99949161
> kwin(14356) KWin::Workspace::allowClientActivation: Activation: No client
> active, allowing

This says: there are at least 3 plasma-desktop windows and they were activated one after another.
This output corresponds to your failed approach to alter the current screen?

> custom shortcuts:
> Screen0 (Meta+F1): xdotool mousemove 960 540
> 
> Anyway, it does not work as the original feature would have worked because
> the focus goes to the window that is found under the pointer

errmmm... what focus policy do you use? Focus follows mouse?
Quick test: does it work with "click to focus"?
Comment 5 goo 2012-11-22 22:24:16 UTC
Created attachment 75419 [details]
"kwin --replace" full debug output
Comment 6 goo 2012-11-22 22:25:02 UTC
(In reply to comment #4)
> This says: there are at least 3 plasma-desktop windows and they were
> activated one after another.
> This output corresponds to your failed approach to alter the current screen?

The output corresponds to a snipset of the start of "kwin --replace &". I don't get any other significant debug output while switching screens either via standard KDE or modified shortcuts.


> 
> > custom shortcuts:
> > Screen0 (Meta+F1): xdotool mousemove 960 540
> > 
> > Anyway, it does not work as the original feature would have worked because
> > the focus goes to the window that is found under the pointer
> 
> errmmm... what focus policy do you use? Focus follows mouse?
> Quick test: does it work with "click to focus"?

Yes, indeed, I usually use "Focus follow mouse".
"Focus follow mouse" and "click to focus" behave the same, letting the user to only switch between screen0 and the most recent focused screen of the other two ( =screen0 and screen1 OR screen0 and screen2).

"Focus under mouse" and "focus strictly under mouse" forbid focus switching to other screens, as expected, I suppose. 
Obviously I'm speaking about KDE's screen switching, not the workaround I am used to.
Comment 7 Thomas Lübking 2012-11-23 01:14:39 UTC
=)
I checked the sources *closely* and found the reason.
The bug is there ever since the feature was introduced.

Consider it fixed in 4.10, 4.9.4 if i switch back to the 4.9 branch interim ;-)
Comment 8 goo 2012-11-27 18:38:32 UTC
(In reply to comment #7)
> =)
> I checked the sources *closely* and found the reason.
> The bug is there ever since the feature was introduced.
> 
> Consider it fixed in 4.10, 4.9.4 if i switch back to the 4.9 branch interim
> ;-)

These are really good news :-)
Comment 9 Thomas Lübking 2012-11-29 19:37:00 UTC
Git commit 217895fb13cf7498841a288a777f575cdd249efc by Thomas Lübking.
Committed on 23/11/2012 at 02:15.
Pushed by luebking into branch 'master'.

fix screen switching for more than two screens
FIXED-IN: 4.10

M  +4    -4    kwin/activation.cpp

http://commits.kde.org/kde-workspace/217895fb13cf7498841a288a777f575cdd249efc
Comment 10 Thomas Lübking 2012-11-29 19:58:38 UTC
Git commit 5bfa461ffa1357e1d3f9af5066b78604aad86898 by Thomas Lübking.
Committed on 23/11/2012 at 02:15.
Pushed by luebking into branch 'KDE/4.9'.

fix screen switching for more than two screens
FIXED-IN: 4.9.4
(cherry picked from commit 217895fb13cf7498841a288a777f575cdd249efc)

M  +4    -4    kwin/activation.cpp

http://commits.kde.org/kde-workspace/5bfa461ffa1357e1d3f9af5066b78604aad86898