WindowServer+MouseSettings: Toggle cursor highlighting with Super+H

Rather than enabling/disabling cursor highlighting by going into mouse
settings, you can now instead toggle it any time with Super+H. Mouse
settings now is only for customising the look of the highlighting.
This commit is contained in:
MacDue 2022-06-07 23:41:04 +01:00 committed by Linus Groh
parent 3c2c6790df
commit 5caf307ec0
Notes: sideshowbarker 2024-07-17 10:19:13 +09:00
5 changed files with 46 additions and 48 deletions

View file

@ -45,20 +45,20 @@
@GUI::Label {
autosize: true
text: "0%"
text: "Low"
}
@GUI::Slider {
name: "highlight_opacity_slider"
orientation: "Horizontal"
max: 230
min: 0
min: 30
value: 110
}
@GUI::Label {
autosize: true
text: "100%"
text: "High"
}
}
}
@ -79,20 +79,20 @@
@GUI::Label {
autosize: true
text: "Off"
text: "Small"
}
@GUI::Slider {
name: "highlight_radius_slider"
orientation: "Horizontal"
max: 60
min: 19
min: 20
value: 25
}
@GUI::Label {
autosize: true
text: "Largest"
text: "Large"
}
}
}

View file

@ -51,12 +51,10 @@ ErrorOr<void> HighlightPreviewWidget::reload_cursor()
void HighlightPreviewWidget::paint_preview(GUI::PaintEvent&)
{
GUI::Painter painter(*this);
if (m_radius > 0 && m_color.alpha() > 0) {
Gfx::AntiAliasingPainter aa_painter { painter };
Gfx::IntRect highlight_rect { 0, 0, m_radius * 2, m_radius * 2 };
highlight_rect.center_within(frame_inner_rect());
aa_painter.fill_ellipse(highlight_rect, m_color);
}
Gfx::AntiAliasingPainter aa_painter { painter };
Gfx::IntRect highlight_rect { 0, 0, m_radius * 2, m_radius * 2 };
highlight_rect.center_within(frame_inner_rect());
aa_painter.fill_ellipse(highlight_rect, m_color);
if (m_cursor_bitmap) {
auto cursor_rect = m_cursor_bitmap->rect();
if (m_cursor_params.frames() > 1)

View file

@ -52,10 +52,7 @@ Gfx::Color HighlightWidget::highlight_color()
int HighlightWidget::highlight_radius()
{
auto current_value = m_highlight_radius_slider->value();
if (current_value <= m_highlight_radius_slider->min())
return 0;
return current_value;
return m_highlight_radius_slider->value();
}
void HighlightWidget::apply_settings()

View file

@ -1697,40 +1697,47 @@ void WindowManager::process_key_event(KeyEvent& event)
if (!active_input_window)
return;
if (event.type() == Event::KeyDown && event.modifiers() == Mod_Super && active_input_window->type() != WindowType::Desktop) {
if (event.key() == Key_Down) {
if (active_input_window->is_resizable() && active_input_window->is_maximized()) {
maximize_windows(*active_input_window, false);
return;
}
if (active_input_window->is_minimizable())
minimize_windows(*active_input_window, true);
if (event.type() == Event::KeyDown && event.modifiers() == Mod_Super) {
if (event.key() == Key_H) {
m_cursor_highlight_enabled = !m_cursor_highlight_enabled;
Compositor::the().invalidate_cursor();
return;
}
if (active_input_window->is_resizable()) {
if (event.key() == Key_Up) {
maximize_windows(*active_input_window, !active_input_window->is_maximized());
return;
}
if (event.key() == Key_Left) {
if (active_input_window->tile_type() == WindowTileType::Left) {
active_input_window->set_untiled();
if (active_input_window->type() != WindowType::Desktop) {
if (event.key() == Key_Down) {
if (active_input_window->is_resizable() && active_input_window->is_maximized()) {
maximize_windows(*active_input_window, false);
return;
}
if (active_input_window->is_maximized())
maximize_windows(*active_input_window, false);
active_input_window->set_tiled(WindowTileType::Left);
if (active_input_window->is_minimizable())
minimize_windows(*active_input_window, true);
return;
}
if (event.key() == Key_Right) {
if (active_input_window->tile_type() == WindowTileType::Right) {
active_input_window->set_untiled();
if (active_input_window->is_resizable()) {
if (event.key() == Key_Up) {
maximize_windows(*active_input_window, !active_input_window->is_maximized());
return;
}
if (event.key() == Key_Left) {
if (active_input_window->tile_type() == WindowTileType::Left) {
active_input_window->set_untiled();
return;
}
if (active_input_window->is_maximized())
maximize_windows(*active_input_window, false);
active_input_window->set_tiled(WindowTileType::Left);
return;
}
if (event.key() == Key_Right) {
if (active_input_window->tile_type() == WindowTileType::Right) {
active_input_window->set_untiled();
return;
}
if (active_input_window->is_maximized())
maximize_windows(*active_input_window, false);
active_input_window->set_tiled(WindowTileType::Right);
return;
}
if (active_input_window->is_maximized())
maximize_windows(*active_input_window, false);
active_input_window->set_tiled(WindowTileType::Right);
return;
}
}
}
@ -2294,11 +2301,6 @@ void WindowManager::set_cursor_highlight_color(Gfx::Color const& color)
sync_config_to_disk();
}
bool WindowManager::is_cursor_highlight_enabled() const
{
return m_cursor_highlight_radius > 0 && m_cursor_highlight_color.alpha() > 0;
}
bool WindowManager::sync_config_to_disk()
{
if (auto result = m_config->sync(); result.is_error()) {

View file

@ -329,7 +329,7 @@ public:
void set_cursor_highlight_radius(int radius);
void set_cursor_highlight_color(Gfx::Color const& color);
bool is_cursor_highlight_enabled() const;
bool is_cursor_highlight_enabled() const { return m_cursor_highlight_radius > 0 && m_cursor_highlight_enabled; }
private:
explicit WindowManager(Gfx::PaletteImpl const&);
@ -386,6 +386,7 @@ private:
RefPtr<Cursor> m_zoom_cursor;
int m_cursor_highlight_radius { 0 };
Gfx::Color m_cursor_highlight_color;
bool m_cursor_highlight_enabled { false };
RefPtr<MultiScaleBitmaps> m_overlay_rect_shadow;