Skip to content

Commit

Permalink
fix(ux): make the Zellij mouse interaction work
Browse files Browse the repository at this point in the history
  • Loading branch information
imsnif committed Jan 9, 2025
1 parent 0d5c8ce commit f7a5115
Show file tree
Hide file tree
Showing 3 changed files with 262 additions and 74 deletions.
18 changes: 17 additions & 1 deletion zellij-server/src/panes/terminal_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::fmt::Debug;
use std::rc::Rc;
use std::time::{self, Instant};
use zellij_utils::input::command::RunCommand;
use zellij_utils::input::mouse::MouseEvent;
use zellij_utils::input::mouse::{MouseEvent, MouseEventType};
use zellij_utils::pane_size::Offset;
use zellij_utils::{
data::{
Expand Down Expand Up @@ -846,6 +846,22 @@ impl Pane for TerminalPane {
}
}
false
}
fn intercept_mouse_event_on_frame(&mut self, event: &MouseEvent, client_id: ClientId) -> bool {
if self.position_is_on_frame(&event.position) {
let relative_position = self.relative_position(&event.position);
if let MouseEventType::Press = event.event_type {
if let Some(client_frame) = self.frame.get_mut(&client_id) {
if client_frame.clicked_on_pinned(relative_position) {
self.toggle_pinned();
return true;
}
}
}
}
false


}
fn reset_logical_position(&mut self) {
self.geom.logical_position = None;
Expand Down
11 changes: 7 additions & 4 deletions zellij-server/src/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3233,6 +3233,7 @@ pub(crate) fn screen_thread_main(
screen.unblock_input()?;
screen.log_and_report_session_state()?;
},
// TODO: remove these and other mouse events we're no longer using
ScreenInstruction::ScrollUpAt(point, client_id) => {
active_tab_and_connected_client_id!(
screen,
Expand Down Expand Up @@ -3715,10 +3716,12 @@ pub(crate) fn screen_thread_main(
screen.unblock_input()?;
},
ScreenInstruction::LeftMouseRelease(point, client_id) => {
active_tab!(screen, client_id, |tab: &mut Tab| tab
.handle_left_mouse_release(&point, client_id), ?);
screen.render(None)?;
screen.unblock_input()?;
// TODO: make sure this is not used anywhere and then delete it and other similar
// outdated events
// active_tab!(screen, client_id, |tab: &mut Tab| tab
// .handle_left_mouse_release(&point, client_id), ?);
// screen.render(None)?;
// screen.unblock_input()?;
},
ScreenInstruction::RightMouseRelease(point, client_id) => {
active_tab!(screen, client_id, |tab: &mut Tab| tab
Expand Down
Loading

0 comments on commit f7a5115

Please sign in to comment.