本文整理汇总了Java中com.sun.jna.platform.unix.X11类的典型用法代码示例。如果您正苦于以下问题:Java X11类的具体用法?Java X11怎么用?Java X11使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
X11类属于com.sun.jna.platform.unix包,在下文中一共展示了X11类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSystemIdleTime
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
@Override
public long getSystemIdleTime () {
X11.Window window = null;
XScreenSaverInfo info = null;
Display display = null;
long idleMillis = 0L;
try {
display = X11.INSTANCE.XOpenDisplay(null);
window = X11.INSTANCE.XDefaultRootWindow(display);
info = new XScreenSaverInfo();
Xss.INSTANCE.XScreenSaverQueryInfo(display, window, info);
idleMillis = info.idle.longValue();
} finally {
info = null;
if (display != null) X11.INSTANCE.XCloseDisplay(display);
display = null;
}
return idleMillis;
}
示例2: sendMessage
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
private void sendMessage (Display display, long mode, String msg) {
X11 x = X11.INSTANCE;
XEvent event = new XEvent();
event.type = X11.ClientMessage;
event.setType(XClientMessageEvent.class);
event.xclient.type = X11.ClientMessage;
event.xclient.display = display;
event.xclient.message_type = x.XInternAtom(display, _NET_WM_STATE, false);
event.xclient.window = window;
event.xclient.format = 32;
event.xclient.data.setType(NativeLong[].class);
event.xclient.data.l[0] = new NativeLong(mode);
event.xclient.data.l[1] = x.XInternAtom(display, msg, false);
NativeLong mask = new NativeLong(X11.SubstructureNotifyMask | X11.SubstructureRedirectMask);
x.XSendEvent(display, x.XDefaultRootWindow(display), 0, mask, event);
}
示例3: getWindows
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
/**
* Returns all windows managed by the window manager.
*
* @return all windows managed by the window manager
* @throws X11Exception thrown if X11 window errors occurred
*/
public Window[] getWindows() throws X11Exception {
byte[] bytes;
Window rootWindow = getRootWindow();
try {
bytes = rootWindow.getProperty(X11.XA_WINDOW, "_NET_CLIENT_LIST");
} catch (X11Exception e) {
try {
bytes = rootWindow.getProperty(X11.XA_CARDINAL, "_WIN_CLIENT_LIST");
} catch (X11Exception e1) {
throw new X11Exception("Cannot get client list properties (_NET_CLIENT_LIST or _WIN_CLIENT_LIST)");
}
}
Window[] windowList = new Window[bytes.length / X11.Window.SIZE];
for (int i = 0; i < windowList.length; i++) {
windowList[i] = new Window(this, new X11.Window(bytesToInt(bytes, X11.XID.SIZE * i)));
}
return windowList;
}
示例4: getActiveDesktopNumber
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
/**
* Returns the number of the active desktop.
*
* @return number of the active desktop
* @throws X11Exception thrown if X11 window errors occurred
*/
public int getActiveDesktopNumber() throws X11Exception {
Window root = getRootWindow();
int cur_desktop;
try {
cur_desktop = root.getIntProperty(X11.XA_CARDINAL, "_NET_CURRENT_DESKTOP");
} catch (X11Exception e) {
try {
cur_desktop = root.getIntProperty(X11.XA_CARDINAL, "_WIN_WORKSPACE");
} catch (X11Exception e1) {
throw new X11Exception(
"Cannot get current desktop properties (_NET_CURRENT_DESKTOP or _WIN_WORKSPACE property)");
}
}
return cur_desktop;
}
示例5: getDesktops
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
/**
* Returns the available desktops.
*
* @return available desktops
* @throws X11Exception thrown if X11 window errors occurred
*/
public Desktop[] getDesktops() throws X11Exception {
Window root = getRootWindow();
String[] desktopNames;
try {
desktopNames = root.getUtf8ListProperty(getAtom("UTF8_STRING"), "_NET_DESKTOP_NAMES");
} catch (X11Exception e) {
try {
desktopNames = root.getStringListProperty(X11.XA_STRING, "_WIN_WORKSPACE_NAMES");
} catch (X11Exception e1) {
throw new X11Exception(
"Cannot get desktop names properties (_NET_DESKTOP_NAMES or _WIN_WORKSPACE_NAMES)");
}
}
Desktop[] desktops = new Desktop[getDesktopCount()];
for (int i = 0; i < desktops.length; i++) {
desktops[i] = new Desktop(this, i, desktopNames[i]);
}
return desktops;
}
示例6: fromXModifierKeymap
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
/**
* Reads all modifiers from the XModifierKeymap.
*
* @param xModifierKeymapRef XModifierKeymap
*/
public void fromXModifierKeymap(X11.XModifierKeymapRef xModifierKeymapRef) {
int count = xModifierKeymapRef.max_keypermod;
byte[] keys = xModifierKeymapRef.modifiermap.getByteArray(0, 8 * count);
ArrayList<Byte>[] allModifiers = getAllModifiers();
for (int modNr = 0; modNr < 8; modNr++) {
ArrayList<Byte> modifier = allModifiers[modNr];
modifier.clear();
for (int keyNr = 0; keyNr < count; keyNr++) {
byte key = keys[modNr * count + keyNr];
if (key != 0) {
modifier.add(new Byte(key));
}
}
}
}
示例7: toXModifierKeyamp
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
/**
* Returns an XModifierKeymap corresponding to this object.
*
* @return XModifierKeymap
*/
public X11.XModifierKeymapRef toXModifierKeyamp() {
ArrayList<Byte>[] allModifiers = getAllModifiers();
// determine max list size
int count = 0;
for (int i = 0; i < allModifiers.length; i++) {
count = Math.max(count, allModifiers[i].size());
}
byte[] keys = new byte[8 * count];
for (int modNr = 0; modNr < 8; modNr++) {
ArrayList<Byte> modifier = allModifiers[modNr];
for (int keyNr = 0; keyNr < modifier.size(); keyNr++) {
keys[modNr * count + keyNr] = modifier.get(keyNr).byteValue();
}
}
X11.XModifierKeymapRef xModifierKeymapRef = new X11.XModifierKeymapRef();
xModifierKeymapRef.max_keypermod = count;
xModifierKeymapRef.modifiermap = new Memory(keys.length);
xModifierKeymapRef.modifiermap.write(0, keys, 0, keys.length);
return xModifierKeymapRef;
}
示例8: getGeometry
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
/**
* Returns the geometry of the window.
*
* @return geometry of the window
*/
public Geometry getGeometry() {
X11.WindowByReference junkRoot = new X11.WindowByReference();
IntByReference junkX = new IntByReference();
IntByReference junkY = new IntByReference();
IntByReference x = new IntByReference();
IntByReference y = new IntByReference();
IntByReference width = new IntByReference();
IntByReference height = new IntByReference();
IntByReference borderWidth = new IntByReference();
IntByReference depth = new IntByReference();
x11.XGetGeometry(display.x11Display, x11Window, junkRoot, junkX, junkY, width, height, borderWidth,
depth);
x11.XTranslateCoordinates(display.x11Display, x11Window, junkRoot.getValue(), junkX.getValue(),
junkY.getValue(), x, y, junkRoot);
return new Geometry(x.getValue(), y.getValue(), width.getValue(), height.getValue(),
borderWidth.getValue(), depth.getValue());
}
示例9: getBounds
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
/**
* Returns the bounding box of the window.
*
* @return bounding box of the window
*/
public Rectangle getBounds() {
X11.WindowByReference junkRoot = new X11.WindowByReference();
IntByReference junkX = new IntByReference();
IntByReference junkY = new IntByReference();
IntByReference x = new IntByReference();
IntByReference y = new IntByReference();
IntByReference width = new IntByReference();
IntByReference height = new IntByReference();
IntByReference border_width = new IntByReference();
IntByReference depth = new IntByReference();
x11.XGetGeometry(display.x11Display, x11Window, junkRoot, junkX, junkY, width, height, border_width,
depth);
x11.XTranslateCoordinates(display.x11Display, x11Window, junkRoot.getValue(), junkX.getValue(),
junkY.getValue(), x, y, junkRoot);
int xVal = x.getValue();
int yVal = y.getValue();
return new Rectangle(xVal, yVal, xVal + width.getValue(), yVal + height.getValue());
}
示例10: getNullTerminatedProperty
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
/**
* Returns the property value as a null terminated byte array.
*
* @param xa_prop_type property type
* @param xa_prop_name property name
* @return property value as a null terminated byte array
* @throws X11Exception thrown if X11 window errors occurred
*/
public byte[] getNullTerminatedProperty(X11.Atom xa_prop_type, X11.Atom xa_prop_name) throws X11Exception {
byte[] bytesOrig = getProperty(xa_prop_type, xa_prop_name);
byte[] bytesDest;
// search for '\0'
int i;
for (i = 0; i < bytesOrig.length; i++) {
if (bytesOrig[i] == '\0') break;
}
if (i < bytesOrig.length - 1) {
bytesDest = new byte[i + 1];
System.arraycopy(bytesOrig, 0, bytesDest, 0, i + 1);
} else {
bytesDest = bytesOrig;
}
return bytesDest;
}
示例11: isLinuxX11
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
public static boolean isLinuxX11 () {
try {
Native.loadLibrary("X11", X11.class);
return true;
} catch (UnsatisfiedLinkError e) {
return false;
}
}
示例12: getIdleTimeMillis
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
@Override
public long getIdleTimeMillis()
{
X11.Window window = null;
XScreenSaverInfo info = null;
Display display = null;
long idleMillis = 0L;
try
{
display = X11.INSTANCE.XOpenDisplay(null);
if (display == null) {
display = X11.INSTANCE.XOpenDisplay(":0.0");
}
if (display == null) {
throw new RuntimeException("Could not find a display, please setup your DISPLAY environment variable");
}
window = X11.INSTANCE.XDefaultRootWindow(display);
info = new XScreenSaverInfo();
Xss.INSTANCE.XScreenSaverQueryInfo(display, window, info);
idleMillis = info.idle.longValue();
}
catch(UnsatisfiedLinkError e)
{
throw new RuntimeException(e.getMessage(), e);
}
finally
{
info = null;
if (display != null) {
X11.INSTANCE.XCloseDisplay(display);
}
display = null;
}
return idleMillis;
}
示例13: Display
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
/**
* Creates the OOWindowUtils using a given display.
*
* @param x11Display open display
*/
public Display(X11.Display x11Display) {
this.x11Display = x11Display;
if (x11Display == null) {
throw new Error("X Display is null");
}
}
示例14: getAtom
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
/**
* Get internal atoms by name.
*
* @param name name of the atom
* @return atom
*/
public X11.Atom getAtom(String name) {
X11.Atom atom = atomsHash.get(name);
if (atom == null) {
atom = x11.XInternAtom(x11Display, name, false);
atomsHash.put(name, atom);
}
return atom;
}
示例15: getWindowManagerInfo
import com.sun.jna.platform.unix.X11; //导入依赖的package包/类
/**
* Returns the window manager information as an window.
*
* @return window manager information as an window
* @throws X11Exception thrown if X11 window errors occurred
*/
public Window getWindowManagerInfo() throws X11Exception {
Window rootWindow = getRootWindow();
try {
return rootWindow.getWindowProperty(X11.XA_WINDOW, "_NET_SUPPORTING_WM_CHECK");
} catch (X11Exception e) {
try {
return rootWindow.getWindowProperty(X11.XA_CARDINAL, "_WIN_SUPPORTING_WM_CHECK");
} catch (X11Exception e1) {
throw new X11Exception(
"Cannot get window manager info properties. (_NET_SUPPORTING_WM_CHECK or _WIN_SUPPORTING_WM_CHECK)");
}
}
}