mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Windows: Improve menu responsiveness (issue #194).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@950 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -297,6 +297,13 @@ typedef struct _cef_browser_t {
|
|||||||
// Send a capture lost event to the browser.
|
// Send a capture lost event to the browser.
|
||||||
///
|
///
|
||||||
void (CEF_CALLBACK *send_capture_lost_event)(struct _cef_browser_t* self);
|
void (CEF_CALLBACK *send_capture_lost_event)(struct _cef_browser_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set to true (1) before calling Windows APIs like TrackPopupMenu that enter
|
||||||
|
// a modal message loop.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_osmodal_loop)(struct _cef_browser_t* self,
|
||||||
|
int osModalLoop);
|
||||||
} cef_browser_t;
|
} cef_browser_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -333,6 +333,13 @@ class CefBrowser : public virtual CefBase {
|
|||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual void SendCaptureLostEvent() =0;
|
virtual void SendCaptureLostEvent() =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Set to true before calling Windows APIs like TrackPopupMenu that enter a
|
||||||
|
// modal message loop.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void SetOSModalLoop(bool osModalLoop) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CEF_BROWSER_H_
|
#endif // CEF_INCLUDE_CEF_BROWSER_H_
|
||||||
|
@ -361,6 +361,11 @@ void CefBrowserImpl::CloseDevTools() {
|
|||||||
base::Bind(&CefBrowserImpl::UIT_CloseDevTools, this));
|
base::Bind(&CefBrowserImpl::UIT_CloseDevTools, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(OS_WIN)
|
||||||
|
void CefBrowserImpl::SetOSModalLoop(bool osModalLoop) {
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
WebKit::WebGeolocationClient* CefBrowserImpl::UIT_GetGeolocationClient() {
|
WebKit::WebGeolocationClient* CefBrowserImpl::UIT_GetGeolocationClient() {
|
||||||
if (!geolocation_client_)
|
if (!geolocation_client_)
|
||||||
geolocation_client_ = new CefGeolocationClient(this);
|
geolocation_client_ = new CefGeolocationClient(this);
|
||||||
|
@ -115,6 +115,7 @@ class CefBrowserImpl : public CefBrowser {
|
|||||||
OVERRIDE;
|
OVERRIDE;
|
||||||
virtual void SendFocusEvent(bool setFocus) OVERRIDE;
|
virtual void SendFocusEvent(bool setFocus) OVERRIDE;
|
||||||
virtual void SendCaptureLostEvent() OVERRIDE;
|
virtual void SendCaptureLostEvent() OVERRIDE;
|
||||||
|
virtual void SetOSModalLoop(bool osModalLoop) OVERRIDE;
|
||||||
|
|
||||||
// Frame-related methods
|
// Frame-related methods
|
||||||
void Undo(CefRefPtr<CefFrame> frame);
|
void Undo(CefRefPtr<CefFrame> frame);
|
||||||
|
@ -148,6 +148,15 @@ bool CefBrowserImpl::IsWindowRenderingDisabled() {
|
|||||||
return (window_info_.m_bWindowRenderingDisabled ? true : false);
|
return (window_info_.m_bWindowRenderingDisabled ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserImpl::SetOSModalLoop(bool osModalLoop) {
|
||||||
|
if (CefThread::CurrentlyOn(CefThread::UI)) {
|
||||||
|
MessageLoop::current()->set_os_modal_loop(osModalLoop);
|
||||||
|
} else {
|
||||||
|
CefThread::PostTask(CefThread::UI, FROM_HERE,
|
||||||
|
base::Bind(&CefBrowserImpl::SetOSModalLoop, this, osModalLoop));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() {
|
gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() {
|
||||||
REQUIRE_UIT();
|
REQUIRE_UIT();
|
||||||
return window_info_.m_bWindowRenderingDisabled ?
|
return window_info_.m_bWindowRenderingDisabled ?
|
||||||
|
@ -487,11 +487,15 @@ void BrowserWebViewDelegate::showContextMenu(
|
|||||||
if (!menu)
|
if (!menu)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
MessageLoop::current()->set_os_modal_loop(true);
|
||||||
|
|
||||||
// Show the context menu
|
// Show the context menu
|
||||||
int selected_id = TrackPopupMenu(menu,
|
int selected_id = TrackPopupMenu(menu,
|
||||||
TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_RECURSE,
|
TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_RECURSE,
|
||||||
screenX, screenY, 0, browser_->UIT_GetMainWndHandle(), NULL);
|
screenX, screenY, 0, browser_->UIT_GetMainWndHandle(), NULL);
|
||||||
|
|
||||||
|
MessageLoop::current()->set_os_modal_loop(false);
|
||||||
|
|
||||||
if (selected_id != 0) {
|
if (selected_id != 0) {
|
||||||
// An action was chosen
|
// An action was chosen
|
||||||
cef_menu_id_t menuId = static_cast<cef_menu_id_t>(selected_id);
|
cef_menu_id_t menuId = static_cast<cef_menu_id_t>(selected_id);
|
||||||
|
@ -703,6 +703,19 @@ void CEF_CALLBACK browser_send_capture_lost_event(struct _cef_browser_t* self) {
|
|||||||
CefBrowserCppToC::Get(self)->SendCaptureLostEvent();
|
CefBrowserCppToC::Get(self)->SendCaptureLostEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK browser_set_osmodal_loop(struct _cef_browser_t* self,
|
||||||
|
int osModalLoop) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefBrowserCppToC::Get(self)->SetOSModalLoop(
|
||||||
|
osModalLoop?true:false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// CONSTRUCTOR - Do not edit by hand.
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
@ -748,6 +761,7 @@ CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls)
|
|||||||
struct_.struct_.send_mouse_wheel_event = browser_send_mouse_wheel_event;
|
struct_.struct_.send_mouse_wheel_event = browser_send_mouse_wheel_event;
|
||||||
struct_.struct_.send_focus_event = browser_send_focus_event;
|
struct_.struct_.send_focus_event = browser_send_focus_event;
|
||||||
struct_.struct_.send_capture_lost_event = browser_send_capture_lost_event;
|
struct_.struct_.send_capture_lost_event = browser_send_capture_lost_event;
|
||||||
|
struct_.struct_.set_osmodal_loop = browser_set_osmodal_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -570,6 +570,17 @@ void CefBrowserCToCpp::SendCaptureLostEvent() {
|
|||||||
struct_->send_capture_lost_event(struct_);
|
struct_->send_capture_lost_event(struct_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserCToCpp::SetOSModalLoop(bool osModalLoop) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, set_osmodal_loop))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->set_osmodal_loop(struct_,
|
||||||
|
osModalLoop);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
template<> long CefCToCpp<CefBrowserCToCpp, CefBrowser,
|
template<> long CefCToCpp<CefBrowserCToCpp, CefBrowser,
|
||||||
|
@ -79,6 +79,7 @@ class CefBrowserCToCpp
|
|||||||
int deltaY) OVERRIDE;
|
int deltaY) OVERRIDE;
|
||||||
virtual void SendFocusEvent(bool setFocus) OVERRIDE;
|
virtual void SendFocusEvent(bool setFocus) OVERRIDE;
|
||||||
virtual void SendCaptureLostEvent() OVERRIDE;
|
virtual void SendCaptureLostEvent() OVERRIDE;
|
||||||
|
virtual void SetOSModalLoop(bool osModalLoop) OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // USING_CEF_SHARED
|
#endif // USING_CEF_SHARED
|
||||||
|
@ -605,6 +605,20 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_ENTERMENULOOP:
|
||||||
|
if (!wParam && g_handler.get() && g_handler->GetBrowserHwnd()) {
|
||||||
|
// Entering the menu loop for the application menu.
|
||||||
|
g_handler->GetBrowser()->SetOSModalLoop(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_EXITMENULOOP:
|
||||||
|
if (!wParam && g_handler.get() && g_handler->GetBrowserHwnd()) {
|
||||||
|
// Exiting the menu loop for the application menu.
|
||||||
|
g_handler->GetBrowser()->SetOSModalLoop(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
if (g_handler.get()) {
|
if (g_handler.get()) {
|
||||||
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
||||||
|
Reference in New Issue
Block a user