From 997b3ceb16dd5dca4ddaad4140337501bc4477b8 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Tue, 2 Aug 2022 13:48:35 +0900 Subject: [PATCH 1/3] fix: touch events not recognized by WCO on windows --- patches/chromium/.patches | 6 ++ ...dle_synthetic_mouse_events_for_touch.patch | 76 +++++++++++++++++++ .../electron_desktop_window_tree_host_win.cc | 21 +++++ .../electron_desktop_window_tree_host_win.h | 1 + 4 files changed, 104 insertions(+) create mode 100644 patches/chromium/chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 3d8a8fd1c9229..9d486d4551611 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -122,3 +122,9 @@ posix_replace_doubleforkandexec_with_forkandspawn.patch cherry-pick-22c61cfae5d1.patch remove_default_window_title.patch keep_handling_scroll_update_if_you_can.patch +feat_filter_out_non-shareable_windows_in_the_current_application_in.patch +fix_allow_guest_webcontents_to_enter_fullscreen.patch +disable_freezing_flags_after_init_in_node.patch +short-circuit_permissions_checks_in_mediastreamdevicescontroller.patch +chore_add_electron_deps_to_gitignores.patch +chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch diff --git a/patches/chromium/chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch b/patches/chromium/chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch new file mode 100644 index 0000000000000..890c5af769a57 --- /dev/null +++ b/patches/chromium/chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch @@ -0,0 +1,76 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: deepak1556 +Date: Fri, 29 Jul 2022 00:29:35 +0900 +Subject: chore: allow chromium to handle synthetic mouse events for touch + +With WCO, allow chromium to handle synthetic mouse events generated for touch +actions in the non-client caption area. + +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 +index f6b37bdec2343d45447b419aeadbe2aa19493c3c..bdbf7153f27376bd68459f9cb480bff7485c9e98 100644 +--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc ++++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc +@@ -1169,6 +1169,10 @@ void DesktopWindowTreeHostWin::HandleWindowScaleFactorChanged( + } + } + ++bool DesktopWindowTreeHostWin::HandleMouseEventForCaption(UINT message) const { ++ return false; ++} ++ + DesktopNativeCursorManager* + DesktopWindowTreeHostWin::GetSingletonDesktopNativeCursorManager() { + return new DesktopNativeCursorManagerWin(); +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 +index 0aae49ec83b88057434af5bbfb54b10e53469918..058e5dc978e76a71fa02dc9e275592f3c39befea 100644 +--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h ++++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h +@@ -263,6 +263,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin + void HandleWindowSizeChanging() override; + void HandleWindowSizeUnchanged() override; + void HandleWindowScaleFactorChanged(float window_scale_factor) override; ++ bool HandleMouseEventForCaption(UINT message) const override; + + Widget* GetWidget(); + const Widget* GetWidget() const; +diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc +index 3b546cf67089e6677fc668b4d1d6c0863282dff5..c6810f162806b36494885b2f63982a756d4dcd38 100644 +--- a/ui/views/win/hwnd_message_handler.cc ++++ b/ui/views/win/hwnd_message_handler.cc +@@ -3129,15 +3129,19 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, + SetMsgHandled(FALSE); + // We must let Windows handle the caption buttons if it's drawing them, or + // they won't work. ++ bool simulate_mouse_event_for_caption = false; + if (delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN && + (hittest == HTCLOSE || hittest == HTMINBUTTON || + hittest == HTMAXBUTTON)) { +- SetMsgHandled(FALSE); ++ simulate_mouse_event_for_caption = ++ delegate_->HandleMouseEventForCaption(message); ++ if (!simulate_mouse_event_for_caption) ++ SetMsgHandled(FALSE); + } + // Let resize events fall through. Ignore everything else, as we're either + // letting Windows handle it above or we've already handled the equivalent + // touch message. +- if (!IsHitTestOnResizeHandle(hittest)) ++ if (!IsHitTestOnResizeHandle(hittest) && !simulate_mouse_event_for_caption) + return 0; + } + +diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h +index 5dbb192d0840ca0ded61397c399b774a8cb05cce..098a9c3140e9e140fdc8f0dc9cf4e8ec84451221 100644 +--- a/ui/views/win/hwnd_message_handler_delegate.h ++++ b/ui/views/win/hwnd_message_handler_delegate.h +@@ -258,6 +258,10 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate { + // Called when the window scale factor has changed. + virtual void HandleWindowScaleFactorChanged(float window_scale_factor) = 0; + ++ // Called when synthetic mouse event is generated for touch event on ++ // caption buttons. ++ virtual bool HandleMouseEventForCaption(UINT message) const = 0; ++ + protected: + virtual ~HWNDMessageHandlerDelegate() = default; + }; diff --git a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc index 696798d9111aa..d13fcd7932ce3 100644 --- a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc +++ b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc @@ -99,4 +99,25 @@ bool ElectronDesktopWindowTreeHostWin::GetClientAreaInsets( return false; } +bool ElectronDesktopWindowTreeHostWin::HandleMouseEventForCaption( + UINT message) const { + // Windows does not seem to generate WM_NCPOINTERDOWN/UP touch events for + // caption buttons with WCO. This results in a no-op for + // HWNDMessageHandler::HandlePointerEventTypeTouchOrNonClient and + // WM_SYSCOMMAND is not generated for the touch action. However, Windows will + // also generate a mouse event for every touch action and this gets handled in + // HWNDMessageHandler::HandleMouseEventInternal. + // With https://chromium-review.googlesource.com/c/chromium/src/+/1048877/ + // Chromium lets the OS handle caption buttons for FrameMode::SYSTEM_DRAWN but + // again this does not generate the SC_MINIMIZE, SC_MAXIMIZE, SC_RESTORE + // commands when Non-client mouse events are generated for HTCLOSE, + // HTMINBUTTON, HTMAXBUTTON. To workaround this issue, wit this delegate we + // let chromium handle the mouse events via + // HWNDMessageHandler::HandleMouseInputForCaption instead of the OS and this + // will generate the necessary system commands to perform caption button + // actions due to the DefWindowProc call. + // https://source.chromium.org/chromium/chromium/src/+/main:ui/views/win/hwnd_message_handler.cc;l=3611 + return native_window_view_->IsWindowControlsOverlayEnabled(); +} + } // namespace electron diff --git a/shell/browser/ui/win/electron_desktop_window_tree_host_win.h b/shell/browser/ui/win/electron_desktop_window_tree_host_win.h index 3fd831aae1ed0..a7be3cdf0413f 100644 --- a/shell/browser/ui/win/electron_desktop_window_tree_host_win.h +++ b/shell/browser/ui/win/electron_desktop_window_tree_host_win.h @@ -36,6 +36,7 @@ class ElectronDesktopWindowTreeHostWin bool GetDwmFrameInsetsInPixels(gfx::Insets* insets) const override; bool GetClientAreaInsets(gfx::Insets* insets, HMONITOR monitor) const override; + bool HandleMouseEventForCaption(UINT message) const override; private: NativeWindowViews* native_window_view_; // weak ref From 3d7b9b14e47132957e54b79fb0dd237159599255 Mon Sep 17 00:00:00 2001 From: Robo Date: Tue, 2 Aug 2022 13:51:52 +0900 Subject: [PATCH 2/3] Update .patches --- patches/chromium/.patches | 5 ----- 1 file changed, 5 deletions(-) diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 9d486d4551611..df1b224e69f34 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -122,9 +122,4 @@ posix_replace_doubleforkandexec_with_forkandspawn.patch cherry-pick-22c61cfae5d1.patch remove_default_window_title.patch keep_handling_scroll_update_if_you_can.patch -feat_filter_out_non-shareable_windows_in_the_current_application_in.patch -fix_allow_guest_webcontents_to_enter_fullscreen.patch -disable_freezing_flags_after_init_in_node.patch -short-circuit_permissions_checks_in_mediastreamdevicescontroller.patch -chore_add_electron_deps_to_gitignores.patch chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch From aaae40c641efe3c1d54d50b4c4108331097276c0 Mon Sep 17 00:00:00 2001 From: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Date: Tue, 2 Aug 2022 05:04:51 +0000 Subject: [PATCH 3/3] chore: update patches --- ...um_to_handle_synthetic_mouse_events_for_touch.patch | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/patches/chromium/chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch b/patches/chromium/chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch index 890c5af769a57..55d4f7396dc82 100644 --- a/patches/chromium/chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch +++ b/patches/chromium/chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch @@ -7,7 +7,7 @@ With WCO, allow chromium to handle synthetic mouse events generated for touch actions in the non-client caption area. 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 -index f6b37bdec2343d45447b419aeadbe2aa19493c3c..bdbf7153f27376bd68459f9cb480bff7485c9e98 100644 +index 9fd052c00a484cd1acd2031fda79e6307fd01b60..016dfe880a48168154c08839afa540880c2d52be 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc @@ -1169,6 +1169,10 @@ void DesktopWindowTreeHostWin::HandleWindowScaleFactorChanged( @@ -22,10 +22,10 @@ index f6b37bdec2343d45447b419aeadbe2aa19493c3c..bdbf7153f27376bd68459f9cb480bff7 DesktopWindowTreeHostWin::GetSingletonDesktopNativeCursorManager() { return new DesktopNativeCursorManagerWin(); 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 -index 0aae49ec83b88057434af5bbfb54b10e53469918..058e5dc978e76a71fa02dc9e275592f3c39befea 100644 +index 444581249014a8ce301591f269dbb194f0520732..9377f26b081b717db6b50c13ce3795907cf2fcd2 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h -@@ -263,6 +263,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin +@@ -262,6 +262,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin void HandleWindowSizeChanging() override; void HandleWindowSizeUnchanged() override; void HandleWindowScaleFactorChanged(float window_scale_factor) override; @@ -34,10 +34,10 @@ index 0aae49ec83b88057434af5bbfb54b10e53469918..058e5dc978e76a71fa02dc9e275592f3 Widget* GetWidget(); const Widget* GetWidget() const; diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc -index 3b546cf67089e6677fc668b4d1d6c0863282dff5..c6810f162806b36494885b2f63982a756d4dcd38 100644 +index 01ff95be00b3911749f66a136b2b5a6c02156bd3..23e8794c0551c377269ebecd6684206fc7087553 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc -@@ -3129,15 +3129,19 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, +@@ -3064,15 +3064,19 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, SetMsgHandled(FALSE); // We must let Windows handle the caption buttons if it's drawing them, or // they won't work.