views: Support per-accelerator priority config (fixes #3598)
This commit is contained in:
parent
2b38e2f793
commit
d3d465b32e
|
@ -33,7 +33,7 @@
|
||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=f72e94f6bd63b6ea623c4d3170b5ad4333c136d6$
|
// $hash=bc80e7f1e467a4e0943dcbf7ea6d08366817d5ca$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_BROWSER_VIEW_CAPI_H_
|
#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);
|
struct _cef_browser_view_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Sets whether accelerators registered with cef_window_t::SetAccelerator are
|
/// Sets whether normal priority accelerators are first forwarded to the web
|
||||||
/// triggered before or after the event is sent to the cef_browser_t. If
|
/// content (`keydown` event handler) or cef_keyboard_handler_t. Normal
|
||||||
/// |prefer_accelerators| is true (1) then the matching accelerator will be
|
/// priority accelerators can be registered via cef_window_t::SetAccelerator
|
||||||
/// triggered immediately and the event will not be sent to the cef_browser_t.
|
/// (with |high_priority|=false (0)) or internally for standard accelerators
|
||||||
/// If |prefer_accelerators| is false (0) then the matching accelerator will
|
/// supported by the Chrome runtime. If |prefer_accelerators| is true (1) then
|
||||||
/// only be triggered if the event is not handled by web content or by
|
/// the matching accelerator will be triggered immediately (calling
|
||||||
/// cef_keyboard_handler_t. The default value is false (0).
|
/// 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,
|
void(CEF_CALLBACK* set_prefer_accelerators)(struct _cef_browser_view_t* self,
|
||||||
int prefer_accelerators);
|
int prefer_accelerators);
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=4b43fe0b493d860e8b28d7a6d892db49d1135b34$
|
// $hash=a48904fcd0f6be07e27839922d8feb07271ed2b5$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_
|
#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|
|
/// 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
|
/// cef_window_delegate_t::OnAccelerator will be called if the keyboard
|
||||||
/// combination is triggered while this window has focus.
|
/// 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,
|
void(CEF_CALLBACK* set_accelerator)(struct _cef_window_t* self,
|
||||||
int command_id,
|
int command_id,
|
||||||
int key_code,
|
int key_code,
|
||||||
int shift_pressed,
|
int shift_pressed,
|
||||||
int ctrl_pressed,
|
int ctrl_pressed,
|
||||||
int alt_pressed);
|
int alt_pressed,
|
||||||
|
int high_priority);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Remove the keyboard accelerator for the specified |command_id|.
|
/// Remove the keyboard accelerator for the specified |command_id|.
|
||||||
|
|
|
@ -42,13 +42,13 @@
|
||||||
// way that may cause binary incompatibility with other builds. The universal
|
// way that may cause binary incompatibility with other builds. The universal
|
||||||
// hash value will change if any platform is affected whereas the platform hash
|
// hash value will change if any platform is affected whereas the platform hash
|
||||||
// values will change only if that particular platform is affected.
|
// 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)
|
#if defined(OS_WIN)
|
||||||
#define CEF_API_HASH_PLATFORM "4d4214adb1bb3cb7a3f8862e9241f2983a0175ca"
|
#define CEF_API_HASH_PLATFORM "b8db902c4604f9447ece1184f0d4f674503d0655"
|
||||||
#elif defined(OS_MAC)
|
#elif defined(OS_MAC)
|
||||||
#define CEF_API_HASH_PLATFORM "762ec50480531244f53add4b884f535c6b11f4be"
|
#define CEF_API_HASH_PLATFORM "a01475fc7c5d8bdc91e29add1aae56c7445a4d4b"
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
#define CEF_API_HASH_PLATFORM "a18434cc9be44f6e1040f03655908d0a0838d3e7"
|
#define CEF_API_HASH_PLATFORM "75cbf2876ee57cc093f9ab7905e19034754a4b8a"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -92,13 +92,18 @@ class CefBrowserView : public CefView {
|
||||||
virtual CefRefPtr<CefView> GetChromeToolbar() = 0;
|
virtual CefRefPtr<CefView> GetChromeToolbar() = 0;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Sets whether accelerators registered with CefWindow::SetAccelerator are
|
/// Sets whether normal priority accelerators are first forwarded to the web
|
||||||
/// triggered before or after the event is sent to the CefBrowser. If
|
/// content (`keydown` event handler) or CefKeyboardHandler. Normal priority
|
||||||
/// |prefer_accelerators| is true then the matching accelerator will be
|
/// accelerators can be registered via CefWindow::SetAccelerator (with
|
||||||
/// triggered immediately and the event will not be sent to the CefBrowser. If
|
/// |high_priority|=false) or internally for standard accelerators supported
|
||||||
/// |prefer_accelerators| is false then the matching accelerator will only be
|
/// by the Chrome runtime. If |prefer_accelerators| is true then the matching
|
||||||
/// triggered if the event is not handled by web content or by
|
/// accelerator will be triggered immediately (calling
|
||||||
/// CefKeyboardHandler. The default value is false.
|
/// 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()--*/
|
/*--cef()--*/
|
||||||
virtual void SetPreferAccelerators(bool prefer_accelerators) = 0;
|
virtual void SetPreferAccelerators(bool prefer_accelerators) = 0;
|
||||||
|
|
|
@ -344,16 +344,25 @@ class CefWindow : public CefPanel {
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set the keyboard accelerator for the specified |command_id|. |key_code|
|
/// 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
|
/// CefWindowDelegate::OnAccelerator will be called if the keyboard
|
||||||
/// combination is triggered while this window has focus.
|
/// 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()--*/
|
/*--cef()--*/
|
||||||
virtual void SetAccelerator(int command_id,
|
virtual void SetAccelerator(int command_id,
|
||||||
int key_code,
|
int key_code,
|
||||||
bool shift_pressed,
|
bool shift_pressed,
|
||||||
bool ctrl_pressed,
|
bool ctrl_pressed,
|
||||||
bool alt_pressed) = 0;
|
bool alt_pressed,
|
||||||
|
bool high_priority) = 0;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Remove the keyboard accelerator for the specified |command_id|.
|
/// Remove the keyboard accelerator for the specified |command_id|.
|
||||||
|
|
|
@ -669,7 +669,8 @@ void CefWindowImpl::SetAccelerator(int command_id,
|
||||||
int key_code,
|
int key_code,
|
||||||
bool shift_pressed,
|
bool shift_pressed,
|
||||||
bool ctrl_pressed,
|
bool ctrl_pressed,
|
||||||
bool alt_pressed) {
|
bool alt_pressed,
|
||||||
|
bool high_priority) {
|
||||||
CEF_REQUIRE_VALID_RETURN_VOID();
|
CEF_REQUIRE_VALID_RETURN_VOID();
|
||||||
if (!widget_) {
|
if (!widget_) {
|
||||||
return;
|
return;
|
||||||
|
@ -698,7 +699,10 @@ void CefWindowImpl::SetAccelerator(int command_id,
|
||||||
views::FocusManager* focus_manager = widget_->GetFocusManager();
|
views::FocusManager* focus_manager = widget_->GetFocusManager();
|
||||||
DCHECK(focus_manager);
|
DCHECK(focus_manager);
|
||||||
focus_manager->RegisterAccelerator(
|
focus_manager->RegisterAccelerator(
|
||||||
accelerator, ui::AcceleratorManager::kNormalPriority, this);
|
accelerator,
|
||||||
|
high_priority ? ui::AcceleratorManager::kHighPriority
|
||||||
|
: ui::AcceleratorManager::kNormalPriority,
|
||||||
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefWindowImpl::RemoveAccelerator(int command_id) {
|
void CefWindowImpl::RemoveAccelerator(int command_id) {
|
||||||
|
|
|
@ -86,7 +86,8 @@ class CefWindowImpl
|
||||||
int key_code,
|
int key_code,
|
||||||
bool shift_pressed,
|
bool shift_pressed,
|
||||||
bool ctrl_pressed,
|
bool ctrl_pressed,
|
||||||
bool alt_pressed) override;
|
bool alt_pressed,
|
||||||
|
bool high_priority) override;
|
||||||
void RemoveAccelerator(int command_id) override;
|
void RemoveAccelerator(int command_id) override;
|
||||||
void RemoveAllAccelerators() override;
|
void RemoveAllAccelerators() override;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=23777aea864e9abf38c2e2c5d79a40d6bd22876d$
|
// $hash=38a50bca35881beb6400f3ad5d81b0a5ec86331d$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/cpptoc/views/window_cpptoc.h"
|
#include "libcef_dll/cpptoc/views/window_cpptoc.h"
|
||||||
|
@ -672,7 +672,8 @@ void CEF_CALLBACK window_set_accelerator(struct _cef_window_t* self,
|
||||||
int key_code,
|
int key_code,
|
||||||
int shift_pressed,
|
int shift_pressed,
|
||||||
int ctrl_pressed,
|
int ctrl_pressed,
|
||||||
int alt_pressed) {
|
int alt_pressed,
|
||||||
|
int high_priority) {
|
||||||
shutdown_checker::AssertNotShutdown();
|
shutdown_checker::AssertNotShutdown();
|
||||||
|
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
@ -685,7 +686,8 @@ void CEF_CALLBACK window_set_accelerator(struct _cef_window_t* self,
|
||||||
// Execute
|
// Execute
|
||||||
CefWindowCppToC::Get(self)->SetAccelerator(
|
CefWindowCppToC::Get(self)->SetAccelerator(
|
||||||
command_id, key_code, shift_pressed ? true : false,
|
command_id, key_code, shift_pressed ? true : false,
|
||||||
ctrl_pressed ? true : false, alt_pressed ? true : false);
|
ctrl_pressed ? true : false, alt_pressed ? true : false,
|
||||||
|
high_priority ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEF_CALLBACK window_remove_accelerator(struct _cef_window_t* self,
|
void CEF_CALLBACK window_remove_accelerator(struct _cef_window_t* self,
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=b6b0a2a563b475163aa71b20af6ec2ac8c1f0cae$
|
// $hash=c8f164d20875c8071837c04abb44e09672d894af$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/ctocpp/views/window_ctocpp.h"
|
#include "libcef_dll/ctocpp/views/window_ctocpp.h"
|
||||||
|
@ -663,7 +663,8 @@ void CefWindowCToCpp::SetAccelerator(int command_id,
|
||||||
int key_code,
|
int key_code,
|
||||||
bool shift_pressed,
|
bool shift_pressed,
|
||||||
bool ctrl_pressed,
|
bool ctrl_pressed,
|
||||||
bool alt_pressed) {
|
bool alt_pressed,
|
||||||
|
bool high_priority) {
|
||||||
shutdown_checker::AssertNotShutdown();
|
shutdown_checker::AssertNotShutdown();
|
||||||
|
|
||||||
cef_window_t* _struct = GetStruct();
|
cef_window_t* _struct = GetStruct();
|
||||||
|
@ -675,7 +676,7 @@ void CefWindowCToCpp::SetAccelerator(int command_id,
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
_struct->set_accelerator(_struct, command_id, key_code, shift_pressed,
|
_struct->set_accelerator(_struct, command_id, key_code, shift_pressed,
|
||||||
ctrl_pressed, alt_pressed);
|
ctrl_pressed, alt_pressed, high_priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
NO_SANITIZE("cfi-icall")
|
NO_SANITIZE("cfi-icall")
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=2a7aaed7d4296e29dca74345cf2b2d4db221a738$
|
// $hash=d0c31c38bf29c9b44f645e69a912b6b8a4030066$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_CTOCPP_H_
|
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_CTOCPP_H_
|
||||||
|
@ -83,7 +83,8 @@ class CefWindowCToCpp
|
||||||
int key_code,
|
int key_code,
|
||||||
bool shift_pressed,
|
bool shift_pressed,
|
||||||
bool ctrl_pressed,
|
bool ctrl_pressed,
|
||||||
bool alt_pressed) override;
|
bool alt_pressed,
|
||||||
|
bool high_priority) override;
|
||||||
void RemoveAccelerator(int command_id) override;
|
void RemoveAccelerator(int command_id) override;
|
||||||
void RemoveAllAccelerators() override;
|
void RemoveAllAccelerators() override;
|
||||||
|
|
||||||
|
|
|
@ -1283,12 +1283,11 @@ void ViewsWindow::AddControls() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewsWindow::AddAccelerators() {
|
void ViewsWindow::AddAccelerators() {
|
||||||
// Trigger accelerators without first forwarding to web content.
|
|
||||||
browser_view_->SetPreferAccelerators(true);
|
|
||||||
|
|
||||||
// Specify the accelerators to handle. OnAccelerator will be called when the
|
// Specify the accelerators to handle. OnAccelerator will be called when the
|
||||||
// accelerator is triggered.
|
// accelerator is triggered.
|
||||||
window_->SetAccelerator(ID_QUIT, 'X', false, false, true);
|
window_->SetAccelerator(ID_QUIT, 'X', /*shift_pressed=*/false,
|
||||||
|
/*ctrl_pressed=*/false, /*alt_pressed=*/true,
|
||||||
|
/*high_priority=*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewsWindow::SetMenuFocusable(bool focusable) {
|
void ViewsWindow::SetMenuFocusable(bool focusable) {
|
||||||
|
|
|
@ -562,7 +562,7 @@ bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunWindowAccelerator(CefRefPtr<CefWindow> window) {
|
void RunWindowAccelerator(CefRefPtr<CefWindow> window) {
|
||||||
window->SetAccelerator(kCloseWindowId, kChar, false, false, true);
|
window->SetAccelerator(kCloseWindowId, kChar, false, false, true, false);
|
||||||
window->Show();
|
window->Show();
|
||||||
|
|
||||||
CefPostDelayedTask(TID_UI, base::BindOnce(TriggerAccelerator, window),
|
CefPostDelayedTask(TID_UI, base::BindOnce(TriggerAccelerator, window),
|
||||||
|
|
Loading…
Reference in New Issue