mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
WindowServer+MouseSettings: Improve buttons_switched
naming
Before this commit it was a bit ambiguous which buttons the function name were referring to; this instead now makes it clear that it's related to mouse input. Additionally, this also fixes incorrect getter naming leftover from yesteryear.
This commit is contained in:
parent
83380ebebc
commit
01cdd3f181
Notes:
sideshowbarker
2024-07-17 11:34:34 +09:00
Author: https://github.com/filiphsps Commit: https://github.com/SerenityOS/serenity/commit/01cdd3f181 Pull-request: https://github.com/SerenityOS/serenity/pull/16312
|
@ -182,7 +182,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::CheckBox {
|
@GUI::CheckBox {
|
||||||
name: "switch_buttons_input"
|
name: "switch_buttons_checkbox"
|
||||||
text: "Switch primary and secondary buttons"
|
text: "Switch primary and secondary buttons"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,8 @@ MouseWidget::MouseWidget()
|
||||||
set_modified(true);
|
set_modified(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_switch_buttons_checkbox = *find_descendant_of_type_named<GUI::CheckBox>("switch_buttons_input");
|
m_switch_buttons_checkbox = *find_descendant_of_type_named<GUI::CheckBox>("switch_buttons_checkbox");
|
||||||
m_switch_buttons_checkbox->set_checked(GUI::ConnectionToWindowServer::the().get_buttons_switched(), GUI::AllowCallback::No);
|
m_switch_buttons_checkbox->set_checked(GUI::ConnectionToWindowServer::the().are_mouse_buttons_switched(), GUI::AllowCallback::No);
|
||||||
m_switch_buttons_checkbox->on_checked = [&](auto) {
|
m_switch_buttons_checkbox->on_checked = [&](auto) {
|
||||||
set_modified(true);
|
set_modified(true);
|
||||||
};
|
};
|
||||||
|
@ -74,7 +74,7 @@ void MouseWidget::apply_settings()
|
||||||
GUI::ConnectionToWindowServer::the().async_set_mouse_acceleration(factor);
|
GUI::ConnectionToWindowServer::the().async_set_mouse_acceleration(factor);
|
||||||
GUI::ConnectionToWindowServer::the().async_set_scroll_step_size(m_scroll_length_spinbox->value());
|
GUI::ConnectionToWindowServer::the().async_set_scroll_step_size(m_scroll_length_spinbox->value());
|
||||||
GUI::ConnectionToWindowServer::the().async_set_double_click_speed(m_double_click_speed_slider->value());
|
GUI::ConnectionToWindowServer::the().async_set_double_click_speed(m_double_click_speed_slider->value());
|
||||||
GUI::ConnectionToWindowServer::the().async_set_buttons_switched(m_switch_buttons_checkbox->is_checked());
|
GUI::ConnectionToWindowServer::the().async_set_mouse_buttons_switched(m_switch_buttons_checkbox->is_checked());
|
||||||
GUI::ConnectionToWindowServer::the().async_set_natural_scroll(m_natural_scroll_checkbox->is_checked());
|
GUI::ConnectionToWindowServer::the().async_set_natural_scroll(m_natural_scroll_checkbox->is_checked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
|
|
||||||
auto buttons = m_buttons | m_double_clicked_buttons;
|
auto buttons = m_buttons | m_double_clicked_buttons;
|
||||||
|
|
||||||
auto primary_secondary_switched = GUI::ConnectionToWindowServer::the().get_buttons_switched();
|
auto primary_secondary_switched = GUI::ConnectionToWindowServer::the().are_mouse_buttons_switched();
|
||||||
auto primary_pressed = buttons & GUI::MouseButton::Primary;
|
auto primary_pressed = buttons & GUI::MouseButton::Primary;
|
||||||
auto secondary_pressed = buttons & GUI::MouseButton::Secondary;
|
auto secondary_pressed = buttons & GUI::MouseButton::Secondary;
|
||||||
|
|
||||||
|
|
|
@ -1100,14 +1100,14 @@ Messages::WindowServer::GetDoubleClickSpeedResponse ConnectionFromClient::get_do
|
||||||
return WindowManager::the().double_click_speed();
|
return WindowManager::the().double_click_speed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionFromClient::set_buttons_switched(bool switched)
|
void ConnectionFromClient::set_mouse_buttons_switched(bool switched)
|
||||||
{
|
{
|
||||||
WindowManager::the().set_buttons_switched(switched);
|
WindowManager::the().set_mouse_buttons_switched(switched);
|
||||||
}
|
}
|
||||||
|
|
||||||
Messages::WindowServer::GetButtonsSwitchedResponse ConnectionFromClient::get_buttons_switched()
|
Messages::WindowServer::AreMouseButtonsSwitchedResponse ConnectionFromClient::are_mouse_buttons_switched()
|
||||||
{
|
{
|
||||||
return WindowManager::the().get_buttons_switched();
|
return WindowManager::the().are_mouse_buttons_switched();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionFromClient::set_natural_scroll(bool inverted)
|
void ConnectionFromClient::set_natural_scroll(bool inverted)
|
||||||
|
|
|
@ -176,8 +176,8 @@ private:
|
||||||
virtual Messages::WindowServer::GetScreenBitmapAroundCursorResponse get_screen_bitmap_around_cursor(Gfx::IntSize) override;
|
virtual Messages::WindowServer::GetScreenBitmapAroundCursorResponse get_screen_bitmap_around_cursor(Gfx::IntSize) override;
|
||||||
virtual void set_double_click_speed(i32) override;
|
virtual void set_double_click_speed(i32) override;
|
||||||
virtual Messages::WindowServer::GetDoubleClickSpeedResponse get_double_click_speed() override;
|
virtual Messages::WindowServer::GetDoubleClickSpeedResponse get_double_click_speed() override;
|
||||||
virtual void set_buttons_switched(bool) override;
|
virtual void set_mouse_buttons_switched(bool) override;
|
||||||
virtual Messages::WindowServer::GetButtonsSwitchedResponse get_buttons_switched() override;
|
virtual Messages::WindowServer::AreMouseButtonsSwitchedResponse are_mouse_buttons_switched() override;
|
||||||
virtual void set_natural_scroll(bool) override;
|
virtual void set_natural_scroll(bool) override;
|
||||||
virtual Messages::WindowServer::IsNaturalScrollResponse is_natural_scroll() override;
|
virtual Messages::WindowServer::IsNaturalScrollResponse is_natural_scroll() override;
|
||||||
virtual void set_window_modified(i32, bool) override;
|
virtual void set_window_modified(i32, bool) override;
|
||||||
|
|
|
@ -85,7 +85,7 @@ void EventLoop::drain_mouse()
|
||||||
|
|
||||||
// Swap primary (1) and secondary (2) buttons if checked in Settings.
|
// Swap primary (1) and secondary (2) buttons if checked in Settings.
|
||||||
// Doing the swap here avoids all emulator and hardware issues.
|
// Doing the swap here avoids all emulator and hardware issues.
|
||||||
if (WindowManager::the().get_buttons_switched()) {
|
if (WindowManager::the().are_mouse_buttons_switched()) {
|
||||||
bool has_primary = state.buttons & MousePacket::Button::LeftButton;
|
bool has_primary = state.buttons & MousePacket::Button::LeftButton;
|
||||||
bool has_secondary = state.buttons & MousePacket::Button::RightButton;
|
bool has_secondary = state.buttons & MousePacket::Button::RightButton;
|
||||||
state.buttons = state.buttons & ~(MousePacket::Button::LeftButton | MousePacket::Button::RightButton);
|
state.buttons = state.buttons & ~(MousePacket::Button::LeftButton | MousePacket::Button::RightButton);
|
||||||
|
|
|
@ -82,7 +82,7 @@ void WindowManager::reload_config()
|
||||||
apply_workspace_settings(workspace_rows, workspace_columns, false);
|
apply_workspace_settings(workspace_rows, workspace_columns, false);
|
||||||
|
|
||||||
m_double_click_speed = m_config->read_num_entry("Input", "DoubleClickSpeed", 250);
|
m_double_click_speed = m_config->read_num_entry("Input", "DoubleClickSpeed", 250);
|
||||||
m_buttons_switched = m_config->read_bool_entry("Mouse", "ButtonsSwitched", false);
|
m_mouse_buttons_switched = m_config->read_bool_entry("Mouse", "ButtonsSwitched", false);
|
||||||
m_natural_scroll = m_config->read_bool_entry("Mouse", "NaturalScroll", false);
|
m_natural_scroll = m_config->read_bool_entry("Mouse", "NaturalScroll", false);
|
||||||
m_cursor_highlight_radius = m_config->read_num_entry("Mouse", "CursorHighlightRadius", 25);
|
m_cursor_highlight_radius = m_config->read_num_entry("Mouse", "CursorHighlightRadius", 25);
|
||||||
Color default_highlight_color = Color::NamedColor::Red;
|
Color default_highlight_color = Color::NamedColor::Red;
|
||||||
|
@ -293,17 +293,17 @@ int WindowManager::double_click_speed() const
|
||||||
return m_double_click_speed;
|
return m_double_click_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::set_buttons_switched(bool switched)
|
void WindowManager::set_mouse_buttons_switched(bool switched)
|
||||||
{
|
{
|
||||||
m_buttons_switched = switched;
|
m_mouse_buttons_switched = switched;
|
||||||
dbgln("Saving mouse buttons switched state {} to config file at {}", switched, m_config->filename());
|
dbgln("Saving mouse buttons switched state {} to config file at {}", switched, m_config->filename());
|
||||||
m_config->write_bool_entry("Mouse", "ButtonsSwitched", switched);
|
m_config->write_bool_entry("Mouse", "ButtonsSwitched", switched);
|
||||||
sync_config_to_disk();
|
sync_config_to_disk();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowManager::get_buttons_switched() const
|
bool WindowManager::are_mouse_buttons_switched() const
|
||||||
{
|
{
|
||||||
return m_buttons_switched;
|
return m_mouse_buttons_switched;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::set_natural_scroll(bool inverted)
|
void WindowManager::set_natural_scroll(bool inverted)
|
||||||
|
|
|
@ -151,8 +151,8 @@ public:
|
||||||
void set_scroll_step_size(unsigned);
|
void set_scroll_step_size(unsigned);
|
||||||
void set_double_click_speed(int);
|
void set_double_click_speed(int);
|
||||||
int double_click_speed() const;
|
int double_click_speed() const;
|
||||||
void set_buttons_switched(bool);
|
void set_mouse_buttons_switched(bool);
|
||||||
bool get_buttons_switched() const;
|
bool are_mouse_buttons_switched() const;
|
||||||
void set_natural_scroll(bool);
|
void set_natural_scroll(bool);
|
||||||
bool is_natural_scroll() const;
|
bool is_natural_scroll() const;
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ private:
|
||||||
int m_double_click_speed { 0 };
|
int m_double_click_speed { 0 };
|
||||||
int m_max_distance_for_double_click { 4 };
|
int m_max_distance_for_double_click { 4 };
|
||||||
bool m_previous_event_was_super_keydown { false };
|
bool m_previous_event_was_super_keydown { false };
|
||||||
bool m_buttons_switched { false };
|
bool m_mouse_buttons_switched { false };
|
||||||
bool m_natural_scroll { false };
|
bool m_natural_scroll { false };
|
||||||
bool m_theme_overridden { false };
|
bool m_theme_overridden { false };
|
||||||
|
|
||||||
|
|
|
@ -173,8 +173,8 @@ endpoint WindowServer
|
||||||
set_double_click_speed(int speed) =|
|
set_double_click_speed(int speed) =|
|
||||||
get_double_click_speed() => (int speed)
|
get_double_click_speed() => (int speed)
|
||||||
|
|
||||||
set_buttons_switched(bool switched) =|
|
set_mouse_buttons_switched(bool switched) =|
|
||||||
get_buttons_switched() => (bool switched)
|
are_mouse_buttons_switched() => (bool switched)
|
||||||
|
|
||||||
set_natural_scroll(bool inverted) =|
|
set_natural_scroll(bool inverted) =|
|
||||||
is_natural_scroll() => (bool inverted)
|
is_natural_scroll() => (bool inverted)
|
||||||
|
|
Loading…
Reference in a new issue