We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 109

Summary: [PATCH] XRandR video mode support
Product: SDL Reporter: Sam Lantinga <slouken>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: don't know   
Hardware: x86   
OS: Linux   
Bug Depends on:    
Bug Blocks: 145    
Attachments: SDL-xrandr.patch
SDL-xrandr.patch

Description Sam Lantinga 2006-01-29 23:15:42 UTC
Date: Tue, 22 Feb 2005 17:09:16 +0900
From: Aric Cyr <acyr@alumni.uwaterloo.ca>
To: sdl@libsdl.org
Subject: [SDL] [PATCH] XRandR video mode support
-- Message: 14676   --  Next: 14677 N --  (1/2) in thread  -------------------
Seeing as I couldn't find a patch for SDL to use the XRandR (resize
and rotate) extension, I whipped one up myself.  I have tested it with
a couple of the applications in the SDL test/ directory, and all
seemed to function just fine. Switching back and forth between
fullscreen and window mode caused no problems.

Since the patch current makes XRandR higher priority than the old
XVidMode extension, I added an environment variable to disable XRandR
at runtime.  The patch also includes documentation for this env var.

XRandR support can also be compile-time disabled with                
--disable-video-x11-xrandr when running configure (I defaulted it to
enable if the Xrandr header file is found).

I applied the patch against the latest CVS (2005-02-22 JST) with no
problem, and it seems to apply cleanly to 1.2.7 as well.

I'm interested in hearing any feedback!  I am not very familiar with
the XRandR extension, and the docs/man page for leave much to be
desired.  Much of my code is based on the "xrandr" application and
reading the source for libXrandr.so.  If there are any errors, please
let me know.

Thanks,
  Aric
Comment 1 Sam Lantinga 2006-01-29 23:15:58 UTC
Created attachment 51 [details]
SDL-xrandr.patch
Comment 2 Sam Lantinga 2006-01-29 23:17:01 UTC
Created attachment 52 [details]
SDL-xrandr.patch

Date: Tue, 22 Feb 2005 19:18:05 +0900
From: Aric Cyr <acyr@alumni.uwaterloo.ca>
To: sdl@libsdl.org
Subject: Re: [SDL] [PATCH] XRandR video mode support
-- Message: 14677   --  Next: 14680 N --  (2/2) in thread  -------------------
Here is a new and improved version of the XRandR patch.... this one is
better tested and includes two important fixes:

  1) the video mode list is sorted largest to smallest, instead of
     vice-versa.  This meant that some of the resolution matching
     logic had to be reversed, so set_best_resolution() changed a fair
     bit for the XRandR case.

  2) freeing of the screen_config state variable was removed from
     X11_DestroyWindow() and placed into X11_FreeVideoModes().  This
     fixes a segfault for applications that destroy and recreate their
     windows and use XRandR for mode switching (i.e. UT2004).

I have only tested on an GeForce and an Radeon system in Linux.  I'd
like to get this tested on a few more systems that support XRandR, so
please try it out and let me know how it goes.
Comment 3 Ryan C. Gordon 2006-03-14 14:59:56 UTC
I'm looking into this patch...probably have to clean up the dynamic X11 code a little first.

--ryan.

Comment 4 Ryan C. Gordon 2006-03-22 06:14:15 UTC
Xrandr support in now in CVS.

--ryan.