Compare commits
3 Commits
caa4102856
...
e690aa07f1
Author | SHA1 | Date |
---|---|---|
expectocode | e690aa07f1 | |
expectocode | b5f697d471 | |
expectocode | e20d9cfa0c |
50
src/main.rs
50
src/main.rs
|
@ -7,15 +7,22 @@ fn main() {
|
|||
|
||||
let window = conn.generate_id();
|
||||
|
||||
let width = screen.width_in_pixels();
|
||||
let height = screen.height_in_pixels();
|
||||
|
||||
println!("width {} height {}", width, height);
|
||||
|
||||
let values = [
|
||||
(xcb::CW_BACK_PIXEL, screen.white_pixel()),
|
||||
// ?RGB. First 4 bytes appear to do nothing
|
||||
(xcb::CW_BACK_PIXEL, 0x00_00_00_00),
|
||||
(
|
||||
xcb::CW_EVENT_MASK,
|
||||
xcb::EVENT_MASK_EXPOSURE
|
||||
| xcb::EVENT_MASK_KEY_PRESS // we'll need this later
|
||||
| xcb::EVENT_MASK_BUTTON_PRESS
|
||||
| xcb::EVENT_MASK_BUTTON_RELEASE,
|
||||
// | xcb::EVENT_MASK_BUTTON_PRESS
|
||||
// | xcb::EVENT_MASK_BUTTON_RELEASE,
|
||||
),
|
||||
(xcb::CW_OVERRIDE_REDIRECT, 1 as u32), // Don't be window managed
|
||||
];
|
||||
|
||||
xcb::create_window(
|
||||
|
@ -23,11 +30,11 @@ fn main() {
|
|||
xcb::COPY_FROM_PARENT as u8,
|
||||
window,
|
||||
screen.root(),
|
||||
0, // x
|
||||
0, // y
|
||||
0, // width
|
||||
0, // height
|
||||
0,
|
||||
0,
|
||||
150,
|
||||
150,
|
||||
10,
|
||||
xcb::WINDOW_CLASS_INPUT_OUTPUT as u16,
|
||||
screen.root_visual(),
|
||||
&values,
|
||||
|
@ -35,11 +42,38 @@ fn main() {
|
|||
|
||||
xcb::map_window(&conn, window);
|
||||
|
||||
let title = "hacksaw";
|
||||
// setting title
|
||||
xcb::change_property(
|
||||
&conn,
|
||||
xcb::PROP_MODE_REPLACE as u8,
|
||||
window,
|
||||
xcb::ATOM_WM_NAME,
|
||||
xcb::ATOM_STRING,
|
||||
8,
|
||||
title.as_bytes(),
|
||||
);
|
||||
|
||||
xcb::grab_pointer(
|
||||
&conn,
|
||||
true,
|
||||
screen.root(),
|
||||
(xcb::EVENT_MASK_BUTTON_RELEASE | xcb::EVENT_MASK_BUTTON_PRESS) as u16,
|
||||
xcb::GRAB_MODE_ASYNC as u8,
|
||||
xcb::GRAB_MODE_ASYNC as u8,
|
||||
xcb::NONE,
|
||||
xcb::NONE,
|
||||
xcb::CURRENT_TIME,
|
||||
).get_reply()
|
||||
.unwrap();
|
||||
|
||||
conn.flush();
|
||||
|
||||
loop {
|
||||
let ev = conn.wait_for_event();
|
||||
match ev {
|
||||
None => {
|
||||
println!("Error reading events");
|
||||
break;
|
||||
}
|
||||
Some(ev) => {
|
||||
|
@ -63,4 +97,6 @@ fn main() {
|
|||
}
|
||||
};
|
||||
}
|
||||
// Now we have taken coordinates, we use them
|
||||
// TODO
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue