|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: deepak1556 <hop2deep@gmail.com> |
| 3 | +Date: Fri, 29 Jul 2022 00:29:35 +0900 |
| 4 | +Subject: chore: allow chromium to handle synthetic mouse events for touch |
| 5 | + |
| 6 | +With WCO, allow chromium to handle synthetic mouse events generated for touch |
| 7 | +actions in the non-client caption area. |
| 8 | + |
| 9 | +diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc |
| 10 | +index 65b9f5e5f81e8ef8b591ef2e027e095df11c0d7b..b5d764db353e758e8feefd5fd0a045be27cf09c6 100644 |
| 11 | +--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc |
| 12 | ++++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc |
| 13 | +@@ -1169,6 +1169,10 @@ void DesktopWindowTreeHostWin::HandleWindowScaleFactorChanged( |
| 14 | + } |
| 15 | + } |
| 16 | + |
| 17 | ++bool DesktopWindowTreeHostWin::HandleMouseEventForCaption(UINT message) const { |
| 18 | ++ return false; |
| 19 | ++} |
| 20 | ++ |
| 21 | + DesktopNativeCursorManager* |
| 22 | + DesktopWindowTreeHostWin::GetSingletonDesktopNativeCursorManager() { |
| 23 | + return new DesktopNativeCursorManagerWin(); |
| 24 | +diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h |
| 25 | +index 444581249014a8ce301591f269dbb194f0520732..9377f26b081b717db6b50c13ce3795907cf2fcd2 100644 |
| 26 | +--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h |
| 27 | ++++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h |
| 28 | +@@ -262,6 +262,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin |
| 29 | + void HandleWindowSizeChanging() override; |
| 30 | + void HandleWindowSizeUnchanged() override; |
| 31 | + void HandleWindowScaleFactorChanged(float window_scale_factor) override; |
| 32 | ++ bool HandleMouseEventForCaption(UINT message) const override; |
| 33 | + |
| 34 | + Widget* GetWidget(); |
| 35 | + const Widget* GetWidget() const; |
| 36 | +diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc |
| 37 | +index 86f06d2a2c9588a2210a9f78f47e73f1b7c5e329..f943179d0071ed77fe49f5e4e9cff05eeff665e0 100644 |
| 38 | +--- a/ui/views/win/hwnd_message_handler.cc |
| 39 | ++++ b/ui/views/win/hwnd_message_handler.cc |
| 40 | +@@ -3049,15 +3049,19 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, |
| 41 | + SetMsgHandled(FALSE); |
| 42 | + // We must let Windows handle the caption buttons if it's drawing them, or |
| 43 | + // they won't work. |
| 44 | ++ bool simulate_mouse_event_for_caption = false; |
| 45 | + if (delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN && |
| 46 | + (hittest == HTCLOSE || hittest == HTMINBUTTON || |
| 47 | + hittest == HTMAXBUTTON)) { |
| 48 | +- SetMsgHandled(FALSE); |
| 49 | ++ simulate_mouse_event_for_caption = |
| 50 | ++ delegate_->HandleMouseEventForCaption(message); |
| 51 | ++ if (!simulate_mouse_event_for_caption) |
| 52 | ++ SetMsgHandled(FALSE); |
| 53 | + } |
| 54 | + // Let resize events fall through. Ignore everything else, as we're either |
| 55 | + // letting Windows handle it above or we've already handled the equivalent |
| 56 | + // touch message. |
| 57 | +- if (!IsHitTestOnResizeHandle(hittest)) |
| 58 | ++ if (!IsHitTestOnResizeHandle(hittest) && !simulate_mouse_event_for_caption) |
| 59 | + return 0; |
| 60 | + } |
| 61 | + |
| 62 | +diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h |
| 63 | +index 5dbb192d0840ca0ded61397c399b774a8cb05cce..098a9c3140e9e140fdc8f0dc9cf4e8ec84451221 100644 |
| 64 | +--- a/ui/views/win/hwnd_message_handler_delegate.h |
| 65 | ++++ b/ui/views/win/hwnd_message_handler_delegate.h |
| 66 | +@@ -258,6 +258,10 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate { |
| 67 | + // Called when the window scale factor has changed. |
| 68 | + virtual void HandleWindowScaleFactorChanged(float window_scale_factor) = 0; |
| 69 | + |
| 70 | ++ // Called when synthetic mouse event is generated for touch event on |
| 71 | ++ // caption buttons. |
| 72 | ++ virtual bool HandleMouseEventForCaption(UINT message) const = 0; |
| 73 | ++ |
| 74 | + protected: |
| 75 | + virtual ~HWNDMessageHandlerDelegate() = default; |
| 76 | + }; |