gdritter repos knurling / 0defe33
Draw both windows in the correct place Getty Ritter 5 years ago
2 changed file(s) with 12 addition(s) and 15 deletion(s). Collapse all Expand all
1313 fn main() -> Result<(), failure::Error> {
1414 // set up the display and the window
1515 let mut d = Display::create()?;
16 let size = Size {
17 wd: d.get_width(),
18 // TODO: this should be a function of font size
19 ht: 36,
20 };
2116 let mut ws = Vec::new();
2217 for (x_off, wd) in d.get_widths()? {
23 let size = Size { wd, ht: 36 };
18 let size = Size { wd, ht: 36, xo: x_off, yo: 0 };
2419 let mut w = Window::create(&d, size)?;
2520 // set some window-manager properties: this is a dock
2621 w.change_property("_NET_WM_WINDOW_TYPE", &["_NET_WM_WINDOW_TYPE_DOCK"])?;
8479 // do an initial pass at drawing the bar!
8580 draw(&ctx, &layout, &input, w.size())?;
8681
87 ctxs.push((ctx, layout));
82 ctxs.push((ctx, layout, w.size()));
8883 }
8984
9085
120115 if input.len() == 0 {
121116 break;
122117 }
123 for (ctx, layout) in ctxs.iter() {
124 draw(&ctx, &layout, &input, size)?;
118 for (ctx, layout, sz) in ctxs.iter() {
119 draw(&ctx, &layout, &input, *sz)?;
125120 }
126121 }
127122
136131 }
137132 }
138133
139 for (ctx, layout) in ctxs.iter() {
134 for (ctx, layout, sz) in ctxs.iter() {
140135 // otherwise, draw the thing!
141 draw(&ctx, &layout, &input, size)?;
136 draw(&ctx, &layout, &input, *sz)?;
142137 }
143138 }
144139
88 pub struct Size {
99 pub wd: i32,
1010 pub ht: i32,
11 pub xo: i32,
12 pub yo: i32,
1113 }
1214
1315 pub struct Display {
7981 /// width and height
8082 pub fn create(
8183 display: &'t Display,
82 Size { wd: width, ht: height }: Size,
84 Size { wd: width, ht: height, xo, yo }: Size,
8385 ) -> Result<Window<'t>, failure::Error> {
8486 unsafe {
8587 let screen = display.screen;
8688 let window = xlib::XCreateSimpleWindow(
8789 display.display,
8890 xlib::XRootWindow(display.display, screen),
89 0,
90 0,
91 xo as i32,
92 yo as i32,
9193 width as u32,
9294 height as u32,
9395 1,
300302 }
301303
302304 pub fn size(&self) -> Size {
303 Size { wd: self.width, ht: self.height }
305 Size { wd: self.width, ht: self.height, xo: 0, yo: 0 }
304306 }
305307 }
306308