chromiumembedded / cef

Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
https://bitbucket.org/chromiumembedded/cef/
Other
3.38k stars 467 forks source link

`CefWindowDelegate::OnKeyEvent` is not triggered #3797

Open nik-sp opened 1 month ago

nik-sp commented 1 month ago

Describe the bug

While investigating the failure of ViewsWindowTest.WindowAccelerator, I noticed that the OnKeyEvent function is not triggered. This happens because CefWindowDelegate::OnKeyEvent is not being called as expected.

To Reproduce

I haven't tested on Linux or Windows, but I expect the issue to be reproducible there as well.
It does work on Windows using CefUnhandledKeyEventHandler: https://github.com/chromiumembedded/cef/blob/a231b7ead7e624dc5c2d79bf4c160aed9c8efeb9/libcef/browser/views/window_impl.cc#L59

Steps to reproduce the issue:

  1. Run the ViewsWindowTest.WindowAccelerator unit test:
    ./out/Debug_GN_arm64/ceftests.app/Contents/MacOS/ceftests --use-views --enable-chrome-runtime --gtest_filter=ViewsWindowTest.WindowAccelerator
  2. Observe that OnKeyEvent is never called.

Alternatively, you can:

  1. Run cefclient and set a breakpoint at ViewsWindow::OnKeyEvent: https://github.com/chromiumembedded/cef/blob/a231b7ead7e624dc5c2d79bf4c160aed9c8efeb9/tests/cefclient/browser/views_window.cc#L908
  2. Press any key.
  3. Notice that OnKeyEvent is not called.

Expected behavior

CefWindowDelegate::OnKeyEvent should be triggered whenever a key is pressed: https://github.com/chromiumembedded/cef/blob/a231b7ead7e624dc5c2d79bf4c160aed9c8efeb9/include/views/cef_window_delegate.h#L229-L235

Versions (please complete the following information):