Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5871f81

Browse files
fix: touch events not recognized by WCO on windows (#35117) (#35177)
* fix: touch events not recognized by WCO on windows (#35117)* chore: update patchesCo-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
1 parent511f275 commit5871f81

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed

‎patches/chromium/.patches‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,4 @@ cherry-pick-3cbd5973d704.patch
139139
cherry-pick-902f0d144a5b.patch
140140
cherry-pick-664e0d8b4cfb.patch
141141
chore_add_electron_deps_to_gitignores.patch
142+
chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
};

‎shell/browser/ui/win/electron_desktop_window_tree_host_win.cc‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,25 @@ bool ElectronDesktopWindowTreeHostWin::GetClientAreaInsets(
9999
returnfalse;
100100
}
101101

102+
boolElectronDesktopWindowTreeHostWin::HandleMouseEventForCaption(
103+
UINT message)const {
104+
// Windows does not seem to generate WM_NCPOINTERDOWN/UP touch events for
105+
// caption buttons with WCO. This results in a no-op for
106+
// HWNDMessageHandler::HandlePointerEventTypeTouchOrNonClient and
107+
// WM_SYSCOMMAND is not generated for the touch action. However, Windows will
108+
// also generate a mouse event for every touch action and this gets handled in
109+
// HWNDMessageHandler::HandleMouseEventInternal.
110+
// With https://chromium-review.googlesource.com/c/chromium/src/+/1048877/
111+
// Chromium lets the OS handle caption buttons for FrameMode::SYSTEM_DRAWN but
112+
// again this does not generate the SC_MINIMIZE, SC_MAXIMIZE, SC_RESTORE
113+
// commands when Non-client mouse events are generated for HTCLOSE,
114+
// HTMINBUTTON, HTMAXBUTTON. To workaround this issue, wit this delegate we
115+
// let chromium handle the mouse events via
116+
// HWNDMessageHandler::HandleMouseInputForCaption instead of the OS and this
117+
// will generate the necessary system commands to perform caption button
118+
// actions due to the DefWindowProc call.
119+
// https://source.chromium.org/chromium/chromium/src/+/main:ui/views/win/hwnd_message_handler.cc;l=3611
120+
return native_window_view_->IsWindowControlsOverlayEnabled();
121+
}
122+
102123
}// namespace electron

‎shell/browser/ui/win/electron_desktop_window_tree_host_win.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ElectronDesktopWindowTreeHostWin
3636
boolGetDwmFrameInsetsInPixels(gfx::Insets* insets)constoverride;
3737
boolGetClientAreaInsets(gfx::Insets* insets,
3838
HMONITOR monitor)constoverride;
39+
boolHandleMouseEventForCaption(UINT message)constoverride;
3940

4041
private:
4142
NativeWindowViews* native_window_view_;// weak ref

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp