summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--o3d/plugin/cross/o3d_glue.cc10
-rw-r--r--o3d/plugin/cross/o3d_glue.h2
-rw-r--r--o3d/plugin/mac/main_mac.mm6
3 files changed, 10 insertions, 8 deletions
diff --git a/o3d/plugin/cross/o3d_glue.cc b/o3d/plugin/cross/o3d_glue.cc
index 2f8bcbd..84035f6 100644
--- a/o3d/plugin/cross/o3d_glue.cc
+++ b/o3d/plugin/cross/o3d_glue.cc
@@ -296,18 +296,18 @@ void PluginObject::DeleteRenderer() {
// It records the time of the event and tries to read the selected tab value
// from Safari (on other browsers this tab value should always be NULL).
// Written so that last_mac_event_time_ is always valid or NULL.
-void PluginObject::MacEventReceived() {
+void PluginObject::MacEventReceived(bool updateTab) {
CFDateRef now = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent());
CFDateRef previousTime = last_mac_event_time_;
last_mac_event_time_ = now;
if (previousTime != NULL) {
CFRelease(previousTime);
}
- if (!mac_cocoa_window_) {
- mac_cocoa_window_ = o3d::SafariBrowserWindowForWindowRef(mac_window_);
+ mac_cocoa_window_ = o3d::SafariBrowserWindowForWindowRef(mac_window_);
+ if (!mac_window_selected_tab_ || updateTab) {
+ mac_window_selected_tab_ =
+ o3d::SelectedTabForSafariBrowserWindow(mac_cocoa_window_);
}
- mac_window_selected_tab_ =
- o3d::SelectedTabForSafariBrowserWindow(mac_cocoa_window_);
}
// Returns the time elapsed since the MacEventReceived function was last called.
diff --git a/o3d/plugin/cross/o3d_glue.h b/o3d/plugin/cross/o3d_glue.h
index 97c88af..9af13dd 100644
--- a/o3d/plugin/cross/o3d_glue.h
+++ b/o3d/plugin/cross/o3d_glue.h
@@ -466,7 +466,7 @@ class PluginObject: public NPObject {
#ifdef OS_MACOSX
// Methods needed for the Safari tab-switching hack.
- void MacEventReceived();
+ void MacEventReceived(bool updateTab);
CFTimeInterval TimeSinceLastMacEvent();
diff --git a/o3d/plugin/mac/main_mac.mm b/o3d/plugin/mac/main_mac.mm
index f3ed8c7..5d28f236 100644
--- a/o3d/plugin/mac/main_mac.mm
+++ b/o3d/plugin/mac/main_mac.mm
@@ -737,7 +737,7 @@ bool HandleMacEvent(EventRecord* the_event, NPP instance) {
// Help the plugin keep track of when we last saw an event so the CFTimer can
// notice if we get cut off, eg by our tab being hidden by Safari, which there
// is no other way for us to detect.
- obj->MacEventReceived();
+ obj->MacEventReceived(the_event->what != nsPluginEventType_LoseFocusEvent);
switch (the_event->what) {
case nullEvent:
@@ -831,7 +831,9 @@ bool HandleCocoaEvent(NPP instance, NPCocoaEvent* the_event,
if (g_logger) g_logger->UpdateLogging();
- obj->MacEventReceived();
+ bool lostFocus = the_event->type == NPCocoaEventFocusChanged &&
+ !the_event->data.focus.hasFocus;
+ obj->MacEventReceived(!lostFocus);
switch (the_event->type) {
case NPCocoaEventDrawRect:
// We need to call the render callback from here if we are rendering