lmao we can actually type now
This commit is contained in:
parent
3ef4a2c9fc
commit
464f57f91d
29
src/main.rs
29
src/main.rs
|
@ -142,25 +142,18 @@ async fn main() -> Result<()> {
|
||||||
let mut mask = ModMask::new(false, false, true, false, false, false, false, false, false);
|
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 mut keyboard_state = KeyboardState::new_async(&mut conn).await?;
|
||||||
let keymap = keymap(&mut keyboard_state);
|
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())
|
XcrabError::Custom("At least one letter could not be found in the keymap".to_string())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
println!("got to this part");
|
for &binds in CONFIG.binds.keys() {
|
||||||
|
|
||||||
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 keysym in 97..122_u32 {
|
for keysym in 97..122_u32 {
|
||||||
let keycode = keymap.get(&keysym).ok_or_else(|| {
|
let keycode = keymap.get(&keysym).ok_or_else(|| {
|
||||||
XcrabError::Custom(
|
XcrabError::Custom(
|
||||||
"At least one letter could not be found in the keymap".to_string(),
|
"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())
|
.process_keycode(*keycode, KeyButMask::default())
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
XcrabError::Custom(
|
XcrabError::Custom(
|
||||||
|
@ -170,12 +163,10 @@ async fn main() -> Result<()> {
|
||||||
.as_char()
|
.as_char()
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
XcrabError::Custom("The processed Key could not be cast as a char".to_string())
|
XcrabError::Custom("The processed Key could not be cast as a char".to_string())
|
||||||
})?
|
})?;
|
||||||
== binds.key
|
if iter_char == binds.key {
|
||||||
{
|
request_key = *keycode;
|
||||||
request_key = keycode;
|
mask.inner = binds.mods.inner;
|
||||||
} else {
|
|
||||||
dbg!(binds.key.clone());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +177,7 @@ async fn main() -> Result<()> {
|
||||||
length: 4,
|
length: 4,
|
||||||
grab_window: root,
|
grab_window: root,
|
||||||
modifiers: mask,
|
modifiers: mask,
|
||||||
key: *request_key,
|
key: request_key,
|
||||||
pointer_mode: GrabMode::Async,
|
pointer_mode: GrabMode::Async,
|
||||||
keyboard_mode: GrabMode::Async,
|
keyboard_mode: GrabMode::Async,
|
||||||
})
|
})
|
||||||
|
@ -207,7 +198,7 @@ async fn main() -> Result<()> {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
biased;
|
biased;
|
||||||
Some(s) = recv.recv() => msg_listener::on_recv(s, &mut manager, &mut conn, &result_send).await?,
|
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(k) = keyboard_state.process_keycode(ev.detail, ev.state) {
|
||||||
if let Some(c) = k.as_char() {
|
if let Some(c) = k.as_char() {
|
||||||
for (&bind, action) in &CONFIG.binds {
|
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?;
|
action.eval(manager, conn).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,10 +242,7 @@ impl XcrabWindowManager {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(focus) = self.focused {
|
if let Some(focus) = self.focused {
|
||||||
let focused_key = self.clients.get(&focus).unwrap();
|
req.focus = focus;
|
||||||
let focused = self.rects.get(*focused_key).unwrap();
|
|
||||||
let focused_frame = focused.unwrap_client().frame;
|
|
||||||
req.focus = focused_frame.input;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.exchange_request_async(req).await?;
|
conn.exchange_request_async(req).await?;
|
||||||
|
@ -640,7 +637,6 @@ pub fn may_not_exist(res: breadx::Result) -> breadx::Result {
|
||||||
pub struct FramedWindow {
|
pub struct FramedWindow {
|
||||||
pub frame: Window,
|
pub frame: Window,
|
||||||
pub win: Window,
|
pub win: Window,
|
||||||
pub input: Window,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FramedWindow {
|
impl FramedWindow {
|
||||||
|
@ -700,27 +696,12 @@ impl FramedWindow {
|
||||||
.await,
|
.await,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.input
|
|
||||||
.configure_async(
|
|
||||||
conn,
|
|
||||||
ConfigureWindowParameters {
|
|
||||||
x: Some(0),
|
|
||||||
y: Some(0),
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
border_width: None,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn map<Dpy: AsyncDisplay + ?Sized>(self, conn: &mut Dpy) -> Result<()> {
|
async fn map<Dpy: AsyncDisplay + ?Sized>(self, conn: &mut Dpy) -> Result<()> {
|
||||||
may_not_exist(self.win.map_async(conn).await)?;
|
may_not_exist(self.win.map_async(conn).await)?;
|
||||||
self.frame.map_async(conn).await?;
|
self.frame.map_async(conn).await?;
|
||||||
self.input.map_async(conn).await?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -736,10 +717,6 @@ impl FramedWindow {
|
||||||
// no longer related to us, remove from save set
|
// no longer related to us, remove from save set
|
||||||
may_not_exist(self.win.change_save_set_async(conn, SetMode::Delete).await)?;
|
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?;
|
self.frame.free_async(conn).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -851,21 +828,6 @@ async fn frame<Dpy: AsyncDisplay + ?Sized>(conn: &mut Dpy, win: Window) -> Resul
|
||||||
)
|
)
|
||||||
.await?;
|
.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
|
frame
|
||||||
.set_event_mask_async(
|
.set_event_mask_async(
|
||||||
conn,
|
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)
|
win.set_event_mask_async(conn, EventMask::BUTTON_PRESS)
|
||||||
.await?;
|
.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.change_save_set_async(conn, SetMode::Insert).await)?;
|
||||||
|
|
||||||
may_not_exist(win.reparent_async(conn, frame, 0, 0).await)?;
|
may_not_exist(win.reparent_async(conn, frame, 0, 0).await)?;
|
||||||
|
|
||||||
Ok(FramedWindow { frame, win, input })
|
Ok(FramedWindow { frame, win })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue