The company I work for has recently released a Java application which makes use of the Java Fullscreen Exclusive Mode API. It works great on Windows but because of a longstanding Java bug it is unable to change the display size and suspend windowed mode on Linux. Luckily the fix for this issue has been included in Java 6 Mustang so I’ll have to download a new snapshot and test it out with that.
Anyway, while reading through the bug listing I found some hints on changing the X server screen resolution, which were a great find for me as I was wondering how I could get MPlayer to play movies in proper fullscreen mode and hadn’t justified the time to research the solution.
To change the screen resolution on Linux you need to send an instruction to the X server to switch to another of its preconfigured modes. One way is to use the Ctrl+Alt+NumPad[+|-] key combination which iterates either up (numpad +) or down (numpad -) through the available modes. The only draw back to this on my platform (Ubuntu 5.10 Breezy Badger) is that when switching to smaller resolutions it didn’t resize the Gnome desktop and open windows it just acted more like a global magnifying glass to the desktop which made it rather difficult to work in any new mode.
The best way I found is to use the RandR extension which provides a command line tool called xrandr to manipulate the screen modes. I’m not sure how widely available this extension is on other distributions but it was certainly present on my Ubuntu installation without me having to install it.
To use it to change the resolution you first need to get a list of available modes to change to. To see a list open a console and type xrandr -q. This is what gets listed for my machine:
$ xrandr -q SZ: Pixels Physical Refresh *0 1440 x 900 ( 373mm x 231mm ) *60 1 1024 x 768 ( 373mm x 231mm ) 60 2 800 x 600 ( 373mm x 231mm ) 60 3 640 x 480 ( 373mm x 231mm ) 60 4 1152 x 864 ( 373mm x 231mm ) 60 5 640 x 400 ( 373mm x 231mm ) 60 6 512 x 384 ( 373mm x 231mm ) 60 7 400 x 600 ( 373mm x 231mm ) 60 8 320 x 480 ( 373mm x 231mm ) 60 9 320 x 400 ( 373mm x 231mm ) 60 Current rotation - normal Current reflection - none Rotations possible - normal Reflections possible - none
You can see that the current mode is highlighted with ‘*’. The first column in the table is the index number of the screen mode. My default has an index of 0. To change to another mode simply look up the index of the mode you want and type xrandr -s [index]. I needed to swap to 800x600 so I just typed xrandr -s 2 and the screen switched mode and most importantly also updated the layout of my desktop to fit the new screen size. To get back to the default I just typed xrandr -s 0.
After swapping to 800x600 MPlayer correctly took the entire screen in its fullscreen mode for the video clip I was playing and ran just as well as on Windows - no need to reboot back into XP to play my clips anymore! :D