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

MouseSettings: Add option to reverse buttons

Add option to reverse primary and secondary buttons in Mouse Settings.
- WindowServer.ini: add default entry
- switch-mouse-buttons.png: new icon for settings entry
- Mouse.gml/MouseWidget.*: new settings dialog
- ClientConnection/WindowManager/Server: window message for settings
- EventLoop.cpp: swap buttons 1 and 2 if settings are on
This commit is contained in:
Andrew Pardoe 2021-10-24 19:47:33 -07:00 committed by Idan Horowitz
parent 5599d22744
commit 0e68550c05
11 changed files with 90 additions and 0 deletions

View file

@ -158,4 +158,39 @@
}
}
}
@GUI::GroupBox {
title: "Button configuration"
fixed_height: 60
layout: @GUI::VerticalBoxLayout {
margins: [16, 8, 8]
spacing: 2
}
@GUI::Widget {
layout: @GUI::HorizontalBoxLayout {
spacing: 16
}
@GUI::Label {
fixed_width: 32
fixed_height: 32
name: "switch_buttons_image_label"
}
@GUI::Label {
text: "Switch primary and secondary buttons"
fixed_width: 201
text_alignment: "CenterLeft"
name: "switch_buttons_label"
}
@GUI::CheckBox {
name: "switch_buttons_input"
fixed_width: 14
}
}
}
}

View file

@ -51,6 +51,10 @@ MouseWidget::MouseWidget()
m_double_click_speed_label->set_text(String::formatted("{} ms", speed));
};
m_double_click_speed_slider->set_value(GUI::WindowServerConnection::the().get_double_click_speed());
m_switch_buttons_checkbox = *find_descendant_of_type_named<GUI::CheckBox>("switch_buttons_input");
m_switch_buttons_checkbox->set_checked(GUI::WindowServerConnection::the().get_buttons_switched());
auto& switch_buttons_image_label = *find_descendant_of_type_named<GUI::Label>("switch_buttons_image_label");
switch_buttons_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/switch-mouse-buttons.png"));
}
void MouseWidget::update_window_server()
@ -59,6 +63,7 @@ void MouseWidget::update_window_server()
GUI::WindowServerConnection::the().async_set_mouse_acceleration(factor);
GUI::WindowServerConnection::the().async_set_scroll_step_size(m_scroll_length_spinbox->value());
GUI::WindowServerConnection::the().async_set_double_click_speed(m_double_click_speed_slider->value());
GUI::WindowServerConnection::the().async_set_buttons_switched(m_switch_buttons_checkbox->is_checked());
}
void MouseWidget::reset_default_values()
@ -66,6 +71,7 @@ void MouseWidget::reset_default_values()
m_speed_slider->set_value(speed_slider_scale);
m_scroll_length_spinbox->set_value(default_scroll_length);
m_double_click_speed_slider->set_value(double_click_speed_default);
m_switch_buttons_checkbox->set_checked(false);
update_window_server();
}

View file

@ -6,6 +6,7 @@
#pragma once
#include <LibGUI/CheckBox.h>
#include <LibGUI/Window.h>
#include "DoubleClickArrowWidget.h"
@ -26,5 +27,6 @@ private:
RefPtr<GUI::SpinBox> m_scroll_length_spinbox;
RefPtr<GUI::HorizontalSlider> m_double_click_speed_slider;
RefPtr<GUI::Label> m_double_click_speed_label;
RefPtr<GUI::CheckBox> m_switch_buttons_checkbox;
RefPtr<MouseSettings::DoubleClickArrowWidget> m_double_click_arrow_widget;
};