Avoiding windows.h using CHROME_MSG, etc.
In order to avoid having platform_events.h including windows.h just to get the definition of the MSG struct (thus polluting ~1,000 translation units with the windows.h macros) this change defines the CHROME_MSG struct (following the pattern of CHROME_SRWLOCK and others) and uses it. In the few (two) places where the MSG type is required in order to call in to Windows a reinterpret_cast function does the conversion. This change also removes some includes of windows.h and objidl.h from headers, and adds includes of windows.h to .cc files that need it. The net result is a significant drop in how many translation units get namespace polluted by windows.h. This change touches many files, but most of the changes are just replacing MSG with CHROME_MSG. This change has been tested to ensure that it builds with is_chrome_branded=true and enable_nacl=true to reduce the risk of compile breakage on other bots. Bug: 796644 Change-Id: I8aa2b6a7106923303b6a8f4f60e1d0167cfc5da3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3095785 Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Peter Kasting <pkasting@chromium.org> Reviewed-by: Mark Pearson <mpearson@chromium.org> Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Cr-Commit-Position: refs/heads/main@{#914906}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
73f5723054
commit
f6278aeb01
base/win
chrome/browser
content/renderer
ui
base
dragdrop
ime
events
platform_window
views
@ -42,3 +42,4 @@ static_assert(sizeof(CHROME_WIN32_FIND_DATA) == sizeof(WIN32_FIND_DATA),
|
||||
static_assert(sizeof(CHROME_FORMATETC) == sizeof(FORMATETC),
|
||||
"Definition mismatch.");
|
||||
static_assert(sizeof(CHROME_LUID) == sizeof(LUID), "Definition mismatch.");
|
||||
static_assert(sizeof(CHROME_MSG) == sizeof(MSG), "Definition mismatch.");
|
||||
|
@ -90,6 +90,7 @@ CHROME_DECLARE_HANDLE(HKL);
|
||||
CHROME_DECLARE_HANDLE(HMENU);
|
||||
CHROME_DECLARE_HANDLE(HWINSTA);
|
||||
CHROME_DECLARE_HANDLE(HWND);
|
||||
CHROME_DECLARE_HANDLE(HMONITOR);
|
||||
#undef CHROME_DECLARE_HANDLE
|
||||
|
||||
typedef LPVOID HINTERNET;
|
||||
@ -170,6 +171,20 @@ struct CHROME_FORMATETC {
|
||||
DWORD tymed;
|
||||
};
|
||||
|
||||
struct CHROME_POINT {
|
||||
LONG x;
|
||||
LONG y;
|
||||
};
|
||||
|
||||
struct CHROME_MSG {
|
||||
HWND hwnd;
|
||||
UINT message;
|
||||
WPARAM wParam;
|
||||
LPARAM lParam;
|
||||
DWORD time;
|
||||
CHROME_POINT pt;
|
||||
};
|
||||
|
||||
// Define some commonly used Windows constants. Note that the layout of these
|
||||
// macros - including internal spacing - must be 100% consistent with windows.h.
|
||||
|
||||
@ -313,6 +328,10 @@ inline const FORMATETC* ChromeToWindowsType(const CHROME_FORMATETC* p) {
|
||||
return reinterpret_cast<const FORMATETC*>(p);
|
||||
}
|
||||
|
||||
inline MSG* ChromeToWindowsType(CHROME_MSG* p) {
|
||||
return reinterpret_cast<MSG*>(p);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// These macros are all defined by windows.h and are also used as the names of
|
||||
|
@ -79,6 +79,8 @@
|
||||
#endif // defined(USE_OZONE) || defined(USE_X11)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
|
||||
#include "base/win/base_win_buildflags.h"
|
||||
#include "base/win/scoped_handle.h"
|
||||
#include "base/win/windows_version.h"
|
||||
|
@ -257,6 +257,9 @@
|
||||
#include "ui/gfx/color_palette.h"
|
||||
#include "ui/native_theme/native_theme_win.h"
|
||||
#include "ui/views/win/scoped_fullscreen_visibility.h"
|
||||
|
||||
// To avoid conflicts with the macro from the Windows SDK...
|
||||
#undef LoadAccelerators
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN)
|
||||
|
@ -480,17 +480,17 @@ class RenderViewImplTest : public RenderViewTest {
|
||||
// WM_KEYDOWN, WM_CHAR, and WM_KEYUP.
|
||||
// WM_KEYDOWN and WM_KEYUP sends virtual-key codes. On the other hand,
|
||||
// WM_CHAR sends a composed Unicode character.
|
||||
MSG msg1 = {NULL, WM_KEYDOWN, static_cast<WPARAM>(key_code), 0};
|
||||
CHROME_MSG msg1 = {NULL, WM_KEYDOWN, static_cast<WPARAM>(key_code), 0};
|
||||
ui::KeyEvent evt1(msg1);
|
||||
NativeWebKeyboardEvent keydown_event(evt1);
|
||||
SendNativeKeyEvent(keydown_event);
|
||||
|
||||
MSG msg2 = {NULL, WM_CHAR, (*output)[0], 0};
|
||||
CHROME_MSG msg2 = {NULL, WM_CHAR, (*output)[0], 0};
|
||||
ui::KeyEvent evt2(msg2);
|
||||
NativeWebKeyboardEvent char_event(evt2);
|
||||
SendNativeKeyEvent(char_event);
|
||||
|
||||
MSG msg3 = {NULL, WM_KEYUP, static_cast<WPARAM>(key_code), 0};
|
||||
CHROME_MSG msg3 = {NULL, WM_KEYUP, static_cast<WPARAM>(key_code), 0};
|
||||
ui::KeyEvent evt3(msg3);
|
||||
NativeWebKeyboardEvent keyup_event(evt3);
|
||||
SendNativeKeyEvent(keyup_event);
|
||||
|
@ -10,10 +10,6 @@
|
||||
#include "base/component_export.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <objidl.h>
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
class FilePath;
|
||||
}
|
||||
|
@ -13,10 +13,6 @@
|
||||
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <objidl.h>
|
||||
#endif
|
||||
|
||||
#include "base/callback_forward.h"
|
||||
#include "base/component_export.h"
|
||||
#include "base/files/file_path.h"
|
||||
|
@ -11,10 +11,6 @@
|
||||
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <objidl.h>
|
||||
#endif
|
||||
|
||||
#include "base/component_export.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "ui/base/clipboard/clipboard_format_type.h"
|
||||
|
@ -24,7 +24,7 @@ void DummyInputMethod::OnBlur() {
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool DummyInputMethod::OnUntranslatedIMEMessage(const MSG event,
|
||||
bool DummyInputMethod::OnUntranslatedIMEMessage(const CHROME_MSG event,
|
||||
NativeEventResult* result) {
|
||||
return false;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class DummyInputMethod : public InputMethod {
|
||||
void OnBlur() override;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool OnUntranslatedIMEMessage(const MSG event,
|
||||
bool OnUntranslatedIMEMessage(const CHROME_MSG event,
|
||||
NativeEventResult* result) override;
|
||||
void OnInputLocaleChanged() override;
|
||||
bool IsInputLocaleCJK() const override;
|
||||
|
@ -72,7 +72,7 @@ class InputMethod {
|
||||
// Called when the focused window receives native IME messages that are not
|
||||
// translated into other predefined event callbacks. Currently this method is
|
||||
// used only for IME functionalities specific to Windows.
|
||||
virtual bool OnUntranslatedIMEMessage(const MSG event,
|
||||
virtual bool OnUntranslatedIMEMessage(const CHROME_MSG event,
|
||||
NativeEventResult* result) = 0;
|
||||
|
||||
// Called by the focused client whenever its input locale is changed.
|
||||
|
@ -43,7 +43,7 @@ void InputMethodBase::OnBlur() {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool InputMethodBase::OnUntranslatedIMEMessage(
|
||||
const MSG event,
|
||||
const CHROME_MSG event,
|
||||
InputMethod::NativeEventResult* result) {
|
||||
return false;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class COMPONENT_EXPORT(UI_BASE_IME) InputMethodBase
|
||||
void OnBlur() override;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool OnUntranslatedIMEMessage(const MSG event,
|
||||
bool OnUntranslatedIMEMessage(const CHROME_MSG event,
|
||||
NativeEventResult* result) override;
|
||||
void OnInputLocaleChanged() override;
|
||||
bool IsInputLocaleCJK() const override;
|
||||
|
@ -11,6 +11,10 @@
|
||||
#include "ui/base/ime/text_input_client.h"
|
||||
#include "ui/events/event.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
namespace ui {
|
||||
|
||||
MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate)
|
||||
@ -64,7 +68,7 @@ void MockInputMethod::OnBlur() {
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool MockInputMethod::OnUntranslatedIMEMessage(const MSG event,
|
||||
bool MockInputMethod::OnUntranslatedIMEMessage(const CHROME_MSG event,
|
||||
NativeEventResult* result) {
|
||||
if (result)
|
||||
*result = NativeEventResult();
|
||||
|
@ -35,7 +35,7 @@ class COMPONENT_EXPORT(UI_BASE_IME) MockInputMethod : public InputMethod {
|
||||
void OnBlur() override;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool OnUntranslatedIMEMessage(const MSG event,
|
||||
bool OnUntranslatedIMEMessage(const CHROME_MSG event,
|
||||
NativeEventResult* result) override;
|
||||
void OnInputLocaleChanged() override;
|
||||
bool IsInputLocaleCJK() const override;
|
||||
|
@ -173,7 +173,7 @@ void InputMethodWinBase::OnDidChangeFocusedClient(
|
||||
|
||||
ui::EventDispatchDetails InputMethodWinBase::DispatchKeyEvent(
|
||||
ui::KeyEvent* event) {
|
||||
MSG native_key_event = MSGFromKeyEvent(event);
|
||||
CHROME_MSG native_key_event = MSGFromKeyEvent(event);
|
||||
if (native_key_event.message == WM_CHAR) {
|
||||
auto ref = weak_ptr_factory_.GetWeakPtr();
|
||||
BOOL handled = FALSE;
|
||||
@ -187,7 +187,7 @@ ui::EventDispatchDetails InputMethodWinBase::DispatchKeyEvent(
|
||||
return ui::EventDispatchDetails();
|
||||
}
|
||||
|
||||
std::vector<MSG> char_msgs;
|
||||
std::vector<CHROME_MSG> char_msgs;
|
||||
// Combines the WM_KEY* and WM_CHAR messages in the event processing flow
|
||||
// which is necessary to let Chrome IME extension to process the key event
|
||||
// and perform corresponding IME actions.
|
||||
@ -237,12 +237,13 @@ ui::EventDispatchDetails InputMethodWinBase::DispatchKeyEvent(
|
||||
bool InputMethodWinBase::HandlePeekMessage(HWND hwnd,
|
||||
UINT msg_filter_min,
|
||||
UINT msg_filter_max,
|
||||
std::vector<MSG>* char_msgs) {
|
||||
std::vector<CHROME_MSG>* char_msgs) {
|
||||
auto ref = weak_ptr_factory_.GetWeakPtr();
|
||||
while (true) {
|
||||
MSG msg_found;
|
||||
const bool result = !!::PeekMessage(&msg_found, hwnd, msg_filter_min,
|
||||
msg_filter_max, PM_REMOVE);
|
||||
CHROME_MSG msg_found;
|
||||
const bool result =
|
||||
!!::PeekMessage(ChromeToWindowsType(&msg_found), hwnd, msg_filter_min,
|
||||
msg_filter_max, PM_REMOVE);
|
||||
// PeekMessage may result in WM_NCDESTROY which will cause deletion of
|
||||
// |this|. We should use WeakPtr to check whether |this| is destroyed.
|
||||
if (!ref)
|
||||
@ -270,7 +271,7 @@ LRESULT InputMethodWinBase::OnChar(HWND window_handle,
|
||||
UINT message,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam,
|
||||
const MSG& event,
|
||||
const CHROME_MSG& event,
|
||||
BOOL* handled) {
|
||||
*handled = TRUE;
|
||||
|
||||
@ -477,9 +478,10 @@ LRESULT InputMethodWinBase::OnQueryCharPosition(IMECHARPOSITION* char_positon) {
|
||||
return 1; // returns non-zero value when succeeded.
|
||||
}
|
||||
|
||||
void InputMethodWinBase::ProcessKeyEventDone(ui::KeyEvent* event,
|
||||
const std::vector<MSG>* char_msgs,
|
||||
bool is_handled) {
|
||||
void InputMethodWinBase::ProcessKeyEventDone(
|
||||
ui::KeyEvent* event,
|
||||
const std::vector<CHROME_MSG>* char_msgs,
|
||||
bool is_handled) {
|
||||
if (is_handled)
|
||||
return;
|
||||
ProcessUnhandledKeyEvent(event, char_msgs);
|
||||
@ -487,7 +489,7 @@ void InputMethodWinBase::ProcessKeyEventDone(ui::KeyEvent* event,
|
||||
|
||||
ui::EventDispatchDetails InputMethodWinBase::ProcessUnhandledKeyEvent(
|
||||
ui::KeyEvent* event,
|
||||
const std::vector<MSG>* char_msgs) {
|
||||
const std::vector<CHROME_MSG>* char_msgs) {
|
||||
DCHECK(event);
|
||||
ui::EventDispatchDetails details = DispatchKeyEventPostIME(event);
|
||||
if (details.dispatcher_destroyed || details.target_destroyed ||
|
||||
|
@ -37,7 +37,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN) InputMethodWinBase
|
||||
UINT message,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam,
|
||||
const MSG& event,
|
||||
const CHROME_MSG& event,
|
||||
BOOL* handled);
|
||||
|
||||
// Some IMEs rely on WM_IME_REQUEST message even when TSF is enabled. So
|
||||
@ -53,12 +53,12 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN) InputMethodWinBase
|
||||
|
||||
// Callback function for IMEEngineHandlerInterface::ProcessKeyEvent.
|
||||
void ProcessKeyEventDone(ui::KeyEvent* event,
|
||||
const std::vector<MSG>* char_msgs,
|
||||
const std::vector<CHROME_MSG>* char_msgs,
|
||||
bool is_handled);
|
||||
|
||||
ui::EventDispatchDetails ProcessUnhandledKeyEvent(
|
||||
ui::KeyEvent* event,
|
||||
const std::vector<MSG>* char_msgs);
|
||||
const std::vector<CHROME_MSG>* char_msgs);
|
||||
|
||||
// The toplevel window handle.
|
||||
const HWND toplevel_window_handle_;
|
||||
@ -82,7 +82,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN) InputMethodWinBase
|
||||
bool HandlePeekMessage(HWND hwnd,
|
||||
UINT msg_filter_min,
|
||||
UINT msg_filter_max,
|
||||
std::vector<MSG>* char_msgs);
|
||||
std::vector<CHROME_MSG>* char_msgs);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(InputMethodWinBase);
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ void InputMethodWinImm32::OnFocus() {
|
||||
}
|
||||
|
||||
bool InputMethodWinImm32::OnUntranslatedIMEMessage(
|
||||
const MSG event,
|
||||
const CHROME_MSG event,
|
||||
InputMethod::NativeEventResult* result) {
|
||||
LRESULT original_result = 0;
|
||||
BOOL handled = FALSE;
|
||||
@ -268,9 +268,9 @@ LRESULT InputMethodWinImm32::OnImeEndComposition(HWND window_handle,
|
||||
// Also see Firefox's implementation:
|
||||
// https://dxr.mozilla.org/mozilla-beta/source/widget/windows/IMMHandler.cpp#800
|
||||
// TODO(crbug.com/654865): Further investigations and clean-ups required.
|
||||
MSG compositionMsg;
|
||||
if (::PeekMessage(&compositionMsg, window_handle, WM_IME_STARTCOMPOSITION,
|
||||
WM_IME_COMPOSITION, PM_NOREMOVE) &&
|
||||
CHROME_MSG compositionMsg;
|
||||
if (::PeekMessage(ChromeToWindowsType(&compositionMsg), window_handle,
|
||||
WM_IME_STARTCOMPOSITION, WM_IME_COMPOSITION, PM_NOREMOVE) &&
|
||||
compositionMsg.message == WM_IME_COMPOSITION &&
|
||||
(compositionMsg.lParam & GCS_RESULTSTR))
|
||||
return 0;
|
||||
|
@ -28,7 +28,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN) InputMethodWinImm32
|
||||
void OnFocus() override;
|
||||
|
||||
// Overridden from InputMethod:
|
||||
bool OnUntranslatedIMEMessage(const MSG event,
|
||||
bool OnUntranslatedIMEMessage(const CHROME_MSG event,
|
||||
NativeEventResult* result) override;
|
||||
void OnTextInputTypeChanged(const TextInputClient* client) override;
|
||||
void OnCaretBoundsChanged(const TextInputClient* client) override;
|
||||
|
@ -62,7 +62,7 @@ void InputMethodWinTSF::OnBlur() {
|
||||
}
|
||||
|
||||
bool InputMethodWinTSF::OnUntranslatedIMEMessage(
|
||||
const MSG event,
|
||||
const CHROME_MSG event,
|
||||
InputMethod::NativeEventResult* result) {
|
||||
LRESULT original_result = 0;
|
||||
BOOL handled = FALSE;
|
||||
|
@ -25,7 +25,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN) InputMethodWinTSF
|
||||
// Overridden from InputMethod:
|
||||
void OnFocus() override;
|
||||
void OnBlur() override;
|
||||
bool OnUntranslatedIMEMessage(const MSG event,
|
||||
bool OnUntranslatedIMEMessage(const CHROME_MSG event,
|
||||
NativeEventResult* result) override;
|
||||
void OnTextInputTypeChanged(const TextInputClient* client) override;
|
||||
void OnCaretBoundsChanged(const TextInputClient* client) override;
|
||||
|
@ -922,7 +922,8 @@ void TSFTextStore::DispatchKeyEvent(ui::EventType type,
|
||||
|
||||
// prepare ui::KeyEvent.
|
||||
UINT message = type == ui::ET_KEY_PRESSED ? WM_KEYDOWN : WM_KEYUP;
|
||||
const MSG key_event_MSG = {window_handle_, message, VK_PROCESSKEY, lparam};
|
||||
const CHROME_MSG key_event_MSG = {window_handle_, message, VK_PROCESSKEY,
|
||||
lparam};
|
||||
ui::KeyEvent key_event = KeyEventFromMSG(key_event_MSG);
|
||||
|
||||
if (input_method_delegate_) {
|
||||
|
@ -90,6 +90,8 @@ source_set("event_constants") {
|
||||
|
||||
source_set("platform_event") {
|
||||
sources = [ "platform_event.h" ]
|
||||
|
||||
public_deps = [ "//base" ]
|
||||
}
|
||||
|
||||
component("events_base") {
|
||||
|
@ -479,7 +479,7 @@ TEST(WebInputEventTest, MousePointerEvent) {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
TEST(WebInputEventTest, MouseLeaveScreenCoordinate) {
|
||||
MSG msg_event = {nullptr, WM_MOUSELEAVE, 0, MAKELPARAM(300, 200)};
|
||||
CHROME_MSG msg_event = {nullptr, WM_MOUSELEAVE, 0, MAKELPARAM(300, 200)};
|
||||
::SetCursorPos(250, 350);
|
||||
ui::MouseEvent ui_event(msg_event);
|
||||
|
||||
|
@ -43,7 +43,7 @@ TEST(EventTest, NoNativeEvent) {
|
||||
|
||||
TEST(EventTest, NativeEvent) {
|
||||
#if defined(OS_WIN)
|
||||
MSG native_event = {nullptr, WM_KEYUP, VKEY_A, 0};
|
||||
CHROME_MSG native_event = {nullptr, WM_KEYUP, VKEY_A, 0};
|
||||
KeyEvent keyev(native_event);
|
||||
EXPECT_TRUE(keyev.HasNativeEvent());
|
||||
#endif
|
||||
@ -407,7 +407,7 @@ TEST(EventTest, KeyEventCode) {
|
||||
ASSERT_EQ((kNativeCodeSpace & 0xFF), kNativeCodeSpace);
|
||||
|
||||
const LPARAM lParam = GetLParamFromScanCode(kNativeCodeSpace);
|
||||
MSG native_event = {nullptr, WM_KEYUP, VKEY_SPACE, lParam};
|
||||
CHROME_MSG native_event = {nullptr, WM_KEYUP, VKEY_SPACE, lParam};
|
||||
KeyEvent key(native_event);
|
||||
|
||||
// KeyEvent converts from the native keycode (scan code) to the code.
|
||||
@ -421,7 +421,7 @@ TEST(EventTest, KeyEventCode) {
|
||||
ASSERT_NE((kNativeCodeHome & 0xFF), kNativeCodeHome);
|
||||
const LPARAM lParam = GetLParamFromScanCode(kNativeCodeHome);
|
||||
|
||||
MSG native_event = {nullptr, WM_KEYUP, VKEY_HOME, lParam};
|
||||
CHROME_MSG native_event = {nullptr, WM_KEYUP, VKEY_HOME, lParam};
|
||||
KeyEvent key(native_event);
|
||||
|
||||
// KeyEvent converts from the native keycode (scan code) to the code.
|
||||
@ -695,7 +695,7 @@ TEST(EventTest, OrdinalMotionConversion) {
|
||||
TEST(EventTest, EventLatencyOSMouseWheelHistogram) {
|
||||
#if defined(OS_WIN)
|
||||
base::HistogramTester histogram_tester;
|
||||
MSG event = {nullptr, WM_MOUSEWHEEL, 0, 0};
|
||||
CHROME_MSG event = {nullptr, WM_MOUSEWHEEL, 0, 0};
|
||||
MouseWheelEvent mouseWheelEvent(event);
|
||||
histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1);
|
||||
histogram_tester.ExpectTotalCount("Event.Latency.OS2.MOUSE_WHEEL", 1);
|
||||
@ -914,7 +914,7 @@ class AltGraphEventTest
|
||||
return std::get<1>(GetParam());
|
||||
}
|
||||
|
||||
const MSG msg_;
|
||||
const CHROME_MSG msg_;
|
||||
BYTE original_keyboard_state_[256] = {};
|
||||
HKL original_keyboard_layout_ = nullptr;
|
||||
};
|
||||
|
@ -209,11 +209,12 @@ EVENTS_EXPORT bool IsMouseEventFromTouch(UINT message);
|
||||
EVENTS_EXPORT uint16_t GetScanCodeFromLParam(LPARAM lParam);
|
||||
EVENTS_EXPORT LPARAM GetLParamFromScanCode(uint16_t scan_code);
|
||||
|
||||
// Creates an MSG from the given KeyEvent if there is no native_event.
|
||||
EVENTS_EXPORT MSG MSGFromKeyEvent(KeyEvent* key_event, HWND hwnd = nullptr);
|
||||
EVENTS_EXPORT KeyEvent KeyEventFromMSG(const MSG& msg);
|
||||
EVENTS_EXPORT MouseEvent MouseEventFromMSG(const MSG& msg);
|
||||
EVENTS_EXPORT MouseWheelEvent MouseWheelEventFromMSG(const MSG& msg);
|
||||
// Creates a CHROME_MSG from the given KeyEvent if there is no native_event.
|
||||
EVENTS_EXPORT CHROME_MSG MSGFromKeyEvent(KeyEvent* key_event,
|
||||
HWND hwnd = nullptr);
|
||||
EVENTS_EXPORT KeyEvent KeyEventFromMSG(const CHROME_MSG& msg);
|
||||
EVENTS_EXPORT MouseEvent MouseEventFromMSG(const CHROME_MSG& msg);
|
||||
EVENTS_EXPORT MouseWheelEvent MouseWheelEventFromMSG(const CHROME_MSG& msg);
|
||||
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#include "base/win/windows_types.h"
|
||||
#elif defined(OS_APPLE)
|
||||
#if defined(__OBJC__)
|
||||
@class NSEvent;
|
||||
@ -27,7 +27,7 @@ namespace ui {
|
||||
#if defined(USE_OZONE) || defined(USE_X11)
|
||||
using PlatformEvent = ui::Event*;
|
||||
#elif defined(OS_WIN)
|
||||
using PlatformEvent = MSG;
|
||||
using PlatformEvent = CHROME_MSG;
|
||||
#elif defined(OS_APPLE)
|
||||
using PlatformEvent = NSEvent*;
|
||||
#else
|
||||
|
@ -657,7 +657,8 @@ void EventGenerator::DispatchKeyEvent(bool is_press,
|
||||
uint16_t character = ui::DomCodeToUsLayoutCharacter(
|
||||
ui::UsLayoutKeyboardCodeToDomCode(key_code), flags);
|
||||
if (is_press && character) {
|
||||
MSG native_event = {NULL, WM_KEYDOWN, static_cast<UINT>(key_code), 0};
|
||||
CHROME_MSG native_event = {NULL, WM_KEYDOWN, static_cast<UINT>(key_code),
|
||||
0};
|
||||
native_event.time =
|
||||
(ui::EventTimeForNow() - base::TimeTicks()).InMilliseconds() &
|
||||
UINT32_MAX;
|
||||
@ -668,8 +669,8 @@ void EventGenerator::DispatchKeyEvent(bool is_press,
|
||||
key_press = WM_CHAR;
|
||||
key_code = static_cast<ui::KeyboardCode>(character);
|
||||
}
|
||||
MSG native_event = {NULL, (is_press ? key_press : WM_KEYUP),
|
||||
static_cast<UINT>(key_code), 0};
|
||||
CHROME_MSG native_event = {NULL, (is_press ? key_press : WM_KEYUP),
|
||||
static_cast<UINT>(key_code), 0};
|
||||
native_event.time =
|
||||
(ui::EventTimeForNow() - base::TimeTicks()).InMilliseconds() & UINT32_MAX;
|
||||
ui::KeyEvent keyev(native_event, flags);
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "ui/events/event_utils.h"
|
||||
|
||||
#include "base/win/windows_types.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "ui/gfx/win/window_impl.h"
|
||||
|
||||
@ -32,8 +33,8 @@ class TestWindow : public gfx::WindowImpl {
|
||||
DISALLOW_COPY_AND_ASSIGN(TestWindow);
|
||||
};
|
||||
|
||||
MSG CreateEvent(UINT type, WORD x, WORD y, HWND hwnd) {
|
||||
MSG event;
|
||||
CHROME_MSG CreateEvent(UINT type, WORD x, WORD y, HWND hwnd) {
|
||||
CHROME_MSG event;
|
||||
event.message = type;
|
||||
event.hwnd = hwnd;
|
||||
event.lParam = MAKELPARAM(x, y);
|
||||
@ -51,7 +52,7 @@ TEST(EventWinTest, EventSystemLocationFromNative) {
|
||||
EXPECT_TRUE(test_window.hwnd() != nullptr);
|
||||
|
||||
{
|
||||
MSG event =
|
||||
CHROME_MSG event =
|
||||
CreateEvent(WM_MOUSEWHEEL, x_coord, y_coord, test_window.hwnd());
|
||||
// Mouse wheel events already have screen coordinates so they should not be
|
||||
// converted.
|
||||
@ -59,7 +60,8 @@ TEST(EventWinTest, EventSystemLocationFromNative) {
|
||||
EventSystemLocationFromNative(event));
|
||||
}
|
||||
|
||||
MSG event = CreateEvent(WM_LBUTTONDOWN, x_coord, y_coord, test_window.hwnd());
|
||||
CHROME_MSG event =
|
||||
CreateEvent(WM_LBUTTONDOWN, x_coord, y_coord, test_window.hwnd());
|
||||
EXPECT_EQ(gfx::Point(x_coord + x_window_offset, y_coord + y_window_offset),
|
||||
EventSystemLocationFromNative(event));
|
||||
}
|
||||
|
@ -8,73 +8,75 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
EventType EventTypeFromNative(const MSG& native_event) {
|
||||
EventType EventTypeFromNative(const CHROME_MSG& native_event) {
|
||||
return EventTypeFromMSG(native_event);
|
||||
}
|
||||
|
||||
int EventFlagsFromNative(const MSG& native_event) {
|
||||
int EventFlagsFromNative(const CHROME_MSG& native_event) {
|
||||
return EventFlagsFromMSG(native_event);
|
||||
}
|
||||
|
||||
base::TimeTicks EventTimeFromNative(const MSG& native_event) {
|
||||
base::TimeTicks EventTimeFromNative(const CHROME_MSG& native_event) {
|
||||
// Note EventTimeFromMSG actually returns a time based on the current clock
|
||||
// tick, ignoring MSG. See the comments in that function (which is in
|
||||
// events_win_utils.cc) for the reason.
|
||||
return EventTimeFromMSG(native_event);
|
||||
}
|
||||
|
||||
base::TimeTicks EventLatencyTimeFromNative(const MSG& native_event,
|
||||
base::TimeTicks EventLatencyTimeFromNative(const CHROME_MSG& native_event,
|
||||
base::TimeTicks current_time) {
|
||||
// For latency calculations use the real timestamp, rather than the one
|
||||
// returned from EventTimeFromMSG.
|
||||
return EventLatencyTimeFromTickClock(native_event.time, current_time);
|
||||
}
|
||||
|
||||
gfx::PointF EventLocationFromNative(const MSG& native_event) {
|
||||
gfx::PointF EventLocationFromNative(const CHROME_MSG& native_event) {
|
||||
return gfx::PointF(EventLocationFromMSG(native_event));
|
||||
}
|
||||
|
||||
gfx::Point EventSystemLocationFromNative(const MSG& native_event) {
|
||||
gfx::Point EventSystemLocationFromNative(const CHROME_MSG& native_event) {
|
||||
return EventSystemLocationFromMSG(native_event);
|
||||
}
|
||||
|
||||
KeyboardCode KeyboardCodeFromNative(const MSG& native_event) {
|
||||
KeyboardCode KeyboardCodeFromNative(const CHROME_MSG& native_event) {
|
||||
return KeyboardCodeFromMSG(native_event);
|
||||
}
|
||||
|
||||
DomCode CodeFromNative(const MSG& native_event) {
|
||||
DomCode CodeFromNative(const CHROME_MSG& native_event) {
|
||||
return CodeFromMSG(native_event);
|
||||
}
|
||||
|
||||
bool IsCharFromNative(const MSG& native_event) {
|
||||
bool IsCharFromNative(const CHROME_MSG& native_event) {
|
||||
return IsCharFromMSG(native_event);
|
||||
}
|
||||
|
||||
int GetChangedMouseButtonFlagsFromNative(const MSG& native_event) {
|
||||
int GetChangedMouseButtonFlagsFromNative(const CHROME_MSG& native_event) {
|
||||
return GetChangedMouseButtonFlagsFromMSG(native_event);
|
||||
}
|
||||
|
||||
PointerDetails GetMousePointerDetailsFromNative(const MSG& native_event) {
|
||||
PointerDetails GetMousePointerDetailsFromNative(
|
||||
const CHROME_MSG& native_event) {
|
||||
return GetMousePointerDetailsFromMSG(native_event);
|
||||
}
|
||||
|
||||
gfx::Vector2d GetMouseWheelOffset(const MSG& native_event) {
|
||||
gfx::Vector2d GetMouseWheelOffset(const CHROME_MSG& native_event) {
|
||||
return GetMouseWheelOffsetFromMSG(native_event);
|
||||
}
|
||||
|
||||
gfx::Vector2d GetMouseWheelTick120ths(const MSG& native_event) {
|
||||
gfx::Vector2d GetMouseWheelTick120ths(const CHROME_MSG& native_event) {
|
||||
// On Windows, the wheel offset is already in 120ths of a tick
|
||||
// (https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-mousewheel).
|
||||
return GetMouseWheelOffsetFromMSG(native_event);
|
||||
}
|
||||
|
||||
MSG CopyNativeEvent(const MSG& event) {
|
||||
CHROME_MSG CopyNativeEvent(const CHROME_MSG& event) {
|
||||
return CopyMSGEvent(event);
|
||||
}
|
||||
|
||||
void ReleaseCopiedNativeEvent(const MSG& event) {}
|
||||
void ReleaseCopiedNativeEvent(const CHROME_MSG& event) {}
|
||||
|
||||
PointerDetails GetTouchPointerDetailsFromNative(const MSG& native_event) {
|
||||
PointerDetails GetTouchPointerDetailsFromNative(
|
||||
const CHROME_MSG& native_event) {
|
||||
NOTIMPLEMENTED();
|
||||
return PointerDetails(EventPointerType::kTouch,
|
||||
/* pointer_id*/ 0,
|
||||
@ -83,7 +85,7 @@ PointerDetails GetTouchPointerDetailsFromNative(const MSG& native_event) {
|
||||
/* force */ 0.f);
|
||||
}
|
||||
|
||||
bool GetScrollOffsets(const MSG& native_event,
|
||||
bool GetScrollOffsets(const CHROME_MSG& native_event,
|
||||
float* x_offset,
|
||||
float* y_offset,
|
||||
float* x_offset_ordinal,
|
||||
@ -93,7 +95,7 @@ bool GetScrollOffsets(const MSG& native_event,
|
||||
return GetScrollOffsetsFromMSG(native_event);
|
||||
}
|
||||
|
||||
bool GetFlingData(const MSG& native_event,
|
||||
bool GetFlingData(const CHROME_MSG& native_event,
|
||||
float* vx,
|
||||
float* vy,
|
||||
float* vx_ordinal,
|
||||
|
@ -35,7 +35,7 @@ namespace {
|
||||
#define SIGNATURE_MASK 0xFFFFFF00
|
||||
|
||||
// Get the native mouse key state from the native event message type.
|
||||
int GetNativeMouseKey(const MSG& native_event) {
|
||||
int GetNativeMouseKey(const CHROME_MSG& native_event) {
|
||||
switch (native_event.message) {
|
||||
case WM_LBUTTONDBLCLK:
|
||||
case WM_LBUTTONDOWN:
|
||||
@ -69,7 +69,7 @@ int GetNativeMouseKey(const MSG& native_event) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IsButtonDown(const MSG& native_event) {
|
||||
bool IsButtonDown(const CHROME_MSG& native_event) {
|
||||
return ((MK_LBUTTON | MK_MBUTTON | MK_RBUTTON | MK_XBUTTON1 | MK_XBUTTON2) &
|
||||
native_event.wParam) != 0;
|
||||
}
|
||||
@ -79,7 +79,7 @@ bool IsClientMouseMessage(UINT message) {
|
||||
(message >= WM_MOUSEFIRST && message <= WM_MOUSELAST);
|
||||
}
|
||||
|
||||
bool IsClientMouseEvent(const MSG& native_event) {
|
||||
bool IsClientMouseEvent(const CHROME_MSG& native_event) {
|
||||
return IsClientMouseMessage(native_event.message);
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ bool IsNonClientMouseMessage(UINT message) {
|
||||
(message >= WM_NCMOUSEMOVE && message <= WM_NCXBUTTONDBLCLK);
|
||||
}
|
||||
|
||||
bool IsNonClientMouseEvent(const MSG& native_event) {
|
||||
bool IsNonClientMouseEvent(const CHROME_MSG& native_event) {
|
||||
return IsNonClientMouseMessage(native_event.message);
|
||||
}
|
||||
|
||||
@ -96,17 +96,17 @@ bool IsMouseMessage(UINT message) {
|
||||
return IsClientMouseMessage(message) || IsNonClientMouseMessage(message);
|
||||
}
|
||||
|
||||
bool IsMouseEvent(const MSG& native_event) {
|
||||
bool IsMouseEvent(const CHROME_MSG& native_event) {
|
||||
return IsClientMouseEvent(native_event) ||
|
||||
IsNonClientMouseEvent(native_event);
|
||||
}
|
||||
|
||||
bool IsMouseWheelEvent(const MSG& native_event) {
|
||||
bool IsMouseWheelEvent(const CHROME_MSG& native_event) {
|
||||
return native_event.message == WM_MOUSEWHEEL ||
|
||||
native_event.message == WM_MOUSEHWHEEL;
|
||||
}
|
||||
|
||||
bool IsKeyEvent(const MSG& native_event) {
|
||||
bool IsKeyEvent(const CHROME_MSG& native_event) {
|
||||
return native_event.message == WM_KEYDOWN ||
|
||||
native_event.message == WM_SYSKEYDOWN ||
|
||||
native_event.message == WM_CHAR ||
|
||||
@ -115,14 +115,14 @@ bool IsKeyEvent(const MSG& native_event) {
|
||||
native_event.message == WM_SYSKEYUP;
|
||||
}
|
||||
|
||||
bool IsScrollEvent(const MSG& native_event) {
|
||||
bool IsScrollEvent(const CHROME_MSG& native_event) {
|
||||
return native_event.message == WM_VSCROLL ||
|
||||
native_event.message == WM_HSCROLL;
|
||||
}
|
||||
|
||||
// Returns a mask corresponding to the set of pressed modifier keys.
|
||||
// Checks the current global state and the state sent by client mouse messages.
|
||||
int KeyStateFlags(const MSG& native_event) {
|
||||
int KeyStateFlags(const CHROME_MSG& native_event) {
|
||||
int flags = GetModifiersFromKeyState();
|
||||
|
||||
// Check key messages for the extended key flag.
|
||||
@ -141,7 +141,7 @@ int KeyStateFlags(const MSG& native_event) {
|
||||
|
||||
// Returns a mask corresponding to the set of pressed mouse buttons.
|
||||
// This includes the button of the given message, even if it is being released.
|
||||
int MouseStateFlags(const MSG& native_event) {
|
||||
int MouseStateFlags(const CHROME_MSG& native_event) {
|
||||
int win_flags = GetNativeMouseKey(native_event);
|
||||
|
||||
// Client mouse messages provide key states in their WPARAMs.
|
||||
@ -171,7 +171,7 @@ const base::TickClock* g_tick_count_clock = nullptr;
|
||||
|
||||
} // namespace
|
||||
|
||||
EventType EventTypeFromMSG(const MSG& native_event) {
|
||||
EventType EventTypeFromMSG(const CHROME_MSG& native_event) {
|
||||
switch (native_event.message) {
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
@ -236,7 +236,7 @@ EventType EventTypeFromMSG(const MSG& native_event) {
|
||||
return ET_UNKNOWN;
|
||||
}
|
||||
|
||||
int EventFlagsFromMSG(const MSG& native_event) {
|
||||
int EventFlagsFromMSG(const CHROME_MSG& native_event) {
|
||||
int flags = KeyStateFlags(native_event);
|
||||
if (IsMouseEvent(native_event))
|
||||
flags |= MouseStateFlags(native_event);
|
||||
@ -244,7 +244,7 @@ int EventFlagsFromMSG(const MSG& native_event) {
|
||||
return flags;
|
||||
}
|
||||
|
||||
base::TimeTicks EventTimeFromMSG(const MSG& native_event) {
|
||||
base::TimeTicks EventTimeFromMSG(const CHROME_MSG& native_event) {
|
||||
// On Windows, the native input event timestamp (|native_event.time|) is
|
||||
// coming from |GetTickCount()| clock [1], while in platform independent code
|
||||
// path we get timestamps by calling |TimeTicks::Now()|, which, if using high-
|
||||
@ -299,7 +299,7 @@ base::TimeTicks EventLatencyTimeFromPerformanceCounter(UINT64 event_time) {
|
||||
return time_stamp;
|
||||
}
|
||||
|
||||
gfx::Point EventLocationFromMSG(const MSG& native_event) {
|
||||
gfx::Point EventLocationFromMSG(const CHROME_MSG& native_event) {
|
||||
// This code may use GetCursorPos() to get a mouse location. This may
|
||||
// fail in certain situations (see
|
||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=540840#c20 for
|
||||
@ -339,7 +339,7 @@ gfx::Point EventLocationFromMSG(const MSG& native_event) {
|
||||
return event_location;
|
||||
}
|
||||
|
||||
gfx::Point EventSystemLocationFromMSG(const MSG& native_event) {
|
||||
gfx::Point EventSystemLocationFromMSG(const CHROME_MSG& native_event) {
|
||||
POINT global_point = {GET_X_LPARAM(native_event.lParam),
|
||||
GET_Y_LPARAM(native_event.lParam)};
|
||||
// Wheel events have position in screen coordinates.
|
||||
@ -348,20 +348,20 @@ gfx::Point EventSystemLocationFromMSG(const MSG& native_event) {
|
||||
return gfx::Point(global_point);
|
||||
}
|
||||
|
||||
KeyboardCode KeyboardCodeFromMSG(const MSG& native_event) {
|
||||
KeyboardCode KeyboardCodeFromMSG(const CHROME_MSG& native_event) {
|
||||
return KeyboardCodeForWindowsKeyCode(static_cast<WORD>(native_event.wParam));
|
||||
}
|
||||
|
||||
DomCode CodeFromMSG(const MSG& native_event) {
|
||||
DomCode CodeFromMSG(const CHROME_MSG& native_event) {
|
||||
const uint16_t scan_code = GetScanCodeFromLParam(native_event.lParam);
|
||||
return CodeForWindowsScanCode(scan_code);
|
||||
}
|
||||
|
||||
bool IsCharFromMSG(const MSG& native_event) {
|
||||
bool IsCharFromMSG(const CHROME_MSG& native_event) {
|
||||
return native_event.message == WM_CHAR || native_event.message == WM_SYSCHAR;
|
||||
}
|
||||
|
||||
int GetChangedMouseButtonFlagsFromMSG(const MSG& native_event) {
|
||||
int GetChangedMouseButtonFlagsFromMSG(const CHROME_MSG& native_event) {
|
||||
switch (GetNativeMouseKey(native_event)) {
|
||||
case MK_LBUTTON:
|
||||
return EF_LEFT_MOUSE_BUTTON;
|
||||
@ -376,7 +376,7 @@ int GetChangedMouseButtonFlagsFromMSG(const MSG& native_event) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PointerDetails GetMousePointerDetailsFromMSG(const MSG& native_event) {
|
||||
PointerDetails GetMousePointerDetailsFromMSG(const CHROME_MSG& native_event) {
|
||||
// We should filter out all the mouse events Synthesized from touch events.
|
||||
// TODO(lanwei): Will set the pointer ID, see https://crbug.com/616771.
|
||||
if ((GetMessageExtraInfo() & SIGNATURE_MASK) != MOUSEEVENTF_FROMTOUCHPEN)
|
||||
@ -385,7 +385,7 @@ PointerDetails GetMousePointerDetailsFromMSG(const MSG& native_event) {
|
||||
return PointerDetails(EventPointerType::kPen);
|
||||
}
|
||||
|
||||
gfx::Vector2d GetMouseWheelOffsetFromMSG(const MSG& native_event) {
|
||||
gfx::Vector2d GetMouseWheelOffsetFromMSG(const CHROME_MSG& native_event) {
|
||||
DCHECK(native_event.message == WM_MOUSEWHEEL ||
|
||||
native_event.message == WM_MOUSEHWHEEL);
|
||||
if (native_event.message == WM_MOUSEWHEEL)
|
||||
@ -393,22 +393,22 @@ gfx::Vector2d GetMouseWheelOffsetFromMSG(const MSG& native_event) {
|
||||
return gfx::Vector2d(GET_WHEEL_DELTA_WPARAM(native_event.wParam), 0);
|
||||
}
|
||||
|
||||
MSG CopyMSGEvent(const MSG& event) {
|
||||
CHROME_MSG CopyMSGEvent(const CHROME_MSG& event) {
|
||||
return event;
|
||||
}
|
||||
|
||||
void ReleaseCopiedMSGEvent(const MSG& event) {}
|
||||
void ReleaseCopiedMSGEvent(const CHROME_MSG& event) {}
|
||||
|
||||
void ClearTouchIdIfReleasedFromMSG(const MSG& xev) {
|
||||
void ClearTouchIdIfReleasedFromMSG(const CHROME_MSG& xev) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
int GetTouchIdFromMSG(const MSG& xev) {
|
||||
int GetTouchIdFromMSG(const CHROME_MSG& xev) {
|
||||
NOTIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
PointerDetails GetTouchPointerDetailsFromMSG(const MSG& native_event) {
|
||||
PointerDetails GetTouchPointerDetailsFromMSG(const CHROME_MSG& native_event) {
|
||||
NOTIMPLEMENTED();
|
||||
return PointerDetails(EventPointerType::kTouch,
|
||||
/* pointer_id*/ 0,
|
||||
@ -417,7 +417,7 @@ PointerDetails GetTouchPointerDetailsFromMSG(const MSG& native_event) {
|
||||
/* force */ 0.f);
|
||||
}
|
||||
|
||||
bool GetScrollOffsetsFromMSG(const MSG& native_event) {
|
||||
bool GetScrollOffsetsFromMSG(const CHROME_MSG& native_event) {
|
||||
// TODO(ananta)
|
||||
// Support retrieving the scroll offsets from the scroll event.
|
||||
if (native_event.message == WM_VSCROLL || native_event.message == WM_HSCROLL)
|
||||
@ -425,7 +425,7 @@ bool GetScrollOffsetsFromMSG(const MSG& native_event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetFlingDataFromMSG(const MSG& native_event,
|
||||
bool GetFlingDataFromMSG(const CHROME_MSG& native_event,
|
||||
float* vx,
|
||||
float* vy,
|
||||
float* vx_ordinal,
|
||||
@ -493,7 +493,7 @@ LPARAM GetLParamFromScanCode(uint16_t scan_code) {
|
||||
return l_param;
|
||||
}
|
||||
|
||||
KeyEvent KeyEventFromMSG(const MSG& msg) {
|
||||
KeyEvent KeyEventFromMSG(const CHROME_MSG& msg) {
|
||||
DCHECK(IsKeyEvent(msg));
|
||||
EventType type = EventTypeFromMSG(msg);
|
||||
KeyboardCode key_code = KeyboardCodeFromMSG(msg);
|
||||
@ -511,7 +511,7 @@ KeyEvent KeyEventFromMSG(const MSG& msg) {
|
||||
}
|
||||
}
|
||||
|
||||
MSG MSGFromKeyEvent(KeyEvent* event, HWND hwnd) {
|
||||
CHROME_MSG MSGFromKeyEvent(KeyEvent* event, HWND hwnd) {
|
||||
if (event->HasNativeEvent())
|
||||
return event->native_event();
|
||||
uint16_t scan_code = KeycodeConverter::DomCodeToNativeKeycode(event->code());
|
||||
@ -525,7 +525,7 @@ MSG MSGFromKeyEvent(KeyEvent* event, HWND hwnd) {
|
||||
return {hwnd, message, w_param, l_param};
|
||||
}
|
||||
|
||||
MouseEvent MouseEventFromMSG(const MSG& msg) {
|
||||
MouseEvent MouseEventFromMSG(const CHROME_MSG& msg) {
|
||||
EventType type = EventTypeFromMSG(msg);
|
||||
gfx::Point location = EventLocationFromMSG(msg);
|
||||
gfx::Point root_location = EventSystemLocationFromMSG(msg);
|
||||
@ -538,7 +538,7 @@ MouseEvent MouseEventFromMSG(const MSG& msg) {
|
||||
changed_button_flags, pointer_details);
|
||||
}
|
||||
|
||||
MouseWheelEvent MouseWheelEventFromMSG(const MSG& msg) {
|
||||
MouseWheelEvent MouseWheelEventFromMSG(const CHROME_MSG& msg) {
|
||||
gfx::Vector2d offset = GetMouseWheelOffsetFromMSG(msg);
|
||||
gfx::Point location = EventLocationFromMSG(msg);
|
||||
gfx::Point root_location = EventSystemLocationFromMSG(msg);
|
||||
|
@ -6,9 +6,8 @@
|
||||
#define UI_EVENTS_WIN_EVENTS_WIN_UTILS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
#include "base/win/windows_types.h"
|
||||
#include "build/build_config.h"
|
||||
#include "ui/display/display.h"
|
||||
#include "ui/events/event.h"
|
||||
@ -35,15 +34,15 @@ namespace ui {
|
||||
enum class DomCode;
|
||||
|
||||
// Get the EventType from a native event.
|
||||
EVENTS_EXPORT EventType EventTypeFromMSG(const MSG& native_event);
|
||||
EVENTS_EXPORT EventType EventTypeFromMSG(const CHROME_MSG& native_event);
|
||||
|
||||
// Get the EventFlags from a native event.
|
||||
EVENTS_EXPORT int EventFlagsFromMSG(const MSG& native_event);
|
||||
EVENTS_EXPORT int EventFlagsFromMSG(const CHROME_MSG& native_event);
|
||||
|
||||
// Get the timestamp from a native event.
|
||||
// Note: This is not a pure function meaning that multiple applications on the
|
||||
// same native event may return different values.
|
||||
EVENTS_EXPORT base::TimeTicks EventTimeFromMSG(const MSG& native_event);
|
||||
EVENTS_EXPORT base::TimeTicks EventTimeFromMSG(const CHROME_MSG& native_event);
|
||||
|
||||
// Convert |event_time|, a count of milliseconds from the clock used by
|
||||
// ::GetTickCount(), to a value comparable to the base::TimeTicks clock.
|
||||
@ -65,49 +64,52 @@ EVENTS_EXPORT base::TimeTicks EventLatencyTimeFromPerformanceCounter(
|
||||
// |Point| has the origin at top-left of the "root window". The nature of
|
||||
// this "root window" and how it maps to platform-specific drawing surfaces is
|
||||
// defined in ui/aura/root_window.* and ui/aura/window_tree_host*.
|
||||
EVENTS_EXPORT gfx::Point EventLocationFromMSG(const MSG& native_event);
|
||||
EVENTS_EXPORT gfx::Point EventLocationFromMSG(const CHROME_MSG& native_event);
|
||||
|
||||
// Gets the location in native system coordinate space.
|
||||
EVENTS_EXPORT gfx::Point EventSystemLocationFromMSG(const MSG& native_event);
|
||||
EVENTS_EXPORT gfx::Point EventSystemLocationFromMSG(
|
||||
const CHROME_MSG& native_event);
|
||||
|
||||
// Returns the KeyboardCode from a native event.
|
||||
EVENTS_EXPORT KeyboardCode KeyboardCodeFromMSG(const MSG& native_event);
|
||||
EVENTS_EXPORT KeyboardCode KeyboardCodeFromMSG(const CHROME_MSG& native_event);
|
||||
|
||||
// Returns the DOM KeyboardEvent code (physical location in the
|
||||
// keyboard) from a native event.
|
||||
EVENTS_EXPORT DomCode CodeFromMSG(const MSG& native_event);
|
||||
EVENTS_EXPORT DomCode CodeFromMSG(const CHROME_MSG& native_event);
|
||||
|
||||
// Returns true if the keyboard event is a character event rather than
|
||||
// a keystroke event.
|
||||
EVENTS_EXPORT bool IsCharFromMSG(const MSG& native_event);
|
||||
EVENTS_EXPORT bool IsCharFromMSG(const CHROME_MSG& native_event);
|
||||
|
||||
// Returns the flags of the button that changed during a press/release.
|
||||
EVENTS_EXPORT int GetChangedMouseButtonFlagsFromMSG(const MSG& native_event);
|
||||
EVENTS_EXPORT int GetChangedMouseButtonFlagsFromMSG(
|
||||
const CHROME_MSG& native_event);
|
||||
|
||||
// Returns the detailed pointer information for mouse events.
|
||||
EVENTS_EXPORT PointerDetails
|
||||
GetMousePointerDetailsFromMSG(const MSG& native_event);
|
||||
GetMousePointerDetailsFromMSG(const CHROME_MSG& native_event);
|
||||
|
||||
// Gets the mouse wheel offsets from a native event.
|
||||
EVENTS_EXPORT gfx::Vector2d GetMouseWheelOffsetFromMSG(const MSG& native_event);
|
||||
EVENTS_EXPORT gfx::Vector2d GetMouseWheelOffsetFromMSG(
|
||||
const CHROME_MSG& native_event);
|
||||
|
||||
// Returns a copy of |native_event|. Depending on the platform, this copy may
|
||||
// need to be deleted with ReleaseCopiedMSGEvent().
|
||||
EVENTS_EXPORT MSG CopyMSGEvent(const MSG& native_event);
|
||||
EVENTS_EXPORT CHROME_MSG CopyMSGEvent(const CHROME_MSG& native_event);
|
||||
|
||||
// Delete a |native_event| previously created by CopyMSGEvent().
|
||||
EVENTS_EXPORT void ReleaseCopiedMSGEvent(const MSG& native_event);
|
||||
EVENTS_EXPORT void ReleaseCopiedMSGEvent(const CHROME_MSG& native_event);
|
||||
|
||||
// Returns the detailed pointer information for touch events.
|
||||
EVENTS_EXPORT PointerDetails
|
||||
GetTouchPointerDetailsFromMSG(const MSG& native_event);
|
||||
GetTouchPointerDetailsFromMSG(const CHROME_MSG& native_event);
|
||||
|
||||
// Clear the touch id from bookkeeping if it is a release/cancel event.
|
||||
EVENTS_EXPORT void ClearTouchIdIfReleased(const MSG& native_event);
|
||||
EVENTS_EXPORT void ClearTouchIdIfReleased(const CHROME_MSG& native_event);
|
||||
|
||||
// Gets the fling velocity from a native event. is_cancel is set to true if
|
||||
// this was a tap down, intended to stop an ongoing fling.
|
||||
EVENTS_EXPORT bool GetFlingData(const MSG& native_event,
|
||||
EVENTS_EXPORT bool GetFlingData(const CHROME_MSG& native_event,
|
||||
float* vx,
|
||||
float* vy,
|
||||
float* vx_ordinal,
|
||||
@ -116,7 +118,7 @@ EVENTS_EXPORT bool GetFlingData(const MSG& native_event,
|
||||
|
||||
// Returns whether this is a scroll event and optionally gets the amount to be
|
||||
// scrolled.
|
||||
EVENTS_EXPORT bool GetScrollOffsetsFromMSG(const MSG& native_event);
|
||||
EVENTS_EXPORT bool GetScrollOffsetsFromMSG(const CHROME_MSG& native_event);
|
||||
|
||||
// Makes EventLatencyTimeFromTickClock call the given |clock| to find the
|
||||
// current time ticks. If |clock| is nullptr, it will call ::GetTickCount(),
|
||||
|
@ -91,8 +91,8 @@ bool MediaKeyboardHookWinImpl::ProcessKeyEventMessage(WPARAM w_param,
|
||||
return false;
|
||||
|
||||
bool is_repeat = false;
|
||||
MSG msg = {nullptr, static_cast<UINT>(w_param), vk,
|
||||
GetLParamFromScanCode(scan_code), time_stamp};
|
||||
CHROME_MSG msg = {nullptr, static_cast<UINT>(w_param), vk,
|
||||
GetLParamFromScanCode(scan_code), time_stamp};
|
||||
EventType event_type = EventTypeFromMSG(msg);
|
||||
if (event_type == ET_KEY_PRESSED) {
|
||||
is_repeat = (last_key_down_ == vk);
|
||||
|
@ -250,8 +250,8 @@ bool ModifierKeyboardHookWinImpl::ProcessKeyEventMessage(WPARAM w_param,
|
||||
: LocatedToNonLocatedKeyboardCode(static_cast<KeyboardCode>(vk));
|
||||
|
||||
bool is_repeat = false;
|
||||
MSG msg = {nullptr, static_cast<UINT>(w_param), non_located_vk,
|
||||
GetLParamFromScanCode(scan_code), time_stamp};
|
||||
CHROME_MSG msg = {nullptr, static_cast<UINT>(w_param), non_located_vk,
|
||||
GetLParamFromScanCode(scan_code), time_stamp};
|
||||
EventType event_type = EventTypeFromMSG(msg);
|
||||
if (event_type == ET_KEY_PRESSED) {
|
||||
UpdateModifierState(vk, /*key_down=*/true);
|
||||
|
@ -240,12 +240,12 @@ bool WinWindow::IsFullscreen() const {
|
||||
}
|
||||
|
||||
LRESULT WinWindow::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) {
|
||||
MSG msg = {hwnd(),
|
||||
message,
|
||||
w_param,
|
||||
l_param,
|
||||
static_cast<DWORD>(GetMessageTime()),
|
||||
{CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param)}};
|
||||
CHROME_MSG msg = {hwnd(),
|
||||
message,
|
||||
w_param,
|
||||
l_param,
|
||||
static_cast<DWORD>(GetMessageTime()),
|
||||
{CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param)}};
|
||||
std::unique_ptr<Event> event = EventFromNative(msg);
|
||||
if (IsMouseEventFromTouch(message))
|
||||
event->set_flags(event->flags() | EF_FROM_TOUCH);
|
||||
@ -263,7 +263,7 @@ LRESULT WinWindow::OnCaptureChanged(UINT message,
|
||||
}
|
||||
|
||||
LRESULT WinWindow::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) {
|
||||
MSG msg = {hwnd(), message, w_param, l_param};
|
||||
CHROME_MSG msg = {hwnd(), message, w_param, l_param};
|
||||
KeyEvent event(msg);
|
||||
delegate_->DispatchEvent(&event);
|
||||
SetMsgHandled(event.handled());
|
||||
|
@ -17,10 +17,6 @@
|
||||
#include "ui/native_theme/themed_vector_icon.h"
|
||||
#include "ui/views/views_export.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
namespace gfx {
|
||||
class Canvas;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "ui/events/event.h"
|
||||
|
||||
namespace views {
|
||||
@ -14,8 +16,9 @@ bool UnhandledKeyboardEventHandler::HandleNativeKeyboardEvent(
|
||||
FocusManager* focus_manager) {
|
||||
// Any unhandled keyboard/character messages should be defproced.
|
||||
// This allows stuff like F10, etc to work correctly.
|
||||
const MSG& message(event->native_event());
|
||||
DefWindowProc(message.hwnd, message.message, message.wParam, message.lParam);
|
||||
const CHROME_MSG& message(event->native_event());
|
||||
::DefWindowProc(message.hwnd, message.message, message.wParam,
|
||||
message.lParam);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1087,7 +1087,7 @@ bool DesktopWindowTreeHostWin::HandleIMEMessage(UINT message,
|
||||
return true;
|
||||
}
|
||||
|
||||
MSG msg = {};
|
||||
CHROME_MSG msg = {};
|
||||
msg.hwnd = GetHWND();
|
||||
msg.message = message;
|
||||
msg.wParam = w_param;
|
||||
|
@ -1914,8 +1914,8 @@ void HWNDMessageHandler::OnInputLangChange(DWORD character_set,
|
||||
LRESULT HWNDMessageHandler::OnKeyEvent(UINT message,
|
||||
WPARAM w_param,
|
||||
LPARAM l_param) {
|
||||
MSG msg = {hwnd(), message, w_param, l_param,
|
||||
static_cast<DWORD>(GetMessageTime())};
|
||||
CHROME_MSG msg = {hwnd(), message, w_param, l_param,
|
||||
static_cast<DWORD>(GetMessageTime())};
|
||||
ui::KeyEvent key(msg);
|
||||
base::WeakPtr<HWNDMessageHandler> ref(msg_handler_weak_factory_.GetWeakPtr());
|
||||
delegate_->HandleKeyEvent(&key);
|
||||
@ -2478,8 +2478,8 @@ LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message,
|
||||
LRESULT HWNDMessageHandler::OnScrollMessage(UINT message,
|
||||
WPARAM w_param,
|
||||
LPARAM l_param) {
|
||||
MSG msg = {hwnd(), message, w_param, l_param,
|
||||
static_cast<DWORD>(GetMessageTime())};
|
||||
CHROME_MSG msg = {hwnd(), message, w_param, l_param,
|
||||
static_cast<DWORD>(GetMessageTime())};
|
||||
ui::ScrollEvent event(msg);
|
||||
delegate_->HandleScrollEvent(&event);
|
||||
return 0;
|
||||
@ -3093,12 +3093,12 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message,
|
||||
}
|
||||
|
||||
LONG message_time = GetMessageTime();
|
||||
MSG msg = {hwnd(),
|
||||
message,
|
||||
w_param,
|
||||
l_param,
|
||||
static_cast<DWORD>(message_time),
|
||||
{CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param)}};
|
||||
CHROME_MSG msg = {hwnd(),
|
||||
message,
|
||||
w_param,
|
||||
l_param,
|
||||
static_cast<DWORD>(message_time),
|
||||
{CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param)}};
|
||||
ui::MouseEvent event(msg);
|
||||
if (IsSynthesizedMouseMessage(message, message_time, l_param))
|
||||
event.set_flags(event.flags() | ui::EF_FROM_TOUCH);
|
||||
|
Reference in New Issue
Block a user