Bug 824757

Summary: can't do display switching via system hotkeys.
Product: Red Hat Enterprise Linux 6 Reporter: MaricoXu <xu.marico>
Component: gnome-settings-daemonAssignee: Bastien Nocera <bnocera>
Status: CLOSED ERRATA QA Contact: Desktop QE <desktop-qa-list>
Severity: urgent Docs Contact:
Priority: high    
Version: 6.2CC: bskeggs, cww, ltroan, mboisver, ofourdan, rezwanul_kabir, rstrode, tpelka, wgomerin, xu.marico
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: gnome-settings-daemon-2.28.2-25.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 829891 (view as bug list) Environment:
Last Closed: 2013-02-21 08:24:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 829891    
Bug Blocks: 783549, 840699, 866528    

Description MaricoXu 2012-05-24 07:54:58 UTC
Description of problem:
when the user try to use the hot key (depend on the system , some is Fn+F8,and some is Fn+F4), the xinerama configuration will not show, and sometimes other display wrong issue will happen.

Version-Release number of selected component (if applicable):
RHEL6.2 x86_64
gnome-settings-daemon from 2.28 -3.2.
libgnome-desktop from 2.28-3.2

How reproducible:
input the switch hot key (Fn +F8 on my system,the hot key is different in the different system)

steps:
1.setup the environment(Laptop,RHEL6.2,two monitors)
2.plug in the monitor.
3.use the switch hot key several times

Actual results:
the xinerama configuration will not show or the switch operation cannot work. and sometimes

Expected result:
the four switch operations(clone,xinerama,laptop,extern) should work succcessfully

The Code Change can fix the issue:
       (1) libxrandr.so :
           code change:  in the function make_xinerama_setup()  (gsd-xrandr-managers.c)
          gnome version>3.0
            add gnome_rr_config_set_clone(result ,0); to the end of this function.
         gnome version<3.0
           add result->clone=false; to the end of this function. 

           When the user is doing the hotkey switch operation first time, gnome will call make_**_setup() function to setup the configurations for the future use.
However the original logic in gnome-settings-daemon didn’t deal with the clone flag well.  The clone flag should be set as false in the xinerama case.

(2) libgnome-desktop-3.so.2.0.2 :
      Code change: in crtc_assignment_new() (gnome-rr-config.c)
          Change the judgment from if (required_pixels < min_pixels || required_pixels > max_pixels)
          To  if (required_pixels < min_pixels || required_pixels > max_pixel  || with>max_width || height>max_height) 
          The bigdesktop mode set logic of Most graphic drivers(intel,ati) is try to set two  buffers in one screen, and we need the width and height of screen to fit the two buffers.
          Otherwise gnome-settings-daemon think the configuration can pass ,and actually the driver can not apply the configuration. ( the issue only can reproduce in some special cases)

Comment 2 RHEL Program Management 2012-05-30 05:48:03 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 3 Rezwanul Kabir 2012-05-31 16:27:31 UTC
Dell would like to request this fix for RHEL6.3 updates.

Business Case:

   All new Generation Dell Precision Portables with AMD Gfx currently show this issue with Display Switching. This is a high priority for Dell, since these platforms will launch in the next couple of months and this issue severely affects the use of external displays with those laptops.

Comment 4 Ray Strode [halfline] 2012-06-04 20:03:10 UTC
So to clarify comment 0, gnome-settings-daemon does something like the following pseudocode when constructing the list of of possible output configurations to cycle through when the user presses fn-f7:

generate_fn_f7_configs (...) {
   configs = new array;

   configs += current_setup();
   configs += make_clone_setup();
   configs += make_xinerama_setup();
   configs += make_laptop_setup();
   configs += make_other_setup();
   configs += previously_saved_to_disk_setup();

   remove_duplicate_configs (configs);

   fn_f7_configs = configs;
}

each of these make_..._setup() functions starts with a copy of the current setup, that they tweak until it fits the characteristics of the desired config. So, for example, make_xinerama_setup will start with a current config, and then position the configuration offsets of the outputs so they are side-by-side. 

If the current configuration is cloned at the time generate_fn_f7_configs is called, the config->clone will be set to TRUE, and every generated config will have config->clone=TRUE since those config generation functions don't explicitly set it to a value that makes sense for their particular configs.

Later, when the user presses, fn-f7, gnome-settings-daemon cycles through and applies the next config in the array using the gnome-rr apis.  the gnome-rr code then does this, as part of applying the configuration, then looks at the clone property:

make_outputs(config) {
    for (each output in config.outputs) {
        if (config->clone) {
          /* ignore output width/height and just use geometry of first output for all outputs*/
          output.width = config.outputs[0].width
          output.height = config.outputs[0].height
          output.rotation = config.outputs[0].rotation
          output.x = config.outputs[0].x;
          output.y = config.outputs[0].y;
        }
    } 
}

So these make_..._setup functions carefully placed the monitors to fit their desired layout, but neglected to change clone appropriately, then the presence of clone causes those carefullly placed monitors to get overridden with a clone setup.

Note, setting config->clone is an accepted part of the gnome-rr api.  control-center does it when the user toggles "mirror screens", and the reporter is correct, gnome-settings-daemon should set it as well in its make_..._setup functions.

Comment 5 Ray Strode [halfline] 2012-06-04 20:37:21 UTC
Regarding part (2) of comment 0 , at some point this change was made (http://git.gnome.org/browse/gnome-desktop/commit/?id=8ba5e616ceb10ae8f1138eaa550ec65742195b78)

Allow rotation if the virtual size has the correct number of pixels

We checked for the rotated size actually fitting in the virtual size; now we just check for the virtual size having the required number of pixels.

--- a/libgnome-desktop/gnome-rr-config.c
+++ b/libgnome-desktop/gnome-rr-config.c
@@ -1666,14 +1666,18 @@ crtc_assignment_new (GnomeRRScreen *screen, 

+ required_pixels = width * height;
+ min_pixels = min_width * min_height;
+ max_pixels = max_width * max_height;

- if (width < min_width || width > max_width ||
- height < min_height || height > max_height)
+ if (required_pixels < min_pixels || required_pixels > max_pixels)
{

So, at some point the check was made more lax to allow rotated configs to work.  I guess.

Comment 8 Ray Strode [halfline] 2012-06-07 18:38:20 UTC
I've pushed both changes upstream:

http://bugzilla.gnome.org/show_bug.cgi?id=677472
and
http://bugzilla.gnome.org/show_bug.cgi?id=640237

Comment 9 Ray Strode [halfline] 2012-06-07 18:47:02 UTC
i've filed bug 829891 to cover the gnome-desktop part of these changes

Comment 14 Bastien Nocera 2012-08-30 14:47:53 UTC
Done in gnome-settings-daemon-2.28.2-22.el6
http://brewweb.devel.redhat.com/brew/taskinfo?taskID=4817289

Comment 16 Olivier Fourdan 2012-09-05 08:13:14 UTC
The patch "0001-xrandr-explicitly-set-clone-state-variable-when-gene.patch" added here breaks XRandR plugin in gnome-settings-daemon as it uses gnome_rr_config_set_clone() which is not available in gnome-desktop-2.0 API on el6.

** (gnome-settings-daemon:14261): WARNING **: /usr/lib64/gnome-settings-daemon-2.0/libxrandr.so: undefined symbol: gnome_rr_config_set_clone

** (gnome-settings-daemon:14261): WARNING **: Cannot load plugin 'XRandR' since file '/usr/lib64/gnome-settings-daemon-2.0/libxrandr.so' cannot be read.

** (gnome-settings-daemon:14261): WARNING **: Error activating plugin 'XRandR'

Comment 17 Olivier Fourdan 2012-09-05 08:34:27 UTC
Created attachment 609902 [details]
Updated patch

gnome-desktop-2.0 API has no gnome_rr_config_get_clone() / gnome_rr_config_set_clone(), so using it in el6 would prevent the XRandR plugin from loading as the symbols remain unresolved.

This patch changes structure data directly instead.

Comment 18 Bastien Nocera 2012-09-06 16:11:38 UTC
With the updated patch in gnome-settings-daemon-2.28.2-25.el6
http://brewweb.devel.redhat.com/brew/taskinfo?taskID=4840704

Comment 19 Rezwanul Kabir 2012-09-10 16:44:42 UTC
Dell would like to test these fixes and provide feedback. It seems we would need both gonome-settings-daemon and gnome-desktop package to verify the fix. Can we get links to these packages to test?

Thanks..
   --rez

Comment 26 Michael Boisvert 2013-01-15 21:17:55 UTC
I am having some trouble with this fix. I am using a Wacom Cintiq 24HD as a monitor and a Dell M6300 laptop with an Nvidia Quadro FX 1600 G84.

Fresh installation of 6.4 with gnome-settings-daemon-2.28.2-30.el6.

I start the session with a cloned (mirrored) setup. Next, I use the hot key (fn + f8) to switch the screen setup. It goes from cloned to extended with one hit, then just the laptop screen with a second hit. On the third hit it should just put the 24HD on, but it leaves both screens blank.

Technically, it can leave the cloned state by using the hot key making this bug "verifiable." I was wondering if this is a known or related issue.

Comment 34 errata-xmlrpc 2013-02-21 08:24:05 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-0312.html