Bug 2965

Summary: xrandr: RRScreenChangeNotify event has incorrect geometry after rotation
Product: xorg Reporter: Lubos Lunak <l.lunak>
Component: Server/GeneralAssignee: Aaron Plattner <aplattner>
Status: RESOLVED INVALID QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: high CC: bugzilla, caster, khnz
Version: git   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 1690    
Attachments:
Description Flags
testcase
none
Patch to make libXrandr.so take rotation into account. none

Description Lubos Lunak 2005-04-11 03:47:39 UTC
I can reproduce this problem only with the 'nvidia' driver version 7167. Xrandr 
rotation doesn't seem to work here with the 'nv' driver and in fact I haven't been able 
to find any other case when rotation would work except for the nvidia driver. If the 
problem is specific to the driver, then please close and I'll report to nvidia. 
 
As demonstrated by the attached testcase, the width and height fields of the 
XRRScreenChangeNotifyEvent structure don't reflect rotation. If I run it and then 
rotate the screen, the reported width and height always match the unrotated 
geometry. 
 
[normal rotation] 
kde2@magic:~> /tmp/a.out 
[ xrandr -o left in another konsole] 
SIZE1: 1280 960 
EVENT: 1280 960 
SIZE2: 1280 960 
[ xrandr -o normal ] 
SIZE1: 1280 960 
EVENT: 1280 960 
SIZE2: 1280 960 
 
[ xrandr -o left before ] 
kde2@magic:~> /tmp/a.out 
[ xrandr -o normal ] 
SIZE1: 960 1280 
EVENT: 1280 960 
SIZE2: 1280 960 
 
In the second case XDisplayWidth()/XDisplayHeight() even initially have proper 
values, but after any rotation they're always set to match unrotated geometry.
Comment 1 Lubos Lunak 2005-04-11 03:48:29 UTC
Created attachment 2389 [details]
testcase
Comment 2 kevin wang 2005-04-22 18:57:05 UTC
I am using nvidia driver version 7174, driver = 'nvidia' and xorg 6.8.2 all
running on a quadro4 980 xgl card.  xrandr does work for me with twinview on,
but does not quite work right (xinerama bugs) and other various screen size
reporting issues.

email me if you need any more info.
Comment 3 kevin wang 2005-04-22 19:10:32 UTC
(In reply to comment #2)
> I am using nvidia driver version 7174, driver = 'nvidia' and xorg 6.8.2 all
> running on a quadro4 980 xgl card.  xrandr does work for me with twinview on,
> but does not quite work right (xinerama bugs) and other various screen size
> reporting issues.
> 
> email me if you need any more info.

my physical config is a pair of 1600x1200 monitors, arranged using twinview into
a 1600x2400 twinview (hardware dual-head) setup, and then primarily rotated so I
end up with a 2400x1600 display

running the attached a.c I get:
[ started in xrandr -o left ]
kjw@kjw:~/Ftp $ xrandr -o normal
SIZE1: 2400 1600
EVENT: 1600 2400
SIZE2: 1600 2400
kjw@kjw:~/Ftp $ xrandr -o left
SIZE1: 1600 2400
EVENT: 1600 2400
SIZE2: 1600 2400
kjw@kjw:~/Ftp $ xrandr -o right
SIZE1: 1600 2400
EVENT: 1600 2400
SIZE2: 1600 2400
kjw@kjw:~/Ftp $ xrandr -o normal
SIZE1: 1600 2400
EVENT: 1600 2400
SIZE2: 1600 2400
kjw@kjw:~/Ftp $ xrandr -o left
SIZE1: 1600 2400
EVENT: 1600 2400
SIZE2: 1600 2400

[kill a.out. xrandr -o left. a.out&]
kjw@kjw:~/Ftp $ xrandr -o left
SIZE1: 2400 1600
EVENT: 1600 2400
SIZE2: 1600 2400
kjw@kjw:~/Ftp $ xrandr -o left
SIZE1: 1600 2400
EVENT: 1600 2400
SIZE2: 1600 2400

so I guess I am seeing the same behaviour. 
Comment 4 Aaron Plattner 2005-08-22 15:47:58 UTC
Created attachment 2994 [details] [review]
Patch to make libXrandr.so take rotation into account.

This looks like a bug in libXrandr.so.	The sizes reported in
RRScreenChangeNotifyEvent are the physical (unrotated) dimensions of the
screen,
so when XRRUpdateConfiguration is changing the client's idea of the screen
size,
it needs to take the rotation into account.  Patch is attached.
Comment 5 Aaron Plattner 2005-08-22 21:57:23 UTC
Blocking the 6.9/7.0 release. 
Comment 6 Aaron Plattner 2005-09-27 23:39:25 UTC
Assigning to myself, now that I have an account.
Comment 7 Aaron Plattner 2005-09-29 21:28:11 UTC
CVSROOT:	/cvs/xorg
Module name:	xc
Changes by:	aplattner at gabe.freedesktop.org	05/09/29 21:25:14

Log message:
  * lib/Xrandr/Xrandr.c: (XRRUpdateConfiguration):
  Bug #2965 <https://bugs.freedesktop.org/show_bug.cgi?id=2965>
  Patch #2994 <https://bugs.freedesktop.org/attachment.cgi?id=2994>
  Swap the screen dimensions when handling XRRScreenChangeNotify events for 90-
  and 270-degree rotations.  This fixes KDE's panel placement for rotated
  screens.

Modified files:
      ./:
        ChangeLog 
      xc/lib/Xrandr/:
        Xrandr.c 
  
  Revision      Changes    Path
  1.1355        +17 -0     xc/ChangeLog
  http://cvs.freedesktop.org/xorg/xc/ChangeLog
  1.6           +11 -4     xc/lib/Xrandr/Xrandr.c
  http://cvs.freedesktop.org/xorg/xc/lib/Xrandr/Xrandr.c
Comment 8 Robert Gerlach 2007-07-26 01:30:22 UTC
[normal]
[xrandr -o right]
SIZE1: 1024 768
EVENT: 1024 768
SIZE2: 1024 768
SIZE1: 1024 768
EVENT: 768 1024
SIZE2: 1024 768
[xrandr -o normal]
SIZE1: 1024 768
EVENT: 768 1024
SIZE2: 768 1024
SIZE1: 768 1024
EVENT: 1024 768
SIZE2: 1024 768

> "The sizes reported in RRScreenChangeNotifyEvent are the physical"
think it's wrong with xserver commit c10df5b967d4da4e11786520317e2917de5541fa (03.04.2007) and the patch to libXrandr should reverted.
Comment 9 Robert Gerlach 2007-07-26 03:50:28 UTC
with patch reverted:
[normal]
[xrandr -o right]
SIZE1: 1024 768
EVENT: 1024 768
SIZE2: 1024 768
SIZE1: 1024 768
EVENT: 768 1024
SIZE2: 768 1024
[xrandr -o normal]
SIZE1: 768 1024
EVENT: 768 1024
SIZE2: 768 1024
SIZE1: 768 1024
EVENT: 1024 768
SIZE2: 1024 768
Comment 10 Vlastimil Babka 2007-07-26 05:30:40 UTC
Are you sure about applied/reverted? I'm getting this with xorg-server-1.3.0.0, which source doesn't contain the commit as far as I can see (although the release as dated after the commit date). libXrandr is 1.2.1, xrandr is 1.2.0

[normal]
[xrandr -o right]
SIZE1: 1024 768
EVENT: 1024 768
SIZE2: 1024 768
SIZE1: 1024 768
EVENT: 768 1024
SIZE2: 1024 768
[xrandr -o left]
SIZE1: 1024 768
EVENT: 768 1024
SIZE2: 768 1024
SIZE1: 768 1024
EVENT: 1024 768
SIZE2: 1024 768

Which matches yours in comment 8. I'll see what applying the patch (not reverting) will do.
Comment 11 Vlastimil Babka 2007-07-26 06:17:46 UTC
This is what I get after applying the patch...

[normal]
[xrandr -o right]
SIZE1: 1024 768
EVENT: 1024 768
SIZE2: 1024 768
SIZE1: 1024 768
EVENT: 1024 768
SIZE2: 768 1024
[normal]
[xrandr -o left]
SIZE1: 768 1024
EVENT: 768 1024
SIZE2: 768 1024
SIZE1: 768 1024
EVENT: 1024 768
SIZE2: 1024 768

This doesn't match any of your reports so I'm not sure what's going on. However, it fixed the KDE bug 112294 for me, with unpatched qt and no kicker problems.
Comment 12 Robert Gerlach 2007-07-26 06:25:07 UTC
You are right, I messed up with my servers, sorry.
So c10df5b967d4da4e11786520317e2917de5541fa fixed the wrong behavior of 1.3.0.0 (I really should read comments better).
Comment 13 Aaron Plattner 2007-07-26 10:17:58 UTC
Robert,
In the future, when you see a symptom similar to an old, closed bug and it's clear that the causes are unrelated (e.g. an xserver bug vs. one in libXrandr), please file a new bug instead of reopening the old one.  Thanks!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.