├── .gitignore ├── COPYING ├── Cargo.toml ├── README.md ├── flake.lock ├── flake.nix └── src ├── cursor.rs ├── ewmh.rs ├── ffi ├── ewmh.rs ├── icccm.rs ├── image.rs ├── keysyms.rs ├── mod.rs └── render.rs ├── icccm.rs ├── image.rs ├── keysyms.rs ├── lib.rs ├── misc.rs ├── render.rs └── util.rs /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | Cargo.lock 3 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 meh. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "xcb-util" 3 | version = "0.4.0" 4 | 5 | authors = ["meh. "] 6 | license = "MIT" 7 | 8 | description = "Rust bindings and wrappers for XCB utility functions." 9 | repository = "https://github.com/meh/rust-xcb-util" 10 | keywords = ["x11", "xcb"] 11 | 12 | [dependencies] 13 | libc = "0.2" 14 | xcb = "0.10" 15 | 16 | [features] 17 | static = [] 18 | shm = ["xcb/shm"] 19 | thread = ["xcb/thread"] 20 | 21 | icccm = [] 22 | ewmh = [] 23 | image = [] 24 | cursor = [] 25 | keysyms = [] 26 | misc = ["icccm"] 27 | render = [] 28 | 29 | [package.metadata.docs.rs] 30 | all-features = true 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xcb-util 2 | [![crates](https://img.shields.io/crates/v/xcb-util.svg)](https://crates.io/crates/xcb-util) 3 | [![docs.rs](https://docs.rs/xcb-util/badge.svg)](https://docs.rs/xcb-util/) 4 | 5 | Rust bindings and wrappers for XCB utility functions. 6 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "fenix": { 4 | "inputs": { 5 | "nixpkgs": [ 6 | "nixpkgs" 7 | ], 8 | "rust-analyzer-src": "rust-analyzer-src" 9 | }, 10 | "locked": { 11 | "lastModified": 1634161690, 12 | "narHash": "sha256-thPhsv1wYSLX+ZhuyHbQLB/TlUPpjyD4S/XlHZSxCuQ=", 13 | "owner": "nix-community", 14 | "repo": "fenix", 15 | "rev": "53018ee7fd8244c2252b1c3d6f4dc9aff30f1ec2", 16 | "type": "github" 17 | }, 18 | "original": { 19 | "owner": "nix-community", 20 | "repo": "fenix", 21 | "type": "github" 22 | } 23 | }, 24 | "nixpkgs": { 25 | "locked": { 26 | "lastModified": 1633329294, 27 | "narHash": "sha256-0LpQLS4KMgxslMgmDHmxG/5twFlXDBW9z4Or1iOrCvU=", 28 | "owner": "NixOS", 29 | "repo": "nixpkgs", 30 | "rev": "ee084c02040e864eeeb4cf4f8538d92f7c675671", 31 | "type": "github" 32 | }, 33 | "original": { 34 | "owner": "NixOS", 35 | "ref": "nixpkgs-unstable", 36 | "repo": "nixpkgs", 37 | "type": "github" 38 | } 39 | }, 40 | "root": { 41 | "inputs": { 42 | "fenix": "fenix", 43 | "nixpkgs": "nixpkgs", 44 | "utils": "utils" 45 | } 46 | }, 47 | "rust-analyzer-src": { 48 | "flake": false, 49 | "locked": { 50 | "lastModified": 1634066987, 51 | "narHash": "sha256-YgoOqnB0OrplGOK5PEmedZp4ucgN6Ax6MxCbQrhVK4Y=", 52 | "owner": "rust-analyzer", 53 | "repo": "rust-analyzer", 54 | "rev": "137ac67f5dd10d8a5e83e9eeb7600993e9886c8a", 55 | "type": "github" 56 | }, 57 | "original": { 58 | "owner": "rust-analyzer", 59 | "ref": "nightly", 60 | "repo": "rust-analyzer", 61 | "type": "github" 62 | } 63 | }, 64 | "utils": { 65 | "locked": { 66 | "lastModified": 1631561581, 67 | "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", 68 | "owner": "numtide", 69 | "repo": "flake-utils", 70 | "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", 71 | "type": "github" 72 | }, 73 | "original": { 74 | "owner": "numtide", 75 | "repo": "flake-utils", 76 | "type": "github" 77 | } 78 | } 79 | }, 80 | "root": "root", 81 | "version": 7 82 | } 83 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs = { 3 | nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 4 | utils.url = "github:numtide/flake-utils"; 5 | fenix = { 6 | url = "github:nix-community/fenix"; 7 | inputs.nixpkgs.follows = "nixpkgs"; 8 | }; 9 | }; 10 | 11 | outputs = { self, utils, nixpkgs, fenix, }: utils.lib.eachDefaultSystem (system: let 12 | pkgs = nixpkgs.legacyPackages.${system}; 13 | rust = fenix.packages.${system}; 14 | lib = pkgs.lib; 15 | in { 16 | devShell = pkgs.mkShell { 17 | buildInputs = with pkgs; with llvmPackages; with python37Packages; [ 18 | # For building. 19 | clang rust.latest.toolchain pkg-config openssl libsodium libclang.lib 20 | libxkbcommon xorg.libxcb 21 | ]; 22 | 23 | LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; 24 | RUST_BACKTRACE = 1; 25 | # RUST_LOG = "info,sqlx::query=warn"; 26 | RUSTFLAGS = "-C target-cpu=native"; 27 | }; 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /src/cursor.rs: -------------------------------------------------------------------------------- 1 | use xcb; 2 | 3 | pub const NUM_GLYPHS: u16 = 154; 4 | pub const X_CURSOR: u16 = 0; 5 | pub const ARROW: u16 = 2; 6 | pub const BASED_ARROW_DOWN: u16 = 4; 7 | pub const BASED_ARROW_UP: u16 = 6; 8 | pub const BOAT: u16 = 8; 9 | pub const BOGOSITY: u16 = 10; 10 | pub const BOTTOM_LEFT_CORNER: u16 = 12; 11 | pub const BOTTOM_RIGHT_CORNER: u16 = 14; 12 | pub const BOTTOM_SIDE: u16 = 16; 13 | pub const BOTTOM_TEE: u16 = 18; 14 | pub const BOX_SPIRAL: u16 = 20; 15 | pub const CENTER_PTR: u16 = 22; 16 | pub const CIRCLE: u16 = 24; 17 | pub const CLOCK: u16 = 26; 18 | pub const COFFEE_MUG: u16 = 28; 19 | pub const CROSS: u16 = 30; 20 | pub const CROSS_REVERSE: u16 = 32; 21 | pub const CROSSHAIR: u16 = 34; 22 | pub const DIAMOND_CROSS: u16 = 36; 23 | pub const DOT: u16 = 38; 24 | pub const DOTBOX: u16 = 40; 25 | pub const DOUBLE_ARROW: u16 = 42; 26 | pub const DRAFT_LARGE: u16 = 44; 27 | pub const DRAFT_SMALL: u16 = 46; 28 | pub const DRAPED_BOX: u16 = 48; 29 | pub const EXCHANGE: u16 = 50; 30 | pub const FLEUR: u16 = 52; 31 | pub const GOBBLER: u16 = 54; 32 | pub const GUMBY: u16 = 56; 33 | pub const HAND1: u16 = 58; 34 | pub const HAND2: u16 = 60; 35 | pub const HEART: u16 = 62; 36 | pub const ICON: u16 = 64; 37 | pub const IRON_CROSS: u16 = 66; 38 | pub const LEFT_PTR: u16 = 68; 39 | pub const LEFT_SIDE: u16 = 70; 40 | pub const LEFT_TEE: u16 = 72; 41 | pub const LEFTBUTTON: u16 = 74; 42 | pub const LL_ANGLE: u16 = 76; 43 | pub const LR_ANGLE: u16 = 78; 44 | pub const MAN: u16 = 80; 45 | pub const MIDDLEBUTTON: u16 = 82; 46 | pub const MOUSE: u16 = 84; 47 | pub const PENCIL: u16 = 86; 48 | pub const PIRATE: u16 = 88; 49 | pub const PLUS: u16 = 90; 50 | pub const QUESTION_ARROW: u16 = 92; 51 | pub const RIGHT_PTR: u16 = 94; 52 | pub const RIGHT_SIDE: u16 = 96; 53 | pub const RIGHT_TEE: u16 = 98; 54 | pub const RIGHTBUTTON: u16 = 100; 55 | pub const RTL_LOGO: u16 = 102; 56 | pub const SAILBOAT: u16 = 104; 57 | pub const SB_DOWN_ARROW: u16 = 106; 58 | pub const SB_H_DOUBLE_ARROW: u16 = 108; 59 | pub const SB_LEFT_ARROW: u16 = 110; 60 | pub const SB_RIGHT_ARROW: u16 = 112; 61 | pub const SB_UP_ARROW: u16 = 114; 62 | pub const SB_V_DOUBLE_ARROW: u16 = 116; 63 | pub const SHUTTLE: u16 = 118; 64 | pub const SIZING: u16 = 120; 65 | pub const SPIDER: u16 = 122; 66 | pub const SPRAYCAN: u16 = 124; 67 | pub const STAR: u16 = 126; 68 | pub const TARGET: u16 = 128; 69 | pub const TCROSS: u16 = 130; 70 | pub const TOP_LEFT_ARROW: u16 = 132; 71 | pub const TOP_LEFT_CORNER: u16 = 134; 72 | pub const TOP_RIGHT_CORNER: u16 = 136; 73 | pub const TOP_SIDE: u16 = 138; 74 | pub const TOP_TEE: u16 = 140; 75 | pub const TREK: u16 = 142; 76 | pub const UL_ANGLE: u16 = 144; 77 | pub const UMBRELLA: u16 = 146; 78 | pub const UR_ANGLE: u16 = 148; 79 | pub const WATCH: u16 = 150; 80 | pub const XTERM: u16 = 152; 81 | 82 | pub fn create_font_cursor(c: &xcb::Connection, glyph: u16) -> xcb::Cursor { 83 | let font = c.generate_id(); 84 | xcb::open_font(c, font, "cursor"); 85 | 86 | let cursor = c.generate_id(); 87 | xcb::create_glyph_cursor(c, cursor, font, font, glyph, glyph + 1, 88 | 0, 0, 0, 0xffff, 0xffff, 0xffff); 89 | 90 | cursor 91 | } 92 | 93 | pub fn create_font_cursor_checked(c: &xcb::Connection, glyph: u16) -> Result { 94 | let font = c.generate_id(); 95 | xcb::open_font_checked(c, font, "cursor").request_check()?; 96 | 97 | let cursor = c.generate_id(); 98 | xcb::create_glyph_cursor(c, cursor, font, font, glyph, glyph + 1, 99 | 0, 0, 0, 0xffff, 0xffff, 0xffff).request_check()?; 100 | 101 | Ok(cursor) 102 | } 103 | -------------------------------------------------------------------------------- /src/ewmh.rs: -------------------------------------------------------------------------------- 1 | use std::mem; 2 | use std::ptr; 3 | use std::slice; 4 | use std::str; 5 | use std::ops::{Deref, DerefMut}; 6 | 7 | use xcb; 8 | use xcb::ffi::*; 9 | use ffi::ewmh::*; 10 | use libc::c_int; 11 | use util::utf8; 12 | 13 | pub type Coordinates = xcb_ewmh_coordinates_t; 14 | 15 | impl Coordinates { 16 | pub fn x(&self) -> u32 { 17 | self.x 18 | } 19 | 20 | pub fn y(&self) -> u32 { 21 | self.y 22 | } 23 | } 24 | 25 | pub type Geometry = xcb_ewmh_geometry_t; 26 | 27 | impl Geometry { 28 | pub fn x(&self) -> u32 { 29 | self.x 30 | } 31 | 32 | pub fn y(&self) -> u32 { 33 | self.y 34 | } 35 | 36 | pub fn width(&self) -> u32 { 37 | self.width 38 | } 39 | 40 | pub fn height(&self) -> u32 { 41 | self.height 42 | } 43 | } 44 | 45 | pub type StrutPartial = xcb_ewmh_wm_strut_partial_t; 46 | 47 | impl StrutPartial { 48 | pub fn left(&self) -> u32 { 49 | self.left 50 | } 51 | 52 | pub fn right(&self) -> u32 { 53 | self.right 54 | } 55 | 56 | pub fn top(&self) -> u32 { 57 | self.top 58 | } 59 | 60 | pub fn bottom(&self) -> u32 { 61 | self.bottom 62 | } 63 | 64 | pub fn left_start_y(&self) -> u32 { 65 | self.left_start_y 66 | } 67 | 68 | pub fn left_end_y(&self) -> u32 { 69 | self.left_end_y 70 | } 71 | 72 | pub fn right_start_y(&self) -> u32 { 73 | self.right_start_y 74 | } 75 | 76 | pub fn right_end_y(&self) -> u32 { 77 | self.right_end_y 78 | } 79 | 80 | pub fn top_start_x(&self) -> u32 { 81 | self.top_start_x 82 | } 83 | 84 | pub fn top_end_x(&self) -> u32 { 85 | self.top_end_x 86 | } 87 | 88 | pub fn bottom_start_x(&self) -> u32 { 89 | self.bottom_start_x 90 | } 91 | 92 | pub fn bottom_end_x(&self) -> u32 { 93 | self.bottom_end_x 94 | } 95 | } 96 | 97 | pub type Extents = xcb_ewmh_get_extents_reply_t; 98 | 99 | impl Extents { 100 | pub fn top(&self) -> u32 { 101 | self.top 102 | } 103 | 104 | pub fn bottom(&self) -> u32 { 105 | self.bottom 106 | } 107 | 108 | pub fn left(&self) -> u32 { 109 | self.left 110 | } 111 | 112 | pub fn right(&self) -> u32 { 113 | self.right 114 | } 115 | } 116 | 117 | pub struct WmIcon { 118 | width: u32, 119 | height: u32, 120 | id: u32, 121 | } 122 | 123 | impl WmIcon { 124 | pub fn width(&self) -> u32 { 125 | self.width 126 | } 127 | 128 | pub fn height(&self) -> u32 { 129 | self.height 130 | } 131 | 132 | pub fn id(&self) -> u32 { 133 | self.id 134 | } 135 | } 136 | 137 | 138 | pub type WmIconIterator = xcb_ewmh_wm_icon_iterator_t; 139 | 140 | impl Iterator for WmIconIterator { 141 | type Item = WmIcon; 142 | 143 | fn next(&mut self) -> Option { 144 | unsafe { 145 | if self.rem == 0 { 146 | None 147 | } 148 | else { 149 | let width = self.width; 150 | let height = self.height; 151 | let id = *self.data; 152 | 153 | xcb_ewmh_get_wm_icon_next(self); 154 | 155 | Some(WmIcon { 156 | width: width, 157 | height: height, 158 | id: id 159 | }) 160 | } 161 | } 162 | } 163 | } 164 | 165 | pub type WmFullScreenMonitors = xcb_ewmh_get_wm_fullscreen_monitors_reply_t; 166 | 167 | impl WmFullScreenMonitors { 168 | pub fn top(&self) -> u32 { 169 | self.top 170 | } 171 | 172 | pub fn bottom(&self) -> u32 { 173 | self.bottom 174 | } 175 | 176 | pub fn left(&self) -> u32 { 177 | self.left 178 | } 179 | 180 | pub fn right(&self) -> u32 { 181 | self.right 182 | } 183 | } 184 | 185 | pub type ClientSourceType = xcb_ewmh_client_source_type_t; 186 | pub const CLIENT_SOURCE_TYPE_NONE: ClientSourceType = 0; 187 | pub const CLIENT_SOURCE_TYPE_NORMAL: ClientSourceType = 1; 188 | pub const CLIENT_SOURCE_TYPE_OTHER: ClientSourceType = 2; 189 | 190 | pub type DesktopLayoutOrientation = xcb_ewmh_desktop_layout_orientation_t; 191 | pub const ORIENTATION_HORZ: DesktopLayoutOrientation = 0; 192 | pub const ORIENTATION_VERT: DesktopLayoutOrientation = 1; 193 | 194 | pub type DesktopLayoutStartingCorner = xcb_ewmh_desktop_layout_starting_corner_t; 195 | pub const TOP_LEFT: DesktopLayoutStartingCorner = 0; 196 | pub const TOP_RIGHT: DesktopLayoutStartingCorner = 1; 197 | pub const BOTTOM_RIGHT: DesktopLayoutStartingCorner = 2; 198 | pub const BOTTOM_LEFT: DesktopLayoutStartingCorner = 3; 199 | 200 | pub type MoveResizeWindowFlags = xcb_ewmh_moveresize_window_opt_flags_t; 201 | pub const MOVE_RESIZE_WINDOW_X: MoveResizeWindowFlags = 1 << 8; 202 | pub const MOVE_RESIZE_WINDOW_Y: MoveResizeWindowFlags = 1 << 9; 203 | pub const MOVE_RESIZE_WINDOW_WIDTH: MoveResizeWindowFlags = 1 << 10; 204 | pub const MOVE_RESIZE_WINDOW_HEIGHT: MoveResizeWindowFlags = 1 << 11; 205 | 206 | pub type MoveResizeDirection = xcb_ewmh_moveresize_direction_t; 207 | pub const MOVE_RESIZE_SIZE_TOPLEFT: MoveResizeDirection = 0; 208 | pub const MOVE_RESIZE_SIZE_TOP: MoveResizeDirection = 1; 209 | pub const MOVE_RESIZE_SIZE_TOPRIGHT: MoveResizeDirection = 2; 210 | pub const MOVE_RESIZE_SIZE_RIGHT: MoveResizeDirection = 3; 211 | pub const MOVE_RESIZE_SIZE_BOTTOMRIGHT: MoveResizeDirection = 4; 212 | pub const MOVE_RESIZE_SIZE_BOTTOM: MoveResizeDirection = 5; 213 | pub const MOVE_RESIZE_SIZE_BOTTOMLEFT: MoveResizeDirection = 6; 214 | pub const MOVE_RESIZE_SIZE_LEFT: MoveResizeDirection = 7; 215 | pub const MOVE_RESIZE_MOVE: MoveResizeDirection = 8; 216 | pub const MOVE_RESIZE_SIZE_KEYBOARD: MoveResizeDirection = 9; 217 | pub const MOVE_RESIZE_MOVE_KEYBOARD: MoveResizeDirection = 10; 218 | pub const MOVE_RESIZE_CANCEL: MoveResizeDirection = 11; 219 | 220 | pub type StateAction = xcb_ewmh_wm_state_action_t; 221 | pub const STATE_REMOVE: StateAction = 0; 222 | pub const STATE_ADD: StateAction = 1; 223 | pub const STATE_TOGGLE: StateAction = 2; 224 | 225 | pub struct Connection { 226 | xcb: xcb::Connection, 227 | ewmh: xcb_ewmh_connection_t, 228 | } 229 | 230 | #[cfg(feature = "thread")] 231 | unsafe impl<'a> Send for Connection { } 232 | #[cfg(feature = "thread")] 233 | unsafe impl<'a> Sync for Connection { } 234 | 235 | impl Connection { 236 | pub fn connect(xcb: xcb::Connection) -> Result { 237 | unsafe { 238 | let mut ewmh = mem::zeroed(); 239 | let mut err: *mut xcb_generic_error_t = ptr::null_mut(); 240 | 241 | let cookie = xcb_ewmh_init_atoms(xcb.get_raw_conn(), &mut ewmh); 242 | xcb_ewmh_init_atoms_replies(&mut ewmh, cookie, &mut err); 243 | 244 | if err.is_null() { 245 | Ok(Connection { 246 | xcb: xcb, 247 | ewmh: ewmh, 248 | }) 249 | } 250 | else { 251 | Err((xcb::ReplyError::GenericError(xcb::GenericError { ptr: err }), xcb)) 252 | } 253 | } 254 | } 255 | 256 | #[inline(always)] 257 | pub fn get_raw_conn(&self) -> *mut xcb_ewmh_connection_t { 258 | &self.ewmh as *const _ as *mut _ 259 | } 260 | 261 | #[inline(always)] 262 | pub fn WM_CM(&self) -> &[xcb::Atom] { 263 | unsafe { 264 | slice::from_raw_parts(self.ewmh._NET_WM_CM_Sn, self.ewmh.nb_screens as usize) 265 | } 266 | } 267 | 268 | #[inline(always)] 269 | pub fn SUPPORTED(&self) -> xcb::Atom { 270 | self.ewmh._NET_SUPPORTED 271 | } 272 | 273 | #[inline(always)] 274 | pub fn CLIENT_LIST(&self) -> xcb::Atom { 275 | self.ewmh._NET_CLIENT_LIST 276 | } 277 | 278 | #[inline(always)] 279 | pub fn CLIENT_LIST_STACKING(&self) -> xcb::Atom { 280 | self.ewmh._NET_CLIENT_LIST_STACKING 281 | } 282 | 283 | #[inline(always)] 284 | pub fn NUMBER_OF_DESKTOPS(&self) -> xcb::Atom { 285 | self.ewmh._NET_NUMBER_OF_DESKTOPS 286 | } 287 | 288 | #[inline(always)] 289 | pub fn DESKTOP_GEOMETRY(&self) -> xcb::Atom { 290 | self.ewmh._NET_DESKTOP_GEOMETRY 291 | } 292 | 293 | #[inline(always)] 294 | pub fn DESKTOP_VIEWPORT(&self) -> xcb::Atom { 295 | self.ewmh._NET_DESKTOP_VIEWPORT 296 | } 297 | 298 | #[inline(always)] 299 | pub fn CURRENT_DESKTOP(&self) -> xcb::Atom { 300 | self.ewmh._NET_CURRENT_DESKTOP 301 | } 302 | 303 | #[inline(always)] 304 | pub fn DESKTOP_NAMES(&self) -> xcb::Atom { 305 | self.ewmh._NET_DESKTOP_NAMES 306 | } 307 | 308 | #[inline(always)] 309 | pub fn ACTIVE_WINDOW(&self) -> xcb::Atom { 310 | self.ewmh._NET_ACTIVE_WINDOW 311 | } 312 | 313 | #[inline(always)] 314 | pub fn WORKAREA(&self) -> xcb::Atom { 315 | self.ewmh._NET_WORKAREA 316 | } 317 | 318 | #[inline(always)] 319 | pub fn SUPPORTING_WM_CHECK(&self) -> xcb::Atom { 320 | self.ewmh._NET_SUPPORTING_WM_CHECK 321 | } 322 | 323 | #[inline(always)] 324 | pub fn VIRTUAL_ROOTS(&self) -> xcb::Atom { 325 | self.ewmh._NET_VIRTUAL_ROOTS 326 | } 327 | 328 | #[inline(always)] 329 | pub fn DESKTOP_LAYOUT(&self) -> xcb::Atom { 330 | self.ewmh._NET_DESKTOP_LAYOUT 331 | } 332 | 333 | #[inline(always)] 334 | pub fn SHOWING_DESKTOP(&self) -> xcb::Atom { 335 | self.ewmh._NET_SHOWING_DESKTOP 336 | } 337 | 338 | #[inline(always)] 339 | pub fn CLOSE_WINDOW(&self) -> xcb::Atom { 340 | self.ewmh._NET_CLOSE_WINDOW 341 | } 342 | 343 | #[inline(always)] 344 | pub fn MOVERESIZE_WINDOW(&self) -> xcb::Atom { 345 | self.ewmh._NET_MOVERESIZE_WINDOW 346 | } 347 | 348 | #[inline(always)] 349 | pub fn WM_MOVERESIZE(&self) -> xcb::Atom { 350 | self.ewmh._NET_WM_MOVERESIZE 351 | } 352 | 353 | #[inline(always)] 354 | pub fn RESTACK_WINDOW(&self) -> xcb::Atom { 355 | self.ewmh._NET_RESTACK_WINDOW 356 | } 357 | 358 | #[inline(always)] 359 | pub fn REQUEST_FRAME_EXTENTS(&self) -> xcb::Atom { 360 | self.ewmh._NET_REQUEST_FRAME_EXTENTS 361 | } 362 | 363 | #[inline(always)] 364 | pub fn WM_NAME(&self) -> xcb::Atom { 365 | self.ewmh._NET_WM_NAME 366 | } 367 | 368 | #[inline(always)] 369 | pub fn WM_VISIBLE_NAME(&self) -> xcb::Atom { 370 | self.ewmh._NET_WM_VISIBLE_NAME 371 | } 372 | 373 | #[inline(always)] 374 | pub fn WM_ICON_NAME(&self) -> xcb::Atom { 375 | self.ewmh._NET_WM_ICON_NAME 376 | } 377 | 378 | #[inline(always)] 379 | pub fn WM_VISIBLE_ICON_NAME(&self) -> xcb::Atom { 380 | self.ewmh._NET_WM_VISIBLE_ICON_NAME 381 | } 382 | 383 | #[inline(always)] 384 | pub fn WM_DESKTOP(&self) -> xcb::Atom { 385 | self.ewmh._NET_WM_DESKTOP 386 | } 387 | 388 | #[inline(always)] 389 | pub fn WM_WINDOW_TYPE(&self) -> xcb::Atom { 390 | self.ewmh._NET_WM_WINDOW_TYPE 391 | } 392 | 393 | #[inline(always)] 394 | pub fn WM_STATE(&self) -> xcb::Atom { 395 | self.ewmh._NET_WM_STATE 396 | } 397 | 398 | #[inline(always)] 399 | pub fn WM_ALLOWED_ACTIONS(&self) -> xcb::Atom { 400 | self.ewmh._NET_WM_ALLOWED_ACTIONS 401 | } 402 | 403 | #[inline(always)] 404 | pub fn WM_STRUT(&self) -> xcb::Atom { 405 | self.ewmh._NET_WM_STRUT 406 | } 407 | 408 | #[inline(always)] 409 | pub fn WM_STRUT_PARTIAL(&self) -> xcb::Atom { 410 | self.ewmh._NET_WM_STRUT_PARTIAL 411 | } 412 | 413 | #[inline(always)] 414 | pub fn WM_ICON_GEOMETRY(&self) -> xcb::Atom { 415 | self.ewmh._NET_WM_ICON_GEOMETRY 416 | } 417 | 418 | #[inline(always)] 419 | pub fn WM_ICON(&self) -> xcb::Atom { 420 | self.ewmh._NET_WM_ICON 421 | } 422 | 423 | #[inline(always)] 424 | pub fn WM_PID(&self) -> xcb::Atom { 425 | self.ewmh._NET_WM_PID 426 | } 427 | 428 | #[inline(always)] 429 | pub fn WM_HANDLED_ICONS(&self) -> xcb::Atom { 430 | self.ewmh._NET_WM_HANDLED_ICONS 431 | } 432 | 433 | #[inline(always)] 434 | pub fn WM_USER_TIME(&self) -> xcb::Atom { 435 | self.ewmh._NET_WM_USER_TIME 436 | } 437 | 438 | #[inline(always)] 439 | pub fn WM_USER_TIME_WINDOW(&self) -> xcb::Atom { 440 | self.ewmh._NET_WM_USER_TIME_WINDOW 441 | } 442 | 443 | #[inline(always)] 444 | pub fn FRAME_EXTENTS(&self) -> xcb::Atom { 445 | self.ewmh._NET_FRAME_EXTENTS 446 | } 447 | 448 | #[inline(always)] 449 | pub fn WM_PING(&self) -> xcb::Atom { 450 | self.ewmh._NET_WM_PING 451 | } 452 | 453 | #[inline(always)] 454 | pub fn WM_SYNC_REQUEST(&self) -> xcb::Atom { 455 | self.ewmh._NET_WM_SYNC_REQUEST 456 | } 457 | 458 | #[inline(always)] 459 | pub fn WM_SYNC_REQUEST_COUNTER(&self) -> xcb::Atom { 460 | self.ewmh._NET_WM_SYNC_REQUEST_COUNTER 461 | } 462 | 463 | #[inline(always)] 464 | pub fn WM_FULLSCREEN_MONITORS(&self) -> xcb::Atom { 465 | self.ewmh._NET_WM_FULLSCREEN_MONITORS 466 | } 467 | 468 | #[inline(always)] 469 | pub fn WM_FULL_PLACEMENT(&self) -> xcb::Atom { 470 | self.ewmh._NET_WM_FULL_PLACEMENT 471 | } 472 | 473 | #[inline(always)] 474 | pub fn WM_PROTOCOLS(&self) -> xcb::Atom { 475 | self.ewmh.WM_PROTOCOLS 476 | } 477 | 478 | #[inline(always)] 479 | pub fn MANAGER(&self) -> xcb::Atom { 480 | self.ewmh.MANAGER 481 | } 482 | 483 | #[inline(always)] 484 | pub fn WM_WINDOW_TYPE_DESKTOP(&self) -> xcb::Atom { 485 | self.ewmh._NET_WM_WINDOW_TYPE_DESKTOP 486 | } 487 | 488 | #[inline(always)] 489 | pub fn WM_WINDOW_TYPE_DOCK(&self) -> xcb::Atom { 490 | self.ewmh._NET_WM_WINDOW_TYPE_DOCK 491 | } 492 | 493 | #[inline(always)] 494 | pub fn WM_WINDOW_TYPE_TOOLBAR(&self) -> xcb::Atom { 495 | self.ewmh._NET_WM_WINDOW_TYPE_TOOLBAR 496 | } 497 | 498 | #[inline(always)] 499 | pub fn WM_WINDOW_TYPE_MENU(&self) -> xcb::Atom { 500 | self.ewmh._NET_WM_WINDOW_TYPE_MENU 501 | } 502 | 503 | #[inline(always)] 504 | pub fn WM_WINDOW_TYPE_UTILITY(&self) -> xcb::Atom { 505 | self.ewmh._NET_WM_WINDOW_TYPE_UTILITY 506 | } 507 | 508 | #[inline(always)] 509 | pub fn WM_WINDOW_TYPE_SPLASH(&self) -> xcb::Atom { 510 | self.ewmh._NET_WM_WINDOW_TYPE_SPLASH 511 | } 512 | 513 | #[inline(always)] 514 | pub fn WM_WINDOW_TYPE_DIALOG(&self) -> xcb::Atom { 515 | self.ewmh._NET_WM_WINDOW_TYPE_DIALOG 516 | } 517 | 518 | #[inline(always)] 519 | pub fn WM_WINDOW_TYPE_DROPDOWN_MENU(&self) -> xcb::Atom { 520 | self.ewmh._NET_WM_WINDOW_TYPE_DROPDOWN_MENU 521 | } 522 | 523 | #[inline(always)] 524 | pub fn WM_WINDOW_TYPE_POPUP_MENU(&self) -> xcb::Atom { 525 | self.ewmh._NET_WM_WINDOW_TYPE_POPUP_MENU 526 | } 527 | 528 | #[inline(always)] 529 | pub fn WM_WINDOW_TYPE_TOOLTIP(&self) -> xcb::Atom { 530 | self.ewmh._NET_WM_WINDOW_TYPE_TOOLTIP 531 | } 532 | 533 | #[inline(always)] 534 | pub fn WM_WINDOW_TYPE_NOTIFICATION(&self) -> xcb::Atom { 535 | self.ewmh._NET_WM_WINDOW_TYPE_NOTIFICATION 536 | } 537 | 538 | #[inline(always)] 539 | pub fn WM_WINDOW_TYPE_COMBO(&self) -> xcb::Atom { 540 | self.ewmh._NET_WM_WINDOW_TYPE_COMBO 541 | } 542 | 543 | #[inline(always)] 544 | pub fn WM_WINDOW_TYPE_DND(&self) -> xcb::Atom { 545 | self.ewmh._NET_WM_WINDOW_TYPE_DND 546 | } 547 | 548 | #[inline(always)] 549 | pub fn WM_WINDOW_TYPE_NORMAL(&self) -> xcb::Atom { 550 | self.ewmh._NET_WM_WINDOW_TYPE_NORMAL 551 | } 552 | 553 | #[inline(always)] 554 | pub fn WM_STATE_MODAL(&self) -> xcb::Atom { 555 | self.ewmh._NET_WM_STATE_MODAL 556 | } 557 | 558 | #[inline(always)] 559 | pub fn WM_STATE_STICKY(&self) -> xcb::Atom { 560 | self.ewmh._NET_WM_STATE_STICKY 561 | } 562 | 563 | #[inline(always)] 564 | pub fn WM_STATE_MAXIMIZED_VERT(&self) -> xcb::Atom { 565 | self.ewmh._NET_WM_STATE_MAXIMIZED_VERT 566 | } 567 | 568 | #[inline(always)] 569 | pub fn WM_STATE_MAXIMIZED_HORZ(&self) -> xcb::Atom { 570 | self.ewmh._NET_WM_STATE_MAXIMIZED_HORZ 571 | } 572 | 573 | #[inline(always)] 574 | pub fn WM_STATE_SHADED(&self) -> xcb::Atom { 575 | self.ewmh._NET_WM_STATE_SHADED 576 | } 577 | 578 | #[inline(always)] 579 | pub fn WM_STATE_SKIP_TASKBAR(&self) -> xcb::Atom { 580 | self.ewmh._NET_WM_STATE_SKIP_TASKBAR 581 | } 582 | 583 | #[inline(always)] 584 | pub fn WM_STATE_SKIP_PAGER(&self) -> xcb::Atom { 585 | self.ewmh._NET_WM_STATE_SKIP_PAGER 586 | } 587 | 588 | #[inline(always)] 589 | pub fn WM_STATE_HIDDEN(&self) -> xcb::Atom { 590 | self.ewmh._NET_WM_STATE_HIDDEN 591 | } 592 | 593 | #[inline(always)] 594 | pub fn WM_STATE_FULLSCREEN(&self) -> xcb::Atom { 595 | self.ewmh._NET_WM_STATE_FULLSCREEN 596 | } 597 | 598 | #[inline(always)] 599 | pub fn WM_STATE_ABOVE(&self) -> xcb::Atom { 600 | self.ewmh._NET_WM_STATE_ABOVE 601 | } 602 | 603 | #[inline(always)] 604 | pub fn WM_STATE_BELOW(&self) -> xcb::Atom { 605 | self.ewmh._NET_WM_STATE_BELOW 606 | } 607 | 608 | #[inline(always)] 609 | pub fn WM_STATE_DEMANDS_ATTENTION(&self) -> xcb::Atom { 610 | self.ewmh._NET_WM_STATE_DEMANDS_ATTENTION 611 | } 612 | 613 | #[inline(always)] 614 | pub fn WM_ACTION_MOVE(&self) -> xcb::Atom { 615 | self.ewmh._NET_WM_ACTION_MOVE 616 | } 617 | 618 | #[inline(always)] 619 | pub fn WM_ACTION_RESIZE(&self) -> xcb::Atom { 620 | self.ewmh._NET_WM_ACTION_RESIZE 621 | } 622 | 623 | #[inline(always)] 624 | pub fn WM_ACTION_MINIMIZE(&self) -> xcb::Atom { 625 | self.ewmh._NET_WM_ACTION_MINIMIZE 626 | } 627 | 628 | #[inline(always)] 629 | pub fn WM_ACTION_SHADE(&self) -> xcb::Atom { 630 | self.ewmh._NET_WM_ACTION_SHADE 631 | } 632 | 633 | #[inline(always)] 634 | pub fn WM_ACTION_STICK(&self) -> xcb::Atom { 635 | self.ewmh._NET_WM_ACTION_STICK 636 | } 637 | 638 | #[inline(always)] 639 | pub fn WM_ACTION_MAXIMIZE_HORZ(&self) -> xcb::Atom { 640 | self.ewmh._NET_WM_ACTION_MAXIMIZE_HORZ 641 | } 642 | 643 | #[inline(always)] 644 | pub fn WM_ACTION_MAXIMIZE_VERT(&self) -> xcb::Atom { 645 | self.ewmh._NET_WM_ACTION_MAXIMIZE_VERT 646 | } 647 | 648 | #[inline(always)] 649 | pub fn WM_ACTION_FULLSCREEN(&self) -> xcb::Atom { 650 | self.ewmh._NET_WM_ACTION_FULLSCREEN 651 | } 652 | 653 | #[inline(always)] 654 | pub fn WM_ACTION_CHANGE_DESKTOP(&self) -> xcb::Atom { 655 | self.ewmh._NET_WM_ACTION_CHANGE_DESKTOP 656 | } 657 | 658 | #[inline(always)] 659 | pub fn WM_ACTION_CLOSE(&self) -> xcb::Atom { 660 | self.ewmh._NET_WM_ACTION_CLOSE 661 | } 662 | 663 | #[inline(always)] 664 | pub fn WM_ACTION_ABOVE(&self) -> xcb::Atom { 665 | self.ewmh._NET_WM_ACTION_ABOVE 666 | } 667 | 668 | #[inline(always)] 669 | pub fn WM_ACTION_BELOW(&self) -> xcb::Atom { 670 | self.ewmh._NET_WM_ACTION_BELOW 671 | } 672 | } 673 | 674 | impl Deref for Connection { 675 | type Target = xcb::Connection; 676 | 677 | fn deref(&self) -> &Self::Target { 678 | &self.xcb 679 | } 680 | } 681 | 682 | impl DerefMut for Connection { 683 | fn deref_mut(&mut self) -> &mut Self::Target { 684 | &mut self.xcb 685 | } 686 | } 687 | 688 | impl Drop for Connection { 689 | fn drop(&mut self) { 690 | unsafe { 691 | xcb_ewmh_connection_wipe(&mut self.ewmh) 692 | } 693 | } 694 | } 695 | 696 | pub fn send_client_message<'a>(c: &'a xcb::Connection, window: xcb::Window, dest: xcb::Window, atom: xcb::Atom, data: &[u32]) -> xcb::VoidCookie<'a> { 697 | void!(unchecked -> c, 698 | xcb_ewmh_send_client_message(c.get_raw_conn(), window, dest, atom, 699 | data.len() as u32, data.as_ptr())) 700 | } 701 | 702 | pub fn request_close_window(c: &Connection, screen: i32, window: xcb::Window, timestamp: xcb::Timestamp, source_indication: ClientSourceType) -> xcb::VoidCookie { 703 | void!(unchecked -> c, 704 | xcb_ewmh_request_close_window(c.get_raw_conn(), screen as c_int, window, timestamp, source_indication)) 705 | } 706 | 707 | pub fn request_move_resize_window(c: &Connection, screen: i32, window: xcb::Window, gravity: xcb::Gravity, source_indication: ClientSourceType, flags: MoveResizeWindowFlags, x: u32, y: u32, width: u32, height: u32) -> xcb::VoidCookie { 708 | void!(unchecked -> c, 709 | xcb_ewmh_request_moveresize_window(c.get_raw_conn(), screen as c_int, window, 710 | gravity, source_indication, flags, x, y, width, height)) 711 | } 712 | 713 | pub fn send_wm_ping(c: &Connection, window: xcb::Window, timestamp: xcb::Timestamp) -> xcb::VoidCookie { 714 | void!(unchecked -> c, 715 | xcb_ewmh_send_wm_ping(c.get_raw_conn(), window, timestamp)) 716 | } 717 | 718 | define!(cookie GetSupportedCookie through Connection with xcb_ewmh_get_supported_reply => GetSupportedReply); 719 | define!(reply GetSupportedReply for xcb_ewmh_get_atoms_reply_t with xcb_ewmh_get_atoms_reply_wipe); 720 | 721 | impl GetSupportedReply { 722 | pub fn atoms(&self) -> &[xcb::Atom] { 723 | unsafe { 724 | slice::from_raw_parts(self.0.atoms as *mut _, self.0.atoms_len as usize) 725 | } 726 | } 727 | } 728 | 729 | pub fn set_supported<'a>(c: &'a Connection, screen: i32, list: &[xcb::Atom]) -> xcb::VoidCookie<'a> { 730 | void!(unchecked -> c, 731 | xcb_ewmh_set_supported(c.get_raw_conn(), screen as c_int, 732 | list.len() as u32, list.as_ptr())) 733 | } 734 | 735 | pub fn set_supported_checked<'a>(c: &'a Connection, screen: i32, list: &[xcb::Atom]) -> xcb::VoidCookie<'a> { 736 | void!(checked -> c, 737 | xcb_ewmh_set_supported_checked(c.get_raw_conn(), screen as c_int, 738 | list.len() as u32, list.as_ptr())) 739 | } 740 | 741 | pub fn get_supported(c: &Connection, screen: i32) -> GetSupportedCookie { 742 | property!(checked GetSupportedCookie -> c, 743 | xcb_ewmh_get_supported(c.get_raw_conn(), screen as c_int)) 744 | } 745 | 746 | pub fn get_supported_unchecked(c: &Connection, screen: i32) -> GetSupportedCookie { 747 | property!(unchecked GetSupportedCookie -> c, 748 | xcb_ewmh_get_supported_unchecked(c.get_raw_conn(), screen as c_int)) 749 | } 750 | 751 | define!(cookie GetClientListCookie through Connection with xcb_ewmh_get_client_list_reply => GetClientListReply); 752 | define!(reply GetClientListReply for xcb_ewmh_get_windows_reply_t with xcb_ewmh_get_windows_reply_wipe); 753 | 754 | impl GetClientListReply { 755 | pub fn windows(&self) -> &[xcb::Window] { 756 | unsafe { 757 | slice::from_raw_parts(self.0.windows as *mut _, self.0.windows_len as usize) 758 | } 759 | } 760 | } 761 | 762 | pub fn set_client_list<'a>(c: &'a Connection, screen: i32, list: &[xcb::Window]) -> xcb::VoidCookie<'a> { 763 | void!(unchecked -> c, 764 | xcb_ewmh_set_client_list(c.get_raw_conn(), screen as c_int, 765 | list.len() as u32, list.as_ptr() as *const _)) 766 | } 767 | 768 | pub fn set_client_list_checked<'a>(c: &'a Connection, screen: i32, list: &[xcb::Window]) -> xcb::VoidCookie<'a> { 769 | void!(checked -> c, 770 | xcb_ewmh_set_client_list_checked(c.get_raw_conn(), screen as c_int, 771 | list.len() as u32, list.as_ptr() as *const _)) 772 | } 773 | 774 | pub fn get_client_list(c: &Connection, screen: i32) -> GetClientListCookie { 775 | property!(checked GetClientListCookie -> c, 776 | xcb_ewmh_get_client_list(c.get_raw_conn(), screen as c_int)) 777 | } 778 | 779 | pub fn get_client_list_unchecked(c: &Connection, screen: i32) -> GetClientListCookie { 780 | property!(unchecked GetClientListCookie -> c, 781 | xcb_ewmh_get_client_list(c.get_raw_conn(), screen as c_int)) 782 | } 783 | 784 | define!(cookie GetClientListStackingCookie through Connection with xcb_ewmh_get_client_list_stacking_reply => GetClientListStackingReply); 785 | define!(reply GetClientListStackingReply for xcb_ewmh_get_windows_reply_t with xcb_ewmh_get_windows_reply_wipe); 786 | 787 | impl GetClientListStackingReply { 788 | pub fn windows(&self) -> &[xcb::Window] { 789 | unsafe { 790 | slice::from_raw_parts(self.0.windows as *mut _, self.0.windows_len as usize) 791 | } 792 | } 793 | } 794 | 795 | pub fn set_client_list_stacking<'a>(c: &'a Connection, screen: i32, list: &[xcb::Window]) -> xcb::VoidCookie<'a> { 796 | void!(unchecked -> c, 797 | xcb_ewmh_set_client_list_stacking(c.get_raw_conn(), screen as c_int, 798 | list.len() as u32, list.as_ptr() as *const _)) 799 | } 800 | 801 | pub fn set_client_list_stacking_checked<'a>(c: &'a Connection, screen: i32, list: &[xcb::Window]) -> xcb::VoidCookie<'a> { 802 | void!(checked -> c, 803 | xcb_ewmh_set_client_list_stacking_checked(c.get_raw_conn(), screen as c_int, 804 | list.len() as u32, list.as_ptr() as *const _)) 805 | } 806 | 807 | pub fn get_client_list_stacking(c: &Connection, screen: i32) -> GetClientListStackingCookie { 808 | property!(checked GetClientListStackingCookie -> c, 809 | xcb_ewmh_get_client_list_stacking(c.get_raw_conn(), screen as c_int)) 810 | } 811 | 812 | pub fn get_client_list_stacking_unchecked(c: &Connection, screen: i32) -> GetClientListStackingCookie { 813 | property!(unchecked GetClientListStackingCookie -> c, 814 | xcb_ewmh_get_client_list_stacking(c.get_raw_conn(), screen as c_int)) 815 | } 816 | 817 | define!(cookie GetNumberOfDesktopsCookie through Connection with xcb_ewmh_get_number_of_desktops_reply as u32); 818 | 819 | pub fn set_number_of_desktops(c: &Connection, screen: i32, number: u32) -> xcb::VoidCookie { 820 | void!(unchecked -> c, 821 | xcb_ewmh_set_number_of_desktops(c.get_raw_conn(), screen as c_int, number)) 822 | } 823 | 824 | pub fn set_number_of_desktops_checked(c: &Connection, screen: i32, number: u32) -> xcb::VoidCookie { 825 | void!(checked -> c, 826 | xcb_ewmh_set_number_of_desktops_checked(c.get_raw_conn(), screen as c_int, number)) 827 | } 828 | 829 | pub fn get_number_of_desktops(c: &Connection, screen: i32) -> GetNumberOfDesktopsCookie { 830 | property!(checked GetNumberOfDesktopsCookie -> c, 831 | xcb_ewmh_get_number_of_desktops(c.get_raw_conn(), screen as c_int)) 832 | } 833 | 834 | pub fn get_number_of_desktops_unchecked(c: &Connection, screen: i32) -> GetNumberOfDesktopsCookie { 835 | property!(unchecked GetNumberOfDesktopsCookie -> c, 836 | xcb_ewmh_get_number_of_desktops_unchecked(c.get_raw_conn(), screen as c_int)) 837 | } 838 | 839 | define!(cookie GetDesktopGeometryCookie through Connection with xcb_ewmh_get_desktop_geometry_reply as (u32, u32)); 840 | 841 | pub fn set_desktop_geometry(c: &Connection, screen: i32, width: u32, height: u32) -> xcb::VoidCookie { 842 | void!(unchecked -> c, 843 | xcb_ewmh_set_desktop_geometry(c.get_raw_conn(), screen as c_int, width, height)) 844 | } 845 | 846 | pub fn set_desktop_geometry_checked(c: &Connection, screen: i32, width: u32, height: u32) -> xcb::VoidCookie { 847 | void!(checked -> c, 848 | xcb_ewmh_set_desktop_geometry_checked(c.get_raw_conn(), screen as c_int, width, height)) 849 | } 850 | 851 | pub fn request_change_desktop_geometry(c: &Connection, screen: i32, width: u32, height: u32) -> xcb::VoidCookie { 852 | void!(unchecked -> c, 853 | xcb_ewmh_request_change_desktop_geometry(c.get_raw_conn(), screen as c_int, width, height)) 854 | } 855 | 856 | pub fn get_desktop_geometry(c: &Connection, screen: i32) -> GetDesktopGeometryCookie { 857 | property!(checked GetDesktopGeometryCookie -> c, 858 | xcb_ewmh_get_desktop_geometry(c.get_raw_conn(), screen as c_int)) 859 | } 860 | 861 | pub fn get_desktop_geometry_unchecked(c: &Connection, screen: i32) -> GetDesktopGeometryCookie { 862 | property!(unchecked GetDesktopGeometryCookie -> c, 863 | xcb_ewmh_get_desktop_geometry_unchecked(c.get_raw_conn(), screen as c_int)) 864 | } 865 | 866 | define!(cookie GetDesktopViewportCookie through Connection with xcb_ewmh_get_desktop_viewport_reply => GetDesktopViewportReply); 867 | define!(reply GetDesktopViewportReply for xcb_ewmh_get_desktop_viewport_reply_t with xcb_ewmh_get_desktop_viewport_reply_wipe); 868 | 869 | impl GetDesktopViewportReply { 870 | pub fn desktop_viewports(&self) -> &[Coordinates] { 871 | unsafe { 872 | slice::from_raw_parts(self.0.desktop_viewport as *mut _, self.0.desktop_viewport_len as usize) 873 | } 874 | } 875 | } 876 | 877 | pub fn set_desktop_viewport<'a>(c: &'a Connection, screen: i32, list: &[Coordinates]) -> xcb::VoidCookie<'a> { 878 | void!(unchecked -> c, 879 | xcb_ewmh_set_desktop_viewport(c.get_raw_conn(), screen as c_int, 880 | list.len() as u32, list.as_ptr())) 881 | } 882 | 883 | pub fn set_desktop_viewport_checked<'a>(c: &'a Connection, screen: i32, list: &[Coordinates]) -> xcb::VoidCookie<'a> { 884 | void!(checked -> c, 885 | xcb_ewmh_set_desktop_viewport_checked(c.get_raw_conn(), screen as c_int, 886 | list.len() as u32, list.as_ptr())) 887 | } 888 | 889 | pub fn get_desktop_viewport(c: &Connection, screen: i32) -> GetDesktopViewportCookie { 890 | property!(checked GetDesktopViewportCookie -> c, 891 | xcb_ewmh_get_desktop_viewport(c.get_raw_conn(), screen as c_int)) 892 | } 893 | 894 | pub fn get_desktop_viewport_unchecked(c: &Connection, screen: i32) -> GetDesktopViewportCookie { 895 | property!(unchecked GetDesktopViewportCookie -> c, 896 | xcb_ewmh_get_desktop_viewport_unchecked(c.get_raw_conn(), screen as c_int)) 897 | } 898 | 899 | define!(cookie GetCurrentDesktopCookie through Connection with xcb_ewmh_get_current_desktop_reply as u32); 900 | 901 | pub fn set_current_desktop(c: &Connection, screen: i32, current_desktop: u32) -> xcb::VoidCookie { 902 | void!(unchecked -> c, 903 | xcb_ewmh_set_current_desktop(c.get_raw_conn(), screen as c_int, current_desktop)) 904 | } 905 | 906 | pub fn set_current_desktop_checked(c: &Connection, screen: i32, current_desktop: u32) -> xcb::VoidCookie { 907 | void!(checked -> c, 908 | xcb_ewmh_set_current_desktop_checked(c.get_raw_conn(), screen as c_int, current_desktop)) 909 | } 910 | 911 | pub fn request_change_current_desktop(c: &Connection, screen: i32, current_desktop: u32, timestamp: xcb::Timestamp) -> xcb::VoidCookie { 912 | void!(unchecked -> c, 913 | xcb_ewmh_request_change_current_desktop(c.get_raw_conn(), screen as c_int, current_desktop, timestamp)) 914 | } 915 | 916 | pub fn get_current_desktop(c: &Connection, screen: i32) -> GetCurrentDesktopCookie { 917 | property!(checked GetCurrentDesktopCookie -> c, 918 | xcb_ewmh_get_current_desktop(c.get_raw_conn(), screen as c_int)) 919 | } 920 | 921 | pub fn get_current_desktop_unchecked(c: &Connection, screen: i32) -> GetCurrentDesktopCookie { 922 | property!(unchecked GetCurrentDesktopCookie -> c, 923 | xcb_ewmh_get_current_desktop_unchecked(c.get_raw_conn(), screen as c_int)) 924 | } 925 | 926 | define!(cookie GetDesktopNamesCookie through Connection with xcb_ewmh_get_desktop_names_reply => GetDesktopNamesReply); 927 | define!(reply GetDesktopNamesReply for xcb_ewmh_get_utf8_strings_reply_t with xcb_ewmh_get_utf8_strings_reply_wipe); 928 | 929 | impl GetDesktopNamesReply { 930 | pub fn strings(&self) -> Vec<&str> { 931 | utf8::into(self.0.strings, self.0.strings_len) 932 | } 933 | } 934 | 935 | pub fn set_desktop_names<'a, T: IntoIterator>(c: &Connection, screen: i32, list: T) -> xcb::VoidCookie { 936 | let value = utf8::from(list); 937 | 938 | void!(unchecked -> c, 939 | xcb_ewmh_set_desktop_names(c.get_raw_conn(), screen, value.len() as u32, value.as_ptr() as *mut _)) 940 | } 941 | 942 | pub fn set_desktop_names_checked<'a, T: IntoIterator>(c: &Connection, screen: i32, list: T) -> xcb::VoidCookie { 943 | let value = utf8::from(list); 944 | 945 | void!(checked -> c, 946 | xcb_ewmh_set_desktop_names_checked(c.get_raw_conn(), screen, value.len() as u32, value.as_ptr() as *mut _)) 947 | } 948 | 949 | pub fn get_desktop_names(c: &Connection, screen: i32) -> GetDesktopNamesCookie { 950 | property!(checked GetDesktopNamesCookie -> c, 951 | xcb_ewmh_get_desktop_names(c.get_raw_conn(), screen as c_int)) 952 | } 953 | 954 | pub fn get_desktop_names_unchecked(c: &Connection, screen: i32) -> GetDesktopNamesCookie { 955 | property!(unchecked GetDesktopNamesCookie -> c, 956 | xcb_ewmh_get_desktop_names_unchecked(c.get_raw_conn(), screen as c_int)) 957 | } 958 | 959 | define!(cookie GetActiveWindowCookie through Connection with xcb_ewmh_get_active_window_reply as xcb::Window); 960 | 961 | pub fn set_active_window(c: &Connection, screen: i32, window: xcb::Window) -> xcb::VoidCookie { 962 | void!(unchecked -> c, 963 | xcb_ewmh_set_active_window(c.get_raw_conn(), screen as c_int, window)) 964 | } 965 | 966 | pub fn set_active_window_checked(c: &Connection, screen: i32, window: xcb::Window) -> xcb::VoidCookie { 967 | void!(checked -> c, 968 | xcb_ewmh_set_active_window_checked(c.get_raw_conn(), screen as c_int, window)) 969 | } 970 | 971 | pub fn request_change_active_window(c: &Connection, screen: i32, window: xcb::Window, source_indication: ClientSourceType, timestamp: xcb::Timestamp, current: xcb::Window) -> xcb::VoidCookie { 972 | void!(unchecked -> c, 973 | xcb_ewmh_request_change_active_window(c.get_raw_conn(), screen as c_int, window, 974 | source_indication, timestamp, current)) 975 | } 976 | 977 | pub fn get_active_window(c: &Connection, screen: i32) -> GetActiveWindowCookie { 978 | property!(checked GetActiveWindowCookie -> c, 979 | xcb_ewmh_get_active_window(c.get_raw_conn(), screen as c_int)) 980 | } 981 | 982 | pub fn get_active_window_unchecked(c: &Connection, screen: i32) -> GetActiveWindowCookie { 983 | property!(unchecked GetActiveWindowCookie -> c, 984 | xcb_ewmh_get_active_window_unchecked(c.get_raw_conn(), screen as c_int)) 985 | } 986 | 987 | define!(cookie GetWorkAreaCookie through Connection with xcb_ewmh_get_workarea_reply => GetWorkAreaReply); 988 | define!(reply GetWorkAreaReply for xcb_ewmh_get_workarea_reply_t with xcb_ewmh_get_workarea_reply_wipe); 989 | 990 | impl GetWorkAreaReply { 991 | pub fn work_area(&self) -> &[Geometry] { 992 | unsafe { 993 | slice::from_raw_parts(self.0.workarea, self.0.workarea_len as usize) 994 | } 995 | } 996 | } 997 | 998 | pub fn set_work_area<'a>(c: &'a Connection, screen: i32, list: &[Geometry]) -> xcb::VoidCookie<'a> { 999 | void!(unchecked -> c, 1000 | xcb_ewmh_set_workarea(c.get_raw_conn(), screen as c_int, list.len() as u32, list.as_ptr())) 1001 | } 1002 | 1003 | pub fn set_work_area_checked<'a>(c: &'a Connection, screen: i32, list: &[Geometry]) -> xcb::VoidCookie<'a> { 1004 | void!(checked -> c, 1005 | xcb_ewmh_set_workarea_checked(c.get_raw_conn(), screen as c_int, list.len() as u32, list.as_ptr())) 1006 | } 1007 | 1008 | pub fn get_work_area(c: &Connection, screen: i32) -> GetWorkAreaCookie { 1009 | property!(checked GetWorkAreaCookie -> c, 1010 | xcb_ewmh_get_workarea(c.get_raw_conn(), screen as c_int)) 1011 | } 1012 | 1013 | pub fn get_work_area_unchecked(c: &Connection, screen: i32) -> GetWorkAreaCookie { 1014 | property!(unchecked GetWorkAreaCookie -> c, 1015 | xcb_ewmh_get_workarea_unchecked(c.get_raw_conn(), screen as c_int)) 1016 | } 1017 | 1018 | define!(cookie GetSupportingWmCheckCookie through Connection with xcb_ewmh_get_supporting_wm_check_reply as xcb::Window); 1019 | 1020 | pub fn set_supporting_wm_check(c: &Connection, parent: xcb::Window, child: xcb::Window) -> xcb::VoidCookie { 1021 | void!(unchecked -> c, 1022 | xcb_ewmh_set_supporting_wm_check(c.get_raw_conn(), parent, child)) 1023 | } 1024 | 1025 | pub fn set_supporting_wm_check_checked(c: &Connection, parent: xcb::Window, child: xcb::Window) -> xcb::VoidCookie { 1026 | void!(checked -> c, 1027 | xcb_ewmh_set_supporting_wm_check_checked(c.get_raw_conn(), parent, child)) 1028 | } 1029 | 1030 | pub fn get_supporting_wm_check(c: &Connection, window: xcb::Window) -> GetSupportingWmCheckCookie { 1031 | property!(checked GetSupportingWmCheckCookie -> c, 1032 | xcb_ewmh_get_supporting_wm_check(c.get_raw_conn(), window)) 1033 | } 1034 | 1035 | pub fn get_supporting_wm_check_unchecked(c: &Connection, window: xcb::Window) -> GetSupportingWmCheckCookie { 1036 | property!(unchecked GetSupportingWmCheckCookie -> c, 1037 | xcb_ewmh_get_supporting_wm_check_unchecked(c.get_raw_conn(), window)) 1038 | } 1039 | 1040 | define!(cookie GetVirtualRootsCookie through Connection with xcb_ewmh_get_virtual_roots_reply => GetVirtualRootsReply); 1041 | define!(reply GetVirtualRootsReply for xcb_ewmh_get_windows_reply_t with xcb_ewmh_get_windows_reply_wipe); 1042 | 1043 | pub fn set_virtual_roots<'a>(c: &'a Connection, screen: i32, list: &[xcb::Window]) -> xcb::VoidCookie<'a> { 1044 | void!(unchecked -> c, 1045 | xcb_ewmh_set_virtual_roots(c.get_raw_conn(), screen as c_int, list.len() as u32, list.as_ptr())) 1046 | } 1047 | 1048 | pub fn set_virtual_roots_checked<'a>(c: &'a Connection, screen: i32, list: &[xcb::Window]) -> xcb::VoidCookie<'a> { 1049 | void!(checked -> c, 1050 | xcb_ewmh_set_virtual_roots_checked(c.get_raw_conn(), screen as c_int, list.len() as u32, list.as_ptr())) 1051 | } 1052 | 1053 | pub fn get_virtual_roots(c: &Connection, screen: i32) -> GetVirtualRootsCookie { 1054 | property!(checked GetVirtualRootsCookie -> c, 1055 | xcb_ewmh_get_virtual_roots(c.get_raw_conn(), screen as c_int)) 1056 | } 1057 | 1058 | pub fn get_virtual_roots_unchecked(c: &Connection, screen: i32) -> GetVirtualRootsCookie { 1059 | property!(unchecked GetVirtualRootsCookie -> c, 1060 | xcb_ewmh_get_virtual_roots_unchecked(c.get_raw_conn(), screen as c_int)) 1061 | } 1062 | 1063 | define!(cookie GetDesktopLayoutCookie through Connection with xcb_ewmh_get_desktop_layout_reply => GetDesktopLayoutReply); 1064 | define!(reply GetDesktopLayoutReply for xcb_ewmh_get_desktop_layout_reply_t); 1065 | 1066 | impl GetDesktopLayoutReply { 1067 | pub fn orientation(&self) -> DesktopLayoutOrientation { 1068 | self.0.orientation 1069 | } 1070 | 1071 | pub fn columns(&self) -> u32 { 1072 | self.0.columns 1073 | } 1074 | 1075 | pub fn rows(&self) -> u32 { 1076 | self.0.rows 1077 | } 1078 | 1079 | pub fn starting_corner(&self) -> DesktopLayoutStartingCorner { 1080 | self.0.starting_corner 1081 | } 1082 | } 1083 | 1084 | pub fn set_desktop_layout(c: &Connection, screen: i32, orientation: DesktopLayoutOrientation, columns: u32, rows: u32, starting_corner: DesktopLayoutStartingCorner) -> xcb::VoidCookie { 1085 | void!(unchecked -> c, 1086 | xcb_ewmh_set_desktop_layout(c.get_raw_conn(), screen as c_int, orientation, columns, rows, starting_corner)) 1087 | } 1088 | 1089 | pub fn set_desktop_layout_checked(c: &Connection, screen: i32, orientation: DesktopLayoutOrientation, columns: u32, rows: u32, starting_corner: DesktopLayoutStartingCorner) -> xcb::VoidCookie { 1090 | void!(checked -> c, 1091 | xcb_ewmh_set_desktop_layout_checked(c.get_raw_conn(), screen as c_int, orientation, columns, rows, starting_corner)) 1092 | } 1093 | 1094 | pub fn get_desktop_layout(c: &Connection, screen: i32) -> GetDesktopLayoutCookie { 1095 | property!(checked GetDesktopLayoutCookie -> c, 1096 | xcb_ewmh_get_desktop_layout(c.get_raw_conn(), screen as c_int)) 1097 | } 1098 | 1099 | pub fn get_desktop_layout_unchecked(c: &Connection, screen: i32) -> GetDesktopLayoutCookie { 1100 | property!(unchecked GetDesktopLayoutCookie -> c, 1101 | xcb_ewmh_get_desktop_layout_unchecked(c.get_raw_conn(), screen as c_int)) 1102 | } 1103 | 1104 | define!(cookie GetShowingDesktopCookie through Connection with xcb_ewmh_get_showing_desktop_reply as u32); 1105 | 1106 | pub fn set_showing_desktop(c: &Connection, screen: i32, desktop: u32) -> xcb::VoidCookie { 1107 | void!(unchecked -> c, 1108 | xcb_ewmh_set_showing_desktop(c.get_raw_conn(), screen as c_int, desktop)) 1109 | } 1110 | 1111 | pub fn set_showing_desktop_checked(c: &Connection, screen: i32, desktop: u32) -> xcb::VoidCookie { 1112 | void!(checked -> c, 1113 | xcb_ewmh_set_showing_desktop_checked(c.get_raw_conn(), screen as c_int, desktop)) 1114 | } 1115 | 1116 | pub fn get_showing_desktop(c: &Connection, screen: i32) -> GetShowingDesktopCookie { 1117 | property!(checked GetShowingDesktopCookie -> c, 1118 | xcb_ewmh_get_showing_desktop(c.get_raw_conn(), screen as c_int)) 1119 | } 1120 | 1121 | pub fn get_showing_desktop_unchecked(c: &Connection, screen: i32) -> GetShowingDesktopCookie { 1122 | property!(unchecked GetShowingDesktopCookie -> c, 1123 | xcb_ewmh_get_showing_desktop_unchecked(c.get_raw_conn(), screen as c_int)) 1124 | } 1125 | 1126 | define!(cookie GetWmNameCookie through Connection with xcb_ewmh_get_wm_name_reply => GetWmNameReply); 1127 | define!(reply GetWmNameReply for xcb_ewmh_get_utf8_strings_reply_t with xcb_ewmh_get_utf8_strings_reply_wipe); 1128 | 1129 | impl GetWmNameReply { 1130 | pub fn string(&self) -> &str { 1131 | utf8::into(self.0.strings, self.0.strings_len).get(0).unwrap_or(&"") 1132 | } 1133 | } 1134 | 1135 | pub fn set_wm_name>(c: &Connection, window: xcb::Window, name: T) -> xcb::VoidCookie { 1136 | let value = name.as_ref(); 1137 | 1138 | void!(unchecked -> c, 1139 | xcb_ewmh_set_wm_name(c.get_raw_conn(), window, value.len() as u32, value.as_ptr() as *mut _)) 1140 | } 1141 | 1142 | pub fn set_wm_name_checked>(c: &Connection, window: xcb::Window, name: T) -> xcb::VoidCookie { 1143 | let value = name.as_ref(); 1144 | 1145 | void!(checked -> c, 1146 | xcb_ewmh_set_wm_name_checked(c.get_raw_conn(), window, value.len() as u32, value.as_ptr() as *mut _)) 1147 | } 1148 | 1149 | pub fn get_wm_name(c: &Connection, window: xcb::Window) -> GetWmNameCookie { 1150 | property!(checked GetWmNameCookie -> c, 1151 | xcb_ewmh_get_wm_name(c.get_raw_conn(), window)) 1152 | } 1153 | 1154 | pub fn get_wm_name_unchecked(c: &Connection, window: xcb::Window) -> GetWmNameCookie { 1155 | property!(unchecked GetWmNameCookie -> c, 1156 | xcb_ewmh_get_wm_name_unchecked(c.get_raw_conn(), window)) 1157 | } 1158 | 1159 | define!(cookie GetWmVisibleNameCookie through Connection with xcb_ewmh_get_wm_visible_name_reply => GetWmVisibleNameReply); 1160 | define!(reply GetWmVisibleNameReply for xcb_ewmh_get_utf8_strings_reply_t with xcb_ewmh_get_utf8_strings_reply_wipe); 1161 | 1162 | pub fn set_wm_visible_name>(c: &Connection, window: xcb::Window, name: T) -> xcb::VoidCookie { 1163 | let value = utf8::from(vec![name.as_ref()]); 1164 | 1165 | void!(unchecked -> c, 1166 | xcb_ewmh_set_wm_visible_name(c.get_raw_conn(), window, value.len() as u32, value.as_ptr() as *mut _)) 1167 | } 1168 | 1169 | pub fn set_wm_visible_name_checked>(c: &Connection, window: xcb::Window, name: T) -> xcb::VoidCookie { 1170 | let value = utf8::from(vec![name.as_ref()]); 1171 | 1172 | void!(checked -> c, 1173 | xcb_ewmh_set_wm_visible_name_checked(c.get_raw_conn(), window, value.len() as u32, value.as_ptr() as *mut _)) 1174 | } 1175 | 1176 | pub fn get_wm_visible_name(c: &Connection, window: xcb::Window) -> GetWmVisibleNameCookie { 1177 | property!(checked GetWmVisibleNameCookie -> c, 1178 | xcb_ewmh_get_wm_visible_name(c.get_raw_conn(), window)) 1179 | } 1180 | 1181 | pub fn get_wm_visible_name_unchecked(c: &Connection, window: xcb::Window) -> GetWmVisibleNameCookie { 1182 | property!(unchecked GetWmVisibleNameCookie -> c, 1183 | xcb_ewmh_get_wm_visible_name_unchecked(c.get_raw_conn(), window)) 1184 | } 1185 | 1186 | define!(cookie GetWmIconNameCookie through Connection with xcb_ewmh_get_wm_icon_name_reply => GetWmIconNameReply); 1187 | define!(reply GetWmIconNameReply for xcb_ewmh_get_utf8_strings_reply_t with xcb_ewmh_get_utf8_strings_reply_wipe); 1188 | 1189 | pub fn set_wm_icon_name>(c: &Connection, window: xcb::Window, name: T) -> xcb::VoidCookie { 1190 | let value = utf8::from(vec![name.as_ref()]); 1191 | 1192 | void!(unchecked -> c, 1193 | xcb_ewmh_set_wm_icon_name(c.get_raw_conn(), window, value.len() as u32, value.as_ptr() as *mut _)) 1194 | } 1195 | 1196 | pub fn set_wm_icon_name_checked>(c: &Connection, window: xcb::Window, name: T) -> xcb::VoidCookie { 1197 | let value = utf8::from(vec![name.as_ref()]); 1198 | 1199 | void!(checked -> c, 1200 | xcb_ewmh_set_wm_icon_name_checked(c.get_raw_conn(), window, value.len() as u32, value.as_ptr() as *mut _)) 1201 | } 1202 | 1203 | pub fn get_wm_icon_name(c: &Connection, window: xcb::Window) -> GetWmIconNameCookie { 1204 | property!(checked GetWmIconNameCookie -> c, 1205 | xcb_ewmh_get_wm_icon_name(c.get_raw_conn(), window)) 1206 | } 1207 | 1208 | pub fn get_wm_icon_name_unchecked(c: &Connection, window: xcb::Window) -> GetWmIconNameCookie { 1209 | property!(unchecked GetWmIconNameCookie -> c, 1210 | xcb_ewmh_get_wm_icon_name_unchecked(c.get_raw_conn(), window)) 1211 | } 1212 | 1213 | define!(cookie GetWmVisibleIconNameCookie through Connection with xcb_ewmh_get_wm_visible_icon_name_reply => GetWmVisibleIconNameReply); 1214 | define!(reply GetWmVisibleIconNameReply for xcb_ewmh_get_utf8_strings_reply_t with xcb_ewmh_get_utf8_strings_reply_wipe); 1215 | 1216 | pub fn set_wm_visible_icon_name>(c: &Connection, window: xcb::Window, name: T) -> xcb::VoidCookie { 1217 | let value = utf8::from(vec![name.as_ref()]); 1218 | 1219 | void!(unchecked -> c, 1220 | xcb_ewmh_set_wm_visible_icon_name(c.get_raw_conn(), window, value.len() as u32, value.as_ptr() as *mut _)) 1221 | } 1222 | 1223 | pub fn set_wm_visible_icon_name_checked>(c: &Connection, window: xcb::Window, name: T) -> xcb::VoidCookie { 1224 | let value = utf8::from(vec![name.as_ref()]); 1225 | 1226 | void!(checked -> c, 1227 | xcb_ewmh_set_wm_visible_icon_name_checked(c.get_raw_conn(), window, value.len() as u32, value.as_ptr() as *mut _)) 1228 | } 1229 | 1230 | pub fn get_wm_visible_icon_name(c: &Connection, window: xcb::Window) -> GetWmVisibleIconNameCookie { 1231 | property!(checked GetWmVisibleIconNameCookie -> c, 1232 | xcb_ewmh_get_wm_visible_icon_name(c.get_raw_conn(), window)) 1233 | } 1234 | 1235 | pub fn get_wm_visible_icon_name_unchecked(c: &Connection, window: xcb::Window) -> GetWmVisibleIconNameCookie { 1236 | property!(unchecked GetWmVisibleIconNameCookie -> c, 1237 | xcb_ewmh_get_wm_visible_icon_name_unchecked(c.get_raw_conn(), window)) 1238 | } 1239 | 1240 | define!(cookie GetWmDesktopCookie through Connection with xcb_ewmh_get_wm_desktop_reply as u32); 1241 | 1242 | pub fn set_wm_desktop(c: &Connection, window: xcb::Window, number: u32) -> xcb::VoidCookie { 1243 | void!(unchecked -> c, 1244 | xcb_ewmh_set_wm_desktop(c.get_raw_conn(), window, number)) 1245 | } 1246 | 1247 | pub fn set_wm_desktop_checked(c: &Connection, window: xcb::Window, number: u32) -> xcb::VoidCookie { 1248 | void!(checked -> c, 1249 | xcb_ewmh_set_wm_desktop_checked(c.get_raw_conn(), window, number)) 1250 | } 1251 | 1252 | pub fn request_change_wm_desktop(c: &Connection, screen: i32, window: xcb::Window, desktop: u32, source_indication: ClientSourceType) -> xcb::VoidCookie { 1253 | void!(unchecked -> c, 1254 | xcb_ewmh_request_change_wm_desktop(c.get_raw_conn(), screen as c_int, window, 1255 | desktop, source_indication)) 1256 | } 1257 | 1258 | pub fn get_wm_desktop(c: &Connection, window: xcb::Window) -> GetWmDesktopCookie { 1259 | property!(checked GetWmDesktopCookie -> c, 1260 | xcb_ewmh_get_wm_desktop(c.get_raw_conn(), window)) 1261 | } 1262 | 1263 | pub fn get_wm_desktop_unchecked(c: &Connection, window: xcb::Window) -> GetWmDesktopCookie { 1264 | property!(unchecked GetWmDesktopCookie -> c, 1265 | xcb_ewmh_get_wm_desktop_unchecked(c.get_raw_conn(), window)) 1266 | } 1267 | 1268 | define!(cookie GetWmWindowTypeCookie through Connection with xcb_ewmh_get_wm_window_type_reply => GetWmWindowTypeReply); 1269 | define!(reply GetWmWindowTypeReply for xcb_ewmh_get_atoms_reply_t with xcb_ewmh_get_atoms_reply_wipe); 1270 | 1271 | impl GetWmWindowTypeReply { 1272 | pub fn atoms(&self) -> &[xcb::Atom] { 1273 | unsafe { 1274 | slice::from_raw_parts(self.0.atoms as *mut _, self.0.atoms_len as usize) 1275 | } 1276 | } 1277 | } 1278 | 1279 | pub fn set_wm_window_type<'a>(c: &'a Connection, window: xcb::Window, list: &[xcb::Atom]) -> xcb::VoidCookie<'a> { 1280 | void!(unchecked -> c, 1281 | xcb_ewmh_set_wm_window_type(c.get_raw_conn(), window, list.len() as u32, list.as_ptr())) 1282 | } 1283 | 1284 | pub fn set_wm_window_type_checked<'a>(c: &'a Connection, window: xcb::Window, list: &[xcb::Atom]) -> xcb::VoidCookie<'a> { 1285 | void!(checked -> c, 1286 | xcb_ewmh_set_wm_window_type_checked(c.get_raw_conn(), window, list.len() as u32, list.as_ptr())) 1287 | } 1288 | 1289 | pub fn get_wm_window_type(c: &Connection, window: xcb::Window) -> GetWmWindowTypeCookie { 1290 | property!(checked GetWmWindowTypeCookie -> c, 1291 | xcb_ewmh_get_wm_window_type(c.get_raw_conn(), window)) 1292 | } 1293 | 1294 | pub fn get_wm_window_type_unchecked(c: &Connection, window: xcb::Window) -> GetWmWindowTypeCookie { 1295 | property!(unchecked GetWmWindowTypeCookie -> c, 1296 | xcb_ewmh_get_wm_window_type_unchecked(c.get_raw_conn(), window)) 1297 | } 1298 | 1299 | define!(cookie GetWmStateCookie through Connection with xcb_ewmh_get_wm_state_reply => GetWmStateReply); 1300 | define!(reply GetWmStateReply for xcb_ewmh_get_atoms_reply_t with xcb_ewmh_get_atoms_reply_wipe); 1301 | 1302 | impl GetWmStateReply { 1303 | pub fn atoms(&self) -> &[xcb::Atom] { 1304 | unsafe { 1305 | slice::from_raw_parts(self.0.atoms as *mut _, self.0.atoms_len as usize) 1306 | } 1307 | } 1308 | } 1309 | 1310 | pub fn set_wm_state<'a>(c: &'a Connection, window: xcb::Window, list: &[xcb::Atom]) -> xcb::VoidCookie<'a> { 1311 | void!(unchecked -> c, 1312 | xcb_ewmh_set_wm_state(c.get_raw_conn(), window, list.len() as u32, list.as_ptr())) 1313 | } 1314 | 1315 | pub fn set_wm_state_checked<'a>(c: &'a Connection, window: xcb::Window, list: &[xcb::Atom]) -> xcb::VoidCookie<'a> { 1316 | void!(checked -> c, 1317 | xcb_ewmh_set_wm_state_checked(c.get_raw_conn(), window, list.len() as u32, list.as_ptr())) 1318 | } 1319 | 1320 | pub fn request_change_wm_state(c: &Connection, screen: i32, window: xcb::Window, action: StateAction, first: xcb::Atom, second: xcb::Atom, source_indication: ClientSourceType) -> xcb::VoidCookie { 1321 | void!(unchecked -> c, 1322 | xcb_ewmh_request_change_wm_state(c.get_raw_conn(), screen as c_int, window, action, first, second, source_indication)) 1323 | } 1324 | 1325 | pub fn get_wm_state(c: &Connection, window: xcb::Window) -> GetWmStateCookie { 1326 | property!(checked GetWmStateCookie -> c, 1327 | xcb_ewmh_get_wm_state(c.get_raw_conn(), window)) 1328 | } 1329 | 1330 | pub fn get_wm_state_unchecked(c: &Connection, window: xcb::Window) -> GetWmStateCookie { 1331 | property!(unchecked GetWmStateCookie -> c, 1332 | xcb_ewmh_get_wm_state_unchecked(c.get_raw_conn(), window)) 1333 | } 1334 | 1335 | define!(cookie GetWmAllowedActionsCookie through Connection with xcb_ewmh_get_wm_allowed_actions_reply => GetWmAllowedActionsReply); 1336 | define!(reply GetWmAllowedActionsReply for xcb_ewmh_get_atoms_reply_t with xcb_ewmh_get_atoms_reply_wipe); 1337 | 1338 | impl GetWmAllowedActionsReply { 1339 | pub fn atoms(&self) -> &[xcb::Atom] { 1340 | unsafe { 1341 | slice::from_raw_parts(self.0.atoms as *mut _, self.0.atoms_len as usize) 1342 | } 1343 | } 1344 | } 1345 | 1346 | pub fn set_wm_allowed_actions<'a>(c: &'a Connection, window: xcb::Window, list: &[xcb::Atom]) -> xcb::VoidCookie<'a> { 1347 | void!(unchecked -> c, 1348 | xcb_ewmh_set_wm_allowed_actions(c.get_raw_conn(), window, list.len() as u32, list.as_ptr())) 1349 | } 1350 | 1351 | pub fn set_wm_allowed_actions_checked<'a>(c: &'a Connection, window: xcb::Window, list: &[xcb::Atom]) -> xcb::VoidCookie<'a> { 1352 | void!(checked -> c, 1353 | xcb_ewmh_set_wm_allowed_actions_checked(c.get_raw_conn(), window, list.len() as u32, list.as_ptr())) 1354 | } 1355 | 1356 | pub fn get_wm_allowed_actions(c: &Connection, window: xcb::Window) -> GetWmAllowedActionsCookie { 1357 | property!(checked GetWmAllowedActionsCookie -> c, 1358 | xcb_ewmh_get_wm_allowed_actions(c.get_raw_conn(), window)) 1359 | } 1360 | 1361 | pub fn get_wm_allowed_actions_unchecked(c: &Connection, window: xcb::Window) -> GetWmAllowedActionsCookie { 1362 | property!(unchecked GetWmAllowedActionsCookie -> c, 1363 | xcb_ewmh_get_wm_allowed_actions_unchecked(c.get_raw_conn(), window)) 1364 | } 1365 | 1366 | define!(cookie GetWmStrutCookie through Connection with xcb_ewmh_get_wm_strut_reply as Extents); 1367 | 1368 | pub fn set_wm_strut(c: &Connection, window: xcb::Window, left: u32, right: u32, top: u32, bottom: u32) -> xcb::VoidCookie { 1369 | void!(unchecked -> c, 1370 | xcb_ewmh_set_wm_strut(c.get_raw_conn(), window, left, right, top, bottom)) 1371 | } 1372 | 1373 | pub fn set_wm_strut_checked(c: &Connection, window: xcb::Window, left: u32, right: u32, top: u32, bottom: u32) -> xcb::VoidCookie { 1374 | void!(checked -> c, 1375 | xcb_ewmh_set_wm_strut_checked(c.get_raw_conn(), window, left, right, top, bottom)) 1376 | } 1377 | 1378 | pub fn get_wm_strut(c: &Connection, window: xcb::Window) -> GetWmStrutCookie { 1379 | property!(checked GetWmStrutCookie -> c, 1380 | xcb_ewmh_get_wm_strut(c.get_raw_conn(), window)) 1381 | } 1382 | 1383 | pub fn get_wm_strut_unchecked(c: &Connection, window: xcb::Window) -> GetWmStrutCookie { 1384 | property!(unchecked GetWmStrutCookie -> c, 1385 | xcb_ewmh_get_wm_strut(c.get_raw_conn(), window)) 1386 | } 1387 | 1388 | define!(cookie GetWmStrutPartialCookie through Connection with xcb_ewmh_get_wm_strut_partial_reply as StrutPartial); 1389 | 1390 | pub fn set_wm_strut_partial(c: &Connection, window: xcb::Window, partial: StrutPartial) -> xcb::VoidCookie { 1391 | void!(unchecked -> c, 1392 | xcb_ewmh_set_wm_strut_partial(c.get_raw_conn(), window, partial)) 1393 | } 1394 | 1395 | pub fn set_wm_strut_partial_checked(c: &Connection, window: xcb::Window, partial: StrutPartial) -> xcb::VoidCookie { 1396 | void!(checked -> c, 1397 | xcb_ewmh_set_wm_strut_partial_checked(c.get_raw_conn(), window, partial)) 1398 | } 1399 | 1400 | pub fn get_wm_strut_partial(c: &Connection, window: xcb::Window) -> GetWmStrutPartialCookie { 1401 | property!(checked GetWmStrutPartialCookie -> c, 1402 | xcb_ewmh_get_wm_strut_partial(c.get_raw_conn(), window)) 1403 | } 1404 | 1405 | pub fn get_wm_strut_partial_unchecked(c: &Connection, window: xcb::Window) -> GetWmStrutPartialCookie { 1406 | property!(unchecked GetWmStrutPartialCookie -> c, 1407 | xcb_ewmh_get_wm_strut_partial(c.get_raw_conn(), window)) 1408 | } 1409 | 1410 | define!(cookie GetWmIconGeometryCookie through Connection with xcb_ewmh_get_wm_icon_geometry_reply as Geometry); 1411 | 1412 | pub fn set_wm_icon_geometry(c: &Connection, window: xcb::Window, left: u32, right: u32, top: u32, bottom: u32) -> xcb::VoidCookie { 1413 | void!(unchecked -> c, 1414 | xcb_ewmh_set_wm_icon_geometry(c.get_raw_conn(), window, left, right, top, bottom)) 1415 | } 1416 | 1417 | pub fn set_wm_icon_geometry_checked(c: &Connection, window: xcb::Window, left: u32, right: u32, top: u32, bottom: u32) -> xcb::VoidCookie { 1418 | void!(checked -> c, 1419 | xcb_ewmh_set_wm_icon_geometry_checked(c.get_raw_conn(), window, left, right, top, bottom)) 1420 | } 1421 | 1422 | pub fn get_wm_icon_geometry(c: &Connection, window: xcb::Window) -> GetWmIconGeometryCookie { 1423 | property!(checked GetWmIconGeometryCookie -> c, 1424 | xcb_ewmh_get_wm_icon_geometry(c.get_raw_conn(), window)) 1425 | } 1426 | 1427 | pub fn get_wm_icon_geometry_unchecked(c: &Connection, window: xcb::Window) -> GetWmIconGeometryCookie { 1428 | property!(unchecked GetWmIconGeometryCookie -> c, 1429 | xcb_ewmh_get_wm_icon_geometry_unchecked(c.get_raw_conn(), window)) 1430 | } 1431 | 1432 | define!(cookie GetWmIconCookie through Connection with xcb_ewmh_get_wm_icon_reply => GetWmIconReply); 1433 | define!(reply GetWmIconReply for xcb_ewmh_get_wm_icon_reply_t with xcb_ewmh_get_wm_icon_reply_wipe); 1434 | 1435 | impl GetWmIconReply { 1436 | pub fn len(&self) -> usize { 1437 | unsafe { 1438 | xcb_ewmh_get_wm_icon_length(&self.0) as usize 1439 | } 1440 | } 1441 | 1442 | pub fn icons(&self) -> WmIconIterator { 1443 | unsafe { 1444 | xcb_ewmh_get_wm_icon_iterator(&self.0) 1445 | } 1446 | } 1447 | } 1448 | 1449 | pub fn set_wm_icon<'a>(c: &'a Connection, mode: u8, window: xcb::Window, data: &[u32]) -> xcb::VoidCookie<'a> { 1450 | void!(unchecked -> c, 1451 | xcb_ewmh_set_wm_icon(c.get_raw_conn(), mode, window, data.len() as u32, data.as_ptr())) 1452 | } 1453 | 1454 | pub fn set_wm_icon_checked<'a>(c: &'a Connection, mode: u8, window: xcb::Window, data: &[u32]) -> xcb::VoidCookie<'a> { 1455 | void!(checked -> c, 1456 | xcb_ewmh_set_wm_icon_checked(c.get_raw_conn(), mode, window, data.len() as u32, data.as_ptr())) 1457 | } 1458 | 1459 | pub fn append_wm_icon<'a>(c: &'a Connection, window: xcb::Window, width: u32, height: u32, img: &[u32]) -> xcb::VoidCookie<'a> { 1460 | void!(unchecked -> c, 1461 | xcb_ewmh_append_wm_icon(c.get_raw_conn(), window, width, height, img.len() as u32, img.as_ptr())) 1462 | } 1463 | 1464 | pub fn append_wm_icon_checked<'a>(c: &'a Connection, window: xcb::Window, width: u32, height: u32, img: &[u32]) -> xcb::VoidCookie<'a> { 1465 | void!(checked -> c, 1466 | xcb_ewmh_append_wm_icon_checked(c.get_raw_conn(), window, width, height, img.len() as u32, img.as_ptr())) 1467 | } 1468 | 1469 | pub fn get_wm_icon(c: &Connection, window: xcb::Window) -> GetWmIconCookie { 1470 | property!(checked GetWmIconCookie -> c, 1471 | xcb_ewmh_get_wm_icon(c.get_raw_conn(), window)) 1472 | } 1473 | 1474 | pub fn get_wm_icon_unchecked(c: &Connection, window: xcb::Window) -> GetWmIconCookie { 1475 | property!(unchecked GetWmIconCookie -> c, 1476 | xcb_ewmh_get_wm_icon_unchecked(c.get_raw_conn(), window)) 1477 | } 1478 | 1479 | define!(cookie GetWmPidCookie through Connection with xcb_ewmh_get_wm_pid_reply as u32); 1480 | 1481 | pub fn set_wm_pid(c: &Connection, window: xcb::Window, pid: u32) -> xcb::VoidCookie { 1482 | void!(unchecked -> c, 1483 | xcb_ewmh_set_wm_pid(c.get_raw_conn(), window, pid)) 1484 | } 1485 | 1486 | pub fn set_wm_pid_checked(c: &Connection, window: xcb::Window, pid: u32) -> xcb::VoidCookie { 1487 | void!(checked -> c, 1488 | xcb_ewmh_set_wm_pid_checked(c.get_raw_conn(), window, pid)) 1489 | } 1490 | 1491 | pub fn get_wm_pid(c: &Connection, window: xcb::Window) -> GetWmPidCookie { 1492 | property!(checked GetWmPidCookie -> c, 1493 | xcb_ewmh_get_wm_pid(c.get_raw_conn(), window)) 1494 | } 1495 | 1496 | pub fn get_wm_pid_unchecked(c: &Connection, window: xcb::Window) -> GetWmPidCookie { 1497 | property!(checked GetWmPidCookie -> c, 1498 | xcb_ewmh_get_wm_pid_unchecked(c.get_raw_conn(), window)) 1499 | } 1500 | 1501 | define!(cookie GetWmHandledIconsCookie through Connection with xcb_ewmh_get_wm_handled_icons_reply as u32); 1502 | 1503 | pub fn set_wm_handled_icons(c: &Connection, window: xcb::Window, pid: u32) -> xcb::VoidCookie { 1504 | void!(unchecked -> c, 1505 | xcb_ewmh_set_wm_handled_icons(c.get_raw_conn(), window, pid)) 1506 | } 1507 | 1508 | pub fn set_wm_handled_icons_checked(c: &Connection, window: xcb::Window, pid: u32) -> xcb::VoidCookie { 1509 | void!(checked -> c, 1510 | xcb_ewmh_set_wm_handled_icons_checked(c.get_raw_conn(), window, pid)) 1511 | } 1512 | 1513 | pub fn get_wm_handled_icons(c: &Connection, window: xcb::Window) -> GetWmHandledIconsCookie { 1514 | property!(checked GetWmHandledIconsCookie -> c, 1515 | xcb_ewmh_get_wm_handled_icons(c.get_raw_conn(), window)) 1516 | } 1517 | 1518 | pub fn get_wm_handled_icons_unchecked(c: &Connection, window: xcb::Window) -> GetWmHandledIconsCookie { 1519 | property!(checked GetWmHandledIconsCookie -> c, 1520 | xcb_ewmh_get_wm_handled_icons_unchecked(c.get_raw_conn(), window)) 1521 | } 1522 | 1523 | define!(cookie GetWmUserTimeCookie through Connection with xcb_ewmh_get_wm_user_time_reply as u32); 1524 | 1525 | pub fn set_wm_user_time(c: &Connection, window: xcb::Window, pid: u32) -> xcb::VoidCookie { 1526 | void!(unchecked -> c, 1527 | xcb_ewmh_set_wm_user_time(c.get_raw_conn(), window, pid)) 1528 | } 1529 | 1530 | pub fn set_wm_user_time_checked(c: &Connection, window: xcb::Window, pid: u32) -> xcb::VoidCookie { 1531 | void!(checked -> c, 1532 | xcb_ewmh_set_wm_user_time_checked(c.get_raw_conn(), window, pid)) 1533 | } 1534 | 1535 | pub fn get_wm_user_time(c: &Connection, window: xcb::Window) -> GetWmUserTimeCookie { 1536 | property!(checked GetWmUserTimeCookie -> c, 1537 | xcb_ewmh_get_wm_user_time(c.get_raw_conn(), window)) 1538 | } 1539 | 1540 | pub fn get_wm_user_time_unchecked(c: &Connection, window: xcb::Window) -> GetWmUserTimeCookie { 1541 | property!(checked GetWmUserTimeCookie -> c, 1542 | xcb_ewmh_get_wm_user_time_unchecked(c.get_raw_conn(), window)) 1543 | } 1544 | 1545 | define!(cookie GetWmUserTimeWindowCookie through Connection with xcb_ewmh_get_wm_user_time_window_reply as u32); 1546 | 1547 | pub fn set_wm_user_time_window(c: &Connection, window: xcb::Window, pid: u32) -> xcb::VoidCookie { 1548 | void!(unchecked -> c, 1549 | xcb_ewmh_set_wm_user_time_window(c.get_raw_conn(), window, pid)) 1550 | } 1551 | 1552 | pub fn set_wm_user_time_window_checked(c: &Connection, window: xcb::Window, pid: u32) -> xcb::VoidCookie { 1553 | void!(checked -> c, 1554 | xcb_ewmh_set_wm_user_time_window_checked(c.get_raw_conn(), window, pid)) 1555 | } 1556 | 1557 | pub fn get_wm_user_time_window(c: &Connection, window: xcb::Window) -> GetWmUserTimeWindowCookie { 1558 | property!(checked GetWmUserTimeWindowCookie -> c, 1559 | xcb_ewmh_get_wm_user_time_window(c.get_raw_conn(), window)) 1560 | } 1561 | 1562 | pub fn get_wm_user_time_window_unchecked(c: &Connection, window: xcb::Window) -> GetWmUserTimeWindowCookie { 1563 | property!(checked GetWmUserTimeWindowCookie -> c, 1564 | xcb_ewmh_get_wm_user_time_window_unchecked(c.get_raw_conn(), window)) 1565 | } 1566 | 1567 | define!(cookie GetFrameExtentsCookie through Connection with xcb_ewmh_get_frame_extents_reply as Extents); 1568 | 1569 | pub fn set_frame_extents(c: &Connection, window: xcb::Window, left: u32, right: u32, top: u32, bottom: u32) -> xcb::VoidCookie { 1570 | void!(unchecked -> c, 1571 | xcb_ewmh_set_frame_extents(c.get_raw_conn(), window, left, right, top, bottom)) 1572 | } 1573 | 1574 | pub fn set_frame_extents_checked(c: &Connection, window: xcb::Window, left: u32, right: u32, top: u32, bottom: u32) -> xcb::VoidCookie { 1575 | void!(checked -> c, 1576 | xcb_ewmh_set_frame_extents_checked(c.get_raw_conn(), window, left, right, top, bottom)) 1577 | } 1578 | 1579 | pub fn get_frame_extents(c: &Connection, window: xcb::Window) -> GetFrameExtentsCookie { 1580 | property!(checked GetFrameExtentsCookie -> c, 1581 | xcb_ewmh_get_frame_extents(c.get_raw_conn(), window)) 1582 | } 1583 | 1584 | pub fn get_frame_extents_unchecked(c: &Connection, window: xcb::Window) -> GetFrameExtentsCookie { 1585 | property!(unchecked GetFrameExtentsCookie -> c, 1586 | xcb_ewmh_get_frame_extents_unchecked(c.get_raw_conn(), window)) 1587 | } 1588 | 1589 | define!(cookie GetWmSyncRequestCounterCookie through Connection with xcb_ewmh_get_wm_sync_request_counter_reply as u64); 1590 | 1591 | pub fn set_wm_sync_request_counter(c: &Connection, window: xcb::Window, atom: xcb::Atom, low: u32, high: u32) -> xcb::VoidCookie { 1592 | void!(unchecked -> c, 1593 | xcb_ewmh_set_wm_sync_request_counter(c.get_raw_conn(), window, atom, low, high)) 1594 | } 1595 | 1596 | pub fn set_wm_sync_request_counter_checked(c: &Connection, window: xcb::Window, atom: xcb::Atom, low: u32, high: u32) -> xcb::VoidCookie { 1597 | void!(checked -> c, 1598 | xcb_ewmh_set_wm_sync_request_counter_checked(c.get_raw_conn(), window, atom, low, high)) 1599 | } 1600 | 1601 | pub fn send_wm_sync_request(c: &Connection, window: xcb::Window, wm_protocols: xcb::Atom, wm_sync_request: xcb::Atom, timestamp: xcb::Timestamp, counter: u64) -> xcb::VoidCookie { 1602 | void!(unchecked -> c, 1603 | xcb_ewmh_send_wm_sync_rqeuest(c.get_raw_conn(), window, wm_protocols, wm_sync_request, timestamp, counter)) 1604 | } 1605 | 1606 | pub fn get_wm_sync_request_counter(c: &Connection, window: xcb::Window) -> GetWmSyncRequestCounterCookie { 1607 | property!(checked GetWmSyncRequestCounterCookie -> c, 1608 | xcb_ewmh_get_wm_sync_request_counter(c.get_raw_conn(), window)) 1609 | } 1610 | 1611 | pub fn get_wm_sync_request_counter_unchecked(c: &Connection, window: xcb::Window) -> GetWmSyncRequestCounterCookie { 1612 | property!(unchecked GetWmSyncRequestCounterCookie -> c, 1613 | xcb_ewmh_get_wm_sync_request_counter_unchecked(c.get_raw_conn(), window)) 1614 | } 1615 | 1616 | define!(cookie GetWmFullScreenMonitorsCookie through Connection with xcb_ewmh_get_wm_fullscreen_monitors_reply as WmFullScreenMonitors); 1617 | 1618 | pub fn set_wm_full_screen_monitors(c: &Connection, window: xcb::Window, top: u32, bottom: u32, left: u32, right: u32) -> xcb::VoidCookie { 1619 | void!(unchecked -> c, 1620 | xcb_ewmh_set_wm_fullscreen_monitors(c.get_raw_conn(), window, top, bottom, left, right)) 1621 | } 1622 | 1623 | pub fn set_wm_full_screen_monitors_checked(c: &Connection, window: xcb::Window, top: u32, bottom: u32, left: u32, right: u32) -> xcb::VoidCookie { 1624 | void!(checked -> c, 1625 | xcb_ewmh_set_wm_fullscreen_monitors_checked(c.get_raw_conn(), window, top, bottom, left, right)) 1626 | } 1627 | 1628 | pub fn request_change_wm_full_screen_monitors(c: &Connection, screen: i32, window: xcb::Window, top: u32, bottom: u32, left: u32, right: u32, source_indication: ClientSourceType) -> xcb::VoidCookie { 1629 | void!(unchecked -> c, 1630 | xcb_ewmh_request_change_wm_fullscreen_monitors(c.get_raw_conn(), screen as c_int, window, top, bottom, left, right, source_indication)) 1631 | } 1632 | 1633 | pub fn get_wm_full_screen_monitors(c: &Connection, window: xcb::Window) -> GetWmFullScreenMonitorsCookie { 1634 | property!(checked GetWmFullScreenMonitorsCookie -> c, 1635 | xcb_ewmh_get_wm_fullscreen_monitors(c.get_raw_conn(), window)) 1636 | } 1637 | 1638 | pub fn get_wm_full_screen_monitors_unchecked(c: &Connection, window: xcb::Window) -> GetWmFullScreenMonitorsCookie { 1639 | property!(unchecked GetWmFullScreenMonitorsCookie -> c, 1640 | xcb_ewmh_get_wm_fullscreen_monitors_unchecked(c.get_raw_conn(), window)) 1641 | } 1642 | 1643 | define!(cookie GetWmCmOwnerCookie(xcb_get_selection_owner_cookie_t) through Connection with xcb_ewmh_get_wm_cm_owner_reply as xcb::Window); 1644 | 1645 | pub fn set_wm_cm_owner(c: &Connection, screen: i32, owner: xcb::Window, timestamp: xcb::Timestamp, first: u32, second: u32) -> xcb::VoidCookie { 1646 | void!(unchecked -> c, 1647 | xcb_ewmh_set_wm_cm_owner(c.get_raw_conn(), screen as c_int, owner, timestamp, first, second)) 1648 | } 1649 | 1650 | pub fn set_wm_cm_owner_checked(c: &Connection, screen: i32, owner: xcb::Window, timestamp: xcb::Timestamp, first: u32, second: u32) -> xcb::VoidCookie { 1651 | void!(checked -> c, 1652 | xcb_ewmh_set_wm_cm_owner_checked(c.get_raw_conn(), screen as c_int, owner, timestamp, first, second)) 1653 | } 1654 | 1655 | pub fn get_wm_cm_owner(c: &Connection, screen: i32) -> GetWmCmOwnerCookie { 1656 | unsafe { 1657 | GetWmCmOwnerCookie { 1658 | conn: c, 1659 | cookie: xcb_ewmh_get_wm_cm_owner(c.get_raw_conn(), screen as c_int), 1660 | checked: true, 1661 | } 1662 | } 1663 | } 1664 | 1665 | pub fn get_wm_cm_owner_unchecked(c: &Connection, screen: i32) -> GetWmCmOwnerCookie { 1666 | unsafe { 1667 | GetWmCmOwnerCookie { 1668 | conn: c, 1669 | cookie: xcb_ewmh_get_wm_cm_owner_unchecked(c.get_raw_conn(), screen as c_int), 1670 | checked: false, 1671 | } 1672 | } 1673 | } 1674 | -------------------------------------------------------------------------------- /src/ffi/ewmh.rs: -------------------------------------------------------------------------------- 1 | use std::mem; 2 | use std::ptr; 3 | 4 | use xcb::ffi::*; 5 | use libc::{c_char, c_int, c_uint}; 6 | use libc::{free}; 7 | 8 | #[repr(C)] 9 | pub struct xcb_ewmh_connection_t { 10 | pub connection: *mut xcb_connection_t, 11 | pub screens: *mut *mut xcb_screen_t, 12 | pub nb_screens: c_int, 13 | 14 | pub _NET_WM_CM_Sn: *mut xcb_atom_t, 15 | pub _NET_SUPPORTED: xcb_atom_t, 16 | pub _NET_CLIENT_LIST: xcb_atom_t, 17 | pub _NET_CLIENT_LIST_STACKING: xcb_atom_t, 18 | pub _NET_NUMBER_OF_DESKTOPS: xcb_atom_t, 19 | pub _NET_DESKTOP_GEOMETRY: xcb_atom_t, 20 | pub _NET_DESKTOP_VIEWPORT: xcb_atom_t, 21 | pub _NET_CURRENT_DESKTOP: xcb_atom_t, 22 | pub _NET_DESKTOP_NAMES: xcb_atom_t, 23 | pub _NET_ACTIVE_WINDOW: xcb_atom_t, 24 | pub _NET_WORKAREA: xcb_atom_t, 25 | pub _NET_SUPPORTING_WM_CHECK: xcb_atom_t, 26 | pub _NET_VIRTUAL_ROOTS: xcb_atom_t, 27 | pub _NET_DESKTOP_LAYOUT: xcb_atom_t, 28 | pub _NET_SHOWING_DESKTOP: xcb_atom_t, 29 | pub _NET_CLOSE_WINDOW: xcb_atom_t, 30 | pub _NET_MOVERESIZE_WINDOW: xcb_atom_t, 31 | pub _NET_WM_MOVERESIZE: xcb_atom_t, 32 | pub _NET_RESTACK_WINDOW: xcb_atom_t, 33 | pub _NET_REQUEST_FRAME_EXTENTS: xcb_atom_t, 34 | pub _NET_WM_NAME: xcb_atom_t, 35 | pub _NET_WM_VISIBLE_NAME: xcb_atom_t, 36 | pub _NET_WM_ICON_NAME: xcb_atom_t, 37 | pub _NET_WM_VISIBLE_ICON_NAME: xcb_atom_t, 38 | pub _NET_WM_DESKTOP: xcb_atom_t, 39 | pub _NET_WM_WINDOW_TYPE: xcb_atom_t, 40 | pub _NET_WM_STATE: xcb_atom_t, 41 | pub _NET_WM_ALLOWED_ACTIONS: xcb_atom_t, 42 | pub _NET_WM_STRUT: xcb_atom_t, 43 | pub _NET_WM_STRUT_PARTIAL: xcb_atom_t, 44 | pub _NET_WM_ICON_GEOMETRY: xcb_atom_t, 45 | pub _NET_WM_ICON: xcb_atom_t, 46 | pub _NET_WM_PID: xcb_atom_t, 47 | pub _NET_WM_HANDLED_ICONS: xcb_atom_t, 48 | pub _NET_WM_USER_TIME: xcb_atom_t, 49 | pub _NET_WM_USER_TIME_WINDOW: xcb_atom_t, 50 | pub _NET_FRAME_EXTENTS: xcb_atom_t, 51 | pub _NET_WM_PING: xcb_atom_t, 52 | pub _NET_WM_SYNC_REQUEST: xcb_atom_t, 53 | pub _NET_WM_SYNC_REQUEST_COUNTER: xcb_atom_t, 54 | pub _NET_WM_FULLSCREEN_MONITORS: xcb_atom_t, 55 | pub _NET_WM_FULL_PLACEMENT: xcb_atom_t, 56 | pub UTF8_STRING: xcb_atom_t, 57 | pub WM_PROTOCOLS: xcb_atom_t, 58 | pub MANAGER: xcb_atom_t, 59 | pub _NET_WM_WINDOW_TYPE_DESKTOP: xcb_atom_t, 60 | pub _NET_WM_WINDOW_TYPE_DOCK: xcb_atom_t, 61 | pub _NET_WM_WINDOW_TYPE_TOOLBAR: xcb_atom_t, 62 | pub _NET_WM_WINDOW_TYPE_MENU: xcb_atom_t, 63 | pub _NET_WM_WINDOW_TYPE_UTILITY: xcb_atom_t, 64 | pub _NET_WM_WINDOW_TYPE_SPLASH: xcb_atom_t, 65 | pub _NET_WM_WINDOW_TYPE_DIALOG: xcb_atom_t, 66 | pub _NET_WM_WINDOW_TYPE_DROPDOWN_MENU: xcb_atom_t, 67 | pub _NET_WM_WINDOW_TYPE_POPUP_MENU: xcb_atom_t, 68 | pub _NET_WM_WINDOW_TYPE_TOOLTIP: xcb_atom_t, 69 | pub _NET_WM_WINDOW_TYPE_NOTIFICATION: xcb_atom_t, 70 | pub _NET_WM_WINDOW_TYPE_COMBO: xcb_atom_t, 71 | pub _NET_WM_WINDOW_TYPE_DND: xcb_atom_t, 72 | pub _NET_WM_WINDOW_TYPE_NORMAL: xcb_atom_t, 73 | pub _NET_WM_STATE_MODAL: xcb_atom_t, 74 | pub _NET_WM_STATE_STICKY: xcb_atom_t, 75 | pub _NET_WM_STATE_MAXIMIZED_VERT: xcb_atom_t, 76 | pub _NET_WM_STATE_MAXIMIZED_HORZ: xcb_atom_t, 77 | pub _NET_WM_STATE_SHADED: xcb_atom_t, 78 | pub _NET_WM_STATE_SKIP_TASKBAR: xcb_atom_t, 79 | pub _NET_WM_STATE_SKIP_PAGER: xcb_atom_t, 80 | pub _NET_WM_STATE_HIDDEN: xcb_atom_t, 81 | pub _NET_WM_STATE_FULLSCREEN: xcb_atom_t, 82 | pub _NET_WM_STATE_ABOVE: xcb_atom_t, 83 | pub _NET_WM_STATE_BELOW: xcb_atom_t, 84 | pub _NET_WM_STATE_DEMANDS_ATTENTION: xcb_atom_t, 85 | pub _NET_WM_ACTION_MOVE: xcb_atom_t, 86 | pub _NET_WM_ACTION_RESIZE: xcb_atom_t, 87 | pub _NET_WM_ACTION_MINIMIZE: xcb_atom_t, 88 | pub _NET_WM_ACTION_SHADE: xcb_atom_t, 89 | pub _NET_WM_ACTION_STICK: xcb_atom_t, 90 | pub _NET_WM_ACTION_MAXIMIZE_HORZ: xcb_atom_t, 91 | pub _NET_WM_ACTION_MAXIMIZE_VERT: xcb_atom_t, 92 | pub _NET_WM_ACTION_FULLSCREEN: xcb_atom_t, 93 | pub _NET_WM_ACTION_CHANGE_DESKTOP: xcb_atom_t, 94 | pub _NET_WM_ACTION_CLOSE: xcb_atom_t, 95 | pub _NET_WM_ACTION_ABOVE: xcb_atom_t, 96 | pub _NET_WM_ACTION_BELOW: xcb_atom_t, 97 | } 98 | 99 | #[repr(C)] 100 | pub struct xcb_ewmh_get_atoms_reply_t { 101 | pub atoms_len: u32, 102 | pub atoms: *mut xcb_atom_t, 103 | 104 | _reply: *mut xcb_get_property_reply_t, 105 | } 106 | 107 | #[repr(C)] 108 | pub struct xcb_ewmh_get_windows_reply_t { 109 | pub windows_len: u32, 110 | pub windows: *mut xcb_window_t, 111 | 112 | _reply: *mut xcb_get_property_reply_t, 113 | } 114 | 115 | #[repr(C)] 116 | pub struct xcb_ewmh_get_utf8_strings_reply_t { 117 | pub strings_len: u32, 118 | pub strings: *mut c_char, 119 | 120 | _reply: *mut xcb_get_property_reply_t, 121 | } 122 | 123 | #[repr(C)] 124 | pub struct xcb_ewmh_coordinates_t { 125 | pub x: u32, 126 | pub y: u32, 127 | } 128 | 129 | #[repr(C)] 130 | pub struct xcb_ewmh_get_desktop_viewport_reply_t { 131 | pub desktop_viewport_len: u32, 132 | pub desktop_viewport: *mut xcb_ewmh_coordinates_t, 133 | 134 | _reply: *mut xcb_get_property_reply_t, 135 | } 136 | 137 | #[repr(C)] 138 | pub struct xcb_ewmh_geometry_t { 139 | pub x: u32, 140 | pub y: u32, 141 | pub width: u32, 142 | pub height: u32, 143 | } 144 | 145 | #[repr(C)] 146 | pub struct xcb_ewmh_get_workarea_reply_t { 147 | pub workarea_len: u32, 148 | pub workarea: *mut xcb_ewmh_geometry_t, 149 | 150 | _reply: *mut xcb_get_property_reply_t, 151 | } 152 | 153 | pub type xcb_ewmh_client_source_type_t = u32; 154 | pub const XCB_EWMH_CLIENT_SOURCE_TYPE_NONE: xcb_ewmh_client_source_type_t = 0; 155 | pub const XCB_EWMH_CLIENT_SOURCE_TYPE_NORMAL: xcb_ewmh_client_source_type_t = 1; 156 | pub const XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER: xcb_ewmh_client_source_type_t = 2; 157 | 158 | pub type xcb_ewmh_desktop_layout_orientation_t = u32; 159 | pub const XCB_EWMH_WM_ORIENTATION_HORZ: xcb_ewmh_desktop_layout_orientation_t = 0; 160 | pub const XCB_EWMH_WM_ORIENTATION_VERT: xcb_ewmh_desktop_layout_orientation_t = 1; 161 | 162 | pub type xcb_ewmh_desktop_layout_starting_corner_t = u32; 163 | pub const XCB_EWMH_WM_TOPLEFT: xcb_ewmh_desktop_layout_starting_corner_t = 0; 164 | pub const XCB_EWMH_WM_TOPRIGHT: xcb_ewmh_desktop_layout_starting_corner_t = 1; 165 | pub const XCB_EWMH_WM_BOTTOMRIGHT: xcb_ewmh_desktop_layout_starting_corner_t = 2; 166 | pub const XCB_EWMH_WM_BOTTOMLEFT: xcb_ewmh_desktop_layout_starting_corner_t = 3; 167 | 168 | #[repr(C)] 169 | pub struct xcb_ewmh_get_desktop_layout_reply_t { 170 | pub orientation: u32, 171 | pub columns: u32, 172 | pub rows: u32, 173 | pub starting_corner: u32, 174 | } 175 | 176 | pub type xcb_ewmh_moveresize_window_opt_flags_t = u32; 177 | pub const XCB_EWMH_MOVERESIZE_WINDOW_X: xcb_ewmh_moveresize_window_opt_flags_t = 1 << 8; 178 | pub const XCB_EWMH_MOVERESIZE_WINDOW_Y: xcb_ewmh_moveresize_window_opt_flags_t = 1 << 9; 179 | pub const XCB_EWMH_MOVERESIZE_WINDOW_WIDTH: xcb_ewmh_moveresize_window_opt_flags_t = 1 << 10; 180 | pub const XCB_EWMH_MOVERESIZE_WINDOW_HEIGHT: xcb_ewmh_moveresize_window_opt_flags_t = 1 << 11; 181 | 182 | pub type xcb_ewmh_moveresize_direction_t = u32; 183 | pub const XCB_EWMH_WM_MOVERESIZE_SIZE_TOPLEFT: xcb_ewmh_moveresize_direction_t = 0; 184 | pub const XCB_EWMH_WM_MOVERESIZE_SIZE_TOP: xcb_ewmh_moveresize_direction_t = 1; 185 | pub const XCB_EWMH_WM_MOVERESIZE_SIZE_TOPRIGHT: xcb_ewmh_moveresize_direction_t = 2; 186 | pub const XCB_EWMH_WM_MOVERESIZE_SIZE_RIGHT: xcb_ewmh_moveresize_direction_t = 3; 187 | pub const XCB_EWMH_WM_MOVERESIZE_SIZE_BOTTOMRIGHT: xcb_ewmh_moveresize_direction_t = 4; 188 | pub const XCB_EWMH_WM_MOVERESIZE_SIZE_BOTTOM: xcb_ewmh_moveresize_direction_t = 5; 189 | pub const XCB_EWMH_WM_MOVERESIZE_SIZE_BOTTOMLEFT: xcb_ewmh_moveresize_direction_t = 6; 190 | pub const XCB_EWMH_WM_MOVERESIZE_SIZE_LEFT: xcb_ewmh_moveresize_direction_t = 7; 191 | pub const XCB_EWMH_WM_MOVERESIZE_MOVE: xcb_ewmh_moveresize_direction_t = 8; 192 | pub const XCB_EWMH_WM_MOVERESIZE_SIZE_KEYBOARD: xcb_ewmh_moveresize_direction_t = 9; 193 | pub const XCB_EWMH_WM_MOVERESIZE_MOVE_KEYBOARD: xcb_ewmh_moveresize_direction_t = 10; 194 | pub const XCB_EWMH_WM_MOVERESIZE_CANCEL: xcb_ewmh_moveresize_direction_t = 11; 195 | 196 | pub type xcb_ewmh_wm_state_action_t = u32; 197 | pub const XCB_EWMH_WM_STATE_REMOVE: xcb_ewmh_wm_state_action_t = 0; 198 | pub const XCB_EWMH_WM_STATE_ADD: xcb_ewmh_wm_state_action_t = 1; 199 | pub const XCB_EWMH_WM_STATE_TOGGLE: xcb_ewmh_wm_state_action_t = 2; 200 | 201 | #[repr(C)] 202 | pub struct xcb_ewmh_wm_strut_partial_t { 203 | pub left: u32, 204 | pub right: u32, 205 | pub top: u32, 206 | pub bottom: u32, 207 | pub left_start_y: u32, 208 | pub left_end_y: u32, 209 | pub right_start_y: u32, 210 | pub right_end_y: u32, 211 | pub top_start_x: u32, 212 | pub top_end_x: u32, 213 | pub bottom_start_x: u32, 214 | pub bottom_end_x: u32, 215 | } 216 | 217 | #[repr(C)] 218 | pub struct xcb_ewmh_wm_icon_iterator_t { 219 | pub width: u32, 220 | pub height: u32, 221 | pub data: *mut u32, 222 | pub rem: c_uint, 223 | pub index: c_uint, 224 | } 225 | 226 | #[repr(C)] 227 | pub struct xcb_ewmh_get_wm_icon_reply_t { 228 | pub num_icons: c_uint, 229 | 230 | _reply: *mut xcb_get_property_reply_t, 231 | } 232 | 233 | #[repr(C)] 234 | pub struct xcb_ewmh_get_extents_reply_t { 235 | pub top: u32, 236 | pub bottom: u32, 237 | pub left: u32, 238 | pub right: u32, 239 | } 240 | 241 | #[repr(C)] 242 | pub struct xcb_ewmh_get_wm_fullscreen_monitors_reply_t { 243 | pub top: u32, 244 | pub bottom: u32, 245 | pub left: u32, 246 | pub right: u32, 247 | } 248 | 249 | #[cfg_attr(feature = "static", link(name = "xcb-ewmh", kind = "static"))] 250 | #[cfg_attr(not(feature = "static"), link(name = "xcb-ewmh"))] 251 | extern "C" { 252 | pub fn xcb_ewmh_init_atoms(c: *mut xcb_connection_t, ewmh: *mut xcb_ewmh_connection_t) -> *mut xcb_intern_atom_cookie_t; 253 | pub fn xcb_ewmh_init_atoms_replies(ewmh: *mut xcb_ewmh_connection_t, ewmh_cookies: *mut xcb_intern_atom_cookie_t, e: *mut *mut xcb_generic_error_t) -> u8; 254 | 255 | pub fn xcb_ewmh_send_client_message(c: *mut xcb_connection_t, window: xcb_window_t, dest: xcb_window_t, atom: xcb_atom_t, data_len: u32, data: *const u32) -> xcb_void_cookie_t; 256 | pub fn xcb_ewmh_request_close_window(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, window_to_close: xcb_window_t, timetamp: xcb_timestamp_t, source_indication: xcb_ewmh_client_source_type_t) -> xcb_void_cookie_t; 257 | pub fn xcb_ewmh_request_moveresize_window(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, moveresize_window: xcb_window_t, gravity: xcb_gravity_t, source_indication: xcb_ewmh_client_source_type_t, flags: xcb_ewmh_moveresize_window_opt_flags_t, x: u32, y: u32, width: u32, height: u32) -> xcb_void_cookie_t; 258 | pub fn xcb_ewmh_request_wm_moveresize(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, moveresize_window: xcb_window_t, x_root: u32, y_root: u32, direction: xcb_ewmh_moveresize_direction_t, button: xcb_button_index_t, source_indication: xcb_ewmh_client_source_type_t) -> xcb_void_cookie_t; 259 | pub fn xcb_ewmh_request_restack_window(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, window_to_restack: xcb_window_t, sibling_window: xcb_window_t, detail: xcb_stack_mode_t) -> xcb_void_cookie_t; 260 | pub fn xcb_ewmh_send_wm_ping(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, timestamp: xcb_timestamp_t) -> xcb_void_cookie_t; 261 | 262 | pub fn xcb_ewmh_get_window_from_reply(window: *mut xcb_window_t, r: *const xcb_get_property_reply_t) -> u8; 263 | pub fn xcb_ewmh_get_window_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, window: *mut xcb_window_t, e: *mut *mut xcb_generic_error_t) -> u8; 264 | 265 | pub fn xcb_ewmh_get_cardinal_from_reply(cardinal: *mut u32, r: *const xcb_get_property_reply_t) -> u8; 266 | pub fn xcb_ewmh_get_cardinal_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, cardinal: *mut u32, e: *mut *mut xcb_generic_error_t) -> u8; 267 | 268 | pub fn xcb_ewmh_get_atoms_from_reply(atoms: *mut xcb_ewmh_get_atoms_reply_t, r: *const xcb_get_property_reply_t) -> u8; 269 | pub fn xcb_ewmh_get_atoms_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, atoms: *mut xcb_ewmh_get_atoms_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 270 | pub fn xcb_ewmh_get_atoms_reply_wipe(data: *mut xcb_ewmh_get_atoms_reply_t); 271 | 272 | pub fn xcb_ewmh_get_windows_from_reply(atoms: *mut xcb_ewmh_get_windows_reply_t, r: *const xcb_get_property_reply_t) -> u8; 273 | pub fn xcb_ewmh_get_windows_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, atoms: *mut xcb_ewmh_get_windows_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 274 | pub fn xcb_ewmh_get_windows_reply_wipe(data: *mut xcb_ewmh_get_windows_reply_t); 275 | 276 | pub fn xcb_ewmh_get_utf8_strings_from_reply(ewmh: *mut xcb_ewmh_connection_t, data: *mut xcb_ewmh_get_utf8_strings_reply_t, r: *const xcb_get_property_reply_t) -> u8; 277 | pub fn xcb_ewmh_get_utf8_strings_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, data: *mut xcb_ewmh_get_utf8_strings_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 278 | pub fn xcb_ewmh_get_utf8_strings_reply_wipe(data: *mut xcb_ewmh_get_utf8_strings_reply_t); 279 | 280 | pub fn xcb_ewmh_set_supported(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_atom_t) -> xcb_void_cookie_t; 281 | pub fn xcb_ewmh_set_supported_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_atom_t) -> xcb_void_cookie_t; 282 | pub fn xcb_ewmh_get_supported(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 283 | pub fn xcb_ewmh_get_supported_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 284 | 285 | pub fn xcb_ewmh_set_client_list(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_window_t) -> xcb_void_cookie_t; 286 | pub fn xcb_ewmh_set_client_list_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_window_t) -> xcb_void_cookie_t; 287 | pub fn xcb_ewmh_get_client_list(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 288 | pub fn xcb_ewmh_get_client_list_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 289 | 290 | pub fn xcb_ewmh_set_client_list_stacking(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_window_t) -> xcb_void_cookie_t; 291 | pub fn xcb_ewmh_set_client_list_stacking_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_window_t) -> xcb_void_cookie_t; 292 | pub fn xcb_ewmh_get_client_list_stacking(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 293 | pub fn xcb_ewmh_get_client_list_stacking_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 294 | 295 | pub fn xcb_ewmh_set_number_of_desktops(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, number_of_desktops: u32) -> xcb_void_cookie_t; 296 | pub fn xcb_ewmh_set_number_of_desktops_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, number_of_desktops: u32) -> xcb_void_cookie_t; 297 | pub fn xcb_ewmh_get_number_of_desktops(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 298 | pub fn xcb_ewmh_get_number_of_desktops_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 299 | 300 | pub fn xcb_ewmh_set_desktop_geometry(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, new_width: u32, new_height: u32) -> xcb_void_cookie_t; 301 | pub fn xcb_ewmh_set_desktop_geometry_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, new_width: u32, new_height: u32) -> xcb_void_cookie_t; 302 | pub fn xcb_ewmh_get_desktop_geometry(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 303 | pub fn xcb_ewmh_get_desktop_geometry_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 304 | pub fn xcb_ewmh_request_change_desktop_geometry(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, new_width: u32, new_height: u32) -> xcb_void_cookie_t; 305 | pub fn xcb_ewmh_get_desktop_geometry_from_reply(width: *mut u32, height: *mut u32, r: xcb_get_property_reply_t) -> u8; 306 | pub fn xcb_ewmh_get_desktop_geometry_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, width: *mut u32, height: *mut u32, e: *mut *mut xcb_generic_error_t) -> u8; 307 | 308 | pub fn xcb_ewmh_set_desktop_viewport(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_ewmh_coordinates_t) -> xcb_void_cookie_t; 309 | pub fn xcb_ewmh_set_desktop_viewport_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_ewmh_coordinates_t) -> xcb_void_cookie_t; 310 | pub fn xcb_ewmh_get_desktop_viewport(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 311 | pub fn xcb_ewmh_get_desktop_viewport_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 312 | pub fn xcb_ewmh_get_desktop_viewport_from_reply(vp: *mut xcb_ewmh_get_desktop_viewport_reply_t, r: xcb_get_property_reply_t) -> u8; 313 | pub fn xcb_ewmh_get_desktop_viewport_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, vp: *mut xcb_ewmh_get_desktop_viewport_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 314 | pub fn xcb_ewmh_get_desktop_viewport_reply_wipe(r: *mut xcb_ewmh_get_desktop_viewport_reply_t); 315 | 316 | pub fn xcb_ewmh_set_current_desktop(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, new_current_desktop: u32) -> xcb_void_cookie_t; 317 | pub fn xcb_ewmh_set_current_desktop_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, new_current_desktop: u32) -> xcb_void_cookie_t; 318 | pub fn xcb_ewmh_get_current_desktop(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 319 | pub fn xcb_ewmh_get_current_desktop_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 320 | pub fn xcb_ewmh_request_change_current_desktop(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, new_desktop: u32, timestamp: xcb_timestamp_t) -> xcb_void_cookie_t; 321 | 322 | pub fn xcb_ewmh_set_desktop_names(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, strings_len: u32, strings: *mut c_char) -> xcb_void_cookie_t; 323 | pub fn xcb_ewmh_set_desktop_names_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, strings_len: u32, strings: *mut c_char) -> xcb_void_cookie_t; 324 | pub fn xcb_ewmh_get_desktop_names(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 325 | pub fn xcb_ewmh_get_desktop_names_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 326 | 327 | pub fn xcb_ewmh_set_active_window(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, new_active_window: xcb_window_t) -> xcb_void_cookie_t; 328 | pub fn xcb_ewmh_set_active_window_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, new_active_window: xcb_window_t) -> xcb_void_cookie_t; 329 | pub fn xcb_ewmh_request_change_active_window(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, window_to_activate: xcb_window_t, source_indication: xcb_ewmh_client_source_type_t, timestamp: xcb_timestamp_t, current_active_window: xcb_window_t) -> xcb_void_cookie_t; 330 | pub fn xcb_ewmh_get_active_window(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 331 | pub fn xcb_ewmh_get_active_window_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 332 | 333 | pub fn xcb_ewmh_set_workarea(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_ewmh_geometry_t) -> xcb_void_cookie_t; 334 | pub fn xcb_ewmh_set_workarea_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_ewmh_geometry_t) -> xcb_void_cookie_t; 335 | pub fn xcb_ewmh_get_workarea(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 336 | pub fn xcb_ewmh_get_workarea_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 337 | pub fn xcb_ewmh_get_workarea_from_reply(wa: *mut xcb_ewmh_get_workarea_reply_t, r: *const xcb_get_property_reply_t) -> u8; 338 | pub fn xcb_ewmh_get_workarea_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, wa: *mut xcb_ewmh_get_workarea_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 339 | pub fn xcb_ewmh_get_workarea_reply_wipe(r: *mut xcb_ewmh_get_workarea_reply_t); 340 | 341 | pub fn xcb_ewmh_set_supporting_wm_check(ewmh: *mut xcb_ewmh_connection_t, parent_window: xcb_window_t, child_window: xcb_window_t) -> xcb_void_cookie_t; 342 | pub fn xcb_ewmh_set_supporting_wm_check_checked(ewmh: *mut xcb_ewmh_connection_t, parent_window: xcb_window_t, child_window: xcb_window_t) -> xcb_void_cookie_t; 343 | pub fn xcb_ewmh_get_supporting_wm_check(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 344 | pub fn xcb_ewmh_get_supporting_wm_check_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 345 | 346 | pub fn xcb_ewmh_set_virtual_roots(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_window_t) -> xcb_void_cookie_t; 347 | pub fn xcb_ewmh_set_virtual_roots_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, list_len: u32, list: *const xcb_window_t) -> xcb_void_cookie_t; 348 | pub fn xcb_ewmh_get_virtual_roots(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 349 | pub fn xcb_ewmh_get_virtual_roots_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 350 | 351 | pub fn xcb_ewmh_set_desktop_layout(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, orientation: xcb_ewmh_desktop_layout_orientation_t, columns: u32, rows: u32, starting_corner: xcb_ewmh_desktop_layout_starting_corner_t) -> xcb_void_cookie_t; 352 | pub fn xcb_ewmh_set_desktop_layout_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, orientation: xcb_ewmh_desktop_layout_orientation_t, columns: u32, rows: u32, starting_corner: xcb_ewmh_desktop_layout_starting_corner_t) -> xcb_void_cookie_t; 353 | pub fn xcb_ewmh_get_desktop_layout(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 354 | pub fn xcb_ewmh_get_desktop_layout_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 355 | pub fn xcb_ewmh_get_desktop_layout_from_reply(desktop_layouts: *mut xcb_ewmh_get_desktop_layout_reply_t, r: *const xcb_get_property_reply_t) -> u8; 356 | pub fn xcb_ewmh_get_desktop_layout_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, desktop_layouts: *mut xcb_ewmh_get_desktop_layout_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 357 | 358 | pub fn xcb_ewmh_set_showing_desktop(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, desktop: u32) -> xcb_void_cookie_t; 359 | pub fn xcb_ewmh_set_showing_desktop_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, desktop: u32) -> xcb_void_cookie_t; 360 | pub fn xcb_ewmh_get_showing_desktop(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 361 | pub fn xcb_ewmh_get_showing_desktop_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_property_cookie_t; 362 | 363 | pub fn xcb_ewmh_set_wm_name(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, strings_len: u32, strings: *const c_char) -> xcb_void_cookie_t; 364 | pub fn xcb_ewmh_set_wm_name_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, strings_len: u32, strings: *const c_char) -> xcb_void_cookie_t; 365 | pub fn xcb_ewmh_get_wm_name(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 366 | pub fn xcb_ewmh_get_wm_name_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 367 | 368 | pub fn xcb_ewmh_set_wm_visible_name(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, strings_len: u32, strings: *const c_char) -> xcb_void_cookie_t; 369 | pub fn xcb_ewmh_set_wm_visible_name_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, strings_len: u32, strings: *const c_char) -> xcb_void_cookie_t; 370 | pub fn xcb_ewmh_get_wm_visible_name(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 371 | pub fn xcb_ewmh_get_wm_visible_name_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 372 | 373 | pub fn xcb_ewmh_set_wm_icon_name(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, strings_len: u32, strings: *const c_char) -> xcb_void_cookie_t; 374 | pub fn xcb_ewmh_set_wm_icon_name_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, strings_len: u32, strings: *const c_char) -> xcb_void_cookie_t; 375 | pub fn xcb_ewmh_get_wm_icon_name(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 376 | pub fn xcb_ewmh_get_wm_icon_name_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 377 | 378 | pub fn xcb_ewmh_set_wm_visible_icon_name(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, strings_len: u32, strings: *const c_char) -> xcb_void_cookie_t; 379 | pub fn xcb_ewmh_set_wm_visible_icon_name_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, strings_len: u32, strings: *const c_char) -> xcb_void_cookie_t; 380 | pub fn xcb_ewmh_get_wm_visible_icon_name(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 381 | pub fn xcb_ewmh_get_wm_visible_icon_name_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 382 | 383 | pub fn xcb_ewmh_set_wm_desktop(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, desktop: u32) -> xcb_void_cookie_t; 384 | pub fn xcb_ewmh_set_wm_desktop_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, desktop: u32) -> xcb_void_cookie_t; 385 | pub fn xcb_ewmh_request_change_wm_desktop(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, client_window: xcb_window_t, new_desktop: u32, source_indication: xcb_ewmh_client_source_type_t) -> xcb_void_cookie_t; 386 | pub fn xcb_ewmh_get_wm_desktop(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 387 | pub fn xcb_ewmh_get_wm_desktop_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 388 | 389 | pub fn xcb_ewmh_set_wm_window_type(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, list_len: u32, list: *const xcb_atom_t) -> xcb_void_cookie_t; 390 | pub fn xcb_ewmh_set_wm_window_type_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, list_len: u32, list: *const xcb_atom_t) -> xcb_void_cookie_t; 391 | pub fn xcb_ewmh_get_wm_window_type(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 392 | pub fn xcb_ewmh_get_wm_window_type_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 393 | pub fn xcb_ewmh_get_wm_window_type_from_reply(wtypes: *mut xcb_ewmh_get_atoms_reply_t, r: *const xcb_get_property_reply_t) -> u8; 394 | pub fn xcb_ewmh_get_wm_window_type_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, name: *mut xcb_ewmh_get_atoms_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 395 | 396 | pub fn xcb_ewmh_set_wm_state(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, list_len: u32, list: *const xcb_atom_t) -> xcb_void_cookie_t; 397 | pub fn xcb_ewmh_set_wm_state_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, list_len: u32, list: *const xcb_atom_t) -> xcb_void_cookie_t; 398 | pub fn xcb_ewmh_request_change_wm_state(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, client_window: xcb_window_t, action: xcb_ewmh_wm_state_action_t, first_property: xcb_atom_t, second_property: xcb_atom_t, source_indication: xcb_ewmh_client_source_type_t) -> xcb_void_cookie_t; 399 | pub fn xcb_ewmh_get_wm_state(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 400 | pub fn xcb_ewmh_get_wm_state_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 401 | pub fn xcb_ewmh_get_wm_state_from_reply(wtypes: *mut xcb_ewmh_get_atoms_reply_t, r: *const xcb_get_property_reply_t) -> u8; 402 | pub fn xcb_ewmh_get_wm_state_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, name: *mut xcb_ewmh_get_atoms_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 403 | 404 | pub fn xcb_ewmh_set_wm_allowed_actions(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, list_len: u32, list: *const xcb_atom_t) -> xcb_void_cookie_t; 405 | pub fn xcb_ewmh_set_wm_allowed_actions_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, list_len: u32, list: *const xcb_atom_t) -> xcb_void_cookie_t; 406 | pub fn xcb_ewmh_get_wm_allowed_actions(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 407 | pub fn xcb_ewmh_get_wm_allowed_actions_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 408 | pub fn xcb_ewmh_get_wm_allowed_actions_from_reply(wtypes: *mut xcb_ewmh_get_atoms_reply_t, r: *const xcb_get_property_reply_t) -> u8; 409 | pub fn xcb_ewmh_get_wm_allowed_actions_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, name: *mut xcb_ewmh_get_atoms_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 410 | 411 | pub fn xcb_ewmh_set_wm_strut(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, left: u32, right: u32, top: u32, bottom: u32) -> xcb_void_cookie_t; 412 | pub fn xcb_ewmh_set_wm_strut_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, left: u32, right: u32, top: u32, bottom: u32) -> xcb_void_cookie_t; 413 | pub fn xcb_ewmh_get_wm_strut(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 414 | pub fn xcb_ewmh_get_wm_strut_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 415 | pub fn xcb_ewmh_get_wm_strut_from_reply(struts: *mut xcb_ewmh_get_extents_reply_t, r: *const xcb_get_property_reply_t) -> u8; 416 | pub fn xcb_ewmh_get_wm_strut_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, struts: *mut xcb_ewmh_get_extents_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 417 | 418 | pub fn xcb_ewmh_set_wm_strut_partial(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, wm_strut: xcb_ewmh_wm_strut_partial_t) -> xcb_void_cookie_t; 419 | pub fn xcb_ewmh_set_wm_strut_partial_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, wm_strut: xcb_ewmh_wm_strut_partial_t) -> xcb_void_cookie_t; 420 | pub fn xcb_ewmh_get_wm_strut_partial(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 421 | pub fn xcb_ewmh_get_wm_strut_partial_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 422 | pub fn xcb_ewmh_get_wm_strut_partial_from_reply(struts: *mut xcb_ewmh_wm_strut_partial_t, r: *const xcb_get_property_reply_t) -> u8; 423 | pub fn xcb_ewmh_get_wm_strut_partial_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, struts: *mut xcb_ewmh_wm_strut_partial_t, e: *mut *mut xcb_generic_error_t) -> u8; 424 | 425 | pub fn xcb_ewmh_set_wm_icon_geometry(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, left: u32, right: u32, top: u32, bottom: u32) -> xcb_void_cookie_t; 426 | pub fn xcb_ewmh_set_wm_icon_geometry_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, left: u32, right: u32, top: u32, bottom: u32) -> xcb_void_cookie_t; 427 | pub fn xcb_ewmh_get_wm_icon_geometry(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 428 | pub fn xcb_ewmh_get_wm_icon_geometry_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 429 | pub fn xcb_ewmh_get_wm_icon_geometry_from_reply(icons: *mut xcb_ewmh_geometry_t, r: *const xcb_get_property_reply_t) -> u8; 430 | pub fn xcb_ewmh_get_wm_icon_geometry_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, icons: *mut xcb_ewmh_geometry_t, e: *mut *mut xcb_generic_error_t) -> u8; 431 | 432 | pub fn xcb_ewmh_append_wm_icon(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, width: u32, height: u32, img_len: u32, img: *const u32) -> xcb_void_cookie_t; 433 | pub fn xcb_ewmh_append_wm_icon_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, width: u32, height: u32, img_len: u32, img: *const u32) -> xcb_void_cookie_t; 434 | pub fn xcb_ewmh_get_wm_icon(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 435 | pub fn xcb_ewmh_get_wm_icon_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 436 | pub fn xcb_ewmh_get_wm_icon_from_reply(wm_icon: *mut xcb_ewmh_get_wm_icon_reply_t, r: *const xcb_get_property_reply_t) -> u8; 437 | pub fn xcb_ewmh_get_wm_icon_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, wm_icon: *mut xcb_ewmh_get_wm_icon_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 438 | pub fn xcb_ewmh_get_wm_icon_iterator(wm_icon: *const xcb_ewmh_get_wm_icon_reply_t) -> xcb_ewmh_wm_icon_iterator_t; 439 | pub fn xcb_ewmh_get_wm_icon_length(wm_icon: *const xcb_ewmh_get_wm_icon_reply_t) -> c_uint; 440 | pub fn xcb_ewmh_get_wm_icon_next(iterator: *mut xcb_ewmh_wm_icon_iterator_t); 441 | pub fn xcb_ewmh_get_wm_icon_reply_wipe(wm_icon: *mut xcb_ewmh_get_wm_icon_reply_t); 442 | 443 | pub fn xcb_ewmh_set_wm_pid(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, pid: u32) -> xcb_void_cookie_t; 444 | pub fn xcb_ewmh_set_wm_pid_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, pid: u32) -> xcb_void_cookie_t; 445 | pub fn xcb_ewmh_get_wm_pid(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 446 | pub fn xcb_ewmh_get_wm_pid_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 447 | 448 | pub fn xcb_ewmh_set_wm_handled_icons(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, handled_icons: u32) -> xcb_void_cookie_t; 449 | pub fn xcb_ewmh_set_wm_handled_icons_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, handled_icons: u32) -> xcb_void_cookie_t; 450 | pub fn xcb_ewmh_get_wm_handled_icons(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 451 | pub fn xcb_ewmh_get_wm_handled_icons_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 452 | 453 | pub fn xcb_ewmh_set_wm_user_time(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, time: u32) -> xcb_void_cookie_t; 454 | pub fn xcb_ewmh_set_wm_user_time_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, time: u32) -> xcb_void_cookie_t; 455 | pub fn xcb_ewmh_get_wm_user_time(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 456 | pub fn xcb_ewmh_get_wm_user_time_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 457 | 458 | pub fn xcb_ewmh_set_wm_user_time_window(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, time: u32) -> xcb_void_cookie_t; 459 | pub fn xcb_ewmh_set_wm_user_time_window_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, time: u32) -> xcb_void_cookie_t; 460 | pub fn xcb_ewmh_get_wm_user_time_window(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 461 | pub fn xcb_ewmh_get_wm_user_time_window_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 462 | 463 | pub fn xcb_ewmh_set_frame_extents(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, left: u32, right: u32, top: u32, bottom: u32) -> xcb_void_cookie_t; 464 | pub fn xcb_ewmh_set_frame_extents_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, left: u32, right: u32, top: u32, bottom: u32) -> xcb_void_cookie_t; 465 | pub fn xcb_ewmh_get_frame_extents(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 466 | pub fn xcb_ewmh_get_frame_extents_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 467 | pub fn xcb_ewmh_get_frame_extents_from_reply(frame_extents: *mut xcb_ewmh_get_extents_reply_t, r: *const xcb_get_property_reply_t) -> u8; 468 | pub fn xcb_ewmh_get_frame_extents_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, frame_extents: *mut xcb_ewmh_get_extents_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 469 | 470 | pub fn xcb_ewmh_set_wm_sync_request_counter(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, atom: xcb_atom_t, low: u32, high: u32) -> xcb_void_cookie_t; 471 | pub fn xcb_ewmh_set_wm_sync_request_counter_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, atom: xcb_atom_t, low: u32, high: u32) -> xcb_void_cookie_t; 472 | pub fn xcb_ewmh_send_wm_sync_rqeuest(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, wm_protocols: xcb_atom_t, wm_sync_request: xcb_atom_t, timestamp: xcb_timestamp_t, couner: u64) -> xcb_void_cookie_t; 473 | pub fn xcb_ewmh_get_wm_sync_request_counter(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 474 | pub fn xcb_ewmh_get_wm_sync_request_counter_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 475 | pub fn xcb_ewmh_get_wm_sync_request_counter_from_reply(counter: *mut u64) -> u8; 476 | pub fn xcb_ewmh_get_wm_sync_request_counter_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, counter: *mut u64, e: *mut *mut xcb_generic_error_t) -> u8; 477 | 478 | pub fn xcb_ewmh_set_wm_fullscreen_monitors(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, top: u32, bottom: u32, left: u32, right: u32) -> xcb_void_cookie_t; 479 | pub fn xcb_ewmh_set_wm_fullscreen_monitors_checked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t, top: u32, bottom: u32, left: u32, right: u32) -> xcb_void_cookie_t; 480 | pub fn xcb_ewmh_request_change_wm_fullscreen_monitors(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, window: xcb_window_t, top: u32, bottom: u32, left: u32, right: u32, source_indication: xcb_ewmh_client_source_type_t) -> xcb_void_cookie_t; 481 | pub fn xcb_ewmh_get_wm_fullscreen_monitors(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 482 | pub fn xcb_ewmh_get_wm_fullscreen_monitors_unchecked(ewmh: *mut xcb_ewmh_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 483 | pub fn xcb_ewmh_get_wm_fullscreen_monitors_from_reply(monitors: *mut xcb_ewmh_get_wm_fullscreen_monitors_reply_t, r: *const xcb_get_property_reply_t) -> u8; 484 | pub fn xcb_ewmh_get_wm_fullscreen_monitors_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, monitors: *mut xcb_ewmh_get_wm_fullscreen_monitors_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 485 | 486 | pub fn xcb_ewmh_set_wm_cm_owner(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, owner: xcb_window_t, timestamp: xcb_timestamp_t, selection_data1: u32, selection_data2: u32) -> xcb_void_cookie_t; 487 | pub fn xcb_ewmh_set_wm_cm_owner_checked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, owner: xcb_window_t, timestamp: xcb_timestamp_t, selection_data1: u32, selection_data2: u32) -> xcb_void_cookie_t; 488 | pub fn xcb_ewmh_get_wm_cm_owner(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_selection_owner_cookie_t; 489 | pub fn xcb_ewmh_get_wm_cm_owner_unchecked(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int) -> xcb_get_selection_owner_cookie_t; 490 | pub fn xcb_ewmh_get_wm_cm_owner_from_reply(owner: *mut xcb_window_t, r: *const xcb_get_selection_owner_cookie_t) -> u8; 491 | pub fn xcb_ewmh_get_wm_cm_owner_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_selection_owner_cookie_t, owner: *mut xcb_window_t, e: *mut *mut xcb_generic_error_t) -> u8; 492 | } 493 | 494 | #[inline(always)] 495 | pub unsafe extern "C" fn xcb_ewmh_connection_wipe(ewmh: *mut xcb_ewmh_connection_t) { 496 | free((*ewmh).screens as *mut _); 497 | free((*ewmh)._NET_WM_CM_Sn as *mut _); 498 | } 499 | 500 | #[inline(always)] 501 | pub unsafe extern "C" fn xcb_ewmh_get_supported_from_reply(supported: *mut xcb_ewmh_get_atoms_reply_t, r: *const xcb_get_property_reply_t) -> u8 { 502 | xcb_ewmh_get_atoms_from_reply(supported, r) 503 | } 504 | 505 | #[inline(always)] 506 | pub unsafe extern "C" fn xcb_ewmh_get_supported_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, supported: *mut xcb_ewmh_get_atoms_reply_t, e: *mut *mut xcb_generic_error_t) -> u8 { 507 | xcb_ewmh_get_atoms_reply(ewmh, cookie, supported, e) 508 | } 509 | 510 | #[inline(always)] 511 | pub unsafe extern "C" fn xcb_ewmh_get_client_list_from_reply(clients: *mut xcb_ewmh_get_windows_reply_t, r: *const xcb_get_property_reply_t) -> u8 { 512 | xcb_ewmh_get_windows_from_reply(clients, r) 513 | } 514 | 515 | #[inline(always)] 516 | pub unsafe extern "C" fn xcb_ewmh_get_client_list_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, clients: *mut xcb_ewmh_get_windows_reply_t, e: *mut *mut xcb_generic_error_t) -> u8 { 517 | xcb_ewmh_get_windows_reply(ewmh, cookie, clients, e) 518 | } 519 | 520 | #[inline(always)] 521 | pub unsafe extern "C" fn xcb_ewmh_get_client_list_stacking_from_reply(clients: *mut xcb_ewmh_get_windows_reply_t, r: *const xcb_get_property_reply_t) -> u8 { 522 | xcb_ewmh_get_windows_from_reply(clients, r) 523 | } 524 | 525 | #[inline(always)] 526 | pub unsafe extern "C" fn xcb_ewmh_get_client_list_stacking_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, clients: *mut xcb_ewmh_get_windows_reply_t, e: *mut *mut xcb_generic_error_t) -> u8 { 527 | xcb_ewmh_get_windows_reply(ewmh, cookie, clients, e) 528 | } 529 | 530 | #[inline(always)] 531 | pub unsafe extern "C" fn xcb_ewmh_get_number_of_desktops_from_reply(number_of_desktops: *mut u32, r: *const xcb_get_property_reply_t) -> u8 { 532 | xcb_ewmh_get_cardinal_from_reply(number_of_desktops, r) 533 | } 534 | 535 | #[inline(always)] 536 | pub unsafe extern "C" fn xcb_ewmh_get_number_of_desktops_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, number_of_desktops: *mut u32, e: *mut *mut xcb_generic_error_t) -> u8 { 537 | xcb_ewmh_get_cardinal_reply(ewmh, cookie, number_of_desktops, e) 538 | } 539 | 540 | #[inline(always)] 541 | pub unsafe extern "C" fn xcb_ewmh_get_current_desktop_from_reply(current_desktop: *mut u32, r: *const xcb_get_property_reply_t) -> u8 { 542 | xcb_ewmh_get_cardinal_from_reply(current_desktop, r) 543 | } 544 | 545 | #[inline(always)] 546 | pub unsafe extern "C" fn xcb_ewmh_get_current_desktop_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, current_desktop: *mut u32, e: *mut *mut xcb_generic_error_t) -> u8 { 547 | xcb_ewmh_get_cardinal_reply(ewmh, cookie, current_desktop, e) 548 | } 549 | 550 | #[inline(always)] 551 | pub unsafe extern "C" fn xcb_ewmh_get_desktop_names_from_reply(ewmh: *mut xcb_ewmh_connection_t, names: *mut xcb_ewmh_get_utf8_strings_reply_t, r: *const xcb_get_property_reply_t) -> u8 { 552 | xcb_ewmh_get_utf8_strings_from_reply(ewmh, names, r) 553 | } 554 | 555 | #[inline(always)] 556 | pub unsafe extern "C" fn xcb_ewmh_get_desktop_names_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, names: *mut xcb_ewmh_get_utf8_strings_reply_t, e: *mut *mut xcb_generic_error_t) -> u8 { 557 | xcb_ewmh_get_utf8_strings_reply(ewmh, cookie, names, e) 558 | } 559 | 560 | #[inline(always)] 561 | pub unsafe extern "C" fn xcb_ewmh_get_active_window_from_reply(active_window: *mut xcb_window_t, r: *const xcb_get_property_reply_t) -> u8 { 562 | xcb_ewmh_get_window_from_reply(active_window, r) 563 | } 564 | 565 | #[inline(always)] 566 | pub unsafe extern "C" fn xcb_ewmh_get_active_window_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, active_window: *mut xcb_window_t, e: *mut *mut xcb_generic_error_t) -> u8 { 567 | xcb_ewmh_get_window_reply(ewmh, cookie, active_window, e) 568 | } 569 | 570 | #[inline(always)] 571 | pub unsafe extern "C" fn xcb_ewmh_get_supporting_wm_check_from_reply(window: *mut xcb_window_t, r: *const xcb_get_property_reply_t) -> u8 { 572 | xcb_ewmh_get_window_from_reply(window, r) 573 | } 574 | 575 | #[inline(always)] 576 | pub unsafe extern "C" fn xcb_ewmh_get_supporting_wm_check_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, window: *mut xcb_window_t, e: *mut *mut xcb_generic_error_t) -> u8 { 577 | xcb_ewmh_get_window_reply(ewmh, cookie, window, e) 578 | } 579 | 580 | #[inline(always)] 581 | pub unsafe extern "C" fn xcb_ewmh_get_virtual_roots_from_reply(virtual_roots: *mut xcb_ewmh_get_windows_reply_t, r: *const xcb_get_property_reply_t) -> u8 { 582 | xcb_ewmh_get_windows_from_reply(virtual_roots, r) 583 | } 584 | 585 | #[inline(always)] 586 | pub unsafe extern "C" fn xcb_ewmh_get_virtual_roots_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, virtual_roots: *mut xcb_ewmh_get_windows_reply_t, e: *mut *mut xcb_generic_error_t) -> u8 { 587 | xcb_ewmh_get_windows_reply(ewmh, cookie, virtual_roots, e) 588 | } 589 | 590 | #[inline(always)] 591 | pub unsafe extern "C" fn xcb_ewmh_get_showing_desktop_from_reply(desktop: *mut u32, r: *const xcb_get_property_reply_t) -> u8 { 592 | xcb_ewmh_get_cardinal_from_reply(desktop, r) 593 | } 594 | 595 | #[inline(always)] 596 | pub unsafe extern "C" fn xcb_ewmh_get_showing_desktop_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, desktop: *mut u32, e: *mut *mut xcb_generic_error_t) -> u8 { 597 | xcb_ewmh_get_cardinal_reply(ewmh, cookie, desktop, e) 598 | } 599 | 600 | #[inline(always)] 601 | pub unsafe extern "C" fn xcb_ewmh_request_change_showing_desktop(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, enter: u32) -> xcb_void_cookie_t { 602 | xcb_ewmh_send_client_message((*ewmh).connection, XCB_NONE, (**(*ewmh).screens.offset(screen_nbr as isize)).root, 603 | (*ewmh)._NET_SHOWING_DESKTOP, mem::size_of_val(&enter) as u32, &enter) 604 | } 605 | 606 | #[inline(always)] 607 | pub unsafe extern "C" fn xcb_ewmh_request_frame_extents(ewmh: *mut xcb_ewmh_connection_t, screen_nbr: c_int, client_window: xcb_window_t) -> xcb_void_cookie_t { 608 | xcb_ewmh_send_client_message((*ewmh).connection, client_window, (**(*ewmh).screens.offset(screen_nbr as isize)).root, 609 | (*ewmh)._NET_REQUEST_FRAME_EXTENTS, 0, ptr::null()) 610 | } 611 | 612 | #[inline(always)] 613 | pub unsafe extern "C" fn xcb_ewmh_get_wm_name_from_reply(ewmh: *mut xcb_ewmh_connection_t, data: *mut xcb_ewmh_get_utf8_strings_reply_t, r: *const xcb_get_property_reply_t) -> u8 { 614 | xcb_ewmh_get_utf8_strings_from_reply(ewmh, data, r) 615 | } 616 | 617 | #[inline(always)] 618 | pub unsafe extern "C" fn xcb_ewmh_get_wm_name_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, data: *mut xcb_ewmh_get_utf8_strings_reply_t, e: *mut *mut xcb_generic_error_t) -> u8 { 619 | xcb_ewmh_get_utf8_strings_reply(ewmh, cookie, data, e) 620 | } 621 | 622 | #[inline(always)] 623 | pub unsafe extern "C" fn xcb_ewmh_get_wm_visible_name_from_reply(ewmh: *mut xcb_ewmh_connection_t, data: *mut xcb_ewmh_get_utf8_strings_reply_t, r: *const xcb_get_property_reply_t) -> u8 { 624 | xcb_ewmh_get_utf8_strings_from_reply(ewmh, data, r) 625 | } 626 | 627 | #[inline(always)] 628 | pub unsafe extern "C" fn xcb_ewmh_get_wm_visible_name_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, data: *mut xcb_ewmh_get_utf8_strings_reply_t, e: *mut *mut xcb_generic_error_t) -> u8 { 629 | xcb_ewmh_get_utf8_strings_reply(ewmh, cookie, data, e) 630 | } 631 | 632 | #[inline(always)] 633 | pub unsafe extern "C" fn xcb_ewmh_get_wm_icon_name_from_reply(ewmh: *mut xcb_ewmh_connection_t, data: *mut xcb_ewmh_get_utf8_strings_reply_t, r: *const xcb_get_property_reply_t) -> u8 { 634 | xcb_ewmh_get_utf8_strings_from_reply(ewmh, data, r) 635 | } 636 | 637 | #[inline(always)] 638 | pub unsafe extern "C" fn xcb_ewmh_get_wm_icon_name_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, data: *mut xcb_ewmh_get_utf8_strings_reply_t, e: *mut *mut xcb_generic_error_t) -> u8 { 639 | xcb_ewmh_get_utf8_strings_reply(ewmh, cookie, data, e) 640 | } 641 | 642 | #[inline(always)] 643 | pub unsafe extern "C" fn xcb_ewmh_get_wm_visible_icon_name_from_reply(ewmh: *mut xcb_ewmh_connection_t, data: *mut xcb_ewmh_get_utf8_strings_reply_t, r: *const xcb_get_property_reply_t) -> u8 { 644 | xcb_ewmh_get_utf8_strings_from_reply(ewmh, data, r) 645 | } 646 | 647 | #[inline(always)] 648 | pub unsafe extern "C" fn xcb_ewmh_get_wm_visible_icon_name_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, data: *mut xcb_ewmh_get_utf8_strings_reply_t, e: *mut *mut xcb_generic_error_t) -> u8 { 649 | xcb_ewmh_get_utf8_strings_reply(ewmh, cookie, data, e) 650 | } 651 | 652 | #[inline(always)] 653 | pub unsafe extern "C" fn xcb_ewmh_get_wm_desktop_from_reply(desktop: *mut u32, r: *const xcb_get_property_reply_t) -> u8 { 654 | xcb_ewmh_get_cardinal_from_reply(desktop, r) 655 | } 656 | 657 | #[inline(always)] 658 | pub unsafe extern "C" fn xcb_ewmh_get_wm_desktop_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, desktop: *mut u32, e: *mut *mut xcb_generic_error_t) -> u8 { 659 | xcb_ewmh_get_cardinal_reply(ewmh, cookie, desktop, e) 660 | } 661 | 662 | #[inline(always)] 663 | pub unsafe extern "C" fn xcb_ewmh_set_wm_icon(ewmh: *mut xcb_ewmh_connection_t, mode: u8, window: xcb_window_t, data_len: u32, data: *const u32) -> xcb_void_cookie_t { 664 | xcb_change_property((*ewmh).connection, mode, window, (*ewmh)._NET_WM_ICON, XCB_ATOM_CARDINAL, 32, data_len, data as *const _) 665 | } 666 | 667 | #[inline(always)] 668 | pub unsafe extern "C" fn xcb_ewmh_set_wm_icon_checked(ewmh: *mut xcb_ewmh_connection_t, mode: u8, window: xcb_window_t, data_len: u32, data: *const u32) -> xcb_void_cookie_t { 669 | xcb_change_property_checked((*ewmh).connection, mode, window, (*ewmh)._NET_WM_ICON, XCB_ATOM_CARDINAL, 32, data_len, data as *const _) 670 | } 671 | 672 | #[inline(always)] 673 | pub unsafe extern "C" fn xcb_ewmh_get_wm_pid_from_reply(pid: *mut u32, r: *const xcb_get_property_reply_t) -> u8 { 674 | xcb_ewmh_get_cardinal_from_reply(pid, r) 675 | } 676 | 677 | #[inline(always)] 678 | pub unsafe extern "C" fn xcb_ewmh_get_wm_pid_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, pid: *mut u32, e: *mut *mut xcb_generic_error_t) -> u8 { 679 | xcb_ewmh_get_cardinal_reply(ewmh, cookie, pid, e) 680 | } 681 | 682 | #[inline(always)] 683 | pub unsafe extern "C" fn xcb_ewmh_get_wm_handled_icons_from_reply(handled_icons: *mut u32, r: *const xcb_get_property_reply_t) -> u8 { 684 | xcb_ewmh_get_cardinal_from_reply(handled_icons, r) 685 | } 686 | 687 | #[inline(always)] 688 | pub unsafe extern "C" fn xcb_ewmh_get_wm_handled_icons_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, handled_icons: *mut u32, e: *mut *mut xcb_generic_error_t) -> u8 { 689 | xcb_ewmh_get_cardinal_reply(ewmh, cookie, handled_icons, e) 690 | } 691 | 692 | #[inline(always)] 693 | pub unsafe extern "C" fn xcb_ewmh_get_wm_user_time_from_reply(time: *mut u32, r: *const xcb_get_property_reply_t) -> u8 { 694 | xcb_ewmh_get_cardinal_from_reply(time, r) 695 | } 696 | 697 | #[inline(always)] 698 | pub unsafe extern "C" fn xcb_ewmh_get_wm_user_time_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, time: *mut u32, e: *mut *mut xcb_generic_error_t) -> u8 { 699 | xcb_ewmh_get_cardinal_reply(ewmh, cookie, time, e) 700 | } 701 | 702 | #[inline(always)] 703 | pub unsafe extern "C" fn xcb_ewmh_get_wm_user_time_window_from_reply(time: *mut u32, r: *const xcb_get_property_reply_t) -> u8 { 704 | xcb_ewmh_get_cardinal_from_reply(time, r) 705 | } 706 | 707 | #[inline(always)] 708 | pub unsafe extern "C" fn xcb_ewmh_get_wm_user_time_window_reply(ewmh: *mut xcb_ewmh_connection_t, cookie: xcb_get_property_cookie_t, time: *mut u32, e: *mut *mut xcb_generic_error_t) -> u8 { 709 | xcb_ewmh_get_cardinal_reply(ewmh, cookie, time, e) 710 | } 711 | -------------------------------------------------------------------------------- /src/ffi/icccm.rs: -------------------------------------------------------------------------------- 1 | use xcb::ffi::*; 2 | use libc::{c_char, c_int}; 3 | 4 | #[repr(C)] 5 | pub struct xcb_icccm_get_text_property_reply_t { 6 | _reply: *mut xcb_get_property_reply_t, 7 | 8 | pub encoding: xcb_atom_t, 9 | pub name_len: u32, 10 | pub name: *mut c_char, 11 | pub format: u8, 12 | } 13 | 14 | #[repr(C)] 15 | pub struct xcb_icccm_get_wm_colormap_windows_reply_t { 16 | pub windows_len: u32, 17 | pub windows: *mut xcb_window_t, 18 | 19 | _reply: *mut xcb_get_property_reply_t, 20 | } 21 | 22 | #[repr(C)] 23 | pub struct xcb_icccm_get_wm_class_reply_t { 24 | pub instance_name: *mut c_char, 25 | pub class_name: *mut c_char, 26 | 27 | _reply: *mut xcb_get_property_reply_t, 28 | } 29 | 30 | pub type xcb_icccm_size_hints_flags_t = u32; 31 | pub const XCB_ICCCM_SIZE_HINT_US_SIZE: xcb_icccm_size_hints_flags_t = 1 << 1; 32 | pub const XCB_ICCCM_SIZE_HINT_P_POSITION: xcb_icccm_size_hints_flags_t = 1 << 2; 33 | pub const XCB_ICCCM_SIZE_HINT_P_SIZE: xcb_icccm_size_hints_flags_t = 1 << 3; 34 | pub const XCB_ICCCM_SIZE_HINT_P_MIN_SIZE: xcb_icccm_size_hints_flags_t = 1 << 4; 35 | pub const XCB_ICCCM_SIZE_HINT_P_MAX_SIZE: xcb_icccm_size_hints_flags_t = 1 << 5; 36 | pub const XCB_ICCCM_SIZE_HINT_P_RESIZE_INC: xcb_icccm_size_hints_flags_t = 1 << 6; 37 | pub const XCB_ICCCM_SIZE_HINT_P_ASPECT: xcb_icccm_size_hints_flags_t = 1 << 7; 38 | pub const XCB_ICCCM_SIZE_HINT_BASE_SIZE: xcb_icccm_size_hints_flags_t = 1 << 8; 39 | pub const XCB_ICCCM_SIZE_HINT_P_WIN_GRAVITY: xcb_icccm_size_hints_flags_t = 1 << 9; 40 | 41 | #[repr(C)] 42 | pub struct xcb_size_hints_t { 43 | pub flags: u32, 44 | pub x: i32, 45 | pub y: i32, 46 | pub width: i32, 47 | pub height: i32, 48 | pub min_width: i32, 49 | pub min_height: i32, 50 | pub max_width: i32, 51 | pub max_height: i32, 52 | pub width_inc: i32, 53 | pub height_inc: i32, 54 | pub min_aspect_num: i32, 55 | pub min_aspect_den: i32, 56 | pub max_aspect_num: i32, 57 | pub max_aspect_den: i32, 58 | pub base_width: i32, 59 | pub base_height: i32, 60 | pub win_gravity: u32, 61 | } 62 | 63 | pub const XCB_ICCCM_NUM_WM_SIZE_HINTS_ELEMENTS: u32 = 18; 64 | 65 | #[repr(C)] 66 | pub struct xcb_icccm_wm_hints_t { 67 | pub flags: i32, 68 | pub input: u32, 69 | pub initial_state: i32, 70 | pub icon_pixmap: xcb_pixmap_t, 71 | pub icon_window: xcb_window_t, 72 | pub icon_x: i32, 73 | pub icon_y: i32, 74 | pub icon_mask: xcb_pixmap_t, 75 | pub window_group: xcb_window_t, 76 | } 77 | 78 | pub const XCB_ICCCM_NUM_WM_HINTS_ELEMENTS: u32 = 9; 79 | 80 | pub type xcb_icccm_wm_state_t = i32; 81 | pub const XCB_ICCCM_WM_STATE_WITHDRAWN: xcb_icccm_wm_state_t = 0; 82 | pub const XCB_ICCCM_WM_STATE_NORMAL: xcb_icccm_wm_state_t = 1; 83 | pub const XCB_ICCCM_WM_STATE_ICONIC: xcb_icccm_wm_state_t = 3; 84 | 85 | pub type xcb_icccm_wm_t = i32; 86 | pub const XCB_ICCCM_WM_HINT_INPUT: xcb_icccm_wm_t = 1 << 0; 87 | pub const XCB_ICCCM_WM_HINT_STATE: xcb_icccm_wm_t = 1 << 1; 88 | pub const XCB_ICCCM_WM_HINT_ICON_PIXMAP: xcb_icccm_wm_t = 1 << 2; 89 | pub const XCB_ICCCM_WM_HINT_ICON_WINDOW: xcb_icccm_wm_t = 1 << 3; 90 | pub const XCB_ICCCM_WM_HINT_ICON_POSITION: xcb_icccm_wm_t = 1 << 4; 91 | pub const XCB_ICCCM_WM_HINT_ICON_MASK: xcb_icccm_wm_t = 1 << 5; 92 | pub const XCB_ICCCM_WM_HINT_WINDOW_GROUP: xcb_icccm_wm_t = 1 << 6; 93 | pub const XCB_ICCCM_WM_HINT_X_URGENCY: xcb_icccm_wm_t = 1 << 8; 94 | pub const XCB_ICCCM_WM_ALL_HINTS: xcb_icccm_wm_t = 95 | XCB_ICCCM_WM_HINT_INPUT | XCB_ICCCM_WM_HINT_STATE | 96 | XCB_ICCCM_WM_HINT_ICON_PIXMAP | XCB_ICCCM_WM_HINT_ICON_WINDOW | 97 | XCB_ICCCM_WM_HINT_ICON_POSITION | XCB_ICCCM_WM_HINT_ICON_MASK | 98 | XCB_ICCCM_WM_HINT_WINDOW_GROUP; 99 | 100 | #[repr(C)] 101 | pub struct xcb_icccm_get_wm_protocols_reply_t { 102 | pub atoms_len: u32, 103 | pub atoms: *mut xcb_atom_t, 104 | 105 | _reply: *mut xcb_get_property_reply_t, 106 | } 107 | 108 | #[cfg_attr(feature = "static", link(name = "xcb-icccm", kind = "static"))] 109 | #[cfg_attr(not(feature = "static"), link(name = "xcb-icccm"))] 110 | extern "C" { 111 | pub fn xcb_icccm_get_text_property(c: *mut xcb_connection_t, window: xcb_window_t, property: xcb_atom_t) -> xcb_get_property_cookie_t; 112 | pub fn xcb_icccm_get_text_property_unchecked(c: *mut xcb_connection_t, window: xcb_window_t, property: xcb_atom_t) -> xcb_get_property_cookie_t; 113 | pub fn xcb_icccm_get_text_property_reply(c: *mut xcb_connection_t, cookie: xcb_get_property_cookie_t, prop: *mut xcb_icccm_get_text_property_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 114 | pub fn xcb_icccm_get_text_property_reply_wipe(prop: *mut xcb_icccm_get_text_property_reply_t); 115 | 116 | pub fn xcb_icccm_set_wm_name_checked(c: *mut xcb_connection_t, window: xcb_window_t, encoding: xcb_atom_t, format: u8, name_len: u32, name: *const c_char) -> xcb_void_cookie_t; 117 | pub fn xcb_icccm_set_wm_name(c: *mut xcb_connection_t, window: xcb_window_t, encoding: xcb_atom_t, format: u8, name_len: u32, name: *const c_char) -> xcb_void_cookie_t; 118 | pub fn xcb_icccm_get_wm_name(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 119 | pub fn xcb_icccm_get_wm_name_reply(c: *mut xcb_connection_t, cookie: xcb_get_property_cookie_t, prop: *mut xcb_icccm_get_text_property_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 120 | 121 | pub fn xcb_icccm_set_wm_icon_name_checked(c: *mut xcb_connection_t, window: xcb_window_t, encoding: xcb_atom_t, format: u8, name_len: u32, name: *const c_char) -> xcb_void_cookie_t; 122 | pub fn xcb_icccm_set_wm_icon_name(c: *mut xcb_connection_t, window: xcb_window_t, encoding: xcb_atom_t, format: u8, name_len: u32, name: *const c_char) -> xcb_void_cookie_t; 123 | pub fn xcb_icccm_get_wm_icon_name(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 124 | pub fn xcb_icccm_get_wm_icon_name_unchecked(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 125 | pub fn xcb_icccm_get_wm_icon_name_reply(c: *mut xcb_connection_t, cookie: xcb_get_property_cookie_t, prop: *mut xcb_icccm_get_text_property_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 126 | 127 | pub fn xcb_icccm_set_wm_colormap_windows_checked(c: *mut xcb_connection_t, window: xcb_window_t, wm_colormap_windows_atom: xcb_atom_t, list_len: u32, list: *const xcb_window_t) -> xcb_void_cookie_t; 128 | pub fn xcb_icccm_set_wm_colormap_windows(c: *mut xcb_connection_t, window: xcb_window_t, wm_colormap_windows_atom: xcb_atom_t, list_len: u32, list: *const xcb_window_t) -> xcb_void_cookie_t; 129 | pub fn xcb_icccm_get_wm_colormap_windows(c: *mut xcb_connection_t, window: xcb_window_t, wm_colormap_windows_atom: xcb_atom_t) -> xcb_get_property_cookie_t; 130 | pub fn xcb_icccm_get_wm_colormap_windows_unchecked(c: *mut xcb_connection_t, window: xcb_window_t, wm_colormap_windows_atom: xcb_atom_t) -> xcb_get_property_cookie_t; 131 | pub fn xcb_icccm_get_wm_colormap_windows_from_reply(reply: *mut xcb_get_property_reply_t, colormap_windows: *mut xcb_icccm_get_wm_colormap_windows_reply_t) -> u8; 132 | pub fn xcb_icccm_get_wm_colormap_windows_reply(c: *mut xcb_connection_t, cookie: xcb_get_property_cookie_t, windows: *mut xcb_icccm_get_wm_colormap_windows_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 133 | pub fn xcb_icccm_get_wm_colormap_windows_reply_wipe(windows: *mut xcb_icccm_get_wm_colormap_windows_reply_t); 134 | 135 | pub fn xcb_icccm_set_wm_client_machine_checked(c: *mut xcb_connection_t, window: xcb_window_t, encoding: xcb_atom_t, format: u8, name_len: u32, name: *const c_char) -> xcb_void_cookie_t; 136 | pub fn xcb_icccm_set_wm_client_machine(c: *mut xcb_connection_t, window: xcb_window_t, encoding: xcb_atom_t, format: u8, name_len: u32, name: *const c_char) -> xcb_void_cookie_t; 137 | pub fn xcb_icccm_get_wm_client_machine(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 138 | pub fn xcb_icccm_get_wm_client_machine_unchecked(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 139 | pub fn xcb_icccm_get_wm_client_machine_reply(c: *mut xcb_connection_t, cookie: xcb_get_property_cookie_t, prop: *mut xcb_icccm_get_text_property_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 140 | 141 | pub fn xcb_icccm_set_wm_class_checked(c: *mut xcb_connection_t, window: xcb_window_t, class_len: u32, class_name: *const c_char) -> xcb_void_cookie_t; 142 | pub fn xcb_icccm_set_wm_class(c: *mut xcb_connection_t, window: xcb_window_t, class_len: u32, class_name: *const c_char) -> xcb_void_cookie_t; 143 | pub fn xcb_icccm_get_wm_class(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 144 | pub fn xcb_icccm_get_wm_class_unchecked(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 145 | pub fn xcb_icccm_get_wm_class_from_reply(prop: *mut xcb_icccm_get_wm_class_reply_t, reply: *mut xcb_get_property_reply_t) -> u8; 146 | pub fn xcb_icccm_get_wm_class_reply(c: *mut xcb_connection_t, cookie: xcb_get_property_cookie_t, prop: *mut xcb_icccm_get_wm_class_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 147 | pub fn xcb_icccm_get_wm_class_reply_wipe(prop: *mut xcb_icccm_get_wm_class_reply_t); 148 | 149 | pub fn xcb_icccm_set_wm_transient_for_checked(c: *mut xcb_connection_t, window: xcb_window_t, transient_for_window: xcb_window_t) -> xcb_void_cookie_t; 150 | pub fn xcb_icccm_set_wm_transient_for(c: *mut xcb_connection_t, window: xcb_window_t, transient_for_window: xcb_window_t) -> xcb_void_cookie_t; 151 | pub fn xcb_icccm_get_wm_transient_for(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 152 | pub fn xcb_icccm_get_wm_transient_for_unchecked(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 153 | pub fn xcb_icccm_get_wm_transient_for_from_reply(prop: *mut xcb_window_t, reply: *mut xcb_get_property_reply_t) -> u8; 154 | pub fn xcb_icccm_get_wm_transient_for_reply(c: *mut xcb_connection_t, cookie: xcb_get_property_reply_t, prop: *mut xcb_window_t, e: *mut *mut xcb_generic_error_t) -> u8; 155 | 156 | pub fn xcb_icccm_size_hints_set_position(hints: *mut xcb_size_hints_t, user_specified: c_int, x: i32, y: i32); 157 | pub fn xcb_icccm_size_hints_set_size(hints: *mut xcb_size_hints_t, user_specified: c_int, width: i32, height: i32); 158 | pub fn xcb_icccm_size_hints_set_min_size(hints: *mut xcb_size_hints_t, min_width: i32, min_height: i32); 159 | pub fn xcb_icccm_size_hints_set_max_size(hints: *mut xcb_size_hints_t, max_width: i32, max_height: i32); 160 | pub fn xcb_icccm_size_hints_set_resize_inc(hints: *mut xcb_size_hints_t, width_inc: i32, height_inc: i32); 161 | pub fn xcb_icccm_size_hints_set_aspect(hints: *mut xcb_size_hints_t, min_aspect_num: i32, min_aspect_den: i32, max_aspect_num: i32, min_aspect_den: i32); 162 | pub fn xcb_icccm_size_hints_set_base_size(hints: *mut xcb_size_hints_t, base_width: i32, base_height: i32); 163 | pub fn xcb_icccm_size_hints_set_win_gravity(hints: *mut xcb_size_hints_t, win_gravity: xcb_gravity_t); 164 | 165 | pub fn xcb_icccm_set_wm_size_hints_checked(c: *mut xcb_connection_t, window: xcb_window_t, property: xcb_atom_t, hints: *const xcb_size_hints_t) -> xcb_void_cookie_t; 166 | pub fn xcb_icccm_set_wm_size_hints(c: *mut xcb_connection_t, window: xcb_window_t, property: xcb_atom_t, hints: *const xcb_size_hints_t) -> xcb_void_cookie_t; 167 | pub fn xcb_icccm_get_wm_size_hints(c: *mut xcb_connection_t, window: xcb_window_t, property: xcb_atom_t) -> xcb_get_property_cookie_t; 168 | pub fn xcb_icccm_get_wm_size_hints_unchecked(c: *mut xcb_connection_t, window: xcb_window_t, property: xcb_atom_t) -> xcb_get_property_cookie_t; 169 | pub fn xcb_icccm_get_wm_size_hints_reply(c: *mut xcb_connection_t, cookie: xcb_get_property_cookie_t, hints: *mut xcb_size_hints_t, e: *mut *mut xcb_generic_error_t) -> u8; 170 | pub fn xcb_icccm_get_wm_size_hints_from_reply(hints: *mut xcb_size_hints_t, reply: *mut xcb_get_property_reply_t) -> u8; 171 | 172 | pub fn xcb_icccm_set_wm_normal_hints_checked(c: *mut xcb_connection_t, window: xcb_window_t, hints: *const xcb_size_hints_t) -> xcb_void_cookie_t; 173 | pub fn xcb_icccm_set_wm_normal_hints(c: *mut xcb_connection_t, window: xcb_window_t, hints: *const xcb_size_hints_t) -> xcb_void_cookie_t; 174 | pub fn xcb_icccm_get_wm_normal_hints(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 175 | pub fn xcb_icccm_get_wm_normal_hints_unchecked(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 176 | pub fn xcb_icccm_get_wm_normal_hints_reply(c: *mut xcb_connection_t, cookie: xcb_get_property_cookie_t, hints: *mut xcb_size_hints_t, e: *mut *mut xcb_generic_error_t) -> u8; 177 | 178 | pub fn xcb_icccm_wm_hints_get_urgency(hints: *const xcb_icccm_wm_hints_t) -> u32; 179 | pub fn xcb_icccm_wm_hints_set_input(hints: *mut xcb_icccm_wm_hints_t, input: u8); 180 | pub fn xcb_icccm_wm_hints_set_iconic(hints: *mut xcb_icccm_wm_hints_t); 181 | pub fn xcb_icccm_wm_hints_set_normal(hints: *mut xcb_icccm_wm_hints_t); 182 | pub fn xcb_icccm_wm_hints_set_withdrawn(hints: *mut xcb_icccm_wm_hints_t); 183 | pub fn xcb_icccm_wm_hints_set_none(hints: *mut xcb_icccm_wm_hints_t); 184 | pub fn xcb_icccm_wm_hints_set_icon_pixmap(hints: *mut xcb_icccm_wm_hints_t, icon_pixmap: xcb_pixmap_t); 185 | pub fn xcb_icccm_wm_hints_set_icon_mask(hints: *mut xcb_icccm_wm_hints_t, icon_mask: xcb_pixmap_t); 186 | pub fn xcb_icccm_wm_hints_set_icon_window(hints: *mut xcb_icccm_wm_hints_t, icon_window: xcb_window_t); 187 | pub fn xcb_icccm_wm_hints_set_window_group(hints: *mut xcb_icccm_wm_hints_t, window_group: xcb_window_t); 188 | pub fn xcb_icccm_wm_hints_set_urgency(hints: *mut xcb_icccm_wm_hints_t); 189 | 190 | pub fn xcb_icccm_set_wm_hints_checked(c: *mut xcb_connection_t, window: xcb_window_t, hints: *const xcb_icccm_wm_hints_t) -> xcb_void_cookie_t; 191 | pub fn xcb_icccm_set_wm_hints(c: *mut xcb_connection_t, window: xcb_window_t, hints: *const xcb_icccm_wm_hints_t) -> xcb_void_cookie_t; 192 | pub fn xcb_icccm_get_wm_hints(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 193 | pub fn xcb_icccm_get_wm_hints_unchecked(c: *mut xcb_connection_t, window: xcb_window_t) -> xcb_get_property_cookie_t; 194 | pub fn xcb_icccm_get_wm_hints_from_reply(hints: *mut xcb_icccm_wm_hints_t, reply: *mut xcb_get_property_reply_t) -> u8; 195 | pub fn xcb_icccm_get_wm_hints_reply(c: *mut xcb_connection_t, cookie: xcb_get_property_cookie_t, hints: *mut xcb_icccm_wm_hints_t, e: *mut *mut xcb_generic_error_t) -> u8; 196 | 197 | pub fn xcb_icccm_set_wm_protocols_checked(c: *mut xcb_connection_t, window: xcb_window_t, wm_protocols: xcb_atom_t, list_len: u32, list: *const xcb_atom_t) -> xcb_void_cookie_t; 198 | pub fn xcb_icccm_set_wm_protocols(c: *mut xcb_connection_t, window: xcb_window_t, wm_protocols: xcb_atom_t, list_len: u32, list: *const xcb_atom_t) -> xcb_void_cookie_t; 199 | pub fn xcb_icccm_get_wm_protocols(c: *mut xcb_connection_t, window: xcb_window_t, wm_protocol_atom: xcb_atom_t) -> xcb_get_property_cookie_t; 200 | pub fn xcb_icccm_get_wm_protocols_unchecked(c: *mut xcb_connection_t, window: xcb_window_t, wm_protocol_atom: xcb_atom_t) -> xcb_get_property_cookie_t; 201 | pub fn xcb_icccm_get_wm_protocols_from_reply(reply: *mut xcb_get_property_reply_t, protocols: *mut xcb_icccm_get_wm_protocols_reply_t) -> u8; 202 | pub fn xcb_icccm_get_wm_protocols_reply(c: *mut xcb_connection_t, cookie: xcb_get_property_cookie_t, protocols: *mut xcb_icccm_get_wm_protocols_reply_t, e: *mut *mut xcb_generic_error_t) -> u8; 203 | pub fn xcb_icccm_get_wm_protocols_reply_wipe(protocols: *mut xcb_icccm_get_wm_protocols_reply_t); 204 | } 205 | -------------------------------------------------------------------------------- /src/ffi/image.rs: -------------------------------------------------------------------------------- 1 | use xcb::ffi::*; 2 | use libc::{c_void, c_int}; 3 | 4 | #[repr(C)] 5 | pub struct xcb_image_t { 6 | pub width: u16, 7 | pub height: u16, 8 | pub format: xcb_image_format_t, 9 | pub scanline_pad: u8, 10 | pub depth: u8, 11 | pub bpp: u8, 12 | pub unit: u8, 13 | pub plane_mask: u32, 14 | pub byte_order: xcb_image_order_t, 15 | pub bit_order: xcb_image_order_t, 16 | pub stride: u32, 17 | pub size: u32, 18 | pub base: *mut c_void, 19 | pub data: *mut u8, 20 | } 21 | 22 | #[cfg_attr(feature = "static", link(name = "xcb-image", kind = "static"))] 23 | #[cfg_attr(not(feature = "static"), link(name = "xcb-image"))] 24 | extern "C" { 25 | pub fn xcb_image_annotate(image: *mut xcb_image_t); 26 | pub fn xcb_image_create(width: u16, height: u16, format: xcb_image_format_t, xpad: u8, depth: u8, bpp: u8, unit: u8, byte_order: xcb_image_order_t, bit_order: xcb_image_order_t, base: *mut c_void, bytes: u32, data: *mut u8) -> *mut xcb_image_t; 27 | pub fn xcb_image_create_native(c: *mut xcb_connection_t, width: u16, height: u16, format: xcb_image_format_t, depth: u8, base: *mut c_void, bytes: u32, data: *mut u8) -> *mut xcb_image_t; 28 | pub fn xcb_image_destroy(image: *mut xcb_image_t); 29 | pub fn xcb_image_get(conn: *mut xcb_connection_t, draw: xcb_drawable_t, x: i16, y: i16, width: u16, height: u16, plane_mask: u32, format: xcb_image_format_t) -> *mut xcb_image_t; 30 | pub fn xcb_image_put(conn: *mut xcb_connection_t, draw: xcb_drawable_t, gc: xcb_gcontext_t, image: *const xcb_image_t, x: i16, y: i16, left_pad: u8) -> xcb_void_cookie_t; 31 | pub fn xcb_image_native(c: *mut xcb_connection_t, image: *const xcb_image_t, convert: c_int) -> *mut xcb_image_t; 32 | pub fn xcb_image_put_pixel(image: *mut xcb_image_t, x: u32, y: u32, pixel: u32); 33 | pub fn xcb_image_get_pixel(image: *const xcb_image_t, x: u32, y: u32) -> u32; 34 | pub fn xcb_image_convert(src: *const xcb_image_t, dst: *mut xcb_image_t) -> *mut xcb_image_t; 35 | pub fn xcb_image_subimage(image: *const xcb_image_t, x: u32, y: u32, width: u32, height: u32, base: *mut c_void, bytes: u32, data: *mut u8) -> *mut xcb_image_t; 36 | pub fn xcb_image_create_from_bitmap_data(data: *mut u8, width: u32, height: u32) -> *mut xcb_image_t; 37 | pub fn xcb_create_pixmap_from_bitmap_data(display: *mut xcb_connection_t, d: xcb_drawable_t, data: *mut u8, width: u32, height: u32, depth: u32, fg: u32, bg: u32, gcp: *const xcb_gcontext_t) -> xcb_pixmap_t; 38 | } 39 | 40 | #[cfg(feature = "shm")] 41 | use xcb::ffi::shm::*; 42 | 43 | #[cfg(feature = "shm")] 44 | #[repr(C)] 45 | #[derive(Copy, Clone)] 46 | pub struct xcb_shm_segment_info_t { 47 | pub shmseg: xcb_shm_seg_t, 48 | pub shmid: u32, 49 | pub shmaddr: *mut u8, 50 | } 51 | 52 | #[cfg(feature = "shm")] 53 | #[cfg_attr(feature = "static", link(name = "xcb-image", kind = "static"))] 54 | #[cfg_attr(not(feature = "static"), link(name = "xcb-image"))] 55 | extern "C" { 56 | pub fn xcb_image_shm_put(conn: *mut xcb_connection_t, draw: xcb_drawable_t, gc: xcb_gcontext_t, image: *const xcb_image_t, shminfo: xcb_shm_segment_info_t, src_x: i16, src_y: i16, dest_x: i16, dest_y: i16, src_width: u16, src_height: u16, send_event: u8) -> *mut xcb_image_t; 57 | pub fn xcb_image_shm_get(conn: *mut xcb_connection_t, draw: xcb_drawable_t, image: *mut xcb_image_t, shminfo: xcb_shm_segment_info_t, x: i16, y: i16, plane_mask: u32) -> c_int; 58 | } 59 | -------------------------------------------------------------------------------- /src/ffi/keysyms.rs: -------------------------------------------------------------------------------- 1 | use xcb::ffi::*; 2 | use libc::c_int; 3 | 4 | pub enum xcb_key_symbols_t {} 5 | 6 | #[cfg_attr(feature = "static", link(name = "xcb-keysyms", kind = "static"))] 7 | #[cfg_attr(not(feature = "static"), link(name = "xcb-keysyms"))] 8 | extern "C" { 9 | pub fn xcb_key_symbols_alloc(c: *mut xcb_connection_t) -> *mut xcb_key_symbols_t; 10 | pub fn xcb_key_symbols_free(syms: *mut xcb_key_symbols_t); 11 | pub fn xcb_key_symbols_get_keysym(syms: *mut xcb_key_symbols_t, keycode: xcb_keycode_t, col: c_int) -> xcb_keysym_t; 12 | pub fn xcb_key_symbols_get_keycode(syms: *mut xcb_key_symbols_t, keysym: xcb_keysym_t) -> *mut xcb_keycode_t; 13 | pub fn xcb_key_press_lookup_keysym(syms: *mut xcb_key_symbols_t, event: *mut xcb_key_press_event_t, col: c_int) -> xcb_keysym_t; 14 | pub fn xcb_key_release_lookup_keysym(syms: *mut xcb_key_symbols_t, event: *mut xcb_key_release_event_t, col: c_int) -> xcb_keysym_t; 15 | 16 | pub fn xcb_refresh_keyboard_mapping(syms: *mut xcb_key_symbols_t, event: *mut xcb_mapping_notify_event_t) -> c_int; 17 | pub fn xcb_is_keypad_key(keysym: xcb_keysym_t) -> c_int; 18 | pub fn xcb_is_private_keypad_key(keysym: xcb_keysym_t) -> c_int; 19 | pub fn xcb_is_cursor_key(keysym: xcb_keysym_t) -> c_int; 20 | pub fn xcb_is_pf_key(keysym: xcb_keysym_t) -> c_int; 21 | pub fn xcb_is_function_key(keysym: xcb_keysym_t) -> c_int; 22 | pub fn xcb_is_misc_function_key(keysym: xcb_keysym_t) -> c_int; 23 | pub fn xcb_is_modifier_key(keysym: xcb_keysym_t) -> c_int; 24 | } 25 | -------------------------------------------------------------------------------- /src/ffi/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "icccm")] 2 | pub mod icccm; 3 | 4 | #[cfg(feature = "ewmh")] 5 | pub mod ewmh; 6 | 7 | #[cfg(feature = "image")] 8 | pub mod image; 9 | 10 | #[cfg(feature = "keysyms")] 11 | pub mod keysyms; 12 | 13 | #[cfg(feature = "render")] 14 | pub mod render; 15 | -------------------------------------------------------------------------------- /src/ffi/render.rs: -------------------------------------------------------------------------------- 1 | use xcb::ffi::*; 2 | use xcb::ffi::render::*; 3 | 4 | pub type xcb_pict_format_t = u32; 5 | pub const XCB_PICT_FORMAT_ID: xcb_pict_format_t = 1 << 0; 6 | pub const XCB_PICT_FORMAT_TYPE: xcb_pict_format_t = 1 << 1; 7 | pub const XCB_PICT_FORMAT_DEPTH: xcb_pict_format_t = 1 << 2; 8 | pub const XCB_PICT_FORMAT_RED: xcb_pict_format_t = 1 << 3; 9 | pub const XCB_PICT_FORMAT_RED_MASK: xcb_pict_format_t = 1 << 4; 10 | pub const XCB_PICT_FORMAT_GREEN: xcb_pict_format_t = 1 << 5; 11 | pub const XCB_PICT_FORMAT_GREEN_MASK: xcb_pict_format_t = 1 << 6; 12 | pub const XCB_PICT_FORMAT_BLUE: xcb_pict_format_t = 1 << 7; 13 | pub const XCB_PICT_FORMAT_BLUE_MASK: xcb_pict_format_t = 1 << 8; 14 | pub const XCB_PICT_FORMAT_ALPHA: xcb_pict_format_t = 1 << 9; 15 | pub const XCB_PICT_FORMAT_ALPHA_MASK: xcb_pict_format_t = 1 << 10; 16 | pub const XCB_PICT_FORMAT_COLORMAP: xcb_pict_format_t = 1 << 11; 17 | 18 | pub type xcb_pict_standard_t = u32; 19 | pub const XCB_PICT_STANDARD_ARGB_32: xcb_pict_standard_t = 0; 20 | pub const XCB_PICT_STANDARD_RGB_24: xcb_pict_standard_t = 1; 21 | pub const XCB_PICT_STANDARD_A_8: xcb_pict_standard_t = 2; 22 | pub const XCB_PICT_STANDARD_A_4: xcb_pict_standard_t = 3; 23 | pub const XCB_PICT_STANDARD_A_1: xcb_pict_standard_t = 4; 24 | 25 | #[repr(C)] 26 | pub struct xcb_render_util_composite_text_stream_t([u8; 0]); 27 | 28 | #[cfg_attr(feature = "static", link(name = "xcb-render-util", kind = "static"))] 29 | #[cfg_attr(not(feature = "static"), link(name = "xcb-render-util"))] 30 | extern "C" { 31 | pub fn xcb_render_util_find_visual_format( 32 | formats: *const xcb_render_query_pict_formats_reply_t, 33 | visual: xcb_visualid_t, 34 | ) -> *mut xcb_render_pictvisual_t; 35 | 36 | pub fn xcb_render_util_find_format( 37 | formats: *const xcb_render_query_pict_formats_reply_t, 38 | mask: u32, 39 | ptemplate: *const xcb_render_pictforminfo_t, 40 | count: i32, 41 | ) -> *mut xcb_render_pictforminfo_t; 42 | 43 | pub fn xcb_render_util_find_standard_format( 44 | formats: *const xcb_render_query_pict_formats_reply_t, 45 | format: xcb_pict_standard_t, 46 | ) -> *mut xcb_render_pictforminfo_t; 47 | 48 | pub fn xcb_render_util_query_version( 49 | c: *mut xcb_connection_t, 50 | ) -> *const xcb_render_query_version_reply_t; 51 | pub fn xcb_render_util_query_formats( 52 | c: *mut xcb_connection_t, 53 | ) -> *const xcb_render_query_pict_formats_reply_t; 54 | pub fn xcb_render_util_disconnect( 55 | c: *mut xcb_connection_t, 56 | ) -> i32; 57 | 58 | pub fn xcb_render_util_composite_text_stream( 59 | initial_glyphset: xcb_render_glyphset_t, 60 | total_glyphs: u32, 61 | total_glyphset_changes: u32, 62 | ) -> *mut xcb_render_util_composite_text_stream_t; 63 | 64 | pub fn xcb_render_util_glyphs_8( 65 | stream: *mut xcb_render_util_composite_text_stream_t, 66 | dx: i16, 67 | dy: i16, 68 | count: u32, 69 | glyphs: *const u8, 70 | ); 71 | pub fn xcb_render_util_glyphs_16( 72 | stream: *mut xcb_render_util_composite_text_stream_t, 73 | dx: i16, 74 | dy: i16, 75 | count: u32, 76 | glyphs: *const u8, 77 | ); 78 | pub fn xcb_render_util_glyphs_32( 79 | stream: *mut xcb_render_util_composite_text_stream_t, 80 | dx: i16, 81 | dy: i16, 82 | count: u32, 83 | glyphs: *const u8, 84 | ); 85 | 86 | pub fn xcb_render_util_change_glyphset( 87 | stream: *mut xcb_render_util_composite_text_stream_t, 88 | glyphset: xcb_render_glyphset_t, 89 | ); 90 | 91 | pub fn xcb_render_util_composite_text( 92 | c: *mut xcb_connection_t, 93 | op: u8, 94 | src: xcb_render_picture_t, 95 | dst: xcb_render_picture_t, 96 | mask_format: xcb_render_picture_t, 97 | src_x: i16, 98 | src_y: i16, 99 | stream: *mut xcb_render_util_composite_text_stream_t, 100 | ) -> xcb_void_cookie_t; 101 | 102 | pub fn xcb_render_util_composite_text_checked( 103 | c: *mut xcb_connection_t, 104 | op: u8, 105 | src: xcb_render_picture_t, 106 | dst: xcb_render_picture_t, 107 | mask_format: xcb_render_picture_t, 108 | src_x: i16, 109 | src_y: i16, 110 | stream: *mut xcb_render_util_composite_text_stream_t, 111 | ) -> xcb_void_cookie_t; 112 | 113 | pub fn xcb_render_util_composite_text_free( 114 | stream: *mut xcb_render_util_composite_text_stream_t, 115 | ); 116 | } 117 | -------------------------------------------------------------------------------- /src/icccm.rs: -------------------------------------------------------------------------------- 1 | use std::mem; 2 | use std::ptr; 3 | use std::slice; 4 | use std::str; 5 | use std::ffi::CStr; 6 | 7 | use xcb; 8 | use xcb::ffi::*; 9 | use ffi::icccm::*; 10 | use util::utf8; 11 | 12 | macro_rules! property { 13 | (checked $name:ident with $func:ident -> $conn:expr, $cookie:expr) => (unsafe { 14 | $name(xcb::GetPropertyCookie { 15 | cookie: $cookie, 16 | conn: $conn, 17 | checked: true, 18 | }, $func) 19 | }); 20 | 21 | (unchecked $name:ident with $func:ident -> $conn:expr, $cookie:expr) => (unsafe { 22 | $name(xcb::GetPropertyCookie { 23 | cookie: $cookie, 24 | conn: $conn, 25 | checked: false, 26 | }, $func) 27 | }); 28 | 29 | (checked $name:ident -> $conn:expr, $cookie:expr) => (unsafe { 30 | $name(xcb::GetPropertyCookie { 31 | cookie: $cookie, 32 | conn: $conn, 33 | checked: true, 34 | }) 35 | }); 36 | 37 | (unchecked $name:ident -> $conn:expr, $cookie:expr) => (unsafe { 38 | $name(xcb::GetPropertyCookie { 39 | cookie: $cookie, 40 | conn: $conn, 41 | checked: false, 42 | }) 43 | }); 44 | } 45 | 46 | pub type WmState = xcb_icccm_wm_state_t; 47 | pub const WM_STATE_WITHDRAWN: WmState = XCB_ICCCM_WM_STATE_WITHDRAWN; 48 | pub const WM_STATE_NORMAL: WmState = XCB_ICCCM_WM_STATE_NORMAL; 49 | pub const WM_STATE_ICONIC: WmState = XCB_ICCCM_WM_STATE_ICONIC; 50 | 51 | define!(cookie GetTextPropertyCookie for xcb_icccm_get_text_property_reply_t => GetTextPropertyReply); 52 | define!(reply GetTextPropertyReply for xcb_icccm_get_text_property_reply_t with xcb_icccm_get_text_property_reply_wipe); 53 | 54 | impl GetTextPropertyReply { 55 | pub fn encoding(&self) -> xcb::Atom { 56 | self.0.encoding as xcb::Atom 57 | } 58 | 59 | pub fn name(&self) -> &str { 60 | unsafe { 61 | str::from_utf8_unchecked(slice::from_raw_parts( 62 | self.0.name as *mut u8, self.0.name_len as usize)) 63 | } 64 | } 65 | 66 | pub fn format(&self) -> u8 { 67 | self.0.format 68 | } 69 | } 70 | 71 | pub fn get_text_property(c: &xcb::Connection, window: xcb::Window, property: xcb::Atom) -> GetTextPropertyCookie { 72 | property!(checked GetTextPropertyCookie with xcb_icccm_get_text_property_reply -> c, 73 | xcb_icccm_get_text_property(c.get_raw_conn(), window, property)) 74 | } 75 | 76 | pub fn get_text_property_unchecked(c: &xcb::Connection, window: xcb::Window, property: xcb::Atom) -> GetTextPropertyCookie { 77 | property!(unchecked GetTextPropertyCookie with xcb_icccm_get_text_property_reply -> c, 78 | xcb_icccm_get_text_property_unchecked(c.get_raw_conn(), window, property)) 79 | } 80 | 81 | pub fn set_wm_name>(c: &xcb::Connection, window: xcb::Window, name: T) -> xcb::VoidCookie { 82 | let name = name.as_ref(); 83 | 84 | void!(unchecked -> c, 85 | xcb_icccm_set_wm_name(c.get_raw_conn(), window, xcb::ATOM_STRING, 8, 86 | name.len() as u32, name.as_bytes().as_ptr() as *const _)) 87 | } 88 | 89 | pub fn set_wm_name_checked>(c: &xcb::Connection, window: xcb::Window, name: T) -> xcb::VoidCookie { 90 | let name = name.as_ref(); 91 | 92 | void!(checked -> c, 93 | xcb_icccm_set_wm_name_checked(c.get_raw_conn(), window, xcb::ATOM_STRING, 8, 94 | name.len() as u32, name.as_bytes().as_ptr() as *const _)) 95 | } 96 | 97 | pub fn get_wm_name(c: &xcb::Connection, window: xcb::Window) -> GetTextPropertyCookie { 98 | property!(checked GetTextPropertyCookie with xcb_icccm_get_wm_name_reply -> c, 99 | xcb_icccm_get_wm_name(c.get_raw_conn(), window)) 100 | } 101 | 102 | pub fn set_wm_icon_name>(c: &xcb::Connection, window: xcb::Window, encoding: xcb::Atom, format: u8, name: T) -> xcb::VoidCookie { 103 | let name = name.as_ref(); 104 | 105 | void!(unchecked -> c, 106 | xcb_icccm_set_wm_icon_name(c.get_raw_conn(), window, encoding, format, 107 | name.len() as u32, name.as_bytes().as_ptr() as *const _)) 108 | } 109 | 110 | pub fn set_wm_icon_name_checked>(c: &xcb::Connection, window: xcb::Window, encoding: xcb::Atom, format: u8, name: T) -> xcb::VoidCookie { 111 | let name = name.as_ref(); 112 | 113 | void!(checked -> c, 114 | xcb_icccm_set_wm_icon_name_checked(c.get_raw_conn(), window, encoding, format, 115 | name.len() as u32, name.as_bytes().as_ptr() as *const _)) 116 | } 117 | 118 | pub fn get_wm_icon_name(c: &xcb::Connection, window: xcb::Window) -> GetTextPropertyCookie { 119 | property!(checked GetTextPropertyCookie with xcb_icccm_get_wm_icon_name_reply -> c, 120 | xcb_icccm_get_wm_icon_name(c.get_raw_conn(), window)) 121 | } 122 | 123 | pub fn get_wm_icon_name_unchecked(c: &xcb::Connection, window: xcb::Window) -> GetTextPropertyCookie { 124 | property!(unchecked GetTextPropertyCookie with xcb_icccm_get_wm_icon_name_reply -> c, 125 | xcb_icccm_get_wm_icon_name_unchecked(c.get_raw_conn(), window)) 126 | } 127 | 128 | define!(cookie GetWmColormapWindowsCookie with xcb_icccm_get_wm_colormap_windows_reply => GetWmColormapWindowsReply); 129 | define!(reply GetWmColormapWindowsReply for xcb_icccm_get_wm_colormap_windows_reply_t with xcb_icccm_get_wm_colormap_windows_reply_wipe); 130 | 131 | impl GetWmColormapWindowsReply { 132 | pub fn windows(&self) -> &[xcb::Window] { 133 | unsafe { 134 | slice::from_raw_parts(self.0.windows as *mut _, self.0.windows_len as usize) 135 | } 136 | } 137 | } 138 | 139 | pub fn set_wm_colormap_windows<'a>(c: &'a xcb::Connection, window: xcb::Window, colormap_windows: xcb::Atom, list: &[xcb::Window]) -> xcb::VoidCookie<'a> { 140 | void!(unchecked -> c, 141 | xcb_icccm_set_wm_colormap_windows(c.get_raw_conn(), window, colormap_windows, 142 | list.len() as u32, list.as_ptr() as *const _)) 143 | } 144 | 145 | pub fn set_wm_colormap_windows_checked<'a>(c: &'a xcb::Connection, window: xcb::Window, colormap_windows: xcb::Atom, list: &[xcb::Window]) -> xcb::VoidCookie<'a> { 146 | void!(checked -> c, 147 | xcb_icccm_set_wm_colormap_windows_checked(c.get_raw_conn(), window, colormap_windows, 148 | list.len() as u32, list.as_ptr() as *const _)) 149 | } 150 | 151 | pub fn get_wm_colormap_windows(c: &xcb::Connection, window: xcb::Window, colormap_windows: xcb::Atom) -> GetWmColormapWindowsCookie { 152 | property!(checked GetWmColormapWindowsCookie -> c, 153 | xcb_icccm_get_wm_colormap_windows(c.get_raw_conn(), window, colormap_windows)) 154 | } 155 | 156 | pub fn get_wm_colormap_windows_unchecked(c: &xcb::Connection, window: xcb::Window, colormap_windows: xcb::Atom) -> GetWmColormapWindowsCookie { 157 | property!(unchecked GetWmColormapWindowsCookie -> c, 158 | xcb_icccm_get_wm_colormap_windows_unchecked(c.get_raw_conn(), window, colormap_windows)) 159 | } 160 | 161 | pub fn set_wm_client_machine>(c: &xcb::Connection, window: xcb::Window, encoding: xcb::Atom, format: u8, name: T) -> xcb::VoidCookie { 162 | let name = name.as_ref(); 163 | 164 | void!(unchecked -> c, 165 | xcb_icccm_set_wm_client_machine(c.get_raw_conn(), window, encoding, format, 166 | name.len() as u32, name.as_bytes().as_ptr() as *const _)) 167 | } 168 | 169 | pub fn set_wm_client_machine_checked>(c: &xcb::Connection, window: xcb::Window, encoding: xcb::Atom, format: u8, name: T) -> xcb::VoidCookie { 170 | let name = name.as_ref(); 171 | 172 | void!(checked -> c, 173 | xcb_icccm_set_wm_client_machine_checked(c.get_raw_conn(), window, encoding, format, 174 | name.len() as u32, name.as_bytes().as_ptr() as *const _)) 175 | } 176 | 177 | pub fn get_wm_client_machine(c: &xcb::Connection, window: xcb::Window) -> GetTextPropertyCookie { 178 | property!(checked GetTextPropertyCookie with xcb_icccm_get_wm_client_machine_reply -> c, 179 | xcb_icccm_get_wm_client_machine(c.get_raw_conn(), window)) 180 | } 181 | 182 | pub fn get_wm_client_machine_unchecked(c: &xcb::Connection, window: xcb::Window) -> GetTextPropertyCookie { 183 | property!(unchecked GetTextPropertyCookie with xcb_icccm_get_wm_client_machine_reply -> c, 184 | xcb_icccm_get_wm_client_machine_unchecked(c.get_raw_conn(), window)) 185 | } 186 | 187 | define!(cookie GetWmClassCookie with xcb_icccm_get_wm_class_reply => GetWmClassReply); 188 | define!(reply GetWmClassReply for xcb_icccm_get_wm_class_reply_t with xcb_icccm_get_wm_class_reply_wipe); 189 | 190 | impl GetWmClassReply { 191 | pub fn instance(&self) -> &str { 192 | unsafe { 193 | CStr::from_ptr(self.0.instance_name).to_str().unwrap() 194 | } 195 | } 196 | 197 | pub fn class(&self) -> &str { 198 | unsafe { 199 | CStr::from_ptr(self.0.class_name).to_str().unwrap() 200 | } 201 | } 202 | } 203 | 204 | pub fn set_wm_class, B: AsRef>(c: &xcb::Connection, window: xcb::Window, class: A, instance: B) -> xcb::VoidCookie { 205 | let value = utf8::from(vec![instance.as_ref(), class.as_ref()]); 206 | 207 | void!(unchecked -> c, 208 | xcb_icccm_set_wm_class(c.get_raw_conn(), window, 209 | value.len() as u32, value.as_ptr() as *const _)) 210 | } 211 | 212 | pub fn set_wm_class_checked, B: AsRef>(c: &xcb::Connection, window: xcb::Window, class: A, instance: B) -> xcb::VoidCookie { 213 | let value = utf8::from(vec![class.as_ref(), instance.as_ref()]); 214 | 215 | void!(checked -> c, 216 | xcb_icccm_set_wm_class_checked(c.get_raw_conn(), window, 217 | value.len() as u32, value.as_ptr() as *const _)) 218 | } 219 | 220 | pub fn get_wm_class(c: &xcb::Connection, window: xcb::Window) -> GetWmClassCookie { 221 | property!(checked GetWmClassCookie -> c, 222 | xcb_icccm_get_wm_class(c.get_raw_conn(), window)) 223 | } 224 | 225 | pub fn get_wm_class_unchecked(c: &xcb::Connection, window: xcb::Window) -> GetWmClassCookie { 226 | property!(unchecked GetWmClassCookie -> c, 227 | xcb_icccm_get_wm_class_unchecked(c.get_raw_conn(), window)) 228 | } 229 | 230 | pub struct SizeHints(xcb_size_hints_t); 231 | pub struct SizeHintsBuilder(xcb_size_hints_t); 232 | 233 | impl SizeHints { 234 | pub fn empty() -> SizeHintsBuilder { 235 | unsafe { 236 | SizeHintsBuilder(mem::zeroed()) 237 | } 238 | } 239 | 240 | pub fn position(&self) -> Option<(i32, i32)> { 241 | if self.0.flags & XCB_ICCCM_SIZE_HINT_P_POSITION == 1 { 242 | Some((self.0.x, self.0.y)) 243 | } 244 | else { 245 | None 246 | } 247 | } 248 | 249 | pub fn size(&self) -> Option<(i32, i32)> { 250 | if self.0.flags & XCB_ICCCM_SIZE_HINT_P_SIZE == 1 { 251 | Some((self.0.width, self.0.height)) 252 | } 253 | else { 254 | None 255 | } 256 | } 257 | 258 | pub fn min_size(&self) -> Option<(i32, i32)> { 259 | if self.0.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE == 1 { 260 | Some((self.0.min_width, self.0.min_height)) 261 | } 262 | else { 263 | None 264 | } 265 | } 266 | 267 | pub fn max_size(&self) -> Option<(i32, i32)> { 268 | if self.0.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE == 1 { 269 | Some((self.0.max_width, self.0.max_height)) 270 | } 271 | else { 272 | None 273 | } 274 | } 275 | 276 | pub fn resize(&self) -> Option<(i32, i32)> { 277 | if self.0.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC == 1 { 278 | Some((self.0.width_inc, self.0.height_inc)) 279 | } 280 | else { 281 | None 282 | } 283 | } 284 | 285 | pub fn aspect(&self) -> Option<((i32, i32), (i32, i32))> { 286 | if self.0.flags & XCB_ICCCM_SIZE_HINT_P_ASPECT == 1 { 287 | Some(((self.0.min_aspect_num, self.0.min_aspect_den), (self.0.max_aspect_num, self.0.max_aspect_den))) 288 | } 289 | else { 290 | None 291 | } 292 | } 293 | 294 | pub fn base(&self) -> Option<(i32, i32)> { 295 | if self.0.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE == 1 { 296 | Some((self.0.base_width, self.0.base_height)) 297 | } 298 | else { 299 | None 300 | } 301 | } 302 | 303 | pub fn gravity(&self) -> Option { 304 | if self.0.flags & XCB_ICCCM_SIZE_HINT_P_WIN_GRAVITY == 1 { 305 | Some(self.0.win_gravity as xcb::Gravity) 306 | } 307 | else { 308 | None 309 | } 310 | } 311 | } 312 | 313 | impl SizeHintsBuilder { 314 | pub fn position(mut self, x: i32, y: i32) -> Self { 315 | unsafe { 316 | xcb_icccm_size_hints_set_position(&mut self.0, 0, x, y); 317 | } 318 | 319 | self 320 | } 321 | 322 | pub fn size(mut self, width: i32, height: i32) -> Self { 323 | unsafe { 324 | xcb_icccm_size_hints_set_size(&mut self.0, 0, width, height) 325 | } 326 | 327 | self 328 | } 329 | 330 | pub fn min_size(mut self, width: i32, height: i32) -> Self { 331 | unsafe { 332 | xcb_icccm_size_hints_set_min_size(&mut self.0, width, height) 333 | } 334 | 335 | self 336 | } 337 | 338 | pub fn max_size(mut self, width: i32, height: i32) -> Self { 339 | unsafe { 340 | xcb_icccm_size_hints_set_max_size(&mut self.0, width, height) 341 | } 342 | 343 | self 344 | } 345 | 346 | pub fn resize(mut self, width: i32, height: i32) -> Self { 347 | unsafe { 348 | xcb_icccm_size_hints_set_resize_inc(&mut self.0, width, height) 349 | } 350 | 351 | self 352 | } 353 | 354 | pub fn aspect(mut self, min: (i32, i32), max: (i32, i32)) -> Self { 355 | unsafe { 356 | xcb_icccm_size_hints_set_aspect(&mut self.0, min.0, min.1, max.0, max.1) 357 | } 358 | 359 | self 360 | } 361 | 362 | pub fn base(mut self, width: i32, height: i32) -> Self { 363 | unsafe { 364 | xcb_icccm_size_hints_set_base_size(&mut self.0, width, height) 365 | } 366 | 367 | self 368 | } 369 | 370 | pub fn gravity(mut self, gravity: xcb::Gravity) -> Self { 371 | unsafe { 372 | xcb_icccm_size_hints_set_win_gravity(&mut self.0, gravity) 373 | } 374 | 375 | self 376 | } 377 | 378 | pub fn build(self) -> SizeHints { 379 | SizeHints(self.0) 380 | } 381 | } 382 | 383 | define!(cookie GetWmSizeHintsCookie with xcb_icccm_get_wm_size_hints_reply => SizeHints); 384 | 385 | pub fn set_wm_size_hints<'a>(c: &'a xcb::Connection, window: xcb::Window, property: xcb::Atom, hints: &SizeHints) -> xcb::VoidCookie<'a> { 386 | void!(unchecked -> c, 387 | xcb_icccm_set_wm_size_hints(c.get_raw_conn(), window, property, &hints.0)) 388 | } 389 | 390 | pub fn set_wm_size_hints_checked<'a>(c: &'a xcb::Connection, window: xcb::Window, property: xcb::Atom, hints: &SizeHints) -> xcb::VoidCookie<'a> { 391 | void!(checked -> c, 392 | xcb_icccm_set_wm_size_hints_checked(c.get_raw_conn(), window, property, &hints.0)) 393 | } 394 | 395 | pub fn get_wm_size_hints(c: &xcb::Connection, window: xcb::Window, property: xcb::Atom) -> GetWmSizeHintsCookie { 396 | property!(checked GetWmSizeHintsCookie -> c, 397 | xcb_icccm_get_wm_size_hints(c.get_raw_conn(), window, property)) 398 | } 399 | 400 | pub fn get_wm_size_hints_unchecked(c: &xcb::Connection, window: xcb::Window, property: xcb::Atom) -> GetWmSizeHintsCookie { 401 | property!(unchecked GetWmSizeHintsCookie -> c, 402 | xcb_icccm_get_wm_size_hints_unchecked(c.get_raw_conn(), window, property)) 403 | } 404 | 405 | pub fn set_wm_normal_hints<'a>(c: &'a xcb::Connection, window: xcb::Window, hints: &SizeHints) -> xcb::VoidCookie<'a> { 406 | void!(unchecked -> c, 407 | xcb_icccm_set_wm_normal_hints(c.get_raw_conn(), window, &hints.0)) 408 | } 409 | 410 | pub fn set_wm_normal_hints_checked<'a>(c: &'a xcb::Connection, window: xcb::Window, hints: &SizeHints) -> xcb::VoidCookie<'a> { 411 | void!(checked -> c, 412 | xcb_icccm_set_wm_normal_hints_checked(c.get_raw_conn(), window, &hints.0)) 413 | } 414 | 415 | pub fn get_wm_normal_hints(c: &xcb::Connection, window: xcb::Window) -> GetWmSizeHintsCookie { 416 | property!(checked GetWmSizeHintsCookie -> c, 417 | xcb_icccm_get_wm_normal_hints(c.get_raw_conn(), window)) 418 | } 419 | 420 | pub fn get_wm_normal_hints_unchecked(c: &xcb::Connection, window: xcb::Window) -> GetWmSizeHintsCookie { 421 | property!(unchecked GetWmSizeHintsCookie -> c, 422 | xcb_icccm_get_wm_normal_hints_unchecked(c.get_raw_conn(), window)) 423 | } 424 | 425 | pub struct WmHints(xcb_icccm_wm_hints_t); 426 | pub struct WmHintsBuilder(xcb_icccm_wm_hints_t); 427 | 428 | impl WmHints { 429 | pub fn empty() -> WmHintsBuilder { 430 | unsafe { 431 | WmHintsBuilder(mem::zeroed()) 432 | } 433 | } 434 | 435 | pub fn input(&self) -> Option { 436 | if self.0.flags & XCB_ICCCM_WM_HINT_INPUT == 1 { 437 | Some(self.0.input != 0) 438 | } 439 | else { 440 | None 441 | } 442 | } 443 | 444 | pub fn is_iconic(&self) -> bool { 445 | self.0.flags & XCB_ICCCM_WM_HINT_INPUT == 1 446 | && self.0.initial_state == XCB_ICCCM_WM_STATE_ICONIC 447 | } 448 | 449 | pub fn is_normal(&self) -> bool { 450 | self.0.flags & XCB_ICCCM_WM_HINT_INPUT == 1 451 | && self.0.initial_state == XCB_ICCCM_WM_STATE_NORMAL 452 | } 453 | 454 | pub fn is_withdrawn(&self) -> bool { 455 | self.0.flags & XCB_ICCCM_WM_HINT_INPUT == 1 456 | && self.0.initial_state == XCB_ICCCM_WM_STATE_WITHDRAWN 457 | } 458 | 459 | pub fn is_none(&self) -> bool { 460 | self.0.flags & XCB_ICCCM_WM_HINT_INPUT != 1 || ( 461 | self.0.initial_state != XCB_ICCCM_WM_STATE_ICONIC && 462 | self.0.initial_state != XCB_ICCCM_WM_STATE_NORMAL && 463 | self.0.initial_state != XCB_ICCCM_WM_STATE_WITHDRAWN) 464 | } 465 | 466 | pub fn icon_pixmap(&self) -> Option { 467 | if self.0.flags & XCB_ICCCM_WM_HINT_ICON_PIXMAP == 1 { 468 | Some(self.0.icon_pixmap as xcb::Pixmap) 469 | } 470 | else { 471 | None 472 | } 473 | } 474 | 475 | pub fn icon_mask(&self) -> Option { 476 | if self.0.flags & XCB_ICCCM_WM_HINT_ICON_MASK == 1 { 477 | Some(self.0.icon_mask as xcb::Pixmap) 478 | } 479 | else { 480 | None 481 | } 482 | } 483 | 484 | pub fn icon_window(&self) -> Option { 485 | if self.0.flags & XCB_ICCCM_WM_HINT_ICON_WINDOW == 1 { 486 | Some(self.0.icon_window as xcb::Window) 487 | } 488 | else { 489 | None 490 | } 491 | } 492 | 493 | pub fn window_group(&self) -> Option { 494 | if self.0.flags & XCB_ICCCM_WM_HINT_WINDOW_GROUP == 1 { 495 | Some(self.0.window_group as xcb::Window) 496 | } 497 | else { 498 | None 499 | } 500 | } 501 | 502 | pub fn is_urgent(&self) -> Option { 503 | if self.0.flags & XCB_ICCCM_WM_HINT_X_URGENCY == 1 { 504 | Some(unsafe { 505 | xcb_icccm_wm_hints_get_urgency(&self.0) != 0 506 | }) 507 | } 508 | else { 509 | None 510 | } 511 | } 512 | } 513 | 514 | impl WmHintsBuilder { 515 | pub fn input(mut self, value: bool) -> Self { 516 | unsafe { 517 | xcb_icccm_wm_hints_set_input(&mut self.0, value as u8); 518 | } 519 | 520 | self 521 | } 522 | 523 | pub fn is_iconic(mut self) -> Self { 524 | unsafe { 525 | xcb_icccm_wm_hints_set_iconic(&mut self.0); 526 | } 527 | 528 | self 529 | } 530 | 531 | pub fn is_normal(mut self) -> Self { 532 | unsafe { 533 | xcb_icccm_wm_hints_set_normal(&mut self.0); 534 | } 535 | 536 | self 537 | } 538 | 539 | pub fn is_withdrawn(mut self) -> Self { 540 | unsafe { 541 | xcb_icccm_wm_hints_set_withdrawn(&mut self.0); 542 | } 543 | 544 | self 545 | } 546 | 547 | pub fn is_none(mut self) -> Self { 548 | unsafe { 549 | xcb_icccm_wm_hints_set_none(&mut self.0); 550 | } 551 | 552 | self 553 | } 554 | 555 | pub fn icon_pixmap(mut self, icon: xcb::Pixmap) -> Self { 556 | unsafe { 557 | xcb_icccm_wm_hints_set_icon_pixmap(&mut self.0, icon); 558 | } 559 | 560 | self 561 | } 562 | 563 | pub fn icon_mask(mut self, icon: xcb::Pixmap) -> Self { 564 | unsafe { 565 | xcb_icccm_wm_hints_set_icon_mask(&mut self.0, icon); 566 | } 567 | 568 | self 569 | } 570 | 571 | pub fn icon_window(mut self, icon: xcb::Window) -> Self { 572 | unsafe { 573 | xcb_icccm_wm_hints_set_icon_window(&mut self.0, icon); 574 | } 575 | 576 | self 577 | } 578 | 579 | pub fn window_group(mut self, group: xcb::Window) -> Self { 580 | unsafe { 581 | xcb_icccm_wm_hints_set_window_group(&mut self.0, group); 582 | } 583 | 584 | self 585 | } 586 | 587 | pub fn is_urgent(mut self) -> Self { 588 | unsafe { 589 | xcb_icccm_wm_hints_set_urgency(&mut self.0); 590 | } 591 | 592 | self 593 | } 594 | 595 | pub fn build(self) -> WmHints { 596 | WmHints(self.0) 597 | } 598 | } 599 | 600 | define!(cookie GetWmHintsCookie with xcb_icccm_get_wm_hints_reply => WmHints); 601 | 602 | pub fn set_wm_hints<'a>(c: &'a xcb::Connection, window: xcb::Window, hints: &WmHints) -> xcb::VoidCookie<'a> { 603 | void!(unchecked -> c, 604 | xcb_icccm_set_wm_hints(c.get_raw_conn(), window, &hints.0)) 605 | } 606 | 607 | pub fn set_wm_hints_checked<'a>(c: &'a xcb::Connection, window: xcb::Window, hints: &WmHints) -> xcb::VoidCookie<'a> { 608 | void!(checked -> c, 609 | xcb_icccm_set_wm_hints_checked(c.get_raw_conn(), window, &hints.0)) 610 | } 611 | 612 | pub fn get_wm_hints(c: &xcb::Connection, window: xcb::Window) -> GetWmHintsCookie { 613 | property!(checked GetWmHintsCookie -> c, 614 | xcb_icccm_get_wm_hints(c.get_raw_conn(), window)) 615 | } 616 | 617 | pub fn get_wm_hints_unchecked(c: &xcb::Connection, window: xcb::Window) -> GetWmHintsCookie { 618 | property!(unchecked GetWmHintsCookie -> c, 619 | xcb_icccm_get_wm_hints_unchecked(c.get_raw_conn(), window)) 620 | } 621 | 622 | define!(cookie GetWmProtocolsCookie with xcb_icccm_get_wm_protocols_reply => GetWmProtocolsReply); 623 | define!(reply GetWmProtocolsReply for xcb_icccm_get_wm_protocols_reply_t with xcb_icccm_get_wm_protocols_reply_wipe); 624 | 625 | impl GetWmProtocolsReply { 626 | pub fn atoms(&self) -> &[xcb::Atom] { 627 | unsafe { 628 | slice::from_raw_parts(self.0.atoms as *mut xcb::Atom, self.0.atoms_len as usize) 629 | } 630 | } 631 | } 632 | 633 | pub fn set_wm_protocols<'a>(c: &'a xcb::Connection, window: xcb::Window, protocols: xcb::Atom, list: &[xcb::Window]) -> xcb::VoidCookie<'a> { 634 | void!(unchecked -> c, 635 | xcb_icccm_set_wm_protocols(c.get_raw_conn(), window, protocols, 636 | list.len() as u32, list.as_ptr() as *const _)) 637 | } 638 | 639 | pub fn set_wm_protocols_checked<'a>(c: &'a xcb::Connection, window: xcb::Window, protocols: xcb::Atom, list: &[xcb::Window]) -> xcb::VoidCookie<'a> { 640 | void!(checked -> c, 641 | xcb_icccm_set_wm_protocols_checked(c.get_raw_conn(), window, protocols, 642 | list.len() as u32, list.as_ptr() as *const _)) 643 | } 644 | 645 | pub fn get_wm_protocols(c: &xcb::Connection, window: xcb::Window, protocols: xcb::Atom) -> GetWmProtocolsCookie { 646 | property!(checked GetWmProtocolsCookie -> c, 647 | xcb_icccm_get_wm_protocols(c.get_raw_conn(), window, protocols)) 648 | } 649 | 650 | pub fn get_wm_protocols_unchecked(c: &xcb::Connection, window: xcb::Window, protocols: xcb::Atom) -> GetWmProtocolsCookie { 651 | property!(unchecked GetWmProtocolsCookie -> c, 652 | xcb_icccm_get_wm_protocols_unchecked(c.get_raw_conn(), window, protocols)) 653 | } 654 | 655 | pub struct GetWmStateCookie<'a>(xcb::GetPropertyCookie<'a>); 656 | pub struct GetWmStateReply(xcb::GetPropertyReply); 657 | 658 | impl<'a> GetWmStateCookie<'a> { 659 | pub fn get_reply(self) -> Result { 660 | let reply = self.0.get_reply()?; 661 | 662 | if reply.type_() == xcb::ATOM_NONE { 663 | Err(xcb::ReplyError::GenericError(xcb::GenericError { ptr: ptr::null_mut() })) 664 | } 665 | else { 666 | Ok(GetWmStateReply(reply)) 667 | } 668 | } 669 | } 670 | 671 | impl GetWmStateReply { 672 | pub fn state(&self) -> WmState { 673 | self.0.value()[0] 674 | } 675 | 676 | pub fn icon(&self) -> xcb::Window { 677 | self.0.value()[1] 678 | } 679 | } 680 | 681 | pub fn set_wm_state(c: &xcb::Connection, window: xcb::Window, state: WmState, icon: xcb::Window) -> xcb::VoidCookie { 682 | let atom = xcb::intern_atom_unchecked(c, false, "WM_STATE").get_reply().unwrap().atom(); 683 | xcb::change_property(c, xcb::CHANGE_PROPERTY as u8, window, atom, atom, 32, &[state as i32, icon as i32]) 684 | } 685 | 686 | pub fn set_wm_state_checked(c: &xcb::Connection, window: xcb::Window, state: WmState, icon: xcb::Window) -> xcb::VoidCookie { 687 | let atom = xcb::intern_atom_unchecked(c, false, "WM_STATE").get_reply().unwrap().atom(); 688 | xcb::change_property_checked(c, xcb::CHANGE_PROPERTY as u8, window, atom, atom, 32, &[state as i32, icon as i32]) 689 | } 690 | 691 | pub fn get_wm_state(c: &xcb::Connection, window: xcb::Window) -> GetWmStateCookie { 692 | let atom = xcb::intern_atom_unchecked(c, false, "WM_STATE").get_reply().unwrap().atom(); 693 | GetWmStateCookie(xcb::get_property(c, false, window, atom, atom, 0, 2)) 694 | } 695 | 696 | pub fn get_wm_state_unchecked(c: &xcb::Connection, window: xcb::Window) -> GetWmStateCookie { 697 | let atom = xcb::intern_atom_unchecked(c, false, "WM_STATE").get_reply().unwrap().atom(); 698 | GetWmStateCookie(xcb::get_property_unchecked(c, false, window, atom, atom, 0, 2)) 699 | } 700 | -------------------------------------------------------------------------------- /src/image.rs: -------------------------------------------------------------------------------- 1 | use std::slice; 2 | 3 | use xcb; 4 | use ffi::image::*; 5 | use libc::{malloc, memcpy, size_t}; 6 | 7 | pub struct Image(*mut xcb_image_t); 8 | 9 | #[cfg(feature = "thread")] 10 | unsafe impl Send for Image { } 11 | #[cfg(feature = "thread")] 12 | unsafe impl Sync for Image { } 13 | 14 | impl Image { 15 | pub fn annotate(&self) { 16 | unsafe { 17 | xcb_image_annotate(self.0) 18 | } 19 | } 20 | 21 | pub fn width(&self) -> u16 { 22 | unsafe { 23 | (*self.0).width 24 | } 25 | } 26 | 27 | pub fn height(&self) -> u16 { 28 | unsafe { 29 | (*self.0).height 30 | } 31 | } 32 | 33 | pub fn format(&self) -> xcb::ImageFormat { 34 | unsafe { 35 | (*self.0).format 36 | } 37 | } 38 | 39 | pub fn scanline_pad(&self) -> u8 { 40 | unsafe { 41 | (*self.0).scanline_pad 42 | } 43 | } 44 | 45 | pub fn depth(&self) -> u8 { 46 | unsafe { 47 | (*self.0).depth 48 | } 49 | } 50 | 51 | pub fn bpp(&self) -> u8 { 52 | unsafe { 53 | (*self.0).bpp 54 | } 55 | } 56 | 57 | pub fn unit(&self) -> u8 { 58 | unsafe { 59 | (*self.0).unit 60 | } 61 | } 62 | 63 | pub fn plane_mask(&self) -> u32 { 64 | unsafe { 65 | (*self.0).plane_mask 66 | } 67 | } 68 | 69 | pub fn byte_order(&self) -> xcb::ImageOrder { 70 | unsafe { 71 | (*self.0).byte_order 72 | } 73 | } 74 | 75 | pub fn bit_order(&self) -> xcb::ImageOrder { 76 | unsafe { 77 | (*self.0).bit_order 78 | } 79 | } 80 | 81 | pub fn stride(&self) -> u32 { 82 | unsafe { 83 | (*self.0).stride 84 | } 85 | } 86 | 87 | pub fn size(&self) -> u32 { 88 | unsafe { 89 | (*self.0).size 90 | } 91 | } 92 | 93 | pub fn data(&self) -> &[u8] { 94 | unsafe { 95 | slice::from_raw_parts((*self.0).data, (*self.0).size as usize) 96 | } 97 | } 98 | 99 | pub fn put(&mut self, x: u32, y: u32, pixel: u32) { 100 | unsafe { 101 | xcb_image_put_pixel(self.0, x, y, pixel) 102 | } 103 | } 104 | 105 | pub fn get(&self, x: u32, y: u32) -> u32 { 106 | unsafe { 107 | xcb_image_get_pixel(self.0, x, y) 108 | } 109 | } 110 | } 111 | 112 | impl Drop for Image { 113 | fn drop(&mut self) { 114 | unsafe { 115 | xcb_image_destroy(self.0); 116 | } 117 | } 118 | } 119 | 120 | pub fn create>(source: T, width: u32, height: u32) -> Image { 121 | unsafe { 122 | let source = source.as_ref(); 123 | let data = malloc(source.len() as size_t); 124 | memcpy(data, source.as_ptr() as *const _, source.len() as size_t); 125 | 126 | Image(xcb_image_create_from_bitmap_data(data as *mut _, width, height)) 127 | } 128 | } 129 | 130 | pub fn get(c: &xcb::Connection, drawable: xcb::Drawable, x: i16, y: i16, width: u16, height: u16, plane_mask: u32, format: xcb::ImageFormat) -> Result { 131 | unsafe { 132 | let ptr = xcb_image_get(c.get_raw_conn(), drawable, x, y, width, height, plane_mask, format); 133 | 134 | if ptr.is_null() { 135 | Err(()) 136 | } 137 | else { 138 | Ok(Image(ptr)) 139 | } 140 | } 141 | } 142 | 143 | pub fn put<'a>(c: &'a xcb::Connection, drawable: xcb::Drawable, gc: xcb::Gcontext, image: &Image, x: i16, y: i16) -> xcb::VoidCookie<'a> { 144 | unsafe { 145 | xcb::VoidCookie { 146 | cookie: xcb_image_put(c.get_raw_conn(), drawable, gc, image.0, x, y, 0), 147 | conn: c, 148 | checked: false, 149 | } 150 | } 151 | } 152 | 153 | pub fn is_native(c: &xcb::Connection, image: &Image) -> bool { 154 | unsafe { 155 | xcb_image_native(c.get_raw_conn(), image.0, 0) == image.0 156 | } 157 | } 158 | 159 | pub fn to_native(c: &xcb::Connection, image: &Image) -> Option { 160 | unsafe { 161 | let ptr = xcb_image_native(c.get_raw_conn(), image.0, 1); 162 | 163 | if ptr == image.0 || ptr.is_null() { 164 | None 165 | } 166 | else { 167 | Some(Image(ptr)) 168 | } 169 | } 170 | } 171 | 172 | #[cfg(feature = "shm")] 173 | pub mod shm { 174 | use std::ptr; 175 | use std::ops::{Deref, DerefMut}; 176 | 177 | use xcb; 178 | use xcb::ffi::*; 179 | use xcb::ffi::shm::*; 180 | use ffi::image::*; 181 | use libc::{shmget, shmat, shmdt, shmctl, IPC_CREAT, IPC_RMID}; 182 | 183 | pub struct Image { 184 | conn: *mut xcb_connection_t, 185 | base: super::Image, 186 | shm: xcb_shm_segment_info_t, 187 | 188 | width: u16, 189 | height: u16, 190 | } 191 | 192 | #[cfg(feature = "thread")] 193 | unsafe impl Send for Image { } 194 | #[cfg(feature = "thread")] 195 | unsafe impl Sync for Image { } 196 | 197 | pub fn create(c: &xcb::Connection, depth: u8, width: u16, height: u16) -> Result { 198 | unsafe { 199 | let setup = c.get_setup(); 200 | let format = setup.pixmap_formats().find(|f| f.depth() == depth).ok_or(())?; 201 | let image = xcb_image_create(width, height, xcb::IMAGE_FORMAT_Z_PIXMAP, 202 | format.scanline_pad(), format.depth(), format.bits_per_pixel(), 203 | setup.bitmap_format_scanline_unit(), setup.image_byte_order() as u32, setup.bitmap_format_bit_order() as u32, 204 | ptr::null_mut(), !0, ptr::null_mut()); 205 | 206 | if image.is_null() { 207 | return Err(()); 208 | } 209 | 210 | let id = match shmget(0, (*image).size as usize, IPC_CREAT | 0o666) { 211 | -1 => { 212 | xcb_image_destroy(image); 213 | return Err(()); 214 | } 215 | 216 | id => id 217 | }; 218 | 219 | let addr = match shmat(id, ptr::null(), 0) { 220 | addr if addr as isize == -1 => { 221 | xcb_image_destroy(image); 222 | shmctl(id, IPC_RMID, ptr::null_mut()); 223 | 224 | return Err(()); 225 | } 226 | 227 | addr => addr 228 | }; 229 | 230 | let seg = c.generate_id(); 231 | xcb::shm::attach(c, seg, id as u32, false); 232 | (*image).data = addr as *mut _; 233 | 234 | Ok(Image { 235 | conn: c.get_raw_conn(), 236 | base: super::Image(image), 237 | 238 | shm: xcb_shm_segment_info_t { 239 | shmseg: seg, 240 | shmid: id as u32, 241 | shmaddr: addr as *mut _, 242 | }, 243 | 244 | width: width, 245 | height: height, 246 | }) 247 | } 248 | } 249 | 250 | impl Image { 251 | pub fn resize(&mut self, width: u16, height: u16) { 252 | assert!(width <= self.width && height <= self.height); 253 | 254 | unsafe { 255 | (*self.base.0).width = width; 256 | (*self.base.0).height = height; 257 | } 258 | 259 | self.annotate(); 260 | } 261 | 262 | pub fn restore(&mut self) { 263 | let width = self.width; 264 | let height = self.height; 265 | 266 | self.resize(width, height); 267 | } 268 | 269 | pub fn actual_width(&self) -> u16 { 270 | self.width 271 | } 272 | 273 | pub fn actual_height(&self) -> u16 { 274 | self.height 275 | } 276 | } 277 | 278 | impl Deref for Image { 279 | type Target = super::Image; 280 | 281 | fn deref(&self) -> &Self::Target { 282 | &self.base 283 | } 284 | } 285 | 286 | impl DerefMut for Image { 287 | fn deref_mut(&mut self) -> &mut Self::Target { 288 | &mut self.base 289 | } 290 | } 291 | 292 | impl Drop for Image { 293 | fn drop(&mut self) { 294 | unsafe { 295 | xcb_shm_detach(self.conn, self.shm.shmseg); 296 | shmdt(self.shm.shmaddr as *mut _); 297 | shmctl(self.shm.shmid as i32, IPC_RMID, ptr::null_mut()); 298 | } 299 | } 300 | } 301 | 302 | pub fn get<'a>(c: &xcb::Connection, drawable: xcb::Drawable, output: &'a mut Image, x: i16, y: i16, plane_mask: u32) -> Result<&'a mut Image, ()> { 303 | unsafe { 304 | if xcb_image_shm_get(c.get_raw_conn(), drawable, output.base.0, output.shm, x, y, plane_mask) != 0 { 305 | Ok(output) 306 | } 307 | else { 308 | Err(()) 309 | } 310 | } 311 | } 312 | 313 | pub fn put<'a>(c: &xcb::Connection, drawable: xcb::Drawable, gc: xcb::Gcontext, input: &'a Image, src_x: i16, src_y: i16, dest_x: i16, dest_y: i16, src_width: u16, src_height: u16, send_event: bool) -> Result<&'a Image, ()> { 314 | unsafe { 315 | if !xcb_image_shm_put(c.get_raw_conn(), drawable, gc, input.base.0, input.shm, src_x, src_y, dest_x, dest_y, src_width, src_height, send_event as u8).is_null() { 316 | Ok(input) 317 | } 318 | else { 319 | Err(()) 320 | } 321 | } 322 | } 323 | 324 | /// Fetches an area from the given drawable. 325 | /// 326 | /// For technical reasons the `output` is resized to fit the area, to restore 327 | /// it to its original dimensions see `Image::restore`, the shared memory is 328 | /// untouched. 329 | pub fn area<'a>(c: &xcb::Connection, drawable: xcb::Drawable, output: &'a mut Image, x: i16, y: i16, width: u16, height: u16, plane_mask: u32) -> Result<&'a mut Image, ()> { 330 | output.resize(width, height); 331 | get(c, drawable, output, x, y, plane_mask) 332 | } 333 | } 334 | -------------------------------------------------------------------------------- /src/keysyms.rs: -------------------------------------------------------------------------------- 1 | use xcb; 2 | use ffi::keysyms::*; 3 | use libc::{free, c_void}; 4 | 5 | pub struct KeySymbols<'a> { 6 | ptr: *mut xcb_key_symbols_t, 7 | conn: &'a xcb::Connection, 8 | } 9 | 10 | impl<'a> KeySymbols<'a> { 11 | pub fn new(c: &xcb::Connection) -> KeySymbols { 12 | unsafe { 13 | KeySymbols { 14 | ptr: xcb_key_symbols_alloc(c.get_raw_conn()), 15 | conn: c, 16 | } 17 | } 18 | } 19 | 20 | pub fn get_keysym(&self, keycode: xcb::Keycode, col: i32) -> xcb::Keysym { 21 | unsafe { 22 | xcb_key_symbols_get_keysym(self.ptr, keycode, col) 23 | } 24 | } 25 | 26 | pub fn get_keycode(&self, keysym: xcb::Keysym) -> KeycodeIter { 27 | unsafe { 28 | KeycodeIter { 29 | ptr: xcb_key_symbols_get_keycode(self.ptr, keysym), 30 | index: 0, 31 | } 32 | } 33 | } 34 | 35 | pub fn press_lookup_keysym(&self, event: &xcb::KeyPressEvent, col: i32) -> xcb::Keysym { 36 | unsafe { 37 | xcb_key_press_lookup_keysym(self.ptr, event.ptr, col) 38 | } 39 | } 40 | 41 | pub fn release_lookup_keysym(&self, event: &xcb::KeyReleaseEvent, col: i32) -> xcb::Keysym { 42 | unsafe { 43 | xcb_key_release_lookup_keysym(self.ptr, event.ptr, col) 44 | } 45 | } 46 | 47 | pub fn refresh_keyboard_mapping(&self, event: &xcb::MappingNotifyEvent) -> i32 { 48 | unsafe { 49 | xcb_refresh_keyboard_mapping(self.ptr, event.ptr) 50 | } 51 | } 52 | } 53 | 54 | impl<'a> Drop for KeySymbols<'a> { 55 | fn drop(&mut self) { 56 | unsafe { 57 | xcb_key_symbols_free(self.ptr); 58 | } 59 | } 60 | } 61 | 62 | pub struct KeycodeIter { 63 | ptr: *mut xcb::Keycode, 64 | index: isize, 65 | } 66 | 67 | impl Drop for KeycodeIter { 68 | fn drop(&mut self) { 69 | unsafe { 70 | free(self.ptr as *mut c_void); 71 | } 72 | } 73 | } 74 | 75 | impl Iterator for KeycodeIter { 76 | type Item = xcb::Keycode; 77 | 78 | fn next(&mut self) -> Option { 79 | unsafe { 80 | if self.ptr.is_null() { 81 | return None; 82 | } 83 | 84 | match *self.ptr.offset(self.index) { 85 | 0 => 86 | None, 87 | 88 | keycode => { 89 | self.index += 1; 90 | Some(keycode) 91 | } 92 | } 93 | } 94 | } 95 | } 96 | 97 | pub fn is_keypad_key(keysym: xcb::Keysym) -> bool { 98 | unsafe { 99 | xcb_is_keypad_key(keysym) != 0 100 | } 101 | } 102 | 103 | pub fn is_private_keypad_key(keysym: xcb::Keysym) -> bool { 104 | unsafe { 105 | xcb_is_private_keypad_key(keysym) != 0 106 | } 107 | } 108 | 109 | pub fn is_cursor_key(keysym: xcb::Keysym) -> bool { 110 | unsafe { 111 | xcb_is_cursor_key(keysym) != 0 112 | } 113 | } 114 | 115 | pub fn is_pf_key(keysym: xcb::Keysym) -> bool { 116 | unsafe { 117 | xcb_is_pf_key(keysym) != 0 118 | } 119 | } 120 | 121 | pub fn is_function_key(keysym: xcb::Keysym) -> bool { 122 | unsafe { 123 | xcb_is_function_key(keysym) != 0 124 | } 125 | } 126 | 127 | pub fn is_misc_function_key(keysym: xcb::Keysym) -> bool { 128 | unsafe { 129 | xcb_is_misc_function_key(keysym) != 0 130 | } 131 | } 132 | 133 | pub fn is_modifier_key(keysym: xcb::Keysym) -> bool { 134 | unsafe { 135 | xcb_is_modifier_key(keysym) != 0 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_camel_case_types, non_snake_case)] 2 | 3 | extern crate xcb; 4 | extern crate libc; 5 | 6 | pub mod ffi; 7 | 8 | #[macro_use] 9 | mod util; 10 | 11 | #[cfg(feature = "icccm")] 12 | pub mod icccm; 13 | 14 | #[cfg(feature = "ewmh")] 15 | pub mod ewmh; 16 | 17 | #[cfg(feature = "image")] 18 | pub mod image; 19 | 20 | #[cfg(feature = "cursor")] 21 | pub mod cursor; 22 | 23 | #[cfg(feature = "keysyms")] 24 | pub mod keysyms; 25 | 26 | #[cfg(feature = "misc")] 27 | pub mod misc; 28 | 29 | #[cfg(feature = "render")] 30 | pub mod render; 31 | -------------------------------------------------------------------------------- /src/misc.rs: -------------------------------------------------------------------------------- 1 | use xcb; 2 | use icccm; 3 | 4 | pub fn client_window(c: &xcb::Connection, window: xcb::Window) -> Option { 5 | fn try_children(c: &xcb::Connection, window: xcb::Window) -> Option { 6 | if let Ok(query) = xcb::query_tree(c, window).get_reply() { 7 | for &child in query.children() { 8 | if icccm::get_wm_state(c, child).get_reply().is_ok() { 9 | return Some(child); 10 | } 11 | 12 | if let Some(window) = try_children(c, child) { 13 | return Some(window); 14 | } 15 | } 16 | } 17 | 18 | None 19 | } 20 | 21 | if icccm::get_wm_state(c, window).get_reply().is_ok() { 22 | Some(window) 23 | } 24 | else { 25 | try_children(c, window) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/render.rs: -------------------------------------------------------------------------------- 1 | use xcb; 2 | use xcb::ffi::*; 3 | use xcb::render::*; 4 | use ffi::render::*; 5 | 6 | pub const PICT_FORMAT_ID: Pictformat = XCB_PICT_FORMAT_ID; 7 | pub const PICT_FORMAT_TYPE: Pictformat = XCB_PICT_FORMAT_TYPE; 8 | pub const PICT_FORMAT_DEPTH: Pictformat = XCB_PICT_FORMAT_DEPTH; 9 | pub const PICT_FORMAT_RED: Pictformat = XCB_PICT_FORMAT_RED; 10 | pub const PICT_FORMAT_RED_MASK: Pictformat = XCB_PICT_FORMAT_RED_MASK; 11 | pub const PICT_FORMAT_GREEN: Pictformat = XCB_PICT_FORMAT_GREEN; 12 | pub const PICT_FORMAT_GREEN_MASK: Pictformat = XCB_PICT_FORMAT_GREEN_MASK; 13 | pub const PICT_FORMAT_BLUE: Pictformat = XCB_PICT_FORMAT_BLUE; 14 | pub const PICT_FORMAT_BLUE_MASK: Pictformat = XCB_PICT_FORMAT_BLUE_MASK; 15 | pub const PICT_FORMAT_ALPHA: Pictformat = XCB_PICT_FORMAT_ALPHA; 16 | pub const PICT_FORMAT_ALPHA_MASK: Pictformat = XCB_PICT_FORMAT_ALPHA_MASK; 17 | pub const PICT_FORMAT_COLORMAP: Pictformat = XCB_PICT_FORMAT_COLORMAP; 18 | 19 | pub type PictStandard = xcb_pict_standard_t; 20 | pub const PICT_STANDARD_ARGB_32: PictStandard = XCB_PICT_STANDARD_ARGB_32; 21 | pub const PICT_STANDARD_RGB_24: PictStandard = XCB_PICT_STANDARD_RGB_24; 22 | pub const PICT_STANDARD_A_8: PictStandard = XCB_PICT_STANDARD_A_8; 23 | pub const PICT_STANDARD_A_4: PictStandard = XCB_PICT_STANDARD_A_4; 24 | pub const PICT_STANDARD_A_1: PictStandard = XCB_PICT_STANDARD_A_1; 25 | 26 | pub trait QueryPictFormatsReplyExt { 27 | fn find_visual_format(&self, visual: xcb::Visualid) -> Option; 28 | fn find_format(&self, mask: Pictformat, formats: &[Pictforminfo]) -> Option; 29 | fn find_standard_format(&self, format: PictStandard) -> Option; 30 | } 31 | 32 | impl QueryPictFormatsReplyExt for QueryPictFormatsReply { 33 | fn find_visual_format(&self, visual: xcb::Visualid) -> Option { 34 | let result = unsafe { 35 | xcb_render_util_find_visual_format( 36 | self.ptr, 37 | visual, 38 | ) 39 | }; 40 | 41 | if result.is_null() { 42 | None 43 | } else { 44 | Some(Pictvisual { 45 | base: unsafe { *result }, 46 | }) 47 | } 48 | } 49 | 50 | fn find_format(&self, mask: Pictformat, formats: &[Pictforminfo]) -> Option { 51 | let formats: Vec = formats 52 | .into_iter() 53 | .map(|format| format.base) 54 | .collect(); 55 | 56 | let result = unsafe { 57 | xcb_render_util_find_format( 58 | self.ptr, 59 | mask, 60 | formats.as_ptr(), 61 | formats.len() as _, 62 | ) 63 | }; 64 | 65 | if result.is_null() { 66 | None 67 | } else { 68 | Some(Pictforminfo { 69 | base: unsafe { *result }, 70 | }) 71 | } 72 | } 73 | 74 | fn find_standard_format(&self, format: PictStandard) -> Option { 75 | let result = unsafe { 76 | xcb_render_util_find_standard_format( 77 | self.ptr, 78 | format, 79 | ) 80 | }; 81 | 82 | if result.is_null() { 83 | None 84 | } else { 85 | Some(Pictforminfo { 86 | base: unsafe { *result }, 87 | }) 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/util.rs: -------------------------------------------------------------------------------- 1 | macro_rules! define { 2 | (cookie $cookie:ident for $inner:ident => $reply:ident) => ( 3 | pub struct $cookie<'a>(xcb::GetPropertyCookie<'a>, 4 | unsafe extern "C" fn(*mut xcb_connection_t, xcb_get_property_cookie_t, *mut $inner, *mut *mut xcb_generic_error_t) -> u8); 5 | 6 | #[cfg(feature = "thread")] 7 | unsafe impl<'a> Send for $cookie<'a> { } 8 | #[cfg(feature = "thread")] 9 | unsafe impl<'a> Sync for $cookie<'a> { } 10 | 11 | impl<'a> $cookie<'a> { 12 | pub fn get_reply(&self) -> Result<$reply, xcb::ReplyError> { 13 | unsafe { 14 | if self.0.checked { 15 | let mut err: *mut xcb_generic_error_t = ptr::null_mut(); 16 | let mut reply = mem::zeroed(); 17 | let res = self.1(self.0.conn.get_raw_conn(), self.0.cookie, &mut reply, &mut err); 18 | 19 | if err.is_null() && res != 0 { 20 | Ok($reply(reply)) 21 | } 22 | else { 23 | Err(xcb::ReplyError::GenericError(xcb::GenericError { ptr: err })) 24 | } 25 | } 26 | else { 27 | let mut reply = mem::zeroed(); 28 | self.1(self.0.conn.get_raw_conn(), self.0.cookie, &mut reply, ptr::null_mut()); 29 | 30 | Ok($reply(reply)) 31 | } 32 | } 33 | } 34 | } 35 | ); 36 | 37 | (cookie $cookie:ident with $func:ident => $reply:ident) => ( 38 | pub struct $cookie<'a>(xcb::GetPropertyCookie<'a>); 39 | 40 | #[cfg(feature = "thread")] 41 | unsafe impl<'a> Send for $cookie<'a> { } 42 | #[cfg(feature = "thread")] 43 | unsafe impl<'a> Sync for $cookie<'a> { } 44 | 45 | impl<'a> $cookie<'a> { 46 | pub fn get_reply(&self) -> Result<$reply, xcb::ReplyError> { 47 | unsafe { 48 | if self.0.checked { 49 | let mut err: *mut xcb_generic_error_t = ptr::null_mut(); 50 | let mut reply = mem::zeroed(); 51 | let res = $func(self.0.conn.get_raw_conn(), self.0.cookie, &mut reply, &mut err); 52 | 53 | if err.is_null() && res != 0 { 54 | Ok($reply(reply)) 55 | } 56 | else { 57 | Err(xcb::ReplyError::GenericError(xcb::GenericError { ptr: err })) 58 | } 59 | } 60 | else { 61 | let mut reply = mem::zeroed(); 62 | $func(self.0.conn.get_raw_conn(), self.0.cookie, &mut reply, ptr::null_mut()); 63 | 64 | Ok($reply(reply)) 65 | } 66 | } 67 | } 68 | } 69 | ); 70 | 71 | (cookie $cookie:ident through $conn:ident with $func:ident => $reply:ident) => ( 72 | pub struct $cookie<'a> { 73 | conn: &'a $conn, 74 | cookie: xcb_get_property_cookie_t, 75 | checked: bool, 76 | } 77 | 78 | #[cfg(feature = "thread")] 79 | unsafe impl<'a> Send for $cookie<'a> { } 80 | #[cfg(feature = "thread")] 81 | unsafe impl<'a> Sync for $cookie<'a> { } 82 | 83 | impl<'a> $cookie<'a> { 84 | pub fn get_reply(&self) -> Result<$reply, xcb::ReplyError> { 85 | unsafe { 86 | if self.checked { 87 | let mut err: *mut xcb_generic_error_t = ptr::null_mut(); 88 | let mut reply = mem::zeroed(); 89 | let res = $func(self.conn.get_raw_conn(), self.cookie, &mut reply, &mut err); 90 | 91 | if err.is_null() && res != 0 { 92 | Ok($reply(reply)) 93 | } 94 | else { 95 | Err(xcb::ReplyError::GenericError(xcb::GenericError { ptr: err })) 96 | } 97 | } 98 | else { 99 | let mut reply = mem::zeroed(); 100 | $func(self.conn.get_raw_conn(), self.cookie, &mut reply, ptr::null_mut()); 101 | 102 | Ok($reply(reply)) 103 | } 104 | } 105 | } 106 | } 107 | ); 108 | 109 | (cookie $cookie:ident through $conn:ident with $func:ident as ($first:path, $second:path)) => ( 110 | pub struct $cookie<'a> { 111 | conn: &'a $conn, 112 | cookie: xcb_get_property_cookie_t, 113 | checked: bool, 114 | } 115 | 116 | #[cfg(feature = "thread")] 117 | unsafe impl<'a> Send for $cookie<'a> { } 118 | #[cfg(feature = "thread")] 119 | unsafe impl<'a> Sync for $cookie<'a> { } 120 | 121 | impl<'a> $cookie<'a> { 122 | pub fn get_reply(&self) -> Result<($first, $second), xcb::ReplyError> { 123 | unsafe { 124 | if self.checked { 125 | let mut err: *mut xcb_generic_error_t = ptr::null_mut(); 126 | let mut first = mem::zeroed(); 127 | let mut second = mem::zeroed(); 128 | let res = $func(self.conn.get_raw_conn(), self.cookie, &mut first, &mut second, &mut err); 129 | 130 | if err.is_null() && res != 0 { 131 | Ok((first, second)) 132 | } 133 | else { 134 | Err(xcb::ReplyError::GenericError(xcb::GenericError { ptr: err })) 135 | } 136 | } 137 | else { 138 | let mut first = mem::zeroed(); 139 | let mut second = mem::zeroed(); 140 | $func(self.conn.get_raw_conn(), self.cookie, &mut first, &mut second, ptr::null_mut()); 141 | 142 | Ok((first, second)) 143 | } 144 | } 145 | } 146 | } 147 | ); 148 | 149 | (cookie $cookie:ident through $conn:ident with $func:ident as $reply:path) => ( 150 | pub struct $cookie<'a> { 151 | conn: &'a $conn, 152 | cookie: xcb_get_property_cookie_t, 153 | checked: bool, 154 | } 155 | 156 | #[cfg(feature = "thread")] 157 | unsafe impl<'a> Send for $cookie<'a> { } 158 | #[cfg(feature = "thread")] 159 | unsafe impl<'a> Sync for $cookie<'a> { } 160 | 161 | impl<'a> $cookie<'a> { 162 | pub fn get_reply(&self) -> Result<$reply, xcb::ReplyError> { 163 | unsafe { 164 | if self.checked { 165 | let mut err: *mut xcb_generic_error_t = ptr::null_mut(); 166 | let mut reply = mem::zeroed(); 167 | let res = $func(self.conn.get_raw_conn(), self.cookie, &mut reply, &mut err); 168 | 169 | if err.is_null() && res != 0 { 170 | Ok(reply) 171 | } 172 | else { 173 | Err(xcb::ReplyError::GenericError(xcb::GenericError { ptr: err })) 174 | } 175 | } 176 | else { 177 | let mut reply = mem::zeroed(); 178 | $func(self.conn.get_raw_conn(), self.cookie, &mut reply, ptr::null_mut()); 179 | 180 | Ok(reply) 181 | } 182 | } 183 | } 184 | } 185 | ); 186 | 187 | (cookie $cookie:ident($inner:path) through $conn:ident with $func:ident as $reply:path) => ( 188 | pub struct $cookie<'a> { 189 | conn: &'a $conn, 190 | cookie: $inner, 191 | checked: bool, 192 | } 193 | 194 | #[cfg(feature = "thread")] 195 | unsafe impl<'a> Send for $cookie<'a> { } 196 | #[cfg(feature = "thread")] 197 | unsafe impl<'a> Sync for $cookie<'a> { } 198 | 199 | impl<'a> $cookie<'a> { 200 | pub fn get_reply(&self) -> Result<$reply, xcb::ReplyError> { 201 | unsafe { 202 | if self.checked { 203 | let mut err: *mut xcb_generic_error_t = ptr::null_mut(); 204 | let mut reply = mem::zeroed(); 205 | let res = $func(self.conn.get_raw_conn(), self.cookie, &mut reply, &mut err); 206 | 207 | if err.is_null() && res != 0 { 208 | Ok(reply) 209 | } 210 | else { 211 | Err(xcb::ReplyError::GenericError(xcb::GenericError { ptr: err })) 212 | } 213 | } 214 | else { 215 | let mut reply = mem::zeroed(); 216 | $func(self.conn.get_raw_conn(), self.cookie, &mut reply, ptr::null_mut()); 217 | 218 | Ok(reply) 219 | } 220 | } 221 | } 222 | } 223 | ); 224 | 225 | (reply $reply:ident for $inner:ident with $wipe:ident) => ( 226 | pub struct $reply($inner); 227 | 228 | impl Drop for $reply { 229 | fn drop(&mut self) { 230 | unsafe { 231 | $wipe(&mut self.0); 232 | } 233 | } 234 | } 235 | ); 236 | 237 | (reply $reply:ident for $inner:ident) => ( 238 | pub struct $reply($inner); 239 | ); 240 | } 241 | 242 | macro_rules! void { 243 | (checked -> $conn:expr, $cookie:expr) => (unsafe { 244 | xcb::VoidCookie { 245 | cookie: $cookie, 246 | conn: $conn, 247 | checked: true, 248 | } 249 | }); 250 | 251 | (unchecked -> $conn:expr, $cookie:expr) => (unsafe { 252 | xcb::VoidCookie { 253 | cookie: $cookie, 254 | conn: $conn, 255 | checked: true, 256 | } 257 | }); 258 | } 259 | 260 | macro_rules! property { 261 | (checked $name:ident -> $conn:expr, $cookie:expr) => (unsafe { 262 | $name { 263 | conn: $conn, 264 | cookie: $cookie, 265 | checked: true, 266 | } 267 | }); 268 | 269 | (unchecked $name:ident -> $conn:expr, $cookie:expr) => (unsafe { 270 | $name { 271 | conn: $conn, 272 | cookie: $cookie, 273 | checked: false, 274 | } 275 | }); 276 | } 277 | 278 | pub mod utf8 { 279 | use std::str; 280 | use std::slice; 281 | use libc::c_char; 282 | 283 | pub fn into<'a>(data: *const c_char, length: u32) -> Vec<&'a str> { 284 | if length == 0 { 285 | return Vec::new(); 286 | } 287 | 288 | unsafe { 289 | let mut result = str::from_utf8_unchecked(slice::from_raw_parts(data as *mut u8, length as usize)) 290 | .split('\0') 291 | .collect::>(); 292 | 293 | // Data is sometimes NULL-terminated and sometimes not. If there is a 294 | // NULL terminator, then our call to .split() will result in an extra 295 | // empty-string element at the end, so pop it. 296 | if let Some(&"") = result.last() { 297 | result.pop(); 298 | } 299 | 300 | result 301 | } 302 | } 303 | 304 | pub fn from<'a, T: IntoIterator>(data: T) -> Vec { 305 | let mut result = String::new(); 306 | 307 | for item in data { 308 | result.push_str(item); 309 | result.push('\0'); 310 | } 311 | 312 | result.into_bytes() 313 | } 314 | } 315 | --------------------------------------------------------------------------------