mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-17 04:30:46 +01: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:
parent
9accdc8b01
commit
f782b4b1e0
@ -297,6 +297,13 @@ typedef struct _cef_browser_t {
|
||||
// Send a capture lost event to the browser.
|
||||
///
|
||||
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;
|
||||
|
||||
|
||||
|
@ -333,6 +333,13 @@ class CefBrowser : public virtual CefBase {
|
||||
///
|
||||
/*--cef()--*/
|
||||
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_
|
||||
|
@ -361,6 +361,11 @@ void CefBrowserImpl::CloseDevTools() {
|
||||
base::Bind(&CefBrowserImpl::UIT_CloseDevTools, this));
|
||||
}
|
||||
|
||||
#if !defined(OS_WIN)
|
||||
void CefBrowserImpl::SetOSModalLoop(bool osModalLoop) {
|
||||
}
|
||||
#endif
|
||||
|
||||
WebKit::WebGeolocationClient* CefBrowserImpl::UIT_GetGeolocationClient() {
|
||||
if (!geolocation_client_)
|
||||
geolocation_client_ = new CefGeolocationClient(this);
|
||||
|
@ -115,6 +115,7 @@ class CefBrowserImpl : public CefBrowser {
|
||||
OVERRIDE;
|
||||
virtual void SendFocusEvent(bool setFocus) OVERRIDE;
|
||||
virtual void SendCaptureLostEvent() OVERRIDE;
|
||||
virtual void SetOSModalLoop(bool osModalLoop) OVERRIDE;
|
||||
|
||||
// Frame-related methods
|
||||
void Undo(CefRefPtr<CefFrame> frame);
|
||||
|
@ -148,6 +148,15 @@ bool CefBrowserImpl::IsWindowRenderingDisabled() {
|
||||
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() {
|
||||
REQUIRE_UIT();
|
||||
return window_info_.m_bWindowRenderingDisabled ?
|
||||
|
@ -487,11 +487,15 @@ void BrowserWebViewDelegate::showContextMenu(
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
MessageLoop::current()->set_os_modal_loop(true);
|
||||
|
||||
// Show the context menu
|
||||
int selected_id = TrackPopupMenu(menu,
|
||||
TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_RECURSE,
|
||||
screenX, screenY, 0, browser_->UIT_GetMainWndHandle(), NULL);
|
||||
|
||||
MessageLoop::current()->set_os_modal_loop(false);
|
||||
|
||||
if (selected_id != 0) {
|
||||
// An action was chosen
|
||||
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();
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
@ -748,6 +761,7 @@ CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls)
|
||||
struct_.struct_.send_mouse_wheel_event = browser_send_mouse_wheel_event;
|
||||
struct_.struct_.send_focus_event = browser_send_focus_event;
|
||||
struct_.struct_.send_capture_lost_event = browser_send_capture_lost_event;
|
||||
struct_.struct_.set_osmodal_loop = browser_set_osmodal_loop;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -570,6 +570,17 @@ void CefBrowserCToCpp::SendCaptureLostEvent() {
|
||||
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
|
||||
template<> long CefCToCpp<CefBrowserCToCpp, CefBrowser,
|
||||
|
@ -79,6 +79,7 @@ class CefBrowserCToCpp
|
||||
int deltaY) OVERRIDE;
|
||||
virtual void SendFocusEvent(bool setFocus) OVERRIDE;
|
||||
virtual void SendCaptureLostEvent() OVERRIDE;
|
||||
virtual void SetOSModalLoop(bool osModalLoop) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
|
@ -605,6 +605,20 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
}
|
||||
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:
|
||||
if (g_handler.get()) {
|
||||
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
||||
|
Loading…
x
Reference in New Issue
Block a user