Bug 218320

Summary: Upgrade to Qt 4.6 breaks Kephal multi-head support
Product: [Unmaintained] kephal Reporter: Marcel Hasler <mahasler>
Component: GeneralAssignee: Aike J Sommer <dev>
Status: RESOLVED UNMAINTAINED    
Severity: normal CC: cfeck, mahasler
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Marcel Hasler 2009-12-11 20:52:31 UTC
Version:            (using KDE 4.3.4)
Compiler:          gcc-Version 4.4.2 (Gentoo 4.4.2 p1.0) Target: x86_64-pc-linux-gnu
OS:                Linux
Installed from:    Gentoo Packages

After my last system update which included an update to Qt 4.6 Kephal fails to recognize my TwinView setup correctly. It reports only a single screen and apparently doesn't know about my second screen which is set right of my primary screen. For people who like myself use multi-head setups often this is a major regression since it doesn't allow maximizing windows or switching windows to fullscreen on the second monitor.

Downgrading Qt back to 4.5.3 fixes the problem.

I haven't yet had a chance to test whether KDE SC 4.4 beta1 is affected by this, too, but I'll try to find out this weekend.

I'll be happy to help testing patches in order for this issue to resolved quickly.

Thanks.
Comment 1 Marcel Hasler 2009-12-13 16:05:36 UTC
I found this thread

http://markmail.org/message/huibm7di5wighhkb

which mentions a NoXRandR option for Kephal which is supposed to work around such problems.

Unfortunately that option has no effect for me. However, the other workaround mentioned, disabling Kephal completely, works for me.

I've renamed the kephal.desktop file to make sure kded doesn't find it. Now everything works the way it should.
Comment 2 Aike J Sommer 2009-12-13 16:20:22 UTC
This is really weird... I hav no idea, why an upgrade of Qt would lead to this behavior!
Just to have a little more hints of where to look:
 - Is your setup xrandr 1.2?
 - Can you post the output of `xrandr` before and after disconnecting the monitor?
Comment 3 Marcel Hasler 2009-12-13 16:58:29 UTC
I have RandR 1.3 on my system. However, I'm using the Nvidia drivers which to my knowledge still only support RandR 1.1.

The output of xrandr before disconnecting:

Screen 0: minimum 320 x 175, current 2464 x 900, maximum 2464 x 900
default connected 2464x900+0+0 0mm x 0mm
   1440x900       50.0     55.0     51.0
   1024x768       51.0     56.0     52.0
   832x624        52.0     65.0     53.0
   800x600        53.0     66.0     54.0
   720x400        54.0     68.0     55.0
   700x525        57.0     71.0
   640x512        58.0     73.0
   640x480        59.0     74.0
   640x400        60.0     75.0
   640x350        61.0     76.0
   576x432        62.0     77.0
   512x384        63.0     78.0
   416x312        64.0     79.0
   400x300        67.0     80.0
   360x200        69.0     81.0
   320x240        70.0     82.0
   320x200        72.0     83.0
   320x175        73.0     84.0
   2464x900       55.0     51.0*

And after disconnecting:

Screen 0: minimum 320 x 175, current 1440 x 900, maximum 2464 x 900
default connected 1440x900+0+0 0mm x 0mm
   1440x900       50.0*    55.0     51.0
   1024x768       51.0     56.0     52.0
   832x624        52.0     65.0     53.0
   800x600        53.0     66.0     54.0
   720x400        54.0     68.0     55.0
   700x525        57.0     71.0
   640x512        58.0     73.0
   640x480        59.0     74.0
   640x400        60.0     75.0
   640x350        61.0     76.0
   576x432        62.0     77.0
   512x384        63.0     78.0
   416x312        64.0     79.0
   400x300        67.0     80.0
   360x200        69.0     81.0
   320x240        70.0     82.0
   320x200        72.0     83.0
   320x175        73.0     84.0
   2464x900       55.0     51.0

Looking at the output I'm wondering how Kephal managed to detect the correct layout in the first place. Obviously Nvidia's RandR implementation can't really be trusted.

Since QDesktopWidget reports the correct values but Kephal doesn't (even when using QDesktopWidget itself), I would assume the problem to be either Dbus-related or somewhere in Qt's container classes.

I'll try to add a few debugging statements to Kephal's code in order to find out if and where it has correct values and where the values start going wrong. Maybe that can help to pin down the actual problem.
Comment 4 Aike J Sommer 2009-12-13 17:30:25 UTC
Could you kill kded4 and start it from a terminal? That should give you a few lines of debugging output from kephal...
Those might also help to clarify...
Comment 5 Marcel Hasler 2009-12-13 17:51:55 UTC
Interestingly, Kephal doesn't seem to detect the screen change at all. Here's all I get (with NoXRandR enabled):

kephald starting up
adding an output 0 with geom:  QRect(0,0 1440x900)
output: "SCREEN-0" QRect(0,0 1440x900) 2097261 true false
load xml
connected: 1
looking for current "SCREEN-0"
known "*" has score: 0.125
screen: 0 QRect(0,0 1440x900)
looking for a matching configuration...
connected: 1
looking for current "SCREEN-0"
known "*" has score: 0.125
found outputs, known: false
activate external configuration!!
registered the service: true
screens registered on the bus: true
outputs registered on the bus: true
configurations registered on the bus: true


That's all printed when Kephal starts up. Changing the screen layout after that doesn't produce any output at all.

Here's the same without NoXRandR:

kephald starting up                                                                                                   
XRANDR error base:  173                                                                                               
RRInput mask is set!!                                                                                                 
RandRScreen::loadSettings - adding mode:  346 1440 x 900                                                              
RandRScreen::loadSettings - adding mode:  347 1024 x 768                                                              
RandRScreen::loadSettings - adding mode:  348 832 x 624                                                               
RandRScreen::loadSettings - adding mode:  349 800 x 600                                                               
RandRScreen::loadSettings - adding mode:  350 720 x 400                                                               
RandRScreen::loadSettings - adding mode:  351 700 x 525                                                               
RandRScreen::loadSettings - adding mode:  352 640 x 512                                                               
RandRScreen::loadSettings - adding mode:  353 640 x 480                                                               
RandRScreen::loadSettings - adding mode:  354 640 x 400                                                               
RandRScreen::loadSettings - adding mode:  355 640 x 350                                                               
RandRScreen::loadSettings - adding mode:  356 576 x 432                                                               
RandRScreen::loadSettings - adding mode:  357 512 x 384                                                               
RandRScreen::loadSettings - adding mode:  358 416 x 312                                                               
RandRScreen::loadSettings - adding mode:  359 400 x 300                                                               
RandRScreen::loadSettings - adding mode:  360 360 x 200                                                               
RandRScreen::loadSettings - adding mode:  361 320 x 240                                                               
RandRScreen::loadSettings - adding mode:  362 320 x 200                                                               
RandRScreen::loadSettings - adding mode:  363 320 x 175                                                               
RandRScreen::loadSettings - adding mode:  372 2464 x 900                                                              
RandRScreen::loadSettings - adding mode:  373 1440 x 900                                                              
RandRScreen::loadSettings - adding mode:  451 1024 x 768                                                              
RandRScreen::loadSettings - adding mode:  452 832 x 624                                                               
RandRScreen::loadSettings - adding mode:  453 800 x 600                                                               
RandRScreen::loadSettings - adding mode:  454 720 x 400                                                               
RandRScreen::loadSettings - adding mode:  455 700 x 525                                                               
RandRScreen::loadSettings - adding mode:  456 640 x 512                                                               
RandRScreen::loadSettings - adding mode:  457 640 x 480                                                               
RandRScreen::loadSettings - adding mode:  458 640 x 400
RandRScreen::loadSettings - adding mode:  459 640 x 350
RandRScreen::loadSettings - adding mode:  460 576 x 432
RandRScreen::loadSettings - adding mode:  461 512 x 384
RandRScreen::loadSettings - adding mode:  462 416 x 312
RandRScreen::loadSettings - adding mode:  463 400 x 300
RandRScreen::loadSettings - adding mode:  464 360 x 200
RandRScreen::loadSettings - adding mode:  465 320 x 240
RandRScreen::loadSettings - adding mode:  466 320 x 200
RandRScreen::loadSettings - adding mode:  467 320 x 175
RandRScreen::loadSettings - adding mode:  486 2464 x 900
RandRScreen::loadSettings - adding mode:  487 1440 x 900
RandRScreen::loadSettings - adding mode:  488 1024 x 768
RandRScreen::loadSettings - adding mode:  489 832 x 624
RandRScreen::loadSettings - adding mode:  490 800 x 600
RandRScreen::loadSettings - adding mode:  491 720 x 400
RandRScreen::loadSettings - adding crtc:  344
RandRScreen::loadSettings - adding output:  345
Setting CRTC 344 on output "default" (previous 0 )
CRTC outputs: (345)
Output name: "default"
Output refresh rate: 50
Output rect: QRect(0,0 1440x900)
Output rotation: 1
XRandROutputs::init
  added output  345
adding an output 0 with geom:  QRect(0,0 1440x900)
output: "SCREEN-0" QRect(0,0 1440x900) 3801197 true false
load xml
connected: 1
looking for current "SCREEN-0"
known "*" has score: 0.125
screen: 0 QRect(0,0 1440x900)
looking for a matching configuration...
connected: 1
looking for current "SCREEN-0"
known "*" has score: 0.125
found outputs, known: false
activate external configuration!!
registered the service: true
screens registered on the bus: true
outputs registered on the bus: true
configurations registered on the bus: true


Again, changing the screen layout isn't detected.
Comment 6 Aike J Sommer 2009-12-13 18:00:16 UTC
What is printed when you start with both screens connected?
Comment 7 Marcel Hasler 2009-12-13 18:15:38 UTC
Ok, that way Kephal detects the screens correctly. Here's the output:

kephald starting up                                                                             
XRANDR error base:  173                                                                                               
RRInput mask is set!!                                                                                                 
RandRScreen::loadSettings - adding mode:  346 1440 x 900                                                              
RandRScreen::loadSettings - adding mode:  354 2464 x 900
RandRScreen::loadSettings - adding mode:  355 1440 x 900
RandRScreen::loadSettings - adding mode:  380 2464 x 900
RandRScreen::loadSettings - adding crtc:  344
RandRScreen::loadSettings - adding output:  345
Setting CRTC 344 on output "default" (previous 0 )
CRTC outputs: (345)
Output name: "default"
Output refresh rate: 50
Output rect: QRect(0,0 2464x900)
Output rotation: 1
XRandROutputs::init
  added output  345
adding an output 0 with geom:  QRect(0,0 1440x900)
adding an output 1 with geom:  QRect(1440,0 1024x768)
adding a disconnected output 2
adding a disconnected output 3
output: "SCREEN-0" QRect(0,0 1440x900) 208 false false
output: "SCREEN-1" QRect(1440,0 1024x768) 10086976 false false
output: "SCREEN-2" QRect(0,0 0x0) 2097268 true false
output: "SCREEN-3" QRect(0,0 0x0) 2097268 true false
load xml
connected: 2
looking for current "SCREEN-0"
known "*" has score: 0.125
known "*" has score: 0.125
looking for current "SCREEN-1"
known "*" has score: 0.125
screen: 0 QRect(0,0 1440x900)
screen: 1 QRect(1440,0 1024x768)
looking for a matching configuration...
connected: 2
looking for current "SCREEN-0"
known "*" has score: 0.125
known "*" has score: 0.125
looking for current "SCREEN-1"
known "*" has score: 0.125
found outputs, known: false
activate external configuration!!
registered the service: true
screens registered on the bus: true
outputs registered on the bus: true
configurations registered on the bus: true


In turn, as expected, it now doesn't detect when I disconnect the second screen.
Comment 8 Aike J Sommer 2009-12-13 18:23:03 UTC
I just saw that Qt 4.6 introduced a new signal QDesktopWidget::screenCountChanged(), which might have also changed the semantics of the signal QDesktopWidget::resized(int)...
Could you try whether also connecting to that signal in desktopwidgetoutputs.cpp on line 70 fixes things?
Comment 9 Marcel Hasler 2009-12-13 19:44:48 UTC
Connecting to QDesktopWidget::screenCountChanged() indeed causes DesktopWidgetOutputs::screenChanged(int) to be called (which isn't the case without connecting). Unfortunately that isn't enough. While Kephal detects adding screens it still doesn't detect removing them. If I'm not mistaken this has something to do with the isVirtual variable. When I disconnect my second screen QDesktopWidget::isVirtualDesktop() returns false (has this also changed in Qt 4.6?). Therefore the following for-loop is never executed and the output isn't removed. Removing the if(isVirtual) check seems to fix it but I'm not sure that's the correct thing to do, although it seems to work correctly for me.
Comment 10 Christoph Feck 2015-02-05 11:30:09 UTC
Thank you for your bug report or feature request.

Unfortunately, we did not have a maintainer for the "kephal" component, which is used to manage displays and monitors in the KDE Workspaces.

The "kephal" component has been superseded by "KScreen" in newer releases of the KDE Workspaces. It is compatible with all versions since 4.11, and is also used with Plasma 5. Please check with your distribution how to update to KScreen.

If this issue or feature request is still applicable to KScreen version 1.0.5 or newer, please add a comment. We will then reassign this ticket to KScreen developers.

If you are already using KScreen to manage displays or monitors, and found a different bug or need a specific feature, please create a new ticket for "KScreen" product in this bugzilla using this link: https://bugs.kde.org/enter_bug.cgi?product=KScreen

(This is an automatic message from the KDE Bug Triaging Team)