Struct x11_dl::xlib::ClientMessageData
source · #[repr(C)]pub struct ClientMessageData { /* private fields */ }
Implementations§
source§impl ClientMessageData
impl ClientMessageData
pub fn as_bytes(&self) -> &[c_char]
pub fn as_bytes_mut(&mut self) -> &mut [c_char]
pub fn as_longs(&self) -> &[c_long]
pub fn as_longs_mut(&mut self) -> &mut [c_long]
pub fn as_shorts(&self) -> &[c_short]
pub fn as_shorts_mut(&mut self) -> &mut [c_short]
pub fn get_byte(&self, index: usize) -> c_char
sourcepub fn get_long(&self, index: usize) -> c_long
pub fn get_long(&self, index: usize) -> c_long
Examples found in repository?
examples/hello-world-dl.rs (line 83)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
fn main() {
unsafe {
// Load Xlib library.
let xlib = xlib::Xlib::open().unwrap();
// Open display connection.
let display = (xlib.XOpenDisplay)(ptr::null());
if display.is_null() {
panic!("XOpenDisplay failed");
}
// Create window.
let screen = (xlib.XDefaultScreen)(display);
let root = (xlib.XRootWindow)(display, screen);
let mut attributes: xlib::XSetWindowAttributes = mem::MaybeUninit::uninit().assume_init();
attributes.background_pixel = (xlib.XWhitePixel)(display, screen);
let window = (xlib.XCreateWindow)(
display,
root,
0,
0,
400,
300,
0,
0,
xlib::InputOutput as c_uint,
ptr::null_mut(),
xlib::CWBackPixel,
&mut attributes,
);
// Set window title.
let title_str = CString::new("hello-world").unwrap();
(xlib.XStoreName)(display, window, title_str.as_ptr() as *mut c_char);
// Hook close requests.
let wm_protocols_str = CString::new("WM_PROTOCOLS").unwrap();
let wm_delete_window_str = CString::new("WM_DELETE_WINDOW").unwrap();
let wm_protocols = (xlib.XInternAtom)(display, wm_protocols_str.as_ptr(), xlib::False);
let wm_delete_window =
(xlib.XInternAtom)(display, wm_delete_window_str.as_ptr(), xlib::False);
let mut protocols = [wm_delete_window];
(xlib.XSetWMProtocols)(
display,
window,
protocols.as_mut_ptr(),
protocols.len() as c_int,
);
// Show window.
(xlib.XMapWindow)(display, window);
// Main loop.
let mut event: xlib::XEvent = mem::MaybeUninit::uninit().assume_init();
loop {
(xlib.XNextEvent)(display, &mut event);
match event.get_type() {
xlib::ClientMessage => {
let xclient = xlib::XClientMessageEvent::from(event);
if xclient.message_type == wm_protocols && xclient.format == 32 {
let protocol = xclient.data.get_long(0) as xlib::Atom;
if protocol == wm_delete_window {
break;
}
}
}
_ => (),
}
}
// Shut down.
(xlib.XCloseDisplay)(display);
}
}
pub fn get_short(&self, index: usize) -> c_short
pub fn new() -> ClientMessageData
pub fn set_byte(&mut self, index: usize, value: c_char)
pub fn set_long(&mut self, index: usize, value: c_long)
pub fn set_short(&mut self, index: usize, value: c_short)
Trait Implementations§
source§impl AsMut<[i16]> for ClientMessageData
impl AsMut<[i16]> for ClientMessageData
source§impl AsMut<[i64]> for ClientMessageData
impl AsMut<[i64]> for ClientMessageData
source§impl AsMut<[i8]> for ClientMessageData
impl AsMut<[i8]> for ClientMessageData
source§impl AsMut<[u16]> for ClientMessageData
impl AsMut<[u16]> for ClientMessageData
source§impl AsMut<[u64]> for ClientMessageData
impl AsMut<[u64]> for ClientMessageData
source§impl AsMut<[u8]> for ClientMessageData
impl AsMut<[u8]> for ClientMessageData
source§impl AsRef<[i16]> for ClientMessageData
impl AsRef<[i16]> for ClientMessageData
source§impl AsRef<[i64]> for ClientMessageData
impl AsRef<[i64]> for ClientMessageData
source§impl AsRef<[i8]> for ClientMessageData
impl AsRef<[i8]> for ClientMessageData
source§impl AsRef<[u16]> for ClientMessageData
impl AsRef<[u16]> for ClientMessageData
source§impl AsRef<[u64]> for ClientMessageData
impl AsRef<[u64]> for ClientMessageData
source§impl AsRef<[u8]> for ClientMessageData
impl AsRef<[u8]> for ClientMessageData
source§impl Clone for ClientMessageData
impl Clone for ClientMessageData
source§fn clone(&self) -> ClientMessageData
fn clone(&self) -> ClientMessageData
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ClientMessageData
impl Debug for ClientMessageData
source§impl Default for ClientMessageData
impl Default for ClientMessageData
source§fn default() -> ClientMessageData
fn default() -> ClientMessageData
Returns the “default value” for a type. Read more
source§impl PartialEq<ClientMessageData> for ClientMessageData
impl PartialEq<ClientMessageData> for ClientMessageData
source§fn eq(&self, other: &ClientMessageData) -> bool
fn eq(&self, other: &ClientMessageData) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.