com.sun.jna.platform.unix.X11 Java Examples
The following examples show how to use
com.sun.jna.platform.unix.X11.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlatformUtils.java From Quelea with GNU General Public License v3.0 | 6 votes |
/** * Helper method to send a client message to an X window. * * @param display display * @param wid native window identifier * @param msg type of message to send * @param data0 message data * @param data1 message data * @return <code>1</code> if the message was successfully sent to the * window; <code>0</code> otherwise */ private static int sendClientMessage(X11.Display display, long wid, String msg, NativeLong[] data) { // Use the JNA platform X11 binding assert (data.length == 5); X11 x = X11.INSTANCE; // Create and populate a client-event structure X11.XEvent event = new X11.XEvent(); event.type = X11.ClientMessage; // Select the proper union structure for the event type and populate it event.setType(X11.XClientMessageEvent.class); event.xclient.type = X11.ClientMessage; event.xclient.serial = new NativeLong(0L); event.xclient.send_event = 1; event.xclient.message_type = x.XInternAtom(display, msg, false); event.xclient.window = new X11.Window(wid); event.xclient.format = 32; // Select the proper union structure for the event data and populate it event.xclient.data.setType(NativeLong[].class); System.arraycopy(data, 0, event.xclient.data.l, 0, 5); // Send the event NativeLong mask = new NativeLong(X11.SubstructureRedirectMask | X11.SubstructureNotifyMask); int result = x.XSendEvent(display, x.XDefaultRootWindow(display), 0, mask, event); // Flush, since we're not processing an X event loop x.XFlush(display); // Finally, return the result of sending the event return result; }
Example #2
Source File: PlatformUtils.java From Quelea with GNU General Public License v3.0 | 5 votes |
private static boolean setFullScreenWindow(long wid, boolean fullScreen) { //Ignore this method for now. Doesn't work with snaps. if(true) return false; // Use the JNA platform X11 binding X11 x = X11.INSTANCE; X11.Display display = null; try { // Open the display display = x.XOpenDisplay(null); // Send the message int result = sendClientMessage( display, wid, "_NET_WM_STATE", new NativeLong[]{ new NativeLong(fullScreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE), x.XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", false), x.XInternAtom(display, "_NET_WM_STATE_ABOVE", false), new NativeLong(0L), new NativeLong(0L) } ); return (result != 0); } finally { if (display != null) { // Close the display x.XCloseDisplay(display); } } }
Example #3
Source File: LinuxUtils.java From RemoteSupportTool with Apache License 2.0 | 5 votes |
/** * Load X11 library. * * @return JNA interface of the X11 library */ private static X11 loadX11() { try { //LOGGER.debug("Load X11 library."); return Native.load(X11.class); } catch (UnsatisfiedLinkError ex) { LOGGER.warn("Can't load X11 library.", ex); return null; } }
Example #4
Source File: LinuxUtils.java From RemoteSupportTool with Apache License 2.0 | 5 votes |
/** * Load XTest library. * * @return JNA interface of the XTest library */ private static X11.XTest loadXTest() { try { //LOGGER.debug("Load XTest library."); return Native.load(X11.XTest.class); } catch (UnsatisfiedLinkError ex) { LOGGER.warn("Can't load XTest library.", ex); return null; } }
Example #5
Source File: LinuxIdleTime.java From Spark with Apache License 2.0 | 5 votes |
@Override public long getIdleTimeMillis() { X11.Window win = null; Xss.XScreenSaverInfo info = null; X11.Display dpy = null; final X11 x11 = X11.INSTANCE; final Xss xss = Xss.INSTANCE; long idlemillis = 0L; try { dpy = x11.XOpenDisplay(null); win = x11.XDefaultRootWindow(dpy); info = xss.XScreenSaverAllocInfo(); xss.XScreenSaverQueryInfo(dpy, win, info); idlemillis = info.idle.longValue(); } finally { if (info != null) x11.XFree(info.getPointer()); info = null; if (dpy != null) x11.XCloseDisplay(dpy); dpy = null; } return idlemillis; }
Example #6
Source File: LinuxIdleTime.java From Spark with Apache License 2.0 | 4 votes |
int XScreenSaverQueryInfo(X11.Display dpy, X11.Drawable drawable, XScreenSaverInfo saver_info);