gpt4 book ai didi

com.sun.jna.platform.unix.X11类的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 00:37:05 25 4
gpt4 key购买 nike

本文整理了Java中com.sun.jna.platform.unix.X11类的一些代码示例,展示了X11类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X11类的具体详情如下:
包路径:com.sun.jna.platform.unix.X11
类名称:X11

X11介绍

[英]Definition (incomplete) of the X library.
[中]X库的定义(不完整)。

代码示例

代码示例来源:origin: stackoverflow.com

public interface XLib extends StdCallLibrary {
  XLib INSTANCE = (XLib) Native.loadLibrary("XLib", Psapi.class);

  int XGetInputFocus(X11.Display display, X11.Window focus_return, Pointer revert_to_return);
}

if(Platform.isLinux()) {  // Possibly most of the Unix systems will work here too, e.g. FreeBSD
    final X11 x11 = X11.INSTANCE;
    final XLib xlib= XLib.INSTANCE;
    X11.Display display = x11.XOpenDisplay(null);
    X11.Window window=new X11.Window();
    xlib.XGetInputFocus(display, window,Pointer.NULL);
    X11.XTextProperty name=new X11.XTextProperty();
    x11.XGetWMName(display, window, name);
    System.out.println(name.toString());
  }

代码示例来源:origin: net.java.dev.jna/jna-platform

Window window = SwingUtilities.getWindowAncestor(this);
X11 x11 = X11.INSTANCE;
X11.Display dpy = x11.XOpenDisplay(null);
X11.Window win = getDrawable(window);
Point offset = new Point();
win = getContentWindow(window, dpy, win, offset);
X11.GC gc = x11.XCreateGC(dpy, win, new NativeLong(0), null);
x11.XGetWindowAttributes(dpy, win, xwa);
X11.XImage image =
  x11.XCreateImage(dpy, xwa.visual, 32, X11.ZPixmap,
           0, buffer, w, h, 32, w * 4);
buffer.write(0, pixels, 0, pixels.length);
offset.x += bounds.x;
offset.y += bounds.y;
x11.XPutImage(dpy, win, gc, image, 0, 0, offset.x, offset.y, w, h);
x11.XFree(image.getPointer());
x11.XFreeGC(dpy, gc);
x11.XCloseDisplay(dpy);

代码示例来源:origin: net.java.dev.jna/jna-platform

@Override
  public void run() {
    X11 x11 = X11.INSTANCE;
    Display dpy = x11.XOpenDisplay(null);
    if (dpy == null)
      return;
    try {
      X11.Window win = getDrawable(w);
      if (alpha == 1f) {
        x11.XDeleteProperty(dpy, win,
                  x11.XInternAtom(dpy, OPACITY,
                          false));
      }
      else {
        int opacity = (int)((long)(alpha * OPAQUE) & 0xFFFFFFFF);
        IntByReference patom = new IntByReference(opacity);
        x11.XChangeProperty(dpy, win,
                  x11.XInternAtom(dpy, OPACITY,
                          false),
                  X11.XA_CARDINAL, 32,
                  X11.PropModeReplace,
                  patom.getPointer(), 1);
      }
    }
    finally {
      x11.XCloseDisplay(dpy);
    }
  }
};

代码示例来源:origin: net.java.dev.jna/jna-platform

Display dpy = x11.XOpenDisplay(null);
if (dpy == null)
  return alphaVisualIDs;
XVisualInfo info = null;
try {
  int screen = x11.XDefaultScreen(dpy);
  XVisualInfo template = new XVisualInfo();
  template.screen = screen;
                   | X11.VisualClassMask);
  IntByReference pcount = new IntByReference();
  info = x11.XGetVisualInfo(dpy, mask, template, pcount);
  if (info != null) {
    List<X11.VisualID> list = new ArrayList<X11.VisualID>();
    x11.XFree(info.getPointer());
  x11.XCloseDisplay(dpy);

代码示例来源:origin: net.java.dev.jna/platform

public boolean isPressed(int keycode, int location) {
    X11 lib = X11.INSTANCE;
    Display dpy = lib.XOpenDisplay(null);
    if (dpy == null) {
      throw new Error("Can't open X Display");
    }
    try {
      byte[] keys = new byte[32];
      // Ignore the return value
      lib.XQueryKeymap(dpy, keys);
      int keysym = toKeySym(keycode, location);
      for (int code=5;code < 256;code++) {
        int idx = code / 8;
        int shift = code % 8;
        if ((keys[idx] & (1 << shift)) != 0) {
          int sym = lib.XKeycodeToKeysym(dpy, (byte)code, 0).intValue();
          if (sym == keysym)
            return true;
        }
      }
    }
    finally {
      lib.XCloseDisplay(dpy);
    }
    return false;
  }
}

代码示例来源:origin: net.java.dev.jna/platform

public void run() {
    X11 x11 = X11.INSTANCE;
    Display dpy = x11.XOpenDisplay(null);
    if (dpy == null) {
      return;
    }
    Pixmap pm = null;
    try {
      X11.Window win = getDrawable(w);
      pm = src.getPixmap(dpy, win);
      Xext ext = Xext.INSTANCE;
      ext.XShapeCombineMask(dpy, win, X11.Xext.ShapeBounding,
                 0, 0, pm == null ? Pixmap.None : pm,
                 X11.Xext.ShapeSet);
    }
    finally {
      if (pm != null) {
        x11.XFreePixmap(dpy, pm);
      }
      x11.XCloseDisplay(dpy);
    }
    setForceHeavyweightPopups(getWindow(w), pm != null);
  }
};

代码示例来源:origin: net.java.dev.jna/platform

int width = bounds.x + bounds.width;
int height = bounds.y + bounds.height;
final Pixmap pm = x11.XCreatePixmap(dpy, win, width, height, 1);
final GC gc = x11.XCreateGC(dpy, pm, new NativeLong(0), null);
if (gc == null) {
  return null;
x11.XSetForeground(dpy, gc, new NativeLong(0));
x11.XFillRectangle(dpy, pm, gc, 0, 0, width, height);
final List<Rectangle> rlist = new ArrayList<Rectangle>();
try {
  x11.XSetForeground(dpy, gc, new NativeLong(UNMASKED));
  x11.XFillRectangles(dpy, pm, gc, rects, rects.length);
  x11.XFreeGC(dpy, gc);

代码示例来源:origin: igniterealtime/Spark

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;
  }
}

代码示例来源:origin: uk.co.caprica/vlcj

try {
  display = x.XOpenDisplay(null);
  int result = sendClientMessage(display, Native.getWindowID(w), "_NET_WM_STATE", new NativeLong(fullScreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE), x.XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", false));
  return result != 0;
  if(display != null) {
    x.XCloseDisplay(display);

代码示例来源:origin: com.googlecode.gstreamer-java/gstreamer-java

try {
  final X11 x11 = X11.INSTANCE;
  final Display display = x11.XOpenDisplay(null);
  Window window = new Window(nativeHandle);
  x11.XSelectInput(display, window,
      new NativeLong(X11.ExposureMask |
          X11.VisibilityChangeMask |
  while (watcherRunning) {
    final XEvent xEvent = new XEvent();
    x11.XNextEvent(display, xEvent);
    if (watcherRunning && !isDisposed()) {
      getDisplay().asyncExec(new Runnable() {
  x11.XCloseDisplay(display);
} catch (Exception e) {
  e.printStackTrace();

代码示例来源:origin: net.java.dev.jna/jna-platform

private static X11.Window getContentWindow(Window w, X11.Display dpy,
                      X11.Window win, Point offset) {
  if ((w instanceof Frame && !((Frame)w).isUndecorated())
    || (w instanceof Dialog && !((Dialog)w).isUndecorated())) {
    X11 x11 = X11.INSTANCE;
    X11.WindowByReference rootp = new X11.WindowByReference();
    X11.WindowByReference parentp = new X11.WindowByReference();
    PointerByReference childrenp = new PointerByReference();
    IntByReference countp = new IntByReference();
    x11.XQueryTree(dpy, win, rootp, parentp, childrenp, countp);
    Pointer p = childrenp.getValue();
    int[] ids = p.getIntArray(0, countp.getValue());
    for (int id : ids) {
      // TODO: more verification of correct window?
      X11.Window child = new X11.Window(id);
      X11.XWindowAttributes xwa = new X11.XWindowAttributes();
      x11.XGetWindowAttributes(dpy, child, xwa);
      offset.x = -xwa.x;
      offset.y = -xwa.y;
      win = child;
      break;
    }
    if (p != null) {
      x11.XFree(p);
    }
  }
  return win;
}

代码示例来源:origin: uk.co.caprica/vlcj

event.xclient.serial = new NativeLong(0L);
event.xclient.send_event = TRUE;
event.xclient.message_type = x.XInternAtom(display, msg, false);
event.xclient.window = new com.sun.jna.platform.unix.X11.Window(wid);
event.xclient.format = 32;
int result = x.XSendEvent(display, x.XDefaultRootWindow(display), 0, mask, event);
x.XFlush(display);

代码示例来源:origin: net.java.dev.jna/platform

protected void paintDirect(BufferedImage buf, Rectangle bounds) {
  Window window = SwingUtilities.getWindowAncestor(this);
  X11 x11 = X11.INSTANCE;
  X11.Display dpy = x11.XOpenDisplay(null);
  X11.Window win = getDrawable(window);
  Point offset = new Point();
  win = getContentWindow(window, dpy, win, offset);
  X11.GC gc = x11.XCreateGC(dpy, win, new NativeLong(0), null);
  x11.XGetWindowAttributes(dpy, win, xwa);
  X11.XImage image =
    x11.XCreateImage(dpy, xwa.visual, 32, X11.ZPixmap,
             0, buffer, w, h, 32, w * 4);
  buffer.write(0, pixels, 0, pixels.length);
  offset.x += bounds.x;
  offset.y += bounds.y;
  x11.XPutImage(dpy, win, gc, image, 0, 0, offset.x, offset.y, w, h);
  x11.XFree(image.getPointer());
  x11.XFreeGC(dpy, gc);
  x11.XCloseDisplay(dpy);

代码示例来源:origin: net.java.dev.jna/platform

public void run() {
    X11 x11 = X11.INSTANCE;
    Display dpy = x11.XOpenDisplay(null);
    if (dpy == null)
      return;
    try {
      X11.Window win = getDrawable(w);
      if (alpha == 1f) {
        x11.XDeleteProperty(dpy, win,
                  x11.XInternAtom(dpy, OPACITY,
                          false));
      }
      else {
        int opacity = (int)((long)(alpha * OPAQUE) & 0xFFFFFFFF);
        IntByReference patom = new IntByReference(opacity);
        x11.XChangeProperty(dpy, win,
                  x11.XInternAtom(dpy, OPACITY,
                          false),
                  X11.XA_CARDINAL, 32,
                  X11.PropModeReplace,
                  patom.getPointer(), 1);
      }
    }
    finally {
      x11.XCloseDisplay(dpy);
    }
  }
};

代码示例来源:origin: net.java.dev.jna/platform

Display dpy = x11.XOpenDisplay(null);
if (dpy == null)
  return alphaVisualIDs;
XVisualInfo info = null;
try {
  int screen = x11.XDefaultScreen(dpy);
  XVisualInfo template = new XVisualInfo();
  template.screen = screen;
                   | X11.VisualClassMask);
  IntByReference pcount = new IntByReference();
  info = x11.XGetVisualInfo(dpy, mask, template, pcount);
  if (info != null) {
    List<X11.VisualID> list = new ArrayList<X11.VisualID>();
    x11.XFree(info.getPointer());
  x11.XCloseDisplay(dpy);

代码示例来源:origin: net.java.dev.jna/jna-platform

public boolean isPressed(int keycode, int location) {
    X11 lib = X11.INSTANCE;
    Display dpy = lib.XOpenDisplay(null);
    if (dpy == null) {
      throw new Error("Can't open X Display");
    }
    try {
      byte[] keys = new byte[32];
      // Ignore the return value
      lib.XQueryKeymap(dpy, keys);
      int keysym = toKeySym(keycode, location);
      for (int code=5;code < 256;code++) {
        int idx = code / 8;
        int shift = code % 8;
        if ((keys[idx] & (1 << shift)) != 0) {
          int sym = lib.XKeycodeToKeysym(dpy, (byte)code, 0).intValue();
          if (sym == keysym)
            return true;
        }
      }
    }
    finally {
      lib.XCloseDisplay(dpy);
    }
    return false;
  }
}

代码示例来源:origin: net.java.dev.jna/jna-platform

@Override
  public void run() {
    X11 x11 = X11.INSTANCE;
    Display dpy = x11.XOpenDisplay(null);
    if (dpy == null) {
      return;
    }
    Pixmap pm = null;
    try {
      X11.Window win = getDrawable(w);
      pm = src.getPixmap(dpy, win);
      Xext ext = Xext.INSTANCE;
      ext.XShapeCombineMask(dpy, win, X11.Xext.ShapeBounding,
                 0, 0, pm == null ? Pixmap.None : pm,
                 X11.Xext.ShapeSet);
    }
    finally {
      if (pm != null) {
        x11.XFreePixmap(dpy, pm);
      }
      x11.XCloseDisplay(dpy);
    }
    setForceHeavyweightPopups(getWindow(w), pm != null);
  }
};

代码示例来源:origin: net.java.dev.jna/jna-platform

int width = bounds.x + bounds.width;
int height = bounds.y + bounds.height;
final Pixmap pm = x11.XCreatePixmap(dpy, win, width, height, 1);
final GC gc = x11.XCreateGC(dpy, pm, new NativeLong(0), null);
if (gc == null) {
  return null;
x11.XSetForeground(dpy, gc, new NativeLong(0));
x11.XFillRectangle(dpy, pm, gc, 0, 0, width, height);
final List<Rectangle> rlist = new ArrayList<Rectangle>();
try {
  x11.XSetForeground(dpy, gc, new NativeLong(UNMASKED));
  x11.XFillRectangles(dpy, pm, gc, rects, rects.length);
  x11.XFreeGC(dpy, gc);

代码示例来源:origin: net.java.dev.jna/platform

private static X11.Window getContentWindow(Window w, X11.Display dpy,
                      X11.Window win, Point offset) {
  if ((w instanceof Frame && !((Frame)w).isUndecorated())
    || (w instanceof Dialog && !((Dialog)w).isUndecorated())) {
    X11 x11 = X11.INSTANCE;
    X11.WindowByReference rootp = new X11.WindowByReference();
    X11.WindowByReference parentp = new X11.WindowByReference();
    PointerByReference childrenp = new PointerByReference();
    IntByReference countp = new IntByReference();
    x11.XQueryTree(dpy, win, rootp, parentp, childrenp, countp);
    Pointer p = childrenp.getValue();
    int[] ids = p.getIntArray(0, countp.getValue());
    for (int id : ids) {
      // TODO: more verification of correct window?
      X11.Window child = new X11.Window(id);
      X11.XWindowAttributes xwa = new X11.XWindowAttributes();
      x11.XGetWindowAttributes(dpy, child, xwa);
      offset.x = -xwa.x;
      offset.y = -xwa.y;
      win = child;
      break;
    }
    if (p != null) {
      x11.XFree(p);
    }
  }
  return win;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com