Compare commits
1 Commits
diff_down
...
visual-key
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59651d9343 |
@@ -824,7 +824,7 @@ impl X11Client {
|
|||||||
Event::XkbStateNotify(event) => {
|
Event::XkbStateNotify(event) => {
|
||||||
let mut state = self.0.borrow_mut();
|
let mut state = self.0.borrow_mut();
|
||||||
state.xkb.update_mask(
|
state.xkb.update_mask(
|
||||||
event.base_mods.into(),
|
dbg!(event).base_mods.into(),
|
||||||
event.latched_mods.into(),
|
event.latched_mods.into(),
|
||||||
event.locked_mods.into(),
|
event.locked_mods.into(),
|
||||||
event.base_group as u32,
|
event.base_group as u32,
|
||||||
@@ -836,7 +836,7 @@ impl X11Client {
|
|||||||
latched_layout: event.latched_group as u32,
|
latched_layout: event.latched_group as u32,
|
||||||
locked_layout: event.locked_group.into(),
|
locked_layout: event.locked_group.into(),
|
||||||
};
|
};
|
||||||
let modifiers = Modifiers::from_xkb(&state.xkb);
|
let modifiers = dbg!(Modifiers::from_xkb(&state.xkb));
|
||||||
if state.modifiers == modifiers {
|
if state.modifiers == modifiers {
|
||||||
drop(state);
|
drop(state);
|
||||||
} else {
|
} else {
|
||||||
@@ -919,7 +919,7 @@ impl X11Client {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
Event::KeyRelease(event) => {
|
Event::KeyRelease(event) => {
|
||||||
let window = self.get_window(event.event)?;
|
let window = self.get_window(dbg!(event).event)?;
|
||||||
let mut state = self.0.borrow_mut();
|
let mut state = self.0.borrow_mut();
|
||||||
|
|
||||||
let modifiers = modifiers_from_state(event.state);
|
let modifiers = modifiers_from_state(event.state);
|
||||||
|
|||||||
@@ -3216,24 +3216,11 @@ impl<'a> WindowContext<'a> {
|
|||||||
self.draw();
|
self.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
let node_id = self
|
|
||||||
.window
|
|
||||||
.focus
|
|
||||||
.and_then(|focus_id| {
|
|
||||||
self.window
|
|
||||||
.rendered_frame
|
|
||||||
.dispatch_tree
|
|
||||||
.focusable_node_id(focus_id)
|
|
||||||
})
|
|
||||||
.unwrap_or_else(|| self.window.rendered_frame.dispatch_tree.root_node_id());
|
|
||||||
|
|
||||||
let dispatch_path = self
|
let dispatch_path = self
|
||||||
.window
|
.window
|
||||||
.rendered_frame
|
.rendered_frame
|
||||||
.dispatch_tree
|
.dispatch_tree
|
||||||
.dispatch_path(node_id);
|
.dispatch_path(self.focused_node_id());
|
||||||
|
|
||||||
let mut keystroke: Option<Keystroke> = None;
|
|
||||||
|
|
||||||
if let Some(event) = event.downcast_ref::<ModifiersChangedEvent>() {
|
if let Some(event) = event.downcast_ref::<ModifiersChangedEvent>() {
|
||||||
if event.modifiers.number_of_modifiers() == 0
|
if event.modifiers.number_of_modifiers() == 0
|
||||||
@@ -3249,30 +3236,36 @@ impl<'a> WindowContext<'a> {
|
|||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
if let Some(key) = key {
|
if let Some(key) = key {
|
||||||
keystroke = Some(Keystroke {
|
let keystroke = Keystroke {
|
||||||
key: key.to_string(),
|
key: key.to_string(),
|
||||||
ime_key: None,
|
ime_key: None,
|
||||||
modifiers: Modifiers::default(),
|
modifiers: Modifiers::default(),
|
||||||
});
|
};
|
||||||
|
self.finish_dispatch_keystroke(keystroke, &dispatch_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.window.pending_modifier.modifiers.number_of_modifiers() == 0
|
if self.window.pending_modifier.modifiers.number_of_modifiers() == 0
|
||||||
&& event.modifiers.number_of_modifiers() == 1
|
&& event.modifiers.number_of_modifiers() == 1
|
||||||
{
|
{
|
||||||
self.window.pending_modifier.saw_keystroke = false
|
self.window.pending_modifier.saw_keystroke = false;
|
||||||
}
|
}
|
||||||
self.window.pending_modifier.modifiers = event.modifiers
|
self.window.pending_modifier.modifiers = event.modifiers;
|
||||||
|
|
||||||
|
self.finish_dispatch_key_event(event, &dispatch_path);
|
||||||
} else if let Some(key_down_event) = event.downcast_ref::<KeyDownEvent>() {
|
} else if let Some(key_down_event) = event.downcast_ref::<KeyDownEvent>() {
|
||||||
self.window.pending_modifier.saw_keystroke = true;
|
self.window.pending_modifier.saw_keystroke = true;
|
||||||
keystroke = Some(key_down_event.keystroke.clone());
|
self.finish_dispatch_keystroke(key_down_event.keystroke.clone(), &dispatch_path);
|
||||||
|
} else {
|
||||||
|
self.finish_dispatch_key_event(event, &dispatch_path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let Some(keystroke) = keystroke else {
|
fn finish_dispatch_keystroke(
|
||||||
self.finish_dispatch_key_event(event, dispatch_path);
|
&self,
|
||||||
return;
|
keystroke: Keystroke,
|
||||||
};
|
dispatch_path: &SmallVec<[DispatchNodeId; 32]>,
|
||||||
|
) {
|
||||||
let mut currently_pending = self.window.pending_input.take().unwrap_or_default();
|
let mut currently_pending = self.window.pending_input.take().unwrap_or_default();
|
||||||
if currently_pending.focus.is_some() && currently_pending.focus != self.window.focus {
|
if currently_pending.focus.is_some() && currently_pending.focus != self.window.focus {
|
||||||
currently_pending = PendingInput::default();
|
currently_pending = PendingInput::default();
|
||||||
@@ -3306,7 +3299,8 @@ impl<'a> WindowContext<'a> {
|
|||||||
.window
|
.window
|
||||||
.rendered_frame
|
.rendered_frame
|
||||||
.dispatch_tree
|
.dispatch_tree
|
||||||
.dispatch_path(node_id);
|
// FIXME: valid?
|
||||||
|
.dispatch_path(cx.focused_node_id());
|
||||||
|
|
||||||
let to_replay = cx
|
let to_replay = cx
|
||||||
.window
|
.window
|
||||||
@@ -3334,13 +3328,13 @@ impl<'a> WindowContext<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.finish_dispatch_key_event(event, dispatch_path)
|
self.finish_dispatch_key_event(event, &dispatch_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finish_dispatch_key_event(
|
fn finish_dispatch_key_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
event: &dyn Any,
|
event: &dyn Any,
|
||||||
dispatch_path: SmallVec<[DispatchNodeId; 32]>,
|
dispatch_path: &SmallVec<[DispatchNodeId; 32]>,
|
||||||
) {
|
) {
|
||||||
self.dispatch_key_down_up_event(event, &dispatch_path);
|
self.dispatch_key_down_up_event(event, &dispatch_path);
|
||||||
if !self.propagate_event {
|
if !self.propagate_event {
|
||||||
|
|||||||
@@ -372,7 +372,7 @@ impl PickerDelegate for TabSwitcherDelegate {
|
|||||||
icon.color(git_status_color.unwrap_or_default())
|
icon.color(git_status_color.unwrap_or_default())
|
||||||
});
|
});
|
||||||
|
|
||||||
let indicator = render_item_indicator(tab_match.item.boxed_clone(), cx);
|
let indicator = render_item_indicator(tab_match.item.boxed_clone(), None, cx);
|
||||||
let indicator_color = if let Some(ref indicator) = indicator {
|
let indicator_color = if let Some(ref indicator) = indicator {
|
||||||
indicator.color
|
indicator.color
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ enum IndicatorKind {
|
|||||||
Dot,
|
Dot,
|
||||||
Bar,
|
Bar,
|
||||||
Icon(AnyIcon),
|
Icon(AnyIcon),
|
||||||
|
Character(char),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(IntoElement)]
|
#[derive(IntoElement)]
|
||||||
@@ -37,12 +38,18 @@ impl Indicator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn character(character: char) -> Self {
|
||||||
|
Self {
|
||||||
|
kind: IndicatorKind::Character(character),
|
||||||
|
color: Color::Default,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn color(mut self, color: Color) -> Self {
|
pub fn color(mut self, color: Color) -> Self {
|
||||||
self.color = color;
|
self.color = color;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for Indicator {
|
impl RenderOnce for Indicator {
|
||||||
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
||||||
let container = div().flex_none();
|
let container = div().flex_none();
|
||||||
@@ -60,6 +67,9 @@ impl RenderOnce for Indicator {
|
|||||||
.h_1p5()
|
.h_1p5()
|
||||||
.rounded_t_md()
|
.rounded_t_md()
|
||||||
.bg(self.color.color(cx)),
|
.bg(self.color.color(cx)),
|
||||||
|
IndicatorKind::Character(character) => container
|
||||||
|
.text_color(self.color.color(cx))
|
||||||
|
.child(character.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1835,6 +1835,18 @@ impl Pane {
|
|||||||
focus_handle: &FocusHandle,
|
focus_handle: &FocusHandle,
|
||||||
cx: &mut ViewContext<'_, Pane>,
|
cx: &mut ViewContext<'_, Pane>,
|
||||||
) -> impl IntoElement {
|
) -> impl IntoElement {
|
||||||
|
let pending_keystrokes = cx.pending_input_keystrokes().unwrap_or(&[]);
|
||||||
|
let char_to_type = cx.bindings_for_action(&ActivateItem(ix)).iter().find_map(
|
||||||
|
|keybinding| match keybinding.remaining_keystrokes(pending_keystrokes) {
|
||||||
|
Some([keystroke])
|
||||||
|
if keystroke.modifiers == cx.modifiers() && keystroke.key.len() == 1 =>
|
||||||
|
{
|
||||||
|
keystroke.key.chars().next()
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let project_path = item.project_path(cx);
|
let project_path = item.project_path(cx);
|
||||||
|
|
||||||
let is_active = ix == self.active_item_index;
|
let is_active = ix == self.active_item_index;
|
||||||
@@ -1866,7 +1878,7 @@ impl Pane {
|
|||||||
|
|
||||||
let icon = item.tab_icon(cx);
|
let icon = item.tab_icon(cx);
|
||||||
let close_side = &ItemSettings::get_global(cx).close_position;
|
let close_side = &ItemSettings::get_global(cx).close_position;
|
||||||
let indicator = render_item_indicator(item.boxed_clone(), cx);
|
let indicator = render_item_indicator(item.boxed_clone(), char_to_type, cx);
|
||||||
let item_id = item.item_id();
|
let item_id = item.item_id();
|
||||||
let is_first_item = ix == 0;
|
let is_first_item = ix == 0;
|
||||||
let is_last_item = ix == self.items.len() - 1;
|
let is_last_item = ix == self.items.len() - 1;
|
||||||
@@ -2997,16 +3009,22 @@ pub fn tab_details(items: &[Box<dyn ItemHandle>], cx: &AppContext) -> Vec<usize>
|
|||||||
tab_details
|
tab_details
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_item_indicator(item: Box<dyn ItemHandle>, cx: &WindowContext) -> Option<Indicator> {
|
pub fn render_item_indicator(
|
||||||
maybe!({
|
item: Box<dyn ItemHandle>,
|
||||||
let indicator_color = match (item.has_conflict(cx), item.is_dirty(cx)) {
|
char_to_type: Option<char>,
|
||||||
(true, _) => Color::Warning,
|
cx: &WindowContext,
|
||||||
(_, true) => Color::Accent,
|
) -> Option<Indicator> {
|
||||||
(false, false) => return None,
|
if let Some(char) = char_to_type {
|
||||||
};
|
return Some(Indicator::character(char));
|
||||||
|
}
|
||||||
|
|
||||||
Some(Indicator::dot().color(indicator_color))
|
let indicator_color = match (item.has_conflict(cx), item.is_dirty(cx)) {
|
||||||
})
|
(true, _) => Color::Warning,
|
||||||
|
(_, true) => Color::Accent,
|
||||||
|
(false, false) => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(Indicator::dot().color(indicator_color))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for DraggedTab {
|
impl Render for DraggedTab {
|
||||||
|
|||||||
Reference in New Issue
Block a user