views: Support per-accelerator priority config (fixes #3598)

This commit is contained in:
Marshall Greenblatt
2023-11-08 14:27:50 -05:00
parent 2b38e2f793
commit d3d465b32e
12 changed files with 77 additions and 40 deletions

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=f72e94f6bd63b6ea623c4d3170b5ad4333c136d6$
// $hash=bc80e7f1e467a4e0943dcbf7ea6d08366817d5ca$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
@@ -77,13 +77,19 @@ typedef struct _cef_browser_view_t {
struct _cef_browser_view_t* self);
///
/// Sets whether accelerators registered with cef_window_t::SetAccelerator are
/// triggered before or after the event is sent to the cef_browser_t. If
/// |prefer_accelerators| is true (1) then the matching accelerator will be
/// triggered immediately and the event will not be sent to the cef_browser_t.
/// If |prefer_accelerators| is false (0) then the matching accelerator will
/// only be triggered if the event is not handled by web content or by
/// cef_keyboard_handler_t. The default value is false (0).
/// Sets whether normal priority accelerators are first forwarded to the web
/// content (`keydown` event handler) or cef_keyboard_handler_t. Normal
/// priority accelerators can be registered via cef_window_t::SetAccelerator
/// (with |high_priority|=false (0)) or internally for standard accelerators
/// supported by the Chrome runtime. If |prefer_accelerators| is true (1) then
/// the matching accelerator will be triggered immediately (calling
/// cef_window_delegate_t::OnAccelerator or
/// cef_command_handler_t::OnChromeCommand respectively) and the event will
/// not be forwarded to the web content or cef_keyboard_handler_t first. If
/// |prefer_accelerators| is false (0) then the matching accelerator will only
/// be triggered if the event is not handled by web content (`keydown` event
/// handler that calls `event.preventDefault()`) or by cef_keyboard_handler_t.
/// The default value is false (0).
///
void(CEF_CALLBACK* set_prefer_accelerators)(struct _cef_browser_view_t* self,
int prefer_accelerators);

View File

@@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=4b43fe0b493d860e8b28d7a6d892db49d1135b34$
// $hash=a48904fcd0f6be07e27839922d8feb07271ed2b5$
//
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_
@@ -332,16 +332,25 @@ typedef struct _cef_window_t {
///
/// Set the keyboard accelerator for the specified |command_id|. |key_code|
/// can be any virtual key or character value.
/// can be any virtual key or character value. Required modifier keys are
/// specified by |shift_pressed|, |ctrl_pressed| and/or |alt_pressed|.
/// cef_window_delegate_t::OnAccelerator will be called if the keyboard
/// combination is triggered while this window has focus.
///
/// The |high_priority| value will be considered if a child cef_browser_view_t
/// has focus when the keyboard combination is triggered. If |high_priority|
/// is true (1) then the key event will not be forwarded to the web content
/// (`keydown` event handler) or cef_keyboard_handler_t first. If
/// |high_priority| is false (0) then the behavior will depend on the
/// cef_browser_view_t::SetPreferAccelerators configuration.
///
void(CEF_CALLBACK* set_accelerator)(struct _cef_window_t* self,
int command_id,
int key_code,
int shift_pressed,
int ctrl_pressed,
int alt_pressed);
int alt_pressed,
int high_priority);
///
/// Remove the keyboard accelerator for the specified |command_id|.

View File

@@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "b6896cd6fe1f0a43197f649b0e18be1aac6b918d"
#define CEF_API_HASH_UNIVERSAL "c0c754c1ca4f72f6ca6a80861b38b34a61ed5116"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "4d4214adb1bb3cb7a3f8862e9241f2983a0175ca"
#define CEF_API_HASH_PLATFORM "b8db902c4604f9447ece1184f0d4f674503d0655"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "762ec50480531244f53add4b884f535c6b11f4be"
#define CEF_API_HASH_PLATFORM "a01475fc7c5d8bdc91e29add1aae56c7445a4d4b"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "a18434cc9be44f6e1040f03655908d0a0838d3e7"
#define CEF_API_HASH_PLATFORM "75cbf2876ee57cc093f9ab7905e19034754a4b8a"
#endif
#ifdef __cplusplus

View File

@@ -92,13 +92,18 @@ class CefBrowserView : public CefView {
virtual CefRefPtr<CefView> GetChromeToolbar() = 0;
///
/// Sets whether accelerators registered with CefWindow::SetAccelerator are
/// triggered before or after the event is sent to the CefBrowser. If
/// |prefer_accelerators| is true then the matching accelerator will be
/// triggered immediately and the event will not be sent to the CefBrowser. If
/// |prefer_accelerators| is false then the matching accelerator will only be
/// triggered if the event is not handled by web content or by
/// CefKeyboardHandler. The default value is false.
/// Sets whether normal priority accelerators are first forwarded to the web
/// content (`keydown` event handler) or CefKeyboardHandler. Normal priority
/// accelerators can be registered via CefWindow::SetAccelerator (with
/// |high_priority|=false) or internally for standard accelerators supported
/// by the Chrome runtime. If |prefer_accelerators| is true then the matching
/// accelerator will be triggered immediately (calling
/// CefWindowDelegate::OnAccelerator or CefCommandHandler::OnChromeCommand
/// respectively) and the event will not be forwarded to the web content or
/// CefKeyboardHandler first. If |prefer_accelerators| is false then the
/// matching accelerator will only be triggered if the event is not handled by
/// web content (`keydown` event handler that calls `event.preventDefault()`)
/// or by CefKeyboardHandler. The default value is false.
///
/*--cef()--*/
virtual void SetPreferAccelerators(bool prefer_accelerators) = 0;

View File

@@ -344,16 +344,25 @@ class CefWindow : public CefPanel {
///
/// Set the keyboard accelerator for the specified |command_id|. |key_code|
/// can be any virtual key or character value.
/// can be any virtual key or character value. Required modifier keys are
/// specified by |shift_pressed|, |ctrl_pressed| and/or |alt_pressed|.
/// CefWindowDelegate::OnAccelerator will be called if the keyboard
/// combination is triggered while this window has focus.
///
/// The |high_priority| value will be considered if a child CefBrowserView has
/// focus when the keyboard combination is triggered. If |high_priority| is
/// true then the key event will not be forwarded to the web content
/// (`keydown` event handler) or CefKeyboardHandler first. If |high_priority|
/// is false then the behavior will depend on the
/// CefBrowserView::SetPreferAccelerators configuration.
///
/*--cef()--*/
virtual void SetAccelerator(int command_id,
int key_code,
bool shift_pressed,
bool ctrl_pressed,
bool alt_pressed) = 0;
bool alt_pressed,
bool high_priority) = 0;
///
/// Remove the keyboard accelerator for the specified |command_id|.