Set orbclient async mode when edge scrolling

This commit is contained in:
Jeremy Soller 2022-10-25 09:30:16 -06:00
parent d04147e1fc
commit a19182507b
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
2 changed files with 12 additions and 2 deletions

View file

@ -11,7 +11,7 @@ cosmic-text = { path = "../../" }
env_logger = "0.9"
fontdb = "0.9"
log = "0.4"
orbclient = "0.3.35"
orbclient = "0.3.39"
[features]
mono = []

View file

@ -167,6 +167,7 @@ fn main() {
}
let mut found_event = false;
let mut window_async = false;
for event in window.events() {
found_event = true;
match event.to_option() {
@ -225,8 +226,10 @@ fn main() {
if mouse_y <= 5 {
buffer.action(TextAction::Scroll { lines: -3 });
window_async = true;
} else if mouse_y + 5 >= window.height() as i32 {
buffer.action(TextAction::Scroll { lines: 3 });
window_async = true;
} else {
buffer.shape_until_cursor()
}
@ -269,12 +272,19 @@ fn main() {
if mouse_y <= 5 {
buffer.action(TextAction::Scroll { lines: -3 });
window_async = true;
} else if mouse_y + 5 >= window.height() as i32 {
buffer.action(TextAction::Scroll { lines: 3 });
window_async = true;
}
}
if ! found_event {
if window_async != window.is_async() {
window.set_async(window_async);
}
if window_async && ! found_event {
// In async mode and no event found, sleep
thread::sleep(Duration::from_millis(5));
}
}