UI/AppKit+LibWeb: Handle the Ctrl+click context menu in EventHandler
Changing Ctrl+click to a secondary click is incorrect. It prevents sites from using Ctrl+click themselves. Instead, just maybe open the context menu in mousedown for primary clicks with Ctrl pressed. Fixes the autofire shortcut not working in the Humble Mozilla Bundle's asm.js FTL.
This commit is contained in:
parent
bdda60f9c8
commit
07cf09a0f2
2 changed files with 8 additions and 8 deletions
|
|
@ -1285,6 +1285,10 @@ EventResult EventHandler::handle_mousedown(CSSPixelPoint visual_viewport_positio
|
|||
// do so in mouseup, so we should make this configurable by the UI.
|
||||
if (button == UIEvents::MouseButton::Secondary)
|
||||
maybe_show_context_menu(*node, coordinates, screen_position, viewport_position, buttons, modifiers);
|
||||
#if defined(AK_OS_MACOS)
|
||||
if (button == UIEvents::MouseButton::Primary && (modifiers & UIEvents::KeyModifier::Mod_Ctrl) != 0)
|
||||
maybe_show_context_menu(*node, coordinates, screen_position, viewport_position, buttons, modifiers);
|
||||
#endif
|
||||
|
||||
// NB: Dispatching an event may have disturbed the world.
|
||||
if (m_navigable->active_document() != document)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace Ladybird {
|
||||
|
||||
static Web::UIEvents::KeyModifier ns_modifiers_to_key_modifiers(NSEventModifierFlags modifier_flags, Optional<Web::UIEvents::MouseButton&> button = {})
|
||||
static Web::UIEvents::KeyModifier ns_modifiers_to_key_modifiers(NSEventModifierFlags modifier_flags)
|
||||
{
|
||||
unsigned modifiers = Web::UIEvents::KeyModifier::Mod_None;
|
||||
|
||||
|
|
@ -24,11 +24,7 @@ static Web::UIEvents::KeyModifier ns_modifiers_to_key_modifiers(NSEventModifierF
|
|||
modifiers |= Web::UIEvents::KeyModifier::Mod_Shift;
|
||||
}
|
||||
if ((modifier_flags & NSEventModifierFlagControl) != 0) {
|
||||
if (button == Web::UIEvents::MouseButton::Primary) {
|
||||
*button = Web::UIEvents::MouseButton::Secondary;
|
||||
} else {
|
||||
modifiers |= Web::UIEvents::KeyModifier::Mod_Ctrl;
|
||||
}
|
||||
modifiers |= Web::UIEvents::KeyModifier::Mod_Ctrl;
|
||||
}
|
||||
if ((modifier_flags & NSEventModifierFlagOption) != 0) {
|
||||
modifiers |= Web::UIEvents::KeyModifier::Mod_Alt;
|
||||
|
|
@ -48,7 +44,7 @@ Web::MouseEvent ns_event_to_mouse_event(Web::MouseEvent::Type type, NSEvent* eve
|
|||
auto screen_position = [NSEvent mouseLocation];
|
||||
auto device_screen_position = ns_point_to_gfx_point(screen_position).to_type<Web::DevicePixels>();
|
||||
|
||||
auto modifiers = ns_modifiers_to_key_modifiers(event.modifierFlags, button);
|
||||
auto modifiers = ns_modifiers_to_key_modifiers(event.modifierFlags);
|
||||
|
||||
int wheel_delta_x = 0;
|
||||
int wheel_delta_y = 0;
|
||||
|
|
@ -93,7 +89,7 @@ Web::DragEvent ns_event_to_drag_event(Web::DragEvent::Type type, id<NSDraggingIn
|
|||
auto device_screen_position = ns_point_to_gfx_point(screen_position).to_type<Web::DevicePixels>();
|
||||
|
||||
auto button = Web::UIEvents::MouseButton::Primary;
|
||||
auto modifiers = ns_modifiers_to_key_modifiers([NSEvent modifierFlags], button);
|
||||
auto modifiers = ns_modifiers_to_key_modifiers([NSEvent modifierFlags]);
|
||||
|
||||
Vector<Web::HTML::SelectedFile> files;
|
||||
OwnPtr<DragData> browser_data;
|
||||
|
|
|
|||
Loading…
Reference in a new issue