minor tweak to XRandR class to add AccessControllers to remaining methods that need it.
This commit is contained in:
parent
2bcbea95d1
commit
8f784c424c
|
@ -119,11 +119,20 @@ public class XRandR {
|
||||||
* @param screens
|
* @param screens
|
||||||
* The desired screen set, may not be <code>null</code>
|
* The desired screen set, may not be <code>null</code>
|
||||||
*/
|
*/
|
||||||
public static void setConfiguration(Screen[]/* ... */screens) {
|
public static void setConfiguration(final Screen[]/* ... */screens) {
|
||||||
if (screens.length == 0) {
|
if (screens.length == 0) {
|
||||||
throw new IllegalArgumentException("Must specify at least one screen");
|
throw new IllegalArgumentException("Must specify at least one screen");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AccessController.doPrivileged(new PrivilegedAction() {
|
||||||
|
public Object run() {
|
||||||
|
setScreen(screens);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setScreen(Screen[] screens) {
|
||||||
List/* <String> */cmd = new ArrayList/* <String> */();
|
List/* <String> */cmd = new ArrayList/* <String> */();
|
||||||
cmd.add("xrandr");
|
cmd.add("xrandr");
|
||||||
|
|
||||||
|
@ -164,7 +173,6 @@ public class XRandR {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,7 +180,13 @@ public class XRandR {
|
||||||
* xrandr is not supported
|
* xrandr is not supported
|
||||||
*/
|
*/
|
||||||
public static String[] getScreenNames() {
|
public static String[] getScreenNames() {
|
||||||
populate();
|
AccessController.doPrivileged(new PrivilegedAction() {
|
||||||
|
public Object run() {
|
||||||
|
populate();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (String[]) screens.keySet().toArray(new String[screens.size()]);
|
return (String[]) screens.keySet().toArray(new String[screens.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +196,13 @@ public class XRandR {
|
||||||
* <code>null</code> if there is no such screen
|
* <code>null</code> if there is no such screen
|
||||||
*/
|
*/
|
||||||
public static Screen[] getResolutions(String name) {
|
public static Screen[] getResolutions(String name) {
|
||||||
populate();
|
AccessController.doPrivileged(new PrivilegedAction() {
|
||||||
|
public Object run() {
|
||||||
|
populate();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// clone the array to prevent held copies being altered
|
// clone the array to prevent held copies being altered
|
||||||
return (Screen[]) ((Screen[]) screens.get(name)).clone();
|
return (Screen[]) ((Screen[]) screens.get(name)).clone();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue