Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/backend/wayland/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use wayland_client::{Connection, backend::WaylandError, globals::registry_queue_
use wayland_protocols::wp::tablet::zv2::client::zwp_tablet_manager_v2::ZwpTabletManagerV2;
use wayland_protocols_wlr::screencopy::v1::client::zwlr_screencopy_manager_v1::ZwlrScreencopyManagerV1;

use super::state::{OverlaySuppression, WaylandState};
use super::state::{OverlaySuppression, WaylandGlobals, WaylandState, WaylandStateInit};
use crate::{
RESUME_SESSION_ENV,
capture::{CaptureManager, CaptureOutcome},
Expand Down Expand Up @@ -495,7 +495,7 @@ impl WaylandBackend {
};

// Create application state
let mut state = WaylandState::new(
let globals = WaylandGlobals {
registry_state,
compositor_state,
layer_shell,
Expand All @@ -506,19 +506,22 @@ impl WaylandBackend {
relative_pointer_state,
output_state,
seat_state,
};
let mut state = WaylandState::new(WaylandStateInit {
globals,
config,
input_state,
capture_manager,
session_options,
tokio_handle,
frozen_supported,
frozen_enabled: frozen_supported,
preferred_output_identity,
xdg_fullscreen,
freeze_on_start,
pending_freeze_on_start: freeze_on_start,
screencopy_manager,
#[cfg(tablet)]
tablet_manager,
);
});

// Ensure pinned toolbars are created immediately if visible on startup.
state.sync_toolbar_visibility(&qh);
Expand Down
38 changes: 38 additions & 0 deletions src/backend/wayland/handlers/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,27 @@ impl KeyboardHandler for WaylandState {
}
}
debug!("Key pressed: {:?}", key);
let prefs_before = (
self.input_state.current_color,
self.input_state.current_thickness,
self.input_state.eraser_mode,
self.input_state.marker_opacity,
self.input_state.current_font_size,
self.input_state.font_descriptor.clone(),
self.input_state.fill_enabled,
);
self.input_state.on_key_press(key);
self.input_state.needs_redraw = true;
let prefs_changed = prefs_before.0 != self.input_state.current_color
|| (prefs_before.1 - self.input_state.current_thickness).abs() > f64::EPSILON
|| prefs_before.2 != self.input_state.eraser_mode
|| (prefs_before.3 - self.input_state.marker_opacity).abs() > f64::EPSILON
|| (prefs_before.4 - self.input_state.current_font_size).abs() > f64::EPSILON
|| prefs_before.5 != self.input_state.font_descriptor
|| prefs_before.6 != self.input_state.fill_enabled;
if prefs_changed {
self.save_drawing_preferences();
}

#[cfg(tablet)]
if (self.input_state.current_thickness - prev_thickness).abs() > f64::EPSILON {
Expand Down Expand Up @@ -208,8 +227,27 @@ impl KeyboardHandler for WaylandState {
}
}
debug!("Key repeated: {:?}", key);
let prefs_before = (
self.input_state.current_color,
self.input_state.current_thickness,
self.input_state.eraser_mode,
self.input_state.marker_opacity,
self.input_state.current_font_size,
self.input_state.font_descriptor.clone(),
self.input_state.fill_enabled,
);
self.input_state.on_key_press(key);
self.input_state.needs_redraw = true;
let prefs_changed = prefs_before.0 != self.input_state.current_color
|| (prefs_before.1 - self.input_state.current_thickness).abs() > f64::EPSILON
|| prefs_before.2 != self.input_state.eraser_mode
|| (prefs_before.3 - self.input_state.marker_opacity).abs() > f64::EPSILON
|| (prefs_before.4 - self.input_state.current_font_size).abs() > f64::EPSILON
|| prefs_before.5 != self.input_state.font_descriptor
|| prefs_before.6 != self.input_state.fill_enabled;
if prefs_changed {
self.save_drawing_preferences();
}

#[cfg(tablet)]
if (self.input_state.current_thickness - prev_thickness).abs() > f64::EPSILON {
Expand Down
15 changes: 15 additions & 0 deletions src/backend/wayland/handlers/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,18 +362,30 @@ impl PointerHandler for WaylandState {

match scroll_direction.cmp(&0) {
std::cmp::Ordering::Greater if self.input_state.modifiers.shift => {
let prev_font_size = self.input_state.current_font_size;
self.input_state.adjust_font_size(-2.0);
debug!(
"Font size decreased: {:.1}px",
self.input_state.current_font_size
);
if (self.input_state.current_font_size - prev_font_size).abs()
> f64::EPSILON
{
self.save_drawing_preferences();
}
}
std::cmp::Ordering::Less if self.input_state.modifiers.shift => {
let prev_font_size = self.input_state.current_font_size;
self.input_state.adjust_font_size(2.0);
debug!(
"Font size increased: {:.1}px",
self.input_state.current_font_size
);
if (self.input_state.current_font_size - prev_font_size).abs()
> f64::EPSILON
{
self.save_drawing_preferences();
}
}
std::cmp::Ordering::Greater | std::cmp::Ordering::Less => {
let delta = if scroll_direction > 0 { -1.0 } else { 1.0 };
Expand All @@ -394,6 +406,9 @@ impl PointerHandler for WaylandState {
);
}
self.input_state.needs_redraw = true;
if !eraser_active {
self.save_drawing_preferences();
}
}
#[cfg(tablet)]
if !eraser_active
Expand Down
Loading