# /etc/X11/xorg.conf (xorg X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the /etc/X11/xorg.conf manual page.
# (Type "man /etc/X11/xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following commands:
#
#   cp /etc/X11/xorg.conf /etc/X11/xorg.conf.custom
#   sudo sh -c 'md5sum /etc/X11/xorg.conf >/var/lib/xfree86/xorg.conf.md5sum'
#   sudo dpkg-reconfigure xserver-xorg

# mg: I have edited this file manually:
#
#       * I enabled DynamicClocks to provide some power savings
#         LATER: disablet to see if crashes disappear (freedesktop bug #uhh..)
#         EVEN LATER: reenabled, because disabling it didn't make the crashes
#         go away
#
#       * I added a couple of ServerLayout sections to play with dual-head
#         support
#
#           startx -- -layout MergedFBLayout
#               Starts in MergedFB mode.  Single large virtual desktop
#               (2048x768), the LCD sees the left half, the external monitor
#               sees the right half.  Ctrl+Alt+[+/-] switches to clone mode
#               where you have a large virtual desktop with just one viewport
#               and can scroll horizontally.  xrandr switches to clone mode
#               where the desktop is just 1024x768 with no scrolling.
#
#               MergedFB supports 3D accel and video overlays on both heads.
#               MergedFB supports some Xinerama-style hints that let GNOME
#               maximize windows on only one head.  Sadly, workspaces are linked
#               -- you can't switch workspaces on the left head independently
#               from the right head.
#
#               MergedFB does not let me have a non-rectangular virtual desktop,
#               so if I configure a 1024x768 + 1280x1024 setup, the smaller one
#               will scroll inside a bigger a virtual desktop (only vertically,
#               also, when scrolling down the mouse cursor casts strange green
#               bars all the way to the top).  Try it with
#                   startx -- -layout MergedFB2Layout
#               Actually, there is an option to disable the vertical scrolling
#               and set xinerama hints appropriately.  It needs a newer version
#               of the radeon driver (from Xorg 6.9):
#                   Option "MergedNonRectangular" "true"
#
#               xrandr works and gives me an opportunity to switch between
#               dualhead and clone!  (If there are windows on the second head
#               when I switch to clone, they're moved so that part of them
#               is visible; when I switch back, metacity doesn't repaint half
#               of the titlebar ;)
#
#               If the second display is not connected during X startup,
#               MergedFB gets totally disabled, and nothing will bring it back
#               (xrandr shows only one mode).  In this mode Firefox breaks
#               totally and never shows any windows on the screen.  The good
#               news is that if I specify CRT2HSync/CRT2VSync, then MergedFB
#               does not get disabled, and Firefox works fine.
#
#               xv: works when mplayer is fully on head 1 or head 2; doesn't
#               work when mplayer overlaps both heads.  Switching to
#               full-screen and back always puts mplayer on the top-left
#               corner of the first head; strange.  Totem doesn't do this.
#
#               DRI: works on both heads, also overlapped.
#
#               http://bugs.xfree86.org/show_bug.cgi?id=276 is very informative
#
#           startx -- -layout XineramaLayout
#               Starts in Xinerama mode.  Two heads -- 1024x768 and 1280x1024.
#               You can move windows between them, like in MergedFB mode.  The
#               smaller head doesn't scroll in a bigger virtual space, an
#               improvement over MergedFB.  Workspaces are linked, like in
#               MergedFB.
#
#               If the second display is not connected during X startup,
#               Xinerama gets totally disabled, and nothing will bring it back
#               (except server restart).  To avoid this, I have hardcoded the
#               CRT2 hsync/vsync ranges in this config file.  This prevents
#               Xinerama/mergedfb from being disabled.
#
#               xv: works on both heads, and also partially when mplayer
#               overlaps them (but video is shown only on one head).
#               mplayer's full-screen doesn't work on second head (it displays
#               only 1024x768 image).
#
#               DRI doesn't work at all.
#
#               Xrandr doesn't work at all.  There's no way to tell the PC I do
#               not have the second head -- if I unplug the monitor, half of
#               the windows aren't accessible.
#
#           startx -- -layout TwoHeadLayout
#               No Xinerama, just two screens -- :0.0 and :0.1.  You can move
#               the mouse between them, but you cannot move windows.  Two
#               completely independent desktops, except for a bunch of GNOME
#               bugs -- e.g. window list applet breaks in the other head, etc.
#               You have independent workspaces OTOH, but the inability to move
#               windows arbitrarily is a killer :(

Section "Files"
	FontPath	"/usr/share/X11/fonts/misc"
##	FontPath	"/usr/share/X11/fonts/cyrillic"
	FontPath	"/usr/share/X11/fonts/100dpi/:unscaled"
	FontPath	"/usr/share/X11/fonts/75dpi/:unscaled"
	FontPath	"/usr/share/X11/fonts/Type1"
##	FontPath	"/usr/share/X11/fonts/CID"
	FontPath	"/usr/share/X11/fonts/100dpi"
	FontPath	"/usr/share/X11/fonts/75dpi"
        # paths to defoma fonts
	FontPath	"/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
##	FontPath	"/var/lib/defoma/x-ttcidfont-conf.d/dirs/CID"
EndSection

Section "Module"
	Load	"bitmap"
	Load	"ddc"
	Load	"dri"
	Load	"extmod"
	Load	"freetype"
	Load	"glx"
	Load	"int10"
	Load	"type1"
	Load	"vbe"
# https://help.ubuntu.com/community/CompositeManager/AIGLXOnEdgy: for AIGLX
# I need dri, dbe and glx.  I wonder what dbe is?
	Load	"dbe"
EndSection

Section "InputDevice"
	Identifier	"Generic Keyboard"
	Driver		"kbd"
	Option		"CoreKeyboard"
	Option		"XkbRules"	"xorg"
	Option		"XkbModel"	"pc105"
	Option		"XkbLayout"	"us"
EndSection

Section "InputDevice"
	Identifier	"Configured Mouse"
	Driver		"mouse"
	Option		"CorePointer"
	Option		"Device"		"/dev/input/mice"
	Option		"Protocol"		"ImPS/2"
	Option		"Emulate3Buttons"	"true"
	Option		"ZAxisMapping"		"4 5"
EndSection
Section "InputDevice"
        Identifier      "Synaptics Touchpad"
        Driver          "synaptics"
        Option          "SendCoreEvents"        "true"
        Option          "Device"                "/dev/psaux"
        Option          "Protocol"              "auto-dev"
##      Option		"HorizScrollDelta"	"0"
# The default RightEdge is 5400; it is too narrow for me
        Option		"RightEdge"		"5000"

	# This is a potential security problem; I only enable it temporarily,
	# to experiment and find out a comfortable RightEdge value
#	Option		"SHMConfig"		"true"
EndSection

Section "Device"
	Identifier	"ATI Technologies, Inc. Radeon Mobility 7500 (M7 LW)"
	Driver		"radeon"
	BusID		"PCI:1:0:0"
	Option		"DynamicClocks"	"on"
##	Option		"backingstore"	"on"
# The next line would enables Fn-F7/Fn-F8 to switch display outputs/screen
# resizing, if I had a newer version of the 'radeon' driver.
##	Option		"BIOSHotkeys"	"on"
# Surprise -- it seems that MergedFB is on by the default nowadays?  And if
# I don't explicitly list any MetaModes, then I can't use xrandr at all?
# Unfortunately, disabling MergedFB causes a side effect: if I then plug in
# an external monitor, the picture is shifted and wavy.  Unusable.
##	Option		"MergedFB"	"false"

# It won't give me the chance to get a 1280x1024 on my external display without
# this
	Option		"CRT2HSync"	"30-80"
	Option		"CRT2VRefresh"	"59-75"
# and this
  	Option		"MetaModes"	"1024x768 800x600 640x480 1024x768+1280x1024"

# https://help.ubuntu.com/community/CompositeManager/AIGLXOnEdgy: for AIGLX
# I need
    Option  "XAANoOffscreenPixmaps"	"true"
EndSection

Section "Device"
	Identifier	"MergedFB ATI Technologies, Inc. Radeon Mobility 7500 (M7 LW)"
	Driver		"radeon"
	BusID		"PCI:1:0:0"
	Option		"DynamicClocks"	"on"
	Option		"MergedFB"	"true"
	Option		"CRT2Position"	"RightOf"
    # This allows X to use MergedFB if the external monitor is not connected
    # when I start X.  The ranges are taken from DDC values of the CTX monitor
    # I use at the office; as listed in Xorg.log.
	Option		"CRT2HSync"	"30-81"
	Option		"CRT2VRefresh"	"56-76"
    # The next line lets me switch between dual-head and several clone modes
    # of varying resolutions with xrandr.
	Option		"MetaModes"	"1024x768-1024x768 1024x768 800x600 640x480"
    # My laptop's internal LCD is 100dpi.  The external LCD is designed
    # for 1280x1024, and the picture is streched.  The radeon driver computes
    # its DPI by looking at the physical size of the external LCD, and gets
    # ~65 DPI.  I want to override that.
	Option		"MergedDPI"	"100 100"
    # This should speed up RENDER acceleration and perhaps make compositing not
    # so terribly slow.  What it does, is make EVERYTHING slow.
    # Maybe it is time to try again?
##	Option		"AccelMethod"	"EXA"

        Option  "XAANoOffscreenPixmaps"	"true"
EndSection

Section "Device"
	Identifier	"MergedFB2 ATI Technologies, Inc. Radeon Mobility 7500 (M7 LW)"
	Driver		"radeon"
	BusID		"PCI:1:0:0"
	Option		"DynamicClocks"	"on"
	Option		"MergedFB"	"true"
	Option		"CRT2Position"	"RightOf"
    # This allows X to use MergedFB if the external monitor is not connected
    # when I start X.  The ranges are taken from DDC values of the CTX monitor
    # I use at the office; as listed in Xorg.log.
	Option		"CRT2HSync"	"30-81"
	Option		"CRT2VRefresh"	"56-76"
    # The next line lets me switch between dual-head and several clone modes
    # of varying resolutions with xrandr.
	Option		"MetaModes"	"1024x768-1280x1024 1024x768-1024x768 1024x768+1280x1024 1280x1024 1024x768 800x600 640x480"
    # A newer version of the radeon driver has an option that disables vertical
    # scrolling for the 1024x768 part.
	Option		"MergedNonRectangular"	"true"
    # In 1024x768-1280x1024 mode the DPI is correct (100), but in all other
    # modes it is weird.  Try to override
	Option		"MergedDPI"	"100 100"
# https://help.ubuntu.com/community/CompositeManager/AIGLXOnEdgy: for AIGLX
# I need
   Option  "XAANoOffscreenPixmaps"	"true"
# but then I wonder if AIGLX + MergedFB is a good idea.  The 3D engine is
# limited to 2048x2048, which is less than my MergedFB desktop.

    # This should speed up RENDER acceleration and perhaps make compositing not
    # so terribly slow.  What it does, is make EVERYTHING slow.
    # Maybe it is time to try again?  Well, it is still painfully slow, without
    # a composition manager.  Manageable with a composition manager.  compiz
    # fails to work, though:
    #   libGL warning: 3D driver claims to not support visual 0x4b
    #   compiz.real: GLX_EXT_texture_from_pixmap is missing
    #   compiz.real: Failed to manage screen: 0
    #   compiz.real: No manageable screens found on display :0.0
    # why? glxinfo reports I have dri, and I have GLX_EXT_texture_from_pixmap.
##	Option		"AccelMethod"	"EXA"
EndSection

Section "Device"
	Identifier	"Screen0 ATI Technologies, Inc. Radeon Mobility 7500 (M7 LW)"
	Driver		"radeon"
	BusID		"PCI:1:0:0"
	Option		"DynamicClocks"	"on"
	Screen		0
EndSection

Section "Device"
	Identifier	"Screen1 ATI Technologies, Inc. Radeon Mobility 7500 (M7 LW)"
	Driver		"radeon"
	BusID		"PCI:1:0:0"
	Option		"DynamicClocks"	"on"
	Screen		1
EndSection

Section "Monitor"
	Identifier	"Generic Monitor"
	Option		"DPMS"
EndSection

Section "Monitor"
	Identifier	"Second Monitor"
	Option		"DPMS"
EndSection

Section "Screen"
	Identifier	"Default Screen"
	Device		"ATI Technologies, Inc. Radeon Mobility 7500 (M7 LW)"
	Monitor		"Generic Monitor"
	DefaultDepth	24
	SubSection "Display"
		Depth		16
		Modes		"1024x768" "800x600" "640x480" "1280x1024"
	EndSubSection
	SubSection "Display"
		Depth		24
		Modes		"1024x768" "800x600" "640x480" "1280x1024"
	EndSubSection
EndSection

Section "Screen"
	Identifier	"MergedFB Screen"
	Device		"MergedFB ATI Technologies, Inc. Radeon Mobility 7500 (M7 LW)"
	Monitor		"Generic Monitor"
	DefaultDepth	24
	SubSection "Display"
		Depth		1
		Modes		"1024x768"
	EndSubSection
	SubSection "Display"
		Depth		4
		Modes		"1024x768"
	EndSubSection
	SubSection "Display"
		Depth		8
		Modes		"1024x768"
	EndSubSection
	SubSection "Display"
		Depth		15
		Modes		"1024x768"
	EndSubSection
	SubSection "Display"
		Depth		16
		Modes		"1024x768"
	EndSubSection
	SubSection "Display"
		Depth		24
		Modes		"1024x768"
	EndSubSection
EndSection

Section "Screen"
	Identifier	"MergedFB2 Screen"
	Device		"MergedFB2 ATI Technologies, Inc. Radeon Mobility 7500 (M7 LW)"
	Monitor		"Generic Monitor"
	DefaultDepth	24
##	DefaultDepth	16
	SubSection "Display"
		Depth		24
		Modes		"1280x1024" "1024x768"
	EndSubSection
        # People keep saying add this for compiz.  I want to know what it does.
        Option "AddARGBGLXVisuals" "true"
EndSection

Section "Screen"
	Identifier	"Screen0"
	Device		"Screen0 ATI Technologies, Inc. Radeon Mobility 7500 (M7 LW)"
	Monitor		"Generic Monitor"
	DefaultDepth	24
	SubSection "Display"
		Depth		1
		Modes		"1024x768"
	EndSubSection
	SubSection "Display"
		Depth		4
		Modes		"1024x768"
	EndSubSection
	SubSection "Display"
		Depth		8
		Modes		"1024x768"
	EndSubSection
	SubSection "Display"
		Depth		15
		Modes		"1024x768"
	EndSubSection
	SubSection "Display"
		Depth		16
		Modes		"1024x768"
	EndSubSection
	SubSection "Display"
		Depth		24
		Modes		"1024x768"
	EndSubSection
EndSection

Section "Screen"
	Identifier	"Screen1"
	Device		"Screen1 ATI Technologies, Inc. Radeon Mobility 7500 (M7 LW)"
	Monitor		"Second Monitor"
	DefaultDepth	24
	SubSection "Display"
		Depth		1
		Modes		"1280x1024" "1024x768"
	EndSubSection
	SubSection "Display"
		Depth		4
		Modes		"1280x1024" "1024x768"
	EndSubSection
	SubSection "Display"
		Depth		8
		Modes		"1280x1024" "1024x768"
	EndSubSection
	SubSection "Display"
		Depth		15
		Modes		"1280x1024" "1024x768"
	EndSubSection
	SubSection "Display"
		Depth		16
		Modes		"1280x1024" "1024x768"
	EndSubSection
	SubSection "Display"
		Depth		24
		Modes		"1280x1024" "1024x768"
	EndSubSection
EndSection

Section "ServerLayout"
	Identifier	"DefaultLayout"
	Screen		"Default Screen"
	InputDevice	"Generic Keyboard"
	InputDevice	"Configured Mouse"
	InputDevice	"Synaptics Touchpad"
EndSection

Section "ServerLayout"
	Identifier	"AiglxLayout"
	Screen		"Default Screen"
	InputDevice	"Generic Keyboard"
	InputDevice	"Configured Mouse"
	InputDevice	"Synaptics Touchpad"
# https://help.ubuntu.com/community/CompositeManager/AIGLXOnEdgy
# Hm, but isn't it enabled by default?  My xorg.0.log mentions it anyway
	Option		"AIGLX"		"true"
EndSection


Section "ServerLayout"
	Identifier	"MergedFBLayout"
	Screen		"MergedFB Screen"
	InputDevice	"Generic Keyboard"
	InputDevice	"Configured Mouse"
	InputDevice	"Synaptics Touchpad"
EndSection

Section "ServerLayout"
	Identifier	"MergedFB2Layout"
	Screen		"MergedFB2 Screen"
	InputDevice	"Generic Keyboard"
	InputDevice	"Configured Mouse"
	InputDevice	"Synaptics Touchpad"
EndSection

Section "ServerLayout"
	Identifier	"XineramaLayout"
	Screen		"Screen0"
	Screen		"Screen1" RightOf "Screen0"
	InputDevice	"Generic Keyboard"
	InputDevice	"Configured Mouse"
	InputDevice	"Synaptics Touchpad"
	Option		"Xinerama" "true"
EndSection

Section "ServerLayout"
	Identifier	"TwoHeadLayout"
	Screen		"Screen0"
	Screen		"Screen1" RightOf "Screen0"
	InputDevice	"Generic Keyboard"
	InputDevice	"Configured Mouse"
	InputDevice	"Synaptics Touchpad"
EndSection

Section "DRI"
	Mode	0666
EndSection

Section "ServerFlags"
# MergedFB2: best for dual-head, but no compiz
	Option		"DefaultServerLayout"	"MergedFB2Layout"
# dual-head compiz works here
##	Option		"DefaultServerLayout"	"MergedFBLayout"
# single-head (or clone mode) compiz works here
## 	Option		"DefaultServerLayout"	"DefaultLayout"

# If enabled, lets you deactivate KB/Mouse grabs with Ctrl+Alt+KP_Divide
#	Option		"AllowDeactivateGrabs"	"on"
# If enabled, lets you kill clients that grab the server with Ctrl+Alt+KP_Multiply
#	Option		"AllowClosedownGrabs"	"on"
EndSection

# Composite: slow as hell.  Or used to be.  Needed for AIGLX
# Hm, looks like it is enabled by default nowadays. (xorg 7.1)
# Also, it becomes not-slow if I say Option "XAANoOffscreenPixmaps" "true".
##Section "Extensions"
##	Option		"Composite"	"Enable"
##EndSection
