aaah backgrounds
This commit is contained in:
parent
caa4102856
commit
e20d9cfa0c
99
src/main.rs
99
src/main.rs
|
@ -1,5 +1,8 @@
|
||||||
extern crate xcb;
|
extern crate xcb;
|
||||||
|
|
||||||
|
// use std::fs::File;
|
||||||
|
// use std::io::Write;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let (conn, screen_num) = xcb::Connection::connect(None).unwrap();
|
let (conn, screen_num) = xcb::Connection::connect(None).unwrap();
|
||||||
let setup = conn.get_setup();
|
let setup = conn.get_setup();
|
||||||
|
@ -7,8 +10,40 @@ fn main() {
|
||||||
|
|
||||||
let window = conn.generate_id();
|
let window = conn.generate_id();
|
||||||
|
|
||||||
|
let width = screen.width_in_pixels();
|
||||||
|
let height = screen.height_in_pixels();
|
||||||
|
|
||||||
|
println!("width {} height {}", width, height);
|
||||||
|
|
||||||
|
let screenshot = xcb::get_image(
|
||||||
|
&conn,
|
||||||
|
xcb::IMAGE_FORMAT_Z_PIXMAP as u8,
|
||||||
|
screen.root(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
0xFF_FF_FF_FF_u32,
|
||||||
|
).get_reply()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// let mut buf = File::create("out.bin").unwrap();
|
||||||
|
// buf.write(screenshot.data()).unwrap();
|
||||||
|
|
||||||
|
let bg = conn.generate_id();
|
||||||
|
xcb::create_pixmap(
|
||||||
|
&conn,
|
||||||
|
xcb::COPY_FROM_PARENT as u8,
|
||||||
|
bg,
|
||||||
|
screenshot,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
);
|
||||||
|
|
||||||
let values = [
|
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_BACK_PIXMAP, bg),
|
||||||
(
|
(
|
||||||
xcb::CW_EVENT_MASK,
|
xcb::CW_EVENT_MASK,
|
||||||
xcb::EVENT_MASK_EXPOSURE
|
xcb::EVENT_MASK_EXPOSURE
|
||||||
|
@ -16,6 +51,7 @@ fn main() {
|
||||||
| xcb::EVENT_MASK_BUTTON_PRESS
|
| xcb::EVENT_MASK_BUTTON_PRESS
|
||||||
| xcb::EVENT_MASK_BUTTON_RELEASE,
|
| xcb::EVENT_MASK_BUTTON_RELEASE,
|
||||||
),
|
),
|
||||||
|
(xcb::CW_OVERRIDE_REDIRECT, 1 as u32), // Don't be window managed
|
||||||
];
|
];
|
||||||
|
|
||||||
xcb::create_window(
|
xcb::create_window(
|
||||||
|
@ -25,17 +61,47 @@ fn main() {
|
||||||
screen.root(),
|
screen.root(),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
150,
|
width / 2,
|
||||||
150,
|
height / 2,
|
||||||
10,
|
0,
|
||||||
xcb::WINDOW_CLASS_INPUT_OUTPUT as u16,
|
xcb::WINDOW_CLASS_INPUT_OUTPUT as u16,
|
||||||
screen.root_visual(),
|
screen.root_visual(),
|
||||||
&values,
|
&values,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// // Set transparency.
|
||||||
|
// let opacity_atom = xcb::intern_atom(&conn, false, "_NET_WM_WINDOW_OPACITY")
|
||||||
|
// .get_reply()
|
||||||
|
// .expect("Couldn't create atom _NET_WM_WINDOW_OPACITY")
|
||||||
|
// .atom();
|
||||||
|
// // let opacity = u32::max_value();
|
||||||
|
// let opacity = 0;
|
||||||
|
// xcb::change_property(
|
||||||
|
// &conn,
|
||||||
|
// xcb::PROP_MODE_REPLACE as u8,
|
||||||
|
// window,
|
||||||
|
// opacity_atom,
|
||||||
|
// xcb::ATOM_CARDINAL,
|
||||||
|
// 32,
|
||||||
|
// &[opacity],
|
||||||
|
// );
|
||||||
|
|
||||||
xcb::map_window(&conn, window);
|
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(),
|
||||||
|
);
|
||||||
|
|
||||||
conn.flush();
|
conn.flush();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let ev = conn.wait_for_event();
|
let ev = conn.wait_for_event();
|
||||||
match ev {
|
match ev {
|
||||||
|
@ -63,4 +129,29 @@ fn main() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// Now we have taken coordinates, we use them
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// let vinfo: xcb::XVisualInfo;
|
||||||
|
// unsafe {
|
||||||
|
// xcb::XMatchVisualInfo(conn.get_raw_dpy(), screen_num, 32, xcb::Truecolor, &vinfo);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// int main(int argc, char* argv[])
|
||||||
|
// {
|
||||||
|
// Display* display = XOpenDisplay(NULL);
|
||||||
|
|
||||||
|
// XVisualInfo vinfo;
|
||||||
|
// XMatchVisualInfo(display, DefaultScreen(display), 32, TrueColor, &vinfo);
|
||||||
|
|
||||||
|
// XSetWindowAttributes attr;
|
||||||
|
// attr.colormap = XCreateColormap(display, DefaultRootWindow(display), vinfo.visual, AllocNone);
|
||||||
|
// attr.border_pixel = 0;
|
||||||
|
// attr.background_pixel = 0;
|
||||||
|
|
||||||
|
// Window win = XCreateWindow(display, DefaultRootWindow(display), 0, 0, 300, 200, 0, vinfo.depth, InputOutput, vinfo.visual, CWColormap | CWBorderPixel | CWBackPixel, &attr);
|
||||||
|
|
||||||
|
// XDestroyWindow(display, win);
|
||||||
|
// XCloseDisplay(display);
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
|
Loading…
Reference in New Issue