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

Everywhere: Rename left/right-click to primary/secondary

This resolves #10641.
This commit is contained in:
Filiph Sandström 2021-10-27 13:20:27 +02:00 committed by Idan Horowitz
parent a6ccf6659a
commit d6a0726302
79 changed files with 183 additions and 183 deletions

View file

@ -96,7 +96,7 @@ void AbstractButton::mousemove_event(MouseEvent& event)
{
bool is_over = rect().contains(event.position());
m_hovered = is_over;
if (event.buttons() & MouseButton::Left) {
if (event.buttons() & MouseButton::Primary) {
bool being_pressed = is_over;
if (being_pressed != m_being_pressed) {
m_being_pressed = being_pressed;
@ -114,7 +114,7 @@ void AbstractButton::mousemove_event(MouseEvent& event)
void AbstractButton::mousedown_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left) {
if (event.button() == MouseButton::Primary) {
m_being_pressed = true;
repaint();
@ -129,7 +129,7 @@ void AbstractButton::mousedown_event(MouseEvent& event)
void AbstractButton::mouseup_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left && m_being_pressed) {
if (event.button() == MouseButton::Primary && m_being_pressed) {
bool was_auto_repeating = m_auto_repeat_timer->is_active();
m_auto_repeat_timer->stop();
bool was_being_pressed = m_being_pressed;

View file

@ -207,7 +207,7 @@ void AbstractTableView::mousedown_event(MouseEvent& event)
if (!model())
return AbstractView::mousedown_event(event);
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return AbstractView::mousedown_event(event);
bool is_toggle;

View file

@ -224,7 +224,7 @@ void AbstractView::mousedown_event(MouseEvent& event)
if (!model())
return;
if (event.button() == MouseButton::Left)
if (event.button() == MouseButton::Primary)
m_left_mousedown_position = event.position();
auto index = index_at_event_position(event.position());
@ -236,10 +236,10 @@ void AbstractView::mousedown_event(MouseEvent& event)
set_cursor(index, SelectionUpdate::Ctrl);
} else if (event.modifiers() & Mod_Shift) {
set_cursor(index, SelectionUpdate::Shift);
} else if (event.button() == MouseButton::Left && m_selection.contains(index) && !m_model->drag_data_type().is_null()) {
} else if (event.button() == MouseButton::Primary && m_selection.contains(index) && !m_model->drag_data_type().is_null()) {
// We might be starting a drag, so don't throw away other selected items yet.
m_might_drag = true;
} else if (event.button() == MouseButton::Right) {
} else if (event.button() == MouseButton::Secondary) {
set_cursor(index, SelectionUpdate::ClearIfNotSelected);
} else {
set_cursor(index, SelectionUpdate::Set);
@ -285,7 +285,7 @@ void AbstractView::mousemove_event(MouseEvent& event)
if (!m_might_drag)
return AbstractScrollableWidget::mousemove_event(event);
if (!(event.buttons() & MouseButton::Left) || m_selection.is_empty()) {
if (!(event.buttons() & MouseButton::Primary) || m_selection.is_empty()) {
m_might_drag = false;
return AbstractScrollableWidget::mousemove_event(event);
}
@ -360,7 +360,7 @@ void AbstractView::doubleclick_event(MouseEvent& event)
if (!model())
return;
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
m_might_drag = false;

View file

@ -59,7 +59,7 @@ void ColorInput::set_color(Color color)
void ColorInput::mousedown_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left && color_rect().contains(event.position())) {
if (event.button() == MouseButton::Primary && color_rect().contains(event.position())) {
m_may_be_color_rect_click = true;
return;
}
@ -69,7 +69,7 @@ void ColorInput::mousedown_event(MouseEvent& event)
void ColorInput::mouseup_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left) {
if (event.button() == MouseButton::Primary) {
bool is_color_rect_click = m_may_be_color_rect_click && color_rect().contains(event.position());
m_may_be_color_rect_click = false;
if (is_color_rect_click) {

View file

@ -611,7 +611,7 @@ void ColorField::pick_color_at_position(GUI::MouseEvent& event)
void ColorField::mousedown_event(GUI::MouseEvent& event)
{
if (event.button() == GUI::MouseButton::Left) {
if (event.button() == GUI::MouseButton::Primary) {
m_being_pressed = true;
pick_color_at_position(event);
}
@ -619,7 +619,7 @@ void ColorField::mousedown_event(GUI::MouseEvent& event)
void ColorField::mouseup_event(GUI::MouseEvent& event)
{
if (event.button() == GUI::MouseButton::Left) {
if (event.button() == GUI::MouseButton::Primary) {
m_being_pressed = false;
pick_color_at_position(event);
}
@ -627,7 +627,7 @@ void ColorField::mouseup_event(GUI::MouseEvent& event)
void ColorField::mousemove_event(GUI::MouseEvent& event)
{
if (event.buttons() & GUI::MouseButton::Left)
if (event.buttons() & GUI::MouseButton::Primary)
pick_color_at_position(event);
}
@ -705,7 +705,7 @@ void ColorSlider::pick_value_at_position(GUI::MouseEvent& event)
void ColorSlider::mousedown_event(GUI::MouseEvent& event)
{
if (event.button() == GUI::MouseButton::Left) {
if (event.button() == GUI::MouseButton::Primary) {
m_being_pressed = true;
pick_value_at_position(event);
}
@ -713,7 +713,7 @@ void ColorSlider::mousedown_event(GUI::MouseEvent& event)
void ColorSlider::mouseup_event(GUI::MouseEvent& event)
{
if (event.button() == GUI::MouseButton::Left) {
if (event.button() == GUI::MouseButton::Primary) {
m_being_pressed = false;
pick_value_at_position(event);
}
@ -721,7 +721,7 @@ void ColorSlider::mouseup_event(GUI::MouseEvent& event)
void ColorSlider::mousemove_event(GUI::MouseEvent& event)
{
if (event.buttons() & GUI::MouseButton::Left)
if (event.buttons() & GUI::MouseButton::Primary)
pick_value_at_position(event);
}

View file

@ -246,7 +246,7 @@ void ColumnsView::mousedown_event(MouseEvent& event)
if (!model())
return;
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
auto index = index_at_event_position(event.position());

View file

@ -311,8 +311,8 @@ public:
enum MouseButton : u8 {
None = 0,
Left = 1,
Right = 2,
Primary = 1,
Secondary = 2,
Middle = 4,
Back = 8,
Forward = 16,

View file

@ -142,7 +142,7 @@ void HeaderView::doubleclick_event(MouseEvent& event)
void HeaderView::mousedown_event(MouseEvent& event)
{
if (event.button() != GUI::MouseButton::Left)
if (event.button() != GUI::MouseButton::Primary)
return;
if (!model())
@ -227,7 +227,7 @@ void HeaderView::mousemove_event(MouseEvent& event)
void HeaderView::mouseup_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left) {
if (event.button() == MouseButton::Primary) {
if (m_in_section_resize) {
if (!section_resize_grabbable_rect(m_resizing_section).contains(event.position()))
set_override_cursor(Gfx::StandardCursor::None);

View file

@ -214,7 +214,7 @@ void IconView::mousedown_event(MouseEvent& event)
if (!model())
return AbstractView::mousedown_event(event);
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return AbstractView::mousedown_event(event);
auto index = index_at_event_position(event.position());
@ -239,7 +239,7 @@ void IconView::mousedown_event(MouseEvent& event)
void IconView::mouseup_event(MouseEvent& event)
{
if (m_rubber_banding && event.button() == MouseButton::Left) {
if (m_rubber_banding && event.button() == MouseButton::Primary) {
m_rubber_banding = false;
if (m_out_of_view_timer)
m_out_of_view_timer->stop();

View file

@ -54,7 +54,7 @@ void LinkLabel::mousemove_event(MouseEvent& event)
void LinkLabel::mousedown_event(MouseEvent& event)
{
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
Label::mousedown_event(event);

View file

@ -111,7 +111,7 @@ int OpacitySlider::value_at(const Gfx::IntPoint& position) const
void OpacitySlider::mousedown_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left) {
if (event.button() == MouseButton::Primary) {
m_dragging = true;
set_value(value_at(event.position()));
return;
@ -130,7 +130,7 @@ void OpacitySlider::mousemove_event(MouseEvent& event)
void OpacitySlider::mouseup_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left) {
if (event.button() == MouseButton::Primary) {
m_dragging = false;
return;
}

View file

@ -85,7 +85,7 @@ void ResizeCorner::paint_event(PaintEvent& event)
void ResizeCorner::mousedown_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left)
if (event.button() == MouseButton::Primary)
window()->start_interactive_resize();
Widget::mousedown_event(event);
}

View file

@ -220,7 +220,7 @@ void Scrollbar::on_automatic_scrolling_timer_fired()
void Scrollbar::mousedown_event(MouseEvent& event)
{
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
if (!has_scrubber())
return;
@ -259,7 +259,7 @@ void Scrollbar::mousedown_event(MouseEvent& event)
void Scrollbar::mouseup_event(MouseEvent& event)
{
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
set_automatic_scrolling_active(false, Component::None);
update();

View file

@ -80,7 +80,7 @@ Gfx::IntRect Slider::knob_rect() const
void Slider::mousedown_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left) {
if (event.button() == MouseButton::Primary) {
if (knob_rect().contains(event.position())) {
m_dragging = true;
m_drag_origin = event.position();
@ -128,7 +128,7 @@ void Slider::mousemove_event(MouseEvent& event)
void Slider::mouseup_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left) {
if (event.button() == MouseButton::Primary) {
m_dragging = false;
return;
}

View file

@ -121,7 +121,7 @@ Splitter::Grabbable* Splitter::grabbable_at(Gfx::IntPoint const& position)
void Splitter::mousedown_event(MouseEvent& event)
{
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
auto* grabbable = grabbable_at(event.position());
@ -235,7 +235,7 @@ void Splitter::did_layout()
void Splitter::mouseup_event(MouseEvent& event)
{
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
m_resizing = false;
m_first_resizee = nullptr;

View file

@ -416,7 +416,7 @@ void TabWidget::mousedown_event(MouseEvent& event)
if (!button_rect.contains(event.position()))
continue;
if (event.button() == MouseButton::Left) {
if (event.button() == MouseButton::Primary) {
if (m_close_button_enabled && close_button_rect.contains(event.position())) {
m_pressed_close_button_index = i;
update_bar();
@ -437,7 +437,7 @@ void TabWidget::mousedown_event(MouseEvent& event)
void TabWidget::mouseup_event(MouseEvent& event)
{
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
if (m_dragging_active_tab) {

View file

@ -103,7 +103,7 @@ void UrlBox::mousedown_event(GUI::MouseEvent& event)
if (is_displayonly())
return;
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
if (is_focus_transition()) {

View file

@ -205,7 +205,7 @@ TextPosition TextEditor::text_position_at(Gfx::IntPoint const& widget_position)
void TextEditor::doubleclick_event(MouseEvent& event)
{
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
if (is_displayonly())
@ -244,7 +244,7 @@ void TextEditor::doubleclick_event(MouseEvent& event)
void TextEditor::mousedown_event(MouseEvent& event)
{
if (event.button() != MouseButton::Left) {
if (event.button() != MouseButton::Primary) {
return;
}
@ -287,7 +287,7 @@ void TextEditor::mousedown_event(MouseEvent& event)
void TextEditor::mouseup_event(MouseEvent& event)
{
if (event.button() == MouseButton::Left) {
if (event.button() == MouseButton::Primary) {
if (m_in_drag_select) {
m_in_drag_select = false;
}

View file

@ -122,7 +122,7 @@ void Tray::mousemove_event(GUI::MouseEvent& event)
void Tray::mousedown_event(GUI::MouseEvent& event)
{
if (event.button() != GUI::MouseButton::Left)
if (event.button() != GUI::MouseButton::Primary)
return;
auto* pressed_item = item_at(event.position());
@ -137,7 +137,7 @@ void Tray::mousedown_event(GUI::MouseEvent& event)
void Tray::mouseup_event(GUI::MouseEvent& event)
{
if (event.button() != GUI::MouseButton::Left)
if (event.button() != GUI::MouseButton::Primary)
return;
if (auto* pressed_item = item_at(event.position()); pressed_item && m_pressed_item_index == pressed_item->index) {

View file

@ -79,7 +79,7 @@ void TreeView::doubleclick_event(MouseEvent& event)
if (!index.is_valid())
return;
if (event.button() == MouseButton::Left) {
if (event.button() == MouseButton::Primary) {
set_cursor(index, SelectionUpdate::Set);
if (model.row_count(index))

View file

@ -180,7 +180,7 @@ void ValueSlider::mousemove_event(MouseEvent& event)
void ValueSlider::mousedown_event(MouseEvent& event)
{
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
m_textbox->set_focus(true);
@ -193,7 +193,7 @@ void ValueSlider::mousedown_event(MouseEvent& event)
void ValueSlider::mouseup_event(MouseEvent& event)
{
if (event.button() != MouseButton::Left)
if (event.button() != MouseButton::Primary)
return;
m_dragging = false;

View file

@ -422,7 +422,7 @@ void Widget::handle_mousedown_event(MouseEvent& event)
if (has_flag(focus_policy(), FocusPolicy::ClickFocus))
set_focus(true, FocusSource::Mouse);
mousedown_event(event);
if (event.button() == MouseButton::Right) {
if (event.button() == MouseButton::Secondary) {
ContextMenuEvent c_event(event.position(), screen_relative_rect().location().translated(event.position()));
dispatch_event(c_event);
}

View file

@ -212,9 +212,9 @@ static MouseButton to_mouse_button(u32 button)
case 0:
return MouseButton::None;
case 1:
return MouseButton::Left;
return MouseButton::Primary;
case 2:
return MouseButton::Right;
return MouseButton::Secondary;
case 4:
return MouseButton::Middle;
case 8:

View file

@ -715,7 +715,7 @@ VT::Range TerminalWidget::find_previous(const StringView& needle, const VT::Posi
void TerminalWidget::doubleclick_event(GUI::MouseEvent& event)
{
if (event.button() == GUI::MouseButton::Left) {
if (event.button() == GUI::MouseButton::Primary) {
auto attribute = m_terminal.attribute_at(buffer_position_at(event.position()));
if (!attribute.href_id.is_null()) {
dbgln("Open hyperlinked URL: '{}'", attribute.href);
@ -769,7 +769,7 @@ void TerminalWidget::copy()
void TerminalWidget::mouseup_event(GUI::MouseEvent& event)
{
if (event.button() == GUI::MouseButton::Left) {
if (event.button() == GUI::MouseButton::Primary) {
if (!m_active_href_id.is_null()) {
m_active_href = {};
m_active_href_id = {};
@ -781,7 +781,7 @@ void TerminalWidget::mouseup_event(GUI::MouseEvent& event)
void TerminalWidget::mousedown_event(GUI::MouseEvent& event)
{
if (event.button() == GUI::MouseButton::Left) {
if (event.button() == GUI::MouseButton::Primary) {
m_left_mousedown_position = event.position();
m_left_mousedown_position_buffer = buffer_position_at(m_left_mousedown_position);
@ -836,7 +836,7 @@ void TerminalWidget::mousemove_event(GUI::MouseEvent& event)
update();
}
if (!(event.buttons() & GUI::MouseButton::Left))
if (!(event.buttons() & GUI::MouseButton::Primary))
return;
if (!m_active_href_id.is_null()) {

View file

@ -53,7 +53,7 @@ void ButtonBox::paint(PaintContext& context, PaintPhase phase)
void ButtonBox::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned)
{
if (button != GUI::MouseButton::Left || !dom_node().enabled())
if (button != GUI::MouseButton::Primary || !dom_node().enabled())
return;
m_being_pressed = true;
@ -65,7 +65,7 @@ void ButtonBox::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsi
void ButtonBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
{
if (!m_tracking_mouse || button != GUI::MouseButton::Left || !dom_node().enabled())
if (!m_tracking_mouse || button != GUI::MouseButton::Primary || !dom_node().enabled())
return;
// NOTE: Handling the click may run arbitrary JS, which could disappear this node.

View file

@ -39,7 +39,7 @@ void CheckBox::paint(PaintContext& context, PaintPhase phase)
void CheckBox::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned)
{
if (button != GUI::MouseButton::Left || !dom_node().enabled())
if (button != GUI::MouseButton::Primary || !dom_node().enabled())
return;
m_being_pressed = true;
@ -51,7 +51,7 @@ void CheckBox::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsig
void CheckBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
{
if (!m_tracking_mouse || button != GUI::MouseButton::Left || !dom_node().enabled())
if (!m_tracking_mouse || button != GUI::MouseButton::Primary || !dom_node().enabled())
return;
// NOTE: Changing the checked state of the DOM node may run arbitrary JS, which could disappear this node.

View file

@ -28,7 +28,7 @@ Label::~Label()
void Label::handle_mousedown_on_label(Badge<TextNode>, const Gfx::IntPoint&, unsigned button)
{
if (button != GUI::MouseButton::Left)
if (button != GUI::MouseButton::Primary)
return;
if (auto* control = control_node(); control)
@ -39,7 +39,7 @@ void Label::handle_mousedown_on_label(Badge<TextNode>, const Gfx::IntPoint&, uns
void Label::handle_mouseup_on_label(Badge<TextNode>, const Gfx::IntPoint& position, unsigned button)
{
if (!m_tracking_mouse || button != GUI::MouseButton::Left)
if (!m_tracking_mouse || button != GUI::MouseButton::Primary)
return;
// NOTE: Changing the checked state of the DOM node may run arbitrary JS, which could disappear this node.

View file

@ -39,7 +39,7 @@ void RadioButton::paint(PaintContext& context, PaintPhase phase)
void RadioButton::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned)
{
if (button != GUI::MouseButton::Left || !dom_node().enabled())
if (button != GUI::MouseButton::Primary || !dom_node().enabled())
return;
m_being_pressed = true;
@ -51,7 +51,7 @@ void RadioButton::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, un
void RadioButton::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
{
if (!m_tracking_mouse || button != GUI::MouseButton::Left || !dom_node().enabled())
if (!m_tracking_mouse || button != GUI::MouseButton::Primary || !dom_node().enabled())
return;
// NOTE: Changing the checked state of the DOM node may run arbitrary JS, which could disappear this node.

View file

@ -168,7 +168,7 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button
handled_event = true;
}
if (button == GUI::MouseButton::Left)
if (button == GUI::MouseButton::Primary)
m_in_mouse_selection = false;
return handled_event;
}
@ -224,7 +224,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
if (!layout_root() || layout_root() != node->document().layout_node())
return true;
if (button == GUI::MouseButton::Right && is<HTML::HTMLImageElement>(*node)) {
if (button == GUI::MouseButton::Secondary && is<HTML::HTMLImageElement>(*node)) {
auto& image_element = verify_cast<HTML::HTMLImageElement>(*node);
auto image_url = image_element.document().parse_url(image_element.src());
if (auto* page = m_frame.page())
@ -236,7 +236,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
auto href = link->href();
auto url = document->parse_url(href);
dbgln("Web::EventHandler: Clicking on a link to {}", url);
if (button == GUI::MouseButton::Left) {
if (button == GUI::MouseButton::Primary) {
if (href.starts_with("javascript:")) {
document->run_javascript(href.substring_view(11, href.length() - 11));
} else if (href.starts_with('#')) {
@ -252,7 +252,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
m_frame.loader().load(url, FrameLoader::Type::Navigation);
}
}
} else if (button == GUI::MouseButton::Right) {
} else if (button == GUI::MouseButton::Secondary) {
if (auto* page = m_frame.page())
page->client().page_did_request_link_context_menu(m_frame.to_top_level_position(position), url, link->target(), modifiers);
} else if (button == GUI::MouseButton::Middle) {
@ -260,14 +260,14 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
page->client().page_did_middle_click_link(url, link->target(), modifiers);
}
} else {
if (button == GUI::MouseButton::Left) {
if (button == GUI::MouseButton::Primary) {
auto result = layout_root()->hit_test(position, Layout::HitTestType::TextCursor);
if (result.layout_node && result.layout_node->dom_node()) {
m_frame.set_cursor_position(DOM::Position(*result.layout_node->dom_node(), result.index_in_node));
layout_root()->set_selection({ { result.layout_node, result.index_in_node }, {} });
m_in_mouse_selection = true;
}
} else if (button == GUI::MouseButton::Right) {
} else if (button == GUI::MouseButton::Secondary) {
if (auto* page = m_frame.page())
page->client().page_did_request_context_menu(m_frame.to_top_level_position(position));
}