1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:37:35 +00:00

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
5 changed files with 46 additions and 48 deletions

View file

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

View file

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

View file

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

View file

@ -1697,40 +1697,47 @@ void WindowManager::process_key_event(KeyEvent& event)
if (!active_input_window) if (!active_input_window)
return; return;
if (event.type() == Event::KeyDown && event.modifiers() == Mod_Super && active_input_window->type() != WindowType::Desktop) { if (event.type() == Event::KeyDown && event.modifiers() == Mod_Super) {
if (event.key() == Key_Down) { if (event.key() == Key_H) {
if (active_input_window->is_resizable() && active_input_window->is_maximized()) { m_cursor_highlight_enabled = !m_cursor_highlight_enabled;
maximize_windows(*active_input_window, false); Compositor::the().invalidate_cursor();
return;
}
if (active_input_window->is_minimizable())
minimize_windows(*active_input_window, true);
return; return;
} }
if (active_input_window->is_resizable()) { if (active_input_window->type() != WindowType::Desktop) {
if (event.key() == Key_Up) { if (event.key() == Key_Down) {
maximize_windows(*active_input_window, !active_input_window->is_maximized()); if (active_input_window->is_resizable() && active_input_window->is_maximized()) {
return; maximize_windows(*active_input_window, false);
}
if (event.key() == Key_Left) {
if (active_input_window->tile_type() == WindowTileType::Left) {
active_input_window->set_untiled();
return; return;
} }
if (active_input_window->is_maximized()) if (active_input_window->is_minimizable())
maximize_windows(*active_input_window, false); minimize_windows(*active_input_window, true);
active_input_window->set_tiled(WindowTileType::Left);
return; return;
} }
if (event.key() == Key_Right) { if (active_input_window->is_resizable()) {
if (active_input_window->tile_type() == WindowTileType::Right) { if (event.key() == Key_Up) {
active_input_window->set_untiled(); 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; 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(); 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() bool WindowManager::sync_config_to_disk()
{ {
if (auto result = m_config->sync(); result.is_error()) { 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_radius(int radius);
void set_cursor_highlight_color(Gfx::Color const& color); 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: private:
explicit WindowManager(Gfx::PaletteImpl const&); explicit WindowManager(Gfx::PaletteImpl const&);
@ -386,6 +386,7 @@ private:
RefPtr<Cursor> m_zoom_cursor; RefPtr<Cursor> m_zoom_cursor;
int m_cursor_highlight_radius { 0 }; int m_cursor_highlight_radius { 0 };
Gfx::Color m_cursor_highlight_color; Gfx::Color m_cursor_highlight_color;
bool m_cursor_highlight_enabled { false };
RefPtr<MultiScaleBitmaps> m_overlay_rect_shadow; RefPtr<MultiScaleBitmaps> m_overlay_rect_shadow;