diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 8e306795a067..9e9016d5d83d 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -83,7 +83,6 @@ feat_filter_out_non-shareable_windows_in_the_current_application_in.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 add_maximized_parameter_to_linuxui_getwindowframeprovider.patch add_electron_deps_to_license_credits_file.patch fix_crash_loading_non-standard_schemes_in_iframes.patch @@ -146,3 +145,4 @@ fix_win32_synchronous_spellcheck.patch fix_drag_and_drop_icons_on_windows.patch chore_remove_conflicting_allow_unsafe_libc_calls.patch fix_take_snapped_status_into_account_when_showing_a_window.patch +chore_modify_chromium_handling_of_mouse_events.patch diff --git a/patches/chromium/chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch b/patches/chromium/chore_modify_chromium_handling_of_mouse_events.patch similarity index 60% rename from patches/chromium/chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch rename to patches/chromium/chore_modify_chromium_handling_of_mouse_events.patch index 47583a50ac41..2a643dc2d56d 100644 --- a/patches/chromium/chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch +++ b/patches/chromium/chore_modify_chromium_handling_of_mouse_events.patch @@ -1,11 +1,38 @@ 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 +Subject: chore: modify chromium handling of mouse events -With WCO, allow chromium to handle synthetic mouse events generated for touch +This patch does the following: + +1. When Windows Control Overlay is enabled, it allows chromium to handle synthetic mouse events generated for touch actions in the non-client caption area. +2. It calls HandleMouseEvent on the delegate earlier in HandleMouseEventInternal, so that Electron can selectively disable +draggable regions to allow events to propagate to the underlying renderer. +diff --git a/ui/events/event.h b/ui/events/event.h +index 39b5a8fdd165efd74b00256552b51b5413107958..bfc4ef4f50efff4a77f2aef64335bb7e34c69f34 100644 +--- a/ui/events/event.h ++++ b/ui/events/event.h +@@ -587,6 +587,9 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent { + + const PointerDetails& pointer_details() const { return pointer_details_; } + ++ bool is_system_menu() const { return is_system_menu_; } ++ void set_is_system_menu(bool is_menu) { is_system_menu_ = is_menu; } ++ + // Event: + std::string ToString() const override; + std::unique_ptr Clone() const override; +@@ -619,6 +622,8 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent { + + // Structure for holding pointer details for implementing PointerEvents API. + PointerDetails pointer_details_; ++ ++ bool is_system_menu_ = false; + }; + + class ScrollEvent; 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 2d05856687cd9669f72553d33c8033fd9083b4f8..645b7dd2cc20ce64ffa541c74930f541f083f931 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc @@ -34,10 +61,10 @@ index 932351e288f37fd09ae1a43f44e8b51fb0caa4b8..4a0616bc210d234e51e564daabdd2ebd // Overridden from WidgetObserver. void OnWidgetThemeChanged(Widget* widget) override; diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc -index 2bd015be3178ab8dea012d6b1f71d13dd0548c14..759f00dd4e674d1dfca690b82e6e1820900ebf0c 100644 +index c4d1d483454591031bd76dffced0c1d821800e13..e3bb491f218b2e5d96c424e40a071a618b345039 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc -@@ -3144,15 +3144,19 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, +@@ -3165,15 +3165,19 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, } // We must let Windows handle the caption buttons if it's drawing them, or // they won't work. @@ -59,6 +86,25 @@ index 2bd015be3178ab8dea012d6b1f71d13dd0548c14..759f00dd4e674d1dfca690b82e6e1820 return 0; } } +@@ -3203,7 +3207,17 @@ LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, + w_param = static_cast(SendMessage( + hwnd(), WM_NCHITTEST, 0, MAKELPARAM(screen_point.x, screen_point.y))); + if (w_param == HTCAPTION || w_param == HTSYSMENU) { +- ShowSystemMenuAtScreenPixelLocation(hwnd(), gfx::Point(screen_point)); ++ LONG message_time = GetMessageTime(); ++ CHROME_MSG msg = {hwnd(), ++ message, ++ w_param, ++ l_param, ++ static_cast(message_time), ++ {CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param)}}; ++ ui::MouseEvent event(msg); ++ event.set_is_system_menu(true); ++ if (!delegate_->HandleMouseEvent(&event)) ++ ShowSystemMenuAtScreenPixelLocation(hwnd(), gfx::Point(screen_point)); + return 0; + } + } else if (message == WM_NCLBUTTONDOWN && diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h index 04dea68d74ea4f559db60f716c919e555db9ec80..2f8bd1a3c156bb6c04663c74b7279bb59926fc3d 100644 --- a/ui/views/win/hwnd_message_handler_delegate.h diff --git a/patches/chromium/fix_activate_background_material_on_windows.patch b/patches/chromium/fix_activate_background_material_on_windows.patch index 9131aa33730a..fe5c683bcd25 100644 --- a/patches/chromium/fix_activate_background_material_on_windows.patch +++ b/patches/chromium/fix_activate_background_material_on_windows.patch @@ -14,7 +14,7 @@ This patch likely can't be upstreamed as-is, as Chromium doesn't have this use case in mind currently. diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc -index 9888ac709c51cd30228e3bca6915f7d89071cb83..e7b2bc1905958d2ff9c34ed7a22eb53e7ea3b9b8 100644 +index 1bbc783c8606f28c93b6e3bf2c60fe8ea4e1fc01..1ed6a143f76c21e0cfd5c7b319171c6f38a5df19 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -932,13 +932,13 @@ void HWNDMessageHandler::FrameTypeChanged() { diff --git a/patches/chromium/fix_remove_caption-removing_style_call.patch b/patches/chromium/fix_remove_caption-removing_style_call.patch index fcf8f6764eb5..4853bef474de 100644 --- a/patches/chromium/fix_remove_caption-removing_style_call.patch +++ b/patches/chromium/fix_remove_caption-removing_style_call.patch @@ -18,7 +18,7 @@ or resizing, but Electron does not seem to run into that issue for opaque frameless windows even with that block commented out. diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc -index 759f00dd4e674d1dfca690b82e6e1820900ebf0c..9888ac709c51cd30228e3bca6915f7d89071cb83 100644 +index 2bd015be3178ab8dea012d6b1f71d13dd0548c14..1bbc783c8606f28c93b6e3bf2c60fe8ea4e1fc01 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -1786,7 +1786,23 @@ LRESULT HWNDMessageHandler::OnCreate(CREATESTRUCT* create_struct) { diff --git a/patches/chromium/fix_take_snapped_status_into_account_when_showing_a_window.patch b/patches/chromium/fix_take_snapped_status_into_account_when_showing_a_window.patch index 6b4627723474..022210a908c7 100644 --- a/patches/chromium/fix_take_snapped_status_into_account_when_showing_a_window.patch +++ b/patches/chromium/fix_take_snapped_status_into_account_when_showing_a_window.patch @@ -19,7 +19,7 @@ would be removed from its snapped state when re-shown. This fixes that. Upstreamed at https://chromium-review.googlesource.com/c/chromium/src/+/6330848. diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc -index e7b2bc1905958d2ff9c34ed7a22eb53e7ea3b9b8..031f966192084b19294678b84c6962d32de61a47 100644 +index 1ed6a143f76c21e0cfd5c7b319171c6f38a5df19..c4d1d483454591031bd76dffced0c1d821800e13 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -674,7 +674,8 @@ void HWNDMessageHandler::Show(ui::mojom::WindowShowState show_state, diff --git a/shell/browser/native_window_views_win.cc b/shell/browser/native_window_views_win.cc index 91bd2413ce6e..a08d347c3b19 100644 --- a/shell/browser/native_window_views_win.cc +++ b/shell/browser/native_window_views_win.cc @@ -288,15 +288,6 @@ bool NativeWindowViews::PreHandleMSG(UINT message, return false; } - case WM_RBUTTONUP: { - if (!has_frame()) { - bool prevent_default = false; - NotifyWindowSystemContextMenu(GET_X_LPARAM(l_param), - GET_Y_LPARAM(l_param), &prevent_default); - return prevent_default; - } - return false; - } case WM_GETMINMAXINFO: { WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); 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 48d6894d907a..8050f79d42ee 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 @@ -108,6 +108,17 @@ bool ElectronDesktopWindowTreeHostWin::HandleMouseEventForCaption( return native_window_view_->IsWindowControlsOverlayEnabled(); } +bool ElectronDesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) { + if (event->is_system_menu() && !native_window_view_->has_frame()) { + bool prevent_default = false; + native_window_view_->NotifyWindowSystemContextMenu(event->x(), event->y(), + &prevent_default); + return prevent_default; + } + + return views::DesktopWindowTreeHostWin::HandleMouseEvent(event); +} + void ElectronDesktopWindowTreeHostWin::OnNativeThemeUpdated( ui::NativeTheme* observed_theme) { HWND hWnd = GetAcceleratedWidget(); 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 d654431b66ef..cc51d42e8353 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 @@ -40,6 +40,7 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin, bool GetClientAreaInsets(gfx::Insets* insets, HMONITOR monitor) const override; bool HandleMouseEventForCaption(UINT message) const override; + bool HandleMouseEvent(ui::MouseEvent* event) override; // ui::NativeThemeObserver: void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;