mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-02 20:26:59 +01:00
Avoid calling OnSetFocus multiple times (issue #563).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@569 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
b59fc7633d
commit
0a1fd8b040
@ -130,12 +130,16 @@ void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable) {
|
||||
if (!host)
|
||||
return;
|
||||
|
||||
NSView* view = host->view_handle();
|
||||
if (!view)
|
||||
BrowserWebView* browserView = (BrowserWebView*)host->view_handle();
|
||||
if (!browserView)
|
||||
return;
|
||||
|
||||
if (enable)
|
||||
[[view window] makeFirstResponder:view];
|
||||
if (enable) {
|
||||
// Guard against calling OnSetFocus twice.
|
||||
browserView.in_setfocus = true;
|
||||
[[browserView window] makeFirstResponder:browserView];
|
||||
browserView.in_setfocus = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame) {
|
||||
|
@ -22,6 +22,7 @@ struct WebDropData;
|
||||
@private
|
||||
CefBrowserImpl* browser_; // weak
|
||||
NSTrackingArea* trackingArea_;
|
||||
bool is_in_setfocus_;
|
||||
|
||||
scoped_nsobject<WebDragSource> dragSource_;
|
||||
scoped_nsobject<WebDropTarget> dropTarget_;
|
||||
@ -58,6 +59,7 @@ struct WebDropData;
|
||||
offset:(NSPoint)offset;
|
||||
|
||||
@property (nonatomic, assign) CefBrowserImpl* browser;
|
||||
@property (nonatomic, assign) bool in_setfocus;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
@implementation BrowserWebView
|
||||
|
||||
@synthesize browser = browser_;
|
||||
@synthesize in_setfocus = is_in_setfocus_;
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
@ -163,12 +164,14 @@
|
||||
|
||||
- (BOOL)becomeFirstResponder {
|
||||
if (browser_ && browser_->UIT_GetWebView()) {
|
||||
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||
if (client.get()) {
|
||||
CefRefPtr<CefFocusHandler> handler = client->GetFocusHandler();
|
||||
if (handler.get() &&
|
||||
handler->OnSetFocus(browser_, FOCUS_SOURCE_SYSTEM)) {
|
||||
return NO;
|
||||
if (!is_in_setfocus_) {
|
||||
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||
if (client.get()) {
|
||||
CefRefPtr<CefFocusHandler> handler = client->GetFocusHandler();
|
||||
if (handler.get() &&
|
||||
handler->OnSetFocus(browser_, FOCUS_SOURCE_SYSTEM)) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,16 +601,21 @@ void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) {
|
||||
if (!popup()) {
|
||||
SetCapture(view_);
|
||||
|
||||
HWND parent_hwnd = ::GetParent(view_);
|
||||
if (parent_hwnd) {
|
||||
CefRefPtr<CefBrowserImpl> browser =
|
||||
static_cast<CefBrowserImpl*>(ui::GetWindowUserData(parent_hwnd));
|
||||
if (browser.get()) {
|
||||
// This mimics a temporary workaround in RenderWidgetHostViewWin
|
||||
// for bug 765011 to get focus when the mouse is clicked. This
|
||||
// happens after the mouse down event is sent to the renderer
|
||||
// because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN.
|
||||
browser->SetFocus(true);
|
||||
if (::GetFocus() != view_) {
|
||||
// Set focus to this window.
|
||||
HWND parent_hwnd = ::GetParent(view_);
|
||||
if (parent_hwnd) {
|
||||
CefRefPtr<CefBrowserImpl> browser =
|
||||
static_cast<CefBrowserImpl*>(
|
||||
ui::GetWindowUserData(parent_hwnd));
|
||||
if (browser.get()) {
|
||||
// This mimics a temporary workaround in RenderWidgetHostViewWin
|
||||
// for bug 765011 to get focus when the mouse is clicked. This
|
||||
// happens after the mouse down event is sent to the renderer
|
||||
// because normally Windows does a WM_SETFOCUS after
|
||||
// WM_LBUTTONDOWN.
|
||||
browser->SetFocus(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user