├── .github ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── build.yml │ └── tests.yml ├── .gitignore ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE-MIT ├── Makefile ├── README.md ├── src ├── dpms.rs ├── glx.rs ├── internal.rs ├── keysym.rs ├── sync.rs ├── xcursor.rs ├── xf86vmode.rs ├── xfixes.rs ├── xft.rs ├── xinerama.rs ├── xinput.rs ├── xinput2.rs ├── xlib.rs ├── xlib_xcb.rs ├── xmd.rs ├── xmu.rs ├── xpresent.rs ├── xrandr.rs ├── xrecord.rs ├── xrender.rs ├── xshm.rs ├── xss.rs ├── xt.rs └── xtest.rs ├── x11-dl ├── .gitignore ├── Cargo.toml ├── LICENSE-MIT ├── build.rs ├── examples │ └── hello-world-dl.rs └── src │ ├── dpms.rs │ ├── error.rs │ ├── glx.rs │ ├── internal.rs │ ├── keysym.rs │ ├── lib.rs │ ├── link.rs │ ├── old_xrandr.rs │ ├── sync.rs │ ├── xcursor.rs │ ├── xf86vmode.rs │ ├── xfixes.rs │ ├── xft.rs │ ├── xinerama.rs │ ├── xinput.rs │ ├── xinput2.rs │ ├── xlib.rs │ ├── xlib_xcb.rs │ ├── xmd.rs │ ├── xmu.rs │ ├── xpresent.rs │ ├── xrandr.rs │ ├── xrecord.rs │ ├── xrender.rs │ ├── xshm.rs │ ├── xss.rs │ ├── xt.rs │ └── xtest.rs └── x11 ├── .gitignore ├── Cargo.toml ├── LICENSE-MIT ├── build.rs ├── examples ├── hello-world.rs ├── input.rs └── xrecord.rs └── src ├── dpms.rs ├── glx.rs ├── internal.rs ├── keysym.rs ├── lib.rs ├── link.rs ├── sync.rs ├── xcursor.rs ├── xf86vmode.rs ├── xfixes.rs ├── xft.rs ├── xinerama.rs ├── xinput.rs ├── xinput2.rs ├── xlib.rs ├── xlib_xcb.rs ├── xmd.rs ├── xmu.rs ├── xpresent.rs ├── xrandr.rs ├── xrecord.rs ├── xrender.rs ├── xshm.rs ├── xss.rs ├── xt.rs └── xtest.rs /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | - [ ] Tested on an x11 machine 2 | - [ ] Compilation warnings were addressed 3 | - [ ] `cargo fmt` has been run on this branch 4 | - [ ] `cargo doc` builds successfully 5 | - [ ] Added an entry to `CHANGELOG.md` if knowledge of this change could be valuable to users 6 | - [ ] Updated documentation to reflect any user-facing changes 7 | - [ ] Created or updated an example program if it would help users understand this functionality 8 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Build 19 | run: cargo build --verbose -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Build 20 | run: make build 21 | - name: Run tests 22 | run: make tests 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /Cargo.lock 2 | /target 3 | *.swp 4 | 5 | .idea 6 | .vscode -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [Unreleased] 8 | ### Added 9 | - FAQ Section in README 10 | 11 | ### Changed 12 | 13 | ## [2.21.0] - 2023-01-18 14 | ### Added 15 | 16 | ### Changed 17 | 18 | - Fixed a bug that prevented the `XShm` module from loading. 19 | - Ensured that the linked libraries are cached and only loaded once. 20 | 21 | ## [2.20.1] - 2022-11-24 22 | ### Added 23 | - xfixes feature 24 | 25 | ### Changed 26 | 27 | ## [2.20.0] - 2022-08-09 28 | ### Added 29 | - XServerInterpretedAddress struct 30 | - xpresent module 31 | - sync module 32 | 33 | ### Changed 34 | - Updated pkg-config to 0.3.24 35 | - Correct typos in xshm module 36 | - Make members of xshm-structs public 37 | - Update crate to rust 2021 38 | 39 | ## [2.19.1] - 2021-09-25 40 | ### Added 41 | - This changelog 42 | - _XkbControls struct 43 | - _XkbMods struct 44 | - XkbStateRec type 45 | - PictStandardARGB32 const 46 | - PictStandardRGB24 const 47 | - PictStandardA8 const 48 | - PictStandardA4 const 49 | - PictStandardA1 const 50 | - XShmQueryExtension function 51 | - XShmGetEventBase function 52 | - XshmQueryVersion function 53 | - XShmPixmapFormat function 54 | - XShmAttach function 55 | - XShmDetach function 56 | - XShmPutImage function 57 | - XShmGetImage function 58 | - XShmCreateImage function 59 | - XShmCreatePixMap function 60 | - ShmSeg type 61 | - XShmCompletionEvent struct 62 | - XshmSegmentInfo struct 63 | - All feature 64 | 65 | ### Fixed 66 | - Field order in [_XkbStateRec](https://github.com/freedesktop/xorg-xserver/blob/master/include/xkbstr.h#L47) struct 67 | 68 | [Unreleased]: ../../compare/v2.21.0...HEAD 69 | [2.19.1]: ../../compare/v2.19.0...v2.19.1 70 | [2.20.0]: ../../compare/v2.19.1...v2.20.0 71 | [2.20.1]: ../../compare/v2.20.0...v2.20.1 72 | [2.21.0]: ../../compare/v2.20.1...v2.21.0 73 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = ["x11", "x11-dl"] 3 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | X11_FEATURES=xlib 2 | 3 | all: build-x11 build-x11-dl 4 | 5 | build: build-x11 build-x11-dl 6 | 7 | build-x11: 8 | cd x11 && cargo build --features "${X11_FEATURES}" 9 | 10 | build-x11-dl: 11 | cd x11-dl && cargo build 12 | 13 | tests: tests-x11 tests-x11-dl 14 | 15 | tests-x11: 16 | cd x11 && cargo test 17 | 18 | tests-x11-dl: 19 | cd x11-dl && cargo test 20 | 21 | docs: docs-x11 docs-x11-dl 22 | 23 | docs-x11: 24 | cd x11 && cargo doc --features "${X11_FEATURES}" 25 | 26 | docs-x11-dl: 27 | cd x11-dl && cargo doc 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # x11-rs - X11 library bindings for Rust 2 | 3 | [![Build Status](https://github.com/AltF02/x11-rs/workflows/Build/badge.svg?style=flat-square)](https://github.com/AltF02/x11-rs/actions) 4 | 5 | `x11`: [![](https://img.shields.io/crates/v/x11.svg)](https://crates.io/crates/x11) 6 | 7 | `x11-dl`: [![](https://img.shields.io/crates/v/x11-dl.svg)](https://crates.io/crates/x11-dl) 8 | 9 | ## FAQ: 10 | * What is the difference between `x11` and `x11-dl`? x11 is statically linked, x11-dl is dynamically linked. 11 | * What if I just want to basic calls to `xlib`? This crate provides calls to most x11 api's, if you want to do basic calls, take a look at https://github.com/notgull/tiny-xlib 12 | 13 | ## License 14 | 15 | Licensed under 16 | 17 | * MIT license 18 | ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT) 19 | 20 | for related Discussion with contributors see #82 21 | 22 | 23 | --- 24 | The X11 libraries written in C are available under the terms of the MIT license. 25 | These bindings are available as public domain. 26 | 27 | -------------------------------------------------------------------------------- /src/dpms.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::c_int; 6 | 7 | use super::xlib::{Bool, Display, Status}; 8 | use super::xmd::{BOOL, CARD16}; 9 | 10 | // 11 | // functions 12 | // 13 | 14 | x11_link! { Xext, xext, ["libXext.so.6", "libXext.so"], 9, 15 | pub fn DPMSQueryExtension (_1: *mut Display, _2: *mut c_int, _3: *mut c_int) -> Bool, 16 | pub fn DPMSGetVersion (_1: *mut Display, _2: *mut c_int, _3: *mut c_int) -> Status, 17 | pub fn DPMSCapable (_1: *mut Display) -> Bool, 18 | pub fn DPMSSetTimeouts (_1: *mut Display, _2: CARD16, _3: CARD16, _4: CARD16) -> Status, 19 | pub fn DPMSGetTimeouts (_1: *mut Display, _2: *mut CARD16, _3: *mut CARD16, _4: *mut CARD16) -> Bool, 20 | pub fn DPMSEnable (_1: *mut Display) -> Status, 21 | pub fn DPMSDisable (_1: *mut Display) -> Status, 22 | pub fn DPMSForceLevel (_1: *mut Display, _2: CARD16) -> Status, 23 | pub fn DPMSInfo (_1: *mut Display, _2: *mut CARD16, _3: *mut BOOL) -> Status, 24 | variadic: 25 | globals: 26 | } 27 | 28 | // 29 | // constants 30 | // 31 | 32 | pub const DPMSMajorVersion: c_int = 1; 33 | pub const DPMSMinorVersion: c_int = 1; 34 | 35 | pub const DPMSExtensionName: &str = "DPMS"; 36 | 37 | pub const DPMSModeOn: CARD16 = 0; 38 | pub const DPMSModeStandby: CARD16 = 1; 39 | pub const DPMSModeSuspend: CARD16 = 2; 40 | pub const DPMSModeOff: CARD16 = 3; 41 | -------------------------------------------------------------------------------- /src/glx.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::{c_char, c_int, c_uchar, c_uint, c_ulong}; 6 | 7 | use super::xlib::{Display, XVisualInfo, XID}; 8 | 9 | // 10 | // functions 11 | // 12 | 13 | x11_link! { Glx, gl, ["libGL.so.1", "libGL.so"], 40, 14 | pub fn glXChooseFBConfig (_4: *mut Display, _3: c_int, _2: *const c_int, _1: *mut c_int) -> *mut GLXFBConfig, 15 | pub fn glXChooseVisual (_3: *mut Display, _2: c_int, _1: *mut c_int) -> *mut XVisualInfo, 16 | pub fn glXCopyContext (_4: *mut Display, _3: GLXContext, _2: GLXContext, _1: c_ulong) -> (), 17 | pub fn glXCreateContext (_4: *mut Display, _3: *mut XVisualInfo, _2: GLXContext, _1: c_int) -> GLXContext, 18 | pub fn glXCreateGLXPixmap (_3: *mut Display, _2: *mut XVisualInfo, _1: c_ulong) -> c_ulong, 19 | pub fn glXCreateNewContext (_5: *mut Display, _4: GLXFBConfig, _3: c_int, _2: GLXContext, _1: c_int) -> GLXContext, 20 | pub fn glXCreatePbuffer (_3: *mut Display, _2: GLXFBConfig, _1: *const c_int) -> c_ulong, 21 | pub fn glXCreatePixmap (_4: *mut Display, _3: GLXFBConfig, _2: c_ulong, _1: *const c_int) -> c_ulong, 22 | pub fn glXCreateWindow (_4: *mut Display, _3: GLXFBConfig, _2: c_ulong, _1: *const c_int) -> c_ulong, 23 | pub fn glXDestroyContext (_2: *mut Display, _1: GLXContext) -> (), 24 | pub fn glXDestroyGLXPixmap (_2: *mut Display, _1: c_ulong) -> (), 25 | pub fn glXDestroyPbuffer (_2: *mut Display, _1: c_ulong) -> (), 26 | pub fn glXDestroyPixmap (_2: *mut Display, _1: c_ulong) -> (), 27 | pub fn glXDestroyWindow (_2: *mut Display, _1: c_ulong) -> (), 28 | pub fn glXGetClientString (_2: *mut Display, _1: c_int) -> *const c_char, 29 | pub fn glXGetConfig (_4: *mut Display, _3: *mut XVisualInfo, _2: c_int, _1: *mut c_int) -> c_int, 30 | pub fn glXGetCurrentContext () -> GLXContext, 31 | pub fn glXGetCurrentDisplay () -> *mut Display, 32 | pub fn glXGetCurrentDrawable () -> c_ulong, 33 | pub fn glXGetCurrentReadDrawable () -> c_ulong, 34 | pub fn glXGetFBConfigAttrib (_4: *mut Display, _3: GLXFBConfig, _2: c_int, _1: *mut c_int) -> c_int, 35 | pub fn glXGetFBConfigs (_3: *mut Display, _2: c_int, _1: *mut c_int) -> *mut GLXFBConfig, 36 | pub fn glXGetProcAddress (_1: *const c_uchar) -> Option, 37 | pub fn glXGetProcAddressARB (_1: *const c_uchar) -> Option, 38 | pub fn glXGetSelectedEvent (_3: *mut Display, _2: c_ulong, _1: *mut c_ulong) -> (), 39 | pub fn glXGetVisualFromFBConfig (_2: *mut Display, _1: GLXFBConfig) -> *mut XVisualInfo, 40 | pub fn glXIsDirect (_2: *mut Display, _1: GLXContext) -> c_int, 41 | pub fn glXMakeContextCurrent (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: GLXContext) -> c_int, 42 | pub fn glXMakeCurrent (_3: *mut Display, _2: c_ulong, _1: GLXContext) -> c_int, 43 | pub fn glXQueryContext (_4: *mut Display, _3: GLXContext, _2: c_int, _1: *mut c_int) -> c_int, 44 | pub fn glXQueryDrawable (_4: *mut Display, _3: c_ulong, _2: c_int, _1: *mut c_uint) -> (), 45 | pub fn glXQueryExtension (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, 46 | pub fn glXQueryExtensionsString (_2: *mut Display, _1: c_int) -> *const c_char, 47 | pub fn glXQueryServerString (_3: *mut Display, _2: c_int, _1: c_int) -> *const c_char, 48 | pub fn glXQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, 49 | pub fn glXSelectEvent (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> (), 50 | pub fn glXSwapBuffers (_2: *mut Display, _1: c_ulong) -> (), 51 | pub fn glXUseXFont (_4: c_ulong, _3: c_int, _2: c_int, _1: c_int) -> (), 52 | pub fn glXWaitGL () -> (), 53 | pub fn glXWaitX () -> (), 54 | variadic: 55 | globals: 56 | } 57 | 58 | // 59 | // types 60 | // 61 | 62 | // opaque structures 63 | #[repr(C)] 64 | pub struct __GLXcontextRec; 65 | #[repr(C)] 66 | pub struct __GLXFBConfigRec; 67 | 68 | // types 69 | pub type GLXContext = *mut __GLXcontextRec; 70 | pub type GLXContextID = XID; 71 | pub type GLXDrawable = XID; 72 | pub type GLXFBConfig = *mut __GLXFBConfigRec; 73 | pub type GLXFBConfigID = XID; 74 | pub type GLXPbuffer = XID; 75 | pub type GLXPixmap = XID; 76 | pub type GLXWindow = XID; 77 | 78 | // 79 | // constants 80 | // 81 | 82 | // config caveats 83 | pub const GLX_SLOW_CONFIG: c_int = 0x8001; 84 | pub const GLX_NON_CONFORMANT_CONFIG: c_int = 0x800d; 85 | 86 | // drawable type mask 87 | pub const GLX_WINDOW_BIT: c_int = 0x0001; 88 | pub const GLX_PIXMAP_BIT: c_int = 0x0002; 89 | pub const GLX_PBUFFER_BIT: c_int = 0x0004; 90 | 91 | // framebuffer attributes 92 | pub const GLX_USE_GL: c_int = 0x0001; 93 | pub const GLX_BUFFER_SIZE: c_int = 0x0002; 94 | pub const GLX_LEVEL: c_int = 0x0003; 95 | pub const GLX_RGBA: c_int = 0x0004; 96 | pub const GLX_DOUBLEBUFFER: c_int = 0x0005; 97 | pub const GLX_STEREO: c_int = 0x0006; 98 | pub const GLX_AUX_BUFFERS: c_int = 0x0007; 99 | pub const GLX_RED_SIZE: c_int = 0x0008; 100 | pub const GLX_GREEN_SIZE: c_int = 0x0009; 101 | pub const GLX_BLUE_SIZE: c_int = 0x000a; 102 | pub const GLX_ALPHA_SIZE: c_int = 0x000b; 103 | pub const GLX_DEPTH_SIZE: c_int = 0x000c; 104 | pub const GLX_STENCIL_SIZE: c_int = 0x000d; 105 | pub const GLX_ACCUM_RED_SIZE: c_int = 0x000e; 106 | pub const GLX_ACCUM_GREEN_SIZE: c_int = 0x000f; 107 | pub const GLX_ACCUM_BLUE_SIZE: c_int = 0x0010; 108 | pub const GLX_ACCUM_ALPHA_SIZE: c_int = 0x0011; 109 | pub const GLX_CONFIG_CAVEAT: c_int = 0x0020; 110 | pub const GLX_X_VISUAL_TYPE: c_int = 0x0022; 111 | pub const GLX_TRANSPARENT_TYPE: c_int = 0x0023; 112 | pub const GLX_TRANSPARENT_INDEX_VALUE: c_int = 0x0024; 113 | pub const GLX_TRANSPARENT_RED_VALUE: c_int = 0x0025; 114 | pub const GLX_TRANSPARENT_GREEN_VALUE: c_int = 0x0026; 115 | pub const GLX_TRANSPARENT_BLUE_VALUE: c_int = 0x0027; 116 | pub const GLX_TRANSPARENT_ALPHA_VALUE: c_int = 0x0028; 117 | pub const GLX_VISUAL_ID: c_int = 0x800B; 118 | pub const GLX_SCREEN: c_int = 0x800C; 119 | pub const GLX_DRAWABLE_TYPE: c_int = 0x8010; 120 | pub const GLX_RENDER_TYPE: c_int = 0x8011; 121 | pub const GLX_X_RENDERABLE: c_int = 0x8012; 122 | pub const GLX_FBCONFIG_ID: c_int = 0x8013; 123 | pub const GLX_MAX_PBUFFER_WIDTH: c_int = 0x8016; 124 | pub const GLX_MAX_PBUFFER_HEIGHT: c_int = 0x8017; 125 | pub const GLX_MAX_PBUFFER_PIXELS: c_int = 0x8018; 126 | pub const GLX_SAMPLE_BUFFERS: c_int = 0x1_86a0; 127 | pub const GLX_SAMPLES: c_int = 0x1_86a1; 128 | 129 | // misc 130 | pub const GLX_DONT_CARE: c_int = -1; 131 | pub const GLX_NONE: c_int = 0x8000; 132 | 133 | // render type mask 134 | pub const GLX_RGBA_BIT: c_int = 0x0001; 135 | pub const GLX_COLOR_INDEX_BIT: c_int = 0x0002; 136 | 137 | // transparent types 138 | pub const GLX_TRANSPARENT_RGB: c_int = 0x8008; 139 | pub const GLX_TRANSPARENT_INDEX: c_int = 0x8009; 140 | 141 | // visual types 142 | pub const GLX_TRUE_COLOR: c_int = 0x8002; 143 | pub const GLX_DIRECT_COLOR: c_int = 0x8003; 144 | pub const GLX_PSEUDO_COLOR: c_int = 0x8004; 145 | pub const GLX_STATIC_COLOR: c_int = 0x8005; 146 | pub const GLX_GRAY_SCALE: c_int = 0x8006; 147 | pub const GLX_STATIC_GRAY: c_int = 0x8007; 148 | 149 | // glXGetConfig errors 150 | pub const GLX_BAD_SCREEN: c_int = 1; 151 | pub const GLX_BAD_ATTRIBUTE: c_int = 2; 152 | pub const GLX_NO_EXTENSION: c_int = 3; 153 | pub const GLX_BAD_VISUAL: c_int = 4; 154 | pub const GLX_BAD_CONTEXT: c_int = 5; 155 | pub const GLX_BAD_VALUE: c_int = 6; 156 | pub const GLX_BAD_ENUM: c_int = 7; 157 | 158 | // glXGetClientString names 159 | pub const GLX_VENDOR: c_int = 1; 160 | pub const GLX_VERSION: c_int = 2; 161 | pub const GLX_EXTENSIONS: c_int = 3; 162 | 163 | // drawable type mask? 164 | pub const GLX_FRONT_LEFT_BUFFER_BIT: c_uint = 0x0001; 165 | pub const GLX_FRONT_RIGHT_BUFFER_BIT: c_uint = 0x0002; 166 | pub const GLX_BACK_LEFT_BUFFER_BIT: c_uint = 0x0004; 167 | pub const GLX_BACK_RIGHT_BUFFER_BIT: c_uint = 0x0008; 168 | pub const GLX_AUX_BUFFERS_BIT: c_uint = 0x0010; 169 | pub const GLX_DEPTH_BUFFER_BIT: c_uint = 0x0020; 170 | pub const GLX_STENCIL_BUFFER_BIT: c_uint = 0x0040; 171 | pub const GLX_ACCUM_BUFFER_BIT: c_uint = 0x0080; 172 | 173 | // render type for glXCreateNewContext 174 | pub const GLX_RGBA_TYPE: c_int = 0x8014; 175 | pub const GLX_COLOR_INDEX_TYPE: c_int = 0x8015; 176 | 177 | // drawable attributes 178 | pub const GLX_PRESERVED_CONTENTS: c_int = 0x801B; 179 | pub const GLX_LARGEST_PBUFFER: c_int = 0x801C; 180 | pub const GLX_WIDTH: c_int = 0x801D; 181 | pub const GLX_HEIGHT: c_int = 0x801E; 182 | pub const GLX_PBUFFER_HEIGHT: c_int = 0x8040; 183 | pub const GLX_PBUFFER_WIDTH: c_int = 0x8041; 184 | 185 | // other? 186 | pub const GLX_EVENT_MASK: c_int = 0x801F; 187 | 188 | // event mask 189 | pub const GLX_PBUFFER_CLOBBER_MASK: c_ulong = 0x0800_0000; 190 | 191 | // event types 192 | pub const GLX_DAMAGED: c_int = 0x8020; 193 | pub const GLX_SAVED: c_int = 0x8021; 194 | 195 | // drawable types 196 | pub const GLX_WINDOW: c_int = 0x8022; 197 | pub const GLX_PBUFFER: c_int = 0x8023; 198 | 199 | // 200 | // ARB extensions 201 | // 202 | 203 | pub mod arb { 204 | use std::os::raw::c_int; 205 | 206 | // context attributes 207 | pub const GLX_CONTEXT_MAJOR_VERSION_ARB: c_int = 0x2091; 208 | pub const GLX_CONTEXT_MINOR_VERSION_ARB: c_int = 0x2092; 209 | pub const GLX_CONTEXT_FLAGS_ARB: c_int = 0x2094; 210 | pub const GLX_CONTEXT_PROFILE_MASK_ARB: c_int = 0x9126; 211 | 212 | // context flags 213 | pub const GLX_CONTEXT_DEBUG_BIT_ARB: c_int = 0x0001; 214 | pub const GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB: c_int = 0x0002; 215 | 216 | // context profile mask 217 | pub const GLX_CONTEXT_CORE_PROFILE_BIT_ARB: c_int = 0x0001; 218 | pub const GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB: c_int = 0x0002; 219 | } 220 | 221 | // 222 | // EXT extensions 223 | // 224 | 225 | pub mod ext { 226 | use std::os::raw::c_int; 227 | 228 | // drawable attributes 229 | pub const GLX_SWAP_INTERVAL_EXT: c_int = 0x20f1; 230 | pub const GLX_MAX_SWAP_INTERVAL_EXT: c_int = 0x20f2; 231 | } 232 | -------------------------------------------------------------------------------- /src/internal.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::cmp::min; 6 | use std::mem::{size_of, zeroed}; 7 | 8 | // 9 | // public functions 10 | // 11 | 12 | pub unsafe fn mem_eq(a: &T, b: &T) -> bool { 13 | let a_addr = a as *const T as usize; 14 | let b_addr = b as *const T as usize; 15 | 16 | for i in 0..size_of::() { 17 | if *((a_addr + i) as *const u8) != *((b_addr + i) as *const u8) { 18 | return false; 19 | } 20 | } 21 | 22 | true 23 | } 24 | 25 | pub unsafe fn transmute_union(input: &I) -> O 26 | where 27 | I: Sized, 28 | O: Sized, 29 | { 30 | let mut output: O = zeroed(); 31 | let copy_len = min(size_of::(), size_of::()); 32 | 33 | for i in 0..copy_len { 34 | *((&mut output as *mut O as usize + i) as *mut u8) = 35 | *((input as *const I as usize + i) as *const u8); 36 | } 37 | 38 | output 39 | } 40 | -------------------------------------------------------------------------------- /src/sync.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong}; 6 | 7 | use crate::xlib::{Bool, Display, Drawable, Status, Time, XID}; 8 | 9 | // 10 | // functions 11 | // 12 | 13 | x11_link! { Xext, xext, ["libXext.so.6", "libXext.so"], 38, 14 | pub fn XSyncQueryExtension(dpy: *mut Display, event_base: *mut c_int, error_base: *mut c_int) -> Status, 15 | pub fn XSyncInitialize(dpy: *mut Display, major_version: *mut c_int, minor_version: *mut c_int) -> Status, 16 | pub fn XSyncListSystemCounters(dpy: *mut Display, n_counters: *mut c_int) -> *mut XSyncSystemCounter, 17 | pub fn XSyncFreeSystemCounterList(list: *mut XSyncSystemCounter) -> (), 18 | pub fn XSyncCreateCounter(dpy: *mut Display, initial_value: XSyncValue) -> XSyncCounter, 19 | pub fn XSyncSetCounter(dpy: *mut Display, counter: XSyncCounter, value: XSyncValue) -> Status, 20 | pub fn XSyncChangeCounter(dpy: *mut Display, counter: XSyncCounter, value: XSyncValue) -> Status, 21 | pub fn XSyncDestroyCounter(dpy: *mut Display, value: XSyncCounter) -> Status, 22 | pub fn XSyncQueryCounter(dpy: *mut Display, counter: XSyncCounter, value: *mut XSyncValue) -> Status, 23 | pub fn XSyncAwait(dpy: *mut Display, wait_list: *mut XSyncWaitCondition, n_conditions: c_int) -> Status, 24 | pub fn XSyncCreateAlarm(dpy: *mut Display, values_mask: c_ulong, values: *mut XSyncAlarmAttributes) -> XSyncAlarm, 25 | pub fn XSyncDestroyAlarm(dpy: *mut Display, alarm: XSyncAlarm) -> Status, 26 | pub fn XSyncQueryAlarm(dpy: *mut Display, alarm: XSyncAlarm, values: *mut XSyncAlarmAttributes) -> Status, 27 | pub fn XSyncChangeAlarm(dpy: *mut Display, alarm: XSyncAlarm, values_mask: c_ulong, values: *mut XSyncAlarmAttributes) -> Status, 28 | pub fn XSyncSetPriority(dpy: *mut Display, client_resource_id: XID, priority: c_int) -> Status, 29 | pub fn XSyncGetPriority(dpy: *mut Display, client_resource_id: XID, priority: *mut c_int) -> Status, 30 | pub fn XSyncCreateFence(dpy: *mut Display, d: Drawable, initially_triggered: Bool) -> XSyncFence, 31 | pub fn XSyncTriggerFence(dpy: *mut Display, fence: XSyncFence) -> Bool, 32 | pub fn XSyncResetFence(dpy: *mut Display, fence: XSyncFence) -> Bool, 33 | pub fn XSyncDestroyFence(dpy: *mut Display, fence: XSyncFence) -> Bool, 34 | pub fn XSyncQueryFence(dpy: *mut Display, fence: XSyncFence, triggered: *mut Bool) -> Bool, 35 | pub fn XSyncAwaitFence(dpy: *mut Display, fence_list: *const XSyncFence, n_fences: c_int) -> Bool, 36 | pub fn XSyncIntToValue(pv: *mut XSyncValue, i: c_int) -> (), 37 | pub fn XSyncIntsToValue(pv: *mut XSyncValue, l: c_uint, h: c_int) -> (), 38 | pub fn XSyncValueGreaterThan(a: XSyncValue, b: XSyncValue) -> Bool, 39 | pub fn XSyncValueLessThan(a: XSyncValue, b: XSyncValue) -> Bool, 40 | pub fn XSyncValueGreaterOrEqual(a: XSyncValue, b: XSyncValue) -> Bool, 41 | pub fn XSyncValueLessOrEqual(a: XSyncValue, b: XSyncValue) -> Bool, 42 | pub fn XSyncValueEqual(a: XSyncValue, b: XSyncValue) -> Bool, 43 | pub fn XSyncValueIsNegative(v: XSyncValue) -> Bool, 44 | pub fn XSyncValueIsZero(v: XSyncValue) -> Bool, 45 | pub fn XSyncValueIsPositive(v: XSyncValue) -> Bool, 46 | pub fn XSyncValueLow32(v: XSyncValue) -> c_uint, 47 | pub fn XSyncValueHigh32(v: XSyncValue) -> c_int, 48 | pub fn XSyncValueAdd(presult: *mut XSyncValue, a: XSyncValue, b: XSyncValue, poverflow: *mut c_int) -> (), 49 | pub fn XSyncValueSubtract(presult: *mut XSyncValue, a: XSyncValue, b: XSyncValue, poverflow: *mut c_int) -> (), 50 | pub fn XSyncMaxValue(pv: *mut XSyncValue) -> (), 51 | pub fn XSyncMinValue(pv: *mut XSyncValue) -> (), 52 | variadic: 53 | globals: 54 | } 55 | 56 | // 57 | // types 58 | // 59 | 60 | pub type XSyncValueType = c_uint; 61 | pub type XSyncTestType = c_uint; 62 | pub type XSyncAlarmState = c_uint; 63 | pub type XSyncCounter = XID; 64 | pub type XSyncAlarm = XID; 65 | pub type XSyncFence = XID; 66 | 67 | #[repr(C)] 68 | #[derive(Debug, Copy, Clone)] 69 | pub struct XSyncAlarmError { 70 | pub type_: c_int, 71 | pub display: *mut Display, 72 | pub alarm: XSyncAlarm, 73 | pub serial: c_ulong, 74 | pub error_code: c_uchar, 75 | pub request_code: c_uchar, 76 | pub minor_code: c_uchar, 77 | } 78 | #[repr(C)] 79 | #[derive(Debug, Copy, Clone)] 80 | pub struct XSyncCounterError { 81 | pub type_: c_int, 82 | pub display: *mut Display, 83 | pub counter: XSyncCounter, 84 | pub serial: c_ulong, 85 | pub error_code: c_uchar, 86 | pub request_code: c_uchar, 87 | pub minor_code: c_uchar, 88 | } 89 | 90 | #[repr(C)] 91 | #[derive(Debug, Copy, Clone)] 92 | pub struct XSyncValue { 93 | pub hi: c_int, 94 | pub lo: c_uint, 95 | } 96 | 97 | #[repr(C)] 98 | #[derive(Debug, Copy, Clone)] 99 | pub struct XSyncTrigger { 100 | pub counter: XSyncCounter, 101 | pub value_type: XSyncValueType, 102 | pub wait_value: XSyncValue, 103 | pub test_type: XSyncTestType, 104 | } 105 | #[repr(C)] 106 | #[derive(Debug, Copy, Clone)] 107 | pub struct XSyncWaitCondition { 108 | pub trigger: XSyncTrigger, 109 | pub event_threshold: XSyncValue, 110 | } 111 | #[repr(C)] 112 | #[derive(Debug, Copy, Clone)] 113 | pub struct XSyncAlarmAttributes { 114 | pub trigger: XSyncTrigger, 115 | pub delta: XSyncValue, 116 | pub events: Bool, 117 | pub state: XSyncAlarmState, 118 | } 119 | #[repr(C)] 120 | #[derive(Debug, Copy, Clone)] 121 | pub struct XSyncCounterNotifyEvent { 122 | pub type_: c_int, 123 | pub serial: c_ulong, 124 | pub send_event: Bool, 125 | pub display: *mut Display, 126 | pub counter: XSyncCounter, 127 | pub wait_value: XSyncValue, 128 | pub counter_value: XSyncValue, 129 | pub time: Time, 130 | pub count: c_int, 131 | pub destroyed: Bool, 132 | } 133 | #[repr(C)] 134 | #[derive(Debug, Copy, Clone)] 135 | pub struct XSyncAlarmNotifyEvent { 136 | pub type_: c_int, 137 | pub serial: c_ulong, 138 | pub send_event: Bool, 139 | pub display: *mut Display, 140 | pub alarm: XSyncAlarm, 141 | pub counter_value: XSyncValue, 142 | pub alarm_value: XSyncValue, 143 | pub time: Time, 144 | pub state: XSyncAlarmState, 145 | } 146 | 147 | #[repr(C)] 148 | #[derive(Debug, Copy, Clone)] 149 | pub struct XSyncSystemCounter { 150 | pub name: *mut c_char, 151 | pub counter: XSyncCounter, 152 | pub resolution: XSyncValue, 153 | } 154 | 155 | // 156 | // constants 157 | // 158 | 159 | pub const SYNC_NAME: &str = "SYNC"; 160 | 161 | pub const SYNC_MAJOR_VERSION: c_int = 3; 162 | pub const SYNC_MINOR_VERSION: c_int = 1; 163 | 164 | pub const XSyncCounterNotify: c_long = 0; 165 | pub const XSyncAlarmNotify: c_long = 1; 166 | pub const XSyncAlarmNotifyMask: c_long = 1 << XSyncAlarmNotify; 167 | 168 | pub const XSyncNumberEvents: c_long = 2; 169 | 170 | pub const XSyncBadCounter: c_long = 0; 171 | pub const XSyncBadAlarm: c_long = 1; 172 | pub const XSyncBadFence: c_long = 2; 173 | pub const XSyncNumberErrors: c_long = XSyncBadFence + 1; 174 | 175 | pub const XSyncCACounter: c_long = 1 << 0; 176 | pub const XSyncCAValueType: c_long = 1 << 1; 177 | pub const XSyncCAValue: c_long = 1 << 2; 178 | pub const XSyncCATestType: c_long = 1 << 3; 179 | pub const XSyncCADelta: c_long = 1 << 4; 180 | pub const XSyncCAEvents: c_long = 1 << 5; 181 | 182 | pub const XSyncValueType_XSyncAbsolute: XSyncValueType = 0; 183 | pub const XSyncValueType_XSyncRelative: XSyncValueType = 1; 184 | 185 | pub const XSyncTestType_XSyncPositiveTransition: XSyncTestType = 0; 186 | pub const XSyncTestType_XSyncNegativeTransition: XSyncTestType = 1; 187 | pub const XSyncTestType_XSyncPositiveComparison: XSyncTestType = 2; 188 | pub const XSyncTestType_XSyncNegativeComparison: XSyncTestType = 3; 189 | 190 | pub const XSyncAlarmState_XSyncAlarmActive: XSyncAlarmState = 0; 191 | pub const XSyncAlarmState_XSyncAlarmInactive: XSyncAlarmState = 1; 192 | pub const XSyncAlarmState_XSyncAlarmDestroyed: XSyncAlarmState = 2; 193 | -------------------------------------------------------------------------------- /src/xcursor.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use libc::FILE; 6 | use std::os::raw::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_void}; 7 | 8 | use crate::xlib::{Cursor, Display, XColor, XImage}; 9 | 10 | // 11 | // functions 12 | // 13 | 14 | x11_link! { Xcursor, xcursor, ["libXcursor.so.1", "libXcursor.so"], 59, 15 | pub fn XcursorAnimateCreate (_1: *mut XcursorCursors) -> *mut XcursorAnimate, 16 | pub fn XcursorAnimateDestroy (_1: *mut XcursorAnimate) -> (), 17 | pub fn XcursorAnimateNext (_1: *mut XcursorAnimate) -> c_ulong, 18 | pub fn XcursorCommentCreate (_2: c_uint, _1: c_int) -> *mut XcursorComment, 19 | pub fn XcursorCommentDestroy (_1: *mut XcursorComment) -> (), 20 | pub fn XcursorCommentsCreate (_1: c_int) -> *mut XcursorComments, 21 | pub fn XcursorCommentsDestroy (_1: *mut XcursorComments) -> (), 22 | pub fn XcursorCursorsCreate (_2: *mut Display, _1: c_int) -> *mut XcursorCursors, 23 | pub fn XcursorCursorsDestroy (_1: *mut XcursorCursors) -> (), 24 | pub fn XcursorFileLoad (_3: *mut FILE, _2: *mut *mut XcursorComments, _1: *mut *mut XcursorImages) -> c_int, 25 | pub fn XcursorFileLoadAllImages (_1: *mut FILE) -> *mut XcursorImages, 26 | pub fn XcursorFileLoadImage (_2: *mut FILE, _1: c_int) -> *mut XcursorImage, 27 | pub fn XcursorFileLoadImages (_2: *mut FILE, _1: c_int) -> *mut XcursorImages, 28 | pub fn XcursorFilenameLoad (_3: *const c_char, _2: *mut *mut XcursorComments, _1: *mut *mut XcursorImages) -> c_int, 29 | pub fn XcursorFilenameLoadAllImages (_1: *const c_char) -> *mut XcursorImages, 30 | pub fn XcursorFilenameLoadCursor (_2: *mut Display, _1: *const c_char) -> c_ulong, 31 | pub fn XcursorFilenameLoadCursors (_2: *mut Display, _1: *const c_char) -> *mut XcursorCursors, 32 | pub fn XcursorFilenameLoadImage (_2: *const c_char, _1: c_int) -> *mut XcursorImage, 33 | pub fn XcursorFilenameLoadImages (_2: *const c_char, _1: c_int) -> *mut XcursorImages, 34 | pub fn XcursorFilenameSave (_3: *const c_char, _2: *const XcursorComments, _1: *const XcursorImages) -> c_int, 35 | pub fn XcursorFilenameSaveImages (_2: *const c_char, _1: *const XcursorImages) -> c_int, 36 | pub fn XcursorFileSave (_3: *mut FILE, _2: *const XcursorComments, _1: *const XcursorImages) -> c_int, 37 | pub fn XcursorFileSaveImages (_2: *mut FILE, _1: *const XcursorImages) -> c_int, 38 | pub fn XcursorGetDefaultSize (_1: *mut Display) -> c_int, 39 | pub fn XcursorGetTheme (_1: *mut Display) -> *mut c_char, 40 | pub fn XcursorGetThemeCore (_1: *mut Display) -> c_int, 41 | pub fn XcursorImageCreate (_2: c_int, _1: c_int) -> *mut XcursorImage, 42 | pub fn XcursorImageDestroy (_1: *mut XcursorImage) -> (), 43 | pub fn XcursorImageHash (_2: *mut XImage, _1: *mut c_uchar) -> (), 44 | pub fn XcursorImageLoadCursor (_2: *mut Display, _1: *const XcursorImage) -> c_ulong, 45 | pub fn XcursorImagesCreate (_1: c_int) -> *mut XcursorImages, 46 | pub fn XcursorImagesDestroy (_1: *mut XcursorImages) -> (), 47 | pub fn XcursorImagesLoadCursor (_2: *mut Display, _1: *const XcursorImages) -> c_ulong, 48 | pub fn XcursorImagesLoadCursors (_2: *mut Display, _1: *const XcursorImages) -> *mut XcursorCursors, 49 | pub fn XcursorImagesSetName (_2: *mut XcursorImages, _1: *const c_char) -> (), 50 | pub fn XcursorLibraryLoadCursor (_2: *mut Display, _1: *const c_char) -> c_ulong, 51 | pub fn XcursorLibraryLoadCursors (_2: *mut Display, _1: *const c_char) -> *mut XcursorCursors, 52 | pub fn XcursorLibraryLoadImage (_3: *const c_char, _2: *const c_char, _1: c_int) -> *mut XcursorImage, 53 | pub fn XcursorLibraryLoadImages (_3: *const c_char, _2: *const c_char, _1: c_int) -> *mut XcursorImages, 54 | pub fn XcursorLibraryPath () -> *const c_char, 55 | pub fn XcursorLibraryShape (_1: *const c_char) -> c_int, 56 | pub fn XcursorNoticeCreateBitmap (_4: *mut Display, _3: c_ulong, _2: c_uint, _1: c_uint) -> (), 57 | pub fn XcursorNoticePutBitmap (_3: *mut Display, _2: c_ulong, _1: *mut XImage) -> (), 58 | pub fn XcursorSetDefaultSize (_2: *mut Display, _1: c_int) -> c_int, 59 | pub fn XcursorSetTheme (_2: *mut Display, _1: *const c_char) -> c_int, 60 | pub fn XcursorSetThemeCore (_2: *mut Display, _1: c_int) -> c_int, 61 | pub fn XcursorShapeLoadCursor (_2: *mut Display, _1: c_uint) -> c_ulong, 62 | pub fn XcursorShapeLoadCursors (_2: *mut Display, _1: c_uint) -> *mut XcursorCursors, 63 | pub fn XcursorShapeLoadImage (_3: c_uint, _2: *const c_char, _1: c_int) -> *mut XcursorImage, 64 | pub fn XcursorShapeLoadImages (_3: c_uint, _2: *const c_char, _1: c_int) -> *mut XcursorImages, 65 | pub fn XcursorSupportsAnim (_1: *mut Display) -> c_int, 66 | pub fn XcursorSupportsARGB (_1: *mut Display) -> c_int, 67 | pub fn XcursorTryShapeBitmapCursor (_7: *mut Display, _6: c_ulong, _5: c_ulong, _4: *mut XColor, _3: *mut XColor, _2: c_uint, _1: c_uint) -> c_ulong, 68 | pub fn XcursorTryShapeCursor (_7: *mut Display, _6: c_ulong, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *const XColor, _1: *const XColor) -> c_ulong, 69 | pub fn XcursorXcFileLoad (_3: *mut XcursorFile, _2: *mut *mut XcursorComments, _1: *mut *mut XcursorImages) -> c_int, 70 | pub fn XcursorXcFileLoadAllImages (_1: *mut XcursorFile) -> *mut XcursorImages, 71 | pub fn XcursorXcFileLoadImage (_2: *mut XcursorFile, _1: c_int) -> *mut XcursorImage, 72 | pub fn XcursorXcFileLoadImages (_2: *mut XcursorFile, _1: c_int) -> *mut XcursorImages, 73 | pub fn XcursorXcFileSave (_3: *mut XcursorFile, _2: *const XcursorComments, _1: *const XcursorImages) -> c_int, 74 | variadic: 75 | globals: 76 | } 77 | 78 | // 79 | // types 80 | // 81 | 82 | pub type XcursorBool = c_int; 83 | pub type XcursorDim = XcursorUInt; 84 | pub type XcursorPixel = XcursorUInt; 85 | pub type XcursorUInt = c_uint; 86 | 87 | #[derive(Debug, Clone, Copy)] 88 | #[repr(C)] 89 | pub struct _XcursorAnimate { 90 | pub cursors: *mut XcursorCursors, 91 | pub sequence: c_int, 92 | } 93 | pub type XcursorAnimate = _XcursorAnimate; 94 | 95 | #[derive(Debug, Clone, Copy)] 96 | #[repr(C)] 97 | pub struct _XcursorChunkHeader { 98 | pub header: XcursorUInt, 99 | pub type_: XcursorUInt, 100 | pub subtype: XcursorUInt, 101 | pub version: XcursorUInt, 102 | } 103 | pub type XcursorChunkHeader = _XcursorChunkHeader; 104 | 105 | #[derive(Debug, Clone, Copy)] 106 | #[repr(C)] 107 | pub struct _XcursorComment { 108 | pub version: XcursorUInt, 109 | pub comment_type: XcursorUInt, 110 | pub comment: *mut c_char, 111 | } 112 | pub type XcursorComment = _XcursorComment; 113 | 114 | #[derive(Debug, Clone, Copy)] 115 | #[repr(C)] 116 | pub struct _XcursorComments { 117 | pub ncomment: c_int, 118 | pub comments: *mut *mut XcursorComment, 119 | } 120 | pub type XcursorComments = _XcursorComments; 121 | 122 | #[derive(Debug, Clone, Copy)] 123 | #[repr(C)] 124 | pub struct _XcursorCursors { 125 | pub dpy: *mut Display, 126 | pub ref_: c_int, 127 | pub ncursor: c_int, 128 | pub cursors: *mut Cursor, 129 | } 130 | pub type XcursorCursors = _XcursorCursors; 131 | 132 | #[derive(Debug, Copy)] 133 | #[repr(C)] 134 | pub struct _XcursorFile { 135 | pub closure: *mut c_void, 136 | pub read: Option c_int>, 137 | pub write: Option c_int>, 138 | pub seek: Option c_int>, 139 | } 140 | pub type XcursorFile = _XcursorFile; 141 | 142 | impl Clone for _XcursorFile { 143 | fn clone(&self) -> _XcursorFile { 144 | _XcursorFile { 145 | closure: self.closure, 146 | read: self.read, 147 | write: self.write, 148 | seek: self.seek, 149 | } 150 | } 151 | } 152 | 153 | #[derive(Debug, Clone, Copy)] 154 | #[repr(C)] 155 | pub struct _XcursorFileHeader { 156 | pub magic: XcursorUInt, 157 | pub header: XcursorUInt, 158 | pub version: XcursorUInt, 159 | pub ntoc: XcursorUInt, 160 | pub tocs: *mut XcursorFileToc, 161 | } 162 | pub type XcursorFileHeader = _XcursorFileHeader; 163 | 164 | #[derive(Debug, Clone, Copy)] 165 | #[repr(C)] 166 | pub struct _XcursorFileToc { 167 | pub type_: XcursorUInt, 168 | pub subtype: XcursorUInt, 169 | pub position: XcursorUInt, 170 | } 171 | pub type XcursorFileToc = _XcursorFileToc; 172 | 173 | #[derive(Debug, Clone, Copy)] 174 | #[repr(C)] 175 | pub struct _XcursorImage { 176 | pub version: XcursorUInt, 177 | pub size: XcursorDim, 178 | pub width: XcursorDim, 179 | pub height: XcursorDim, 180 | pub xhot: XcursorDim, 181 | pub yhot: XcursorDim, 182 | pub delay: XcursorUInt, 183 | pub pixels: *mut XcursorPixel, 184 | } 185 | pub type XcursorImage = _XcursorImage; 186 | 187 | #[derive(Debug, Clone, Copy)] 188 | #[repr(C)] 189 | pub struct _XcursorImages { 190 | pub nimage: c_int, 191 | pub images: *mut *mut XcursorImage, 192 | pub name: *mut c_char, 193 | } 194 | pub type XcursorImages = _XcursorImages; 195 | -------------------------------------------------------------------------------- /src/xf86vmode.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::{c_char, c_float, c_int, c_uchar, c_uint, c_ulong, c_ushort}; 6 | 7 | use super::xlib::{Bool, Display, Time, Window, XEvent}; 8 | 9 | // 10 | // functions 11 | // 12 | 13 | x11_link! { Xf86vmode, xxf86vm, ["libXxf86vm.so.1", "libXxf86vm.so"], 22, 14 | pub fn XF86VidModeAddModeLine (_4: *mut Display, _3: c_int, _2: *mut XF86VidModeModeInfo, _1: *mut XF86VidModeModeInfo) -> c_int, 15 | pub fn XF86VidModeDeleteModeLine (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeModeInfo) -> c_int, 16 | pub fn XF86VidModeGetAllModeLines (_4: *mut Display, _3: c_int, _2: *mut c_int, _1: *mut *mut *mut XF86VidModeModeInfo) -> c_int, 17 | pub fn XF86VidModeGetDotClocks (_6: *mut Display, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut *mut c_int) -> c_int, 18 | pub fn XF86VidModeGetGamma (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeGamma) -> c_int, 19 | pub fn XF86VidModeGetGammaRamp (_6: *mut Display, _5: c_int, _4: c_int, _3: *mut c_ushort, _2: *mut c_ushort, _1: *mut c_ushort) -> c_int, 20 | pub fn XF86VidModeGetGammaRampSize (_3: *mut Display, _2: c_int, _1: *mut c_int) -> c_int, 21 | pub fn XF86VidModeGetModeLine (_4: *mut Display, _3: c_int, _2: *mut c_int, _1: *mut XF86VidModeModeLine) -> c_int, 22 | pub fn XF86VidModeGetMonitor (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeMonitor) -> c_int, 23 | pub fn XF86VidModeGetPermissions (_3: *mut Display, _2: c_int, _1: *mut c_int) -> c_int, 24 | pub fn XF86VidModeGetViewPort (_4: *mut Display, _3: c_int, _2: *mut c_int, _1: *mut c_int) -> c_int, 25 | pub fn XF86VidModeLockModeSwitch (_3: *mut Display, _2: c_int, _1: c_int) -> c_int, 26 | pub fn XF86VidModeModModeLine (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeModeLine) -> c_int, 27 | pub fn XF86VidModeQueryExtension (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, 28 | pub fn XF86VidModeQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, 29 | pub fn XF86VidModeSetClientVersion (_1: *mut Display) -> c_int, 30 | pub fn XF86VidModeSetGamma (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeGamma) -> c_int, 31 | pub fn XF86VidModeSetGammaRamp (_6: *mut Display, _5: c_int, _4: c_int, _3: *mut c_ushort, _2: *mut c_ushort, _1: *mut c_ushort) -> c_int, 32 | pub fn XF86VidModeSetViewPort (_4: *mut Display, _3: c_int, _2: c_int, _1: c_int) -> c_int, 33 | pub fn XF86VidModeSwitchMode (_3: *mut Display, _2: c_int, _1: c_int) -> c_int, 34 | pub fn XF86VidModeSwitchToMode (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeModeInfo) -> c_int, 35 | pub fn XF86VidModeValidateModeLine (_3: *mut Display, _2: c_int, _1: *mut XF86VidModeModeInfo) -> c_int, 36 | variadic: 37 | globals: 38 | } 39 | 40 | // 41 | // types 42 | // 43 | 44 | #[derive(Debug, Clone, Copy)] 45 | #[repr(C)] 46 | pub struct XF86VidModeGamma { 47 | pub red: c_float, 48 | pub green: c_float, 49 | pub blue: c_float, 50 | } 51 | 52 | #[derive(Debug, Clone, Copy, PartialEq)] 53 | #[repr(C)] 54 | pub struct XF86VidModeModeInfo { 55 | pub dotclock: c_uint, 56 | pub hdisplay: c_ushort, 57 | pub hsyncstart: c_ushort, 58 | pub hsyncend: c_ushort, 59 | pub htotal: c_ushort, 60 | pub hskew: c_ushort, 61 | pub vdisplay: c_ushort, 62 | pub vsyncstart: c_ushort, 63 | pub vsyncend: c_ushort, 64 | pub vtotal: c_ushort, 65 | pub flags: c_uint, 66 | pub privsize: c_int, 67 | pub private: *mut i32, 68 | } 69 | 70 | #[derive(Debug, Clone, Copy)] 71 | #[repr(C)] 72 | pub struct XF86VidModeModeLine { 73 | pub hdisplay: c_ushort, 74 | pub hsyncstart: c_ushort, 75 | pub hsyncend: c_ushort, 76 | pub htotal: c_ushort, 77 | pub hskew: c_ushort, 78 | pub vdisplay: c_ushort, 79 | pub vsyncstart: c_ushort, 80 | pub vsyncend: c_ushort, 81 | pub vtotal: c_ushort, 82 | pub flags: c_uint, 83 | pub privsize: c_int, 84 | pub private: *mut i32, 85 | } 86 | 87 | #[derive(Debug, Clone, Copy)] 88 | #[repr(C)] 89 | pub struct XF86VidModeMonitor { 90 | pub vendor: *mut c_char, 91 | pub model: *mut c_char, 92 | pub EMPTY: c_float, 93 | pub nhsync: c_uchar, 94 | pub hsync: *mut XF86VidModeSyncRange, 95 | pub nvsync: c_uchar, 96 | pub vsync: *mut XF86VidModeSyncRange, 97 | } 98 | 99 | #[derive(Debug, Clone, Copy)] 100 | #[repr(C)] 101 | pub struct XF86VidModeSyncRange { 102 | pub hi: c_float, 103 | pub lo: c_float, 104 | } 105 | 106 | // 107 | // event structures 108 | // 109 | 110 | #[derive(Debug, Clone, Copy)] 111 | #[repr(C)] 112 | pub struct XF86VidModeNotifyEvent { 113 | pub type_: c_int, 114 | pub serial: c_ulong, 115 | pub send_event: Bool, 116 | pub display: *mut Display, 117 | pub root: Window, 118 | pub state: c_int, 119 | pub kind: c_int, 120 | pub forced: Bool, 121 | pub time: Time, 122 | } 123 | 124 | event_conversions_and_tests! { 125 | xf86vm_notify: XF86VidModeNotifyEvent, 126 | } 127 | -------------------------------------------------------------------------------- /src/xfixes.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use super::xlib::{Atom, Bool, Cursor, Display, Pixmap, Status, Time, Window, XRectangle, GC, XID}; 6 | use libc::{c_char, c_int, c_short, c_uint, c_ulong, c_ushort}; 7 | 8 | // 9 | // functions 10 | // 11 | 12 | x11_link! { Xlib, x11, ["libXfixes.so.3", "libXfixes.so"], 35, 13 | pub fn XFixesQueryExtension(dpy: *mut Display, event_base: *mut c_int, error_base: *mut c_int) -> Bool, 14 | pub fn XFixesQueryVersion(dpy: *mut Display, major_version: *mut c_int, minor_version: *const c_int) -> Status, 15 | pub fn XFixesVersion() -> c_int, 16 | pub fn XFixesChangeSaveSet(dpy: *mut Display, win: Window, mode: c_int, target: c_int, map: c_int) -> (), 17 | pub fn XFixesSelectSelectionInput(dpy: *mut Display, win: Window, selection: Atom, event_mask: c_ulong) -> (), 18 | pub fn XFixesSelectCursorInput(dpy: Display, win: Window, event_mask: c_ulong) -> (), 19 | pub fn XFixesGetCursorImage(dpy: *mut Display) -> *mut XFixesCursorImage, 20 | pub fn XFixesCreateRegion(dpy: *mut Display, rectangles: *mut XRectangle, nrectangles: c_int) -> XserverRegion, 21 | pub fn XFixesCreateRegionFromBitmap(dpy: *mut Display, bitmap: Pixmap) -> XserverRegion, 22 | pub fn XFixesCreateRegionFromWindow(dpy: *mut Display, win: Window, kind: c_int) -> XserverRegion, 23 | pub fn XFixesCreateRegionFromGC(dpy: *mut Display, gc: GC) -> XserverRegion, 24 | pub fn XFixesCreateRegionFromPicture(dpy: *mut Display, picture: XID) -> XserverRegion, 25 | pub fn XFixesDestroyRegion(dpy: *mut Display, region: XserverRegion) -> (), 26 | pub fn XFixesSetRegion(dpy: *mut Display, region: XserverRegion, rectangles: *mut XRectangle, nrectangles: c_int) -> (), 27 | pub fn XFixesCopyRegion(dpy: *mut Display, dst: XserverRegion, src: XserverRegion) -> (), 28 | pub fn XFixesUnionRegion(dpy: *mut Display, dst: XserverRegion, src1: XserverRegion, src2: XserverRegion) -> (), 29 | pub fn XFixesIntersectRegion(dpy: *mut Display, dst: XserverRegion, src1: XserverRegion, src2: XserverRegion) -> (), 30 | pub fn XFixesSubtractRegion(dpy: *mut Display, dst: XserverRegion, src1: XserverRegion, src2: XserverRegion) -> (), 31 | pub fn XFixesInvertRegion(dpy: *mut Display, dst: XserverRegion, rect: *mut XRectangle, src: XserverRegion) -> (), 32 | pub fn XFixesTranslateRegion(dpy: *mut Display, region: XserverRegion, dx: c_int, dy: c_int) -> (), 33 | pub fn XFixesRegionExtents(dpy: *mut Display, dst: XserverRegion, src: XserverRegion) -> (), 34 | pub fn XFixesFetchRegion(dpy: *mut Display, region: XserverRegion, nrectangles: *mut c_int) -> *mut XRectangle, 35 | pub fn XFixesFetchRegionAndBounds(dpy: *mut Display, region: XserverRegion, nrectangles: *mut c_int, bounds: *mut XRectangle) -> *mut XRectangle, 36 | pub fn XFixesSetGCClipRegion(dpy: *mut Display, gc: GC, clip_x_origin: c_int, clip_y_origin: c_int, region: XserverRegion) -> (), 37 | pub fn XFixesSetWindowShapeRegion(dpy: *mut Display, win: Window, shape_kind: c_int, x_off: c_int, y_off: c_int, region: XserverRegion) -> (), 38 | pub fn XFixesSetPictureClipRegion(dpy: *mut Display, picture: XID, clip_x_origin: c_int, clip_y_origin: c_int, region: XserverRegion) -> (), 39 | pub fn XFixesSetCursorName(dpy: *mut Display, cursor: Cursor, name: *const c_char) -> (), 40 | pub fn XFixesGetCursorName(dpy: *mut Display, cursor: Cursor, atom: *mut Atom) -> *const c_char, 41 | pub fn XFixesChangeCursor(dpy: *mut Display, source: Cursor, destination: Cursor) -> (), 42 | pub fn XFixesChangeCursorByName(dpy: *mut Display, source: Cursor, name: *const c_char) -> (), 43 | pub fn XFixesExpandRegion(dpy: *mut Display, dst: XserverRegion, src: XserverRegion, left: c_uint, right: c_uint, top: c_uint, bottom: c_uint) -> (), 44 | pub fn XFixesHideCursor(dpy: *mut Display, win: Window) -> (), 45 | pub fn XFixesShowCursor(dpy: *mut Display, win: Window) -> (), 46 | pub fn XFixesCreatePointerBarrier(dpy: *mut Display, w: Window, x1: c_int, y1: c_int, x2: c_int, y2: c_int, directions: c_int, num_devices: c_int, devices: *mut c_int) -> PointerBarrier, 47 | pub fn XFixesDestroyPointerBarrier(dpy: *mut Display, b: PointerBarrier) -> (), 48 | variadic: 49 | globals: 50 | } 51 | 52 | // 53 | // types 54 | // 55 | 56 | pub type PointerBarrier = XID; 57 | pub type XserverRegion = XID; 58 | 59 | // 60 | // structs 61 | // 62 | 63 | #[derive(Debug, Clone, Copy, PartialEq)] 64 | #[repr(C)] 65 | pub struct XFixesSelectionNotifyEvent { 66 | pub _type: c_int, 67 | pub serial: c_ulong, 68 | pub send_event: Bool, 69 | pub display: *mut Display, 70 | pub window: Window, 71 | pub subtype: c_int, 72 | pub owner: Window, 73 | pub selection: Atom, 74 | pub timestamp: Time, 75 | pub selection_timestamp: Time, 76 | } 77 | 78 | #[derive(Debug, Clone, Copy, PartialEq)] 79 | #[repr(C)] 80 | pub struct XFixesCursorNotifyEvent { 81 | pub _type: c_int, 82 | pub serial: c_ulong, 83 | pub send_event: Bool, 84 | pub display: *mut Display, 85 | pub window: Window, 86 | pub subtype: c_int, 87 | pub cursor_serial: c_ulong, 88 | pub timestamp: Time, 89 | pub cursor_name: Atom, 90 | } 91 | 92 | #[derive(Debug, Clone, Copy, PartialEq)] 93 | #[repr(C)] 94 | pub struct XFixesCursorImage { 95 | pub x: c_short, 96 | pub y: c_short, 97 | pub width: c_ushort, 98 | pub height: c_ushort, 99 | pub xhot: c_ushort, 100 | pub yhot: c_ushort, 101 | pub cursor_serial: c_ulong, 102 | pub pixels: *mut c_ulong, 103 | pub atom: Atom, 104 | pub name: *const c_char, 105 | } 106 | -------------------------------------------------------------------------------- /src/xft.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::*; 6 | 7 | use super::xlib::{Display, Region, Visual, XRectangle}; 8 | use super::xrender::{XGlyphInfo, XRenderColor}; 9 | 10 | // 11 | // external types 12 | // 13 | 14 | // freetype 15 | pub enum FT_FaceRec {} 16 | pub type FT_UInt = c_uint; 17 | 18 | // fontconfig 19 | pub type FcChar32 = c_uint; 20 | pub enum FcCharSet {} 21 | pub enum FcPattern {} 22 | 23 | #[repr(C)] 24 | pub enum FcEndian { 25 | Big, 26 | Little, 27 | } 28 | 29 | #[repr(C)] 30 | pub enum FcResult { 31 | Match, 32 | NoMatch, 33 | TypeMismatch, 34 | NoId, 35 | OutOfMemory, 36 | } 37 | 38 | // 39 | // functions 40 | // 41 | 42 | x11_link! { Xft, xft, ["libXft.so.2", "libXft.so"], 77, 43 | pub fn XftCharExists (_2: *mut Display, _1: *mut XftFont, _0: c_uint) -> c_int, 44 | pub fn XftCharFontSpecRender (_7: *mut Display, _6: c_int, _5: c_ulong, _4: c_ulong, _3: c_int, _2: c_int, _1: *const XftCharFontSpec, _0: c_int) -> (), 45 | pub fn XftCharIndex (_2: *mut Display, _1: *mut XftFont, _0: c_uint) -> c_uint, 46 | pub fn XftCharSpecRender (_8: *mut Display, _7: c_int, _6: c_ulong, _5: *mut XftFont, _4: c_ulong, _3: c_int, _2: c_int, _1: *const XftCharSpec, _0: c_int) -> (), 47 | pub fn XftColorAllocName (_4: *mut Display, _3: *const Visual, _2: c_ulong, _1: *const c_char, _0: *mut XftColor) -> c_int, 48 | pub fn XftColorAllocValue (_4: *mut Display, _3: *mut Visual, _2: c_ulong, _1: *const XRenderColor, _0: *mut XftColor) -> c_int, 49 | pub fn XftColorFree (_3: *mut Display, _2: *mut Visual, _1: c_ulong, _0: *mut XftColor) -> (), 50 | pub fn XftDefaultHasRender (_0: *mut Display) -> c_int, 51 | pub fn XftDefaultSet (_1: *mut Display, _0: *mut FcPattern) -> c_int, 52 | pub fn XftDefaultSubstitute (_2: *mut Display, _1: c_int, _0: *mut FcPattern) -> (), 53 | pub fn XftDrawChange (_1: *mut XftDraw, _0: c_ulong) -> (), 54 | pub fn XftDrawCharFontSpec (_3: *mut XftDraw, _2: *const XftColor, _1: *const XftCharFontSpec, _0: c_int) -> (), 55 | pub fn XftDrawCharSpec (_4: *mut XftDraw, _3: *const XftColor, _2: *mut XftFont, _1: *const XftCharSpec, _0: c_int) -> (), 56 | pub fn XftDrawColormap (_0: *mut XftDraw) -> c_ulong, 57 | pub fn XftDrawCreate (_3: *mut Display, _2: c_ulong, _1: *mut Visual, _0: c_ulong) -> *mut XftDraw, 58 | pub fn XftDrawCreateAlpha (_2: *mut Display, _1: c_ulong, _0: c_int) -> *mut XftDraw, 59 | pub fn XftDrawCreateBitmap (_1: *mut Display, _0: c_ulong) -> *mut XftDraw, 60 | pub fn XftDrawDestroy (_0: *mut XftDraw) -> (), 61 | pub fn XftDrawDisplay (_0: *mut XftDraw) -> *mut Display, 62 | pub fn XftDrawDrawable (_0: *mut XftDraw) -> c_ulong, 63 | pub fn XftDrawGlyphFontSpec (_3: *mut XftDraw, _2: *const XftColor, _1: *const XftGlyphFontSpec, _0: c_int) -> (), 64 | pub fn XftDrawGlyphs (_6: *mut XftDraw, _5: *const XftColor, _4: *mut XftFont, _3: c_int, _2: c_int, _1: *const c_uint, _0: c_int) -> (), 65 | pub fn XftDrawGlyphSpec (_4: *mut XftDraw, _3: *const XftColor, _2: *mut XftFont, _1: *const XftGlyphSpec, _0: c_int) -> (), 66 | pub fn XftDrawPicture (_0: *mut XftDraw) -> c_ulong, 67 | pub fn XftDrawRect (_5: *mut XftDraw, _4: *const XftColor, _3: c_int, _2: c_int, _1: c_uint, _0: c_uint) -> (), 68 | pub fn XftDrawSetClip (_1: *mut XftDraw, _0: Region) -> c_int, 69 | pub fn XftDrawSetClipRectangles (_4: *mut XftDraw, _3: c_int, _2: c_int, _1: *const XRectangle, _0: c_int) -> c_int, 70 | pub fn XftDrawSetSubwindowMode (_1: *mut XftDraw, _0: c_int) -> (), 71 | pub fn XftDrawSrcPicture (_1: *mut XftDraw, _0: *const XftColor) -> c_ulong, 72 | pub fn XftDrawString16 (_6: *mut XftDraw, _5: *const XftColor, _4: *mut XftFont, _3: c_int, _2: c_int, _1: *const c_ushort, _0: c_int) -> (), 73 | pub fn XftDrawString32 (_6: *mut XftDraw, _5: *const XftColor, _4: *mut XftFont, _3: c_int, _2: c_int, _1: *const c_uint, _0: c_int) -> (), 74 | pub fn XftDrawString8 (_6: *mut XftDraw, _5: *const XftColor, _4: *mut XftFont, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), 75 | pub fn XftDrawStringUtf16 (_7: *mut XftDraw, _6: *const XftColor, _5: *mut XftFont, _4: c_int, _3: c_int, _2: *const c_uchar, _1: FcEndian, _0: c_int) -> (), 76 | pub fn XftDrawStringUtf8 (_6: *mut XftDraw, _5: *const XftColor, _4: *mut XftFont, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), 77 | pub fn XftDrawVisual (_0: *mut XftDraw) -> *mut Visual, 78 | pub fn XftFontCheckGlyph (_5: *mut Display, _4: *mut XftFont, _3: c_int, _2: c_uint, _1: *mut c_uint, _0: *mut c_int) -> c_int, 79 | pub fn XftFontClose (_1: *mut Display, _0: *mut XftFont) -> (), 80 | pub fn XftFontCopy (_1: *mut Display, _0: *mut XftFont) -> *mut XftFont, 81 | pub fn XftFontInfoCreate (_1: *mut Display, _0: *const FcPattern) -> *mut XftFontInfo, 82 | pub fn XftFontInfoDestroy (_1: *mut Display, _0: *mut XftFontInfo) -> (), 83 | pub fn XftFontInfoEqual (_1: *const XftFontInfo, _0: *const XftFontInfo) -> c_int, 84 | pub fn XftFontInfoHash (_0: *const XftFontInfo) -> c_uint, 85 | pub fn XftFontLoadGlyphs (_4: *mut Display, _3: *mut XftFont, _2: c_int, _1: *const c_uint, _0: c_int) -> (), 86 | pub fn XftFontMatch (_3: *mut Display, _2: c_int, _1: *const FcPattern, _0: *mut FcResult) -> *mut FcPattern, 87 | pub fn XftFontOpenInfo (_2: *mut Display, _1: *mut FcPattern, _0: *mut XftFontInfo) -> *mut XftFont, 88 | pub fn XftFontOpenName (_2: *mut Display, _1: c_int, _0: *const c_char) -> *mut XftFont, 89 | pub fn XftFontOpenPattern (_1: *mut Display, _0: *mut FcPattern) -> *mut XftFont, 90 | pub fn XftFontOpenXlfd (_2: *mut Display, _1: c_int, _0: *const c_char) -> *mut XftFont, 91 | pub fn XftFontUnloadGlyphs (_3: *mut Display, _2: *mut XftFont, _1: *const c_uint, _0: c_int) -> (), 92 | pub fn XftGetVersion () -> c_int, 93 | pub fn XftGlyphExtents (_4: *mut Display, _3: *mut XftFont, _2: *const c_uint, _1: c_int, _0: *mut XGlyphInfo) -> (), 94 | pub fn XftGlyphFontSpecRender (_7: *mut Display, _6: c_int, _5: c_ulong, _4: c_ulong, _3: c_int, _2: c_int, _1: *const XftGlyphFontSpec, _0: c_int) -> (), 95 | pub fn XftGlyphRender (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uint, _0: c_int) -> (), 96 | pub fn XftGlyphSpecRender (_8: *mut Display, _7: c_int, _6: c_ulong, _5: *mut XftFont, _4: c_ulong, _3: c_int, _2: c_int, _1: *const XftGlyphSpec, _0: c_int) -> (), 97 | pub fn XftInit (_0: *const c_char) -> c_int, 98 | pub fn XftInitFtLibrary () -> c_int, 99 | pub fn XftLockFace (_0: *mut XftFont) -> *mut FT_FaceRec, 100 | pub fn XftNameParse (_0: *const c_char) -> *mut FcPattern, 101 | pub fn XftNameUnparse (_2: *mut FcPattern, _1: *mut c_char, _0: c_int) -> c_int, 102 | pub fn XftTextExtents16 (_4: *mut Display, _3: *mut XftFont, _2: *const c_ushort, _1: c_int, _0: *mut XGlyphInfo) -> (), 103 | pub fn XftTextExtents32 (_4: *mut Display, _3: *mut XftFont, _2: *const c_uint, _1: c_int, _0: *mut XGlyphInfo) -> (), 104 | pub fn XftTextExtents8 (_4: *mut Display, _3: *mut XftFont, _2: *const c_uchar, _1: c_int, _0: *mut XGlyphInfo) -> (), 105 | pub fn XftTextExtentsUtf16 (_5: *mut Display, _4: *mut XftFont, _3: *const c_uchar, _2: FcEndian, _1: c_int, _0: *mut XGlyphInfo) -> (), 106 | pub fn XftTextExtentsUtf8 (_4: *mut Display, _3: *mut XftFont, _2: *const c_uchar, _1: c_int, _0: *mut XGlyphInfo) -> (), 107 | pub fn XftTextRender16 (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_ushort, _0: c_int) -> (), 108 | pub fn XftTextRender16BE (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), 109 | pub fn XftTextRender16LE (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), 110 | pub fn XftTextRender32 (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uint, _0: c_int) -> (), 111 | pub fn XftTextRender32BE (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), 112 | pub fn XftTextRender32LE (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), 113 | pub fn XftTextRender8 (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), 114 | pub fn XftTextRenderUtf16 (_11: *mut Display, _10: c_int, _9: c_ulong, _8: *mut XftFont, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const c_uchar, _1: FcEndian, _0: c_int) -> (), 115 | pub fn XftTextRenderUtf8 (_10: *mut Display, _9: c_int, _8: c_ulong, _7: *mut XftFont, _6: c_ulong, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: *const c_uchar, _0: c_int) -> (), 116 | pub fn XftUnlockFace (_0: *mut XftFont) -> (), 117 | pub fn XftXlfdParse (_2: *const c_char, _1: c_int, _0: c_int) -> *mut FcPattern, 118 | variadic: 119 | pub fn XftFontOpen (_1: *mut Display, _0: c_int) -> *mut XftFont, 120 | pub fn XftListFonts (_1: *mut Display, _0: c_int) -> *mut XftFontSet, 121 | globals: 122 | } 123 | 124 | // 125 | // types 126 | // 127 | 128 | pub enum XftFontInfo {} 129 | 130 | #[derive(Debug, Clone, Copy, PartialEq)] 131 | #[repr(C)] 132 | pub struct XftFont { 133 | pub ascent: c_int, 134 | pub descent: c_int, 135 | pub height: c_int, 136 | pub max_advance_width: c_int, 137 | pub charset: *mut FcCharSet, 138 | pub pattern: *mut FcPattern, 139 | } 140 | 141 | pub enum XftDraw {} 142 | 143 | #[derive(Debug, Clone, Copy, PartialEq)] 144 | #[repr(C)] 145 | pub struct XftColor { 146 | pub pixel: c_ulong, 147 | pub color: XRenderColor, 148 | } 149 | 150 | #[derive(Debug, Clone, Copy, PartialEq)] 151 | #[repr(C)] 152 | pub struct XftCharSpec { 153 | pub ucs4: FcChar32, 154 | pub x: c_short, 155 | pub y: c_short, 156 | } 157 | 158 | #[derive(Debug, Clone, Copy, PartialEq)] 159 | #[repr(C)] 160 | pub struct XftCharFontSpec { 161 | pub font: *mut XftFont, 162 | pub ucs4: FcChar32, 163 | pub x: c_short, 164 | pub y: c_short, 165 | } 166 | 167 | #[derive(Debug, Clone, Copy, PartialEq)] 168 | #[repr(C)] 169 | pub struct XftFontSet { 170 | pub nfont: c_int, 171 | pub sfont: c_int, 172 | pub fonts: *mut *mut XftPattern, 173 | } 174 | 175 | #[derive(Debug, Clone, Copy, PartialEq)] 176 | #[repr(C)] 177 | pub struct XftGlyphSpec { 178 | pub glyph: FT_UInt, 179 | pub x: c_short, 180 | pub y: c_short, 181 | } 182 | 183 | #[derive(Debug, Clone, Copy, PartialEq)] 184 | #[repr(C)] 185 | pub struct XftGlyphFontSpec { 186 | pub font: *mut XftFont, 187 | pub glyph: FT_UInt, 188 | pub x: c_short, 189 | pub y: c_short, 190 | } 191 | 192 | pub enum XftPattern {} 193 | 194 | // 195 | // constants 196 | // 197 | 198 | // font attributes 199 | pub const XFT_FAMILY: &str = "family"; 200 | pub const XFT_STYLE: &str = "style"; 201 | pub const XFT_SLANT: &str = "slant"; 202 | pub const XFT_WEIGHT: &str = "weight"; 203 | pub const XFT_SIZE: &str = "size"; 204 | pub const XFT_PIXEL_SIZE: &str = "pixelsize"; 205 | pub const XFT_SPACING: &str = "spacing"; 206 | pub const XFT_FOUNDRY: &str = "foundry"; 207 | pub const XFT_ANTIALIAS: &str = "antialias"; 208 | 209 | // slant values 210 | pub const XFT_SLANT_ROMAN: c_int = 0; 211 | pub const XFT_SLANT_ITALIC: c_int = 100; 212 | pub const XFT_SLANT_OBLIQUE: c_int = 110; 213 | 214 | // attribute types 215 | pub const XftTypeVoid: c_int = 0; 216 | pub const XftTypeInteger: c_int = 1; 217 | pub const XftTypeDouble: c_int = 2; 218 | pub const XftTypeString: c_int = 3; 219 | pub const XftTypeBool: c_int = 4; 220 | pub const XftTypeMatrix: c_int = 5; 221 | -------------------------------------------------------------------------------- /src/xinerama.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::{c_int, c_short}; 6 | 7 | use super::xlib::{Bool, Display, Drawable, Status, Window, XID}; 8 | 9 | // 10 | // functions 11 | // 12 | 13 | x11_link! { Xlib, xinerama, ["libXinerama.so.1", "libXinerama.so"], 10, 14 | pub fn XineramaIsActive (dpy: *mut Display) -> Bool, 15 | pub fn XineramaQueryExtension (dpy: *mut Display, event_base: *mut c_int, error_base: *mut c_int) -> Bool, 16 | pub fn XineramaQueryScreens (dpy: *mut Display, number: *mut c_int) -> *mut XineramaScreenInfo, 17 | pub fn XineramaQueryVersion (dpy: *mut Display, major_versionp: *mut c_int, minor_versionp: *mut c_int) -> Status, 18 | pub fn XPanoramiXAllocInfo () -> *mut XPanoramiXInfo, 19 | pub fn XPanoramiXGetScreenCount (dpy: *mut Display, drawable: Drawable, panoramiX_info: *mut XPanoramiXInfo) -> Status, 20 | pub fn XPanoramiXGetScreenSize (dpy: *mut Display, drawable: Drawable, screen_num: c_int, panoramiX_info: *mut XPanoramiXInfo) -> Status, 21 | pub fn XPanoramiXGetState (dpy: *mut Display, drawable: Drawable, panoramiX_info: *mut XPanoramiXInfo) -> Status, 22 | pub fn XPanoramiXQueryExtension (dpy: *mut Display, event_base_return: *mut c_int, error_base_return: *mut c_int) -> Bool, 23 | pub fn XPanoramiXQueryVersion (dpy: *mut Display, major_version_return: *mut c_int, minor_version_return: *mut c_int) -> Status, 24 | variadic: 25 | globals: 26 | } 27 | 28 | // 29 | // types 30 | // 31 | 32 | #[derive(Debug, Clone, Copy, PartialEq)] 33 | #[repr(C)] 34 | pub struct XineramaScreenInfo { 35 | pub screen_number: c_int, 36 | pub x_org: c_short, 37 | pub y_org: c_short, 38 | pub width: c_short, 39 | pub height: c_short, 40 | } 41 | 42 | #[derive(Debug, Clone, Copy, PartialEq)] 43 | #[repr(C)] 44 | pub struct XPanoramiXInfo { 45 | pub window: Window, 46 | pub screen: c_int, 47 | pub State: c_int, 48 | pub width: c_int, 49 | pub height: c_int, 50 | pub ScreenCount: c_int, 51 | pub eventMask: XID, 52 | } 53 | -------------------------------------------------------------------------------- /src/xinput.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::{c_char, c_int, c_long, c_short, c_uchar, c_uint, c_ulong}; 6 | 7 | use super::xlib::{Atom, Display, Time, XEvent, XModifierKeymap, XID}; 8 | 9 | // 10 | // functions 11 | // 12 | 13 | x11_link! { XInput, xi, ["libXi.so.6", "libXi.so"], 44, 14 | pub fn XAllowDeviceEvents (_4: *mut Display, _3: *mut XDevice, _2: c_int, _1: c_ulong) -> c_int, 15 | pub fn XChangeDeviceControl (_4: *mut Display, _3: *mut XDevice, _2: c_int, _1: *mut XDeviceControl) -> c_int, 16 | pub fn XChangeDeviceDontPropagateList (_5: *mut Display, _4: c_ulong, _3: c_int, _2: *mut c_ulong, _1: c_int) -> c_int, 17 | pub fn XChangeDeviceKeyMapping (_6: *mut Display, _5: *mut XDevice, _4: c_int, _3: c_int, _2: *mut c_ulong, _1: c_int) -> c_int, 18 | pub fn XChangeDeviceProperty (_8: *mut Display, _7: *mut XDevice, _6: c_ulong, _5: c_ulong, _4: c_int, _3: c_int, _2: *const c_uchar, _1: c_int) -> (), 19 | pub fn XChangeFeedbackControl (_4: *mut Display, _3: *mut XDevice, _2: c_ulong, _1: *mut XFeedbackControl) -> c_int, 20 | pub fn XChangeKeyboardDevice (_2: *mut Display, _1: *mut XDevice) -> c_int, 21 | pub fn XChangePointerDevice (_4: *mut Display, _3: *mut XDevice, _2: c_int, _1: c_int) -> c_int, 22 | pub fn XCloseDevice (_2: *mut Display, _1: *mut XDevice) -> c_int, 23 | pub fn XDeleteDeviceProperty (_3: *mut Display, _2: *mut XDevice, _1: c_ulong) -> (), 24 | pub fn XDeviceBell (_5: *mut Display, _4: *mut XDevice, _3: c_ulong, _2: c_ulong, _1: c_int) -> c_int, 25 | pub fn XFreeDeviceControl (_1: *mut XDeviceControl) -> (), 26 | pub fn XFreeDeviceList (_1: *mut XDeviceInfo) -> (), 27 | pub fn XFreeDeviceMotionEvents (_1: *mut XDeviceTimeCoord) -> (), 28 | pub fn XFreeDeviceState (_1: *mut XDeviceState) -> (), 29 | pub fn XFreeFeedbackList (_1: *mut XFeedbackState) -> (), 30 | pub fn XGetDeviceButtonMapping (_4: *mut Display, _3: *mut XDevice, _2: *mut c_uchar, _1: c_uint) -> c_int, 31 | pub fn XGetDeviceControl (_3: *mut Display, _2: *mut XDevice, _1: c_int) -> *mut XDeviceControl, 32 | pub fn XGetDeviceDontPropagateList (_3: *mut Display, _2: c_ulong, _1: *mut c_int) -> *mut c_ulong, 33 | pub fn XGetDeviceFocus (_5: *mut Display, _4: *mut XDevice, _3: *mut c_ulong, _2: *mut c_int, _1: *mut c_ulong) -> c_int, 34 | pub fn XGetDeviceKeyMapping (_5: *mut Display, _4: *mut XDevice, _3: c_uchar, _2: c_int, _1: *mut c_int) -> *mut c_ulong, 35 | pub fn XGetDeviceModifierMapping (_2: *mut Display, _1: *mut XDevice) -> *mut XModifierKeymap, 36 | pub fn XGetDeviceMotionEvents (_7: *mut Display, _6: *mut XDevice, _5: c_ulong, _4: c_ulong, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> *mut XDeviceTimeCoord, 37 | pub fn XGetDeviceProperty (_12: *mut Display, _11: *mut XDevice, _10: c_ulong, _9: c_long, _8: c_long, _7: c_int, _6: c_ulong, _5: *mut c_ulong, _4: *mut c_int, _3: *mut c_ulong, _2: *mut c_ulong, _1: *mut *mut c_uchar) -> c_int, 38 | pub fn XGetExtensionVersion (_2: *mut Display, _1: *const c_char) -> *mut XExtensionVersion, 39 | pub fn XGetFeedbackControl (_3: *mut Display, _2: *mut XDevice, _1: *mut c_int) -> *mut XFeedbackState, 40 | pub fn XGetSelectedExtensionEvents (_6: *mut Display, _5: c_ulong, _4: *mut c_int, _3: *mut *mut c_ulong, _2: *mut c_int, _1: *mut *mut c_ulong) -> c_int, 41 | pub fn XGrabDevice (_9: *mut Display, _8: *mut XDevice, _7: c_ulong, _6: c_int, _5: c_int, _4: *mut c_ulong, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, 42 | pub fn XGrabDeviceButton (_11: *mut Display, _10: *mut XDevice, _9: c_uint, _8: c_uint, _7: *mut XDevice, _6: c_ulong, _5: c_int, _4: c_uint, _3: *mut c_ulong, _2: c_int, _1: c_int) -> c_int, 43 | pub fn XGrabDeviceKey (_11: *mut Display, _10: *mut XDevice, _9: c_uint, _8: c_uint, _7: *mut XDevice, _6: c_ulong, _5: c_int, _4: c_uint, _3: *mut c_ulong, _2: c_int, _1: c_int) -> c_int, 44 | 45 | pub fn XListDeviceProperties (_3: *mut Display, _2: *mut XDevice, _1: *mut c_int) -> *mut c_ulong, 46 | pub fn XListInputDevices (_2: *mut Display, _1: *mut c_int) -> *mut XDeviceInfo, 47 | pub fn XOpenDevice (_2: *mut Display, _1: c_ulong) -> *mut XDevice, 48 | pub fn XQueryDeviceState (_2: *mut Display, _1: *mut XDevice) -> *mut XDeviceState, 49 | pub fn XSelectExtensionEvent (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: c_int) -> c_int, 50 | pub fn XSendExtensionEvent (_7: *mut Display, _6: *mut XDevice, _5: c_ulong, _4: c_int, _3: c_int, _2: *mut c_ulong, _1: *mut XEvent) -> c_int, 51 | pub fn XSetDeviceButtonMapping (_4: *mut Display, _3: *mut XDevice, _2: *mut c_uchar, _1: c_int) -> c_int, 52 | pub fn XSetDeviceFocus (_5: *mut Display, _4: *mut XDevice, _3: c_ulong, _2: c_int, _1: c_ulong) -> c_int, 53 | pub fn XSetDeviceMode (_3: *mut Display, _2: *mut XDevice, _1: c_int) -> c_int, 54 | pub fn XSetDeviceModifierMapping (_3: *mut Display, _2: *mut XDevice, _1: *mut XModifierKeymap) -> c_int, 55 | pub fn XSetDeviceValuators (_5: *mut Display, _4: *mut XDevice, _3: *mut c_int, _2: c_int, _1: c_int) -> c_int, 56 | pub fn XUngrabDevice (_3: *mut Display, _2: *mut XDevice, _1: c_ulong) -> c_int, 57 | pub fn XUngrabDeviceButton (_6: *mut Display, _5: *mut XDevice, _4: c_uint, _3: c_uint, _2: *mut XDevice, _1: c_ulong) -> c_int, 58 | pub fn XUngrabDeviceKey (_6: *mut Display, _5: *mut XDevice, _4: c_uint, _3: c_uint, _2: *mut XDevice, _1: c_ulong) -> c_int, 59 | variadic: 60 | globals: 61 | } 62 | 63 | // 64 | // types 65 | // 66 | 67 | pub enum _XAnyClassinfo {} 68 | 69 | pub type XAnyClassPtr = *mut _XAnyClassinfo; 70 | 71 | #[derive(Debug, Clone, Copy, PartialEq)] 72 | #[repr(C)] 73 | pub struct XDevice { 74 | pub device_id: XID, 75 | pub num_classes: c_int, 76 | pub classes: *mut XInputClassInfo, 77 | } 78 | 79 | #[derive(Debug, Clone, Copy, PartialEq)] 80 | #[repr(C)] 81 | pub struct XDeviceControl { 82 | pub control: XID, 83 | pub length: c_int, 84 | } 85 | 86 | #[derive(Debug, Clone, Copy, PartialEq)] 87 | #[repr(C)] 88 | pub struct XDeviceInfo { 89 | pub id: XID, 90 | pub type_: Atom, 91 | pub name: *mut c_char, 92 | pub num_classes: c_int, 93 | pub use_: c_int, 94 | pub inputclassinfo: XAnyClassPtr, 95 | } 96 | 97 | #[derive(Debug, Clone, Copy, PartialEq)] 98 | #[repr(C)] 99 | pub struct XDeviceState { 100 | pub device_id: XID, 101 | pub num_classes: c_int, 102 | pub data: *mut XInputClass, 103 | } 104 | 105 | #[derive(Debug, Clone, Copy, PartialEq)] 106 | #[repr(C)] 107 | pub struct XDeviceTimeCoord { 108 | pub time: Time, 109 | pub data: *mut c_int, 110 | } 111 | 112 | #[derive(Debug, Clone, Copy, PartialEq)] 113 | #[repr(C)] 114 | pub struct XExtensionVersion { 115 | pub present: c_int, 116 | pub major_version: c_short, 117 | pub minor_version: c_short, 118 | } 119 | 120 | #[derive(Debug, Clone, Copy, PartialEq)] 121 | #[repr(C)] 122 | pub struct XFeedbackControl { 123 | pub class: XID, 124 | pub length: c_int, 125 | pub id: XID, 126 | } 127 | 128 | #[derive(Debug, Clone, Copy, PartialEq)] 129 | #[repr(C)] 130 | pub struct XFeedbackState { 131 | pub class: XID, 132 | pub length: c_int, 133 | pub id: XID, 134 | } 135 | 136 | #[derive(Debug, Clone, Copy, PartialEq)] 137 | #[repr(C)] 138 | pub struct XInputClass { 139 | pub class: c_uchar, 140 | pub length: c_uchar, 141 | } 142 | 143 | #[derive(Debug, Clone, Copy, PartialEq)] 144 | #[repr(C)] 145 | pub struct XInputClassInfo { 146 | pub input_class: c_uchar, 147 | pub event_type_base: c_uchar, 148 | } 149 | -------------------------------------------------------------------------------- /src/xlib_xcb.rs: -------------------------------------------------------------------------------- 1 | use super::xlib::Display; 2 | use std::os::raw::c_void; 3 | 4 | x11_link! { Xlib_xcb, xlib_xcb, ["libX11-xcb.so.1", "libX11-xcb.so"], 2, 5 | pub fn XGetXCBConnection(_1: *mut Display) -> *mut xcb_connection_t, 6 | pub fn XSetEventQueueOwner(_1: *mut Display, _2: XEventQueueOwner) -> (), 7 | variadic: 8 | globals: 9 | } 10 | 11 | pub enum XEventQueueOwner { 12 | XlibOwnsEventQueue = 0, 13 | XCBOwnsEventQueue = 1, 14 | } 15 | 16 | pub type xcb_connection_t = c_void; 17 | -------------------------------------------------------------------------------- /src/xmd.rs: -------------------------------------------------------------------------------- 1 | pub type INT8 = i8; 2 | pub type INT16 = i16; 3 | pub type INT32 = i32; 4 | pub type INT64 = i64; 5 | 6 | pub type CARD8 = u8; 7 | pub type CARD16 = u16; 8 | pub type CARD32 = u32; 9 | pub type CARD64 = u64; 10 | 11 | pub type BYTE = CARD8; 12 | pub type BOOL = CARD8; 13 | -------------------------------------------------------------------------------- /src/xmu.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use libc::FILE; 6 | use std::os::raw::{c_char, c_int, c_uchar, c_uint, c_ulong, c_void}; 7 | 8 | use super::xlib::{ 9 | Display, Screen, XColor, XComposeStatus, XErrorEvent, XEvent, XKeyEvent, XSizeHints, 10 | XStandardColormap, XVisualInfo, XrmValue, GC, 11 | }; 12 | use super::xt::{Widget, XtAppContext}; 13 | 14 | // 15 | // functions 16 | // 17 | 18 | x11_link! { Xmu, xmu, ["libXmu.so.6", "libXmu.so"], 132, 19 | pub fn XmuAddCloseDisplayHook (_3: *mut Display, _2: Option c_int>, _1: *mut c_char) -> *mut c_char, 20 | pub fn XmuAddInitializer (_2: Option, _1: *mut c_char) -> (), 21 | pub fn XmuAllStandardColormaps (_1: *mut Display) -> c_int, 22 | pub fn XmuAppendSegment (_2: *mut XmuSegment, _1: *mut XmuSegment) -> c_int, 23 | pub fn XmuAreaAnd (_2: *mut XmuArea, _1: *mut XmuArea) -> *mut XmuArea, 24 | pub fn XmuAreaCopy (_2: *mut XmuArea, _1: *mut XmuArea) -> *mut XmuArea, 25 | pub fn XmuAreaDup (_1: *mut XmuArea) -> *mut XmuArea, 26 | pub fn XmuAreaNot (_5: *mut XmuArea, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> *mut XmuArea, 27 | pub fn XmuAreaOrXor (_3: *mut XmuArea, _2: *mut XmuArea, _1: c_int) -> *mut XmuArea, 28 | pub fn XmuCallInitializers (_1: XtAppContext) -> (), 29 | pub fn XmuClientWindow (_2: *mut Display, _1: c_ulong) -> c_ulong, 30 | pub fn XmuCompareISOLatin1 (_2: *const c_char, _1: *const c_char) -> c_int, 31 | pub fn XmuConvertStandardSelection (_8: Widget, _7: c_ulong, _6: *mut c_ulong, _5: *mut c_ulong, _4: *mut c_ulong, _3: *mut *mut c_char, _2: *mut c_ulong, _1: *mut c_int) -> c_char, 32 | pub fn XmuCopyISOLatin1Lowered (_2: *mut c_char, _1: *const c_char) -> (), 33 | pub fn XmuCopyISOLatin1Uppered (_2: *mut c_char, _1: *const c_char) -> (), 34 | pub fn XmuCreateColormap (_2: *mut Display, _1: *mut XStandardColormap) -> c_int, 35 | pub fn XmuCreatePixmapFromBitmap (_8: *mut Display, _7: c_ulong, _6: c_ulong, _5: c_uint, _4: c_uint, _3: c_uint, _2: c_ulong, _1: c_ulong) -> c_ulong, 36 | pub fn XmuCreateStippledPixmap (_4: *mut Screen, _3: c_ulong, _2: c_ulong, _1: c_uint) -> c_ulong, 37 | pub fn XmuCursorNameToIndex (_1: *const c_char) -> c_int, 38 | pub fn XmuCvtBackingStoreToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, 39 | pub fn XmuCvtFunctionToCallback (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), 40 | pub fn XmuCvtGravityToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, 41 | pub fn XmuCvtJustifyToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, 42 | pub fn XmuCvtLongToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, 43 | pub fn XmuCvtOrientationToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, 44 | pub fn XmuCvtShapeStyleToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, 45 | pub fn XmuCvtStringToBackingStore (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), 46 | pub fn XmuCvtStringToBitmap (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), 47 | pub fn XmuCvtStringToColorCursor (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, 48 | pub fn XmuCvtStringToCursor (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), 49 | pub fn XmuCvtStringToGravity (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), 50 | pub fn XmuCvtStringToJustify (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), 51 | pub fn XmuCvtStringToLong (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), 52 | pub fn XmuCvtStringToOrientation (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), 53 | pub fn XmuCvtStringToShapeStyle (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, 54 | pub fn XmuCvtStringToWidget (_4: *mut XrmValue, _3: *mut c_uint, _2: *mut XrmValue, _1: *mut XrmValue) -> (), 55 | pub fn XmuCvtWidgetToString (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, 56 | pub fn XmuDeleteStandardColormap (_3: *mut Display, _2: c_int, _1: c_ulong) -> (), 57 | pub fn XmuDestroyScanlineList (_1: *mut XmuScanline) -> (), 58 | pub fn XmuDestroySegmentList (_1: *mut XmuSegment) -> (), 59 | pub fn XmuDistinguishableColors (_2: *mut XColor, _1: c_int) -> c_int, 60 | pub fn XmuDistinguishablePixels (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: c_int) -> c_int, 61 | pub fn XmuDQAddDisplay (_3: *mut XmuDisplayQueue, _2: *mut Display, _1: *mut c_char) -> *mut XmuDisplayQueueEntry, 62 | pub fn XmuDQCreate (_3: Option c_int>, _2: Option c_int>, _1: *mut c_char) -> *mut XmuDisplayQueue, 63 | pub fn XmuDQDestroy (_2: *mut XmuDisplayQueue, _1: c_int) -> c_int, 64 | pub fn XmuDQLookupDisplay (_2: *mut XmuDisplayQueue, _1: *mut Display) -> *mut XmuDisplayQueueEntry, 65 | pub fn XmuDQRemoveDisplay (_2: *mut XmuDisplayQueue, _1: *mut Display) -> c_int, 66 | pub fn XmuDrawLogo (_8: *mut Display, _7: c_ulong, _6: GC, _5: GC, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> (), 67 | pub fn XmuDrawRoundedRectangle (_9: *mut Display, _8: c_ulong, _7: GC, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> (), 68 | pub fn XmuFillRoundedRectangle (_9: *mut Display, _8: c_ulong, _7: GC, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> (), 69 | pub fn XmuGetAtomName (_2: *mut Display, _1: c_ulong) -> *mut c_char, 70 | pub fn XmuGetColormapAllocation (_5: *mut XVisualInfo, _4: c_ulong, _3: *mut c_ulong, _2: *mut c_ulong, _1: *mut c_ulong) -> c_int, 71 | pub fn XmuGetHostname (_2: *mut c_char, _1: c_int) -> c_int, 72 | pub fn XmuInternAtom (_2: *mut Display, _1: AtomPtr) -> c_ulong, 73 | pub fn XmuInternStrings (_4: *mut Display, _3: *mut *mut c_char, _2: c_uint, _1: *mut c_ulong) -> (), 74 | pub fn XmuLocateBitmapFile (_8: *mut Screen, _7: *const c_char, _6: *mut c_char, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_ulong, 75 | pub fn XmuLocatePixmapFile (_11: *mut Screen, _10: *const c_char, _9: c_ulong, _8: c_ulong, _7: c_uint, _6: *mut c_char, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_ulong, 76 | pub fn XmuLookupAPL (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, 77 | pub fn XmuLookupArabic (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, 78 | pub fn XmuLookupCloseDisplayHook (_4: *mut Display, _3: *mut c_char, _2: Option c_int>, _1: *mut c_char) -> c_int, 79 | pub fn XmuLookupCyrillic (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, 80 | pub fn XmuLookupGreek (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, 81 | pub fn XmuLookupHebrew (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, 82 | pub fn XmuLookupJISX0201 (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, 83 | pub fn XmuLookupKana (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, 84 | pub fn XmuLookupLatin1 (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, 85 | pub fn XmuLookupLatin2 (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, 86 | pub fn XmuLookupLatin3 (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, 87 | pub fn XmuLookupLatin4 (_5: *mut XKeyEvent, _4: *mut c_uchar, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int, 88 | pub fn XmuLookupStandardColormap (_7: *mut Display, _6: c_int, _5: c_ulong, _4: c_uint, _3: c_ulong, _2: c_int, _1: c_int) -> c_int, 89 | pub fn XmuLookupString (_6: *mut XKeyEvent, _5: *mut c_uchar, _4: c_int, _3: *mut c_ulong, _2: *mut XComposeStatus, _1: c_ulong) -> c_int, 90 | pub fn XmuMakeAtom (_1: *const c_char) -> AtomPtr, 91 | pub fn XmuNameOfAtom (_1: AtomPtr) -> *mut c_char, 92 | pub fn XmuNCopyISOLatin1Lowered (_3: *mut c_char, _2: *const c_char, _1: c_int) -> (), 93 | pub fn XmuNCopyISOLatin1Uppered (_3: *mut c_char, _2: *const c_char, _1: c_int) -> (), 94 | pub fn XmuNewArea (_4: c_int, _3: c_int, _2: c_int, _1: c_int) -> *mut XmuArea, 95 | pub fn XmuNewCvtStringToWidget (_6: *mut Display, _5: *mut XrmValue, _4: *mut c_uint, _3: *mut XrmValue, _2: *mut XrmValue, _1: *mut *mut c_void) -> c_char, 96 | pub fn XmuNewScanline (_3: c_int, _2: c_int, _1: c_int) -> *mut XmuScanline, 97 | pub fn XmuNewSegment (_2: c_int, _1: c_int) -> *mut XmuSegment, 98 | pub fn XmuOptimizeArea (_1: *mut XmuArea) -> *mut XmuArea, 99 | pub fn XmuOptimizeScanline (_1: *mut XmuScanline) -> *mut XmuScanline, 100 | pub fn XmuPrintDefaultErrorMessage (_3: *mut Display, _2: *mut XErrorEvent, _1: *mut FILE) -> c_int, 101 | pub fn XmuReadBitmapData (_6: *mut FILE, _5: *mut c_uint, _4: *mut c_uint, _3: *mut *mut c_uchar, _2: *mut c_int, _1: *mut c_int) -> c_int, 102 | pub fn XmuReadBitmapDataFromFile (_6: *const c_char, _5: *mut c_uint, _4: *mut c_uint, _3: *mut *mut c_uchar, _2: *mut c_int, _1: *mut c_int) -> c_int, 103 | pub fn XmuRegisterExternalAgent (_4: Widget, _3: *mut c_void, _2: *mut XEvent, _1: *mut c_char) -> (), 104 | pub fn XmuReleaseStippledPixmap (_2: *mut Screen, _1: c_ulong) -> (), 105 | pub fn XmuRemoveCloseDisplayHook (_4: *mut Display, _3: *mut c_char, _2: Option c_int>, _1: *mut c_char) -> c_int, 106 | pub fn XmuReshapeWidget (_4: Widget, _3: c_int, _2: c_int, _1: c_int) -> c_char, 107 | pub fn XmuScanlineAnd (_2: *mut XmuScanline, _1: *mut XmuScanline) -> *mut XmuScanline, 108 | pub fn XmuScanlineAndSegment (_2: *mut XmuScanline, _1: *mut XmuSegment) -> *mut XmuScanline, 109 | pub fn XmuScanlineCopy (_2: *mut XmuScanline, _1: *mut XmuScanline) -> *mut XmuScanline, 110 | pub fn XmuScanlineEqu (_2: *mut XmuScanline, _1: *mut XmuScanline) -> c_int, 111 | pub fn XmuScanlineNot (_3: *mut XmuScanline, _2: c_int, _1: c_int) -> *mut XmuScanline, 112 | pub fn XmuScanlineOr (_2: *mut XmuScanline, _1: *mut XmuScanline) -> *mut XmuScanline, 113 | pub fn XmuScanlineOrSegment (_2: *mut XmuScanline, _1: *mut XmuSegment) -> *mut XmuScanline, 114 | pub fn XmuScanlineXor (_2: *mut XmuScanline, _1: *mut XmuScanline) -> *mut XmuScanline, 115 | pub fn XmuScanlineXorSegment (_2: *mut XmuScanline, _1: *mut XmuSegment) -> *mut XmuScanline, 116 | pub fn XmuScreenOfWindow (_2: *mut Display, _1: c_ulong) -> *mut Screen, 117 | pub fn XmuSimpleErrorHandler (_2: *mut Display, _1: *mut XErrorEvent) -> c_int, 118 | pub fn XmuStandardColormap (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_uint, _5: c_ulong, _4: c_ulong, _3: c_ulong, _2: c_ulong, _1: c_ulong) -> *mut XStandardColormap, 119 | pub fn XmuUpdateMapHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints) -> c_int, 120 | pub fn XmuValidArea (_1: *mut XmuArea) -> c_int, 121 | pub fn XmuValidScanline (_1: *mut XmuScanline) -> c_int, 122 | pub fn XmuVisualStandardColormaps (_6: *mut Display, _5: c_int, _4: c_ulong, _3: c_uint, _2: c_int, _1: c_int) -> c_int, 123 | pub fn XmuWnCountOwnedResources (_3: *mut XmuWidgetNode, _2: *mut XmuWidgetNode, _1: c_int) -> c_int, 124 | pub fn XmuWnFetchResources (_3: *mut XmuWidgetNode, _2: Widget, _1: *mut XmuWidgetNode) -> (), 125 | pub fn XmuWnInitializeNodes (_2: *mut XmuWidgetNode, _1: c_int) -> (), 126 | pub fn XmuWnNameToNode (_3: *mut XmuWidgetNode, _2: c_int, _1: *const c_char) -> *mut XmuWidgetNode, 127 | variadic: 128 | pub fn XmuSnprintf (_3: *mut c_char, _2: c_int, _1: *const c_char) -> c_int, 129 | globals: 130 | pub static _XA_ATOM_PAIR: AtomPtr, 131 | pub static _XA_CHARACTER_POSITION: AtomPtr, 132 | pub static _XA_CLASS: AtomPtr, 133 | pub static _XA_CLIENT_WINDOW: AtomPtr, 134 | pub static _XA_CLIPBOARD: AtomPtr, 135 | pub static _XA_COMPOUND_TEXT: AtomPtr, 136 | pub static _XA_DECNET_ADDRESS: AtomPtr, 137 | pub static _XA_DELETE: AtomPtr, 138 | pub static _XA_FILENAME: AtomPtr, 139 | pub static _XA_HOSTNAME: AtomPtr, 140 | pub static _XA_IP_ADDRESS: AtomPtr, 141 | pub static _XA_LENGTH: AtomPtr, 142 | pub static _XA_LIST_LENGTH: AtomPtr, 143 | pub static _XA_NAME: AtomPtr, 144 | pub static _XA_NET_ADDRESS: AtomPtr, 145 | pub static _XA_NULL: AtomPtr, 146 | pub static _XA_OWNER_OS: AtomPtr, 147 | pub static _XA_SPAN: AtomPtr, 148 | pub static _XA_TARGETS: AtomPtr, 149 | pub static _XA_TEXT: AtomPtr, 150 | pub static _XA_TIMESTAMP: AtomPtr, 151 | pub static _XA_USER: AtomPtr, 152 | pub static _XA_UTF8_STRING: AtomPtr, 153 | } 154 | 155 | // 156 | // types 157 | // 158 | 159 | // TODO structs 160 | #[repr(C)] 161 | pub struct _AtomRec; 162 | #[repr(C)] 163 | pub struct _XmuArea; 164 | #[repr(C)] 165 | pub struct _XmuDisplayQueue; 166 | #[repr(C)] 167 | pub struct _XmuDisplayQueueEntry; 168 | #[repr(C)] 169 | pub struct _XmuScanline; 170 | #[repr(C)] 171 | pub struct _XmuSegment; 172 | #[repr(C)] 173 | pub struct _XmuWidgetNode; 174 | 175 | // struct typedefs 176 | pub type AtomPtr = *mut _AtomRec; 177 | pub type XmuArea = _XmuArea; 178 | pub type XmuDisplayQueue = _XmuDisplayQueue; 179 | pub type XmuDisplayQueueEntry = _XmuDisplayQueueEntry; 180 | pub type XmuScanline = _XmuScanline; 181 | pub type XmuSegment = _XmuSegment; 182 | pub type XmuWidgetNode = _XmuWidgetNode; 183 | -------------------------------------------------------------------------------- /src/xpresent.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::{c_int, c_long, c_uint, c_ulong}; 6 | 7 | use crate::sync::XSyncFence; 8 | use crate::xfixes::XserverRegion; 9 | use crate::xlib::{Bool, Display, Pixmap, Status, Window, XID}; 10 | use crate::xrandr::RRCrtc; 11 | 12 | // 13 | // functions 14 | // 15 | 16 | x11_link! { Xpresent, xpresent, ["libXpresent.so.1.0.0", "libXpresent.so"], 8, 17 | pub fn XPresentQueryExtension( dpy: *mut Display, major_opcode_return: *mut c_int, event_base_return: *mut c_int, error_base_return: *mut c_int) -> Bool, 18 | pub fn XPresentQueryVersion( dpy: *mut Display, major_version_return: *mut c_int, minor_version_return: *mut c_int ) -> Status, 19 | pub fn XPresentVersion() -> c_int, 20 | pub fn XPresentPixmap( dpy: *mut Display, window: Window, pixmap: Pixmap, serial: u32, valid: XserverRegion, update: XserverRegion, x_off: c_int, y_off: c_int, target_crtc: RRCrtc, wait_fence: XSyncFence, idle_fence: XSyncFence, options: u32, target_msc: u64, divisor: u64, remainder: u64, notifies: *mut XPresentNotify, nnotifies: c_int ) -> (), 21 | pub fn XPresentNotifyMSC( dpy: *mut Display, window: Window, serial: u32, target_msc: u64, divisor: u64, remainder: u64 ) -> (), 22 | pub fn XPresentSelectInput( dpy: *mut Display, window: Window, event_mask: c_uint ) -> XID, 23 | pub fn XPresentFreeInput(dpy: *mut Display, window: Window, event_id: XID) -> (), 24 | pub fn XPresentQueryCapabilities(dpy: *mut Display, target: XID) -> u32, 25 | variadic: 26 | globals: 27 | } 28 | 29 | // 30 | // Types 31 | // 32 | 33 | #[repr(C)] 34 | #[derive(Debug, Copy, Clone)] 35 | pub struct XPresentNotify { 36 | pub window: Window, 37 | pub serial: u32, 38 | } 39 | 40 | #[repr(C)] 41 | #[derive(Debug, Copy, Clone)] 42 | pub struct XPresentEvent { 43 | pub type_: c_int, 44 | pub serial: c_ulong, 45 | pub send_event: Bool, 46 | pub display: *mut Display, 47 | pub extension: c_int, 48 | pub evtype: c_int, 49 | } 50 | 51 | #[repr(C)] 52 | #[derive(Debug, Copy, Clone)] 53 | pub struct XPresentIdleNotifyEvent { 54 | pub type_: c_int, 55 | pub serial: c_ulong, 56 | pub send_event: c_int, 57 | pub display: *mut Display, 58 | pub extension: c_int, 59 | pub evtype: c_int, 60 | pub eid: u32, 61 | pub window: Window, 62 | pub serial_number: u32, 63 | pub pixmap: Pixmap, 64 | pub idle_fence: XSyncFence, 65 | } 66 | 67 | #[repr(C)] 68 | #[derive(Debug, Copy, Clone)] 69 | pub struct XPresentCompleteNotifyEvent { 70 | pub type_: c_int, 71 | pub serial: c_ulong, 72 | pub send_event: Bool, 73 | pub display: *mut Display, 74 | pub extension: c_int, 75 | pub evtype: c_int, 76 | pub eid: u32, 77 | pub window: Window, 78 | pub serial_number: u32, 79 | pub ust: u64, 80 | pub msc: u64, 81 | pub kind: u8, 82 | pub mode: u8, 83 | } 84 | 85 | #[repr(C)] 86 | #[derive(Debug, Copy, Clone)] 87 | pub struct XPresentConfigureNotifyEvent { 88 | pub type_: c_int, 89 | pub serial: c_ulong, 90 | pub send_event: Bool, 91 | pub display: *mut Display, 92 | pub extension: c_int, 93 | pub evtype: c_int, 94 | pub eid: u32, 95 | pub window: Window, 96 | pub x: c_int, 97 | pub y: c_int, 98 | pub width: c_uint, 99 | pub height: c_uint, 100 | pub off_x: c_int, 101 | pub off_y: c_int, 102 | pub pixmap_width: c_int, 103 | pub pixmap_height: c_int, 104 | pub pixmap_flags: c_long, 105 | } 106 | 107 | // 108 | // constants 109 | // 110 | 111 | pub const PRESENT_NAME: &str = "Present"; 112 | pub const PRESENT_MAJOR: c_int = 1; 113 | pub const PRESENT_MINOR: c_int = 2; 114 | 115 | pub const PRESENT_REVISION: c_int = 0; 116 | pub const PRESENT_VERSION: c_int = PRESENT_MAJOR * 10000 + PRESENT_MINOR * 100 + PRESENT_REVISION; 117 | 118 | pub const PresentNumberErrors: c_int = 0; 119 | pub const PresentNumberEvents: c_int = 0; 120 | 121 | pub const X_PresentQueryVersion: c_int = 0; 122 | pub const X_PresentPixmap: c_int = 1; 123 | pub const X_PresentNotifyMSC: c_int = 2; 124 | pub const X_PresentSelectInput: c_int = 3; 125 | pub const X_PresentQueryCapabilities: c_int = 4; 126 | 127 | pub const PresentNumberRequests: c_int = 5; 128 | 129 | pub const PresentOptionNone: c_int = 0; 130 | pub const PresentOptionAsync: c_int = 1; 131 | pub const PresentOptionCopy: c_int = 2; 132 | pub const PresentOptionUST: c_int = 4; 133 | pub const PresentOptionSuboptimal: c_int = 8; 134 | 135 | pub const PresentAllOptions: c_int = PresentOptionNone 136 | | PresentOptionAsync 137 | | PresentOptionCopy 138 | | PresentOptionUST 139 | | PresentOptionSuboptimal; 140 | 141 | pub const PresentCapabilityNone: c_int = 0; 142 | pub const PresentCapabilityAsync: c_int = 1; 143 | pub const PresentCapabilityFence: c_int = 2; 144 | pub const PresentCapabilityUST: c_int = 4; 145 | 146 | pub const PresentAllCapabilities: c_int = 147 | PresentCapabilityAsync | PresentCapabilityFence | PresentCapabilityUST; 148 | 149 | pub const PresentConfigureNotify: c_int = 0; 150 | pub const PresentCompleteNotify: c_int = 1; 151 | pub const PresentIdleNotify: c_int = 2; 152 | 153 | pub const PresentConfigureNotifyMask: c_int = 1; 154 | pub const PresentCompleteNotifyMask: c_int = 2; 155 | pub const PresentIdleNotifyMask: c_int = 4; 156 | 157 | pub const PresentAllEvents: c_int = 158 | PresentConfigureNotifyMask | PresentCompleteNotify | PresentIdleNotifyMask; 159 | 160 | pub const PresentCompleteKindPixmap: c_int = 0; 161 | pub const PresentCompleteKindNotifyMSC: c_int = 1; 162 | 163 | pub const PresentCompleteModeCopy: c_int = 0; 164 | pub const PresentCompleteModeFlip: c_int = 1; 165 | pub const PresentCompleteModeSkip: c_int = 2; 166 | pub const PresentCompleteModeSuboptimalCopy: c_int = 3; 167 | -------------------------------------------------------------------------------- /src/xrandr.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::{c_char, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort}; 6 | 7 | use super::xlib::{Atom, Bool, Display, Drawable, Status, Time, Window, XEvent, XID}; 8 | use super::xrender::{XFixed, XTransform}; 9 | 10 | // 11 | // functions 12 | // 13 | 14 | x11_link! { Xrandr, xrandr, ["libXrandr.so.2", "libXrandr.so"], 70, 15 | pub fn XRRAddOutputMode (dpy: *mut Display, output: RROutput, mode: RRMode) -> (), 16 | pub fn XRRAllocGamma (size: c_int) -> *mut XRRCrtcGamma, 17 | pub fn XRRAllocModeInfo (name: *const c_char, nameLength: c_int) -> *mut XRRModeInfo, 18 | pub fn XRRAllocateMonitor (dpy: *mut Display, noutput: c_int) -> *mut XRRMonitorInfo, 19 | pub fn XRRChangeOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, type_: Atom, format: c_int, mode: c_int, data: *const c_uchar, nelements: c_int) -> (), 20 | pub fn XRRChangeProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, type_: Atom, format: c_int, mode: c_int, data: *const c_uchar, nelements: c_int) -> (), 21 | pub fn XRRConfigCurrentConfiguration (config: *mut XRRScreenConfiguration, rotation: *mut Rotation) -> SizeID, 22 | pub fn XRRConfigCurrentRate (config: *mut XRRScreenConfiguration) -> c_short, 23 | pub fn XRRConfigRates (config: *mut XRRScreenConfiguration, sizeID: c_int, nrates: *mut c_int) -> *mut c_short, 24 | pub fn XRRConfigRotations (config: *mut XRRScreenConfiguration, current_rotation: *mut Rotation) -> Rotation, 25 | pub fn XRRConfigSizes (config: *mut XRRScreenConfiguration, nsizes: *mut c_int) -> *mut XRRScreenSize, 26 | pub fn XRRConfigTimes (config: *mut XRRScreenConfiguration, config_timestamp: *mut Time) -> Time, 27 | pub fn XRRConfigureOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, pending: Bool, range: Bool, num_values: c_int, values: *mut c_long) -> (), 28 | pub fn XRRConfigureProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, pending: Bool, range: Bool, num_values: c_int, values: *mut c_long) -> (), 29 | pub fn XRRCreateMode (dpy: *mut Display, window: Window, modeInfo: *mut XRRModeInfo) -> RRMode, 30 | pub fn XRRDeleteMonitor (dpy: *mut Display, window: Window, name: Atom) -> (), 31 | pub fn XRRDeleteOutputMode (dpy: *mut Display, output: RROutput, mode: RRMode) -> (), 32 | pub fn XRRDeleteOutputProperty (dpy: *mut Display, output: RROutput, property: Atom) -> (), 33 | pub fn XRRDeleteProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom) -> (), 34 | pub fn XRRDestroyMode (dpy: *mut Display, mode: RRMode) -> (), 35 | pub fn XRRFreeCrtcInfo (crtcInfo: *mut XRRCrtcInfo) -> (), 36 | pub fn XRRFreeGamma (gamma: *mut XRRCrtcGamma) -> (), 37 | pub fn XRRFreeModeInfo (modeInfo: *mut XRRModeInfo) -> (), 38 | pub fn XRRFreeMonitors (monitors: *mut XRRMonitorInfo) -> (), 39 | pub fn XRRFreeOutputInfo (outputInfo: *mut XRROutputInfo) -> (), 40 | pub fn XRRFreePanning (panning: *mut XRRPanning) -> (), 41 | pub fn XRRFreeProviderInfo (provider: *mut XRRProviderInfo) -> (), 42 | pub fn XRRFreeProviderResources (resources: *mut XRRProviderResources) -> (), 43 | pub fn XRRFreeScreenConfigInfo (config: *mut XRRScreenConfiguration) -> (), 44 | pub fn XRRFreeScreenResources (resources: *mut XRRScreenResources) -> (), 45 | pub fn XRRGetCrtcGamma (dpy: *mut Display, crtc: RRCrtc) -> *mut XRRCrtcGamma, 46 | pub fn XRRGetCrtcGammaSize (dpy: *mut Display, crtc: RRCrtc) -> c_int, 47 | pub fn XRRGetCrtcInfo (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc) -> *mut XRRCrtcInfo, 48 | pub fn XRRGetCrtcTransform (dpy: *mut Display, crtc: RRCrtc, attributes: *mut *mut XRRCrtcTransformAttributes) -> Status, 49 | pub fn XRRGetMonitors (dpy: *mut Display, window: Window, get_active: Bool, nmonitors: *mut c_int) -> *mut XRRMonitorInfo, 50 | pub fn XRRGetOutputInfo (dpy: *mut Display, resources: *mut XRRScreenResources, output: RROutput) -> *mut XRROutputInfo, 51 | pub fn XRRGetOutputPrimary (dpy: *mut Display, window: Window) -> RROutput, 52 | pub fn XRRGetOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, offset: c_long, length: c_long, _delete: Bool, pending: Bool, req_type: Atom, actual_type: *mut Atom, actual_format: *mut c_int, nitems: *mut c_ulong, bytes_after: *mut c_ulong, prop: *mut *mut c_uchar) -> c_int, 53 | pub fn XRRGetPanning (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc) -> *mut XRRPanning, 54 | pub fn XRRGetProviderInfo (dpy: *mut Display, resources: *mut XRRScreenResources, provider: RRProvider) -> *mut XRRProviderInfo, 55 | pub fn XRRGetProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, offset: c_long, length: c_long, _delete: Bool, pending: Bool, req_type: Atom, actual_type: *mut Atom, actual_format: *mut c_int, nitems: *mut c_ulong, bytes_after: *mut c_ulong, prop: *mut *mut c_uchar) -> c_int, 56 | pub fn XRRGetProviderResources (dpy: *mut Display, window: Window) -> *mut XRRProviderResources, 57 | pub fn XRRGetScreenInfo (dpy: *mut Display, window: Window) -> *mut XRRScreenConfiguration, 58 | pub fn XRRGetScreenResources (dpy: *mut Display, window: Window) -> *mut XRRScreenResources, 59 | pub fn XRRGetScreenResourcesCurrent (dpy: *mut Display, window: Window) -> *mut XRRScreenResources, 60 | pub fn XRRGetScreenSizeRange (dpy: *mut Display, window: Window, minWidth: *mut c_int, minHeight: *mut c_int, maxWidth: *mut c_int, maxHeight: *mut c_int) -> Status, 61 | pub fn XRRListOutputProperties (dpy: *mut Display, output: RROutput, nprop: *mut c_int) -> *mut Atom, 62 | pub fn XRRListProviderProperties (dpy: *mut Display, provider: RRProvider, nprop: *mut c_int) -> *mut Atom, 63 | pub fn XRRQueryExtension (dpy: *mut Display, event_base_return: *mut c_int, error_base_return: *mut c_int) -> Bool, 64 | pub fn XRRQueryOutputProperty (dpy: *mut Display, output: RROutput, property: Atom) -> *mut XRRPropertyInfo, 65 | pub fn XRRQueryProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom) -> *mut XRRPropertyInfo, 66 | pub fn XRRQueryVersion (dpy: *mut Display, major_version_return: *mut c_int, minor_version_return: *mut c_int) -> Status, 67 | pub fn XRRRates (dpy: *mut Display, screen: c_int, sizeID: c_int, nrates: *mut c_int) -> *mut c_short, 68 | pub fn XRRRootToScreen (dpy: *mut Display, root: Window) -> c_int, 69 | pub fn XRRRotations (dpy: *mut Display, screen: c_int, current_rotation: *mut Rotation) -> Rotation, 70 | pub fn XRRSelectInput (dpy: *mut Display, window: Window, mask: c_int) -> (), 71 | pub fn XRRSetCrtcConfig (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc, timestamp: Time, x: c_int, y: c_int, mode: RRMode, rotation: Rotation, outputs: *mut RROutput, noutputs: c_int) -> Status, 72 | pub fn XRRSetCrtcGamma (dpy: *mut Display, crtc: RRCrtc, gamma: *mut XRRCrtcGamma) -> (), 73 | pub fn XRRSetCrtcTransform (dpy: *mut Display, crtc: RRCrtc, transform: *mut XTransform, filter: *const c_char, params: *mut XFixed, nparams: c_int) -> (), 74 | pub fn XRRSetMonitor (dpy: *mut Display, window: Window, monitor: *mut XRRMonitorInfo) -> (), 75 | pub fn XRRSetOutputPrimary (dpy: *mut Display, window: Window, output: RROutput) -> (), 76 | pub fn XRRSetPanning (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc, panning: *mut XRRPanning) -> Status, 77 | pub fn XRRSetProviderOffloadSink (dpy: *mut Display, provider: XID, sink_provider: XID) -> c_int, 78 | pub fn XRRSetProviderOutputSource (dpy: *mut Display, provider: XID, source_provider: XID) -> c_int, 79 | pub fn XRRSetScreenConfig (dpy: *mut Display, config: *mut XRRScreenConfiguration, draw: Drawable, size_index: c_int, rotation: Rotation, timestamp: Time) -> Status, 80 | pub fn XRRSetScreenConfigAndRate (dpy: *mut Display, config: *mut XRRScreenConfiguration, draw: Drawable, size_index: c_int, rotation: Rotation, rate: c_short, timestamp: Time) -> Status, 81 | pub fn XRRSetScreenSize (dpy: *mut Display, window: Window, width: c_int, height: c_int, mmWidth: c_int, mmHeight: c_int) -> (), 82 | pub fn XRRSizes (dpy: *mut Display, screen: c_int, nsizes: *mut c_int) -> *mut XRRScreenSize, 83 | pub fn XRRTimes (dpy: *mut Display, screen: c_int, config_timestamp: *mut Time) -> Time, 84 | pub fn XRRUpdateConfiguration (event: *mut XEvent) -> c_int, 85 | variadic: 86 | globals: 87 | } 88 | 89 | // 90 | // types 91 | // 92 | 93 | pub type Connection = c_ushort; 94 | pub type Rotation = c_ushort; 95 | pub type SizeID = c_ushort; 96 | pub type SubpixelOrder = c_ushort; 97 | 98 | pub type RROutput = XID; 99 | pub type RRCrtc = XID; 100 | pub type RRMode = XID; 101 | pub type RRProvider = XID; 102 | 103 | #[derive(Debug, Clone, Copy, PartialEq)] 104 | #[repr(C)] 105 | pub struct XRRScreenSize { 106 | pub width: c_int, 107 | pub height: c_int, 108 | pub mwidth: c_int, 109 | pub mheight: c_int, 110 | } 111 | 112 | #[repr(C)] 113 | pub struct XRRScreenConfiguration; 114 | 115 | pub type XRRModeFlags = c_ulong; 116 | 117 | #[derive(Debug, Clone, Copy, PartialEq)] 118 | #[repr(C)] 119 | pub struct XRRModeInfo { 120 | pub id: RRMode, 121 | pub width: c_uint, 122 | pub height: c_uint, 123 | pub dotClock: c_ulong, 124 | pub hSyncStart: c_uint, 125 | pub hSyncEnd: c_uint, 126 | pub hTotal: c_uint, 127 | pub hSkew: c_uint, 128 | pub vSyncStart: c_uint, 129 | pub vSyncEnd: c_uint, 130 | pub vTotal: c_uint, 131 | pub name: *mut c_char, 132 | pub nameLength: c_uint, 133 | pub modeFlags: XRRModeFlags, 134 | } 135 | 136 | #[derive(Debug, Clone, Copy, PartialEq)] 137 | #[repr(C)] 138 | pub struct XRRScreenResources { 139 | pub timestamp: Time, 140 | pub configTimestamp: Time, 141 | pub ncrtc: c_int, 142 | pub crtcs: *mut RRCrtc, 143 | pub noutput: c_int, 144 | pub outputs: *mut RROutput, 145 | pub nmode: c_int, 146 | pub modes: *mut XRRModeInfo, 147 | } 148 | 149 | #[derive(Debug, Clone, Copy, PartialEq)] 150 | #[repr(C)] 151 | pub struct XRROutputInfo { 152 | pub timestamp: Time, 153 | pub crtc: RRCrtc, 154 | pub name: *mut c_char, 155 | pub nameLen: c_int, 156 | pub mm_width: c_ulong, 157 | pub mm_height: c_ulong, 158 | pub connection: Connection, 159 | pub subpixel_order: SubpixelOrder, 160 | pub ncrtc: c_int, 161 | pub crtcs: *mut RRCrtc, 162 | pub nclone: c_int, 163 | pub clones: *mut RROutput, 164 | pub nmode: c_int, 165 | pub npreferred: c_int, 166 | pub modes: *mut RRMode, 167 | } 168 | 169 | #[derive(Debug, Clone, Copy, PartialEq)] 170 | #[repr(C)] 171 | pub struct XRRPropertyInfo { 172 | pub pending: Bool, 173 | pub range: Bool, 174 | pub immutable: Bool, 175 | pub num_values: c_int, 176 | pub values: *mut c_long, 177 | } 178 | 179 | #[derive(Debug, Clone, Copy, PartialEq)] 180 | #[repr(C)] 181 | pub struct XRRCrtcInfo { 182 | pub timestamp: Time, 183 | pub x: c_int, 184 | pub y: c_int, 185 | pub width: c_uint, 186 | pub height: c_uint, 187 | pub mode: RRMode, 188 | pub rotation: Rotation, 189 | pub noutput: c_int, 190 | pub outputs: *mut RROutput, 191 | pub rotations: Rotation, 192 | pub npossible: c_int, 193 | pub possible: *mut RROutput, 194 | } 195 | 196 | #[derive(Debug, Clone, Copy, PartialEq)] 197 | #[repr(C)] 198 | pub struct XRRCrtcGamma { 199 | pub size: c_int, 200 | pub red: *mut c_ushort, 201 | pub green: *mut c_ushort, 202 | pub blue: *mut c_ushort, 203 | } 204 | 205 | #[derive(Debug, Clone, Copy, PartialEq)] 206 | #[repr(C)] 207 | pub struct XRRCrtcTransformAttributes { 208 | pub pendingTransform: XTransform, 209 | pub pendingFilter: *mut c_char, 210 | pub pendingNparams: c_int, 211 | pub pendingParams: *mut XFixed, 212 | pub currentTransform: XTransform, 213 | pub currentFilter: *mut c_char, 214 | pub currentNparams: c_int, 215 | pub currentParams: *mut XFixed, 216 | } 217 | 218 | #[derive(Debug, Clone, Copy, PartialEq)] 219 | #[repr(C)] 220 | pub struct XRRPanning { 221 | pub timestamp: Time, 222 | pub left: c_uint, 223 | pub top: c_uint, 224 | pub width: c_uint, 225 | pub height: c_uint, 226 | pub track_left: c_uint, 227 | pub track_top: c_uint, 228 | pub track_width: c_uint, 229 | pub track_height: c_uint, 230 | pub border_left: c_int, 231 | pub border_top: c_int, 232 | pub border_right: c_int, 233 | pub border_bottom: c_int, 234 | } 235 | 236 | #[derive(Debug, Clone, Copy, PartialEq)] 237 | #[repr(C)] 238 | pub struct XRRProviderResources { 239 | pub timestamp: Time, 240 | pub nproviders: c_int, 241 | pub providers: *mut RRProvider, 242 | } 243 | 244 | #[derive(Debug, Clone, Copy, PartialEq)] 245 | #[repr(C)] 246 | pub struct XRRProviderInfo { 247 | pub capabilities: c_uint, 248 | pub ncrtcs: c_int, 249 | pub crtcs: *mut RRCrtc, 250 | pub noutputs: c_int, 251 | pub outputs: *mut RROutput, 252 | pub name: *mut c_char, 253 | pub nassociatedproviders: c_int, 254 | pub associated_providers: *mut RRProvider, 255 | pub associated_capability: *mut c_uint, 256 | pub nameLen: c_int, 257 | } 258 | 259 | #[derive(Debug, Clone, Copy, PartialEq)] 260 | #[repr(C)] 261 | pub struct XRRMonitorInfo { 262 | pub name: Atom, 263 | pub primary: Bool, 264 | pub automatic: Bool, 265 | pub noutput: c_int, 266 | pub x: c_int, 267 | pub y: c_int, 268 | pub width: c_int, 269 | pub height: c_int, 270 | pub mwidth: c_int, 271 | pub mheight: c_int, 272 | pub outputs: *mut RROutput, 273 | } 274 | 275 | // 276 | // event structures 277 | // 278 | 279 | #[derive(Debug, Clone, Copy, PartialEq)] 280 | #[repr(C)] 281 | pub struct XRRScreenChangeNotifyEvent { 282 | pub type_: c_int, 283 | pub serial: c_ulong, 284 | pub send_event: Bool, 285 | pub display: *mut Display, 286 | pub window: Window, 287 | pub root: Window, 288 | pub timestamp: Time, 289 | pub config_timestamp: Time, 290 | pub size_index: SizeID, 291 | pub subpixel_order: SubpixelOrder, 292 | pub rotation: Rotation, 293 | pub width: c_int, 294 | pub height: c_int, 295 | pub mwidth: c_int, 296 | pub mheight: c_int, 297 | } 298 | 299 | #[derive(Debug, Clone, Copy, PartialEq)] 300 | #[repr(C)] 301 | pub struct XRRNotifyEvent { 302 | pub type_: c_int, 303 | pub serial: c_ulong, 304 | pub send_event: Bool, 305 | pub display: *mut Display, 306 | pub window: Window, 307 | pub subtype: c_int, 308 | } 309 | 310 | #[derive(Debug, Clone, Copy, PartialEq)] 311 | #[repr(C)] 312 | pub struct XRROutputChangeNotifyEvent { 313 | pub type_: c_int, 314 | pub serial: c_ulong, 315 | pub send_event: Bool, 316 | pub display: *mut Display, 317 | pub window: Window, 318 | pub subtype: c_int, 319 | pub output: RROutput, 320 | pub crtc: RRCrtc, 321 | pub mode: RRMode, 322 | pub rotation: Rotation, 323 | pub connection: Connection, 324 | pub subpixel_order: SubpixelOrder, 325 | } 326 | 327 | #[derive(Debug, Clone, Copy, PartialEq)] 328 | #[repr(C)] 329 | pub struct XRRCrtcChangeNotifyEvent { 330 | pub type_: c_int, 331 | pub serial: c_ulong, 332 | pub send_event: Bool, 333 | pub display: *mut Display, 334 | pub window: Window, 335 | pub subtype: c_int, 336 | pub crtc: RRCrtc, 337 | pub mode: RRMode, 338 | pub rotation: Rotation, 339 | pub x: c_int, 340 | pub y: c_int, 341 | pub width: c_uint, 342 | pub height: c_uint, 343 | } 344 | 345 | #[derive(Debug, Clone, Copy, PartialEq)] 346 | #[repr(C)] 347 | pub struct XRROutputPropertyNotifyEvent { 348 | pub type_: c_int, 349 | pub serial: c_ulong, 350 | pub send_event: Bool, 351 | pub display: *mut Display, 352 | pub window: Window, 353 | pub subtype: c_int, 354 | pub output: RROutput, 355 | pub property: Atom, 356 | pub timestamp: Time, 357 | pub state: c_int, 358 | } 359 | 360 | #[derive(Debug, Clone, Copy, PartialEq)] 361 | #[repr(C)] 362 | pub struct XRRProviderChangeNotifyEvent { 363 | pub type_: c_int, 364 | pub serial: c_ulong, 365 | pub send_event: Bool, 366 | pub display: *mut Display, 367 | pub window: Window, 368 | pub subtype: c_int, 369 | pub provider: RRProvider, 370 | pub timestamp: Time, 371 | pub current_role: c_uint, 372 | } 373 | 374 | #[derive(Debug, Clone, Copy, PartialEq)] 375 | #[repr(C)] 376 | pub struct XRRProviderPropertyNotifyEvent { 377 | pub type_: c_int, 378 | pub serial: c_ulong, 379 | pub send_event: Bool, 380 | pub display: *mut Display, 381 | pub window: Window, 382 | pub subtype: c_int, 383 | pub provider: RRProvider, 384 | pub property: Atom, 385 | pub timestamp: Time, 386 | pub state: c_int, 387 | } 388 | 389 | #[derive(Debug, Clone, Copy, PartialEq)] 390 | #[repr(C)] 391 | pub struct XRRResourceChangeNotifyEvent { 392 | pub type_: c_int, 393 | pub serial: c_ulong, 394 | pub send_event: Bool, 395 | pub display: *mut Display, 396 | pub window: Window, 397 | pub subtype: c_int, 398 | pub timestamp: Time, 399 | } 400 | 401 | event_conversions_and_tests! { 402 | xrr_screen_change_notify: XRRScreenChangeNotifyEvent, 403 | xrr_notify: XRRNotifyEvent, 404 | xrr_output_change_notify: XRROutputChangeNotifyEvent, 405 | xrr_crtc_change_notify: XRRCrtcChangeNotifyEvent, 406 | xrr_output_property_notify: XRROutputPropertyNotifyEvent, 407 | xrr_provider_change_notify: XRRProviderChangeNotifyEvent, 408 | xrr_provider_property_notify: XRRProviderPropertyNotifyEvent, 409 | xrr_resource_change_notify: XRRResourceChangeNotifyEvent, 410 | } 411 | 412 | // 413 | // constants 414 | // 415 | 416 | pub const RANDR_NAME: &str = "RANDR"; 417 | pub const RANDR_MAJOR: c_int = 1; 418 | pub const RANDR_MINOR: c_int = 5; 419 | 420 | pub const RRNumberErrors: c_int = 4; 421 | pub const RRNumberEvents: c_int = 2; 422 | pub const RRNumberRequests: c_int = 45; 423 | 424 | pub const X_RRQueryVersion: c_int = 0; 425 | pub const X_RROldGetScreenInfo: c_int = 1; 426 | pub const X_RRSetScreenConfig: c_int = 2; 427 | pub const X_RROldScreenChangeSelectInput: c_int = 3; 428 | pub const X_RRSelectInput: c_int = 4; 429 | pub const X_RRGetScreenInfo: c_int = 5; 430 | 431 | pub const X_RRGetScreenSizeRange: c_int = 6; 432 | pub const X_RRSetScreenSize: c_int = 7; 433 | pub const X_RRGetScreenResources: c_int = 8; 434 | pub const X_RRGetOutputInfo: c_int = 9; 435 | pub const X_RRListOutputProperties: c_int = 10; 436 | pub const X_RRQueryOutputProperty: c_int = 11; 437 | pub const X_RRConfigureOutputProperty: c_int = 12; 438 | pub const X_RRChangeOutputProperty: c_int = 13; 439 | pub const X_RRDeleteOutputProperty: c_int = 14; 440 | pub const X_RRGetOutputProperty: c_int = 15; 441 | pub const X_RRCreateMode: c_int = 16; 442 | pub const X_RRDestroyMode: c_int = 17; 443 | pub const X_RRAddOutputMode: c_int = 18; 444 | pub const X_RRDeleteOutputMode: c_int = 19; 445 | pub const X_RRGetCrtcInfo: c_int = 20; 446 | pub const X_RRSetCrtcConfig: c_int = 21; 447 | pub const X_RRGetCrtcGammaSize: c_int = 22; 448 | pub const X_RRGetCrtcGamma: c_int = 23; 449 | pub const X_RRSetCrtcGamma: c_int = 24; 450 | 451 | pub const X_RRGetScreenResourcesCurrent: c_int = 25; 452 | pub const X_RRSetCrtcTransform: c_int = 26; 453 | pub const X_RRGetCrtcTransform: c_int = 27; 454 | pub const X_RRGetPanning: c_int = 28; 455 | pub const X_RRSetPanning: c_int = 29; 456 | pub const X_RRSetOutputPrimary: c_int = 30; 457 | pub const X_RRGetOutputPrimary: c_int = 31; 458 | 459 | pub const X_RRGetProviders: c_int = 32; 460 | pub const X_RRGetProviderInfo: c_int = 33; 461 | pub const X_RRSetProviderOffloadSink: c_int = 34; 462 | pub const X_RRSetProviderOutputSource: c_int = 35; 463 | pub const X_RRListProviderProperties: c_int = 36; 464 | pub const X_RRQueryProviderProperty: c_int = 37; 465 | pub const X_RRConfigureProviderProperty: c_int = 38; 466 | pub const X_RRChangeProviderProperty: c_int = 39; 467 | pub const X_RRDeleteProviderProperty: c_int = 40; 468 | pub const X_RRGetProviderProperty: c_int = 41; 469 | 470 | pub const X_RRGetMonitors: c_int = 42; 471 | pub const X_RRSetMonitor: c_int = 43; 472 | pub const X_RRDeleteMonitor: c_int = 44; 473 | 474 | pub const RRTransformUnit: c_int = 1 << 0; 475 | pub const RRTransformScaleUp: c_int = 1 << 1; 476 | pub const RRTransformScaleDown: c_int = 1 << 2; 477 | pub const RRTransformProjective: c_int = 1 << 3; 478 | 479 | pub const RRScreenChangeNotifyMask: c_int = 1 << 0; 480 | pub const RRCrtcChangeNotifyMask: c_int = 1 << 1; 481 | pub const RROutputChangeNotifyMask: c_int = 1 << 2; 482 | pub const RROutputPropertyNotifyMask: c_int = 1 << 3; 483 | pub const RRProviderChangeNotifyMask: c_int = 1 << 4; 484 | pub const RRProviderPropertyNotifyMask: c_int = 1 << 5; 485 | pub const RRResourceChangeNotifyMask: c_int = 1 << 6; 486 | 487 | pub const RRScreenChangeNotify: c_int = 0; 488 | pub const RRNotify: c_int = 1; 489 | pub const RRNotify_CrtcChange: c_int = 0; 490 | pub const RRNotify_OutputChange: c_int = 1; 491 | pub const RRNotify_OutputProperty: c_int = 2; 492 | pub const RRNotify_ProviderChange: c_int = 3; 493 | pub const RRNotify_ProviderProperty: c_int = 4; 494 | pub const RRNotify_ResourceChange: c_int = 5; 495 | 496 | pub const RR_Rotate_0: c_int = 1; 497 | pub const RR_Rotate_90: c_int = 2; 498 | pub const RR_Rotate_180: c_int = 4; 499 | pub const RR_Rotate_270: c_int = 8; 500 | 501 | pub const RR_Reflect_X: c_int = 16; 502 | pub const RR_Reflect_Y: c_int = 32; 503 | 504 | pub const RRSetConfigSuccess: c_int = 0; 505 | pub const RRSetConfigInvalidConfigTime: c_int = 1; 506 | pub const RRSetConfigInvalidTime: c_int = 2; 507 | pub const RRSetConfigFailed: c_int = 3; 508 | 509 | pub const RR_HSyncPositive: c_int = 0x00000001; 510 | pub const RR_HSyncNegative: c_int = 0x00000002; 511 | pub const RR_VSyncPositive: c_int = 0x00000004; 512 | pub const RR_VSyncNegative: c_int = 0x00000008; 513 | pub const RR_Interlace: c_int = 0x00000010; 514 | pub const RR_DoubleScan: c_int = 0x00000020; 515 | pub const RR_CSync: c_int = 0x00000040; 516 | pub const RR_CSyncPositive: c_int = 0x00000080; 517 | pub const RR_CSyncNegative: c_int = 0x00000100; 518 | pub const RR_HSkewPresent: c_int = 0x00000200; 519 | pub const RR_BCast: c_int = 0x00000400; 520 | pub const RR_PixelMultiplex: c_int = 0x00000800; 521 | pub const RR_DoubleClock: c_int = 0x00001000; 522 | pub const RR_ClockDivideBy2: c_int = 0x00002000; 523 | 524 | pub const RR_Connected: c_int = 0; 525 | pub const RR_Disconnected: c_int = 1; 526 | pub const RR_UnknownConnection: c_int = 2; 527 | 528 | pub const BadRROutput: c_int = 0; 529 | pub const BadRRCrtc: c_int = 1; 530 | pub const BadRRMode: c_int = 2; 531 | pub const BadRRProvider: c_int = 3; 532 | 533 | pub const RR_PROPERTY_BACKLIGHT: &str = "Backlight"; 534 | pub const RR_PROPERTY_RANDR_EDID: &str = "EDID"; 535 | pub const RR_PROPERTY_SIGNAL_FORMAT: &str = "SignalFormat"; 536 | pub const RR_PROPERTY_SIGNAL_PROPERTIES: &str = "SignalProperties"; 537 | pub const RR_PROPERTY_CONNECTOR_TYPE: &str = "ConnectorType"; 538 | pub const RR_PROPERTY_CONNECTOR_NUMBER: &str = "ConnectorNumber"; 539 | pub const RR_PROPERTY_COMPATIBILITY_LIST: &str = "CompatibilityList"; 540 | pub const RR_PROPERTY_CLONE_LIST: &str = "CloneList"; 541 | pub const RR_PROPERTY_BORDER: &str = "Border"; 542 | pub const RR_PROPERTY_BORDER_DIMENSIONS: &str = "BorderDimensions"; 543 | pub const RR_PROPERTY_GUID: &str = "GUID"; 544 | pub const RR_PROPERTY_RANDR_TILE: &str = "TILE"; 545 | 546 | pub const RR_Capability_None: c_int = 0; 547 | pub const RR_Capability_SourceOutput: c_int = 1; 548 | pub const RR_Capability_SinkOutput: c_int = 2; 549 | pub const RR_Capability_SourceOffload: c_int = 4; 550 | pub const RR_Capability_SinkOffload: c_int = 8; 551 | -------------------------------------------------------------------------------- /src/xrecord.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::{c_char, c_int, c_uchar, c_ulong, c_ushort}; 6 | 7 | use super::xlib::{Bool, Display, Time, XID}; 8 | 9 | // 10 | // functions 11 | // 12 | 13 | x11_link! { Xf86vmode, xtst, ["libXtst.so.6", "libXtst.so"], 14, 14 | pub fn XRecordAllocRange () -> *mut XRecordRange, 15 | pub fn XRecordCreateContext (_6: *mut Display, _5: c_int, _4: *mut c_ulong, _3: c_int, _2: *mut *mut XRecordRange, _1: c_int) -> c_ulong, 16 | pub fn XRecordDisableContext (_2: *mut Display, _1: c_ulong) -> c_int, 17 | pub fn XRecordEnableContext (_4: *mut Display, _3: c_ulong, _2: Option, _1: *mut c_char) -> c_int, 18 | pub fn XRecordEnableContextAsync (_4: *mut Display, _3: c_ulong, _2: Option, _1: *mut c_char) -> c_int, 19 | pub fn XRecordFreeContext (_2: *mut Display, _1: c_ulong) -> c_int, 20 | pub fn XRecordFreeData (_1: *mut XRecordInterceptData) -> (), 21 | pub fn XRecordFreeState (_1: *mut XRecordState) -> (), 22 | pub fn XRecordGetContext (_3: *mut Display, _2: c_ulong, _1: *mut *mut XRecordState) -> c_int, 23 | pub fn XRecordIdBaseMask (_1: *mut Display) -> c_ulong, 24 | pub fn XRecordProcessReplies (_1: *mut Display) -> (), 25 | pub fn XRecordQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, 26 | pub fn XRecordRegisterClients (_7: *mut Display, _6: c_ulong, _5: c_int, _4: *mut c_ulong, _3: c_int, _2: *mut *mut XRecordRange, _1: c_int) -> c_int, 27 | pub fn XRecordUnregisterClients (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: c_int) -> c_int, 28 | variadic: 29 | globals: 30 | } 31 | 32 | // 33 | // constants 34 | // 35 | 36 | pub const XRecordFromServerTime: c_int = 0x01; 37 | pub const XRecordFromClientTime: c_int = 0x02; 38 | pub const XRecordFromClientSequence: c_int = 0x04; 39 | 40 | pub const XRecordCurrentClients: c_ulong = 1; 41 | pub const XRecordFutureClients: c_ulong = 2; 42 | pub const XRecordAllClients: c_ulong = 3; 43 | 44 | pub const XRecordFromServer: c_int = 0; 45 | pub const XRecordFromClient: c_int = 1; 46 | pub const XRecordClientStarted: c_int = 2; 47 | pub const XRecordClientDied: c_int = 3; 48 | pub const XRecordStartOfData: c_int = 4; 49 | pub const XRecordEndOfData: c_int = 5; 50 | 51 | // 52 | // types 53 | // 54 | 55 | pub type XRecordClientSpec = c_ulong; 56 | pub type XRecordContext = c_ulong; 57 | 58 | #[derive(Debug, Clone, Copy, PartialEq)] 59 | #[repr(C)] 60 | pub struct XRecordClientInfo { 61 | pub client: XRecordClientSpec, 62 | pub nranges: c_ulong, 63 | pub ranges: *mut *mut XRecordRange, 64 | } 65 | 66 | #[derive(Debug, Clone, Copy, PartialEq)] 67 | #[repr(C)] 68 | pub struct XRecordExtRange { 69 | pub ext_major: XRecordRange8, 70 | pub ext_minor: XRecordRange16, 71 | } 72 | 73 | #[derive(Debug, Clone, Copy, PartialEq)] 74 | #[repr(C)] 75 | pub struct XRecordInterceptData { 76 | pub id_base: XID, 77 | pub server_time: Time, 78 | pub client_seq: c_ulong, 79 | pub category: c_int, 80 | pub client_swapped: Bool, 81 | pub data: *mut c_uchar, 82 | pub data_len: c_ulong, 83 | } 84 | 85 | #[derive(Debug, Clone, Copy, PartialEq)] 86 | #[repr(C)] 87 | pub struct XRecordRange { 88 | pub core_requests: XRecordRange8, 89 | pub core_replies: XRecordRange8, 90 | pub ext_requests: XRecordExtRange, 91 | pub ext_replies: XRecordExtRange, 92 | pub delivered_events: XRecordRange8, 93 | pub device_events: XRecordRange8, 94 | pub errors: XRecordRange8, 95 | pub client_started: Bool, 96 | pub client_died: Bool, 97 | } 98 | 99 | #[derive(Debug, Clone, Copy, PartialEq)] 100 | #[repr(C)] 101 | pub struct XRecordRange8 { 102 | pub first: c_uchar, 103 | pub last: c_uchar, 104 | } 105 | 106 | #[derive(Debug, Clone, Copy, PartialEq)] 107 | #[repr(C)] 108 | pub struct XRecordRange16 { 109 | pub first: c_ushort, 110 | pub last: c_ushort, 111 | } 112 | 113 | #[derive(Debug, Clone, Copy, PartialEq)] 114 | #[repr(C)] 115 | pub struct XRecordState { 116 | pub enabled: Bool, 117 | pub datum_flags: c_int, 118 | pub nclients: c_ulong, 119 | pub client_info: *mut *mut XRecordClientInfo, 120 | } 121 | -------------------------------------------------------------------------------- /src/xrender.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::{c_char, c_double, c_int, c_short, c_uint, c_ulong, c_ushort}; 6 | 7 | use super::xlib::{Atom, Bool, Colormap, Cursor, Display, Pixmap, Region, Visual, XRectangle, XID}; 8 | 9 | // 10 | // functions 11 | // 12 | 13 | x11_link! { Xrender, xrender, ["libXrender.so.1", "libXrender.so"], 44, 14 | pub fn XRenderAddGlyphs (_7: *mut Display, _6: c_ulong, _5: *const c_ulong, _4: *const XGlyphInfo, _3: c_int, _2: *const c_char, _1: c_int) -> (), 15 | pub fn XRenderAddTraps (_6: *mut Display, _5: c_ulong, _4: c_int, _3: c_int, _2: *const XTrap, _1: c_int) -> (), 16 | pub fn XRenderChangePicture (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: *const XRenderPictureAttributes) -> (), 17 | pub fn XRenderComposite (_13: *mut Display, _12: c_int, _11: c_ulong, _10: c_ulong, _9: c_ulong, _8: c_int, _7: c_int, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> (), 18 | pub fn XRenderCompositeDoublePoly (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_int, _6: c_int, _5: c_int, _4: c_int, _3: *const XPointDouble, _2: c_int, _1: c_int) -> (), 19 | pub fn XRenderCompositeString16 (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const c_ushort, _1: c_int) -> (), 20 | pub fn XRenderCompositeString32 (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const c_uint, _1: c_int) -> (), 21 | pub fn XRenderCompositeString8 (_12: *mut Display, _11: c_int, _10: c_ulong, _9: c_ulong, _8: *const XRenderPictFormat, _7: c_ulong, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int) -> (), 22 | pub fn XRenderCompositeText16 (_11: *mut Display, _10: c_int, _9: c_ulong, _8: c_ulong, _7: *const XRenderPictFormat, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const XGlyphElt16, _1: c_int) -> (), 23 | pub fn XRenderCompositeText32 (_11: *mut Display, _10: c_int, _9: c_ulong, _8: c_ulong, _7: *const XRenderPictFormat, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const XGlyphElt32, _1: c_int) -> (), 24 | pub fn XRenderCompositeText8 (_11: *mut Display, _10: c_int, _9: c_ulong, _8: c_ulong, _7: *const XRenderPictFormat, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: *const XGlyphElt8, _1: c_int) -> (), 25 | pub fn XRenderCompositeTrapezoids (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XTrapezoid, _1: c_int) -> (), 26 | pub fn XRenderCompositeTriangles (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XTriangle, _1: c_int) -> (), 27 | pub fn XRenderCompositeTriFan (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XPointFixed, _1: c_int) -> (), 28 | pub fn XRenderCompositeTriStrip (_9: *mut Display, _8: c_int, _7: c_ulong, _6: c_ulong, _5: *const XRenderPictFormat, _4: c_int, _3: c_int, _2: *const XPointFixed, _1: c_int) -> (), 29 | pub fn XRenderCreateAnimCursor (_3: *mut Display, _2: c_int, _1: *mut XAnimCursor) -> c_ulong, 30 | pub fn XRenderCreateConicalGradient (_5: *mut Display, _4: *const XConicalGradient, _3: *const c_int, _2: *const XRenderColor, _1: c_int) -> c_ulong, 31 | pub fn XRenderCreateCursor (_4: *mut Display, _3: c_ulong, _2: c_uint, _1: c_uint) -> c_ulong, 32 | pub fn XRenderCreateGlyphSet (_2: *mut Display, _1: *const XRenderPictFormat) -> c_ulong, 33 | pub fn XRenderCreateLinearGradient (_5: *mut Display, _4: *const XLinearGradient, _3: *const c_int, _2: *const XRenderColor, _1: c_int) -> c_ulong, 34 | pub fn XRenderCreatePicture (_5: *mut Display, _4: c_ulong, _3: *const XRenderPictFormat, _2: c_ulong, _1: *const XRenderPictureAttributes) -> c_ulong, 35 | pub fn XRenderCreateRadialGradient (_5: *mut Display, _4: *const XRadialGradient, _3: *const c_int, _2: *const XRenderColor, _1: c_int) -> c_ulong, 36 | pub fn XRenderCreateSolidFill (_2: *mut Display, _1: *const XRenderColor) -> c_ulong, 37 | pub fn XRenderFillRectangle (_8: *mut Display, _7: c_int, _6: c_ulong, _5: *const XRenderColor, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> (), 38 | pub fn XRenderFillRectangles (_6: *mut Display, _5: c_int, _4: c_ulong, _3: *const XRenderColor, _2: *const XRectangle, _1: c_int) -> (), 39 | pub fn XRenderFindFormat (_4: *mut Display, _3: c_ulong, _2: *const XRenderPictFormat, _1: c_int) -> *mut XRenderPictFormat, 40 | pub fn XRenderFindStandardFormat (_2: *mut Display, _1: c_int) -> *mut XRenderPictFormat, 41 | pub fn XRenderFindVisualFormat (_2: *mut Display, _1: *const Visual) -> *mut XRenderPictFormat, 42 | pub fn XRenderFreeGlyphs (_4: *mut Display, _3: c_ulong, _2: *const c_ulong, _1: c_int) -> (), 43 | pub fn XRenderFreeGlyphSet (_2: *mut Display, _1: c_ulong) -> (), 44 | pub fn XRenderFreePicture (_2: *mut Display, _1: c_ulong) -> (), 45 | pub fn XRenderParseColor (_3: *mut Display, _2: *mut c_char, _1: *mut XRenderColor) -> c_int, 46 | pub fn XRenderQueryExtension (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, 47 | pub fn XRenderQueryFilters (_2: *mut Display, _1: c_ulong) -> *mut XFilters, 48 | pub fn XRenderQueryFormats (_1: *mut Display) -> c_int, 49 | pub fn XRenderQueryPictIndexValues (_3: *mut Display, _2: *const XRenderPictFormat, _1: *mut c_int) -> *mut XIndexValue, 50 | pub fn XRenderQuerySubpixelOrder (_2: *mut Display, _1: c_int) -> c_int, 51 | pub fn XRenderQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, 52 | pub fn XRenderReferenceGlyphSet (_2: *mut Display, _1: c_ulong) -> c_ulong, 53 | pub fn XRenderSetPictureClipRectangles (_6: *mut Display, _5: c_ulong, _4: c_int, _3: c_int, _2: *const XRectangle, _1: c_int) -> (), 54 | pub fn XRenderSetPictureClipRegion (_3: *mut Display, _2: c_ulong, _1: Region) -> (), 55 | pub fn XRenderSetPictureFilter (_5: *mut Display, _4: c_ulong, _3: *const c_char, _2: *mut c_int, _1: c_int) -> (), 56 | pub fn XRenderSetPictureTransform (_3: *mut Display, _2: c_ulong, _1: *mut XTransform) -> (), 57 | pub fn XRenderSetSubpixelOrder (_3: *mut Display, _2: c_int, _1: c_int) -> c_int, 58 | variadic: 59 | globals: 60 | } 61 | 62 | // 63 | // types 64 | // 65 | 66 | pub type Glyph = XID; 67 | pub type GlyphSet = XID; 68 | pub type PictFormat = XID; 69 | pub type Picture = XID; 70 | pub type XDouble = c_double; 71 | pub type XFixed = c_int; 72 | 73 | #[derive(Debug, Clone, Copy, PartialEq)] 74 | #[repr(C)] 75 | pub struct _XAnimCursor { 76 | pub cursor: Cursor, 77 | pub delay: c_ulong, 78 | } 79 | pub type XAnimCursor = _XAnimCursor; 80 | 81 | #[derive(Debug, Clone, Copy, PartialEq)] 82 | #[repr(C)] 83 | pub struct _XCircle { 84 | pub x: XFixed, 85 | pub y: XFixed, 86 | pub radius: XFixed, 87 | } 88 | pub type XCircle = _XCircle; 89 | 90 | #[derive(Debug, Clone, Copy, PartialEq)] 91 | #[repr(C)] 92 | pub struct _XConicalGradient { 93 | pub center: XPointFixed, 94 | pub angle: XFixed, 95 | } 96 | pub type XConicalGradient = _XConicalGradient; 97 | 98 | #[derive(Debug, Clone, Copy, PartialEq)] 99 | #[repr(C)] 100 | pub struct _XFilters { 101 | pub nfilter: c_int, 102 | pub filter: *mut *mut c_char, 103 | pub nalias: c_int, 104 | pub alias: *mut c_short, 105 | } 106 | pub type XFilters = _XFilters; 107 | 108 | #[derive(Debug, Clone, Copy, PartialEq)] 109 | #[repr(C)] 110 | pub struct _XGlyphElt8 { 111 | pub glyphset: GlyphSet, 112 | pub chars: *mut c_char, 113 | pub nchars: c_int, 114 | pub xOff: c_int, 115 | pub yOff: c_int, 116 | } 117 | pub type XGlyphElt8 = _XGlyphElt8; 118 | 119 | #[derive(Debug, Clone, Copy, PartialEq)] 120 | #[repr(C)] 121 | pub struct _XGlyphElt16 { 122 | pub glyphset: GlyphSet, 123 | pub chars: *mut c_ushort, 124 | pub nchars: c_int, 125 | pub xOff: c_int, 126 | pub yOff: c_int, 127 | } 128 | pub type XGlyphElt16 = _XGlyphElt16; 129 | 130 | #[derive(Debug, Clone, Copy, PartialEq)] 131 | #[repr(C)] 132 | pub struct _XGlyphElt32 { 133 | pub glyphset: GlyphSet, 134 | pub chars: *mut c_uint, 135 | pub nchars: c_int, 136 | pub xOff: c_int, 137 | pub yOff: c_int, 138 | } 139 | pub type XGlyphElt32 = _XGlyphElt32; 140 | 141 | #[derive(Debug, Clone, Copy, PartialEq)] 142 | #[repr(C)] 143 | pub struct _XGlyphInfo { 144 | pub width: c_ushort, 145 | pub height: c_ushort, 146 | pub x: c_short, 147 | pub y: c_short, 148 | pub xOff: c_short, 149 | pub yOff: c_short, 150 | } 151 | pub type XGlyphInfo = _XGlyphInfo; 152 | 153 | #[derive(Debug, Clone, Copy, PartialEq)] 154 | #[repr(C)] 155 | pub struct _XIndexValue { 156 | pub pixel: c_ulong, 157 | pub red: c_ushort, 158 | pub green: c_ushort, 159 | pub blue: c_ushort, 160 | pub alpha: c_ushort, 161 | } 162 | pub type XIndexValue = _XIndexValue; 163 | 164 | #[derive(Debug, Clone, Copy, PartialEq)] 165 | #[repr(C)] 166 | pub struct _XLinearGradient { 167 | pub p1: XPointFixed, 168 | pub p2: XPointFixed, 169 | } 170 | pub type XLinearGradient = _XLinearGradient; 171 | 172 | #[derive(Debug, Clone, Copy, PartialEq)] 173 | #[repr(C)] 174 | pub struct _XLineFixed { 175 | pub p1: XPointFixed, 176 | pub p2: XPointFixed, 177 | } 178 | pub type XLineFixed = _XLineFixed; 179 | 180 | #[derive(Debug, Clone, Copy, PartialEq)] 181 | #[repr(C)] 182 | pub struct _XPointDouble { 183 | pub x: XDouble, 184 | pub y: XDouble, 185 | } 186 | pub type XPointDouble = _XPointDouble; 187 | 188 | #[derive(Debug, Clone, Copy, PartialEq)] 189 | #[repr(C)] 190 | pub struct _XPointFixed { 191 | pub x: XFixed, 192 | pub y: XFixed, 193 | } 194 | pub type XPointFixed = _XPointFixed; 195 | 196 | #[derive(Debug, Clone, Copy, PartialEq)] 197 | #[repr(C)] 198 | pub struct _XRadialGradient { 199 | pub inner: XCircle, 200 | pub outer: XCircle, 201 | } 202 | pub type XRadialGradient = _XRadialGradient; 203 | 204 | #[derive(Debug, Clone, Copy, PartialEq)] 205 | #[repr(C)] 206 | pub struct XRenderColor { 207 | pub red: c_ushort, 208 | pub green: c_ushort, 209 | pub blue: c_ushort, 210 | pub alpha: c_ushort, 211 | } 212 | 213 | #[derive(Debug, Clone, Copy, PartialEq)] 214 | #[repr(C)] 215 | pub struct XRenderDirectFormat { 216 | pub red: c_short, 217 | pub redMask: c_short, 218 | pub green: c_short, 219 | pub greenMask: c_short, 220 | pub blue: c_short, 221 | pub blueMask: c_short, 222 | pub alpha: c_short, 223 | pub alphaMask: c_short, 224 | } 225 | 226 | #[derive(Debug, Clone, Copy, PartialEq)] 227 | #[repr(C)] 228 | pub struct XRenderPictFormat { 229 | pub id: PictFormat, 230 | pub type_: c_int, 231 | pub depth: c_int, 232 | pub direct: XRenderDirectFormat, 233 | pub colormap: Colormap, 234 | } 235 | 236 | #[derive(Debug, Clone, Copy, PartialEq)] 237 | #[repr(C)] 238 | pub struct _XRenderPictureAttributes { 239 | pub repeat: c_int, 240 | pub alpha_map: Picture, 241 | pub alpha_x_origin: c_int, 242 | pub alpha_y_origin: c_int, 243 | pub clip_x_origin: c_int, 244 | pub clip_y_origin: c_int, 245 | pub clip_mask: Pixmap, 246 | pub graphics_exposures: Bool, 247 | pub subwindow_mode: c_int, 248 | pub poly_edge: c_int, 249 | pub poly_mode: c_int, 250 | pub dither: Atom, 251 | pub component_alpha: Bool, 252 | } 253 | pub type XRenderPictureAttributes = _XRenderPictureAttributes; 254 | 255 | #[derive(Debug, Clone, Copy, PartialEq)] 256 | #[repr(C)] 257 | pub struct _XSpanFix { 258 | pub left: XFixed, 259 | pub right: XFixed, 260 | pub y: XFixed, 261 | } 262 | pub type XSpanFix = _XSpanFix; 263 | 264 | #[derive(Debug, Clone, Copy, PartialEq)] 265 | #[repr(C)] 266 | pub struct _XTrap { 267 | pub top: XSpanFix, 268 | pub bottom: XSpanFix, 269 | } 270 | pub type XTrap = _XTrap; 271 | 272 | #[derive(Debug, Clone, Copy, PartialEq)] 273 | #[repr(C)] 274 | pub struct _XTrapezoid { 275 | pub top: XFixed, 276 | pub bottom: XFixed, 277 | pub left: XLineFixed, 278 | pub right: XLineFixed, 279 | } 280 | pub type XTrapezoid = _XTrapezoid; 281 | 282 | #[derive(Debug, Clone, Copy, PartialEq)] 283 | #[repr(C)] 284 | pub struct _XTriangle { 285 | pub p1: XPointFixed, 286 | pub p2: XPointFixed, 287 | pub p3: XPointFixed, 288 | } 289 | pub type XTriangle = _XTriangle; 290 | 291 | #[derive(Debug, Clone, Copy, PartialEq)] 292 | #[repr(C)] 293 | pub struct _XTransform { 294 | pub matrix: [[XFixed; 3]; 3], 295 | } 296 | pub type XTransform = _XTransform; 297 | 298 | // 299 | // constants 300 | // 301 | 302 | // pict format mask 303 | pub const PictFormatID: c_ulong = 1 << 0; 304 | pub const PictFormatType: c_ulong = 1 << 1; 305 | pub const PictFormatDepth: c_ulong = 1 << 2; 306 | pub const PictFormatRed: c_ulong = 1 << 3; 307 | pub const PictFormatRedMask: c_ulong = 1 << 4; 308 | pub const PictFormatGreen: c_ulong = 1 << 5; 309 | pub const PictFormatGreenMask: c_ulong = 1 << 6; 310 | pub const PictFormatBlue: c_ulong = 1 << 7; 311 | pub const PictFormatBlueMask: c_ulong = 1 << 8; 312 | pub const PictFormatAlpha: c_ulong = 1 << 9; 313 | pub const PictFormatAlphaMask: c_ulong = 1 << 10; 314 | pub const PictFormatColormap: c_ulong = 1 << 11; 315 | 316 | // error codes 317 | pub const BadPictFormat: c_int = 0; 318 | pub const BadPicture: c_int = 1; 319 | pub const BadPictOp: c_int = 2; 320 | pub const BadGlyphSet: c_int = 3; 321 | pub const BadGlyph: c_int = 4; 322 | pub const RenderNumberErrors: c_int = BadGlyph + 1; 323 | 324 | // pict types 325 | pub const PictTypeIndexed: c_int = 0; 326 | pub const PictTypeDirect: c_int = 1; 327 | 328 | // ops 329 | pub const PictOpMinimum: c_int = 0; 330 | pub const PictOpClear: c_int = 0; 331 | pub const PictOpSrc: c_int = 1; 332 | pub const PictOpDst: c_int = 2; 333 | pub const PictOpOver: c_int = 3; 334 | pub const PictOpOverReverse: c_int = 4; 335 | pub const PictOpIn: c_int = 5; 336 | pub const PictOpInReverse: c_int = 6; 337 | pub const PictOpOut: c_int = 7; 338 | pub const PictOpOutReverse: c_int = 8; 339 | pub const PictOpAtop: c_int = 9; 340 | pub const PictOpAtopReverse: c_int = 10; 341 | pub const PictOpXor: c_int = 11; 342 | pub const PictOpAdd: c_int = 12; 343 | pub const PictOpSaturate: c_int = 13; 344 | pub const PictOpMaximum: c_int = 13; 345 | 346 | pub const PictOpDisjointMinimum: c_int = 0x10; 347 | pub const PictOpDisjointClear: c_int = 0x10; 348 | pub const PictOpDisjointSrc: c_int = 0x11; 349 | pub const PictOpDisjointDst: c_int = 0x12; 350 | pub const PictOpDisjointOver: c_int = 0x13; 351 | pub const PictOpDisjointOverReverse: c_int = 0x14; 352 | pub const PictOpDisjointIn: c_int = 0x15; 353 | pub const PictOpDisjointInReverse: c_int = 0x16; 354 | pub const PictOpDisjointOut: c_int = 0x17; 355 | pub const PictOpDisjointOutReverse: c_int = 0x18; 356 | pub const PictOpDisjointAtop: c_int = 0x19; 357 | pub const PictOpDisjointAtopReverse: c_int = 0x1a; 358 | pub const PictOpDisjointXor: c_int = 0x1b; 359 | pub const PictOpDisjointMaximum: c_int = 0x1b; 360 | 361 | pub const PictOpConjointMinimum: c_int = 0x20; 362 | pub const PictOpConjointClear: c_int = 0x20; 363 | pub const PictOpConjointSrc: c_int = 0x21; 364 | pub const PictOpConjointDst: c_int = 0x22; 365 | pub const PictOpConjointOver: c_int = 0x23; 366 | pub const PictOpConjointOverReverse: c_int = 0x24; 367 | pub const PictOpConjointIn: c_int = 0x25; 368 | pub const PictOpConjointInReverse: c_int = 0x26; 369 | pub const PictOpConjointOut: c_int = 0x27; 370 | pub const PictOpConjointOutReverse: c_int = 0x28; 371 | pub const PictOpConjointAtop: c_int = 0x29; 372 | pub const PictOpConjointAtopReverse: c_int = 0x2a; 373 | pub const PictOpConjointXor: c_int = 0x2b; 374 | pub const PictOpConjointMaximum: c_int = 0x2b; 375 | 376 | pub const PictOpBlendMinimum: c_int = 0x30; 377 | pub const PictOpMultiply: c_int = 0x30; 378 | pub const PictOpScreen: c_int = 0x31; 379 | pub const PictOpOverlay: c_int = 0x32; 380 | pub const PictOpDarken: c_int = 0x33; 381 | pub const PictOpLighten: c_int = 0x34; 382 | pub const PictOpColorDodge: c_int = 0x35; 383 | pub const PictOpColorBurn: c_int = 0x36; 384 | pub const PictOpHardLight: c_int = 0x37; 385 | pub const PictOpSoftLight: c_int = 0x38; 386 | pub const PictOpDifference: c_int = 0x39; 387 | pub const PictOpExclusion: c_int = 0x3a; 388 | pub const PictOpHSLHue: c_int = 0x3b; 389 | pub const PictOpHSLSaturation: c_int = 0x3c; 390 | pub const PictOpHSLColor: c_int = 0x3d; 391 | pub const PictOpHSLLuminosity: c_int = 0x3e; 392 | pub const PictOpBlendMaximum: c_int = 0x3e; 393 | 394 | pub const PictStandardARGB32: c_int = 0; 395 | pub const PictStandardRGB24: c_int = 0; 396 | pub const PictStandardA8: c_int = 2; 397 | pub const PictStandardA4: c_int = 3; 398 | pub const PictStandardA1: c_int = 4; 399 | 400 | // poly edge types 401 | pub const PolyEdgeSharp: c_int = 0; 402 | pub const PolyEdgeSmooth: c_int = 1; 403 | 404 | // poly modes 405 | pub const PolyModePrecise: c_int = 0; 406 | pub const PolyModeImprecise: c_int = 1; 407 | 408 | // picture attributes mask 409 | pub const CPRepeat: c_int = 1 << 0; 410 | pub const CPAlphaMap: c_int = 1 << 1; 411 | pub const CPAlphaXOrigin: c_int = 1 << 2; 412 | pub const CPAlphaYOrigin: c_int = 1 << 3; 413 | pub const CPClipXOrigin: c_int = 1 << 4; 414 | pub const CPClipYOrigin: c_int = 1 << 5; 415 | pub const CPClipMask: c_int = 1 << 6; 416 | pub const CPGraphicsExposure: c_int = 1 << 7; 417 | pub const CPSubwindowMode: c_int = 1 << 8; 418 | pub const CPPolyEdge: c_int = 1 << 9; 419 | pub const CPPolyMode: c_int = 1 << 10; 420 | pub const CPDither: c_int = 1 << 11; 421 | pub const CPComponentAlpha: c_int = 1 << 12; 422 | pub const CPLastBit: c_int = 12; 423 | 424 | // filter methods 425 | pub const FilterNearest: &str = "nearest"; 426 | pub const FilterBilinear: &str = "bilinear"; 427 | pub const FilterConvolution: &str = "convolution"; 428 | pub const FilterFast: &str = "fast"; 429 | pub const FilterGood: &str = "good"; 430 | pub const FilterBest: &str = "best"; 431 | 432 | // subpixel orders 433 | pub const SubPixelUnknown: c_int = 0; 434 | pub const SubPixelHorizontalRGB: c_int = 1; 435 | pub const SubPixelHorizontalBGR: c_int = 2; 436 | pub const SubPixelVerticalRGB: c_int = 3; 437 | pub const SubPixelVerticalBGR: c_int = 4; 438 | pub const SubPixelNone: c_int = 5; 439 | 440 | // repeat attributes 441 | pub const RepeatNone: c_int = 0; 442 | pub const RepeatNormal: c_int = 1; 443 | pub const RepeatPad: c_int = 2; 444 | pub const RepeatReflect: c_int = 3; 445 | -------------------------------------------------------------------------------- /src/xshm.rs: -------------------------------------------------------------------------------- 1 | use super::xlib::{Bool, Display, Drawable, Pixmap, Visual, XImage, GC}; 2 | use std::os::raw::{c_char, c_int, c_uint, c_ulong}; 3 | 4 | x11_link! { Xext, xext, ["libXext.so.6", "libXext.so"], 10, 5 | pub fn XShmQueryExtension(_1: *mut Display) -> Bool, 6 | pub fn XShmGetEventBase(_1: *mut Display) -> c_int, 7 | pub fn XShmQueryVersion(_4: *mut Display, _3: *mut c_int, _2: *mut c_int, _1: *mut Bool) -> Bool, 8 | pub fn XShmPixmapFormat(_1: *mut Display) -> c_int, 9 | pub fn XShmAttach(_2: *mut Display, _1: *mut XShmSegmentInfo) -> Bool, 10 | pub fn XShmDetach(_2: *mut Display, _1: *mut XShmSegmentInfo) -> Bool, 11 | pub fn XShmPutImage(_11: *mut Display, _10: Drawable, _9: GC, _8: *mut XImage, _7: c_int, _6: c_int, _5: c_int, _4: c_int, _3: c_uint, _2: c_uint, _1: Bool) -> Bool, 12 | pub fn XShmGetImage(_6: *mut Display, _5: Drawable, _4: *mut XImage, _3: c_int, _2: c_int, _1: c_uint) -> Bool, 13 | pub fn XShmCreateImage(_8: *mut Display, _7: *mut Visual, _6: c_uint, _5: c_int, _4: *mut c_char, _3: *mut XShmSegmentInfo, _2: c_uint, _1: c_uint) -> *mut XImage, 14 | pub fn XShmCreatePixmap(_7: *mut Display, _6: Drawable, _5: *mut c_char, _4: *mut XShmSegmentInfo, _3: c_uint, _2: c_uint, _1: c_uint) -> Pixmap, 15 | 16 | variadic: 17 | globals: 18 | } 19 | 20 | pub type ShmSeg = c_ulong; 21 | 22 | #[derive(Copy, Clone, Debug, PartialEq)] 23 | #[repr(C)] 24 | pub struct XShmCompletionEvent { 25 | /// of event 26 | pub _type: c_int, 27 | /// # of last request processed by server 28 | pub serial: c_uint, 29 | /// true if this came from a SendEvent request 30 | pub send_event: Bool, 31 | /// Display the event was read from 32 | pub diplay: *mut Display, 33 | /// drawable of request 34 | pub drawable: *mut Drawable, 35 | /// ShmReqCode 36 | pub major_code: c_int, 37 | /// X_ShmPutImage 38 | pub minor_code: c_int, 39 | /// the ShmSeg used in the request 40 | pub shmseg: ShmSeg, 41 | /// the offset into ShmSeg used in the request 42 | pub offset: c_ulong, 43 | } 44 | 45 | #[derive(Copy, Clone, Debug, PartialEq)] 46 | #[repr(C)] 47 | pub struct XShmSegmentInfo { 48 | /// resource id 49 | pub shmseg: ShmSeg, 50 | /// kernel id 51 | pub shmid: c_int, 52 | /// address in client 53 | pub shmaddr: *mut c_char, 54 | /// how the server should attach it 55 | pub readOnly: Bool, 56 | } 57 | -------------------------------------------------------------------------------- /src/xss.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use super::xlib::{ 6 | Atom, Bool, Display, Drawable, Status, Time, Visual, Window, XEvent, XSetWindowAttributes, XID, 7 | }; 8 | use std::os::raw::{c_int, c_uint, c_ulong}; 9 | 10 | // 11 | // functions 12 | // 13 | 14 | x11_link! { Xss, xscrnsaver, ["libXss.so.2", "libXss.so"], 11, 15 | pub fn XScreenSaverQueryExtension (_1: *mut Display, _2: *mut c_int, _3: *mut c_int) -> Bool, 16 | pub fn XScreenSaverQueryVersion (_1: *mut Display, _2: *mut c_int, _3: *mut c_int) -> Status, 17 | pub fn XScreenSaverAllocInfo () -> *mut XScreenSaverInfo, 18 | pub fn XScreenSaverQueryInfo (_1: *mut Display, _2: Drawable, _3: *mut XScreenSaverInfo) -> Status, 19 | pub fn XScreenSaverSelectInput (_1: *mut Display, _2: Drawable, _3: c_ulong) -> (), 20 | pub fn XScreenSaverSetAttributes (_1: *mut Display, _2: Drawable, _3: c_int, _4: c_int, _5: c_uint, _6: c_uint, _7: c_uint, _8: c_int, _9: c_uint, _10: *mut Visual, _11: c_ulong, _12: *mut XSetWindowAttributes) -> (), 21 | pub fn XScreenSaverUnsetAttributes (_1: *mut Display, _2: Drawable) -> (), 22 | pub fn XScreenSaverRegister (_1: *mut Display, _2: c_int, _3: XID, _4: Atom) -> Status, 23 | pub fn XScreenSaverUnregister (_1: *mut Display, _2: c_int) -> Status, 24 | pub fn XScreenSaverGetRegistered (_1: *mut Display, _2: c_int, _3: *mut XID, _4: *mut Atom) -> Status, 25 | pub fn XScreenSaverSuspend (_1: *mut Display, _2: Bool) -> (), 26 | variadic: 27 | globals: 28 | } 29 | 30 | // 31 | // types 32 | // 33 | 34 | #[derive(Debug, Clone, Copy, PartialEq)] 35 | #[repr(C)] 36 | pub struct XScreenSaverInfo { 37 | pub window: Window, 38 | pub state: c_int, 39 | pub kind: c_int, 40 | pub til_or_since: c_ulong, 41 | pub idle: c_ulong, 42 | pub eventMask: c_ulong, 43 | } 44 | 45 | // 46 | // event structures 47 | // 48 | 49 | #[derive(Debug, Clone, Copy, PartialEq)] 50 | #[repr(C)] 51 | pub struct XScreenSaverNotifyEvent { 52 | pub type_: c_int, 53 | pub serial: c_ulong, 54 | pub send_event: Bool, 55 | pub display: *mut Display, 56 | pub window: Window, 57 | pub root: Window, 58 | pub state: c_int, 59 | pub kind: c_int, 60 | pub forced: Bool, 61 | pub time: Time, 62 | } 63 | 64 | event_conversions_and_tests! { 65 | xss_notify: XScreenSaverNotifyEvent, 66 | } 67 | 68 | // 69 | // constants 70 | // 71 | 72 | pub const ScreenSaverName: &str = "MIT-SCREEN-SAVER"; 73 | pub const ScreenSaverPropertyName: &str = "_MIT_SCREEN_SAVER_ID"; 74 | 75 | pub const ScreenSaverNotifyMask: c_ulong = 0x00000001; 76 | pub const ScreenSaverCycleMask: c_ulong = 0x00000002; 77 | 78 | pub const ScreenSaverMajorVersion: c_int = 1; 79 | pub const ScreenSaverMinorVersion: c_int = 1; 80 | 81 | pub const ScreenSaverOff: c_int = 0; 82 | pub const ScreenSaverOn: c_int = 1; 83 | pub const ScreenSaverCycle: c_int = 2; 84 | pub const ScreenSaverDisabled: c_int = 3; 85 | 86 | pub const ScreenSaverBlanked: c_int = 0; 87 | pub const ScreenSaverInternal: c_int = 1; 88 | pub const ScreenSaverExternal: c_int = 2; 89 | 90 | pub const ScreenSaverNotify: c_int = 0; 91 | pub const ScreenSaverNumberEvents: c_int = 1; 92 | -------------------------------------------------------------------------------- /src/xtest.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::os::raw::{c_int, c_uint, c_ulong}; 6 | 7 | use super::xinput::XDevice; 8 | use super::xlib::{Display, Visual, GC}; 9 | 10 | // 11 | // functions 12 | // 13 | 14 | x11_link! { Xf86vmode, xtst, ["libXtst.so.6", "libXtst.so"], 15, 15 | pub fn XTestCompareCurrentCursorWithWindow (_2: *mut Display, _1: c_ulong) -> c_int, 16 | pub fn XTestCompareCursorWithWindow (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int, 17 | pub fn XTestDiscard (_1: *mut Display) -> c_int, 18 | pub fn XTestFakeButtonEvent (_4: *mut Display, _3: c_uint, _2: c_int, _1: c_ulong) -> c_int, 19 | pub fn XTestFakeDeviceButtonEvent (_7: *mut Display, _6: *mut XDevice, _5: c_uint, _4: c_int, _3: *mut c_int, _2: c_int, _1: c_ulong) -> c_int, 20 | pub fn XTestFakeDeviceKeyEvent (_7: *mut Display, _6: *mut XDevice, _5: c_uint, _4: c_int, _3: *mut c_int, _2: c_int, _1: c_ulong) -> c_int, 21 | pub fn XTestFakeDeviceMotionEvent (_7: *mut Display, _6: *mut XDevice, _5: c_int, _4: c_int, _3: *mut c_int, _2: c_int, _1: c_ulong) -> c_int, 22 | pub fn XTestFakeKeyEvent (_4: *mut Display, _3: c_uint, _2: c_int, _1: c_ulong) -> c_int, 23 | pub fn XTestFakeMotionEvent (_5: *mut Display, _4: c_int, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, 24 | pub fn XTestFakeProximityEvent (_6: *mut Display, _5: *mut XDevice, _4: c_int, _3: *mut c_int, _2: c_int, _1: c_ulong) -> c_int, 25 | pub fn XTestFakeRelativeMotionEvent (_5: *mut Display, _4: c_int, _3: c_int, _2: c_int, _1: c_ulong) -> c_int, 26 | pub fn XTestGrabControl (_2: *mut Display, _1: c_int) -> c_int, 27 | pub fn XTestQueryExtension (_5: *mut Display, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int, 28 | pub fn XTestSetGContextOfGC (_2: GC, _1: c_ulong) -> (), 29 | pub fn XTestSetVisualIDOfVisual (_2: *mut Visual, _1: c_ulong) -> (), 30 | variadic: 31 | globals: 32 | } 33 | -------------------------------------------------------------------------------- /x11-dl/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /x11-dl/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "x11-dl" 3 | version = "2.21.0" 4 | authors = [ 5 | "daggerbot ", 6 | "Erle Pereira ", 7 | "AltF02 ", 8 | ] 9 | description = "X11 library bindings for Rust" 10 | license = "MIT" 11 | repository = "https://github.com/AltF02/x11-rs.git" 12 | build = "build.rs" 13 | documentation = "https://docs.rs/x11-dl" 14 | workspace = ".." 15 | edition = "2021" 16 | 17 | [dependencies] 18 | libc = "0.2" 19 | once_cell = "1.17.0" 20 | 21 | [build-dependencies] 22 | pkg-config = "0.3.24" 23 | -------------------------------------------------------------------------------- /x11-dl/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | ../LICENSE-MIT -------------------------------------------------------------------------------- /x11-dl/build.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | extern crate pkg_config; 6 | 7 | use std::env; 8 | use std::fs::File; 9 | use std::io::Write; 10 | use std::path::Path; 11 | 12 | fn main() { 13 | let libraries = [ 14 | // lib pkgconfig name 15 | ("xext", "xext"), 16 | ("gl", "gl"), 17 | ("xcursor", "xcursor"), 18 | ("xxf86vm", "xxf86vm"), 19 | ("xft", "xft"), 20 | ("xinerama", "xinerama"), 21 | ("xi", "xi"), 22 | ("x11", "x11"), 23 | ("xlib_xcb", "x11-xcb"), 24 | ("xmu", "xmu"), 25 | ("xrandr", "xrandr"), 26 | ("xtst", "xtst"), 27 | ("xrender", "xrender"), 28 | ("xpresent", "xpresent"), 29 | ("xscrnsaver", "xscrnsaver"), 30 | ("xt", "xt"), 31 | ]; 32 | 33 | let mut config = String::new(); 34 | for &(lib, pcname) in libraries.iter() { 35 | let libdir = match pkg_config::get_variable(pcname, "libdir") { 36 | Ok(libdir) => format!("Some(\"{}\")", libdir), 37 | Err(_) => "None".to_string(), 38 | }; 39 | config.push_str(&format!( 40 | "pub const {}: Option<&'static str> = {};\n", 41 | lib, libdir 42 | )); 43 | } 44 | let config = format!("pub mod config {{ pub mod libdir {{\n{}}}\n}}", config); 45 | let out_dir = env::var("OUT_DIR").unwrap(); 46 | let dest_path = Path::new(&out_dir).join("config.rs"); 47 | let mut f = File::create(&dest_path).unwrap(); 48 | f.write_all(&config.into_bytes()).unwrap(); 49 | 50 | let target = env::var("TARGET").unwrap(); 51 | if target.contains("linux") { 52 | println!("cargo:rustc-link-lib=dl"); 53 | } else if target.contains("freebsd") || target.contains("dragonfly") { 54 | println!("cargo:rustc-link-lib=c"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /x11-dl/examples/hello-world-dl.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | extern crate x11_dl; 6 | 7 | use std::ffi::CString; 8 | use std::mem; 9 | use std::os::raw::*; 10 | use std::ptr; 11 | 12 | use x11_dl::xlib; 13 | 14 | fn main() { 15 | unsafe { 16 | // Load Xlib library. 17 | let xlib = xlib::Xlib::open().unwrap(); 18 | 19 | // Open display connection. 20 | let display = (xlib.XOpenDisplay)(ptr::null()); 21 | 22 | if display.is_null() { 23 | panic!("XOpenDisplay failed"); 24 | } 25 | 26 | // Create window. 27 | let screen = (xlib.XDefaultScreen)(display); 28 | let root = (xlib.XRootWindow)(display, screen); 29 | 30 | let mut attributes: xlib::XSetWindowAttributes = mem::MaybeUninit::uninit().assume_init(); 31 | attributes.background_pixel = (xlib.XWhitePixel)(display, screen); 32 | 33 | let window = (xlib.XCreateWindow)( 34 | display, 35 | root, 36 | 0, 37 | 0, 38 | 400, 39 | 300, 40 | 0, 41 | 0, 42 | xlib::InputOutput as c_uint, 43 | ptr::null_mut(), 44 | xlib::CWBackPixel, 45 | &mut attributes, 46 | ); 47 | 48 | // Set window title. 49 | let title_str = CString::new("hello-world").unwrap(); 50 | (xlib.XStoreName)(display, window, title_str.as_ptr() as *mut c_char); 51 | 52 | // Hook close requests. 53 | let wm_protocols_str = CString::new("WM_PROTOCOLS").unwrap(); 54 | let wm_delete_window_str = CString::new("WM_DELETE_WINDOW").unwrap(); 55 | 56 | let wm_protocols = (xlib.XInternAtom)(display, wm_protocols_str.as_ptr(), xlib::False); 57 | let wm_delete_window = 58 | (xlib.XInternAtom)(display, wm_delete_window_str.as_ptr(), xlib::False); 59 | 60 | let mut protocols = [wm_delete_window]; 61 | 62 | (xlib.XSetWMProtocols)( 63 | display, 64 | window, 65 | protocols.as_mut_ptr(), 66 | protocols.len() as c_int, 67 | ); 68 | 69 | // Show window. 70 | (xlib.XMapWindow)(display, window); 71 | 72 | // Main loop. 73 | let mut event: xlib::XEvent = mem::MaybeUninit::uninit().assume_init(); 74 | 75 | loop { 76 | (xlib.XNextEvent)(display, &mut event); 77 | 78 | match event.get_type() { 79 | xlib::ClientMessage => { 80 | let xclient = xlib::XClientMessageEvent::from(event); 81 | 82 | if xclient.message_type == wm_protocols && xclient.format == 32 { 83 | let protocol = xclient.data.get_long(0) as xlib::Atom; 84 | 85 | if protocol == wm_delete_window { 86 | break; 87 | } 88 | } 89 | } 90 | 91 | _ => (), 92 | } 93 | } 94 | 95 | // Shut down. 96 | (xlib.XCloseDisplay)(display); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /x11-dl/src/dpms.rs: -------------------------------------------------------------------------------- 1 | ../../src/dpms.rs -------------------------------------------------------------------------------- /x11-dl/src/error.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::error::Error; 6 | use std::fmt::{Display, Formatter}; 7 | 8 | // 9 | // OpenError 10 | 11 | // 12 | 13 | #[derive(Clone, Debug)] 14 | pub struct OpenError { 15 | kind: OpenErrorKind, 16 | detail: String, 17 | } 18 | 19 | impl OpenError { 20 | pub fn detail(&self) -> &str { 21 | self.detail.as_ref() 22 | } 23 | 24 | pub fn kind(&self) -> OpenErrorKind { 25 | self.kind 26 | } 27 | 28 | pub fn new(kind: OpenErrorKind, detail: String) -> OpenError { 29 | OpenError { kind, detail } 30 | } 31 | } 32 | 33 | impl Display for OpenError { 34 | fn fmt(&self, f: &mut Formatter) -> Result<(), ::std::fmt::Error> { 35 | //try!(f.write_str(self.kind.as_str())); TEST Erle July 2020 (on dev branch) 36 | f.write_str(self.kind.as_str())?; 37 | if !self.detail.is_empty() { 38 | f.write_str(" (")?; 39 | f.write_str(self.detail.as_ref())?; 40 | f.write_str(")")?; 41 | } 42 | Ok(()) 43 | } 44 | } 45 | 46 | impl Error for OpenError { 47 | fn description(&self) -> &str { 48 | self.kind.as_str() 49 | } 50 | } 51 | 52 | // 53 | // OpenErrorKind 54 | // 55 | 56 | #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] 57 | pub enum OpenErrorKind { 58 | Library, 59 | Symbol, 60 | } 61 | 62 | impl OpenErrorKind { 63 | pub fn as_str(self) -> &'static str { 64 | match self { 65 | OpenErrorKind::Library => "opening library failed", 66 | OpenErrorKind::Symbol => "loading symbol failed", 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /x11-dl/src/glx.rs: -------------------------------------------------------------------------------- 1 | ../../src/glx.rs -------------------------------------------------------------------------------- /x11-dl/src/internal.rs: -------------------------------------------------------------------------------- 1 | ../../src/internal.rs -------------------------------------------------------------------------------- /x11-dl/src/keysym.rs: -------------------------------------------------------------------------------- 1 | ../../src/keysym.rs -------------------------------------------------------------------------------- /x11-dl/src/lib.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | #![allow(non_camel_case_types)] 6 | #![allow(non_snake_case)] 7 | #![allow(non_upper_case_globals)] 8 | #![allow(deref_nullptr)] 9 | #![allow(clippy::missing_safety_doc)] 10 | 11 | extern crate libc; 12 | 13 | #[macro_use] 14 | mod link; 15 | mod internal; 16 | 17 | pub mod error; 18 | 19 | #[macro_use] 20 | pub mod xlib; 21 | 22 | pub mod dpms; 23 | pub mod glx; 24 | pub mod keysym; 25 | pub mod sync; 26 | pub mod xcursor; 27 | pub mod xf86vmode; 28 | pub mod xfixes; 29 | pub mod xft; 30 | pub mod xinerama; 31 | pub mod xinput; 32 | pub mod xinput2; 33 | pub mod xlib_xcb; 34 | pub mod xmd; 35 | pub mod xmu; 36 | pub mod xpresent; 37 | pub mod xrecord; 38 | pub mod xrender; 39 | pub mod xshm; 40 | pub mod xss; 41 | pub mod xt; 42 | pub mod xtest; 43 | 44 | pub mod xrandr { 45 | include!("xrandr.rs"); 46 | include!("old_xrandr.rs"); 47 | } 48 | -------------------------------------------------------------------------------- /x11-dl/src/link.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | use std::ffi::{CStr, CString}; 6 | use std::os::raw::{c_char, c_void}; 7 | use std::path::Path; 8 | 9 | use super::error::{OpenError, OpenErrorKind}; 10 | 11 | include!(concat!(env!("OUT_DIR"), "/config.rs")); 12 | 13 | // 14 | // x11_link! 15 | // 16 | 17 | macro_rules! x11_link { 18 | { $struct_name:ident, $pkg_name:ident, [$($lib_name:expr),*], $nsyms:expr, 19 | $(pub fn $fn_name:ident ($($param_name:ident : $param_type:ty),*) -> $ret_type:ty,)* 20 | variadic: 21 | $(pub fn $vfn_name:ident ($($vparam_name: ident : $vparam_type:ty),+) -> $vret_type:ty,)* 22 | globals: 23 | $(pub static $var_name:ident : $var_type:ty,)* 24 | } => { 25 | #[allow(clippy::manual_non_exhaustive)] 26 | pub struct $struct_name { 27 | _private: (), 28 | $(pub $fn_name: unsafe extern "C" fn ($($param_type),*) -> $ret_type,)* 29 | $(pub $vfn_name: unsafe extern "C" fn ($($vparam_type),+, ...) -> $vret_type,)* 30 | $(pub $var_name: *mut $var_type,)* 31 | } 32 | 33 | unsafe impl Send for $struct_name {} 34 | unsafe impl Sync for $struct_name {} 35 | 36 | impl $struct_name { 37 | pub fn open () -> Result<$struct_name, $crate::error::OpenError> { 38 | /// Cached function pointers and global variables for X11 libraries. 39 | static CACHED: once_cell::sync::OnceCell<($crate::link::DynamicLibrary, $struct_name)> = once_cell::sync::OnceCell::new(); 40 | 41 | // Use the cached library or open a new one. 42 | let (_, funcs) = CACHED.get_or_try_init(|| { 43 | unsafe { 44 | let libdir = $crate::link::config::libdir::$pkg_name; 45 | let lib = $crate::link::DynamicLibrary::open_multi(libdir, &[$($lib_name),*])?; 46 | 47 | // Load every function pointer. 48 | let funcs = $struct_name { 49 | _private: (), 50 | $($fn_name: ::std::mem::transmute(lib.symbol(stringify!($fn_name))?),)* 51 | $($vfn_name: ::std::mem::transmute(lib.symbol(stringify!($vfn_name))?),)* 52 | $($var_name: ::std::mem::transmute(lib.symbol(stringify!($var_name))?),)* 53 | }; 54 | 55 | Ok((lib, funcs)) 56 | } 57 | })?; 58 | 59 | Ok($struct_name { 60 | _private: (), 61 | $($fn_name: funcs.$fn_name,)* 62 | $($vfn_name: funcs.$vfn_name,)* 63 | $($var_name: funcs.$var_name,)* 64 | }) 65 | } 66 | } 67 | }; 68 | } 69 | 70 | // 71 | // DynamicLibrary 72 | // 73 | 74 | pub struct DynamicLibrary { 75 | handle: *mut c_void, 76 | } 77 | 78 | impl DynamicLibrary { 79 | pub fn open(name: &str) -> Result { 80 | unsafe { 81 | let cname = match CString::new(name) { 82 | Ok(cname) => cname, 83 | Err(_) => { 84 | return Err(OpenError::new( 85 | OpenErrorKind::Library, 86 | String::from("library name contains NUL byte(s)"), 87 | )); 88 | } 89 | }; 90 | 91 | let handle = libc::dlopen(cname.as_ptr(), libc::RTLD_LAZY); 92 | 93 | if handle.is_null() { 94 | let msg = libc::dlerror(); 95 | 96 | if msg.is_null() { 97 | return Err(OpenError::new(OpenErrorKind::Library, String::new())); 98 | } 99 | 100 | let cmsg = CStr::from_ptr(msg as *const c_char); 101 | let detail = cmsg.to_string_lossy().into_owned(); 102 | return Err(OpenError::new(OpenErrorKind::Library, detail)); 103 | } 104 | 105 | Ok(DynamicLibrary { 106 | handle: handle as *mut c_void, 107 | }) 108 | } 109 | } 110 | 111 | pub fn open_multi( 112 | libdir: Option<&'static str>, 113 | names: &[&str], 114 | ) -> Result { 115 | assert!(!names.is_empty()); 116 | 117 | let paths = libdir.map_or(Vec::new(), |dir| { 118 | let path = Path::new(dir); 119 | names 120 | .iter() 121 | .map(|name| path.join(name).to_str().unwrap().to_string()) 122 | .collect::>() 123 | }); 124 | 125 | let mut msgs = Vec::new(); 126 | 127 | for name in names.iter().copied().chain(paths.iter().map(|x| &**x)) { 128 | match DynamicLibrary::open(name) { 129 | Ok(lib) => { 130 | return Ok(lib); 131 | } 132 | Err(err) => { 133 | msgs.push(format!("{}", err)); 134 | } 135 | } 136 | } 137 | 138 | let mut detail = String::new(); 139 | 140 | for (i, msg) in msgs.iter().enumerate() { 141 | if i != 0 { 142 | detail.push_str("; "); 143 | } 144 | detail.push_str(msg.as_ref()); 145 | } 146 | 147 | Err(OpenError::new(OpenErrorKind::Library, detail)) 148 | } 149 | 150 | pub fn symbol(&self, name: &str) -> Result<*mut c_void, OpenError> { 151 | unsafe { 152 | let cname = match CString::new(name) { 153 | Ok(cname) => cname, 154 | Err(_) => { 155 | return Err(OpenError::new( 156 | OpenErrorKind::Symbol, 157 | String::from("symbol name contains NUL byte(s)"), 158 | )); 159 | } 160 | }; 161 | 162 | let sym = libc::dlsym(self.handle as *mut _, cname.as_ptr()); 163 | 164 | if sym.is_null() { 165 | let msg = libc::dlerror(); 166 | 167 | if msg.is_null() { 168 | return Err(OpenError::new(OpenErrorKind::Symbol, String::from(name))); 169 | } 170 | 171 | let cmsg = CStr::from_ptr(msg as *const c_char); 172 | let detail = format!("{} - {}", name, cmsg.to_string_lossy().into_owned()); 173 | return Err(OpenError::new(OpenErrorKind::Symbol, detail)); 174 | } 175 | 176 | Ok(sym as *mut c_void) 177 | } 178 | } 179 | } 180 | 181 | impl Drop for DynamicLibrary { 182 | fn drop (&mut self) { 183 | unsafe { 184 | libc::dlclose(self.handle as *mut _); 185 | } 186 | } 187 | } 188 | 189 | unsafe impl Send for DynamicLibrary {} 190 | unsafe impl Sync for DynamicLibrary {} 191 | -------------------------------------------------------------------------------- /x11-dl/src/old_xrandr.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | x11_link! { Xrandr_2_2_0, xrandr, ["libXrandr.so.2.2.0", "libXrandr.so.2", "libXrandr.so"], 65, 6 | pub fn XRRAddOutputMode (dpy: *mut Display, output: RROutput, mode: RRMode) -> (), 7 | pub fn XRRAllocGamma (size: c_int) -> *mut XRRCrtcGamma, 8 | pub fn XRRAllocModeInfo (name: *const c_char, nameLength: c_int) -> *mut XRRModeInfo, 9 | pub fn XRRChangeOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, type_: Atom, format: c_int, mode: c_int, data: *const c_uchar, nelements: c_int) -> (), 10 | pub fn XRRChangeProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, type_: Atom, format: c_int, mode: c_int, data: *const c_uchar, nelements: c_int) -> (), 11 | pub fn XRRConfigCurrentConfiguration (config: *mut XRRScreenConfiguration, rotation: *mut Rotation) -> SizeID, 12 | pub fn XRRConfigCurrentRate (config: *mut XRRScreenConfiguration) -> c_short, 13 | pub fn XRRConfigRates (config: *mut XRRScreenConfiguration, sizeID: c_int, nrates: *mut c_int) -> *mut c_short, 14 | pub fn XRRConfigRotations (config: *mut XRRScreenConfiguration, current_rotation: *mut Rotation) -> Rotation, 15 | pub fn XRRConfigSizes (config: *mut XRRScreenConfiguration, nsizes: *mut c_int) -> *mut XRRScreenSize, 16 | pub fn XRRConfigTimes (config: *mut XRRScreenConfiguration, config_timestamp: *mut Time) -> Time, 17 | pub fn XRRConfigureOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, pending: Bool, range: Bool, num_values: c_int, values: *mut c_long) -> (), 18 | pub fn XRRConfigureProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, pending: Bool, range: Bool, num_values: c_int, values: *mut c_long) -> (), 19 | pub fn XRRCreateMode (dpy: *mut Display, window: Window, modeInfo: *mut XRRModeInfo) -> RRMode, 20 | pub fn XRRDeleteOutputMode (dpy: *mut Display, output: RROutput, mode: RRMode) -> (), 21 | pub fn XRRDeleteOutputProperty (dpy: *mut Display, output: RROutput, property: Atom) -> (), 22 | pub fn XRRDeleteProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom) -> (), 23 | pub fn XRRDestroyMode (dpy: *mut Display, mode: RRMode) -> (), 24 | pub fn XRRFreeCrtcInfo (crtcInfo: *mut XRRCrtcInfo) -> (), 25 | pub fn XRRFreeGamma (gamma: *mut XRRCrtcGamma) -> (), 26 | pub fn XRRFreeModeInfo (modeInfo: *mut XRRModeInfo) -> (), 27 | pub fn XRRFreeOutputInfo (outputInfo: *mut XRROutputInfo) -> (), 28 | pub fn XRRFreePanning (panning: *mut XRRPanning) -> (), 29 | pub fn XRRFreeProviderInfo (provider: *mut XRRProviderInfo) -> (), 30 | pub fn XRRFreeProviderResources (resources: *mut XRRProviderResources) -> (), 31 | pub fn XRRFreeScreenConfigInfo (config: *mut XRRScreenConfiguration) -> (), 32 | pub fn XRRFreeScreenResources (resources: *mut XRRScreenResources) -> (), 33 | pub fn XRRGetCrtcGamma (dpy: *mut Display, crtc: RRCrtc) -> *mut XRRCrtcGamma, 34 | pub fn XRRGetCrtcGammaSize (dpy: *mut Display, crtc: RRCrtc) -> c_int, 35 | pub fn XRRGetCrtcInfo (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc) -> *mut XRRCrtcInfo, 36 | pub fn XRRGetCrtcTransform (dpy: *mut Display, crtc: RRCrtc, attributes: *mut *mut XRRCrtcTransformAttributes) -> Status, 37 | pub fn XRRGetOutputInfo (dpy: *mut Display, resources: *mut XRRScreenResources, output: RROutput) -> *mut XRROutputInfo, 38 | pub fn XRRGetOutputPrimary (dpy: *mut Display, window: Window) -> RROutput, 39 | pub fn XRRGetOutputProperty (dpy: *mut Display, output: RROutput, property: Atom, offset: c_long, length: c_long, _delete: Bool, pending: Bool, req_type: Atom, actual_type: *mut Atom, actual_format: *mut c_int, nitems: *mut c_ulong, bytes_after: *mut c_ulong, prop: *mut *mut c_uchar) -> c_int, 40 | pub fn XRRGetPanning (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc) -> *mut XRRPanning, 41 | pub fn XRRGetProviderInfo (dpy: *mut Display, resources: *mut XRRScreenResources, provider: RRProvider) -> *mut XRRProviderInfo, 42 | pub fn XRRGetProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom, offset: c_long, length: c_long, _delete: Bool, pending: Bool, req_type: Atom, actual_type: *mut Atom, actual_format: *mut c_int, nitems: *mut c_ulong, bytes_after: *mut c_ulong, prop: *mut *mut c_uchar) -> c_int, 43 | pub fn XRRGetProviderResources (dpy: *mut Display, window: Window) -> *mut XRRProviderResources, 44 | pub fn XRRGetScreenInfo (dpy: *mut Display, window: Window) -> *mut XRRScreenConfiguration, 45 | pub fn XRRGetScreenResources (dpy: *mut Display, window: Window) -> *mut XRRScreenResources, 46 | pub fn XRRGetScreenResourcesCurrent (dpy: *mut Display, window: Window) -> *mut XRRScreenResources, 47 | pub fn XRRGetScreenSizeRange (dpy: *mut Display, window: Window, minWidth: *mut c_int, minHeight: *mut c_int, maxWidth: *mut c_int, maxHeight: *mut c_int) -> Status, 48 | pub fn XRRListOutputProperties (dpy: *mut Display, output: RROutput, nprop: *mut c_int) -> *mut Atom, 49 | pub fn XRRListProviderProperties (dpy: *mut Display, provider: RRProvider, nprop: *mut c_int) -> *mut Atom, 50 | pub fn XRRQueryExtension (dpy: *mut Display, event_base_return: *mut c_int, error_base_return: *mut c_int) -> Bool, 51 | pub fn XRRQueryOutputProperty (dpy: *mut Display, output: RROutput, property: Atom) -> *mut XRRPropertyInfo, 52 | pub fn XRRQueryProviderProperty (dpy: *mut Display, provider: RRProvider, property: Atom) -> *mut XRRPropertyInfo, 53 | pub fn XRRQueryVersion (dpy: *mut Display, major_version_return: *mut c_int, minor_version_return: *mut c_int) -> Status, 54 | pub fn XRRRates (dpy: *mut Display, screen: c_int, sizeID: c_int, nrates: *mut c_int) -> *mut c_short, 55 | pub fn XRRRootToScreen (dpy: *mut Display, root: Window) -> c_int, 56 | pub fn XRRRotations (dpy: *mut Display, screen: c_int, current_rotation: *mut Rotation) -> Rotation, 57 | pub fn XRRSelectInput (dpy: *mut Display, window: Window, mask: c_int) -> (), 58 | pub fn XRRSetCrtcConfig (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc, timestamp: Time, x: c_int, y: c_int, mode: RRMode, rotation: Rotation, outputs: *mut RROutput, noutputs: c_int) -> Status, 59 | pub fn XRRSetCrtcGamma (dpy: *mut Display, crtc: RRCrtc, gamma: *mut XRRCrtcGamma) -> (), 60 | pub fn XRRSetCrtcTransform (dpy: *mut Display, crtc: RRCrtc, transform: *mut XTransform, filter: *const c_char, params: *mut XFixed, nparams: c_int) -> (), 61 | pub fn XRRSetOutputPrimary (dpy: *mut Display, window: Window, output: RROutput) -> (), 62 | pub fn XRRSetPanning (dpy: *mut Display, resources: *mut XRRScreenResources, crtc: RRCrtc, panning: *mut XRRPanning) -> Status, 63 | pub fn XRRSetProviderOffloadSink (dpy: *mut Display, provider: XID, sink_provider: XID) -> c_int, 64 | pub fn XRRSetProviderOutputSource (dpy: *mut Display, provider: XID, source_provider: XID) -> c_int, 65 | pub fn XRRSetScreenConfig (dpy: *mut Display, config: *mut XRRScreenConfiguration, draw: Drawable, size_index: c_int, rotation: Rotation, timestamp: Time) -> Status, 66 | pub fn XRRSetScreenConfigAndRate (dpy: *mut Display, config: *mut XRRScreenConfiguration, draw: Drawable, size_index: c_int, rotation: Rotation, rate: c_short, timestamp: Time) -> Status, 67 | pub fn XRRSetScreenSize (dpy: *mut Display, window: Window, width: c_int, height: c_int, mmWidth: c_int, mmHeight: c_int) -> (), 68 | pub fn XRRSizes (dpy: *mut Display, screen: c_int, nsizes: *mut c_int) -> *mut XRRScreenSize, 69 | pub fn XRRTimes (dpy: *mut Display, screen: c_int, config_timestamp: *mut Time) -> Time, 70 | pub fn XRRUpdateConfiguration (event: *mut XEvent) -> c_int, 71 | variadic: 72 | globals: 73 | } 74 | -------------------------------------------------------------------------------- /x11-dl/src/sync.rs: -------------------------------------------------------------------------------- 1 | ../../src/sync.rs -------------------------------------------------------------------------------- /x11-dl/src/xcursor.rs: -------------------------------------------------------------------------------- 1 | ../../src/xcursor.rs -------------------------------------------------------------------------------- /x11-dl/src/xf86vmode.rs: -------------------------------------------------------------------------------- 1 | ../../src/xf86vmode.rs -------------------------------------------------------------------------------- /x11-dl/src/xfixes.rs: -------------------------------------------------------------------------------- 1 | ../../src/xfixes.rs -------------------------------------------------------------------------------- /x11-dl/src/xft.rs: -------------------------------------------------------------------------------- 1 | ../../src/xft.rs -------------------------------------------------------------------------------- /x11-dl/src/xinerama.rs: -------------------------------------------------------------------------------- 1 | ../../src/xinerama.rs -------------------------------------------------------------------------------- /x11-dl/src/xinput.rs: -------------------------------------------------------------------------------- 1 | ../../src/xinput.rs -------------------------------------------------------------------------------- /x11-dl/src/xinput2.rs: -------------------------------------------------------------------------------- 1 | ../../src/xinput2.rs -------------------------------------------------------------------------------- /x11-dl/src/xlib.rs: -------------------------------------------------------------------------------- 1 | ../../src/xlib.rs -------------------------------------------------------------------------------- /x11-dl/src/xlib_xcb.rs: -------------------------------------------------------------------------------- 1 | ../../src/xlib_xcb.rs -------------------------------------------------------------------------------- /x11-dl/src/xmd.rs: -------------------------------------------------------------------------------- 1 | ../../src/xmd.rs -------------------------------------------------------------------------------- /x11-dl/src/xmu.rs: -------------------------------------------------------------------------------- 1 | ../../src/xmu.rs -------------------------------------------------------------------------------- /x11-dl/src/xpresent.rs: -------------------------------------------------------------------------------- 1 | ../../src/xpresent.rs -------------------------------------------------------------------------------- /x11-dl/src/xrandr.rs: -------------------------------------------------------------------------------- 1 | ../../src/xrandr.rs -------------------------------------------------------------------------------- /x11-dl/src/xrecord.rs: -------------------------------------------------------------------------------- 1 | ../../src/xrecord.rs -------------------------------------------------------------------------------- /x11-dl/src/xrender.rs: -------------------------------------------------------------------------------- 1 | ../../src/xrender.rs -------------------------------------------------------------------------------- /x11-dl/src/xshm.rs: -------------------------------------------------------------------------------- 1 | ../../src/xshm.rs -------------------------------------------------------------------------------- /x11-dl/src/xss.rs: -------------------------------------------------------------------------------- 1 | ../../src/xss.rs -------------------------------------------------------------------------------- /x11-dl/src/xt.rs: -------------------------------------------------------------------------------- 1 | ../../src/xt.rs -------------------------------------------------------------------------------- /x11-dl/src/xtest.rs: -------------------------------------------------------------------------------- 1 | ../../src/xtest.rs -------------------------------------------------------------------------------- /x11/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /x11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "x11" 3 | version = "2.21.0" 4 | authors = [ 5 | "daggerbot ", 6 | "Erle Pereira ", 7 | "AltF02 ", 8 | ] 9 | description = "X11 library bindings for Rust" 10 | license = "MIT" 11 | repository = "https://github.com/AltF02/x11-rs.git" 12 | build = "build.rs" 13 | documentation = "https://docs.rs/x11" 14 | workspace = ".." 15 | edition = "2021" 16 | 17 | [features] 18 | all = ["dpms", 19 | "glx", 20 | "xcursor", 21 | "xf86vmode", 22 | "xfixes", 23 | "xft", 24 | "xinerama", 25 | "xinput", 26 | "xlib", 27 | "xlib_xcb", 28 | "xmu", 29 | "xrandr", 30 | "xrecord", 31 | "xrender", 32 | "xss", 33 | "xt", 34 | "xtest", 35 | "xtst", 36 | "dox"] 37 | dpms = [] 38 | glx = [] 39 | xcursor = [] 40 | xf86vmode = [] 41 | xfixes = [] 42 | xft = [] 43 | xinerama = [] 44 | xinput = [] 45 | xlib = [] 46 | xlib_xcb = [] 47 | xmu = [] 48 | xrandr = [] 49 | xrecord = ["xtst"] 50 | xrender = [] 51 | xss = [] 52 | xt = [] 53 | xtest = ["xtst"] 54 | xtst = [] 55 | dox = [] 56 | 57 | [dependencies] 58 | libc = "0.2" 59 | 60 | [build-dependencies] 61 | pkg-config = "0.3.24" 62 | -------------------------------------------------------------------------------- /x11/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | ../LICENSE-MIT -------------------------------------------------------------------------------- /x11/build.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | extern crate pkg_config; 6 | 7 | use std::env; 8 | 9 | fn main() { 10 | if cfg!(feature = "dox") { 11 | return; 12 | } 13 | 14 | let deps = [ 15 | ("gl", "1", "glx"), 16 | ("x11", "1.4.99.1", "xlib"), 17 | ("x11-xcb", "1.6", "xlib_xcb"), 18 | ("xcursor", "1.1", "xcursor"), 19 | ("xext", "1.3", "dpms"), 20 | ("xfixes", "3.1", "xfixes"), 21 | ("xft", "2.1", "xft"), 22 | ("xi", "1.7", "xinput"), 23 | ("xinerama", "1.1", "xinerama"), 24 | ("xmu", "1.1", "xmu"), 25 | ("xrandr", "1.5", "xrandr"), 26 | ("xrender", "0.9.6", "xrender"), 27 | ("xpresent", "1", "xpresent"), 28 | ("xscrnsaver", "1.2", "xss"), 29 | ("xt", "1.1", "xt"), 30 | ("xtst", "1.2", "xtst"), 31 | ("xxf86vm", "1.1", "xf86vmode"), 32 | ]; 33 | 34 | for &(dep, version, feature) in deps.iter() { 35 | let var = format!("CARGO_FEATURE_{}", feature.to_uppercase().replace('-', "_")); 36 | if env::var_os(var).is_none() { 37 | continue; 38 | } 39 | pkg_config::Config::new() 40 | .atleast_version(version) 41 | .probe(dep) 42 | .unwrap(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /x11/examples/hello-world.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | #![cfg_attr(not(feature = "xlib"), allow(dead_code))] 6 | #![cfg_attr(not(feature = "xlib"), allow(unused_imports))] 7 | 8 | extern crate x11; 9 | 10 | use std::ffi::CString; 11 | use std::mem; 12 | use std::os::raw::*; 13 | use std::ptr; 14 | 15 | use x11::xlib; 16 | 17 | #[cfg(not(feature = "xlib"))] 18 | fn main() { 19 | panic!("this example requires `--features xlib`"); 20 | } 21 | 22 | #[cfg(feature = "xlib")] 23 | fn main() { 24 | unsafe { 25 | // Open display connection. 26 | let display = xlib::XOpenDisplay(ptr::null()); 27 | 28 | if display.is_null() { 29 | panic!("XOpenDisplay failed"); 30 | } 31 | 32 | // Create window. 33 | let screen = xlib::XDefaultScreen(display); 34 | let root = xlib::XRootWindow(display, screen); 35 | 36 | let mut attributes: xlib::XSetWindowAttributes = mem::MaybeUninit::uninit().assume_init(); 37 | attributes.background_pixel = xlib::XWhitePixel(display, screen); 38 | 39 | let window = xlib::XCreateWindow( 40 | display, 41 | root, 42 | 0, 43 | 0, 44 | 400, 45 | 300, 46 | 0, 47 | 0, 48 | xlib::InputOutput as c_uint, 49 | ptr::null_mut(), 50 | xlib::CWBackPixel, 51 | &mut attributes, 52 | ); 53 | 54 | // Set window title. 55 | let title_str = CString::new("hello-world").unwrap(); 56 | xlib::XStoreName(display, window, title_str.as_ptr() as *mut c_char); 57 | 58 | // Hook close requests. 59 | let wm_protocols_str = CString::new("WM_PROTOCOLS").unwrap(); 60 | let wm_delete_window_str = CString::new("WM_DELETE_WINDOW").unwrap(); 61 | 62 | let wm_protocols = xlib::XInternAtom(display, wm_protocols_str.as_ptr(), xlib::False); 63 | let wm_delete_window = 64 | xlib::XInternAtom(display, wm_delete_window_str.as_ptr(), xlib::False); 65 | 66 | let mut protocols = [wm_delete_window]; 67 | 68 | xlib::XSetWMProtocols( 69 | display, 70 | window, 71 | protocols.as_mut_ptr(), 72 | protocols.len() as c_int, 73 | ); 74 | 75 | // Show window. 76 | xlib::XMapWindow(display, window); 77 | 78 | // Main loop. 79 | let mut event: xlib::XEvent = mem::MaybeUninit::uninit().assume_init(); 80 | 81 | loop { 82 | xlib::XNextEvent(display, &mut event); 83 | 84 | match event.get_type() { 85 | xlib::ClientMessage => { 86 | let xclient = xlib::XClientMessageEvent::from(event); 87 | 88 | if xclient.message_type == wm_protocols && xclient.format == 32 { 89 | let protocol = xclient.data.get_long(0) as xlib::Atom; 90 | 91 | if protocol == wm_delete_window { 92 | break; 93 | } 94 | } 95 | } 96 | 97 | _ => (), 98 | } 99 | } 100 | 101 | // Shut down. 102 | xlib::XCloseDisplay(display); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /x11/examples/input.rs: -------------------------------------------------------------------------------- 1 | // XInput2 example for x11-rs 2 | // 3 | // This is a basic example showing how to use XInput2 to read 4 | // keyboard, mouse and other input events in X11. 5 | // 6 | // See Pete Hutterer's "XI2 Recipes" blog series, 7 | // starting at https://who-t.blogspot.com/2009/05/xi2-recipes-part-1.html 8 | // for a guide. 9 | 10 | #![cfg_attr(not(feature = "xlib"), allow(dead_code))] 11 | #![cfg_attr(not(feature = "xlib"), allow(unused_imports))] 12 | 13 | extern crate libc; 14 | extern crate x11; 15 | 16 | use std::ffi::CString; 17 | use std::mem::{transmute, zeroed}; 18 | use std::os::raw::*; 19 | use std::ptr::{null, null_mut}; 20 | use std::slice::from_raw_parts; 21 | use x11::{xinput2, xlib}; 22 | 23 | /// Provides a basic framework for connecting to an X Display, 24 | /// creating a window, displaying it and running the event loop 25 | pub struct DemoWindow { 26 | pub display: *mut xlib::Display, 27 | pub window: xlib::Window, 28 | 29 | wm_protocols: xlib::Atom, 30 | wm_delete_window: xlib::Atom, 31 | } 32 | 33 | impl DemoWindow { 34 | /// Create a new window with a given title and size 35 | pub fn new(title: &str, width: u32, height: u32) -> DemoWindow { 36 | unsafe { 37 | // Open display 38 | let display = xlib::XOpenDisplay(null()); 39 | if display == null_mut() { 40 | panic!("can't open display"); 41 | } 42 | 43 | // Load atoms 44 | let wm_delete_window_str = CString::new("WM_DELETE_WINDOW").unwrap(); 45 | let wm_protocols_str = CString::new("WM_PROTOCOLS").unwrap(); 46 | 47 | let wm_delete_window = 48 | xlib::XInternAtom(display, wm_delete_window_str.as_ptr(), xlib::False); 49 | let wm_protocols = xlib::XInternAtom(display, wm_protocols_str.as_ptr(), xlib::False); 50 | 51 | if wm_delete_window == 0 || wm_protocols == 0 { 52 | panic!("can't load atoms"); 53 | } 54 | 55 | // Create window 56 | let screen_num = xlib::XDefaultScreen(display); 57 | let root = xlib::XRootWindow(display, screen_num); 58 | let white_pixel = xlib::XWhitePixel(display, screen_num); 59 | 60 | let mut attributes: xlib::XSetWindowAttributes = zeroed(); 61 | attributes.background_pixel = white_pixel; 62 | 63 | let window = xlib::XCreateWindow( 64 | display, 65 | root, 66 | 0, 67 | 0, 68 | width as c_uint, 69 | height as c_uint, 70 | 0, 71 | 0, 72 | xlib::InputOutput as c_uint, 73 | null_mut(), 74 | xlib::CWBackPixel, 75 | &mut attributes, 76 | ); 77 | // Set window title 78 | let title_str = CString::new(title).unwrap(); 79 | xlib::XStoreName(display, window, title_str.as_ptr() as *mut _); 80 | 81 | // Subscribe to delete (close) events 82 | let mut protocols = [wm_delete_window]; 83 | 84 | if xlib::XSetWMProtocols(display, window, &mut protocols[0] as *mut xlib::Atom, 1) 85 | == xlib::False 86 | { 87 | panic!("can't set WM protocols"); 88 | } 89 | 90 | DemoWindow { 91 | display: display, 92 | window: window, 93 | wm_protocols: wm_protocols, 94 | wm_delete_window: wm_delete_window, 95 | } 96 | } 97 | } 98 | 99 | /// Display the window 100 | pub fn show(&mut self) { 101 | unsafe { 102 | xlib::XMapWindow(self.display, self.window); 103 | } 104 | } 105 | 106 | /// Process events for the window. Window close events are handled automatically, 107 | /// other events are passed on to |event_handler| 108 | pub fn run_event_loop(&mut self, mut event_handler: EventHandler) 109 | where 110 | EventHandler: FnMut(&xlib::XEvent), 111 | { 112 | let mut event: xlib::XEvent = unsafe { zeroed() }; 113 | loop { 114 | unsafe { xlib::XNextEvent(self.display, &mut event) }; 115 | match event.get_type() { 116 | xlib::ClientMessage => { 117 | let xclient: xlib::XClientMessageEvent = From::from(event); 118 | 119 | // WM_PROTOCOLS client message 120 | if xclient.message_type == self.wm_protocols && xclient.format == 32 { 121 | let protocol = xclient.data.get_long(0) as xlib::Atom; 122 | 123 | // WM_DELETE_WINDOW (close event) 124 | if protocol == self.wm_delete_window { 125 | break; 126 | } 127 | } 128 | } 129 | _ => event_handler(&event), 130 | } 131 | } 132 | } 133 | } 134 | 135 | impl Drop for DemoWindow { 136 | /// Destroys the window and disconnects from the display 137 | fn drop(&mut self) { 138 | unsafe { 139 | xlib::XDestroyWindow(self.display, self.window); 140 | xlib::XCloseDisplay(self.display); 141 | } 142 | } 143 | } 144 | 145 | const TITLE: &'static str = "XInput Demo"; 146 | const DEFAULT_WIDTH: c_uint = 640; 147 | const DEFAULT_HEIGHT: c_uint = 480; 148 | 149 | #[derive(Debug)] 150 | enum AxisType { 151 | HorizontalScroll, 152 | VerticalScroll, 153 | Other, 154 | } 155 | 156 | #[derive(Debug)] 157 | struct Axis { 158 | id: i32, 159 | device_id: i32, 160 | axis_number: i32, 161 | axis_type: AxisType, 162 | } 163 | 164 | #[derive(Debug)] 165 | struct AxisValue { 166 | device_id: i32, 167 | axis_number: i32, 168 | value: f64, 169 | } 170 | 171 | struct InputState { 172 | cursor_pos: (f64, f64), 173 | axis_values: Vec, 174 | } 175 | 176 | fn read_input_axis_info(display: *mut xlib::Display) -> Vec { 177 | let mut axis_list = Vec::new(); 178 | let mut device_count = 0; 179 | 180 | // only get events from the master devices which are 'attached' 181 | // to the keyboard or cursor 182 | let devices = 183 | unsafe { xinput2::XIQueryDevice(display, xinput2::XIAllMasterDevices, &mut device_count) }; 184 | for i in 0..device_count { 185 | let device = unsafe { *(devices.offset(i as isize)) }; 186 | for k in 0..device.num_classes { 187 | let class = unsafe { *(device.classes.offset(k as isize)) }; 188 | match unsafe { (*class)._type } { 189 | xinput2::XIScrollClass => { 190 | let scroll_class: &xinput2::XIScrollClassInfo = unsafe { transmute(class) }; 191 | axis_list.push(Axis { 192 | id: scroll_class.sourceid, 193 | device_id: device.deviceid, 194 | axis_number: scroll_class.number, 195 | axis_type: match scroll_class.scroll_type { 196 | xinput2::XIScrollTypeHorizontal => AxisType::HorizontalScroll, 197 | xinput2::XIScrollTypeVertical => AxisType::VerticalScroll, 198 | _ => { 199 | unreachable!() 200 | } 201 | }, 202 | }) 203 | } 204 | xinput2::XIValuatorClass => { 205 | let valuator_class: &xinput2::XIValuatorClassInfo = unsafe { transmute(class) }; 206 | axis_list.push(Axis { 207 | id: valuator_class.sourceid, 208 | device_id: device.deviceid, 209 | axis_number: valuator_class.number, 210 | axis_type: AxisType::Other, 211 | }) 212 | } 213 | _ => { /* TODO */ } 214 | } 215 | } 216 | } 217 | 218 | axis_list.sort_by(|a, b| { 219 | if a.device_id != b.device_id { 220 | a.device_id.cmp(&b.device_id) 221 | } else if a.id != b.id { 222 | a.id.cmp(&b.id) 223 | } else { 224 | a.axis_number.cmp(&b.axis_number) 225 | } 226 | }); 227 | axis_list 228 | } 229 | 230 | /// Given an input motion event for an axis and the previous 231 | /// state of the axises, return the horizontal/vertical 232 | /// scroll deltas 233 | fn calc_scroll_deltas( 234 | event: &xinput2::XIDeviceEvent, 235 | axis_id: i32, 236 | axis_value: f64, 237 | axis_list: &[Axis], 238 | prev_axis_values: &mut Vec, 239 | ) -> (f64, f64) { 240 | let prev_value_pos = prev_axis_values.iter().position(|prev_axis| { 241 | prev_axis.device_id == event.sourceid && prev_axis.axis_number == axis_id 242 | }); 243 | let delta = match prev_value_pos { 244 | Some(idx) => axis_value - prev_axis_values[idx].value, 245 | None => 0.0, 246 | }; 247 | 248 | let new_axis_value = AxisValue { 249 | device_id: event.sourceid, 250 | axis_number: axis_id, 251 | value: axis_value, 252 | }; 253 | 254 | match prev_value_pos { 255 | Some(idx) => prev_axis_values[idx] = new_axis_value, 256 | None => prev_axis_values.push(new_axis_value), 257 | } 258 | 259 | let mut scroll_delta = (0.0, 0.0); 260 | 261 | for axis in axis_list.iter() { 262 | if axis.id == event.sourceid && axis.axis_number == axis_id { 263 | match axis.axis_type { 264 | AxisType::HorizontalScroll => scroll_delta.0 = delta, 265 | AxisType::VerticalScroll => scroll_delta.1 = delta, 266 | _ => {} 267 | } 268 | } 269 | } 270 | 271 | scroll_delta 272 | } 273 | 274 | #[cfg(not(all(feature = "xlib", feature = "xinput")))] 275 | fn main() { 276 | panic!("this example requires `--features 'xlib xinput'`"); 277 | } 278 | 279 | #[cfg(all(feature = "xlib", feature = "xinput"))] 280 | fn main() { 281 | let mut demo_window = DemoWindow::new(TITLE, DEFAULT_WIDTH, DEFAULT_HEIGHT); 282 | 283 | // query XInput support 284 | let mut opcode: c_int = 0; 285 | let mut event: c_int = 0; 286 | let mut error: c_int = 0; 287 | let xinput_str = CString::new("XInputExtension").unwrap(); 288 | let xinput_available = unsafe { 289 | xlib::XQueryExtension( 290 | demo_window.display, 291 | xinput_str.as_ptr(), 292 | &mut opcode, 293 | &mut event, 294 | &mut error, 295 | ) 296 | }; 297 | if xinput_available == xlib::False { 298 | panic!("XInput not available") 299 | } 300 | 301 | let mut xinput_major_ver = xinput2::XI_2_Major; 302 | let mut xinput_minor_ver = xinput2::XI_2_Minor; 303 | if unsafe { 304 | xinput2::XIQueryVersion( 305 | demo_window.display, 306 | &mut xinput_major_ver, 307 | &mut xinput_minor_ver, 308 | ) 309 | } != xlib::Success as c_int 310 | { 311 | panic!("XInput2 not available"); 312 | } 313 | println!( 314 | "XI version available {}.{}", 315 | xinput_major_ver, xinput_minor_ver 316 | ); 317 | 318 | // init XInput events 319 | let mut mask: [c_uchar; 1] = [0]; 320 | let mut input_event_mask = xinput2::XIEventMask { 321 | deviceid: xinput2::XIAllMasterDevices, 322 | mask_len: mask.len() as i32, 323 | mask: mask.as_mut_ptr(), 324 | }; 325 | let events = &[ 326 | xinput2::XI_ButtonPress, 327 | xinput2::XI_ButtonRelease, 328 | xinput2::XI_KeyPress, 329 | xinput2::XI_KeyRelease, 330 | xinput2::XI_Motion, 331 | ]; 332 | for &event in events { 333 | xinput2::XISetMask(&mut mask, event); 334 | } 335 | 336 | match unsafe { 337 | xinput2::XISelectEvents( 338 | demo_window.display, 339 | demo_window.window, 340 | &mut input_event_mask, 341 | 1, 342 | ) 343 | } { 344 | status if status as u8 == xlib::Success => (), 345 | err => panic!("Failed to select events {:?}", err), 346 | } 347 | 348 | // Show window 349 | demo_window.show(); 350 | 351 | // Main loop 352 | let display = demo_window.display; 353 | let axis_list = read_input_axis_info(display); 354 | 355 | let mut prev_state = InputState { 356 | cursor_pos: (0.0, 0.0), 357 | axis_values: Vec::new(), 358 | }; 359 | 360 | demo_window.run_event_loop(|event| match event.get_type() { 361 | xlib::GenericEvent => { 362 | let mut cookie: xlib::XGenericEventCookie = From::from(*event); 363 | if unsafe { xlib::XGetEventData(display, &mut cookie) } != xlib::True { 364 | println!("Failed to retrieve event data"); 365 | return; 366 | } 367 | match cookie.evtype { 368 | xinput2::XI_KeyPress | xinput2::XI_KeyRelease => { 369 | let event_data: &xinput2::XIDeviceEvent = unsafe { transmute(cookie.data) }; 370 | if cookie.evtype == xinput2::XI_KeyPress { 371 | if event_data.flags & xinput2::XIKeyRepeat == 0 { 372 | println!("Key {} pressed", event_data.detail); 373 | } 374 | } else { 375 | println!("Key {} released", event_data.detail); 376 | } 377 | } 378 | xinput2::XI_ButtonPress | xinput2::XI_ButtonRelease => { 379 | let event_data: &xinput2::XIDeviceEvent = unsafe { transmute(cookie.data) }; 380 | if cookie.evtype == xinput2::XI_ButtonPress { 381 | println!("Button {} pressed", event_data.detail); 382 | } else { 383 | println!("Button {} released", event_data.detail); 384 | } 385 | } 386 | xinput2::XI_Motion => { 387 | let event_data: &xinput2::XIDeviceEvent = unsafe { transmute(cookie.data) }; 388 | let axis_state = event_data.valuators; 389 | let mask = 390 | unsafe { from_raw_parts(axis_state.mask, axis_state.mask_len as usize) }; 391 | let mut axis_count = 0; 392 | 393 | let mut scroll_delta = (0.0, 0.0); 394 | for axis_id in 0..axis_state.mask_len { 395 | if xinput2::XIMaskIsSet(&mask, axis_id) { 396 | let axis_value = unsafe { *axis_state.values.offset(axis_count) }; 397 | let delta = calc_scroll_deltas( 398 | event_data, 399 | axis_id, 400 | axis_value, 401 | &axis_list, 402 | &mut prev_state.axis_values, 403 | ); 404 | scroll_delta.0 += delta.0; 405 | scroll_delta.1 += delta.1; 406 | axis_count += 1; 407 | } 408 | } 409 | 410 | if scroll_delta.0.abs() > 0.0 || scroll_delta.1.abs() > 0.0 { 411 | println!( 412 | "Mouse wheel/trackpad scrolled by ({}, {})", 413 | scroll_delta.0, scroll_delta.1 414 | ); 415 | } 416 | 417 | let new_cursor_pos = (event_data.event_x, event_data.event_y); 418 | if new_cursor_pos != prev_state.cursor_pos { 419 | println!( 420 | "Mouse moved to ({}, {})", 421 | new_cursor_pos.0, new_cursor_pos.1 422 | ); 423 | prev_state.cursor_pos = new_cursor_pos; 424 | } 425 | } 426 | _ => (), 427 | } 428 | unsafe { xlib::XFreeEventData(display, &mut cookie) }; 429 | } 430 | _ => (), 431 | }); 432 | } 433 | -------------------------------------------------------------------------------- /x11/examples/xrecord.rs: -------------------------------------------------------------------------------- 1 | // Example for X Record Extension 2 | 3 | #![cfg_attr(not(feature = "xlib"), allow(dead_code))] 4 | #![cfg_attr(not(feature = "xlib"), allow(unused_imports))] 5 | 6 | extern crate libc; 7 | extern crate x11; 8 | 9 | use std::ffi::CString; 10 | use std::ptr::{null, null_mut}; 11 | 12 | use std::os::raw::c_int; 13 | use x11::xlib; 14 | use x11::xrecord; 15 | 16 | static mut EVENT_COUNT: u32 = 0; 17 | 18 | #[cfg(not(all(feature = "xlib", feature = "xrecord")))] 19 | fn main() { 20 | panic!("this example requires `--features 'xlib xrecord'`"); 21 | } 22 | 23 | #[cfg(all(feature = "xlib", feature = "xrecord"))] 24 | fn main() { 25 | unsafe { 26 | // Open displays 27 | let dpy_control = xlib::XOpenDisplay(null()); 28 | let dpy_data = xlib::XOpenDisplay(null()); 29 | if dpy_control == null_mut() || dpy_data == null_mut() { 30 | panic!("can't open display"); 31 | } 32 | // Enable synchronization 33 | xlib::XSynchronize(dpy_control, 1); 34 | 35 | let extension_name = CString::new("RECORD").unwrap(); 36 | 37 | let extension = xlib::XInitExtension(dpy_control, extension_name.as_ptr()); 38 | if extension.is_null() { 39 | panic!("Error init X Record Extension"); 40 | } 41 | 42 | // Get version 43 | let mut version_major: c_int = 0; 44 | let mut version_minor: c_int = 0; 45 | xrecord::XRecordQueryVersion(dpy_control, &mut version_major, &mut version_minor); 46 | println!( 47 | "RECORD extension version {}.{}", 48 | version_major, version_minor 49 | ); 50 | 51 | // Prepare record range 52 | let mut record_range: xrecord::XRecordRange = *xrecord::XRecordAllocRange(); 53 | record_range.device_events.first = xlib::KeyPress as u8; 54 | record_range.device_events.last = xlib::MotionNotify as u8; 55 | 56 | // Create context 57 | let context = xrecord::XRecordCreateContext( 58 | dpy_control, 59 | 0, 60 | &mut xrecord::XRecordAllClients, 61 | 1, 62 | std::mem::transmute(&mut &mut record_range), 63 | 1, 64 | ); 65 | 66 | if context == 0 { 67 | panic!("Fail create Record context\n"); 68 | } 69 | 70 | // Run 71 | let result = 72 | xrecord::XRecordEnableContext(dpy_data, context, Some(record_callback), &mut 0); 73 | if result == 0 { 74 | panic!("Cound not enable the Record context!\n"); 75 | } 76 | } 77 | } 78 | 79 | unsafe extern "C" fn record_callback(_: *mut i8, raw_data: *mut xrecord::XRecordInterceptData) { 80 | EVENT_COUNT += 1; 81 | let data = &*raw_data; 82 | 83 | // Skip server events 84 | if data.category != xrecord::XRecordFromServer { 85 | return; 86 | } 87 | 88 | // Cast binary data 89 | let xdatum = &*(data.data as *mut XRecordDatum); 90 | 91 | let event_type = match xdatum.xtype as i32 { 92 | xlib::KeyPress => "KeyPress", 93 | xlib::KeyRelease => "KeyRelease", 94 | xlib::ButtonPress => "ButtonPress", 95 | xlib::ButtonRelease => "ButtonRelease", 96 | xlib::MotionNotify => "MotionNotify", 97 | _ => "Other", 98 | }; 99 | 100 | println!("Event recieve\t{:?}\tevent.", event_type); 101 | 102 | xrecord::XRecordFreeData(raw_data); 103 | } 104 | 105 | #[repr(C)] 106 | struct XRecordDatum { 107 | xtype: u8, 108 | code: u8, 109 | unknown1: u8, 110 | unknown2: u8, 111 | } 112 | -------------------------------------------------------------------------------- /x11/src/dpms.rs: -------------------------------------------------------------------------------- 1 | ../../src/dpms.rs -------------------------------------------------------------------------------- /x11/src/glx.rs: -------------------------------------------------------------------------------- 1 | ../../src/glx.rs -------------------------------------------------------------------------------- /x11/src/internal.rs: -------------------------------------------------------------------------------- 1 | ../../src/internal.rs -------------------------------------------------------------------------------- /x11/src/keysym.rs: -------------------------------------------------------------------------------- 1 | ../../src/keysym.rs -------------------------------------------------------------------------------- /x11/src/lib.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | #![allow(non_camel_case_types)] 6 | #![allow(non_snake_case)] 7 | #![allow(non_upper_case_globals)] 8 | #![allow(improper_ctypes)] 9 | #![allow(deref_nullptr)] 10 | #![allow(clippy::missing_safety_doc)] 11 | 12 | extern crate libc; 13 | 14 | #[macro_use] 15 | mod link; 16 | mod internal; 17 | 18 | #[macro_use] 19 | pub mod xlib; 20 | 21 | pub mod dpms; 22 | pub mod glx; 23 | pub mod keysym; 24 | pub mod sync; 25 | pub mod xcursor; 26 | pub mod xf86vmode; 27 | pub mod xfixes; 28 | pub mod xft; 29 | pub mod xinerama; 30 | pub mod xinput; 31 | pub mod xinput2; 32 | pub mod xlib_xcb; 33 | pub mod xmd; 34 | pub mod xmu; 35 | pub mod xpresent; 36 | pub mod xrandr; 37 | pub mod xrecord; 38 | pub mod xrender; 39 | pub mod xshm; 40 | pub mod xss; 41 | pub mod xt; 42 | pub mod xtest; 43 | -------------------------------------------------------------------------------- /x11/src/link.rs: -------------------------------------------------------------------------------- 1 | // x11-rs: Rust bindings for X11 libraries 2 | // The X11 libraries are available under the MIT license. 3 | // These bindings are public domain. 4 | 5 | macro_rules! x11_link { 6 | { $struct_name:ident, $pkg_name:expr, [$($lib_name:expr),*], $nsyms:expr, 7 | $(pub fn $fn_name:ident ($($param_name:ident : $param_type:ty),*) -> $ret_type:ty,)* 8 | variadic: 9 | $(pub fn $vfn_name:ident ($($vparam_name: ident : $vparam_type:ty),+) -> $vret_type:ty,)* 10 | globals: 11 | $(pub static $var_name:ident : $var_type:ty,)* 12 | } => { 13 | extern "C" { 14 | $(pub fn $fn_name ($($param_name : $param_type),*) -> $ret_type;)* 15 | $(pub fn $vfn_name ($($vparam_name : $vparam_type),+, ...) -> $vret_type;)* 16 | } 17 | 18 | extern { 19 | $(pub static $var_name : $var_type;)* 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /x11/src/sync.rs: -------------------------------------------------------------------------------- 1 | ../../src/sync.rs -------------------------------------------------------------------------------- /x11/src/xcursor.rs: -------------------------------------------------------------------------------- 1 | ../../src/xcursor.rs -------------------------------------------------------------------------------- /x11/src/xf86vmode.rs: -------------------------------------------------------------------------------- 1 | ../../src/xf86vmode.rs -------------------------------------------------------------------------------- /x11/src/xfixes.rs: -------------------------------------------------------------------------------- 1 | ../../src/xfixes.rs -------------------------------------------------------------------------------- /x11/src/xft.rs: -------------------------------------------------------------------------------- 1 | ../../src/xft.rs -------------------------------------------------------------------------------- /x11/src/xinerama.rs: -------------------------------------------------------------------------------- 1 | ../../src/xinerama.rs -------------------------------------------------------------------------------- /x11/src/xinput.rs: -------------------------------------------------------------------------------- 1 | ../../src/xinput.rs -------------------------------------------------------------------------------- /x11/src/xinput2.rs: -------------------------------------------------------------------------------- 1 | ../../src/xinput2.rs -------------------------------------------------------------------------------- /x11/src/xlib.rs: -------------------------------------------------------------------------------- 1 | ../../src/xlib.rs -------------------------------------------------------------------------------- /x11/src/xlib_xcb.rs: -------------------------------------------------------------------------------- 1 | ../../src/xlib_xcb.rs -------------------------------------------------------------------------------- /x11/src/xmd.rs: -------------------------------------------------------------------------------- 1 | ../../src/xmd.rs -------------------------------------------------------------------------------- /x11/src/xmu.rs: -------------------------------------------------------------------------------- 1 | ../../src/xmu.rs -------------------------------------------------------------------------------- /x11/src/xpresent.rs: -------------------------------------------------------------------------------- 1 | ../../src/xpresent.rs -------------------------------------------------------------------------------- /x11/src/xrandr.rs: -------------------------------------------------------------------------------- 1 | ../../src/xrandr.rs -------------------------------------------------------------------------------- /x11/src/xrecord.rs: -------------------------------------------------------------------------------- 1 | ../../src/xrecord.rs -------------------------------------------------------------------------------- /x11/src/xrender.rs: -------------------------------------------------------------------------------- 1 | ../../src/xrender.rs -------------------------------------------------------------------------------- /x11/src/xshm.rs: -------------------------------------------------------------------------------- 1 | ../../src/xshm.rs -------------------------------------------------------------------------------- /x11/src/xss.rs: -------------------------------------------------------------------------------- 1 | ../../src/xss.rs -------------------------------------------------------------------------------- /x11/src/xt.rs: -------------------------------------------------------------------------------- 1 | ../../src/xt.rs -------------------------------------------------------------------------------- /x11/src/xtest.rs: -------------------------------------------------------------------------------- 1 | ../../src/xtest.rs --------------------------------------------------------------------------------