Make DevToolsFocused in OS X
This commit is contained in:
parent
c30f458d4f
commit
352f758cd1
3 changed files with 29 additions and 0 deletions
|
@ -608,8 +608,10 @@ void InspectableWebContentsImpl::CloseContents(content::WebContents* source) {
|
|||
}
|
||||
|
||||
void InspectableWebContentsImpl::OnWebContentsFocused() {
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
if (view_->GetDelegate())
|
||||
view_->GetDelegate()->DevToolsFocused();
|
||||
#endif
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
|
|
|
@ -24,6 +24,7 @@ using brightray::InspectableWebContentsViewMac;
|
|||
}
|
||||
|
||||
- (instancetype)initWithInspectableWebContentsViewMac:(InspectableWebContentsViewMac*)view;
|
||||
- (void)notifyDevToolsFocused;
|
||||
- (void)setDevToolsVisible:(BOOL)visible;
|
||||
- (BOOL)isDevToolsVisible;
|
||||
- (BOOL)isDevToolsFocused;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "browser/mac/bry_inspectable_web_contents_view.h"
|
||||
|
||||
#include "browser/inspectable_web_contents_impl.h"
|
||||
#include "browser/inspectable_web_contents_view_delegate.h"
|
||||
#include "browser/inspectable_web_contents_view_mac.h"
|
||||
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
|
@ -27,6 +28,12 @@ using namespace brightray;
|
|||
name:kViewDidBecomeFirstResponder
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(parentWindowBecameMain:)
|
||||
name:NSWindowDidBecomeMainNotification
|
||||
object:nil];
|
||||
|
||||
auto contents = inspectableWebContentsView_->inspectable_web_contents()->GetWebContents();
|
||||
auto contentsView = contents->GetNativeView();
|
||||
[contentsView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
|
@ -38,6 +45,11 @@ using namespace brightray;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
|
||||
[self adjustSubviews];
|
||||
}
|
||||
|
@ -46,6 +58,11 @@ using namespace brightray;
|
|||
inspectableWebContentsView_->inspectable_web_contents()->ShowDevTools();
|
||||
}
|
||||
|
||||
- (void)notifyDevToolsFocused {
|
||||
if (inspectableWebContentsView_->GetDelegate())
|
||||
inspectableWebContentsView_->GetDelegate()->DevToolsFocused();
|
||||
}
|
||||
|
||||
- (void)setDevToolsVisible:(BOOL)visible {
|
||||
if (visible == devtools_visible_)
|
||||
return;
|
||||
|
@ -191,9 +208,16 @@ using namespace brightray;
|
|||
|
||||
if ([[devToolsView subviews] containsObject:view]) {
|
||||
devtools_is_first_responder_ = YES;
|
||||
[self notifyDevToolsFocused];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)parentWindowBecameMain:(NSNotification*)notification {
|
||||
NSWindow* parentWindow = [notification object];
|
||||
if ([self window] == parentWindow && devtools_docked_ && devtools_is_first_responder_)
|
||||
[self notifyDevToolsFocused];
|
||||
}
|
||||
|
||||
#pragma mark - NSWindowDelegate
|
||||
|
||||
- (void)windowWillClose:(NSNotification*)notification {
|
||||
|
@ -211,6 +235,8 @@ using namespace brightray;
|
|||
content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
|
||||
if (rwhv)
|
||||
rwhv->SetActive(true);
|
||||
|
||||
[self notifyDevToolsFocused];
|
||||
}
|
||||
|
||||
- (void)windowDidResignMain:(NSNotification*)notification {
|
||||
|
|
Loading…
Add table
Reference in a new issue