Dual-head Gnome / GDM non-Xinerama working with Matrox G450 on RedHat 7.3

Dietmar May <[email protected]>
Newsgroups gmane.comp.xfree86.expert
Message-ID <[email protected]>
I searched for information about running multi-head Gnome GDM (or XDM) 
sessions with XFree, but couldn't really find anything to indicate that 
it was possible. As a matter of fact, some of the gnome mailing lists 
basically said, Wait for gnome 2.2.

However, I did manage to get it working. There may be a cleaner way, but 
here's what I did. I hope this can help someone else get it going too. 
(Who knows, that someone may be me in 4 months after I've forgotten 
exactly what changes to make :-)).

These changes apply to RedHat 7.3 with Gnome (and no KDE) installed. 
 From what I've read dual-head with separate window manager sessions 
should work almost out of the box using KDE (unconfirmed). 
Unfortunately, all of RedHat's tools are based on Gnome, RedHat doesn't 
update their KDE RPMs, and KDE doesn't support stable RedHat releases. 
So, I'm stuck using Gnome, not having the time or inclination to hack 
around trying to get a known good KDE environment running on RH 7.3. But 
all that has no bearing on the technical aspects; it's just why someone 
might bother to try.

Your mileage may vary.

1. Edit XF86Config-4. Add a second Screen section, and a second Display 
section. Both should be a duplicate of the existing sections.

Next, change the Identifier for the second Display and Screen sections 
to be unique.

Use scanpci to obtain the BusID for the display adapter. If you have two 
PCI adapters or a separate PCI and AGP adapter, the BusID for the two 
Display sections will be different. If you have a single dual-head G450, 
it should be identical. In this latter case, add a Screen line to both 
Display sections - the first being Screen 0 and the second being Screen 1.

Make any other obviously necessary changes (like display resolutions, 
color depths, monitor parameters, etc).

Here are the sections from my XF86Config-4 file:

-------

Section "Device"
	Identifier   "Matrox G450 Head1"
         Driver       "mga"
         VendorName   "Matrox"
         BoardName    "Millennium G450 AGP"
         BusID        "PCI:1:0:0"
	Screen       0
EndSection

Section "Device"
	Identifier   "Matrox G450 Head2"
         Driver       "mga"
         VendorName   "Matrox"
         BoardName    "Millennium G450 AGP"
         BusID        "PCI:1:0:0"
	Screen       1
EndSection

Section "Screen"
	Identifier   "Screen0"
         Device       "Matrox G450 Head1"
         Monitor      "Dell P991"
	DefaultDepth 16
	Subsection "Display"
             Depth    16
# demonstrates different display resolutions on one screen
# e.g. for a 15" LCD and a Multi-scan monitor
             Modes    "1024x768" "800x600" "640x480"
#           Modes    "1280x1024" "1152x864" "1024x768" "800x600" "640x480"
	EndSubsection
EndSection

Section "Screen"
	Identifier   "Screen1"
         Device       "Matrox G450 Head2"
         Monitor      "Dell P991"
	DefaultDepth 16
	Subsection "Display"
             Depth    16
             Modes    "1280x1024" "1152x864" "1024x768" "800x600" "640x480"
	EndSubsection
EndSection

-------

Finally, add a second Screen line to the ServerLayout, referencing the 
newly added Screen section.

-------

Section "ServerLayout"
         Identifier     "Anaconda Configured"
         Screen      0  "Screen0" 0 0
	Screen      1  "Screen1" LeftOf "Screen0"
         InputDevice    "Mouse0" "CorePointer"
         InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

-------

2. At this point, you should be able to bring up X (startx), and see the 
gdm or xdm login screen on Screen0, and a gray screen with the X cursor 
on Screen1. After logging in, Gnome should start on Screen0. Screen1 
should still be gray.

Now edit the file /etc/X11/xinit/Xclients. The key here is to invoke 
gnome-session twice, passing --display=:0.1 to one of the sessions. 
There are cleaner ways to do this, but this has minimal impact on the 
system configuration (in other words, if you don't have a second screen 
configured, it should work like the stock install). Note that the script 
greps for LeftOf or RightOf in the config file -- you could add Above, 
Below, and Relative as well if needed.

-------

#!/bin/bash
# Copyright 1999 - 2001 Red Hat, Inc.
# License:  GNU General Public License v2

# check to see if the user has a preferred desktop
PREFERRED=
if [ -f /etc/sysconfig/desktop ]; then
     if [ -n "`grep -i GNOME /etc/sysconfig/desktop`" ]; then
	PREFERRED=gnome-session
     elif [ -n "`grep -i KDE /etc/sysconfig/desktop`" ]; then
	PREFERRED=startkde
     fi
fi

if [ -n "$PREFERRED" ] && which $PREFERRED >/dev/null 2>&1; then
     PREFERRED=`which $PREFERRED`
     if "$PREFERRED" = "gnome-session" ; then
       if [ -n "`grep "LeftOf\|RightOf" /etc/X11/XF86Config-4`" ]; then
           $PREFERRED --display=:0.1 &
           exec $PREFERRED --display=:0.0
       else
           exec $PREFERRED
       fi
     fi
fi

# now if we can reach here, either no desktop file was present,
# or the desktop requested is not installed.

if [ -z "$PREFERRED" ]; then

     GSESSION=gnome-session
     STARTKDE=startkde

     # by default, we run GNOME.
     if which $GSESSION >/dev/null 2>&1; then
       if [ -n "`grep "LeftOf\|RightOf" /etc/X11/XF86Config-4`" ]; then
           `which $GSESSION` --display=:0.1 &
           exec `which $GSESSION` --display=:0.0
       else
	  exec `which $GSESSION`
       fi
     fi

     # if GNOME isn't installed, try KDE.
     if which $STARTKDE >/dev/null 2>&1; then
	exec `which $STARTKDE`
     fi
fi

# Failsafe.
# Nothing of interest after this...

-------

A simpler way to accomplish all of this is to simply create a .xclients 
file in your home directory.

-------

#!/bin/bash
gnome-session --display=:0.1 &
exec gnome-session --display=:0.0

-------

3. Now, after restarting X, gnome should come up in both windows. A 
couple of strange behaviors occur: if logging in as root, two warning 
message boxes pop up, both in the primary display. Also, the splash 
screen is displayed in the second screen as expected; however, it 
displays itself perpetually until you click on it with the mouse. Wait a 
few seconds (OK, maybe longer if you don't have a really fast machine) 
and eventually the gnome desktop and launcher bar appear. I've seen the 
launcher bar occasionally hang for some seconds after it is initially 
displayed. When logging out, one of the two will simply clear the 
screen, the other will close out both sessions (it seems somewhat 
random, like it could be based on a race condition, depending on which 
initialized first). Other than these few oddities, everything seems to 
work fine for me. Hopefully, it will for you too.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.