Browse Source

xbc.h is now mapped almost fully!

master
Magic_RB 2 years ago
parent
commit
8603da5af9
15 changed files with 424 additions and 78 deletions
  1. +98
    -0
      Cargo.lock
  2. +2
    -1
      Cargo.toml
  3. +0
    -73
      src/connection.rs
  4. +1
    -0
      src/connection/color_map.rs
  5. +0
    -0
      src/connection/event.rs
  6. +0
    -0
      src/connection/event_mask.rs
  7. +1
    -0
      src/connection/key_code.rs
  8. +162
    -0
      src/connection/mod.rs
  9. +71
    -0
      src/connection/setup/mod.rs
  10. +24
    -0
      src/connection/setup/screen_iterator/mod.rs
  11. +57
    -0
      src/connection/setup/screen_iterator/screen.rs
  12. +3
    -0
      src/connection/special_event.rs
  13. +1
    -0
      src/connection/visual_id.rs
  14. +1
    -0
      src/connection/window.rs
  15. +3
    -4
      src/lib.rs

+ 98
- 0
Cargo.lock View File

@ -25,6 +25,26 @@ dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "backtrace"
version = "0.3.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "backtrace-sys"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bindgen"
version = "0.51.1"
@ -111,6 +131,26 @@ dependencies = [
"termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "failure"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "failure_derive"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "glob"
version = "0.3.0"
@ -170,6 +210,14 @@ name = "peeking_take_while"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro2"
version = "1.0.4"
@ -183,6 +231,14 @@ name = "quick-error"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quote"
version = "1.0.2"
@ -207,6 +263,11 @@ name = "regex-syntax"
version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc-demangle"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc-hash"
version = "1.0.1"
@ -225,6 +286,27 @@ name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "syn"
version = "0.15.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "synstructure"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "termcolor"
version = "1.0.5"
@ -254,6 +336,11 @@ name = "unicode-width"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.2.0"
@ -318,6 +405,7 @@ name = "xcb-rs"
version = "0.1.0"
dependencies = [
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"xcb-sys 0.1.0",
]
@ -332,6 +420,8 @@ dependencies = [
"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90"
"checksum backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "690a62be8920ccf773ee00ef0968649b0e724cda8bd5b12286302b4ae955fdf5"
"checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b"
"checksum bindgen 0.51.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebd71393f1ec0509b553aa012b9b58e81dadbdff7130bd3b8cba576e69b32f75"
"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2"
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
@ -341,6 +431,8 @@ dependencies = [
"checksum clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853"
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
@ -350,18 +442,24 @@ dependencies = [
"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
"checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
"checksum proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afdc77cc74ec70ed262262942ebb7dac3d479e9e5cfa2da1841c0806f6cdabcc"
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd"
"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716"
"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
"checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f"
"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e"
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"


+ 2
- 1
Cargo.toml View File

@ -8,4 +8,5 @@ edition = "2018"
[dependencies]
xcb-sys = { path = "xcb-sys" }
bitflags = "1.2.*"
bitflags = "1.2.*"
failure = "0.1.*"

+ 0
- 73
src/connection.rs View File

@ -1,73 +0,0 @@
use crate::event::Event;
use crate::event::Event::{LeaveNotify, CreateNotify, DestroyNotify};
#[derive(Debug)]
pub struct Connection {
handle: *mut xcb_sys::xcb_connection_t
}
impl Connection {
pub fn new(display_name: &str, preferred_screen: Option<i32>) -> Result<Self, ()> {
let preferred_screen: *mut i32 = match preferred_screen {
Some(mut screen) => &mut screen,
None => std::ptr::null_mut()
};
unsafe {
let str_ptr = match display_name {
"" => std::ptr::null(),
_ => display_name.as_ptr() as *const i8
};
let handle = xcb_sys::xcb_connect(str_ptr, preferred_screen);
if xcb_sys::xcb_connection_has_error(handle) == 0 {
Ok(Connection {
handle
})
} else {
xcb_sys::xcb_disconnect(handle);
Err(())
}
}
}
pub fn flush(&mut self) -> Result<(), ()>{
if unsafe { xcb_sys::xcb_flush(self.handle) } > 0 {
Ok(())
} else {
Err(())
}
}
fn get_maximum_request_length(&mut self) -> u32 {
unsafe { xcb_sys::xcb_get_maximum_request_length(self.handle) }
}
fn prefetch_maximum_request_length(&mut self) {
unsafe { xcb_sys::xcb_prefetch_maximum_request_length(self.handle) }
}
pub fn wait_for_event(&mut self) -> Option<Event> {
let event = unsafe { xcb_sys::xcb_wait_for_event(self.handle) };
match event.is_null() {
false => Some(Event::from(unsafe { *event })),
True => None
}
}
pub fn poll_for_event(&mut self) -> Option<Event> {
let event = unsafe { xcb_sys::xcb_poll_for_event(self.handle) };
match event.is_null() {
false => Some(Event::from(unsafe { *event })),
True => None
}
// @TODO somehow check if connection was closed?
}
}
impl Drop for Connection {
fn drop(&mut self) {
unsafe {
xcb_sys::xcb_disconnect(self.handle);
}
}
}

+ 1
- 0
src/connection/color_map.rs View File

@ -0,0 +1 @@
pub type ColorMap = u32;

src/event.rs → src/connection/event.rs View File


src/event_mask.rs → src/connection/event_mask.rs View File


+ 1
- 0
src/connection/key_code.rs View File

@ -0,0 +1 @@
pub type KeyCode = u8;

+ 162
- 0
src/connection/mod.rs View File

@ -0,0 +1,162 @@
mod event;
pub use event::*;
mod event_mask;
pub use event_mask::*;
mod special_event;
pub use special_event::*;
mod setup;
pub use setup::*;
mod window;
pub use window::*;
mod color_map;
pub use color_map::*;
mod visual_id;
pub use visual_id::*;
mod key_code;
pub use key_code::*;
#[derive(Debug, Fail)]
pub enum ConnectionError {
#[fail(display = "socket error, pipe error or other stream error")]
StreamError,
#[fail(display = "extension not supported")]
UnsupportedExtension,
#[fail(display = "memory not available")]
MemoryInsufficient,
#[fail(display = "exceeding request length that server accepts")]
RequestLengthExceeded,
#[fail(display = "string parse error")]
ParseError,
#[fail(display = "invalid screen")]
InvalidScreen,
#[fail(display = "unknown")]
Unknown
}
impl From<i32> for ConnectionError {
fn from(num: i32) -> Self {
match num {
1 => ConnectionError::StreamError,
2 => ConnectionError::UnsupportedExtension,
3 => ConnectionError::MemoryInsufficient,
4 => ConnectionError::RequestLengthExceeded,
5 => ConnectionError::ParseError,
6 => ConnectionError::InvalidScreen,
_ => ConnectionError::Unknown
}
}
}
#[derive(Debug)]
pub struct Connection {
handle: *mut xcb_sys::xcb_connection_t
}
impl Connection {
pub fn new(display_name: &str, preferred_screen: Option<i32>) -> Result<Self, ()> {
let preferred_screen: *mut i32 = match preferred_screen {
Some(mut screen) => &mut screen,
None => std::ptr::null_mut()
};
unsafe {
let str_ptr = match display_name {
"" => std::ptr::null(),
_ => display_name.as_ptr() as *const i8
};
let handle = xcb_sys::xcb_connect(str_ptr, preferred_screen);
if xcb_sys::xcb_connection_has_error(handle) == 0 {
Ok(Connection {
handle
})
} else {
xcb_sys::xcb_disconnect(handle);
Err(())
}
}
}
// @TODO maybe add xcb_connect_to_fd
// @TODO maybe add xcb_connect_to_display_with_auth_info
pub fn flush(&mut self) -> Result<(), ()>{
if unsafe { xcb_sys::xcb_flush(self.handle) } > 0 {
Ok(())
} else {
Err(())
}
}
pub fn get_maximum_request_length(&mut self) -> u32 {
unsafe { xcb_sys::xcb_get_maximum_request_length(self.handle) }
}
pub fn prefetch_maximum_request_length(&mut self) {
unsafe { xcb_sys::xcb_prefetch_maximum_request_length(self.handle) }
}
pub fn wait_for_event(&mut self) -> Option<Event> {
let event = unsafe { xcb_sys::xcb_wait_for_event(self.handle) };
match event.is_null() {
false => Some(Event::from(unsafe { *event })),
True => None
}
}
pub fn poll_for_event(&mut self) -> Option<Event> {
let event = unsafe { xcb_sys::xcb_poll_for_event(self.handle) };
match event.is_null() {
false => Some(Event::from(unsafe { *event })),
True => None
}
// @TODO somehow check if connection was closed?
}
pub fn poll_for_queued_event(&mut self) -> Option<Event> {
let event = unsafe { xcb_sys::xcb_poll_for_queued_event(self.handle) };
match event.is_null() {
false => Some(Event::from(unsafe { *event })),
True => None
}
}
pub fn poll_for_special_event(&mut self, special_event: SpecialEvent) -> Option<Event> {
let event = unsafe { xcb_sys::xcb_poll_for_special_event(self.handle, special_event.handle) };
match event.is_null() {
false => Some(Event::from(unsafe { *event })),
True => None
}
}
pub fn wait_for_special_event(&mut self, special_event: SpecialEvent) -> Option<Event> {
let event = unsafe { xcb_sys::xcb_wait_for_special_event(self.handle, special_event.handle) };
match event.is_null() {
false => Some(Event::from(unsafe { *event })),
True => None
}
}
// pub fn register_for_special_xge(&mut self) //@TODO not sure about implementation and usage
// pub fn unregister_for_special_event(&mut self)
// pub fn request_check(&mut self)
// pub fn discard_reply(&mut self)
// pub fn discard_reply64(&mut self)
// pub fn get_extension_data(&mut self)
// pub fn prefetch_extension_data(&mut self)_
pub fn get_setup(&mut self) -> Option<Setup> {
let setup = unsafe { xcb_sys::xcb_get_setup(self.handle) };
match setup.is_null() {
false => Some(Setup { handle: setup }),
true => None
}
}
pub fn get_file_descriptor(&mut self) -> i32 {
unsafe { xcb_sys::xcb_get_file_descriptor(self.handle) }
}
pub fn connection_has_error(&mut self) -> Option<ConnectionError> {
let num = unsafe { xcb_sys::xcb_connection_has_error(self.handle) };
match num {
0 => None,
_ => Some(ConnectionError::from(num))
}
}
// pub fn xcb_parse_display(&mut self) -> @TODO double pointer?
}
impl Drop for Connection {
fn drop(&mut self) {
unsafe {
xcb_sys::xcb_disconnect(self.handle);
}
}
}

+ 71
- 0
src/connection/setup/mod.rs View File

@ -0,0 +1,71 @@
mod screen_iterator;
pub use screen_iterator::*;
use crate::connection::KeyCode;
#[derive(Debug)]
pub struct Setup {
pub(super) handle: *const xcb_sys::xcb_setup_t
}
impl Setup {
pub fn roots_iterator(&mut self) -> ScreenIterator {
let screen_iterator = unsafe { xcb_sys::xcb_setup_roots_iterator(self.handle) };
ScreenIterator { screen_iterator }
}
pub fn status(&mut self) -> u8 {
unsafe { *self.handle }.status
}
pub fn protocol_major_version(&mut self) -> u16 {
unsafe { *self.handle }.protocol_major_version
}
pub fn protocol_minor_version(&mut self) -> u16 {
unsafe { *self.handle }.protocol_minor_version
}
pub fn length(&mut self) -> u16 {
unsafe { *self.handle }.length
}
pub fn release_number(&mut self) -> u32 {
unsafe { *self.handle }.release_number
}
pub fn resource_id_base(&mut self) -> u32 {
unsafe { *self.handle }.resource_id_base
}
pub fn resource_id_mask(&mut self) -> u32 {
unsafe { *self.handle }.resource_id_mask
}
pub fn motion_buffer_size(&mut self) -> u32 {
unsafe { *self.handle }.motion_buffer_size
}
pub fn vendor_len(&mut self) -> u16 {
unsafe { *self.handle }.vendor_len
}
pub fn maximum_request_length(&mut self) -> u16 {
unsafe { *self.handle }.maximum_request_length
}
pub fn roots_len(&mut self) -> u8 {
unsafe { *self.handle }.roots_len
}
pub fn pixmap_formats_len(&mut self) -> u8 {
unsafe { *self.handle }.pixmap_formats_len
}
pub fn image_byte_order(&mut self) -> u8 {
unsafe { *self.handle }.image_byte_order
}
pub fn bitmap_format_bit_order(&mut self) -> u8 {
unsafe { *self.handle }.bitmap_format_bit_order
}
pub fn bitmap_format_scanline_unit(&mut self) -> u8 {
unsafe { *self.handle }.bitmap_format_scanline_unit
}
pub fn bitmap_format_scanline_pad(&mut self) -> u8 {
unsafe { *self.handle }.bitmap_format_scanline_pad
}
pub fn min_keycode(&mut self) -> KeyCode {
unsafe { *self.handle }.min_keycode
}
pub fn max_keycode(&mut self) -> KeyCode {
unsafe { *self.handle }.max_keycode
}
}
// @TODO add all the fields as getters!

+ 24
- 0
src/connection/setup/screen_iterator/mod.rs View File

@ -0,0 +1,24 @@
mod screen;
pub use screen::*;
#[derive(Debug)]
pub struct ScreenIterator {
pub(super) screen_iterator: xcb_sys::xcb_screen_iterator_t
}
impl ScreenIterator {
pub fn screen(&mut self) -> Option<Screen> {
match self.screen_iterator.data.is_null() {
false => Some(Screen { handle: self.screen_iterator.data }),
true => None
}
}
pub fn rem(&self) -> i32 {
self.screen_iterator.rem
}
pub fn index(&self) -> i32 {
self.screen_iterator.index
}
}

+ 57
- 0
src/connection/setup/screen_iterator/screen.rs View File

@ -0,0 +1,57 @@
use crate::connection::{Window, ColorMap, VisualID};
#[derive(Debug)]
pub struct Screen {
pub(super) handle: *mut xcb_sys::xcb_screen_t
}
impl Screen {
pub fn root(&self) -> Window {
unsafe { *self.handle }.root
}
pub fn default_colormap(&mut self) -> ColorMap {
unsafe { *self.handle }.default_colormap
}
pub fn white_pixel(&mut self) -> u32 {
unsafe { *self.handle }.white_pixel
}
pub fn black_pixel(&mut self) -> u32 {
unsafe { *self.handle }.black_pixel
}
pub fn current_input_masks(&mut self) -> u32 {
unsafe { *self.handle }.current_input_masks
}
pub fn width_in_pixels(&mut self) -> u16 {
unsafe { *self.handle }.width_in_pixels
}
pub fn height_in_pixels(&mut self) -> u16 {
unsafe { *self.handle }.height_in_pixels
}
pub fn width_in_millimeters(&mut self) -> u16 {
unsafe { *self.handle }.width_in_millimeters
}
pub fn height_in_millimeters(&mut self) -> u16 {
unsafe { *self.handle }.height_in_millimeters
}
pub fn min_installed_maps(&mut self) -> u16 {
unsafe { *self.handle }.min_installed_maps
}
pub fn max_installed_maps(&mut self) -> u16 {
unsafe { *self.handle }.max_installed_maps
}
pub fn root_visual(&mut self) -> VisualID {
unsafe { *self.handle }.root_visual
}
pub fn backing_stores(&mut self) -> u8 {
unsafe { *self.handle }.backing_stores
}
pub fn save_unders(&mut self) -> u8 {
unsafe { *self.handle }.save_unders
}
pub fn root_depth(&mut self) -> u8 {
unsafe { *self.handle }.root_depth
}
pub fn allowed_depths_len(&mut self) -> u8 {
unsafe { *self.handle }.allowed_depths_len
}
}

+ 3
- 0
src/connection/special_event.rs View File

@ -0,0 +1,3 @@
pub struct SpecialEvent {
pub(super) handle: *mut xcb_sys::xcb_special_event
}

+ 1
- 0
src/connection/visual_id.rs View File

@ -0,0 +1 @@
pub type VisualID = u32;

+ 1
- 0
src/connection/window.rs View File

@ -0,0 +1 @@
pub type Window = u32;

+ 3
- 4
src/lib.rs View File

@ -1,9 +1,7 @@
#[macro_use]
extern crate bitflags;
#[macro_use] extern crate bitflags;
#[macro_use] extern crate failure;
pub mod connection;
pub mod event_mask;
pub mod event;
#[cfg(test)]
mod test {
@ -15,6 +13,7 @@ mod test {
use crate::connection::Connection;
let mut connection = Connection::new("", None).unwrap();
let screen = connection.get_setup().unwrap().roots_iterator().screen().unwrap();
connection.flush();
let event = connection.wait_for_event().unwrap();
}

Loading…
Cancel
Save