Skip to content

Commit

Permalink
Move ungrab_escape_key into lib
Browse files Browse the repository at this point in the history
  • Loading branch information
expectocode committed Mar 21, 2020
1 parent 8568822 commit 92bd039
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ pub fn grab_escape_key(conn: &xcb::Connection, root: u32) {
);
}

pub fn ungrab_escape_key(conn: &xcb::Connection, root: u32) {
xcb::ungrab_key(&conn, 9, root, xcb::NONE as u16);
}

fn viewable(conn: &xcb::Connection, win: xcb::Window) -> bool {
let attrs = xcb::get_window_attributes(conn, win).get_reply().unwrap();
(attrs.map_state() & xcb::MAP_STATE_VIEWABLE as u8) != 0
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ mod lib;

use lib::parse_args::Opt;
use lib::{
get_window_at_point, get_window_geom, grab_pointer_set_cursor, set_shape,
set_title, HacksawResult, CURSOR_GRAB_TRIES, grab_escape_key,
get_window_at_point, get_window_geom, grab_escape_key, grab_pointer_set_cursor, set_shape,
set_title, ungrab_escape_key, HacksawResult, CURSOR_GRAB_TRIES,
};
use structopt::StructOpt;

Expand Down Expand Up @@ -204,7 +204,7 @@ fn main() -> Result<(), String> {
}

xcb::ungrab_pointer(&conn, xcb::CURRENT_TIME);
xcb::ungrab_key(&conn, 9, window, xcb::MOD_MASK_ANY as u16);
ungrab_escape_key(&conn, root);
xcb::unmap_window(&conn, window);
xcb::destroy_window(&conn, window);
conn.flush();
Expand Down

0 comments on commit 92bd039

Please sign in to comment.