Skip to content

Commit

Permalink
Handle all must_uses
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
  • Loading branch information
SUPERCILEX committed Aug 2, 2024
1 parent 6a6ad23 commit b955eb6
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 103 deletions.
16 changes: 8 additions & 8 deletions cairo-example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ where
{
let window = conn.generate_id()?;
let colormap = conn.generate_id()?;
conn.create_colormap(ColormapAlloc::NONE, colormap, screen.root, visual_id)?;
let _ = conn.create_colormap(ColormapAlloc::NONE, colormap, screen.root, visual_id)?;
let win_aux = CreateWindowAux::new()
.event_mask(EventMask::EXPOSURE | EventMask::STRUCTURE_NOTIFY)
.background_pixel(x11rb::NONE)
.border_pixel(screen.black_pixel)
.colormap(colormap);
conn.create_window(
let _ = conn.create_window(
depth,
window,
screen.root,
Expand All @@ -155,36 +155,36 @@ where
)?;

let title = "Simple Window";
conn.change_property8(
let _ = conn.change_property8(
PropMode::REPLACE,
window,
AtomEnum::WM_NAME,
AtomEnum::STRING,
title.as_bytes(),
)?;
conn.change_property8(
let _ = conn.change_property8(
PropMode::REPLACE,
window,
atoms._NET_WM_NAME,
atoms.UTF8_STRING,
title.as_bytes(),
)?;
conn.change_property32(
let _ = conn.change_property32(
PropMode::REPLACE,
window,
atoms.WM_PROTOCOLS,
AtomEnum::ATOM,
&[atoms.WM_DELETE_WINDOW],
)?;
conn.change_property8(
let _ = conn.change_property8(
PropMode::REPLACE,
window,
AtomEnum::WM_CLASS,
AtomEnum::STRING,
b"simple_window\0simple_window\0",
)?;

conn.map_window(window)?;
let _ = conn.map_window(window)?;
Ok(window)
}

Expand Down Expand Up @@ -268,7 +268,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
width.into(),
height.into(),
)
.unwrap();
.unwrap();

loop {
conn.flush()?;
Expand Down
14 changes: 7 additions & 7 deletions x11rb/examples/display_ppm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ fn create_window(
let pixmap_id = conn.generate_id()?;
let gc_id = conn.generate_id()?;

conn.create_gc(
let _ = conn.create_gc(
gc_id,
screen.root,
&CreateGCAux::default().graphics_exposures(0),
)?;
conn.create_pixmap(
let _ = conn.create_pixmap(
screen.root_depth,
pixmap_id,
screen.root,
image.width(),
image.height(),
)?;
image.put(conn, pixmap_id, gc_id, 0, 0)?;
conn.free_gc(gc_id)?;
let _ = conn.free_gc(gc_id)?;

conn.create_window(
let _ = conn.create_window(
screen.root_depth,
win_id,
screen.root,
Expand All @@ -57,9 +57,9 @@ fn create_window(
0,
&CreateWindowAux::default().background_pixmap(pixmap_id),
)?;
conn.free_pixmap(pixmap_id)?;
let _ = conn.free_pixmap(pixmap_id)?;

conn.change_property32(
let _ = conn.change_property32(
PropMode::REPLACE,
win_id,
atoms.WM_PROTOCOLS,
Expand Down Expand Up @@ -137,7 +137,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

let atoms = Atoms::new(conn)?.reply()?;
let win_id = create_window(conn, screen, &atoms, &image)?;
conn.map_window(win_id)?;
let _ = conn.map_window(win_id)?;

util::start_timeout_thread(conn1.clone(), win_id);

Expand Down
22 changes: 11 additions & 11 deletions x11rb/examples/hypnomoire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let white = conn.generate_id()?;
let black = conn.generate_id()?;

conn.create_gc(
let _ = conn.create_gc(
white,
screen.root,
&CreateGCAux::new()
.graphics_exposures(0)
.foreground(screen.white_pixel),
)?;
conn.create_gc(
let _ = conn.create_gc(
black,
screen.root,
&CreateGCAux::new()
Expand Down Expand Up @@ -93,7 +93,7 @@ fn run<C: Connection>(
guard.angle_velocity = 0.05;
}

conn.create_window(
let _ = conn.create_window(
COPY_DEPTH_FROM_PARENT,
window,
screen.root,
Expand All @@ -111,16 +111,16 @@ fn run<C: Connection>(
)
.do_not_propogate_mask(EventMask::BUTTON_PRESS),
)?;
conn.change_property32(
let _ = conn.change_property32(
PropMode::REPLACE,
window,
wm_protocols,
AtomEnum::ATOM,
&[wm_delete_window],
)?;
conn.map_window(window)?;
let _ = conn.map_window(window)?;

conn.create_pixmap(
let _ = conn.create_pixmap(
screen.root_depth,
pixmap,
window,
Expand All @@ -133,7 +133,7 @@ fn run<C: Connection>(
width: default_size,
height: default_size,
};
conn.poly_fill_rectangle(pixmap, white, &[rect])?;
let _ = conn.poly_fill_rectangle(pixmap, white, &[rect])?;

let mut theta: f64 = 0.0;
let radius = f64::from(default_size) + 1.0;
Expand All @@ -151,7 +151,7 @@ fn run<C: Connection>(
},
Point { x, y },
];
conn.poly_line(CoordMode::PREVIOUS, pixmap, black, &lines)?;
let _ = conn.poly_line(CoordMode::PREVIOUS, pixmap, black, &lines)?;

let (sin, cos) = (theta + LAG).sin_cos();
let (x, y) = ((radius * cos) as i16, (radius * sin) as i16);
Expand All @@ -162,9 +162,9 @@ fn run<C: Connection>(
},
Point { x, y },
];
conn.poly_line(CoordMode::PREVIOUS, pixmap, white, &lines)?;
let _ = conn.poly_line(CoordMode::PREVIOUS, pixmap, white, &lines)?;

conn.copy_area(
let _ = conn.copy_area(
pixmap,
window,
white,
Expand Down Expand Up @@ -209,7 +209,7 @@ where
Event::Expose(event) => {
if let Some(state) = find_window_by_id(&windows, event.window) {
let state = state.lock().unwrap();
conn.copy_area(
let _ = conn.copy_area(
state.pixmap,
state.window,
white,
Expand Down
40 changes: 20 additions & 20 deletions x11rb/examples/simple_window_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ impl<'a, C: Connection> WmState<'a, C> {
let screen = &conn.setup().roots[screen_num];
let black_gc = conn.generate_id()?;
let font = conn.generate_id()?;
conn.open_font(font, b"9x15")?;
let _ = conn.open_font(font, b"9x15")?;

let gc_aux = CreateGCAux::new()
.graphics_exposures(0)
.background(screen.white_pixel)
.foreground(screen.black_pixel)
.font(font);
conn.create_gc(black_gc, screen.root, &gc_aux)?;
conn.close_font(font)?;
let _ = conn.create_gc(black_gc, screen.root, &gc_aux)?;
let _ = conn.close_font(font)?;

let wm_protocols = conn.intern_atom(false, b"WM_PROTOCOLS")?;
let wm_delete_window = conn.intern_atom(false, b"WM_DELETE_WINDOW")?;
Expand Down Expand Up @@ -137,7 +137,7 @@ impl<'a, C: Connection> WmState<'a, C> {
| EventMask::ENTER_WINDOW,
)
.background_pixel(screen.white_pixel);
self.conn.create_window(
let _ = self.conn.create_window(
COPY_DEPTH_FROM_PARENT,
frame_win,
screen.root,
Expand All @@ -151,14 +151,14 @@ impl<'a, C: Connection> WmState<'a, C> {
&win_aux,
)?;

self.conn.grab_server()?;
self.conn.change_save_set(SetMode::INSERT, win)?;
let _ = self.conn.grab_server()?;
let _ = self.conn.change_save_set(SetMode::INSERT, win)?;
let cookie = self
.conn
.reparent_window(win, frame_win, 0, TITLEBAR_HEIGHT as _)?;
self.conn.map_window(win)?;
self.conn.map_window(frame_win)?;
self.conn.ungrab_server()?;
let _ = self.conn.map_window(win)?;
let _ = self.conn.map_window(frame_win)?;
let _ = self.conn.ungrab_server()?;

self.windows.push(WindowState::new(win, frame_win, geom));

Expand All @@ -174,7 +174,7 @@ impl<'a, C: Connection> WmState<'a, C> {
/// Draw the titlebar of a window
fn redraw_titlebar(&self, state: &WindowState) -> Result<(), ReplyError> {
let close_x = state.close_x_position();
self.conn.poly_line(
let _ = self.conn.poly_line(
CoordMode::ORIGIN,
state.frame_window,
self.black_gc,
Expand All @@ -186,7 +186,7 @@ impl<'a, C: Connection> WmState<'a, C> {
},
],
)?;
self.conn.poly_line(
let _ = self.conn.poly_line(
CoordMode::ORIGIN,
state.frame_window,
self.black_gc,
Expand All @@ -212,7 +212,7 @@ impl<'a, C: Connection> WmState<'a, C> {
u32::MAX,
)?
.reply()?;
self.conn
let _ = self.conn
.image_text8(state.frame_window, self.black_gc, 1, 10, &reply.value)?;
Ok(())
}
Expand Down Expand Up @@ -289,10 +289,10 @@ impl<'a, C: Connection> WmState<'a, C> {
if state.window != event.window {
return true;
}
conn.change_save_set(SetMode::DELETE, state.window).unwrap();
conn.reparent_window(state.window, root, state.x, state.y)
let _ = conn.change_save_set(SetMode::DELETE, state.window).unwrap();
let _ = conn.reparent_window(state.window, root, state.x, state.y)
.unwrap();
conn.destroy_window(state.frame_window).unwrap();
let _ = conn.destroy_window(state.frame_window).unwrap();
false
});
}
Expand All @@ -307,7 +307,7 @@ impl<'a, C: Connection> WmState<'a, C> {
.sibling(None)
.stack_mode(None);
println!("Configure: {:?}", aux);
self.conn.configure_window(event.window, &aux)?;
let _ = self.conn.configure_window(event.window, &aux)?;
Ok(())
}

Expand All @@ -325,10 +325,10 @@ impl<'a, C: Connection> WmState<'a, C> {
fn handle_enter(&mut self, event: EnterNotifyEvent) -> Result<(), ReplyError> {
if let Some(state) = self.find_window_by_id(event.event) {
// Set the input focus (ignoring ICCCM's WM_PROTOCOLS / WM_TAKE_FOCUS)
self.conn
let _ = self.conn
.set_input_focus(InputFocus::PARENT, state.window, CURRENT_TIME)?;
// Also raise the window to the top of the stacking order
self.conn.configure_window(
let _ = self.conn.configure_window(
state.frame_window,
&ConfigureWindowAux::new().stack_mode(StackMode::ABOVE),
)?;
Expand Down Expand Up @@ -360,7 +360,7 @@ impl<'a, C: Connection> WmState<'a, C> {
self.wm_protocols,
[self.wm_delete_window, 0, 0, 0, 0],
);
self.conn
let _ = self.conn
.send_event(false, state.window, EventMask::NO_EVENT, event)?;
}
}
Expand All @@ -372,7 +372,7 @@ impl<'a, C: Connection> WmState<'a, C> {
let (x, y) = (x + event.root_x, y + event.root_y);
// Sigh, X11 and its mixing up i16 and i32
let (x, y) = (x as i32, y as i32);
self.conn
let _ = self.conn
.configure_window(win, &ConfigureWindowAux::new().x(x).y(y))?;
}
Ok(())
Expand Down
Loading

0 comments on commit b955eb6

Please sign in to comment.