lmao we can actually type now

This commit is contained in:
Akshat Deshpande 2022-08-01 12:59:02 -05:00
parent 3ef4a2c9fc
commit 464f57f91d
2 changed files with 12 additions and 71 deletions

View file

@ -142,25 +142,18 @@ async fn main() -> Result<()> {
let mut mask = ModMask::new(false, false, true, false, false, false, false, false, false);
let mut keyboard_state = KeyboardState::new_async(&mut conn).await?;
let keymap = keymap(&mut keyboard_state);
let mut request_key = keymap.get(&120).ok_or_else(|| {
let mut request_key = *keymap.get(&120).ok_or_else(|| {
XcrabError::Custom("At least one letter could not be found in the keymap".to_string())
})?;
println!("got to this part");
for (&binds, _action) in &CONFIG.binds {
println!("started iteration");
mask.set_control(binds.mods.control());
mask.set_shift(binds.mods.shift());
mask.set_One(binds.mods.mod1());
mask.set_Four(binds.mods.mod4());
for &binds in CONFIG.binds.keys() {
for keysym in 97..122_u32 {
let keycode = keymap.get(&keysym).ok_or_else(|| {
XcrabError::Custom(
"At least one letter could not be found in the keymap".to_string(),
)
})?;
if keyboard_state
let iter_char = keyboard_state
.process_keycode(*keycode, KeyButMask::default())
.ok_or_else(|| {
XcrabError::Custom(
@ -170,12 +163,10 @@ async fn main() -> Result<()> {
.as_char()
.ok_or_else(|| {
XcrabError::Custom("The processed Key could not be cast as a char".to_string())
})?
== binds.key
{
request_key = keycode;
} else {
dbg!(binds.key.clone());
})?;
if iter_char == binds.key {
request_key = *keycode;
mask.inner = binds.mods.inner;
}
}
}
@ -186,7 +177,7 @@ async fn main() -> Result<()> {
length: 4,
grab_window: root,
modifiers: mask,
key: *request_key,
key: request_key,
pointer_mode: GrabMode::Async,
keyboard_mode: GrabMode::Async,
})
@ -207,7 +198,7 @@ async fn main() -> Result<()> {
tokio::select! {
biased;
Some(s) = recv.recv() => msg_listener::on_recv(s, &mut manager, &mut conn, &result_send).await?,
Ok(ev) = conn.wait_for_event_async() => process_event(ev, &mut manager, &mut conn, root,&mut keyboard_state).await?,
Ok(ev) = conn.wait_for_event_async() => process_event(ev, &mut manager, &mut conn, root, &mut keyboard_state).await?,
}
}
}
@ -263,7 +254,7 @@ async fn process_event<Dpy: AsyncDisplay + ?Sized>(
if let Some(k) = keyboard_state.process_keycode(ev.detail, ev.state) {
if let Some(c) = k.as_char() {
for (&bind, action) in &CONFIG.binds {
if bind.key == c && bind.mods == ev.state {
if bind.key == c && bind.mods.inner == 20 {
action.eval(manager, conn).await?;
}
}

View file

@ -242,10 +242,7 @@ impl XcrabWindowManager {
};
if let Some(focus) = self.focused {
let focused_key = self.clients.get(&focus).unwrap();
let focused = self.rects.get(*focused_key).unwrap();
let focused_frame = focused.unwrap_client().frame;
req.focus = focused_frame.input;
req.focus = focus;
}
conn.exchange_request_async(req).await?;
@ -640,7 +637,6 @@ pub fn may_not_exist(res: breadx::Result) -> breadx::Result {
pub struct FramedWindow {
pub frame: Window,
pub win: Window,
pub input: Window,
}
impl FramedWindow {
@ -700,27 +696,12 @@ impl FramedWindow {
.await,
)?;
self.input
.configure_async(
conn,
ConfigureWindowParameters {
x: Some(0),
y: Some(0),
width,
height,
border_width: None,
..Default::default()
},
)
.await?;
Ok(())
}
async fn map<Dpy: AsyncDisplay + ?Sized>(self, conn: &mut Dpy) -> Result<()> {
may_not_exist(self.win.map_async(conn).await)?;
self.frame.map_async(conn).await?;
self.input.map_async(conn).await?;
Ok(())
}
@ -736,10 +717,6 @@ impl FramedWindow {
// no longer related to us, remove from save set
may_not_exist(self.win.change_save_set_async(conn, SetMode::Delete).await)?;
self.input.unmap_async(conn).await?;
self.input.free_async(conn).await?;
self.frame.free_async(conn).await?;
Ok(())
@ -851,21 +828,6 @@ async fn frame<Dpy: AsyncDisplay + ?Sized>(conn: &mut Dpy, win: Window) -> Resul
)
.await?;
let input = conn
.create_window_async(
frame,
breadx::WindowClass::InputOnly,
None,
Some(conn.default_visual_id()),
0,
0,
geometry.width,
geometry.height,
0,
WindowParameters::default(),
)
.await?;
frame
.set_event_mask_async(
conn,
@ -876,21 +838,9 @@ async fn frame<Dpy: AsyncDisplay + ?Sized>(conn: &mut Dpy, win: Window) -> Resul
win.set_event_mask_async(conn, EventMask::BUTTON_PRESS)
.await?;
input
.set_event_mask_async(
conn,
EventMask::BUTTON_PRESS
| EventMask::BUTTON_RELEASE
| EventMask::KEY_PRESS
| EventMask::KEY_RELEASE
| EventMask::ENTER_WINDOW
| EventMask::LEAVE_WINDOW,
)
.await?;
may_not_exist(win.change_save_set_async(conn, SetMode::Insert).await)?;
may_not_exist(win.reparent_async(conn, frame, 0, 0).await)?;
Ok(FramedWindow { frame, win, input })
Ok(FramedWindow { frame, win })
}