-
-
Notifications
You must be signed in to change notification settings - Fork 816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for OSC 22 control sequence to change mouse cursor shape #6292
base: main
Are you sure you want to change the base?
Changes from all commits
278dfdd
20ce388
9587cf6
b67cf84
683d134
0cd76fc
11cf8b6
2251204
94b5acb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,7 @@ | ||||||
use crate::tabbar::TabBarItem; | ||||||
use crate::termwindow::{ | ||||||
GuiWin, MouseCapture, PositionedSplit, ScrollHit, TermWindowNotif, UIItem, UIItemType, TMB, | ||||||
parse_mouse_cursor_shape, GuiWin, MouseCapture, PositionedSplit, ScrollHit, TermWindowNotif, | ||||||
UIItem, UIItemType, TMB, | ||||||
}; | ||||||
use ::window::{ | ||||||
MouseButtons as WMB, MouseCursor, MouseEvent, MouseEventKind as WMEK, MousePress, | ||||||
|
@@ -837,7 +838,17 @@ impl super::TermWindow { | |||||
// When hovering over a hyperlink, show an appropriate | ||||||
// mouse cursor to give the cue that it is clickable | ||||||
MouseCursor::Hand | ||||||
} else if pane.is_mouse_grabbed() || outside_window { | ||||||
} else if outside_window { | ||||||
MouseCursor::Arrow | ||||||
} else if let Some(shape) = pane.get_mouse_cursor_shape() { | ||||||
if pane.is_mouse_grabbed() { | ||||||
parse_mouse_cursor_shape(shape.as_str()) | ||||||
} else { | ||||||
// If the mouse is no longer grabbed by a TUI, reset the cursor shape. | ||||||
pane.clear_mouse_cursor_shape(); | ||||||
MouseCursor::Arrow | ||||||
} | ||||||
} else if pane.is_mouse_grabbed() { | ||||||
Comment on lines
+843
to
+851
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it turns out, this fixed the issue of the mouse cursor shape being wrong. I have absolutely no idea if this is the right way to approach it though. But basically; if the mouse is grabbed by whichever application is running, we defer to whatever mouse shape is set by any OSC 22 escape sequences. If we find that a shape has been set by an OSC 22 escape sequence but the mouse isn't grabbed we clear it and just use the default pointer shape instead. Some thoughts:
Happy to get some guidance on any improvements here! |
||||||
MouseCursor::Arrow | ||||||
} else { | ||||||
MouseCursor::Text | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied what's done for
Alert::PaletteChanged
here, not sure if that's correct.