mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
fix: touch events not recognized by WCO on windows (#35117)
This commit is contained in:
@@ -95,6 +95,27 @@ 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();
|
||||
}
|
||||
|
||||
void ElectronDesktopWindowTreeHostWin::OnNativeThemeUpdated(
|
||||
ui::NativeTheme* observed_theme) {
|
||||
win::SetDarkModeForWindow(GetAcceleratedWidget());
|
||||
|
||||
@@ -36,6 +36,7 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin,
|
||||
bool GetDwmFrameInsetsInPixels(gfx::Insets* insets) const override;
|
||||
bool GetClientAreaInsets(gfx::Insets* insets,
|
||||
HMONITOR monitor) const override;
|
||||
bool HandleMouseEventForCaption(UINT message) const override;
|
||||
|
||||
// ui::NativeThemeObserver:
|
||||
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
|
||||
|
||||
Reference in New Issue
Block a user