Skip to content

Commit

Permalink
Rip out the old code-path for modifier state tracking on X11
Browse files Browse the repository at this point in the history
  • Loading branch information
maroider committed Jul 7, 2022
1 parent 0d5ae7c commit 6c7820e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 244 deletions.
47 changes: 0 additions & 47 deletions src/platform_impl/linux/x11/event_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use super::{
GenericEventCookie, ImeReceiver, ScrollOrientation, UnownedWindow, WindowId, XExtension,
};

use util::modifiers::{ModifierKeyState, ModifierKeymap};

use crate::platform_impl::platform::x11::ime::{ImeEvent, ImeEventReceiver, ImeRequest};
use crate::{
dpi::{PhysicalPosition, PhysicalSize},
Expand Down Expand Up @@ -38,8 +36,6 @@ pub(super) struct EventProcessor<T: 'static> {
pub(super) xkbext: XExtension,
pub(super) target: Rc<RootELW<T>>,
pub(super) kb_state: KbState,
pub(super) mod_keymap: ModifierKeymap,
pub(super) device_mod_state: ModifierKeyState,
pub(super) pending_mod_change: Option<ModifiersState>,
// Number of touch events currently in progress
pub(super) num_touch: u32,
Expand Down Expand Up @@ -142,16 +138,6 @@ impl<T: 'static> EventProcessor<T> {
return;
}

macro_rules! assert_mods_eq {
($old:expr, $new:expr) => {
if $old != $new {
println!("New modifier tracking differed from the old one.");
println!("Old: {:?}", $old);
println!("New: {:?}", $new);
}
}
}

let event_type = xev.get_type();
match event_type {
ffi::ClientMessage => {
Expand Down Expand Up @@ -594,9 +580,7 @@ impl<T: 'static> EventProcessor<T> {
return;
}

let old_modifiers = ModifiersState::from_x11(&xev.mods);
let modifiers = self.kb_state.mods_state().into();
assert_mods_eq!(old_modifiers, modifiers);

let state = if xev.evtype == ffi::XI_ButtonPress {
Pressed
Expand Down Expand Up @@ -672,9 +656,7 @@ impl<T: 'static> EventProcessor<T> {
let window_id = mkwid(xev.event);
let new_cursor_pos = (xev.event_x, xev.event_y);

let old_modifiers = ModifiersState::from_x11(&xev.mods);
let modifiers = self.kb_state.mods_state().into();
assert_mods_eq!(old_modifiers, modifiers);

let cursor_moved = self.with_window(xev.event, |window| {
let mut shared_state_lock = window.shared_state.lock();
Expand Down Expand Up @@ -835,10 +817,7 @@ impl<T: 'static> EventProcessor<T> {
.focus(xev.event)
.expect("Failed to focus input context");

let old_modifiers = ModifiersState::from_x11(&xev.mods);
self.device_mod_state.update_state(&old_modifiers, None);
let modifiers = self.kb_state.mods_state().into();
assert_mods_eq!(old_modifiers, modifiers);

if self.active_window != Some(xev.event) {
self.active_window = Some(xev.event);
Expand Down Expand Up @@ -884,8 +863,6 @@ impl<T: 'static> EventProcessor<T> {
window_id,
ElementState::Pressed,
&mut self.kb_state,
&self.mod_keymap,
&mut self.device_mod_state,
&mut callback,
);
}
Expand All @@ -912,8 +889,6 @@ impl<T: 'static> EventProcessor<T> {
window_id,
ElementState::Released,
&mut self.kb_state,
&self.mod_keymap,
&mut self.device_mod_state,
&mut callback,
);

Expand All @@ -940,9 +915,7 @@ impl<T: 'static> EventProcessor<T> {
};
if self.window_exists(xev.event) {
let id = xev.detail as u64;
let old_modifiers = ModifiersState::from_x11(&xev.mods);
let modifiers = self.kb_state.mods_state().into();
assert_mods_eq!(old_modifiers, modifiers);
let location =
PhysicalPosition::new(xev.event_x as f64, xev.event_y as f64);

Expand Down Expand Up @@ -1113,16 +1086,6 @@ impl<T: 'static> EventProcessor<T> {
state,
}),
});

if let Some(modifier) =
self.mod_keymap.get_modifier(keycode as ffi::KeyCode)
{
self.device_mod_state.key_event(
state,
keycode as ffi::KeyCode,
modifier,
);
}
}

ffi::XI_HierarchyChanged => {
Expand Down Expand Up @@ -1330,8 +1293,6 @@ impl<T: 'static> EventProcessor<T> {
window_id: crate::window::WindowId,
state: ElementState,
kb_state: &mut KbState,
mod_keymap: &ModifierKeymap,
device_mod_state: &mut ModifierKeyState,
callback: &mut F,
) where
F: FnMut(Event<'_, T>),
Expand All @@ -1354,14 +1315,6 @@ impl<T: 'static> EventProcessor<T> {
let (key_without_modifiers, _) = ker.key_without_modifiers();
let text_with_all_modifiers = ker.text_with_all_modifiers();

if let Some(modifier) = mod_keymap.get_modifier(keycode as ffi::KeyCode) {
device_mod_state.key_event(
ElementState::Pressed,
keycode as ffi::KeyCode,
modifier,
);
}

callback(Event::WindowEvent {
window_id,
event: WindowEvent::KeyboardInput {
Expand Down
6 changes: 0 additions & 6 deletions src/platform_impl/linux/x11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ use self::{
dnd::{Dnd, DndState},
event_processor::EventProcessor,
ime::{Ime, ImeCreationError, ImeReceiver, ImeRequest, ImeSender},
util::modifiers::ModifierKeymap,
};
use super::common::xkb_state::KbState;
use crate::{
Expand Down Expand Up @@ -241,9 +240,6 @@ impl<T: 'static> EventLoop<T> {

xconn.update_cached_wm_info(root);

let mut mod_keymap = ModifierKeymap::new();
mod_keymap.reset_from_x_connection(&xconn);

let poll = Poll::new().unwrap();
let waker = Arc::new(Waker::new(poll.registry(), USER_REDRAW_TOKEN).unwrap());

Expand Down Expand Up @@ -292,8 +288,6 @@ impl<T: 'static> EventLoop<T> {
xi2ext,
xkbext,
kb_state,
mod_keymap,
device_mod_state: Default::default(),
pending_mod_change: Default::default(),
num_touch: 0,
first_touch: None,
Expand Down
1 change: 0 additions & 1 deletion src/platform_impl/linux/x11/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ mod icon;
mod input;
pub mod keys;
mod memory;
pub mod modifiers;
mod randr;
mod window_property;
mod wm;
Expand Down
190 changes: 0 additions & 190 deletions src/platform_impl/linux/x11/util/modifiers.rs

This file was deleted.

0 comments on commit 6c7820e

Please sign in to comment.