1 /* Copyright (c) 2007 Timothy Wall, All Rights Reserved 2 * 3 * The contents of this file is dual-licensed under 2 4 * alternative Open Source/Free licenses: LGPL 2.1 or later and 5 * Apache License 2.0. (starting with JNA version 4.0.0). 6 * 7 * You can freely decide which license you want to apply to 8 * the project. 9 * 10 * You may obtain a copy of the LGPL License at: 11 * 12 * http://www.gnu.org/licenses/licenses.html 13 * 14 * A copy is also included in the downloadable source code package 15 * containing JNA, in file "LGPL2.1". 16 * 17 * You may obtain a copy of the Apache License at: 18 * 19 * http://www.apache.org/licenses/ 20 * 21 * A copy is also included in the downloadable source code package 22 * containing JNA, in file "AL2.0". 23 */ 24 package com.sun.jna.platform.unix; 25 26 import com.sun.jna.Callback; 27 import com.sun.jna.FromNativeContext; 28 import com.sun.jna.Library; 29 import com.sun.jna.Native; 30 import com.sun.jna.NativeLong; 31 import com.sun.jna.Pointer; 32 import com.sun.jna.PointerType; 33 import com.sun.jna.Structure; 34 import com.sun.jna.Structure.FieldOrder; 35 import com.sun.jna.Union; 36 import com.sun.jna.ptr.ByReference; 37 import com.sun.jna.ptr.IntByReference; 38 import com.sun.jna.ptr.NativeLongByReference; 39 import com.sun.jna.ptr.PointerByReference; 40 41 /** Definition (incomplete) of the X library. */ 42 public interface X11 extends Library { 43 44 class VisualID extends NativeLong { 45 private static final long serialVersionUID = 1L; 46 public static final VisualID None = null; VisualID()47 public VisualID() { this(0); } VisualID(long value)48 public VisualID(long value) { super(value, true); } isNone(Object o)49 protected boolean isNone(Object o) { 50 return o == null 51 || (o instanceof Number 52 && ((Number)o).longValue() == X11.None); 53 } 54 @Override fromNative(Object nativeValue, FromNativeContext context)55 public Object fromNative(Object nativeValue, FromNativeContext context) { 56 if (isNone(nativeValue)) 57 return None; 58 return new VisualID(((Number)nativeValue).longValue()); 59 } 60 } 61 62 class XID extends NativeLong { 63 private static final long serialVersionUID = 1L; 64 public static final XID None = null; XID()65 public XID() { this(0); } XID(long id)66 public XID(long id) { super(id, true); } isNone(Object o)67 protected boolean isNone(Object o) { 68 return o == null 69 || (o instanceof Number 70 && ((Number)o).longValue() == X11.None); 71 } 72 @Override fromNative(Object nativeValue, FromNativeContext context)73 public Object fromNative(Object nativeValue, FromNativeContext context) { 74 if (isNone(nativeValue)) 75 return None; 76 return new XID(((Number)nativeValue).longValue()); 77 } 78 @Override toString()79 public String toString() { 80 return "0x" + Long.toHexString(longValue()); 81 } 82 } 83 class Atom extends XID { 84 private static final long serialVersionUID = 1L; 85 public static final Atom None = null; Atom()86 public Atom() { } Atom(long id)87 public Atom(long id) { super(id); } 88 /** Return constants for predefined <code>Atom</code> values. */ 89 @Override fromNative(Object nativeValue, FromNativeContext context)90 public Object fromNative(Object nativeValue, FromNativeContext context) { 91 long value = ((Number)nativeValue).longValue(); 92 if (value <= Integer.MAX_VALUE) { 93 switch((int)value) { 94 case 0: return None; 95 case 1: return XA_PRIMARY; 96 case 2: return XA_SECONDARY; 97 case 3: return XA_ARC; 98 case 4: return XA_ATOM; 99 case 5: return XA_BITMAP; 100 case 6: return XA_CARDINAL; 101 case 7: return XA_COLORMAP; 102 case 8: return XA_CURSOR; 103 case 9: return XA_CUT_BUFFER0; 104 case 10: return XA_CUT_BUFFER1; 105 case 11: return XA_CUT_BUFFER2; 106 case 12: return XA_CUT_BUFFER3; 107 case 13: return XA_CUT_BUFFER4; 108 case 14: return XA_CUT_BUFFER5; 109 case 15: return XA_CUT_BUFFER6; 110 case 16: return XA_CUT_BUFFER7; 111 case 17: return XA_DRAWABLE; 112 case 18: return XA_FONT; 113 case 19: return XA_INTEGER; 114 case 20: return XA_PIXMAP; 115 case 21: return XA_POINT; 116 case 22: return XA_RECTANGLE; 117 case 23: return XA_RESOURCE_MANAGER; 118 case 24: return XA_RGB_COLOR_MAP; 119 case 25: return XA_RGB_BEST_MAP; 120 case 26: return XA_RGB_BLUE_MAP; 121 case 27: return XA_RGB_DEFAULT_MAP; 122 case 28: return XA_RGB_GRAY_MAP; 123 case 29: return XA_RGB_GREEN_MAP; 124 case 30: return XA_RGB_RED_MAP; 125 case 31: return XA_STRING; 126 case 32: return XA_VISUALID; 127 case 33: return XA_WINDOW; 128 case 34: return XA_WM_COMMAND; 129 case 35: return XA_WM_HINTS; 130 case 36: return XA_WM_CLIENT_MACHINE; 131 case 37: return XA_WM_ICON_NAME; 132 case 38: return XA_WM_ICON_SIZE; 133 case 39: return XA_WM_NAME; 134 case 40: return XA_WM_NORMAL_HINTS; 135 case 41: return XA_WM_SIZE_HINTS; 136 case 42: return XA_WM_ZOOM_HINTS; 137 case 43: return XA_MIN_SPACE; 138 case 44: return XA_NORM_SPACE; 139 case 45: return XA_MAX_SPACE; 140 case 46: return XA_END_SPACE; 141 case 47: return XA_SUPERSCRIPT_X; 142 case 48: return XA_SUPERSCRIPT_Y; 143 case 49: return XA_SUBSCRIPT_X; 144 case 50: return XA_SUBSCRIPT_Y; 145 case 51: return XA_UNDERLINE_POSITION; 146 case 52: return XA_UNDERLINE_THICKNESS; 147 case 53: return XA_STRIKEOUT_ASCENT; 148 case 54: return XA_STRIKEOUT_DESCENT; 149 case 55: return XA_ITALIC_ANGLE; 150 case 56: return XA_X_HEIGHT; 151 case 57: return XA_QUAD_WIDTH; 152 case 58: return XA_WEIGHT; 153 case 59: return XA_POINT_SIZE; 154 case 60: return XA_RESOLUTION; 155 case 61: return XA_COPYRIGHT; 156 case 62: return XA_NOTICE; 157 case 63: return XA_FONT_NAME; 158 case 64: return XA_FAMILY_NAME; 159 case 65: return XA_FULL_NAME; 160 case 66: return XA_CAP_HEIGHT; 161 case 67: return XA_WM_CLASS; 162 case 68: return XA_WM_TRANSIENT_FOR; 163 default: 164 } 165 } 166 return new Atom(value); 167 } 168 } 169 class AtomByReference extends ByReference { AtomByReference()170 public AtomByReference() { super(XID.SIZE); } getValue()171 public Atom getValue() { 172 NativeLong value = getPointer().getNativeLong(0); 173 return (Atom)new Atom().fromNative(value, null); 174 } 175 } 176 class Colormap extends XID { 177 private static final long serialVersionUID = 1L; 178 public static final Colormap None = null; Colormap()179 public Colormap() { } Colormap(long id)180 public Colormap(long id) { super(id); } 181 @Override fromNative(Object nativeValue, FromNativeContext context)182 public Object fromNative(Object nativeValue, FromNativeContext context) { 183 if (isNone(nativeValue)) 184 return None; 185 return new Colormap(((Number)nativeValue).longValue()); 186 } 187 } 188 class Font extends XID { 189 private static final long serialVersionUID = 1L; 190 public static final Font None = null; Font()191 public Font() { } Font(long id)192 public Font(long id) { super(id); } 193 @Override fromNative(Object nativeValue, FromNativeContext context)194 public Object fromNative(Object nativeValue, FromNativeContext context) { 195 if (isNone(nativeValue)) 196 return None; 197 return new Font(((Number)nativeValue).longValue()); 198 } 199 } 200 class Cursor extends XID { 201 private static final long serialVersionUID = 1L; 202 public static final Cursor None = null; Cursor()203 public Cursor() { } Cursor(long id)204 public Cursor(long id) { super(id); } 205 @Override fromNative(Object nativeValue, FromNativeContext context)206 public Object fromNative(Object nativeValue, FromNativeContext context) { 207 if (isNone(nativeValue)) 208 return None; 209 return new Cursor(((Number)nativeValue).longValue()); 210 } 211 } 212 class KeySym extends XID { 213 private static final long serialVersionUID = 1L; 214 public static final KeySym None = null; KeySym()215 public KeySym() { } KeySym(long id)216 public KeySym(long id) { super(id); } 217 @Override fromNative(Object nativeValue, FromNativeContext context)218 public Object fromNative(Object nativeValue, FromNativeContext context) { 219 if (isNone(nativeValue)) 220 return None; 221 return new KeySym(((Number)nativeValue).longValue()); 222 } 223 } 224 class Drawable extends XID { 225 private static final long serialVersionUID = 1L; 226 public static final Drawable None = null; Drawable()227 public Drawable() { } Drawable(long id)228 public Drawable(long id) { super(id); } 229 @Override fromNative(Object nativeValue, FromNativeContext context)230 public Object fromNative(Object nativeValue, FromNativeContext context) { 231 if (isNone(nativeValue)) 232 return None; 233 return new Drawable(((Number)nativeValue).longValue()); 234 } 235 } 236 class Window extends Drawable { 237 private static final long serialVersionUID = 1L; 238 public static final Window None = null; Window()239 public Window() { } Window(long id)240 public Window(long id) { super(id); } 241 @Override fromNative(Object nativeValue, FromNativeContext context)242 public Object fromNative(Object nativeValue, FromNativeContext context) { 243 if (isNone(nativeValue)) 244 return None; 245 return new Window(((Number)nativeValue).longValue()); 246 } 247 } 248 class WindowByReference extends ByReference { WindowByReference()249 public WindowByReference() { super(XID.SIZE); } getValue()250 public Window getValue() { 251 NativeLong value = getPointer().getNativeLong(0); 252 return value.longValue() == X11.None ? Window.None : new Window(value.longValue()); 253 } 254 } 255 class Pixmap extends Drawable { 256 private static final long serialVersionUID = 1L; 257 public static final Pixmap None = null; Pixmap()258 public Pixmap() { } Pixmap(long id)259 public Pixmap(long id) { super(id); } 260 @Override fromNative(Object nativeValue, FromNativeContext context)261 public Object fromNative(Object nativeValue, FromNativeContext context) { 262 if (isNone(nativeValue)) 263 return None; 264 return new Pixmap(((Number)nativeValue).longValue()); 265 } 266 } 267 // TODO: define structure 268 class Display extends PointerType { } 269 // TODO: define structure 270 class Visual extends PointerType { getVisualID()271 public VisualID getVisualID() { 272 if (getPointer() != null) 273 return new VisualID(getPointer().getNativeLong(Native.POINTER_SIZE).longValue()); 274 throw new IllegalStateException("Attempting to retrieve VisualID from a null Visual"); 275 } 276 @Override toString()277 public String toString() { 278 return "Visual: VisualID=0x" + Long.toHexString(getVisualID().longValue()); 279 } 280 } 281 // TODO: define structure 282 class Screen extends PointerType { } 283 // TODO: define structure 284 class GC extends PointerType { } 285 // TODO: define structure 286 class XImage extends PointerType { } 287 288 /** 289 * The XQueryExtension function determines if the named extension is present. 290 * @param display Specifies the connection to the X server. 291 * @param name Specifies the extension name. 292 * @param major_opcode_return Returns the major opcode. 293 * @param first_event_return Returns the first event code, if any. 294 * @param first_error_return Returns the first error code, if any. 295 * @return if present 296 */ XQueryExtension(Display display, String name, IntByReference major_opcode_return, IntByReference first_event_return, IntByReference first_error_return)297 boolean XQueryExtension(Display display, String name, IntByReference major_opcode_return, IntByReference first_event_return, IntByReference first_error_return); 298 299 /** Definition (incomplete) of the Xext library. */ 300 interface Xext extends Library { 301 Xext INSTANCE = Native.load("Xext", Xext.class); 302 // Shape Kinds 303 int ShapeBounding = 0; 304 int ShapeClip = 1; 305 int ShapeInput = 2; 306 // Operations 307 int ShapeSet = 0; 308 int ShapeUnion = 1; 309 int ShapeIntersect = 2; 310 int ShapeSubtract = 3; 311 int ShapeInvert = 4; 312 XShapeCombineMask(Display display, Window window, int dest_kind, int x_off, int y_off, Pixmap src, int op)313 void XShapeCombineMask(Display display, Window window, int dest_kind, 314 int x_off, int y_off, Pixmap src, int op); 315 } 316 317 /** Definition (incomplete) of the Xrender library. */ 318 interface Xrender extends Library { 319 Xrender INSTANCE = Native.load("Xrender", Xrender.class); 320 321 @FieldOrder({"red", "redMask", "green", "greenMask", "blue", "blueMask", "alpha", "alphaMask"}) 322 class XRenderDirectFormat extends Structure { 323 public short red, redMask; 324 public short green, greenMask; 325 public short blue, blueMask; 326 public short alpha, alphaMask; 327 } 328 329 class PictFormat extends XID { 330 private static final long serialVersionUID = 1L; 331 public static final PictFormat None = null; PictFormat(long value)332 public PictFormat(long value) { super(value); } PictFormat()333 public PictFormat() { this(0); } 334 @Override fromNative(Object nativeValue, FromNativeContext context)335 public Object fromNative(Object nativeValue, FromNativeContext context) { 336 if (isNone(nativeValue)) 337 return None; 338 return new PictFormat(((Number)nativeValue).longValue()); 339 } 340 } 341 342 @FieldOrder({"id", "type", "depth", "direct", "colormap"}) 343 class XRenderPictFormat extends Structure { 344 public PictFormat id; 345 public int type; 346 public int depth; 347 public XRenderDirectFormat direct; 348 public Colormap colormap; 349 } 350 int PictTypeIndexed = 0x0; 351 int PictTypeDirect = 0x1; XRenderFindVisualFormat(Display display, Visual visual)352 XRenderPictFormat XRenderFindVisualFormat(Display display, Visual visual); 353 } 354 355 /** Definition of the Xevie library. */ 356 interface Xevie extends Library { 357 /** Instance of Xevie. Note: This extension has been removed from xorg/xserver on Oct 22, 2008 because it is broken and maintainerless. */ 358 Xevie INSTANCE = Native.load("Xevie", Xevie.class); 359 int XEVIE_UNMODIFIED = 0; 360 int XEVIE_MODIFIED = 1; 361 // Bool XevieQueryVersion (Display* display, int* major_version, int* minor_version); XevieQueryVersion(Display display, IntByReference major_version, IntByReference minor_version)362 boolean XevieQueryVersion (Display display, IntByReference major_version, IntByReference minor_version); 363 // Status XevieStart (Display* display); XevieStart(Display display)364 int XevieStart (Display display); 365 // Status XevieEnd (Display* display); XevieEnd(Display display)366 int XevieEnd (Display display); 367 // Status XevieSendEvent (Display* display, XEvent* event, int data_type); XevieSendEvent(Display display, XEvent event, int data_type)368 int XevieSendEvent (Display display, XEvent event, int data_type); 369 // Status XevieSelectInput (Display* display, NativeLong event_mask); XevieSelectInput(Display display, NativeLong event_mask)370 int XevieSelectInput (Display display, NativeLong event_mask); 371 } 372 373 /** Definition of the XTest library. */ 374 interface XTest extends Library { 375 XTest INSTANCE = Native.load("Xtst", XTest.class);///usr/lib/libxcb-xtest.so.0 XTestQueryExtension(Display display, IntByReference event_basep, IntByReference error_basep, IntByReference majorp, IntByReference minorp)376 boolean XTestQueryExtension(Display display, IntByReference event_basep, IntByReference error_basep, IntByReference majorp, IntByReference minorp); XTestCompareCursorWithWindow(Display display, Window window, Cursor cursor)377 boolean XTestCompareCursorWithWindow(Display display, Window window, Cursor cursor); XTestCompareCurrentCursorWithWindow(Display display, Window window)378 boolean XTestCompareCurrentCursorWithWindow(Display display, Window window); 379 // extern int XTestFakeKeyEvent(Display* display, unsigned int keycode, Bool is_press, unsigned long delay); XTestFakeKeyEvent(Display display, int keycode, boolean is_press, NativeLong delay)380 int XTestFakeKeyEvent(Display display, int keycode, boolean is_press, NativeLong delay); XTestFakeButtonEvent(Display display, int button, boolean is_press, NativeLong delay)381 int XTestFakeButtonEvent(Display display, int button, boolean is_press, NativeLong delay); XTestFakeMotionEvent(Display display, int screen, int x, int y, NativeLong delay)382 int XTestFakeMotionEvent(Display display, int screen, int x, int y, NativeLong delay); XTestFakeRelativeMotionEvent(Display display, int x, int y, NativeLong delay)383 int XTestFakeRelativeMotionEvent(Display display, int x, int y, NativeLong delay); XTestFakeDeviceKeyEvent(Display display, XDeviceByReference dev, int keycode, boolean is_press, IntByReference axes, int n_axes, NativeLong delay)384 int XTestFakeDeviceKeyEvent(Display display, XDeviceByReference dev, int keycode, boolean is_press, IntByReference axes, int n_axes, NativeLong delay); XTestFakeDeviceButtonEvent(Display display, XDeviceByReference dev, int button, boolean is_press, IntByReference axes, int n_axes, NativeLong delay)385 int XTestFakeDeviceButtonEvent(Display display, XDeviceByReference dev, int button, boolean is_press, IntByReference axes, int n_axes, NativeLong delay); XTestFakeProximityEvent(Display display, XDeviceByReference dev, boolean in_prox, IntByReference axes, int n_axes, NativeLong delay)386 int XTestFakeProximityEvent(Display display, XDeviceByReference dev, boolean in_prox, IntByReference axes, int n_axes, NativeLong delay); XTestFakeDeviceMotionEvent(Display display, XDeviceByReference dev, boolean is_relative, int first_axis, IntByReference axes, int n_axes, NativeLong delay)387 int XTestFakeDeviceMotionEvent(Display display, XDeviceByReference dev, boolean is_relative, int first_axis, IntByReference axes, int n_axes, NativeLong delay); XTestGrabControl(Display display, boolean impervious)388 int XTestGrabControl(Display display, boolean impervious); 389 //void XTestSetGContextOfGC(GC gc, GContext gid); XTestSetVisualIDOfVisual(Visual visual, VisualID visualid)390 void XTestSetVisualIDOfVisual(Visual visual, VisualID visualid); XTestDiscard(Display display)391 int XTestDiscard(Display display); 392 } 393 394 @FieldOrder({"input_class", "event_type_base"}) 395 class XInputClassInfoByReference extends Structure implements Structure.ByReference { 396 public byte input_class; 397 public byte event_type_base; 398 } 399 400 @FieldOrder({"device_id", "num_classes", "classes"}) 401 class XDeviceByReference extends Structure implements Structure.ByReference { 402 public XID device_id; 403 public int num_classes; 404 public XInputClassInfoByReference classes; 405 } 406 407 X11 INSTANCE = Native.load("X11", X11.class); 408 409 /* 410 typedef struct { 411 long flags; // marks which fields in this structure are defined 412 Bool input; // does this application rely on the window manager to 413 // get keyboard input? 414 int initial_state; // see below 415 Pixmap icon_pixmap; // pixmap to be used as icon 416 Window icon_window; // window to be used as icon 417 int icon_x, icon_y; // initial position of icon 418 Pixmap icon_mask; // icon mask bitmap 419 XID window_group; // id of related window group 420 // this structure may be extended in the future 421 } XWMHints; 422 */ 423 @FieldOrder({"flags", "input", "initial_state", "icon_pixmap", "icon_window", "icon_x", "icon_y", "icon_mask", "window_group"}) 424 class XWMHints extends Structure { 425 public NativeLong flags; 426 public boolean input; 427 public int initial_state; 428 public Pixmap icon_pixmap; 429 public Window icon_window; 430 public int icon_x, icon_y; 431 public Pixmap icon_mask; 432 public XID window_group; 433 } 434 435 /* 436 typedef struct { 437 unsigned char *value; // same as Property routines 438 Atom encoding; // prop type 439 int format; // prop data format: 8, 16, or 32 440 unsigned long nitems; // number of data items in value 441 } XTextProperty; 442 */ 443 @FieldOrder({"value", "encoding", "format", "nitems"}) 444 class XTextProperty extends Structure { 445 public String value; 446 public Atom encoding; 447 public int format; 448 public NativeLong nitems; 449 } 450 451 /* 452 typedef struct { 453 long flags; // marks which fields in this structure are defined 454 int x, y; // obsolete for new window mgrs, but clients 455 int width, height; /// should set so old wm's don't mess up 456 int min_width, min_height; 457 int max_width, max_height; 458 int width_inc, height_inc; 459 struct { 460 int x; // numerator 461 int y; // denominator 462 } min_aspect, max_aspect; 463 int base_width, base_height; // added by ICCCM version 1 464 int win_gravity; // added by ICCCM version 1 465 } XSizeHints; 466 */ 467 @FieldOrder({"flags", 468 "x", "y", 469 "width", "height", 470 "min_width", "min_height", 471 "max_width", "max_height", 472 "width_inc", "height_inc", 473 "min_aspect", "max_aspect", 474 "base_width", "base_height", 475 "win_gravity"}) 476 class XSizeHints extends Structure { 477 @FieldOrder({"x", "y"}) 478 public static class Aspect extends Structure { 479 public int x; // numerator 480 public int y; // denominator 481 } 482 483 public NativeLong flags; 484 public int x, y; 485 public int width, height; 486 public int min_width, min_height; 487 public int max_width, max_height; 488 public int width_inc, height_inc; 489 490 public Aspect min_aspect, max_aspect; 491 public int base_width, base_height; 492 public int win_gravity; 493 } 494 495 /* 496 typedef struct { 497 int x, y; // location of window 498 int width, height; // width and height of window 499 int border_width; // border width of window 500 int depth; // depth of window 501 Visual *visual; // the associated visual structure 502 Window root; // root of screen containing window 503 #if defined(__cplusplus) || defined(c_plusplus) 504 int c_class; // C++ InputOutput, InputOnly 505 #else 506 int class; // InputOutput, InputOnly 507 #endif 508 int bit_gravity; // one of bit gravity values 509 int win_gravity; // one of the window gravity values 510 int backing_store; // NotUseful, WhenMapped, Always 511 unsigned long backing_planes;// planes to be preserved if possible 512 unsigned long backing_pixel;// value to be used when restoring planes 513 Bool save_under; // boolean, should bits under be saved? 514 Colormap colormap; // color map to be associated with window 515 Bool map_installed; // boolean, is color map currently installed 516 int map_state; // IsUnmapped, IsUnviewable, IsViewable 517 long all_event_masks; // set of events all people have interest in 518 long your_event_mask; // my event mask 519 long do_not_propagate_mask; // set of events that should not propagate 520 Bool override_redirect; // boolean value for override-redirect 521 Screen *screen; // back pointer to correct screen 522 } XWindowAttributes; 523 */ 524 @FieldOrder({"x", "y", 525 "width", "height", 526 "border_width", 527 "depth", "visual", "root", "c_class", 528 "bit_gravity", "win_gravity", 529 "backing_store", "backing_planes", "backing_pixel", 530 "save_under", "colormap", 531 "map_installed", "map_state", 532 "all_event_masks", "your_event_mask", "do_not_propagate_mask", 533 "override_redirect", "screen"}) 534 class XWindowAttributes extends Structure { 535 public int x, y; 536 public int width, height; 537 public int border_width; 538 public int depth; 539 public Visual visual; 540 public Window root; 541 public int c_class; 542 public int bit_gravity; 543 public int win_gravity; 544 public int backing_store; 545 public NativeLong backing_planes; 546 public NativeLong backing_pixel; 547 public boolean save_under; 548 public Colormap colormap; 549 public boolean map_installed; 550 public int map_state; 551 public NativeLong all_event_masks; 552 public NativeLong your_event_mask; 553 public NativeLong do_not_propagate_mask; 554 public boolean override_redirect; 555 public Screen screen; 556 } 557 558 /* 559 typedef struct { 560 Pixmap background_pixmap; // background or None or ParentRelative 561 unsigned long background_pixel; // background pixel 562 Pixmap border_pixmap; // border of the window 563 unsigned long border_pixel; // border pixel value 564 int bit_gravity; // one of bit gravity values 565 int win_gravity; // one of the window gravity values 566 int backing_store; // NotUseful, WhenMapped, Always 567 unsigned long backing_planes;// planes to be preseved if possible 568 unsigned long backing_pixel;// value to use in restoring planes 569 Bool save_under; // should bits under be saved? (popups) 570 long event_mask; // set of events that should be saved 571 long do_not_propagate_mask; // set of events that should not propagate 572 Bool override_redirect; // boolean value for override-redirect 573 Colormap colormap; // color map to be associated with window 574 Cursor cursor; // cursor to be displayed (or None) 575 } XSetWindowAttributes; 576 */ 577 @FieldOrder({"background_pixmap", "background_pixel", 578 "border_pixmap", "border_pixel", 579 "bit_gravity", "win_gravity", 580 "backing_store", "backing_planes", "backing_pixel", 581 "save_under", 582 "event_mask", "do_not_propagate_mask", 583 "override_redirect", "colormap", "cursor"}) 584 class XSetWindowAttributes extends Structure { 585 public Pixmap background_pixmap; 586 public NativeLong background_pixel; 587 public Pixmap border_pixmap; 588 public NativeLong border_pixel; 589 public int bit_gravity; 590 public int win_gravity; 591 public int backing_store; 592 public NativeLong backing_planes; 593 public NativeLong backing_pixel; 594 public boolean save_under; 595 public NativeLong event_mask; 596 public NativeLong do_not_propagate_mask; 597 public boolean override_redirect; 598 public Colormap colormap; 599 public Cursor cursor; 600 } 601 602 int XK_0 = 0x30; 603 int XK_9 = 0x39; 604 int XK_A = 0x41; 605 int XK_Z = 0x5a; 606 int XK_a = 0x61; 607 int XK_z = 0x7a; 608 int XK_Shift_L = 0xffe1; 609 int XK_Shift_R = 0xffe1; 610 int XK_Control_L = 0xffe3; 611 int XK_Control_R = 0xffe4; 612 int XK_CapsLock = 0xffe5; 613 int XK_ShiftLock = 0xffe6; 614 int XK_Meta_L = 0xffe7; 615 int XK_Meta_R = 0xffe8; 616 int XK_Alt_L = 0xffe9; 617 int XK_Alt_R = 0xffea; 618 619 int VisualNoMask = 0x0; 620 int VisualIDMask = 0x1; 621 int VisualScreenMask = 0x2; 622 int VisualDepthMask = 0x4; 623 int VisualClassMask = 0x8; 624 int VisualRedMaskMask = 0x10; 625 int VisualGreenMaskMask = 0x20; 626 int VisualBlueMaskMask = 0x40; 627 int VisualColormapSizeMask = 0x80; 628 int VisualBitsPerRGBMask = 0x100; 629 int VisualAllMask = 0x1FF; 630 631 @FieldOrder({"visual", "visualid", "screen", "depth", "c_class", "red_mask", "green_mask", "blue_mask", "colormap_size", "bits_per_rgb"}) 632 class XVisualInfo extends Structure { 633 public Visual visual; 634 public VisualID visualid; 635 public int screen; 636 public int depth; 637 public int c_class; 638 public NativeLong red_mask; 639 public NativeLong green_mask; 640 public NativeLong blue_mask; 641 public int colormap_size; 642 public int bits_per_rgb; 643 } 644 645 @FieldOrder({"x", "y"}) 646 class XPoint extends Structure { 647 public short x, y; 648 XPoint()649 public XPoint() { this((short)0, (short)0); } XPoint(short x, short y)650 public XPoint(short x, short y) { 651 this.x = x; 652 this.y = y; 653 } 654 } 655 656 @FieldOrder({"x", "y", "width", "height"}) 657 class XRectangle extends Structure { 658 public short x, y; 659 public short width, height; 660 XRectangle()661 public XRectangle() { this((short)0, (short)0, (short)0, (short)0); } XRectangle(short x, short y, short width, short height)662 public XRectangle(short x, short y, short width, short height) { 663 this.x = x; this.y = y; 664 this.width = width; this.height = height; 665 } 666 } 667 668 Atom XA_PRIMARY = new Atom(1); 669 Atom XA_SECONDARY = new Atom(2); 670 Atom XA_ARC = new Atom(3); 671 Atom XA_ATOM = new Atom(4); 672 Atom XA_BITMAP = new Atom(5); 673 Atom XA_CARDINAL = new Atom(6); 674 Atom XA_COLORMAP = new Atom(7); 675 Atom XA_CURSOR = new Atom(8); 676 Atom XA_CUT_BUFFER0 = new Atom(9); 677 Atom XA_CUT_BUFFER1 = new Atom(10); 678 Atom XA_CUT_BUFFER2 = new Atom(11); 679 Atom XA_CUT_BUFFER3 = new Atom(12); 680 Atom XA_CUT_BUFFER4 = new Atom(13); 681 Atom XA_CUT_BUFFER5 = new Atom(14); 682 Atom XA_CUT_BUFFER6 = new Atom(15); 683 Atom XA_CUT_BUFFER7 = new Atom(16); 684 Atom XA_DRAWABLE = new Atom(17); 685 Atom XA_FONT = new Atom(18); 686 Atom XA_INTEGER = new Atom(19); 687 Atom XA_PIXMAP = new Atom(20); 688 Atom XA_POINT = new Atom(21); 689 Atom XA_RECTANGLE = new Atom(22); 690 Atom XA_RESOURCE_MANAGER = new Atom(23); 691 Atom XA_RGB_COLOR_MAP = new Atom(24); 692 Atom XA_RGB_BEST_MAP = new Atom(25); 693 Atom XA_RGB_BLUE_MAP = new Atom(26); 694 Atom XA_RGB_DEFAULT_MAP = new Atom(27); 695 Atom XA_RGB_GRAY_MAP = new Atom(28); 696 Atom XA_RGB_GREEN_MAP = new Atom(29); 697 Atom XA_RGB_RED_MAP = new Atom(30); 698 Atom XA_STRING = new Atom(31); 699 Atom XA_VISUALID = new Atom(32); 700 Atom XA_WINDOW = new Atom(33); 701 Atom XA_WM_COMMAND = new Atom(34); 702 Atom XA_WM_HINTS = new Atom(35); 703 Atom XA_WM_CLIENT_MACHINE = new Atom(36); 704 Atom XA_WM_ICON_NAME = new Atom(37); 705 Atom XA_WM_ICON_SIZE = new Atom(38); 706 Atom XA_WM_NAME = new Atom(39); 707 Atom XA_WM_NORMAL_HINTS = new Atom(40); 708 Atom XA_WM_SIZE_HINTS = new Atom(41); 709 Atom XA_WM_ZOOM_HINTS = new Atom(42); 710 Atom XA_MIN_SPACE = new Atom(43); 711 Atom XA_NORM_SPACE = new Atom(44); 712 Atom XA_MAX_SPACE = new Atom(45); 713 Atom XA_END_SPACE = new Atom(46); 714 Atom XA_SUPERSCRIPT_X = new Atom(47); 715 Atom XA_SUPERSCRIPT_Y = new Atom(48); 716 Atom XA_SUBSCRIPT_X = new Atom(49); 717 Atom XA_SUBSCRIPT_Y = new Atom(50); 718 Atom XA_UNDERLINE_POSITION = new Atom(51); 719 Atom XA_UNDERLINE_THICKNESS = new Atom(52); 720 Atom XA_STRIKEOUT_ASCENT = new Atom(53); 721 Atom XA_STRIKEOUT_DESCENT = new Atom(54); 722 Atom XA_ITALIC_ANGLE = new Atom(55); 723 Atom XA_X_HEIGHT = new Atom(56); 724 Atom XA_QUAD_WIDTH = new Atom(57); 725 Atom XA_WEIGHT = new Atom(58); 726 Atom XA_POINT_SIZE = new Atom(59); 727 Atom XA_RESOLUTION = new Atom(60); 728 Atom XA_COPYRIGHT = new Atom(61); 729 Atom XA_NOTICE = new Atom(62); 730 Atom XA_FONT_NAME = new Atom(63); 731 Atom XA_FAMILY_NAME = new Atom(64); 732 Atom XA_FULL_NAME = new Atom(65); 733 Atom XA_CAP_HEIGHT = new Atom(66); 734 Atom XA_WM_CLASS = new Atom(67); 735 Atom XA_WM_TRANSIENT_FOR = new Atom(68); 736 Atom XA_LAST_PREDEFINED = XA_WM_TRANSIENT_FOR; 737 XOpenDisplay(String name)738 Display XOpenDisplay(String name); XGetErrorText(Display display, int code, byte[] buffer, int len)739 int XGetErrorText(Display display, int code, byte[] buffer, int len); XDefaultScreen(Display display)740 int XDefaultScreen(Display display); DefaultScreenOfDisplay(Display display)741 Screen DefaultScreenOfDisplay(Display display); XDefaultVisual(Display display, int screen)742 Visual XDefaultVisual(Display display, int screen); XDefaultColormap(Display display, int screen)743 Colormap XDefaultColormap(Display display, int screen); XDisplayWidth(Display display, int screen)744 int XDisplayWidth(Display display, int screen); XDisplayHeight(Display display, int screen)745 int XDisplayHeight(Display display, int screen); XDefaultRootWindow(Display display)746 Window XDefaultRootWindow(Display display); XRootWindow(Display display, int screen)747 Window XRootWindow(Display display, int screen); XAllocNamedColor(Display display, int colormap, String color_name, Pointer screen_def_return, Pointer exact_def_return)748 int XAllocNamedColor(Display display, int colormap, String color_name, 749 Pointer screen_def_return, Pointer exact_def_return); XAllocSizeHints()750 XSizeHints XAllocSizeHints(); XSetWMProperties(Display display, Window window, String window_name, String icon_name, String[] argv, int argc, XSizeHints normal_hints, Pointer wm_hints, Pointer class_hints)751 void XSetWMProperties(Display display, Window window, String window_name, 752 String icon_name, String[] argv, int argc, 753 XSizeHints normal_hints, Pointer wm_hints, 754 Pointer class_hints); 755 XSetWMProtocols(Display display, Window window, Atom[] atom, int count)756 int XSetWMProtocols(Display display, Window window, Atom[] atom, int count); XGetWMProtocols(Display display, Window w, PointerByReference protocols_return, IntByReference count_return)757 int XGetWMProtocols(Display display, Window w, PointerByReference protocols_return, IntByReference count_return); 758 XFree(Pointer data)759 int XFree(Pointer data); XCreateSimpleWindow(Display display, Window parent, int x, int y, int width, int height, int border_width, int border, int background)760 Window XCreateSimpleWindow(Display display, Window parent, int x, int y, 761 int width, int height, int border_width, 762 int border, int background); XCreateBitmapFromData(Display display, Window window, Pointer data, int width, int height)763 Pixmap XCreateBitmapFromData(Display display, Window window, Pointer data, 764 int width, int height); XMapWindow(Display display, Window window)765 int XMapWindow(Display display, Window window); XMapRaised(Display display, Window window)766 int XMapRaised(Display display, Window window); XMapSubwindows(Display display, Window window)767 int XMapSubwindows(Display display, Window window); 768 769 /** Flushes the output buffer. Most client applications need not use this 770 * function because the output buffer is automatically flushed as needed 771 * by calls to XPending, XNextEvent, and XWindowEvent. Events generated by 772 * the server may be enqueued into the library's event queue. 773 * @param display target Display 774 * @return status 775 */ XFlush(Display display)776 int XFlush(Display display); 777 /** <p>Flushes the output buffer and then waits until all requests have been 778 * received and processed by the X server. Any errors generated must be 779 * handled by the error handler. For each protocol error received by Xlib, 780 * XSync calls the client application's error handling routine (see 781 * section 11.8.2). Any events generated by the server are enqueued into 782 * the library's event queue.</p> 783 * Finally, if you passed False, XSync does 784 * not discard the events in the queue. If you passed True, XSync discards 785 * all events in the queue, including those events that were on the queue 786 * before XSync was called. Client applications seldom need to call 787 * XSync. 788 * @param display target Display 789 * @param discard whether to discard events 790 * @return status 791 */ XSync(Display display, boolean discard)792 int XSync(Display display, boolean discard); 793 /** <p>If mode is QueuedAlready, XEventsQueued returns the number of events 794 * already in the event queue (and never performs a system call). If mode 795 * is QueuedAfterFlush, XEventsQueued returns the number of events already 796 * in the queue if the number is nonzero. If there are no events in the 797 * queue, XEventsQueued flushes the output buffer, attempts to read more 798 * events out of the application's connection, and returns the number 799 * read. If mode is QueuedAfterReading, XEventsQueued returns the number 800 * of events already in the queue if the number is nonzero. If there are 801 * no events in the queue, XEventsQueued attempts to read more events out 802 * of the application's connection without flushing the output buffer and 803 * returns the number read.</p> 804 * XEventsQueued always returns immediately 805 * without I/O if there are events already in the queue. XEventsQueued 806 * with mode QueuedAfterFlush is identical in behavior to 807 * XPending. XEventsQueued with mode QueuedAlready is identical to the 808 * XQLength function. 809 * @param display target Display 810 * @param mode QueuedAlready, QueuedAfterFlush, or QueuedAfterReading 811 * @return status 812 */ XEventsQueued(Display display, int mode)813 int XEventsQueued(Display display, int mode); 814 /** Returns the number of events that have been received from the X server 815 * but have not been removed from the event queue. XPending is identical 816 * to XEventsQueued with the mode QueuedAfterFlush specified. 817 * @param display target Display 818 * @return status 819 */ XPending(Display display)820 int XPending(Display display); 821 XUnmapWindow(Display display, Window window)822 int XUnmapWindow(Display display, Window window); XDestroyWindow(Display display, Window window)823 int XDestroyWindow(Display display, Window window); XCloseDisplay(Display display)824 int XCloseDisplay(Display display); XClearWindow(Display display, Window window)825 int XClearWindow(Display display, Window window); XClearArea(Display display, Window window, int x, int y, int w, int h, int exposures)826 int XClearArea(Display display, Window window, int x, int y, int w, int h, int exposures); XCreatePixmap(Display display, Drawable drawable, int width, int height, int depth)827 Pixmap XCreatePixmap(Display display, Drawable drawable, int width, int height, int depth); XFreePixmap(Display display, Pixmap pixmap)828 int XFreePixmap(Display display, Pixmap pixmap); 829 830 @FieldOrder({"function", "plane_mask", 831 "foreground", "background", 832 "line_width", "line_style", 833 "cap_style", "join_style", 834 "fill_style", "fill_rule", 835 "arc_mode", "tile", "stipple", 836 "ts_x_origin", "ts_y_origin", 837 "font", "subwindow_mode", "graphics_exposures", 838 "clip_x_origin", "clip_y_origin", "clip_mask", 839 "dash_offset", "dashes"}) 840 class XGCValues extends Structure { 841 public int function; /* logical operation */ 842 public NativeLong plane_mask;/* plane mask */ 843 public NativeLong foreground;/* foreground pixel */ 844 public NativeLong background;/* background pixel */ 845 public int line_width; /* line width (in pixels) */ 846 public int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash*/ 847 public int cap_style; /* CapNotLast, CapButt, CapRound, CapProjecting */ 848 public int join_style; /* JoinMiter, JoinRound, JoinBevel */ 849 public int fill_style; /* FillSolid, FillTiled, FillStippled FillOpaqueStippled*/ 850 public int fill_rule; /* EvenOddRule, WindingRule */ 851 public int arc_mode; /* ArcChord, ArcPieSlice */ 852 public Pixmap tile; /* tile pixmap for tiling operations */ 853 public Pixmap stipple; /* stipple 1 plane pixmap for stippling */ 854 public int ts_x_origin; /* offset for tile or stipple operations */ 855 public int ts_y_origin; 856 public Font font; /* default text font for text operations */ 857 public int subwindow_mode; /* ClipByChildren, IncludeInferiors */ 858 public boolean graphics_exposures; /* boolean, should exposures be generated */ 859 public int clip_x_origin; /* origin for clipping */ 860 public int clip_y_origin; 861 public Pixmap clip_mask; /* bitmap clipping; other calls for rects */ 862 public int dash_offset; /* patterned/dashed line information */ 863 public byte dashes; 864 } XCreateGC(Display display, Drawable drawable, NativeLong mask, XGCValues values)865 GC XCreateGC(Display display, Drawable drawable, NativeLong mask, XGCValues values); XSetFillRule(Display display, GC gc, int fill_rule)866 int XSetFillRule(Display display, GC gc, int fill_rule); XFreeGC(Display display, GC gc)867 int XFreeGC(Display display, GC gc); XDrawPoint(Display display, Drawable drawable, GC gc, int x, int y)868 int XDrawPoint(Display display, Drawable drawable, GC gc, int x, int y); XDrawPoints(Display display, Drawable drawable, GC gc, XPoint[] points, int npoints, int mode)869 int XDrawPoints(Display display, Drawable drawable, GC gc, 870 XPoint[] points, int npoints, int mode); XFillRectangle(Display display, Drawable drawable, GC gc, int x, int y, int width, int height)871 int XFillRectangle(Display display, Drawable drawable, GC gc, 872 int x, int y, int width, int height); XFillRectangles(Display display, Drawable drawable, GC gc, XRectangle[] rectangles, int nrectangles)873 int XFillRectangles(Display display, Drawable drawable, GC gc, 874 XRectangle[] rectangles, int nrectangles); XSetForeground(Display display, GC gc, NativeLong color)875 int XSetForeground(Display display, GC gc, NativeLong color); XSetBackground(Display display, GC gc, NativeLong color)876 int XSetBackground(Display display, GC gc, NativeLong color); XFillArc(Display display, Drawable drawable, GC gc, int x, int y, int width, int height, int angle1, int angle2)877 int XFillArc(Display display, Drawable drawable, GC gc, int x, int y, 878 int width, int height, int angle1, int angle2); XFillPolygon(Display dpy, Drawable drawable, GC gc, XPoint[] points, int npoints, int shape, int mode)879 int XFillPolygon(Display dpy, Drawable drawable, GC gc, XPoint[] points, 880 int npoints, int shape, int mode); XQueryTree(Display display, Window window, WindowByReference root, WindowByReference parent, PointerByReference children, IntByReference childCount)881 int XQueryTree(Display display, Window window, WindowByReference root, 882 WindowByReference parent, PointerByReference children, 883 IntByReference childCount); XQueryPointer(Display display, Window window, WindowByReference root_return, WindowByReference child_return, IntByReference root_x_return, IntByReference root_y_return, IntByReference win_x_return, IntByReference win_y_return, IntByReference mask_return)884 boolean XQueryPointer(Display display, Window window, 885 WindowByReference root_return, 886 WindowByReference child_return, 887 IntByReference root_x_return, 888 IntByReference root_y_return, 889 IntByReference win_x_return, 890 IntByReference win_y_return, 891 IntByReference mask_return); XGetWindowAttributes(Display display, Window window, XWindowAttributes attributes)892 int XGetWindowAttributes(Display display, Window window, XWindowAttributes attributes); XChangeWindowAttributes(Display display, Window window, NativeLong valuemask, XSetWindowAttributes attributes)893 int XChangeWindowAttributes(Display display, Window window, NativeLong valuemask, XSetWindowAttributes attributes); 894 // Status XGetGeometry(Display *display, Drawable d, Window *root_return, int *x_return, int *y_return, unsigned int *width_return, 895 // unsigned int *height_return, unsigned int *border_width_return, unsigned int *depth_return); XGetGeometry(Display display, Drawable d, WindowByReference w, IntByReference x, IntByReference y, IntByReference width, IntByReference heigth, IntByReference border_width, IntByReference depth)896 int XGetGeometry(Display display, Drawable d, WindowByReference w, IntByReference x, IntByReference y, IntByReference width, 897 IntByReference heigth, IntByReference border_width, IntByReference depth); 898 // Bool XTranslateCoordinates(Display *display, Window src_w, dest_w, int src_x, int src_y, 899 // int *dest_x_return, int *dest_y_return, Window *child_return); XTranslateCoordinates(Display display, Window src_w, Window dest_w, int src_x, int src_y, IntByReference dest_x_return, IntByReference dest_y_return, WindowByReference child_return)900 boolean XTranslateCoordinates(Display display, Window src_w, Window dest_w, int src_x, int src_y, 901 IntByReference dest_x_return, IntByReference dest_y_return, WindowByReference child_return); 902 903 /***************************************************************** 904 * RESERVED RESOURCE AND CONSTANT DEFINITIONS 905 *****************************************************************/ 906 907 int None = 0; /* universal null resource or null atom */ 908 int ParentRelative = 1; /* background pixmap in CreateWindow and ChangeWindowAttributes */ 909 int CopyFromParent = 0; /* border pixmap in CreateWindow 910 and ChangeWindowAttributes 911 special VisualID and special window 912 class passed to CreateWindow */ 913 int PointerWindow = 0; /* destination window in SendEvent */ 914 int InputFocus = 1; /* destination window in SendEvent */ 915 int PointerRoot = 1; /* focus window in SetInputFocus */ 916 int AnyPropertyType = 0; /* special Atom, passed to GetProperty */ 917 int AnyKey = 0; /* special Key Code, passed to GrabKey */ 918 int AnyButton = 0; /* special Button Code, passed to GrabButton */ 919 int AllTemporary = 0; /* special Resource ID passed to KillClient */ 920 int CurrentTime = 0; /* special Time */ 921 int NoSymbol = 0; /* special KeySym */ 922 923 /***************************************************************** 924 * EVENT DEFINITIONS 925 *****************************************************************/ 926 927 /* Input Event Masks. Used as event-mask window attribute and as arguments 928 to Grab requests. Not to be confused with event names. */ 929 int NoEventMask = 0; 930 int KeyPressMask = (1<<0); 931 int KeyReleaseMask = (1<<1); 932 int ButtonPressMask = (1<<2); 933 int ButtonReleaseMask = (1<<3); 934 int EnterWindowMask = (1<<4); 935 int LeaveWindowMask = (1<<5); 936 int PointerMotionMask = (1<<6); 937 int PointerMotionHintMask = (1<<7); 938 int Button1MotionMask = (1<<8); 939 int Button2MotionMask = (1<<9); 940 int Button3MotionMask = (1<<10); 941 int Button4MotionMask = (1<<11); 942 int Button5MotionMask = (1<<12); 943 int ButtonMotionMask = (1<<13); 944 int KeymapStateMask = (1<<14); 945 int ExposureMask = (1<<15); 946 int VisibilityChangeMask = (1<<16); 947 int StructureNotifyMask = (1<<17); 948 int ResizeRedirectMask = (1<<18); 949 int SubstructureNotifyMask = (1<<19); 950 int SubstructureRedirectMask = (1<<20); 951 int FocusChangeMask = (1<<21); 952 int PropertyChangeMask = (1<<22); 953 int ColormapChangeMask = (1<<23); 954 int OwnerGrabButtonMask = (1<<24); 955 956 /* Event names. Used in "type" field in XEvent structures. Not to be 957 confused with event masks above. They start from 2 because 0 and 1 958 are reserved in the protocol for errors and replies. */ 959 int KeyPress = 2; 960 int KeyRelease = 3; 961 int ButtonPress = 4; 962 int ButtonRelease = 5; 963 int MotionNotify = 6; 964 int EnterNotify = 7; 965 int LeaveNotify = 8; 966 int FocusIn = 9; 967 int FocusOut = 10; 968 int KeymapNotify = 11; 969 int Expose = 12; 970 int GraphicsExpose = 13; 971 int NoExpose = 14; 972 int VisibilityNotify = 15; 973 int CreateNotify = 16; 974 int DestroyNotify = 17; 975 int UnmapNotify = 18; 976 int MapNotify = 19; 977 int MapRequest = 20; 978 int ReparentNotify = 21; 979 int ConfigureNotify = 22; 980 int ConfigureRequest = 23; 981 int GravityNotify = 24; 982 int ResizeRequest = 25; 983 int CirculateNotify = 26; 984 int CirculateRequest = 27; 985 int PropertyNotify = 28; 986 int SelectionClear = 29; 987 int SelectionRequest = 30; 988 int SelectionNotify = 31; 989 int ColormapNotify = 32; 990 int ClientMessage = 33; 991 int MappingNotify = 34; 992 int GenericEvent = 35; 993 int LASTEvent = 36; // must be bigger than any event # 994 995 /* Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer, 996 state in various key-, mouse-, and button-related events. */ 997 int ShiftMask = (1 << 0); 998 int LockMask = (1 << 1); 999 int ControlMask = (1 << 2); 1000 int Mod1Mask = (1 << 3); 1001 int Mod2Mask = (1 << 4); 1002 int Mod3Mask = (1 << 5); 1003 int Mod4Mask = (1 << 6); 1004 int Mod5Mask = (1 << 7); 1005 1006 /* modifier names. Used to build a SetModifierMapping request or 1007 to read a GetModifierMapping request. These correspond to the 1008 masks defined above. */ 1009 int ShiftMapIndex = 0; 1010 int LockMapIndex = 1; 1011 int ControlMapIndex = 2; 1012 int Mod1MapIndex = 3; 1013 int Mod2MapIndex = 4; 1014 int Mod3MapIndex = 5; 1015 int Mod4MapIndex = 6; 1016 int Mod5MapIndex = 7; 1017 1018 /* button masks. Used in same manner as Key masks above. Not to be confused 1019 with button names below. */ 1020 int Button1Mask = (1 << 8); 1021 int Button2Mask = (1 << 9); 1022 int Button3Mask = (1 << 10); 1023 int Button4Mask = (1 << 11); 1024 int Button5Mask = (1 << 12); 1025 1026 int AnyModifier = (1 << 15); /* used in GrabButton, GrabKey */ 1027 1028 /* button names. Used as arguments to GrabButton and as detail in ButtonPress 1029 and ButtonRelease events. Not to be confused with button masks above. 1030 Note that 0 is already defined above as "AnyButton". */ 1031 int Button1 = 1; 1032 int Button2 = 2; 1033 int Button3 = 3; 1034 int Button4 = 4; 1035 int Button5 = 5; 1036 1037 /* Notify modes */ 1038 int NotifyNormal = 0; 1039 int NotifyGrab = 1; 1040 int NotifyUngrab = 2; 1041 int NotifyWhileGrabbed = 3; 1042 1043 int NotifyHint = 1; /* for MotionNotify events */ 1044 1045 /* Notify detail */ 1046 int NotifyAncestor = 0; 1047 int NotifyVirtual = 1; 1048 int NotifyInferior = 2; 1049 int NotifyNonlinear = 3; 1050 int NotifyNonlinearVirtual = 4; 1051 int NotifyPointer = 5; 1052 int NotifyPointerRoot = 6; 1053 int NotifyDetailNone = 7; 1054 1055 /* Visibility notify */ 1056 int VisibilityUnobscured = 0; 1057 int VisibilityPartiallyObscured = 1; 1058 int VisibilityFullyObscured = 2; 1059 1060 /* Circulation request */ 1061 int PlaceOnTop = 0; 1062 int PlaceOnBottom = 1; 1063 1064 /* protocol families */ 1065 int FamilyInternet = 0; /* IPv4 */ 1066 int FamilyDECnet = 1; 1067 int FamilyChaos = 2; 1068 int FamilyInternet6 = 6; /* IPv6 */ 1069 1070 /* authentication families not tied to a specific protocol */ 1071 int FamilyServerInterpreted = 5; 1072 1073 /* Property notification */ 1074 int PropertyNewValue = 0; 1075 int PropertyDelete = 1; 1076 1077 /* Color Map notification */ 1078 int ColormapUninstalled = 0; 1079 int ColormapInstalled = 1; 1080 1081 /* GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes */ 1082 int GrabModeSync = 0; 1083 int GrabModeAsync = 1; 1084 1085 /* GrabPointer, GrabKeyboard reply status */ 1086 int GrabSuccess = 0; 1087 int AlreadyGrabbed = 1; 1088 int GrabInvalidTime = 2; 1089 int GrabNotViewable = 3; 1090 int GrabFrozen = 4; 1091 1092 /* AllowEvents modes */ 1093 int AsyncPointer = 0; 1094 int SyncPointer = 1; 1095 int ReplayPointer = 2; 1096 int AsyncKeyboard = 3; 1097 int SyncKeyboard = 4; 1098 int ReplayKeyboard = 5; 1099 int AsyncBoth = 6; 1100 int SyncBoth = 7; 1101 1102 /* Used in SetInputFocus, GetInputFocus */ 1103 int RevertToNone = None; 1104 int RevertToPointerRoot = PointerRoot; 1105 int RevertToParent = 2; 1106 1107 /***************************************************************** 1108 * ERROR CODES 1109 *****************************************************************/ 1110 1111 int Success = 0; /* everything's okay */ 1112 int BadRequest = 1; /* bad request code */ 1113 int BadValue = 2; /* int parameter out of range */ 1114 int BadWindow = 3; /* parameter not a Window */ 1115 int BadPixmap = 4; /* parameter not a Pixmap */ 1116 int BadAtom = 5; /* parameter not an Atom */ 1117 int BadCursor = 6; /* parameter not a Cursor */ 1118 int BadFont = 7; /* parameter not a Font */ 1119 int BadMatch = 8; /* parameter mismatch */ 1120 int BadDrawable = 9; /* parameter not a Pixmap or Window */ 1121 int BadAccess = 10; /* depending on context: 1122 - key/button already grabbed 1123 - attempt to free an illegal 1124 cmap entry 1125 - attempt to store into a read-only 1126 color map entry. 1127 - attempt to modify the access control 1128 list from other than the local host. 1129 */ 1130 int BadAlloc = 11; /* insufficient resources */ 1131 int BadColor = 12; /* no such colormap */ 1132 int BadGC = 13; /* parameter not a GC */ 1133 int BadIDChoice = 14; /* choice not in range or already used */ 1134 int BadName = 15; /* font or color name doesn't exist */ 1135 int BadLength = 16; /* Request length incorrect */ 1136 int BadImplementation = 17; /* server is defective */ 1137 1138 int FirstExtensionError = 128; 1139 int LastExtensionError = 255; 1140 1141 /***************************************************************** 1142 * WINDOW DEFINITIONS 1143 *****************************************************************/ 1144 1145 /* Window classes used by CreateWindow */ 1146 /* Note that CopyFromParent is already defined as 0 above */ 1147 int InputOutput = 1; 1148 int InputOnly = 2; 1149 1150 /* Window attributes for CreateWindow and ChangeWindowAttributes */ 1151 int CWBackPixmap = (1<<0); 1152 int CWBackPixel = (1<<1); 1153 int CWBorderPixmap = (1<<2); 1154 int CWBorderPixel = (1<<3); 1155 int CWBitGravity = (1<<4); 1156 int CWWinGravity = (1<<5); 1157 int CWBackingStore = (1<<6); 1158 int CWBackingPlanes = (1<<7); 1159 int CWBackingPixel = (1<<8); 1160 int CWOverrideRedirect = (1<<9); 1161 int CWSaveUnder = (1<<10); 1162 int CWEventMask = (1<<11); 1163 int CWDontPropagate = (1<<12); 1164 int CWColormap = (1<<13); 1165 int CWCursor = (1<<14); 1166 1167 /* ConfigureWindow structure */ 1168 int CWX = (1<<0); 1169 int CWY = (1<<1); 1170 int CWWidth = (1<<2); 1171 int CWHeight = (1<<3); 1172 int CWBorderWidth = (1<<4); 1173 int CWSibling = (1<<5); 1174 int CWStackMode = (1<<6); 1175 1176 1177 /* Bit Gravity */ 1178 int ForgetGravity = 0; 1179 int NorthWestGravity = 1; 1180 int NorthGravity = 2; 1181 int NorthEastGravity = 3; 1182 int WestGravity = 4; 1183 int CenterGravity = 5; 1184 int EastGravity = 6; 1185 int SouthWestGravity = 7; 1186 int SouthGravity = 8; 1187 int SouthEastGravity = 9; 1188 int StaticGravity = 10; 1189 1190 /* Window gravity + bit gravity above */ 1191 int UnmapGravity = 0; 1192 1193 /* Used in CreateWindow for backing-store hint */ 1194 int NotUseful = 0; 1195 int WhenMapped = 1; 1196 int Always = 2; 1197 1198 /* Used in GetWindowAttributes reply */ 1199 int IsUnmapped = 0; 1200 int IsUnviewable = 1; 1201 int IsViewable = 2; 1202 1203 /* Used in ChangeSaveSet */ 1204 int SetModeInsert = 0; 1205 int SetModeDelete = 1; 1206 1207 /* Used in ChangeCloseDownMode */ 1208 int DestroyAll = 0; 1209 int RetainPermanent = 1; 1210 int RetainTemporary = 2; 1211 1212 /* Window stacking method (in configureWindow) */ 1213 int Above = 0; 1214 int Below = 1; 1215 int TopIf = 2; 1216 int BottomIf = 3; 1217 int Opposite = 4; 1218 1219 /* Circulation direction */ 1220 int RaiseLowest = 0; 1221 int LowerHighest = 1; 1222 1223 /* Property modes */ 1224 int PropModeReplace = 0; 1225 int PropModePrepend = 1; 1226 int PropModeAppend = 2; 1227 1228 /***************************************************************** 1229 * GRAPHICS DEFINITIONS 1230 *****************************************************************/ 1231 1232 /* graphics functions, as in GC.alu */ 1233 int GXclear = 0x0; /* 0 */ 1234 int GXand = 0x1; /* src AND dst */ 1235 int GXandReverse = 0x2; /* src AND NOT dst */ 1236 int GXcopy = 0x3; /* src */ 1237 int GXandInverted = 0x4; /* NOT src AND dst */ 1238 int GXnoop = 0x5; /* dst */ 1239 int GXxor = 0x6; /* src XOR dst */ 1240 int GXor = 0x7; /* src OR dst */ 1241 int GXnor = 0x8; /* NOT src AND NOT dst */ 1242 int GXequiv = 0x9; /* NOT src XOR dst */ 1243 int GXinvert = 0xa; /* NOT dst */ 1244 int GXorReverse = 0xb; /* src OR NOT dst */ 1245 int GXcopyInverted = 0xc; /* NOT src */ 1246 int GXorInverted = 0xd; /* NOT src OR dst */ 1247 int GXnand = 0xe; /* NOT src OR NOT dst */ 1248 int GXset = 0xf; /* 1 */ 1249 1250 /* LineStyle */ 1251 int LineSolid = 0; 1252 int LineOnOffDash = 1; 1253 int LineDoubleDash = 2; 1254 1255 /* capStyle */ 1256 int CapNotLast = 0; 1257 int CapButt = 1; 1258 int CapRound = 2; 1259 int CapProjecting = 3; 1260 1261 /* joinStyle */ 1262 int JoinMiter = 0; 1263 int JoinRound = 1; 1264 int JoinBevel = 2; 1265 1266 /* fillStyle */ 1267 int FillSolid = 0; 1268 int FillTiled = 1; 1269 int FillStippled = 2; 1270 int FillOpaqueStippled = 3; 1271 1272 /* fillRule */ 1273 int EvenOddRule = 0; 1274 int WindingRule = 1; 1275 1276 /* subwindow mode */ 1277 int ClipByChildren = 0; 1278 int IncludeInferiors = 1; 1279 1280 /* SetClipRectangles ordering */ 1281 int Unsorted = 0; 1282 int YSorted = 1; 1283 int YXSorted = 2; 1284 int YXBanded = 3; 1285 1286 /* CoordinateMode for drawing routines */ 1287 int CoordModeOrigin = 0; /* relative to the origin */ 1288 int CoordModePrevious = 1; /* relative to previous point */ 1289 1290 /* Polygon shapes */ 1291 int Complex = 0; /* paths may intersect */ 1292 int Nonconvex = 1; /* no paths intersect, but not convex */ 1293 int Convex = 2; /* wholly convex */ 1294 1295 /* Arc modes for PolyFillArc */ 1296 int ArcChord = 0; /* join endpoints of arc */ 1297 int ArcPieSlice = 1; /* join endpoints to center of arc */ 1298 1299 /* GC components: masks used in CreateGC, CopyGC, ChangeGC, OR'ed into 1300 GC.stateChanges */ 1301 int GCFunction = (1<<0); 1302 int GCPlaneMask = (1<<1); 1303 int GCForeground = (1<<2); 1304 int GCBackground = (1<<3); 1305 int GCLineWidth = (1<<4); 1306 int GCLineStyle = (1<<5); 1307 int GCCapStyle = (1<<6); 1308 int GCJoinStyle = (1<<7); 1309 int GCFillStyle = (1<<8); 1310 int GCFillRule = (1<<9); 1311 int GCTile = (1<<10); 1312 int GCStipple = (1<<11); 1313 int GCTileStipXOrigin = (1<<12); 1314 int GCTileStipYOrigin = (1<<13); 1315 int GCFont = (1<<14); 1316 int GCSubwindowMode = (1<<15); 1317 int GCGraphicsExposures = (1<<16); 1318 int GCClipXOrigin = (1<<17); 1319 int GCClipYOrigin = (1<<18); 1320 int GCClipMask = (1<<19); 1321 int GCDashOffset = (1<<20); 1322 int GCDashList = (1<<21); 1323 int GCArcMode = (1<<22); 1324 1325 int GCLastBit = 22; 1326 /***************************************************************** 1327 * FONTS 1328 *****************************************************************/ 1329 1330 /* used in QueryFont -- draw direction */ 1331 int FontLeftToRight = 0; 1332 int FontRightToLeft = 1; 1333 1334 int FontChange = 255; 1335 1336 /***************************************************************** 1337 * IMAGING 1338 *****************************************************************/ 1339 1340 /* ImageFormat -- PutImage, GetImage */ 1341 int XYBitmap = 0; /* depth 1, XYFormat */ 1342 int XYPixmap = 1; /* depth == drawable depth */ 1343 int ZPixmap = 2; /* depth == drawable depth */ 1344 1345 /***************************************************************** 1346 * COLOR MAP STUFF 1347 *****************************************************************/ 1348 1349 /* For CreateColormap */ 1350 int AllocNone = 0; /* create map with no entries */ 1351 int AllocAll = 1; /* allocate entire map writeable */ 1352 1353 1354 /* Flags used in StoreNamedColor, StoreColors */ 1355 int DoRed = (1<<0); 1356 int DoGreen = (1<<1); 1357 int DoBlue = (1<<2); 1358 1359 /***************************************************************** 1360 * CURSOR STUFF 1361 *****************************************************************/ 1362 1363 /* QueryBestSize Class */ 1364 int CursorShape = 0; /* largest size that can be displayed */ 1365 int TileShape = 1; /* size tiled fastest */ 1366 int StippleShape = 2; /* size stippled fastest */ 1367 1368 /***************************************************************** 1369 * KEYBOARD/POINTER STUFF 1370 *****************************************************************/ 1371 1372 int AutoRepeatModeOff = 0; 1373 int AutoRepeatModeOn = 1; 1374 int AutoRepeatModeDefault = 2; 1375 1376 int LedModeOff = 0; 1377 int LedModeOn = 1; 1378 1379 /* masks for ChangeKeyboardControl */ 1380 int KBKeyClickPercent = (1<<0); 1381 int KBBellPercent = (1<<1); 1382 int KBBellPitch = (1<<2); 1383 int KBBellDuration = (1<<3); 1384 int KBLed = (1<<4); 1385 int KBLedMode = (1<<5); 1386 int KBKey = (1<<6); 1387 int KBAutoRepeatMode = (1<<7); 1388 1389 int MappingSuccess = 0; 1390 int MappingBusy = 1; 1391 int MappingFailed = 2; 1392 1393 int MappingModifier = 0; 1394 int MappingKeyboard = 1; 1395 int MappingPointer = 2; 1396 1397 /***************************************************************** 1398 * SCREEN SAVER STUFF 1399 *****************************************************************/ 1400 1401 int DontPreferBlanking = 0; 1402 int PreferBlanking = 1; 1403 int DefaultBlanking = 2; 1404 1405 int DisableScreenSaver = 0; 1406 int DisableScreenInterval = 0; 1407 1408 int DontAllowExposures = 0; 1409 int AllowExposures = 1; 1410 int DefaultExposures = 2; 1411 1412 /* for ForceScreenSaver */ 1413 int ScreenSaverReset = 0; 1414 int ScreenSaverActive = 1; 1415 1416 /***************************************************************** 1417 * HOSTS AND CONNECTIONS 1418 *****************************************************************/ 1419 1420 /* for ChangeHosts */ 1421 int HostInsert = 0; 1422 int HostDelete = 1; 1423 1424 /* for ChangeAccessControl */ 1425 int EnableAccess = 1; 1426 int DisableAccess = 0; 1427 1428 /* Display classes used in opening the connection 1429 * Note that the statically allocated ones are even numbered and the 1430 * dynamically changeable ones are odd numbered */ 1431 int StaticGray = 0; 1432 int GrayScale = 1; 1433 int StaticColor = 2; 1434 int PseudoColor = 3; 1435 int TrueColor = 4; 1436 int DirectColor = 5; 1437 1438 /* Byte order used in imageByteOrder and bitmapBitOrder */ 1439 int LSBFirst = 0; 1440 int MSBFirst = 1; 1441 1442 1443 1444 /***************************************************************** 1445 * DEFINITIONS OF SPECIFIC EVENTS 1446 *****************************************************************/ 1447 1448 public static class XEvent extends Union { 1449 public int type; 1450 public XAnyEvent xany; 1451 public XKeyEvent xkey; 1452 public XButtonEvent xbutton; 1453 public XMotionEvent xmotion; 1454 public XCrossingEvent xcrossing; 1455 public XFocusChangeEvent xfocus; 1456 public XExposeEvent xexpose; 1457 public XGraphicsExposeEvent xgraphicsexpose; 1458 public XNoExposeEvent xnoexpose; 1459 public XVisibilityEvent xvisibility; 1460 public XCreateWindowEvent xcreatewindow; 1461 public XDestroyWindowEvent xdestroywindow; 1462 public XUnmapEvent xunmap; 1463 public XMapEvent xmap; 1464 public XMapRequestEvent xmaprequest; 1465 public XReparentEvent xreparent; 1466 public XConfigureEvent xconfigure; 1467 public XGravityEvent xgravity; 1468 public XResizeRequestEvent xresizerequest; 1469 public XConfigureRequestEvent xconfigurerequest; 1470 public XCirculateEvent xcirculate; 1471 public XCirculateRequestEvent xcirculaterequest; 1472 public XPropertyEvent xproperty; 1473 public XSelectionClearEvent xselectionclear; 1474 public XSelectionRequestEvent xselectionrequest; 1475 public XSelectionEvent xselection; 1476 public XColormapEvent xcolormap; 1477 public XClientMessageEvent xclient; 1478 public XMappingEvent xmapping; 1479 public XErrorEvent xerror; 1480 public XKeymapEvent xkeymap; 1481 public XGenericEvent xgeneric; 1482 public XGenericEventCookie xcookie; 1483 public NativeLong[] pad = new NativeLong[24]; 1484 } 1485 1486 @FieldOrder({"type", "serial", "send_event", "display", "window"}) 1487 public static class XAnyEvent extends Structure { 1488 public int type; 1489 public NativeLong serial; // # of last request processed by server 1490 public int send_event; // true if this came from a SendEvent request 1491 public Display display; // Display the event was read from 1492 public Window window; // window on which event was requested in event mask 1493 } 1494 1495 @FieldOrder({"type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "state", "keycode", "same_screen"}) 1496 class XKeyEvent extends Structure { 1497 public int type; // of event 1498 public NativeLong serial; // # of last request processed by server 1499 public int send_event; // true if this came from a SendEvent request 1500 public Display display; // public Display the event was read from 1501 public Window window; // "event" window it is reported relative to 1502 public Window root; // root window that the event occurred on 1503 public Window subwindow; // child window 1504 public NativeLong time; // milliseconds 1505 public int x, y; // pointer x, y coordinates in event window 1506 public int x_root, y_root; // coordinates relative to root 1507 public int state; // key or button mask 1508 public int keycode; // detail 1509 public int same_screen; // same screen flag 1510 } 1511 1512 @FieldOrder({"type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "state", "button", "same_screen"}) 1513 class XButtonEvent extends Structure { 1514 public int type; // of event 1515 public NativeLong serial; // # of last request processed by server 1516 public int send_event; // true if this came from a SendEvent request 1517 public Display display; // Display the event was read from 1518 public Window window; // "event" window it is reported relative to 1519 public Window root; // root window that the event occurred on 1520 public Window subwindow; // child window 1521 public NativeLong time; // milliseconds 1522 public int x, y; // pointer x, y coordinates in event window 1523 public int x_root, y_root; // coordinates relative to root 1524 public int state; // key or button mask 1525 public int button; // detail 1526 public int same_screen; // same screen flag 1527 } 1528 1529 class XButtonPressedEvent extends XButtonEvent { 1530 } 1531 1532 class XButtonReleasedEvent extends XButtonEvent { 1533 } 1534 1535 @FieldOrder({"type", "serial", "send_event", "display", "window", "message_type", "format", "data"}) 1536 public static class XClientMessageEvent extends Structure { 1537 public int type; // ClientMessage 1538 public NativeLong serial; // # of last request processed by server 1539 public int send_event; // true if this came from a SendEvent request 1540 public Display display; // Display the event was read from 1541 public Window window; 1542 public Atom message_type; 1543 public int format; 1544 public Data data; 1545 1546 public static class Data extends Union { 1547 public byte b[] = new byte[20]; 1548 public short s[] = new short[10]; 1549 public NativeLong[] l = new NativeLong[5]; 1550 } 1551 } 1552 1553 @FieldOrder({"type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "state", "is_hint", "same_screen"}) 1554 class XMotionEvent extends Structure { 1555 public int type; // of event 1556 public NativeLong serial; // # of last request processed by server 1557 public int send_event; // true if this came from a SendEvent request 1558 public Display display; // Display the event was read from 1559 public Window window; // "event" window reported relative to 1560 public Window root; // root window that the event occurred on 1561 public Window subwindow; // child window 1562 public NativeLong time; // milliseconds 1563 public int x, y; // pointer x, y coordinates in event window 1564 public int x_root, y_root; // coordinates relative to root 1565 public int state; // key or button mask 1566 public byte is_hint; // detail 1567 public int same_screen; // same screen flag 1568 } 1569 1570 class XPointerMovedEvent extends XMotionEvent { 1571 } 1572 1573 @FieldOrder({"type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "mode", "detail", "same_screen", "focus", "state"}) 1574 class XCrossingEvent extends Structure { 1575 public int type; // of event 1576 public NativeLong serial; // # of last request processed by server 1577 public int send_event; // true if this came from a SendEvent request 1578 public Display display; // Display the event was read from 1579 public Window window; // "event" window reported relative to 1580 public Window root; // root window that the event occurred on 1581 public Window subwindow; // child window 1582 public NativeLong time; // milliseconds 1583 public int x, y; // pointer x, y coordinates in event window 1584 public int x_root, y_root; // coordinates relative to root 1585 public int mode; // NotifyNormal, NotifyGrab, NotifyUngrab 1586 public int detail; 1587 /* 1588 * NotifyAncestor, NotifyVirtual, NotifyInferior, 1589 * NotifyNonlinear,NotifyNonlinearVirtual 1590 */ 1591 public int same_screen; // same screen flag 1592 public int focus; // boolean focus 1593 public int state; // key or button mask 1594 } 1595 1596 class XEnterWindowEvent extends XCrossingEvent { 1597 } 1598 1599 class XLeaveWindowEvent extends XCrossingEvent { 1600 } 1601 1602 @FieldOrder({"type", "serial", "send_event", "display", "window", "mode", "detail"}) 1603 class XFocusChangeEvent extends Structure { 1604 public int type; // FocusIn or FocusOut 1605 public NativeLong serial; // # of last request processed by server 1606 public int send_event; // true if this came from a SendEvent request 1607 public Display display; // Display the event was read from 1608 public Window window; // window of event 1609 public int mode; // NotifyNormal, NotifyWhileGrabbed, NotifyGrab, NotifyUngrab 1610 public int detail; 1611 /* 1612 * NotifyAncestor, NotifyVirtual, NotifyInferior, 1613 * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer, 1614 * NotifyPointerRoot, NotifyDetailNone 1615 */ 1616 } 1617 1618 class XFocusInEvent extends XFocusChangeEvent { 1619 } 1620 1621 class XFocusOutEvent extends XFocusChangeEvent { 1622 } 1623 1624 @FieldOrder({"type", "serial", "send_event", "display", "window", "x", "y", "width", "height", "count"}) 1625 class XExposeEvent extends Structure { 1626 public int type; 1627 public NativeLong serial; // # of last request processed by server 1628 public int send_event; // true if this came from a SendEvent request 1629 public Display display; // Display the event was read from 1630 public Window window; 1631 public int x, y; 1632 public int width, height; 1633 public int count; // if non-zero, at least this many more 1634 } 1635 1636 @FieldOrder({"type", "serial", "send_event", "display", "drawable", "x", "y", "width", "height", "count", "major_code", "minor_code"}) 1637 class XGraphicsExposeEvent extends Structure { 1638 public int type; 1639 public NativeLong serial; // # of last request processed by server 1640 public int send_event; // true if this came from a SendEvent request 1641 public Display display; // Display the event was read from 1642 public Drawable drawable; 1643 public int x, y; 1644 public int width, height; 1645 public int count; // if non-zero, at least this many more 1646 public int major_code; // core is CopyArea or CopyPlane 1647 public int minor_code; // not defined in the core 1648 } 1649 1650 @FieldOrder({"type", "serial", "send_event", "display", "drawable", "major_code", "minor_code"}) 1651 class XNoExposeEvent extends Structure { 1652 public int type; 1653 public NativeLong serial; // # of last request processed by server 1654 public int send_event; // true if this came from a SendEvent request 1655 public Display display; // Display the event was read from 1656 public Drawable drawable; 1657 public int major_code; // core is CopyArea or CopyPlane 1658 public int minor_code; // not defined in the core 1659 } 1660 1661 @FieldOrder({"type", "serial", "send_event", "display", "window", "state"}) 1662 class XVisibilityEvent extends Structure { 1663 public int type; 1664 public NativeLong serial; // # of last request processed by server 1665 public int send_event; // true if this came from a SendEvent request 1666 public Display display; // Display the event was read from 1667 public Window window; 1668 public int state; // Visibility state 1669 } 1670 1671 @FieldOrder({"type", "serial", "send_event", "display", "parent", "window", "x", "y", "width", "height", "border_width", "override_redirect"}) 1672 class XCreateWindowEvent extends Structure { 1673 public int type; 1674 public NativeLong serial; // # of last request processed by server 1675 public int send_event; // true if this came from a SendEvent request 1676 public Display display; // Display the event was read from 1677 public Window parent; // parent of the window 1678 public Window window; // window id of window created 1679 public int x, y; // window location 1680 public int width, height; // size of window 1681 public int border_width; // border width 1682 public int override_redirect; // creation should be overridden 1683 } 1684 1685 @FieldOrder({"type", "serial", "send_event", "display", "event", "window"}) 1686 class XDestroyWindowEvent extends Structure { 1687 public int type; 1688 public NativeLong serial; // # of last request processed by server 1689 public int send_event; // true if this came from a SendEvent request 1690 public Display display; // Display the event was read from 1691 public Window event; 1692 public Window window; 1693 } 1694 1695 @FieldOrder({"type", "serial", "send_event", "display", "event", "window", "from_configure"}) 1696 class XUnmapEvent extends Structure { 1697 public int type; 1698 public NativeLong serial; // # of last request processed by server 1699 public int send_event; // true if this came from a SendEvent request 1700 public Display display; // Display the event was read from 1701 public Window event; 1702 public Window window; 1703 public int from_configure; 1704 } 1705 1706 @FieldOrder({"type", "serial", "send_event", "display", "event", "window", "override_redirect"}) 1707 class XMapEvent extends Structure { 1708 public int type; 1709 public NativeLong serial; // # of last request processed by server 1710 public int send_event; // true if this came from a SendEvent request 1711 public Display display; // Display the event was read from 1712 public Window event; 1713 public Window window; 1714 public int override_redirect; // boolean, is override set... 1715 } 1716 1717 @FieldOrder({"type", "serial", "send_event", "display", "parent", "window"}) 1718 class XMapRequestEvent extends Structure { 1719 public int type; 1720 public NativeLong serial; // # of last request processed by server 1721 public int send_event; // true if this came from a SendEvent request 1722 public Display display; // Display the event was read from 1723 public Window parent; 1724 public Window window; 1725 } 1726 1727 @FieldOrder({"type", "serial", "send_event", "display", "event", "window", "parent", "x", "y", "override_redirect"}) 1728 class XReparentEvent extends Structure { 1729 public int type; 1730 public NativeLong serial; // # of last request processed by server 1731 public int send_event; // true if this came from a SendEvent request 1732 public Display display; // Display the event was read from 1733 public Window event; 1734 public Window window; 1735 public Window parent; 1736 public int x, y; 1737 public int override_redirect; 1738 } 1739 1740 @FieldOrder({"type", "serial", "send_event", "display", "event", "window", "x", "y", "width", "height", "border_width", "above", "override_redirect"}) 1741 class XConfigureEvent extends Structure { 1742 public int type; 1743 public NativeLong serial; // # of last request processed by server 1744 public int send_event; // true if this came from a SendEvent request 1745 public Display display; // Display the event was read from 1746 public Window event; 1747 public Window window; 1748 public int x, y; 1749 public int width, height; 1750 public int border_width; 1751 public Window above; 1752 public int override_redirect; 1753 } 1754 1755 @FieldOrder({"type", "serial", "send_event", "display", "event", "window", "x", "y"}) 1756 class XGravityEvent extends Structure { 1757 public int type; 1758 public NativeLong serial; // # of last request processed by server 1759 public int send_event; // true if this came from a SendEvent request 1760 public Display display; // Display the event was read from 1761 public Window event; 1762 public Window window; 1763 public int x, y; 1764 } 1765 1766 @FieldOrder({"type", "serial", "send_event", "display", "window", "width", "height"}) 1767 class XResizeRequestEvent extends Structure { 1768 public int type; 1769 public NativeLong serial; // # of last request processed by server 1770 public int send_event; // true if this came from a SendEvent request 1771 public Display display; // Display the event was read from 1772 public Window window; 1773 public int width, height; 1774 } 1775 1776 @FieldOrder({"type", "serial", "send_event", "display", "parent", "window", "x", "y", "width", "height", "border_width", "above", "detail", "value_mask"}) 1777 class XConfigureRequestEvent extends Structure { 1778 public int type; 1779 public NativeLong serial; // # of last request processed by server 1780 public int send_event; // true if this came from a SendEvent request 1781 public Display display; // Display the event was read from 1782 public Window parent; 1783 public Window window; 1784 public int x, y; 1785 public int width, height; 1786 public int border_width; 1787 public Window above; 1788 public int detail; // Above, Below, TopIf, BottomIf, Opposite 1789 public NativeLong value_mask; 1790 } 1791 1792 @FieldOrder({"type", "serial", "send_event", "display", "event", "window", "place"}) 1793 class XCirculateEvent extends Structure { 1794 public int type; 1795 public NativeLong serial; // # of last request processed by server 1796 public int send_event; // true if this came from a SendEvent request 1797 public Display display; // Display the event was read from 1798 public Window event; 1799 public Window window; 1800 public int place; // PlaceOnTop, PlaceOnBottom 1801 } 1802 1803 @FieldOrder({"type", "serial", "send_event", "display", "parent", "window", "place"}) 1804 class XCirculateRequestEvent extends Structure { 1805 public int type; 1806 public NativeLong serial; // # of last request processed by server 1807 public int send_event; // true if this came from a SendEvent request 1808 public Display display; // Display the event was read from 1809 public Window parent; 1810 public Window window; 1811 public int place; // PlaceOnTop, PlaceOnBottom 1812 } 1813 1814 @FieldOrder({"type", "serial", "send_event", "display", "window", "atom", "time", "state"}) 1815 class XPropertyEvent extends Structure { 1816 public int type; 1817 public NativeLong serial; // # of last request processed by server 1818 public int send_event; // true if this came from a SendEvent request 1819 public Display display; // Display the event was read from 1820 public Window window; 1821 public Atom atom; 1822 public NativeLong time; 1823 public int state; // NewValue, Deleted 1824 } 1825 1826 @FieldOrder({"type", "serial", "send_event", "display", "window", "selection", "time"}) 1827 class XSelectionClearEvent extends Structure { 1828 public int type; 1829 public NativeLong serial; // # of last request processed by server 1830 public int send_event; // true if this came from a SendEvent request 1831 public Display display; // Display the event was read from 1832 public Window window; 1833 public Atom selection; 1834 public NativeLong time; 1835 } 1836 1837 @FieldOrder({"type", "serial", "send_event", "display", "owner", "requestor", "selection", "target", "property", "time"}) 1838 class XSelectionRequestEvent extends Structure { 1839 public int type; 1840 public NativeLong serial; // # of last request processed by server 1841 public int send_event; // true if this came from a SendEvent request 1842 public Display display; // Display the event was read from 1843 public Window owner; 1844 public Window requestor; 1845 public Atom selection; 1846 public Atom target; 1847 public Atom property; 1848 public NativeLong time; 1849 } 1850 1851 @FieldOrder({"type", "serial", "send_event", "display", "requestor", "selection", "target", "property", "time"}) 1852 class XSelectionEvent extends Structure { 1853 public int type; 1854 public NativeLong serial; // # of last request processed by server 1855 public int send_event; // true if this came from a SendEvent request 1856 public Display display; // Display the event was read from 1857 public Window requestor; 1858 public Atom selection; 1859 public Atom target; 1860 public Atom property; // ATOM or None 1861 public NativeLong time; 1862 } 1863 1864 @FieldOrder({"type", "serial", "send_event", "display", "window", "colormap", "c_new", "state" }) 1865 class XColormapEvent extends Structure { 1866 public int type; 1867 public NativeLong serial; // # of last request processed by server 1868 public int send_event; // true if this came from a SendEvent request 1869 public Display display; // Display the event was read from 1870 public Window window; 1871 public Colormap colormap; // COLORMAP or None 1872 public int c_new; // C++ 1873 public int state; // ColormapInstalled, ColormapUninstalled 1874 } 1875 1876 @FieldOrder({"type", "serial", "send_event", "display", "window", "request", "first_keycode", "count"}) 1877 class XMappingEvent extends Structure { 1878 public int type; 1879 public NativeLong serial; // # of last request processed by server 1880 public int send_event; // true if this came from a SendEvent request 1881 public Display display; // Display the event was read from 1882 public Window window; // unused 1883 public int request; // one of MappingModifier, MappingKeyboard, MappingPointer 1884 public int first_keycode; // first keycode 1885 public int count; // defines range of change w. first_keycode*/ 1886 } 1887 1888 @FieldOrder({"type", "display", "serial", "error_code", "request_code", "minor_code", "resourceid"}) 1889 class XErrorEvent extends Structure { 1890 public int type; 1891 public Display display; // Display the event was read from 1892 public NativeLong serial; // serial number of failed request 1893 public byte error_code; // error code of failed request 1894 public byte request_code; // Major op-code of failed request 1895 public byte minor_code; // Minor op-code of failed request 1896 public XID resourceid; // resource id 1897 } 1898 1899 // generated on EnterWindow and FocusIn when KeyMapState selected 1900 @FieldOrder({"type", "serial", "send_event", "display", "window", "key_vector"}) 1901 class XKeymapEvent extends Structure { 1902 public int type; 1903 public NativeLong serial; // # of last request processed by server 1904 public int send_event; // true if this came from a SendEvent request 1905 public Display display; // Display the event was read from 1906 public Window window; 1907 public byte key_vector[] = new byte[32]; 1908 } 1909 1910 /** 1911 * This event is the standard event for all newer extensions. 1912 */ 1913 @FieldOrder({"type", "serial", "send_event", "display", "extension", "evtype"}) 1914 class XGenericEvent extends Structure { 1915 public int type; // of event. Always GenericEvent 1916 public NativeLong serial; // # of last request processed by server 1917 public int send_event; // true if this came from a SendEvent request 1918 public Display display; // Display the event was read from 1919 public int extension; // major opcode of extension that caused the event 1920 public int evtype; // actual event type 1921 } 1922 1923 @FieldOrder({"type", "serial", "send_event", "display", "extension", "evtype", "cookie", "data"}) 1924 class XGenericEventCookie extends Structure { 1925 public int type; // of event. Always GenericEvent 1926 public NativeLong serial; // # of last request processed by server 1927 public int send_event; // true if this came from a SendEvent request 1928 public Display display; // Display the event was read from 1929 public int extension; // major opcode of extension that caused the event 1930 public int evtype; // actual event type 1931 public int cookie; 1932 public Pointer data; 1933 } 1934 XSelectInput(Display display, Window window, NativeLong eventMask)1935 int XSelectInput(Display display, Window window, NativeLong eventMask); XSendEvent(Display display, Window w, int propagate, NativeLong event_mask, XEvent event_send)1936 int XSendEvent(Display display, Window w, int propagate, NativeLong event_mask, XEvent event_send); 1937 XNextEvent(Display display, XEvent event_return)1938 int XNextEvent(Display display, XEvent event_return); 1939 XPeekEvent(Display display, XEvent event_return)1940 int XPeekEvent(Display display, XEvent event_return); XWindowEvent(Display display, Window w, NativeLong event_mask, XEvent event_return)1941 int XWindowEvent(Display display, Window w, NativeLong event_mask, XEvent event_return); XCheckWindowEvent(Display display, Window w, NativeLong event_mask, XEvent event_return)1942 boolean XCheckWindowEvent(Display display, Window w, NativeLong event_mask, XEvent event_return); XMaskEvent(Display display, NativeLong event_mask, XEvent event_return)1943 int XMaskEvent(Display display, NativeLong event_mask, XEvent event_return); XCheckMaskEvent(Display display, NativeLong event_mask, XEvent event_return)1944 boolean XCheckMaskEvent(Display display, NativeLong event_mask, XEvent event_return); XCheckTypedEvent(Display display, int event_type, XEvent event_return)1945 boolean XCheckTypedEvent(Display display, int event_type, XEvent event_return); XCheckTypedWindowEvent(Display display, Window w, int event_type, XEvent event_return)1946 boolean XCheckTypedWindowEvent(Display display, Window w, int event_type, XEvent event_return); 1947 XGetEventData(Display display, XGenericEventCookie cookie)1948 boolean XGetEventData(Display display, XGenericEventCookie cookie); XFreeEventData(Display display, XGenericEventCookie cookie)1949 void XFreeEventData(Display display, XGenericEventCookie cookie); 1950 1951 /** Returns an {@link XWMHints} which must be freed by {@link #XFree}. 1952 * @param display target Display 1953 * @param window target Window 1954 * @return XWMHints structure for the requested window 1955 */ XGetWMHints(Display display, Window window)1956 XWMHints XGetWMHints(Display display, Window window); XGetWMName(Display display, Window window, XTextProperty text_property_return)1957 int XGetWMName(Display display, Window window, 1958 XTextProperty text_property_return); 1959 /** Returns an array of {@link XVisualInfo} which must be freed by {@link #XFree}. 1960 * Use {@link XVisualInfo#toArray(int) 1961 * toArray(nitems_return.getValue()} to obtain the array. 1962 * @param display target Display 1963 * @param vinfo_mask mask of data to retrieve 1964 * @param vinfo_template template struct to use as basis for returned data 1965 * @param nitems_return number size of returned array 1966 * @return returned array 1967 */ XGetVisualInfo(Display display, NativeLong vinfo_mask, XVisualInfo vinfo_template, IntByReference nitems_return)1968 XVisualInfo XGetVisualInfo(Display display, NativeLong vinfo_mask, 1969 XVisualInfo vinfo_template, 1970 IntByReference nitems_return); XCreateColormap(Display display, Window w, Visual visual, int alloc)1971 Colormap XCreateColormap(Display display, Window w, Visual visual, int alloc); XGetWindowProperty(Display display, Window w, Atom property, NativeLong long_offset, NativeLong long_length, boolean delete, Atom reg_type, AtomByReference actual_type_return, IntByReference actual_format_return, NativeLongByReference nitems_return, NativeLongByReference bytes_after_return, PointerByReference prop_return)1972 int XGetWindowProperty(Display display, Window w, Atom property, 1973 NativeLong long_offset, 1974 NativeLong long_length, boolean delete, 1975 Atom reg_type, 1976 AtomByReference actual_type_return, 1977 IntByReference actual_format_return, 1978 NativeLongByReference nitems_return, 1979 NativeLongByReference bytes_after_return, 1980 PointerByReference prop_return); XChangeProperty(Display display, Window w, Atom property, Atom type, int format, int mode, Pointer data, int nelements)1981 int XChangeProperty(Display display, Window w, Atom property, Atom type, 1982 int format, int mode, Pointer data, int nelements); XDeleteProperty(Display display, Window w, Atom property)1983 int XDeleteProperty(Display display, Window w, Atom property); 1984 // Atom XInternAtom(Display *display, char *atom_name, Bool only_if_exists); XInternAtom(Display display, String name, boolean only_if_exists)1985 Atom XInternAtom(Display display, String name, boolean only_if_exists); 1986 // char *XGetAtomName(Display *display, Atom atom); XGetAtomName(Display display, Atom atom)1987 String XGetAtomName(Display display, Atom atom); XCopyArea(Display dpy, Drawable src, Drawable dst, GC gc, int src_x, int src_y, int w, int h, int dst_x, int dst_y)1988 int XCopyArea(Display dpy, Drawable src, Drawable dst, GC gc, 1989 int src_x, int src_y, int w, int h, int dst_x, int dst_y); 1990 XCreateImage(Display dpy, Visual visual, int depth, int format, int offset, Pointer data, int width, int height, int bitmap_pad, int bytes_per_line)1991 XImage XCreateImage(Display dpy, Visual visual, int depth, int format, 1992 int offset, Pointer data, int width, int height, 1993 int bitmap_pad, int bytes_per_line); XPutImage(Display dpy, Drawable d, GC gc, XImage image, int src_x, int src_y, int dest_x, int dest_y, int width, int height)1994 int XPutImage(Display dpy, Drawable d, GC gc, XImage image, 1995 int src_x, int src_y, int dest_x, int dest_y, 1996 int width, int height); XDestroyImage(XImage image)1997 int XDestroyImage(XImage image); 1998 1999 /** 2000 * Installs an error handler 2001 * 2002 * @param handler Specifies the program's supplied error handler 2003 * @return The previous error handler 2004 */ XSetErrorHandler(XErrorHandler handler)2005 XErrorHandler XSetErrorHandler(XErrorHandler handler); 2006 2007 public interface XErrorHandler extends Callback { apply(Display display, XErrorEvent errorEvent)2008 public int apply(Display display, XErrorEvent errorEvent); 2009 } 2010 2011 2012 /* 2013 * KeySyms, Keycodes, Keymaps 2014 */ 2015 XKeysymToString(KeySym keysym)2016 String XKeysymToString(KeySym keysym); XStringToKeysym(String string)2017 KeySym XStringToKeysym(String string); XKeysymToKeycode(Display display, KeySym keysym)2018 byte XKeysymToKeycode(Display display, KeySym keysym); XKeycodeToKeysym(Display display, byte keycode, int index)2019 KeySym XKeycodeToKeysym(Display display, byte keycode, int index); 2020 2021 /** 2022 * Establishes a passive grab on the keyboard 2023 * 2024 * @param display Specifies the connection to the X server. 2025 * @param keyCode Specifies the KeyCode or {@link #AnyKey}. 2026 * @param modifiers Specifies the set of keymasks or {@link #AnyModifier}. 2027 * The mask is the bitwise inclusive OR of the valid keymask bits. 2028 * @param grab_window Specifies the grab window. 2029 * @param ownerEvents Specifies a Boolean value that indicates whether the keyboard events are to be reported as usual. 2030 * @param pointerMode Specifies further processing of pointer events. You can pass {@link #GrabModeSync} or {@link #GrabModeAsync}. 2031 * @param keyBoardMode Specifies further processing of keyboard events. You can pass {@link #GrabModeSync} or {@link #GrabModeAsync}. 2032 * @return nothing 2033 */ XGrabKey(Display display, int keyCode, int modifiers, Window grab_window, int ownerEvents, int pointerMode, int keyBoardMode)2034 int XGrabKey(Display display, int keyCode, int modifiers, Window grab_window, int ownerEvents, int pointerMode, int keyBoardMode); 2035 2036 /** 2037 * The XUngrabKey() function releases the key combination on the specified window if it was grabbed by this client. 2038 * 2039 * @param display Specifies the connection to the X server. 2040 * @param keyCode Specifies the KeyCode or {@link #AnyKey}. 2041 * @param modifiers Specifies the set of keymasks or {@link #AnyModifier}. 2042 * The mask is the bitwise inclusive OR of the valid keymask bits 2043 * @param grab_window Specifies the grab window. 2044 * @return nothing 2045 */ XUngrabKey(Display display, int keyCode, int modifiers, Window grab_window)2046 int XUngrabKey(Display display, int keyCode, int modifiers, Window grab_window); 2047 2048 /** 2049 * Actively grabs control of the keyboard and generates FocusIn and FocusOut events 2050 * 2051 * @param display Specifies the connection to the X server. 2052 * @param grab_window Specifies the grab window. 2053 * @param owner_events Specifies a Boolean value that indicates whether the keyboard events are to be reported as usual. 2054 * @param pointer_mode Specifies further processing of pointer events. You can pass GrabModeSync or GrabModeAsync. 2055 * @param keyboard_mode Specifies further processing of keyboard events. You can pass GrabModeSync or GrabModeAsync. 2056 * @param time Specifies the time. You can pass either a timestamp or CurrentTime. 2057 * @return nothing 2058 */ XGrabKeyboard(Display display, Window grab_window, int owner_events, int pointer_mode, int keyboard_mode, NativeLong time)2059 int XGrabKeyboard(Display display, Window grab_window, int owner_events, int pointer_mode, int keyboard_mode, NativeLong time); 2060 2061 /** 2062 * Releases the keyboard and any queued events if this client has it actively grabbed from either XGrabKeyboard() or XGrabKey(). 2063 * @param display Specifies the connection to the X server. 2064 * @param time Specifies the time. You can pass either a timestamp or CurrentTime. 2065 * @return nothing 2066 */ XUngrabKeyboard(Display display, NativeLong time)2067 int XUngrabKeyboard(Display display, NativeLong time); 2068 2069 /** 2070 * The XFetchName() function returns the name of the specified window. If it succeeds, it returns a nonzero status; 2071 * otherwise, no name has been set for the window, and it returns zero. If the WM_NAME property has not been set for this 2072 * window, XFetchName() sets window_name_return to NULL. If the data returned by the server is in the Latin Portable Character 2073 * Encoding, then the returned string is in the Host Portable Character Encoding. Otherwise, the result is implementation 2074 * dependent. When finished with it, a client must free the window name string using XFree(). 2075 * @param display Specifies the connection to the X server. 2076 * @param window Specifies the window. 2077 * @param window_name_return Returns the window name, which is a null-terminated string. 2078 * @return Integer. Nonzero = success, zero = no name has been set. 2079 */ XFetchName(Display display, Window window, PointerByReference window_name_return)2080 int XFetchName(Display display, Window window, PointerByReference window_name_return); 2081 2082 //int XChangeKeyboardMapping(Display display, int first_keycode, int keysyms_per_keycode, KeySym *keysyms, int num_codes); 2083 /** Defines the symbols for the specified number of KeyCodes starting with 2084 * first_keycode. The symbols for KeyCodes outside this range remain 2085 * unchanged. The number of elements in keysyms must be: num_codes * 2086 * keysyms_per_keycode. The specified first_keycode must be greater than 2087 * or equal to min_keycode returned by XDisplayKeycodes, or a BadValue 2088 * error results. In addition, the following expression must be less than 2089 * or equal to max_keycode as returned by XDisplayKeycodes, or a BadValue 2090 * error results: first_keycode + num_codes - 1. 2091 * @param display target Display 2092 * @param first_keycode first keycode 2093 * @param keysyms_per_keycode number of syms per keycode 2094 * @param keysyms array of KeySym 2095 * @param num_codes number of keycodes to be changed 2096 * @return status 2097 */ XChangeKeyboardMapping(Display display, int first_keycode, int keysyms_per_keycode, KeySym[] keysyms, int num_codes)2098 int XChangeKeyboardMapping(Display display, int first_keycode, int keysyms_per_keycode, KeySym[] keysyms, int num_codes); 2099 /** Returns the symbols for the specified number of KeyCodes starting with 2100 * first_keycode. The value specified in first_keycode must be greater 2101 * than or equal to min_keycode as returned by XDisplayKeycodes, or a 2102 * BadValue error results. In addition, the following expression must be 2103 * less than or equal to max_keycode as returned by XDisplayKeycodes: 2104 * first_keycode + keycode_count - 1. If this is not the case, a BadValue 2105 * error results. The number of elements in the KeySyms list is: 2106 * keycode_count * keysyms_per_keycode_return. KeySym number N, counting 2107 * from zero, for KeyCode K has the following index in the list, counting 2108 * from zero: (K - first_code) * keysyms_per_code_return + N. The X server 2109 * arbitrarily chooses the keysyms_per_keycode_return value to be large 2110 * enough to report all requested symbols. A special KeySym value of 2111 * NoSymbol is used to fill in unused elements for individual KeyCodes. To 2112 * free the storage returned by XGetKeyboardMapping, use XFree. 2113 * @param display target Display 2114 * @param first_keycode first keycode to be changed or returned 2115 * @param keycode_count how many 2116 * @param keysyms_per_keycode_return number of syms per keycode 2117 * @return KeySym for the requested code 2118 */ XGetKeyboardMapping(Display display, byte first_keycode, int keycode_count, IntByReference keysyms_per_keycode_return)2119 KeySym XGetKeyboardMapping(Display display, byte first_keycode, int keycode_count, IntByReference keysyms_per_keycode_return); 2120 /** Returns the min-keycodes and max-keycodes supported by the specified 2121 * display. The minimum number of KeyCodes returned is never less than 8, 2122 * and the maximum number of KeyCodes returned is never greater than 2123 * 255. Not all KeyCodes in this range are required to have corresponding 2124 * keys. 2125 * @param display target Display 2126 * @param min_keycodes_return smallest keycode 2127 * @param max_keycodes_return largest keycode 2128 * @return status 2129 */ XDisplayKeycodes(Display display, IntByReference min_keycodes_return, IntByReference max_keycodes_return)2130 int XDisplayKeycodes(Display display, IntByReference min_keycodes_return, IntByReference max_keycodes_return); 2131 /** Specifies the KeyCodes of the keys (if any) that are to be used as 2132 * modifiers. If it succeeds, the X server generates a MappingNotify 2133 * event, and XSetModifierMapping returns MappingSuccess. X permits at 2134 * most 8 modifier keys. If more than 8 are specified in the 2135 * XModifierKeymap structure, a BadLength error results. 2136 * @param display target Display 2137 * @param modmap modifier specification 2138 * @return status 2139 */ XSetModifierMapping(Display display, XModifierKeymapRef modmap)2140 int XSetModifierMapping(Display display, XModifierKeymapRef modmap); 2141 /** The XGetModifierMapping function returns a pointer to a newly created 2142 * XModifierKeymap structure that contains the keys being used as 2143 * modifiers. The structure should be freed after use by calling 2144 * XFreeModifiermap. If only zero values appear in the set for any 2145 * modifier, that modifier is disabled. 2146 * @param display target Display 2147 * @return modifier specification 2148 */ XGetModifierMapping(Display display)2149 XModifierKeymapRef XGetModifierMapping(Display display); 2150 /** Returns a pointer to XModifierKeymap structure for later use. 2151 * @param max_keys_per_mod number of keys to include in the mapping 2152 * @return modifier specification struct 2153 */ XNewModifiermap(int max_keys_per_mod)2154 XModifierKeymapRef XNewModifiermap(int max_keys_per_mod); 2155 /** Adds the specified KeyCode to the set that controls the specified 2156 * modifier and returns the resulting XModifierKeymap structure (expanded 2157 * as needed). 2158 * @param modmap modifier map 2159 * @param keycode_entry keycode entry 2160 * @param modifier modifier 2161 * @return modifier specification struct 2162 */ XInsertModifiermapEntry(XModifierKeymapRef modmap, byte keycode_entry, int modifier)2163 XModifierKeymapRef XInsertModifiermapEntry(XModifierKeymapRef modmap, byte keycode_entry, int modifier); 2164 /** Deletes the specified KeyCode from the set that controls the specified 2165 * modifier and returns a pointer to the resulting XModifierKeymap 2166 * structure. 2167 * @param modmap modifier map 2168 * @param keycode_entry keycode entry 2169 * @param modifier modifier 2170 * @return modifier specification struct 2171 */ XDeleteModifiermapEntry(XModifierKeymapRef modmap, byte keycode_entry, int modifier)2172 XModifierKeymapRef XDeleteModifiermapEntry(XModifierKeymapRef modmap, byte keycode_entry, int modifier); 2173 /** Frees the specified XModifierKeymap structure. 2174 * @param modmap modifier map to be freed 2175 * @return status 2176 */ XFreeModifiermap(XModifierKeymapRef modmap)2177 int XFreeModifiermap(XModifierKeymapRef modmap); 2178 2179 2180 /** Changes the keyboard control state. 2181 * @param display display 2182 * @param value_mask disjunction of KBKeyClickPercent, KBBellPercent, KBBellPitch, KBBellDuration, KBLed, KBLedMode, KBKey, KBAutoRepeatMode 2183 * @param values control ref values 2184 * @return status 2185 */ XChangeKeyboardControl(Display display, NativeLong value_mask, XKeyboardControlRef values)2186 int XChangeKeyboardControl(Display display, NativeLong value_mask, XKeyboardControlRef values); 2187 /** Returns the current control values for the keyboard to the 2188 * XKeyboardState structure. 2189 * @param display display 2190 * @param values_return keyboard state structure 2191 * @return status 2192 */ XGetKeyboardControl(Display display, XKeyboardStateRef values_return)2193 int XGetKeyboardControl(Display display, XKeyboardStateRef values_return); 2194 /** Turns on auto-repeat for the keyboard on the specified display. 2195 * @param display display 2196 * @return status 2197 */ XAutoRepeatOn(Display display)2198 int XAutoRepeatOn(Display display); 2199 /** Turns off auto-repeat for the keyboard on the specified display. 2200 * @param display display 2201 * @return status 2202 */ XAutoRepeatOff(Display display)2203 int XAutoRepeatOff(Display display); 2204 /** Rings the bell on the keyboard on the specified display, if 2205 * possible. The specified volume is relative to the base volume for the 2206 * keyboard. If the value for the percent argument is not in the range 2207 * -100 to 100 inclusive, a BadValue error results. The volume at which 2208 * the bell rings when the percent argument is nonnegative is: base - 2209 * [(base * percent) / 100] + percent. The volume at which the bell rings 2210 * when the percent argument is negative is: base + [(base * percent) / 2211 * 100]. To change the base volume of the bell, use 2212 * XChangeKeyboardControl. 2213 * @param display display 2214 * @param percent value to set 2215 * @return status 2216 */ XBell(Display display, int percent)2217 int XBell(Display display, int percent); 2218 /** Returns a bit vector for the logical state of the keyboard, where each 2219 * bit set to 1 indicates that the corresponding key is currently pressed 2220 * down. The vector is represented as 32 bytes. Byte N (from 0) contains 2221 * the bits for keys 8N to 8N + 7 with the least significant bit in the 2222 * byte representing key 8N. Note that the logical state of a device (as 2223 * seen by client applications) may lag the physical state if device event 2224 * processing is frozen. 2225 * @param display display 2226 * @param keys_return keymap 2227 * @return status 2228 */ XQueryKeymap(Display display, byte[] keys_return)2229 int XQueryKeymap(Display display, byte[] keys_return); 2230 2231 /** The modifiermap member of the XModifierKeymap structure contains 8 2232 * sets of max_keypermod KeyCodes, one for each modifier in the order 2233 * Shift, Lock, Control, Mod1, Mod2, Mod3, Mod4, and Mod5. Only nonzero 2234 * KeyCodes have meaning in each set, and zero KeyCodes are ignored. In 2235 * addition, all of the nonzero KeyCodes must be in the range specified by 2236 * min_keycode and max_keycode in the Display structure, or a BadValue 2237 * error results. 2238 */ 2239 @FieldOrder({"max_keypermod", "modifiermap"}) 2240 class XModifierKeymapRef extends Structure implements Structure.ByReference{ 2241 public int max_keypermod; /* The server's max # of keys per modifier */ 2242 public Pointer modifiermap; /* An 8 by max_keypermod array of modifiers */ 2243 } 2244 2245 @FieldOrder({"key_click_percent", "bell_percent", "bell_pitch", "bell_duration", "led", "led_mode", "key", "auto_repeat_mode"}) 2246 class XKeyboardControlRef extends Structure implements Structure.ByReference { 2247 /** Volume for key clicks between 0 (off) and 100 (loud) inclusive, if possible. A setting of -1 restores the default. */ 2248 public int key_click_percent; 2249 /** Base volume for the bell between 0 (off) and 100 (loud) inclusive, if possible. A setting of -1 restores the default. */ 2250 public int bell_percent; 2251 /** Pitch (specified in Hz) of the bell, if possible. A setting of -1 restores the default. */ 2252 public int bell_pitch; 2253 /** Duration of the bell specified in milliseconds, if possible. A setting of -1 restores the default. */ 2254 public int bell_duration; 2255 /** State of the LEDs. At most 32 LEDs numbered from one are supported. */ 2256 public int led; 2257 /** LED mode: LedModeOn or LedModeOff. */ 2258 public int led_mode; 2259 /** <code>auto_repeat_mode</code> can change the auto repeat settings of this key. */ 2260 public int key; 2261 /** AutoRepeatModeOff, AutoRepeatModeOn, AutoRepeatModeDefault. */ 2262 public int auto_repeat_mode; 2263 2264 @Override toString()2265 public String toString() { 2266 return "XKeyboardControlByReference{" + 2267 "key_click_percent=" + key_click_percent + 2268 ", bell_percent=" + bell_percent + 2269 ", bell_pitch=" + bell_pitch + 2270 ", bell_duration=" + bell_duration + 2271 ", led=" + led + 2272 ", led_mode=" + led_mode + 2273 ", key=" + key + 2274 ", auto_repeat_mode=" + auto_repeat_mode + 2275 '}'; 2276 } 2277 } 2278 2279 @FieldOrder({"key_click_percent", "bell_percent", "bell_pitch", "bell_duration", "led_mask", "global_auto_repeat", "auto_repeats"}) 2280 class XKeyboardStateRef extends Structure implements Structure.ByReference { 2281 /** Volume for key clicks between 0 (off) and 100 (loud) inclusive, if possible. */ 2282 public int key_click_percent; 2283 /** Base volume for the bell between 0 (off) and 100 (loud) inclusive, if possible. */ 2284 public int bell_percent; 2285 /** Pitch (specified in Hz) of the bell, if possible. A setting of -1 restores the default. */ 2286 public int bell_pitch; 2287 /** Duration of the bell specified in milliseconds, if possible. A setting of -1 restores the default. */ 2288 public int bell_duration; 2289 /** State of the LEDs. At most 32 LEDs numbered from one are supported. */ 2290 public NativeLong led_mask; 2291 /** Global auto repeat mode: AutoRepeatModeOff or AutoRepeatModeOn. */ 2292 public int global_auto_repeat; 2293 /** Bit vector. Each bit set to 1 indicates that auto-repeat is enabled for the corresponding key. The vector is represented as 32 bytes. Byte N (from 0) contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N. */ 2294 public byte auto_repeats[] = new byte[32]; 2295 2296 @Override toString()2297 public String toString() { 2298 return "XKeyboardStateByReference{" + 2299 "key_click_percent=" + key_click_percent + 2300 ", bell_percent=" + bell_percent + 2301 ", bell_pitch=" + bell_pitch + 2302 ", bell_duration=" + bell_duration + 2303 ", led_mask=" + led_mask + 2304 ", global_auto_repeat=" + global_auto_repeat + 2305 ", auto_repeats=" + auto_repeats + 2306 '}'; 2307 } 2308 } 2309 } 2310