XRandR question (noob)

Started by Arvigeus, April 21, 2010, 14:23:38

Previous topic - Next topic

Arvigeus

I'm trying to write a program that controls the display (changing resolutions, rotating, external monitor and etc). The problem is I have little experience in Java, so I have troubles using LWJGL. I use XRandR.java source file added to my project and trying to make a wrapper for it. What do I need to list displays for example and execute commands (like "xrandr --output ZZZ --scale XXXxYYY"); ?

Sorry for bothering... :(

Fool Running

I'm not exactly sure what you're trying to do, but LWJGL has the function Display.getAvailableDisplayModes() that lists the display modes supported and then you can pass them to Display.setDisplayMode() to create a full-screen display in that resolution.

If all you're trying to do is use XRandR to change resolutions, etc. without LWJGL, that is, obviously, outside the scope of LWJGL and you'll probably not get much help here, sorry.

EDIT: You might try a Linux forum for help with XRandR...
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

ryanm

Hello there
If you're using LWJGL I'm not sure you should be using this class directly. If you're not using LWJGL,
find a version of the class that isn't tied into it over here.

Listing possible resolutions:
for( String name : XRandr.getScreenNames() )
{
	for( XRandr.Screen s : XRandr.getResolutions( name ) )
	{
		System.out.println( s );
	}
}


To set a configuration, search through the arrays of possible resolutions as above for the ones you want, and pass them to XRandr.setConfiguration().

The class doesn't support rotation, but it would be easy to add.

Arvigeus

 :D
Thanks a lot! Although I don't understand much of it, it simply works! I was struggling with this the whole day.
I never knew about for(String name : XRandR.getScreenNames()) syntax.

Fool Running

Wow, I never realized that LWJGL has a utility for access to XRandR.

I guess I've made a fool of myself. :-[
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

Matzon


ryanm

It probably should be made package-private. Having two different ways to change resolution seems like an accident waiting to happen to me, plus it's platform-specific.

princec

I think it should probably remain public. Let people who know what they're doing use it, etc. etc. We're not in the restriction game.

Cas :)

kappa

I think ryanm has the right idea in this case, all the public methods in XRandr should be made package-private. Last thing you need is an unsigned jar using the lwjgl certificate to pull of some crazy xrandr graphics hack/crash :)

Besides its pretty minimal amount of code, in the extremely rare case you need to use XRander directly, you can just copy and paste the class and use it with your own code.

princec

The XRandR code should be privileged, not private ... and if a signed app wants to do a crazy XRandR hack then that's fine, that's what signed apps are for.

Cacs :)

kappa

Quote from: princec on April 22, 2010, 15:10:17
The XRandR code should be privileged, not private ... and if a signed app wants to do a crazy XRandR hack then that's fine, that's what signed apps are for.

Cacs :)

you know that actually makes sense, I now agree with you :)