1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:57: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

@ -186,7 +186,7 @@ void ClockWidget::paint_event(GUI::PaintEvent& event)
void ClockWidget::mousedown_event(GUI::MouseEvent& event)
{
if (event.button() != GUI::MouseButton::Left) {
if (event.button() != GUI::MouseButton::Primary) {
return;
} else {
if (!m_calendar_window->is_visible())

View file

@ -45,14 +45,14 @@ void Button::on_mouse_event(const MouseEvent& event)
auto interesting_button = false;
switch (event.button()) {
case MouseButton::Left:
case MouseButton::Primary:
interesting_button = !!on_click;
break;
case MouseButton::Middle:
interesting_button = !!on_middle_click;
break;
case MouseButton::Right:
interesting_button = !!on_right_click;
case MouseButton::Secondary:
interesting_button = !!on_secondary_click;
break;
default:
break;
@ -63,14 +63,14 @@ void Button::on_mouse_event(const MouseEvent& event)
auto& wm = WindowManager::the();
if (event.type() == Event::MouseDown && (event.button() == MouseButton::Left || event.button() == MouseButton::Right || event.button() == MouseButton::Middle)) {
if (event.type() == Event::MouseDown && (event.button() == MouseButton::Primary || event.button() == MouseButton::Secondary || event.button() == MouseButton::Middle)) {
m_pressed = true;
wm.set_cursor_tracking_button(this);
m_frame.invalidate(m_relative_rect);
return;
}
if (event.type() == Event::MouseUp && (event.button() == MouseButton::Left || event.button() == MouseButton::Right || event.button() == MouseButton::Middle)) {
if (event.type() == Event::MouseUp && (event.button() == MouseButton::Primary || event.button() == MouseButton::Secondary || event.button() == MouseButton::Middle)) {
if (wm.cursor_tracking_button() != this)
return;
wm.set_cursor_tracking_button(nullptr);
@ -78,14 +78,14 @@ void Button::on_mouse_event(const MouseEvent& event)
m_pressed = false;
if (rect().contains(event.position())) {
switch (event.button()) {
case MouseButton::Left:
case MouseButton::Primary:
if (on_click)
on_click(*this);
break;
case MouseButton::Right:
if (on_right_click)
on_right_click(*this);
case MouseButton::Secondary:
if (on_secondary_click)
on_secondary_click(*this);
break;
default:
@ -113,7 +113,7 @@ void Button::on_mouse_event(const MouseEvent& event)
m_frame.invalidate(m_relative_rect);
}
if (event.type() == Event::MouseMove && event.buttons() & (unsigned)MouseButton::Left) {
if (event.type() == Event::MouseMove && event.buttons() & (unsigned)MouseButton::Primary) {
if (wm.cursor_tracking_button() != this)
return;
bool old_pressed = m_pressed;

View file

@ -35,7 +35,7 @@ public:
void on_mouse_event(const MouseEvent&);
Function<void(Button&)> on_click;
Function<void(Button&)> on_right_click;
Function<void(Button&)> on_secondary_click;
Function<void(Button&)> on_middle_click;
bool is_visible() const { return m_visible; }

View file

@ -727,7 +727,7 @@ void ClientConnection::start_window_resize(i32 window_id)
}
// FIXME: We are cheating a bit here by using the current cursor location and hard-coding the left button.
// Maybe the client should be allowed to specify what initiated this request?
WindowManager::the().start_window_resize(window, ScreenInput::the().cursor_location(), MouseButton::Left);
WindowManager::the().start_window_resize(window, ScreenInput::the().cursor_location(), MouseButton::Primary);
}
Messages::WindowServer::StartDragResponse ClientConnection::start_drag(String const& text, HashMap<String, ByteBuffer> const& mime_data, Gfx::ShareableBitmap const& drag_bitmap)

View file

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

View file

@ -449,8 +449,8 @@ void ScreenInput::on_receive_mouse_data(const MousePacket& packet)
auto message = make<MouseEvent>(buttons & (unsigned)button ? Event::MouseDown : Event::MouseUp, m_cursor_location, buttons, button, m_modifiers);
Core::EventLoop::current().post_event(WindowManager::the(), move(message));
};
post_mousedown_or_mouseup_if_needed(MouseButton::Left);
post_mousedown_or_mouseup_if_needed(MouseButton::Right);
post_mousedown_or_mouseup_if_needed(MouseButton::Primary);
post_mousedown_or_mouseup_if_needed(MouseButton::Secondary);
post_mousedown_or_mouseup_if_needed(MouseButton::Middle);
post_mousedown_or_mouseup_if_needed(MouseButton::Back);
post_mousedown_or_mouseup_if_needed(MouseButton::Forward);

View file

@ -100,7 +100,7 @@ void WMClientConnection::start_window_resize(i32 client_id, i32 window_id)
auto& window = *(*it).value;
// FIXME: We are cheating a bit here by using the current cursor location and hard-coding the left button.
// Maybe the client should be allowed to specify what initiated this request?
WindowManager::the().start_window_resize(window, ScreenInput::the().cursor_location(), MouseButton::Left);
WindowManager::the().start_window_resize(window, ScreenInput::the().cursor_location(), MouseButton::Primary);
}
void WMClientConnection::set_window_minimized(i32 client_id, i32 window_id, bool minimized)

View file

@ -700,7 +700,7 @@ bool WindowFrame::handle_titlebar_icon_mouse_event(MouseEvent const& event)
{
auto& wm = WindowManager::the();
if (event.type() == Event::MouseDown && (event.button() == MouseButton::Left || event.button() == MouseButton::Right)) {
if (event.type() == Event::MouseDown && (event.button() == MouseButton::Primary || event.button() == MouseButton::Secondary)) {
// Manually start a potential double click. Since we're opening
// a menu, we will only receive the MouseDown event, so we
// need to record that fact. If the user subsequently clicks
@ -714,7 +714,7 @@ bool WindowFrame::handle_titlebar_icon_mouse_event(MouseEvent const& event)
m_window.popup_window_menu(titlebar_rect().bottom_left().translated(rect().location()), WindowMenuDefaultAction::Close);
return true;
} else if (event.type() == Event::MouseUp && event.button() == MouseButton::Left) {
} else if (event.type() == Event::MouseUp && event.button() == MouseButton::Primary) {
// Since the MouseDown event opened a menu, another MouseUp
// from the second click outside the menu wouldn't be considered
// a double click, so let's manually check if it would otherwise
@ -743,12 +743,12 @@ void WindowFrame::handle_titlebar_mouse_event(MouseEvent const& event)
}
if (event.type() == Event::MouseDown) {
if ((m_window.type() == WindowType::Normal || m_window.type() == WindowType::ToolWindow) && event.button() == MouseButton::Right) {
if ((m_window.type() == WindowType::Normal || m_window.type() == WindowType::ToolWindow) && event.button() == MouseButton::Secondary) {
auto default_action = m_window.is_maximized() ? WindowMenuDefaultAction::Restore : WindowMenuDefaultAction::Maximize;
m_window.popup_window_menu(event.position().translated(rect().location()), default_action);
return;
}
if (m_window.is_movable() && event.button() == MouseButton::Left)
if (m_window.is_movable() && event.button() == MouseButton::Primary)
wm.start_window_move(m_window, event.translated(rect().location()));
}
}
@ -812,7 +812,7 @@ void WindowFrame::handle_border_mouse_event(const MouseEvent& event)
return;
}
if (event.type() == Event::MouseDown && event.button() == MouseButton::Left)
if (event.type() == Event::MouseDown && event.button() == MouseButton::Primary)
wm.start_window_resize(m_window, event.translated(rect().location()));
}
@ -851,7 +851,7 @@ void WindowFrame::handle_menu_mouse_event(Menu& menu, const MouseEvent& event)
{
auto menubar_rect = this->menubar_rect();
bool is_hover_with_any_menu_open = event.type() == MouseEvent::MouseMove && &m_window == WindowManager::the().window_with_active_menu();
bool is_mousedown_with_left_button = event.type() == MouseEvent::MouseDown && event.button() == MouseButton::Left;
bool is_mousedown_with_left_button = event.type() == MouseEvent::MouseDown && event.button() == MouseButton::Primary;
bool should_open_menu = &menu != MenuManager::the().current_menu() && (is_hover_with_any_menu_open || is_mousedown_with_left_button);
bool should_close_menu = &menu == MenuManager::the().current_menu() && is_mousedown_with_left_button;

View file

@ -724,7 +724,7 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event)
{
if (!m_move_window)
return false;
if (event.type() == Event::MouseUp && event.button() == MouseButton::Left) {
if (event.type() == Event::MouseUp && event.button() == MouseButton::Primary) {
dbgln_if(MOVE_DEBUG, "[WM] Finish moving Window({})", m_move_window);
@ -964,7 +964,7 @@ bool WindowManager::process_ongoing_drag(MouseEvent& event)
});
}
if (!(event.type() == Event::MouseUp && event.button() == MouseButton::Left))
if (!(event.type() == Event::MouseUp && event.button() == MouseButton::Primary))
return true;
if (auto* window = current_window_stack().window_at(event.position())) {
@ -989,10 +989,10 @@ void WindowManager::set_cursor_tracking_button(Button* button)
auto WindowManager::DoubleClickInfo::metadata_for_button(MouseButton button) const -> ClickMetadata const&
{
switch (button) {
case MouseButton::Left:
return m_left;
case MouseButton::Right:
return m_right;
case MouseButton::Primary:
return m_primary;
case MouseButton::Secondary:
return m_secondary;
case MouseButton::Middle:
return m_middle;
case MouseButton::Back:
@ -1007,10 +1007,10 @@ auto WindowManager::DoubleClickInfo::metadata_for_button(MouseButton button) con
auto WindowManager::DoubleClickInfo::metadata_for_button(MouseButton button) -> ClickMetadata&
{
switch (button) {
case MouseButton::Left:
return m_left;
case MouseButton::Right:
return m_right;
case MouseButton::Primary:
return m_primary;
case MouseButton::Secondary:
return m_secondary;
case MouseButton::Middle:
return m_middle;
case MouseButton::Back:
@ -1163,11 +1163,11 @@ void WindowManager::process_mouse_event_for_window(HitTestResult& result, MouseE
// First check if we should initiate a move or resize (Super+LMB or Super+RMB).
// In those cases, the event is swallowed by the window manager.
if (!blocking_modal_window && window.is_movable()) {
if (!window.is_fullscreen() && m_keyboard_modifiers == Mod_Super && event.type() == Event::MouseDown && event.button() == MouseButton::Left) {
if (!window.is_fullscreen() && m_keyboard_modifiers == Mod_Super && event.type() == Event::MouseDown && event.button() == MouseButton::Primary) {
start_window_move(window, event);
return;
}
if (window.is_resizable() && m_keyboard_modifiers == Mod_Super && event.type() == Event::MouseDown && event.button() == MouseButton::Right && !window.blocking_modal_window()) {
if (window.is_resizable() && m_keyboard_modifiers == Mod_Super && event.type() == Event::MouseDown && event.button() == MouseButton::Secondary && !window.blocking_modal_window()) {
start_window_resize(window, event);
return;
}

View file

@ -388,8 +388,8 @@ private:
void reset()
{
m_left = {};
m_right = {};
m_primary = {};
m_secondary = {};
m_middle = {};
m_back = {};
m_forward = {};
@ -398,8 +398,8 @@ private:
WeakPtr<Window> m_clicked_window;
private:
ClickMetadata m_left;
ClickMetadata m_right;
ClickMetadata m_primary;
ClickMetadata m_secondary;
ClickMetadata m_middle;
ClickMetadata m_back;
ClickMetadata m_forward;