- Revision
- 255995
- Author
- [email protected]
- Date
- 2020-02-06 17:41:21 -0800 (Thu, 06 Feb 2020)
Log Message
[Win][MiniBrowser] Accelerator keys don't work unless the main window is focused
https://bugs.webkit.org/show_bug.cgi?id=207250
Reviewed by Alex Christensen.
Source/WebKit:
* UIProcess/win/WebView.cpp:
(WebKit::WebView::wndProc): Bubble up unhandled WM_COMMAND to the
parent window.
Tools:
MiniBrowser has shortcut keys, Ctrl-W to close window, Ctrl-R to
reload. However, they don't work unless the main window is
focused.
Ctrl-W should be processed differently. Ctrl-W should be handled
without dispatching to WebKit, others should be handled only when
WebKit didn't consume. So, this change split the accelerator table
into two, one is for Ctrl-W, another is for other shortcut keys.
For Ctrl-W, key events are processed before dispatching to
WebView. It is converted to IDM_CLOSE_WINDOW of WM_COMMAND, and
dispatched to WebView. WebKit2 WebView bubbles up unhandled
WM_COMMAND to the parent window. Then, IDM_CLOSE_WINDOW is handled
in the main window's WndProc. However, it doesn't work for WebKit1
because this change doesn't add the bubbling up code to WebKit1
WebView.
For other shortcut keys, for example Ctrl-R, key events are
dispatched to WebView without accelerator key translations. Then,
WebKitBrowserWindow::didNotHandleKeyEvent is called back if they
aren't consumed. didNotHandleKeyEvent posts the messasge to the
main window. The message loop processed key events dispatched to
the main window with another accelerator table. However, it
doesn't work for WebKit1, because WebKit1 doesn't have a API
equivalent to didNotHandleKeyEvent.
After switching the active window by pressing Alt-Tab and
reactivating the main window, the main window got the focus. This
was the reason shortcut keys worked only after reactivating the
main window. But, this is not the desired behavior after this
change because other shortcut keys don't work if the main window
is focused. So. set the focus to the brower window when
WM_ACTIVATE of the main window.
Shortcut keys Ctrl++ (zoom in) and Ctrl+- (zoom out) were
effective only for keyboard numpad. Add VK_OEM_MINUS and
VK_OEM_PLUS for them.
Add a shortcut key Ctrl-0 to reset page zoom scale to actual.
* MiniBrowser/win/MainWindow.cpp:
(MainWindow::isInstance):
(MainWindow::WndProc):
* MiniBrowser/win/MainWindow.h:
* MiniBrowser/win/MiniBrowserLib.rc: Add a new accelerator table
IDR_ACCELERATORS_PRE for Ctrl-W.
* MiniBrowser/win/MiniBrowserLibResource.h:
* MiniBrowser/win/WebKitBrowserWindow.cpp:
(WebKitBrowserWindow::didNotHandleKeyEvent):
* MiniBrowser/win/WinMain.cpp:
(wWinMain):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (255994 => 255995)
--- trunk/Source/WebKit/ChangeLog 2020-02-07 01:32:50 UTC (rev 255994)
+++ trunk/Source/WebKit/ChangeLog 2020-02-07 01:41:21 UTC (rev 255995)
@@ -1,3 +1,14 @@
+2020-02-06 Fujii Hironori <[email protected]>
+
+ [Win][MiniBrowser] Accelerator keys don't work unless the main window is focused
+ https://bugs.webkit.org/show_bug.cgi?id=207250
+
+ Reviewed by Alex Christensen.
+
+ * UIProcess/win/WebView.cpp:
+ (WebKit::WebView::wndProc): Bubble up unhandled WM_COMMAND to the
+ parent window.
+
2020-02-06 Chris Dumez <[email protected]>
[WK2][iOS] Add WKWebviewConfiguration SPI to run client navigations at foreground priority, even if the view is background
Modified: trunk/Source/WebKit/UIProcess/win/WebView.cpp (255994 => 255995)
--- trunk/Source/WebKit/UIProcess/win/WebView.cpp 2020-02-07 01:32:50 UTC (rev 255994)
+++ trunk/Source/WebKit/UIProcess/win/WebView.cpp 2020-02-07 01:41:21 UTC (rev 255995)
@@ -184,6 +184,9 @@
case WM_MENUCOMMAND:
lResult = onMenuCommand(hWnd, message, wParam, lParam, handled);
break;
+ case WM_COMMAND:
+ SendMessage(GetParent(hWnd), message, wParam, lParam);
+ break;
default:
handled = false;
break;
Modified: trunk/Tools/ChangeLog (255994 => 255995)
--- trunk/Tools/ChangeLog 2020-02-07 01:32:50 UTC (rev 255994)
+++ trunk/Tools/ChangeLog 2020-02-07 01:41:21 UTC (rev 255995)
@@ -1,3 +1,62 @@
+2020-02-06 Fujii Hironori <[email protected]>
+
+ [Win][MiniBrowser] Accelerator keys don't work unless the main window is focused
+ https://bugs.webkit.org/show_bug.cgi?id=207250
+
+ Reviewed by Alex Christensen.
+
+ MiniBrowser has shortcut keys, Ctrl-W to close window, Ctrl-R to
+ reload. However, they don't work unless the main window is
+ focused.
+
+ Ctrl-W should be processed differently. Ctrl-W should be handled
+ without dispatching to WebKit, others should be handled only when
+ WebKit didn't consume. So, this change split the accelerator table
+ into two, one is for Ctrl-W, another is for other shortcut keys.
+
+ For Ctrl-W, key events are processed before dispatching to
+ WebView. It is converted to IDM_CLOSE_WINDOW of WM_COMMAND, and
+ dispatched to WebView. WebKit2 WebView bubbles up unhandled
+ WM_COMMAND to the parent window. Then, IDM_CLOSE_WINDOW is handled
+ in the main window's WndProc. However, it doesn't work for WebKit1
+ because this change doesn't add the bubbling up code to WebKit1
+ WebView.
+
+ For other shortcut keys, for example Ctrl-R, key events are
+ dispatched to WebView without accelerator key translations. Then,
+ WebKitBrowserWindow::didNotHandleKeyEvent is called back if they
+ aren't consumed. didNotHandleKeyEvent posts the messasge to the
+ main window. The message loop processed key events dispatched to
+ the main window with another accelerator table. However, it
+ doesn't work for WebKit1, because WebKit1 doesn't have a API
+ equivalent to didNotHandleKeyEvent.
+
+ After switching the active window by pressing Alt-Tab and
+ reactivating the main window, the main window got the focus. This
+ was the reason shortcut keys worked only after reactivating the
+ main window. But, this is not the desired behavior after this
+ change because other shortcut keys don't work if the main window
+ is focused. So. set the focus to the brower window when
+ WM_ACTIVATE of the main window.
+
+ Shortcut keys Ctrl++ (zoom in) and Ctrl+- (zoom out) were
+ effective only for keyboard numpad. Add VK_OEM_MINUS and
+ VK_OEM_PLUS for them.
+
+ Add a shortcut key Ctrl-0 to reset page zoom scale to actual.
+
+ * MiniBrowser/win/MainWindow.cpp:
+ (MainWindow::isInstance):
+ (MainWindow::WndProc):
+ * MiniBrowser/win/MainWindow.h:
+ * MiniBrowser/win/MiniBrowserLib.rc: Add a new accelerator table
+ IDR_ACCELERATORS_PRE for Ctrl-W.
+ * MiniBrowser/win/MiniBrowserLibResource.h:
+ * MiniBrowser/win/WebKitBrowserWindow.cpp:
+ (WebKitBrowserWindow::didNotHandleKeyEvent):
+ * MiniBrowser/win/WinMain.cpp:
+ (wWinMain):
+
2020-02-06 Jonathan Bedard <[email protected]>
results.webkitorg: Dead CI links
Modified: trunk/Tools/MiniBrowser/win/MainWindow.cpp (255994 => 255995)
--- trunk/Tools/MiniBrowser/win/MainWindow.cpp 2020-02-07 01:32:50 UTC (rev 255994)
+++ trunk/Tools/MiniBrowser/win/MainWindow.cpp 2020-02-07 01:41:21 UTC (rev 255995)
@@ -91,6 +91,14 @@
RegisterClassEx(&wcex);
}
+bool MainWindow::isInstance(HWND hwnd)
+{
+ wchar_t buff[64];
+ if (!GetClassName(hwnd, buff, _countof(buff)))
+ return false;
+ return s_windowClass == buff;
+}
+
MainWindow::MainWindow()
{
s_numInstances++;
@@ -172,6 +180,13 @@
{
RefPtr<MainWindow> thisWindow = reinterpret_cast<MainWindow*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
switch (message) {
+ case WM_ACTIVATE:
+ switch (LOWORD(wParam)) {
+ case WA_ACTIVE:
+ case WA_CLICKACTIVE:
+ SetFocus(thisWindow->browserWindow()->hwnd());
+ }
+ break;
case WM_CREATE:
SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams));
break;
Modified: trunk/Tools/MiniBrowser/win/MainWindow.h (255994 => 255995)
--- trunk/Tools/MiniBrowser/win/MainWindow.h 2020-02-07 01:32:50 UTC (rev 255994)
+++ trunk/Tools/MiniBrowser/win/MainWindow.h 2020-02-07 01:41:21 UTC (rev 255995)
@@ -45,6 +45,8 @@
BrowserWindow* browserWindow() const { return m_browserWindow.get(); }
void loadURL(std::wstring);
+
+ static bool isInstance(HWND);
private:
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
Modified: trunk/Tools/MiniBrowser/win/MiniBrowserLib.rc (255994 => 255995)
--- trunk/Tools/MiniBrowser/win/MiniBrowserLib.rc 2020-02-07 01:32:50 UTC (rev 255994)
+++ trunk/Tools/MiniBrowser/win/MiniBrowserLib.rc 2020-02-07 01:41:21 UTC (rev 255995)
@@ -51,7 +51,7 @@
POPUP "&View"
BEGIN
MENUITEM "Reload\tCtrl-R", IDM_RELOAD
- MENUITEM "Actual Size", IDM_ACTUAL_SIZE
+ MENUITEM "Actual Size\tCtrl+0", IDM_ACTUAL_SIZE
MENUITEM "Zoom In\tCtrl++", IDM_ZOOM_IN
MENUITEM "Zoom Out\tCtrl+-", IDM_ZOOM_OUT
MENUITEM "Invert Colors", IDM_INVERT_COLORS
@@ -129,11 +129,18 @@
IDC_MINIBROWSER ACCELERATORS
BEGIN
"/", IDM_ABOUT, ASCII, ALT, NOINVERT
+ "0", IDM_ACTUAL_SIZE, VIRTKEY, CONTROL, NOINVERT
"?", IDM_ABOUT, ASCII, ALT, NOINVERT
+ "R", IDM_RELOAD, VIRTKEY, CONTROL, NOINVERT
VK_ADD, IDM_ZOOM_IN, VIRTKEY, CONTROL, NOINVERT
+ VK_OEM_MINUS, IDM_ZOOM_OUT, VIRTKEY, CONTROL, NOINVERT
+ VK_OEM_PLUS, IDM_ZOOM_IN, VIRTKEY, CONTROL, NOINVERT
VK_SUBTRACT, IDM_ZOOM_OUT, VIRTKEY, CONTROL, NOINVERT
+END
+
+IDR_ACCELERATORS_PRE ACCELERATORS
+BEGIN
"W", IDM_CLOSE_WINDOW, VIRTKEY, CONTROL, NOINVERT
- "R", IDM_RELOAD, VIRTKEY, CONTROL, NOINVERT
END
Modified: trunk/Tools/MiniBrowser/win/MiniBrowserLibResource.h (255994 => 255995)
--- trunk/Tools/MiniBrowser/win/MiniBrowserLibResource.h 2020-02-07 01:32:50 UTC (rev 255994)
+++ trunk/Tools/MiniBrowser/win/MiniBrowserLibResource.h 2020-02-07 01:41:21 UTC (rev 255995)
@@ -58,6 +58,7 @@
#define IDM_DEBUG_INFO_LAYER 177
#define IDD_PROXY 178
#define IDD_SERVER_TRUST 179
+#define IDR_ACCELERATORS_PRE 180
#define IDC_EMPTY_URL_CACHE 1000
#define IDC_RETURN_FREE_MEMORY 1001
#define IDC_EMPTY_WEBCORE_CACHE 1002
@@ -132,8 +133,8 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
-#define _APS_NEXT_RESOURCE_VALUE 180
-#define _APS_NEXT_COMMAND_VALUE 32781
+#define _APS_NEXT_RESOURCE_VALUE 181
+#define _APS_NEXT_COMMAND_VALUE 32785
#define _APS_NEXT_CONTROL_VALUE 1063
#define _APS_NEXT_SYMED_VALUE 110
#endif
Modified: trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp (255994 => 255995)
--- trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp 2020-02-07 01:32:50 UTC (rev 255994)
+++ trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp 2020-02-07 01:41:21 UTC (rev 255995)
@@ -399,5 +399,5 @@
void WebKitBrowserWindow::didNotHandleKeyEvent(WKPageRef, WKNativeEventPtr event, const void* clientInfo)
{
auto& thisWindow = toWebKitBrowserWindow(clientInfo);
- DefWindowProc(thisWindow.hwnd(), event->message, event->wParam, event->lParam);
+ PostMessage(thisWindow.m_hMainWnd, event->message, event->wParam, event->lParam);
}
Modified: trunk/Tools/MiniBrowser/win/WinMain.cpp (255994 => 255995)
--- trunk/Tools/MiniBrowser/win/WinMain.cpp 2020-02-07 01:32:50 UTC (rev 255994)
+++ trunk/Tools/MiniBrowser/win/WinMain.cpp 2020-02-07 01:41:21 UTC (rev 255995)
@@ -58,7 +58,7 @@
#endif
MSG msg { };
- HACCEL hAccelTable;
+ HACCEL hAccelTable, hPreAccelTable;
INITCOMMONCONTROLSEX InitCtrlEx;
@@ -94,6 +94,7 @@
ShowWindow(mainWindow.hwnd(), nCmdShow);
hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_MINIBROWSER));
+ hPreAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_ACCELERATORS_PRE));
if (options.requestedURL.length())
mainWindow.loadURL(options.requestedURL.GetBSTR());
@@ -104,25 +105,20 @@
// Main message loop:
__try {
-#if ENABLE(WEBKIT)
while (GetMessage(&msg, nullptr, 0, 0)) {
#if USE(CF)
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
#endif
- if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
+ if (TranslateAccelerator(msg.hwnd, hPreAccelTable, &msg))
+ continue;
+ bool processed = false;
+ if (MainWindow::isInstance(msg.hwnd))
+ processed = TranslateAccelerator(msg.hwnd, hAccelTable, &msg);
+ if (!processed) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
-#else
- IWebKitMessageLoopPtr messageLoop;
-
- hr = WebKitCreateInstance(CLSID_WebKitMessageLoop, 0, IID_IWebKitMessageLoop, reinterpret_cast<void**>(&messageLoop.GetInterfacePtr()));
- if (FAILED(hr))
- goto exit;
-
- messageLoop->run(hAccelTable);
-#endif
} __except(createCrashReport(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) { }
exit: