Commit ffacd6b1 authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Commit Bot

x11: Do not use XEvent in WebMouseEvent translation

Bug: 965991
Change-Id: I575ed42f820dfd328bcb557754441176058cab40
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1813857
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698749}
parent d8dfdb5a
...@@ -393,22 +393,17 @@ blink::WebMouseEvent MakeWebMouseEventFromUiEvent(const MouseEvent& event) { ...@@ -393,22 +393,17 @@ blink::WebMouseEvent MakeWebMouseEventFromUiEvent(const MouseEvent& event) {
click_count = event.GetClickCount(); click_count = event.GetClickCount();
break; break;
case ET_MOUSE_EXITED: { case ET_MOUSE_EXITED: {
#if defined(USE_X11) // When MOUSE_EXITED is created for intermediate windows that the
// NotifyVirtual events are created for intermediate windows that the // pointer crosses through, change these into mouse move events.
// pointer crosses through. These occur when middle clicking. const Event::Properties* props = event.properties();
// Change these into mouse move events. if (props && props->contains(kPropertyMouseCrossedIntermediateWindow)) {
const PlatformEvent& native_event = event.native_event();
if (native_event && native_event->type == LeaveNotify &&
native_event->xcrossing.detail == NotifyVirtual) {
type = blink::WebInputEvent::kMouseMove; type = blink::WebInputEvent::kMouseMove;
break; } else {
static bool s_send_leave =
base::FeatureList::IsEnabled(features::kSendMouseLeaveEvents);
type = s_send_leave ? blink::WebInputEvent::kMouseLeave
: blink::WebInputEvent::kMouseMove;
} }
#endif
static bool s_send_leave =
base::FeatureList::IsEnabled(features::kSendMouseLeaveEvents);
type = s_send_leave ? blink::WebInputEvent::kMouseLeave
: blink::WebInputEvent::kMouseMove;
break; break;
} }
case ET_MOUSE_ENTERED: case ET_MOUSE_ENTERED:
......
...@@ -52,19 +52,28 @@ bool X11EventHasNonStandardState(const PlatformEvent& event) { ...@@ -52,19 +52,28 @@ bool X11EventHasNonStandardState(const PlatformEvent& event) {
return event && (event->xkey.state & ~kAllStateMask) != 0; return event && (event->xkey.state & ~kAllStateMask) != 0;
} }
Event::Properties GetKeyEventPropertiesFromXKeyEvent(const XKeyEvent& xev) { Event::Properties GetEventPropertiesFromXEvent(EventType type,
const XEvent& xev) {
using Values = std::vector<uint8_t>; using Values = std::vector<uint8_t>;
Event::Properties properties; Event::Properties properties;
if (type == ET_KEY_PRESSED || type == ET_KEY_RELEASED) {
// Keyboard group // Keyboard group
uint8_t group = XkbGroupForCoreState(xev.state); uint8_t group = XkbGroupForCoreState(xev.xkey.state);
properties.emplace(kPropertyKeyboardGroup, Values{group}); properties.emplace(kPropertyKeyboardGroup, Values{group});
// IBus-gtk specific flags // IBus-gtk specific flags
uint8_t ibus_flags = (xev.state >> kPropertyKeyboardIBusFlagOffset) & uint8_t ibus_flags = (xev.xkey.state >> kPropertyKeyboardIBusFlagOffset) &
kPropertyKeyboardIBusFlagMask; kPropertyKeyboardIBusFlagMask;
properties.emplace(kPropertyKeyboardIBusFlag, Values{ibus_flags}); properties.emplace(kPropertyKeyboardIBusFlag, Values{ibus_flags});
} else if (type == ET_MOUSE_EXITED) {
// NotifyVirtual events are created for intermediate windows that the
// pointer crosses through. These occur when middle clicking.
// Change these into mouse move events.
bool crossing_intermediate_window = xev.xcrossing.detail == NotifyVirtual;
properties.emplace(kPropertyMouseCrossedIntermediateWindow,
crossing_intermediate_window);
}
return properties; return properties;
} }
#endif #endif
...@@ -494,6 +503,9 @@ MouseEvent::MouseEvent(const PlatformEvent& native_event) ...@@ -494,6 +503,9 @@ MouseEvent::MouseEvent(const PlatformEvent& native_event)
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT); latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT);
if (type() == ET_MOUSE_PRESSED || type() == ET_MOUSE_RELEASED) if (type() == ET_MOUSE_PRESSED || type() == ET_MOUSE_RELEASED)
SetClickCount(GetRepeatCount(*this)); SetClickCount(GetRepeatCount(*this));
#if defined(USE_X11)
SetProperties(GetEventPropertiesFromXEvent(type(), *native_event));
#endif
} }
MouseEvent::MouseEvent(EventType type, MouseEvent::MouseEvent(EventType type,
...@@ -909,7 +921,7 @@ KeyEvent::KeyEvent(const PlatformEvent& native_event, int event_flags) ...@@ -909,7 +921,7 @@ KeyEvent::KeyEvent(const PlatformEvent& native_event, int event_flags)
#if defined(USE_X11) #if defined(USE_X11)
NormalizeFlags(); NormalizeFlags();
key_ = GetDomKeyFromXEvent(native_event); key_ = GetDomKeyFromXEvent(native_event);
SetProperties(GetKeyEventPropertiesFromXKeyEvent(native_event->xkey)); SetProperties(GetEventPropertiesFromXEvent(type(), *native_event));
#elif defined(OS_WIN) #elif defined(OS_WIN)
// Only Windows has native character events. // Only Windows has native character events.
if (is_char_) { if (is_char_) {
......
...@@ -50,6 +50,11 @@ constexpr char kPropertyKeyboardIBusFlag[] = "_keyevent_kbd_ibus_ime_flags_"; ...@@ -50,6 +50,11 @@ constexpr char kPropertyKeyboardIBusFlag[] = "_keyevent_kbd_ibus_ime_flags_";
constexpr unsigned int kPropertyKeyboardIBusFlagOffset = 24; constexpr unsigned int kPropertyKeyboardIBusFlagOffset = 24;
constexpr unsigned int kPropertyKeyboardIBusFlagMask = 0x03; constexpr unsigned int kPropertyKeyboardIBusFlagMask = 0x03;
// Key used to store mouse event flag telling ET_MOUSE_EXITED must actually be
// interpreted as "crossing intermediate window" in blink context.
constexpr char kPropertyMouseCrossedIntermediateWindow[] =
"_mouseevent_cros_window_";
// Returns a ui::Event wrapping a native event. Ownership of the returned value // Returns a ui::Event wrapping a native event. Ownership of the returned value
// is transferred to the caller. // is transferred to the caller.
EVENTS_EXPORT std::unique_ptr<Event> EventFromNative( EVENTS_EXPORT std::unique_ptr<Event> EventFromNative(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment