draw 2 rectangles to prevent the white rectangle from being invisible on
white backgrounds
This commit is contained in:
parent
f7b5288d03
commit
00d66f9712
3 changed files with 26 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -250,7 +250,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "leanshot"
|
name = "leanshot"
|
||||||
version = "0.4.0-rc"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"image",
|
"image",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "leanshot"
|
name = "leanshot"
|
||||||
description = "Screenshot capture for Linux."
|
description = "Screenshot capture for Linux."
|
||||||
version = "0.4.0-rc"
|
version = "0.4.0"
|
||||||
repository = "https://git.mzhang.io/michael/leanshot"
|
repository = "https://git.mzhang.io/michael/leanshot"
|
||||||
license-file = "LICENSE"
|
license-file = "LICENSE"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
28
src/gui.rs
28
src/gui.rs
|
@ -140,7 +140,7 @@ impl Gui {
|
||||||
&[
|
&[
|
||||||
(xcb::GC_FOREGROUND, screen.white_pixel()),
|
(xcb::GC_FOREGROUND, screen.white_pixel()),
|
||||||
(xcb::GC_BACKGROUND, screen.white_pixel()),
|
(xcb::GC_BACKGROUND, screen.white_pixel()),
|
||||||
(xcb::GC_LINE_WIDTH, 3),
|
(xcb::GC_LINE_WIDTH, 1),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -175,18 +175,38 @@ impl Gui {
|
||||||
let mut state = State::default();
|
let mut state = State::default();
|
||||||
let mut cancelled = false;
|
let mut cancelled = false;
|
||||||
|
|
||||||
let redraw = |state: &State| {
|
let redraw = |state: &State| -> Result<()> {
|
||||||
xcb_image::put(&self.conn, window_id, window_gc, &image.image, 0, 0);
|
xcb_image::put(&self.conn, window_id, window_gc, &image.image, 0, 0);
|
||||||
|
|
||||||
if state.dragging {
|
if state.dragging {
|
||||||
let rect = state.rect();
|
let rect = state.rect();
|
||||||
|
xproto::change_gc(
|
||||||
|
&self.conn,
|
||||||
|
window_gc,
|
||||||
|
&[(xcb::GC_FOREGROUND, screen.black_pixel())],
|
||||||
|
);
|
||||||
xproto::poly_rectangle(&self.conn, window_id, window_gc, &[rect]);
|
xproto::poly_rectangle(&self.conn, window_id, window_gc, &[rect]);
|
||||||
|
|
||||||
|
let rect2 = Rectangle::new(
|
||||||
|
rect.x() + 1,
|
||||||
|
rect.y() + 1,
|
||||||
|
rect.width() - 2,
|
||||||
|
rect.height() - 2,
|
||||||
|
);
|
||||||
|
xproto::change_gc(
|
||||||
|
&self.conn,
|
||||||
|
window_gc,
|
||||||
|
&[(xcb::GC_FOREGROUND, screen.white_pixel())],
|
||||||
|
);
|
||||||
|
xproto::poly_rectangle(&self.conn, window_id, window_gc, &[rect2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.conn.flush();
|
self.conn.flush();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
redraw(&state);
|
redraw(&state)?;
|
||||||
|
|
||||||
while let Some(evt) = self.conn.wait_for_event() {
|
while let Some(evt) = self.conn.wait_for_event() {
|
||||||
match evt.response_type() {
|
match evt.response_type() {
|
||||||
|
@ -234,7 +254,7 @@ impl Gui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
redraw(&state);
|
redraw(&state)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Loop exited, cleaning up...");
|
info!("Loop exited, cleaning up...");
|
||||||
|
|
Loading…
Reference in a new issue