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
2 changes: 1 addition & 1 deletion config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ increase_marker_opacity = ["Ctrl+Alt+ArrowUp"]
decrease_marker_opacity = ["Ctrl+Alt+ArrowDown"]

# Tool selection shortcuts (optional; keep empty to rely on modifiers)
select_selection_tool = ["V"]
select_pen_tool = ["F"]
select_marker_tool = ["H"]
select_eraser_tool = ["D"]
Expand Down Expand Up @@ -825,4 +826,3 @@ copy_to_clipboard = true
# When false, clipboard-only captures still auto-exit by default.
# Use --no-exit-after-capture to keep the overlay open for a run.
exit_after_capture = false

2 changes: 2 additions & 0 deletions configurator/src/models/keybindings/field/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl KeybindingField {
Self::DecreaseThickness => &config.tools.decrease_thickness,
Self::IncreaseMarkerOpacity => &config.tools.increase_marker_opacity,
Self::DecreaseMarkerOpacity => &config.tools.decrease_marker_opacity,
Self::SelectSelectionTool => &config.tools.select_selection_tool,
Self::SelectPenTool => &config.tools.select_pen_tool,
Self::SelectEraserTool => &config.tools.select_eraser_tool,
Self::ToggleEraserMode => &config.tools.toggle_eraser_mode,
Expand Down Expand Up @@ -145,6 +146,7 @@ impl KeybindingField {
Self::DecreaseThickness => config.tools.decrease_thickness = value,
Self::IncreaseMarkerOpacity => config.tools.increase_marker_opacity = value,
Self::DecreaseMarkerOpacity => config.tools.decrease_marker_opacity = value,
Self::SelectSelectionTool => config.tools.select_selection_tool = value,
Self::SelectPenTool => config.tools.select_pen_tool = value,
Self::SelectEraserTool => config.tools.select_eraser_tool = value,
Self::ToggleEraserMode => config.tools.toggle_eraser_mode = value,
Expand Down
2 changes: 2 additions & 0 deletions configurator/src/models/keybindings/field/labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl KeybindingField {
Self::DecreaseThickness => "Decrease thickness",
Self::IncreaseMarkerOpacity => "Increase marker opacity",
Self::DecreaseMarkerOpacity => "Decrease marker opacity",
Self::SelectSelectionTool => "Select selection tool",
Self::SelectPenTool => "Select pen tool",
Self::SelectEraserTool => "Select eraser tool",
Self::ToggleEraserMode => "Toggle eraser mode",
Expand Down Expand Up @@ -136,6 +137,7 @@ impl KeybindingField {
Self::DecreaseThickness => "decrease_thickness",
Self::IncreaseMarkerOpacity => "increase_marker_opacity",
Self::DecreaseMarkerOpacity => "decrease_marker_opacity",
Self::SelectSelectionTool => "select_selection_tool",
Self::SelectPenTool => "select_pen_tool",
Self::SelectEraserTool => "select_eraser_tool",
Self::ToggleEraserMode => "toggle_eraser_mode",
Expand Down
1 change: 1 addition & 0 deletions configurator/src/models/keybindings/field/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl KeybindingField {
Self::DecreaseThickness,
Self::IncreaseMarkerOpacity,
Self::DecreaseMarkerOpacity,
Self::SelectSelectionTool,
Self::SelectPenTool,
Self::SelectEraserTool,
Self::ToggleEraserMode,
Expand Down
1 change: 1 addition & 0 deletions configurator/src/models/keybindings/field/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub enum KeybindingField {
DecreaseThickness,
IncreaseMarkerOpacity,
DecreaseMarkerOpacity,
SelectSelectionTool,
SelectPenTool,
SelectEraserTool,
ToggleEraserMode,
Expand Down
3 changes: 2 additions & 1 deletion configurator/src/models/keybindings/field/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ impl KeybindingField {
| Self::SetColorPink
| Self::SetColorWhite
| Self::SetColorBlack => KeybindingsTabId::Drawing,
Self::SelectPenTool
Self::SelectSelectionTool
| Self::SelectPenTool
| Self::SelectEraserTool
| Self::ToggleEraserMode
| Self::SelectMarkerTool
Expand Down
1 change: 1 addition & 0 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ increase_marker_opacity = ["Ctrl+Alt+ArrowUp"]
decrease_marker_opacity = ["Ctrl+Alt+ArrowDown"]

# Tool selection shortcuts (optional; keep empty to rely on modifiers)
select_selection_tool = ["V"]
select_pen_tool = ["F"]
select_marker_tool = ["H"]
select_eraser_tool = ["D"]
Expand Down
5 changes: 4 additions & 1 deletion src/backend/wayland/state/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ pub(in crate::backend::wayland) fn debug_toolbar_drag_logging_enabled() -> bool
pub(in crate::backend::wayland) fn toolbar_pointer_lock_enabled() -> bool {
static ENABLED: OnceLock<bool> = OnceLock::new();
*ENABLED.get_or_init(|| {
parse_boolish_env(&std::env::var("WAYSCRIBER_TOOLBAR_POINTER_LOCK").unwrap_or_default())
// Default ON: without pointer lock, layer-shell toolbar drags jitter/flicker as surfaces move.
parse_boolish_env(
&std::env::var("WAYSCRIBER_TOOLBAR_POINTER_LOCK").unwrap_or_else(|_| "1".into()),
)
})
}

Expand Down
18 changes: 11 additions & 7 deletions src/backend/wayland/state/toolbar/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ impl WaylandState {
/// Returns a snapshot of the current input state for toolbar UI consumption.
pub(in crate::backend::wayland) fn toolbar_snapshot(&self) -> ToolbarSnapshot {
let hints = ToolbarBindingHints::from_input_state(&self.input_state);
let show_drawer_hint =
!self.onboarding.state().drawer_hint_shown && !self.input_state.toolbar_drawer_open;
let hint_max = crate::onboarding::DRAWER_HINT_MAX;
let show_drawer_hint = self.onboarding.state().drawer_hint_count < hint_max
&& !self.input_state.toolbar_drawer_open;
ToolbarSnapshot::from_input_with_options(&self.input_state, hints, show_drawer_hint)
}

/// Applies an incoming toolbar event and schedules redraws as needed.
pub(in crate::backend::wayland) fn handle_toolbar_event(&mut self, event: ToolbarEvent) {
// Mark drawer hint as shown when user opens the drawer
if matches!(event, ToolbarEvent::ToggleDrawer(true))
&& !self.onboarding.state().drawer_hint_shown
{
self.onboarding.state_mut().drawer_hint_shown = true;
self.onboarding.save();
let hint_max = crate::onboarding::DRAWER_HINT_MAX;
if matches!(event, ToolbarEvent::ToggleDrawer(true)) {
let state = self.onboarding.state_mut();
if state.drawer_hint_count < hint_max {
state.drawer_hint_count = state.drawer_hint_count.saturating_add(1);
state.drawer_hint_shown = state.drawer_hint_count >= hint_max;
self.onboarding.save();
}
}

match event {
Expand Down
37 changes: 23 additions & 14 deletions src/backend/wayland/toolbar/render/side_palette/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use super::{ColorSectionInfo, SidePaletteLayout};
use crate::backend::wayland::toolbar::events::HitKind;
use crate::backend::wayland::toolbar::hit::HitRegion;
use crate::backend::wayland::toolbar::layout::ToolbarLayoutSpec;
use crate::config::Action;
use crate::draw::{BLACK, BLUE, Color, GREEN, ORANGE, PINK, RED, WHITE, YELLOW};
use crate::toolbar_icons;
use crate::ui::toolbar::ToolbarEvent;
Expand All @@ -27,17 +28,17 @@ pub(super) fn draw_colors_section(layout: &mut SidePaletteLayout, y: &mut f64) -
size: FONT_SIZE_LABEL,
};

let basic_colors: &[(Color, &str)] = &[
(RED, "Red"),
(GREEN, "Green"),
(BLUE, "Blue"),
(YELLOW, "Yellow"),
(WHITE, "White"),
(BLACK, "Black"),
let basic_colors: &[(Color, &str, Option<Action>)] = &[
(RED, "Red", Some(Action::SetColorRed)),
(GREEN, "Green", Some(Action::SetColorGreen)),
(BLUE, "Blue", Some(Action::SetColorBlue)),
(YELLOW, "Yellow", Some(Action::SetColorYellow)),
(WHITE, "White", Some(Action::SetColorWhite)),
(BLACK, "Black", Some(Action::SetColorBlack)),
];
let extended_colors: &[(Color, &str)] = &[
(ORANGE, "Orange"),
(PINK, "Pink"),
let extended_colors: &[(Color, &str, Option<Action>)] = &[
(ORANGE, "Orange", Some(Action::SetColorOrange)),
(PINK, "Pink", Some(Action::SetColorPink)),
(
Color {
r: 0.0,
Expand All @@ -46,6 +47,7 @@ pub(super) fn draw_colors_section(layout: &mut SidePaletteLayout, y: &mut f64) -
a: 1.0,
},
"Cyan",
None,
),
(
Color {
Expand All @@ -55,6 +57,7 @@ pub(super) fn draw_colors_section(layout: &mut SidePaletteLayout, y: &mut f64) -
a: 1.0,
},
"Purple",
None,
),
(
Color {
Expand All @@ -64,6 +67,7 @@ pub(super) fn draw_colors_section(layout: &mut SidePaletteLayout, y: &mut f64) -
a: 1.0,
},
"Gray",
None,
),
];

Expand Down Expand Up @@ -98,13 +102,15 @@ pub(super) fn draw_colors_section(layout: &mut SidePaletteLayout, y: &mut f64) -

let mut cx = x;
let mut row_y = picker_y + picker_h + 8.0;
for (color, _name) in basic_colors {
for (color, name, action) in basic_colors {
draw_swatch(ctx, cx, row_y, swatch, *color, *color == snapshot.color);
let binding = action.and_then(|action| snapshot.binding_hints.binding_for_action(action));
let tooltip = crate::backend::wayland::toolbar::format_binding_label(name, binding);
hits.push(HitRegion {
rect: (cx, row_y, swatch, swatch),
event: ToolbarEvent::SetColor(*color),
kind: HitKind::Click,
tooltip: None,
tooltip: Some(tooltip),
});
cx += swatch + swatch_gap;
}
Expand Down Expand Up @@ -132,13 +138,16 @@ pub(super) fn draw_colors_section(layout: &mut SidePaletteLayout, y: &mut f64) -

if snapshot.show_more_colors {
cx = x;
for (color, _name) in extended_colors {
for (color, name, action) in extended_colors {
draw_swatch(ctx, cx, row_y, swatch, *color, *color == snapshot.color);
let binding =
action.and_then(|action| snapshot.binding_hints.binding_for_action(action));
let tooltip = crate::backend::wayland::toolbar::format_binding_label(name, binding);
hits.push(HitRegion {
rect: (cx, row_y, swatch, swatch),
event: ToolbarEvent::SetColor(*color),
kind: HitKind::Click,
tooltip: None,
tooltip: Some(tooltip),
});
cx += swatch + swatch_gap;
}
Expand Down
4 changes: 2 additions & 2 deletions src/backend/wayland/toolbar/render/side_palette/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ pub(super) fn draw_header(layout: &mut SidePaletteLayout) -> f64 {
let icon_x = more_x + (btn_size - icon_size) / 2.0;
let icon_y = header_btn_y + (btn_size - icon_size) / 2.0;
toolbar_icons::draw_icon_more(ctx, icon_x, icon_y, icon_size);
// Draw attention dot when drawer is closed
if !snapshot.drawer_open {
// Draw attention dot only for the onboarding hint
if snapshot.show_drawer_hint {
let dot_radius = 4.0;
let dot_x = more_x + btn_size - dot_radius - 2.0;
let dot_y = header_btn_y + dot_radius + 2.0;
Expand Down
18 changes: 15 additions & 3 deletions src/backend/wayland/toolbar/render/widgets/tooltip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ pub(in crate::backend::wayland::toolbar::render) fn draw_tooltip(
let gap = SPACING_STD;

// Determine if tooltip should render above or below
// If rendering below would extend past panel height, render above instead
// If rendering below would extend past panel height, render above only when there's room.
let render_above = if above {
true
} else {
let below_y = hit.rect.1 + hit.rect.3 + gap + tooltip_h;
below_y > panel_height - SPACING_MD
let space_above = hit.rect.1 - tooltip_h - gap >= SPACING_MD;
below_y > panel_height - SPACING_MD && space_above
};

let tooltip_y = if render_above {
let mut tooltip_y = if render_above {
hit.rect.1 - tooltip_h - gap
} else {
hit.rect.1 + hit.rect.3 + gap
Expand All @@ -62,6 +63,17 @@ pub(in crate::backend::wayland::toolbar::render) fn draw_tooltip(
if tooltip_x + tooltip_w > panel_width - SPACING_MD {
tooltip_x = panel_width - tooltip_w - SPACING_MD;
}
let min_y = SPACING_MD;
let max_y = panel_height - tooltip_h - SPACING_MD;
if max_y >= min_y {
if tooltip_y < min_y {
tooltip_y = min_y;
} else if tooltip_y > max_y {
tooltip_y = max_y;
}
} else {
tooltip_y = min_y;
}

let shadow_offset = SPACING_XS;
set_color(ctx, COLOR_TOOLTIP_SHADOW);
Expand Down
16 changes: 8 additions & 8 deletions src/config/action_meta/entries/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub const ENTRIES: &[ActionMeta] = &[
Colors,
true,
true,
false
true
),
meta!(
SetColorGreen,
Expand All @@ -19,7 +19,7 @@ pub const ENTRIES: &[ActionMeta] = &[
Colors,
true,
true,
false
true
),
meta!(
SetColorBlue,
Expand All @@ -29,7 +29,7 @@ pub const ENTRIES: &[ActionMeta] = &[
Colors,
true,
true,
false
true
),
meta!(
SetColorYellow,
Expand All @@ -39,7 +39,7 @@ pub const ENTRIES: &[ActionMeta] = &[
Colors,
true,
true,
false
true
),
meta!(
SetColorOrange,
Expand All @@ -49,7 +49,7 @@ pub const ENTRIES: &[ActionMeta] = &[
Colors,
true,
true,
false
true
),
meta!(
SetColorPink,
Expand All @@ -59,7 +59,7 @@ pub const ENTRIES: &[ActionMeta] = &[
Colors,
true,
true,
false
true
),
meta!(
SetColorWhite,
Expand All @@ -69,7 +69,7 @@ pub const ENTRIES: &[ActionMeta] = &[
Colors,
true,
true,
false
true
),
meta!(
SetColorBlack,
Expand All @@ -79,6 +79,6 @@ pub const ENTRIES: &[ActionMeta] = &[
Colors,
true,
true,
false
true
),
];
10 changes: 10 additions & 0 deletions src/config/action_meta/entries/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ pub const ENTRIES: &[ActionMeta] = &[
true,
true
),
meta!(
SelectSelectionTool,
"Selection Tool",
Some("Select"),
"Select and move items",
Tools,
true,
true,
true
),
meta!(
SelectPenTool,
"Pen Tool",
Expand Down
3 changes: 3 additions & 0 deletions src/config/action_meta/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const HELP_ACTIONS: &[Action] = &[
Action::SetColorPink,
Action::SetColorWhite,
Action::SetColorBlack,
Action::SelectSelectionTool,
Action::SelectPenTool,
Action::SelectLineTool,
Action::SelectRectTool,
Expand Down Expand Up @@ -88,6 +89,7 @@ const TOOLBAR_ACTIONS: &[Action] = &[
Action::SelectRectTool,
Action::SelectEllipseTool,
Action::SelectArrowTool,
Action::SelectSelectionTool,
Action::SelectMarkerTool,
Action::SelectHighlightTool,
Action::SelectEraserTool,
Expand Down Expand Up @@ -137,6 +139,7 @@ const PALETTE_ACTIONS: &[Action] = &[
Action::ClearCanvas,
Action::Undo,
Action::Redo,
Action::SelectSelectionTool,
Action::SelectPenTool,
Action::SelectLineTool,
Action::SelectRectTool,
Expand Down
1 change: 1 addition & 0 deletions src/config/keybindings/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub enum Action {
DecreaseThickness,
IncreaseMarkerOpacity,
DecreaseMarkerOpacity,
SelectSelectionTool,
SelectMarkerTool,
SelectEraserTool,
ToggleEraserMode,
Expand Down
4 changes: 4 additions & 0 deletions src/config/keybindings/config/map/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ impl KeybindingsConfig {
&self.tools.decrease_marker_opacity,
Action::DecreaseMarkerOpacity,
)?;
inserter.insert_all(
&self.tools.select_selection_tool,
Action::SelectSelectionTool,
)?;
inserter.insert_all(&self.tools.select_marker_tool, Action::SelectMarkerTool)?;
inserter.insert_all(&self.tools.select_eraser_tool, Action::SelectEraserTool)?;
inserter.insert_all(&self.tools.toggle_eraser_mode, Action::ToggleEraserMode)?;
Expand Down
Loading