Emit("blur");
}
+void Window::OnWindowFocus() {
+ Emit("focus");
+}
+
void Window::OnRendererUnresponsive() {
Emit("unresponsive");
}
virtual void WillCloseWindow(bool* prevent_default) OVERRIDE;
virtual void OnWindowClosed() OVERRIDE;
virtual void OnWindowBlur() OVERRIDE;
+ virtual void OnWindowFocus() OVERRIDE;
virtual void OnRendererUnresponsive() OVERRIDE;
virtual void OnRendererResponsive() OVERRIDE;
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowBlur());
}
+void NativeWindow::NotifyWindowFocus() {
+ FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowFocus());
+}
+
// In atom-shell all reloads and navigations started by renderer process would
// be redirected to this method, so we can have precise control of how we
// would open the url (in our case, is to restart the renderer process). See
// related notifications.
void NotifyWindowClosed();
void NotifyWindowBlur();
+ void NotifyWindowFocus();
void AddObserver(NativeWindowObserver* obs) {
observers_.AddObserver(obs);
return TRUE;
}
+gboolean NativeWindowGtk::OnFocusIn(GtkWidget* window, GdkEventFocus*) {
+ NotifyWindowFocus();
+ return FALSE;
+}
+
gboolean NativeWindowGtk::OnFocusOut(GtkWidget* window, GdkEventFocus*) {
NotifyWindowBlur();
return FALSE;
CHROMEGTK_CALLBACK_1(NativeWindowGtk, gboolean, OnWindowDeleteEvent,
GdkEvent*);
+ CHROMEGTK_CALLBACK_1(NativeWindowGtk, gboolean, OnFocusIn, GdkEventFocus*);
CHROMEGTK_CALLBACK_1(NativeWindowGtk, gboolean, OnFocusOut, GdkEventFocus*);
CHROMEGTK_CALLBACK_1(NativeWindowGtk, gboolean, OnWindowState,
GdkEventWindowState*);
acceptsFirstMouse_ = accept;
}
+- (void)windowDidBecomeMain:(NSNotification*)notification {
+ shell_->NotifyWindowFocus();
+}
+
- (void)windowDidResignMain:(NSNotification*)notification {
shell_->NotifyWindowBlur();
}
// Called when window loses focus.
virtual void OnWindowBlur() {}
+ // Called when window gains focus.
+ virtual void OnWindowFocus() {}
+
// Called when renderer is hung.
virtual void OnRendererUnresponsive() {}
Emitted when window loses focus.
+### Event: 'focus'
+
+Emitted when window gains focus.
+
### Class Method: BrowserWindow.getAllWindows()
Returns an array of all opened browser windows.