Add xinerama functionality
Getty Ritter
5 years ago
18 | 18 | // TODO: this should be a function of font size |
19 | 19 | ht: 36, |
20 | 20 | }; |
21 | let screens = d.get_widths(); | |
22 | println!("{:?}", screens); | |
23 | let mut w = Window::create(d, size)?; | |
24 | // set some window-manager properties: this is a dock | |
25 | w.change_property("_NET_WM_WINDOW_TYPE", &["_NET_WM_WINDOW_TYPE_DOCK"])?; | |
26 | // ...and should push other windows out of the way | |
27 | w.change_property("_NET_WM_STRUT", &[0i64, 0, size.ht as i64, 0])?; | |
28 | w.change_property( | |
29 | "_NET_WM_STRUT_PARTIAL", | |
30 | &[ 0, 0, size.ht as i64, 0, | |
31 | 0, 0, 0, 0, | |
32 | 0, size.wd as i64, 0, 0, | |
33 | ], | |
34 | )?; | |
21 | let mut ws = Vec::new(); | |
22 | for (x_off, wd) in in d.get_widths() { | |
23 | let size = Size { wd, ht: 36 }; | |
24 | let mut w = Window::create(d, size)?; | |
25 | // set some window-manager properties: this is a dock | |
26 | w.change_property("_NET_WM_WINDOW_TYPE", &["_NET_WM_WINDOW_TYPE_DOCK"])?; | |
27 | // ...and should push other windows out of the way | |
28 | w.change_property("_NET_WM_STRUT", &[x_off as i64, 0, size.ht as i64, 0])?; | |
29 | w.change_property( | |
30 | "_NET_WM_STRUT_PARTIAL", | |
31 | &[ 0, 0, size.ht as i64, 0, | |
32 | 0, 0, 0, 0, | |
33 | 0, size.wd as i64, 0, 0, | |
34 | ], | |
35 | )?; | |
35 | 36 | |
36 | // we won't ever see this, but for good measure. | |
37 | w.set_title("rbar")?; | |
38 | // we care about some input events! | |
39 | w.set_input_masks()?; | |
40 | w.set_protocols()?; | |
41 | // and now show it! | |
42 |
|
|
37 | // we won't ever see this, but for good measure. | |
38 | w.set_title("rbar")?; | |
39 | // we care about some input events! | |
40 | w.set_input_masks()?; | |
41 | w.set_protocols()?; | |
42 | // and now show it! | |
43 | w.map(); | |
44 | ws.push(w); | |
45 | } | |
43 | 46 | |
44 | 47 | // let's grab the cairo context here |
45 | 48 | let surf = w.get_cairo_surface(); |
47 | 50 | |
48 | 51 | // we do some grossness with file descriptors later, so we need |
49 | 52 | // the file descriptors we care about here |
50 |
let window_fd |
|
53 | let window_fds = ws.map{ |w| w.get_fd() }; | |
51 | 54 | let stdin_fd = std::io::stdin().as_raw_fd(); |
52 | 55 | |
53 | 56 | let mut fds = unsafe { std::mem::uninitialized() }; |
83 | 86 | unsafe { |
84 | 87 | // set up the FD set to be the X11 fd and the state of stdin |
85 | 88 | libc::FD_ZERO(&mut fds); |
86 |
|
|
89 | for fd in window_fds { | |
90 | libc::FD_SET(fd, &mut fds); | |
91 | } | |
87 | 92 | libc::FD_SET(stdin_fd, &mut fds); |
88 | 93 | timer.tv_sec = 5; |
89 | 94 |