| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #include "plugin_mac.h" | 34 #include "plugin_mac.h" |
| 35 #include <Breakpad/Breakpad.h> | 35 #include <Breakpad/Breakpad.h> |
| 36 #include <Cocoa/Cocoa.h> | 36 #include <Cocoa/Cocoa.h> |
| 37 #include <QuickTime/QuickTime.h> | 37 #include <QuickTime/QuickTime.h> |
| 38 #include "plugin/cross/o3d_glue.h" | 38 #include "plugin/cross/o3d_glue.h" |
| 39 #include "plugin/cross/main.h" | 39 #include "plugin/cross/main.h" |
| 40 #include "core/mac/display_window_mac.h" | 40 #include "core/mac/display_window_mac.h" |
| 41 #include "plugin/mac/graphics_utils_mac.h" | 41 #include "plugin/mac/graphics_utils_mac.h" |
| 42 | 42 |
| 43 #if !defined(O3D_INTERNAL_PLUGIN) |
| 43 BreakpadRef gBreakpadRef = NULL; | 44 BreakpadRef gBreakpadRef = NULL; |
| 45 #endif |
| 44 | 46 |
| 45 using glue::_o3d::PluginObject; | 47 using glue::_o3d::PluginObject; |
| 46 using o3d::DisplayWindowMac; | 48 using o3d::DisplayWindowMac; |
| 47 | 49 |
| 50 @interface NSWindowController (plugin_hack) |
| 51 - (id)selectedTab; |
| 52 @end |
| 53 |
| 54 namespace o3d { |
| 48 | 55 |
| 49 // Returns the version number of the running Mac browser, as parsed from | 56 // Returns the version number of the running Mac browser, as parsed from |
| 50 // the short version string in the plist of the app's bundle. | 57 // the short version string in the plist of the app's bundle. |
| 51 bool GetBrowserVersionInfo(int *returned_major, | 58 bool GetBrowserVersionInfo(int *returned_major, |
| 52 int *returned_minor, | 59 int *returned_minor, |
| 53 int *returned_bugfix) { | 60 int *returned_bugfix) { |
| 54 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | 61 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
| 55 int major = 0; | 62 int major = 0; |
| 56 int minor = 0; | 63 int minor = 0; |
| 57 int bugfix = 0; | 64 int bugfix = 0; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // the walk from windowref to cocoa window (of type "BrowserWindow") to cocoa | 104 // the walk from windowref to cocoa window (of type "BrowserWindow") to cocoa |
| 98 // windowcontroller to selectedTab should harmlessly break down somewhere along | 105 // windowcontroller to selectedTab should harmlessly break down somewhere along |
| 99 // the way. | 106 // the way. |
| 100 // | 107 // |
| 101 // This is useful merely for peeking at Safari's internal state for a tab change | 108 // This is useful merely for peeking at Safari's internal state for a tab change |
| 102 // event, as Safari does not notify us when this happens. It coerces the value | 109 // event, as Safari does not notify us when this happens. It coerces the value |
| 103 // to a void*, as the plain .cc files don't like the type id, and we actually | 110 // to a void*, as the plain .cc files don't like the type id, and we actually |
| 104 // only care whether the value changes or not. | 111 // only care whether the value changes or not. |
| 105 | 112 |
| 106 | 113 |
| 107 @interface NSWindowController (plugin_hack) | |
| 108 - (id)selectedTab; | |
| 109 @end | |
| 110 | |
| 111 void ReleaseSafariBrowserWindow(void* browserWindow) { | 114 void ReleaseSafariBrowserWindow(void* browserWindow) { |
| 112 NSWindow* cocoaWindow = (NSWindow*) browserWindow; | 115 NSWindow* cocoaWindow = (NSWindow*) browserWindow; |
| 113 [cocoaWindow release]; | 116 [cocoaWindow release]; |
| 114 } | 117 } |
| 115 | 118 |
| 116 void* SafariBrowserWindowForWindowRef(WindowRef theWindow) { | 119 void* SafariBrowserWindowForWindowRef(WindowRef theWindow) { |
| 117 if (theWindow != NULL) { | 120 if (theWindow != NULL) { |
| 118 NSWindow* cocoaWindow = [[NSWindow alloc] initWithWindowRef:theWindow]; | 121 NSWindow* cocoaWindow = [[NSWindow alloc] initWithWindowRef:theWindow]; |
| 119 if (cocoaWindow) { | 122 if (cocoaWindow) { |
| 120 if (strcmp(object_getClassName(cocoaWindow), "BrowserWindow") == 0) { | 123 if (strcmp(object_getClassName(cocoaWindow), "BrowserWindow") == 0) { |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 NSArray* mac_modes = (NSArray*)CGDisplayAvailableModes(CGMainDisplayID()); | 886 NSArray* mac_modes = (NSArray*)CGDisplayAvailableModes(CGMainDisplayID()); |
| 884 int num_modes = [mac_modes count]; | 887 int num_modes = [mac_modes count]; |
| 885 std::vector<o3d::DisplayMode> modes_found; | 888 std::vector<o3d::DisplayMode> modes_found; |
| 886 | 889 |
| 887 for (int i = 0; i < num_modes; ++i) { | 890 for (int i = 0; i < num_modes; ++i) { |
| 888 int width = 0; | 891 int width = 0; |
| 889 int height = 0; | 892 int height = 0; |
| 890 int refresh_rate = 0; | 893 int refresh_rate = 0; |
| 891 int bpp = 0; | 894 int bpp = 0; |
| 892 | 895 |
| 893 if (ExtractDisplayModeData([mac_modes objectAtIndex:i], | 896 if (o3d::ExtractDisplayModeData([mac_modes objectAtIndex:i], |
| 894 &width, | 897 &width, |
| 895 &height, | 898 &height, |
| 896 &refresh_rate, | 899 &refresh_rate, |
| 897 &bpp) && bpp == 32) | 900 &bpp) && bpp == 32) |
| 898 modes_found.push_back(o3d::DisplayMode(width, height, refresh_rate, | 901 modes_found.push_back(o3d::DisplayMode(width, height, refresh_rate, |
| 899 i + kO3D_MODE_OFFSET)); | 902 i + o3d::kO3D_MODE_OFFSET)); |
| 900 } | 903 } |
| 901 | 904 |
| 902 modes->swap(modes_found); | 905 modes->swap(modes_found); |
| 903 } | 906 } |
| 904 | 907 |
| 905 | 908 |
| 906 #pragma mark ____FULLSCREEN_SWITCHING | 909 #pragma mark ____FULLSCREEN_SWITCHING |
| 907 | 910 |
| 908 #define kTransitionTime 1.0 | 911 #define kTransitionTime 1.0 |
| 909 | 912 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 &short_target_width, | 945 &short_target_width, |
| 943 &short_target_height, | 946 &short_target_height, |
| 944 &fullscreen_window, | 947 &fullscreen_window, |
| 945 NULL, | 948 NULL, |
| 946 fullScreenCaptureAllDisplays); | 949 fullScreenCaptureAllDisplays); |
| 947 } else { | 950 } else { |
| 948 SetSystemUIMode(kUIModeAllSuppressed, kUIOptionAutoShowMenuBar); | 951 SetSystemUIMode(kUIModeAllSuppressed, kUIOptionAutoShowMenuBar); |
| 949 mac_fullscreen_state_ = NULL; | 952 mac_fullscreen_state_ = NULL; |
| 950 } | 953 } |
| 951 | 954 |
| 952 SetFullscreenMacWindow(CreateFullscreenWindow(NULL, | 955 SetFullscreenMacWindow(o3d::CreateFullscreenWindow( |
| 953 this, | 956 NULL, |
| 954 fullscreen_region_mode_id_)); | 957 this, |
| 958 fullscreen_region_mode_id_)); |
| 955 Rect bounds = {0,0,0,0}; | 959 Rect bounds = {0,0,0,0}; |
| 956 GetWindowBounds(GetFullscreenMacWindow(), kWindowContentRgn, &bounds); | 960 GetWindowBounds(GetFullscreenMacWindow(), kWindowContentRgn, &bounds); |
| 957 | 961 |
| 958 SetWindowForAGLContext(mac_agl_context_, GetFullscreenMacWindow()); | 962 o3d::SetWindowForAGLContext(mac_agl_context_, GetFullscreenMacWindow()); |
| 959 aglDisable(mac_agl_context_, AGL_BUFFER_RECT); | 963 aglDisable(mac_agl_context_, AGL_BUFFER_RECT); |
| 960 renderer()->SetClientOriginOffset(0, 0); | 964 renderer()->SetClientOriginOffset(0, 0); |
| 961 renderer_->Resize(bounds.right - bounds.left, bounds.bottom - bounds.top); | 965 renderer_->Resize(bounds.right - bounds.left, bounds.bottom - bounds.top); |
| 962 | 966 |
| 963 fullscreen_ = true; | 967 fullscreen_ = true; |
| 964 client()->SendResizeEvent(renderer_->width(), renderer_->height(), true); | 968 client()->SendResizeEvent(renderer_->width(), renderer_->height(), true); |
| 965 | 969 |
| 966 SetFullscreenOverlayMacWindow(CreateOverlayWindow()); | 970 SetFullscreenOverlayMacWindow(o3d::CreateOverlayWindow()); |
| 967 ShowWindow(mac_fullscreen_overlay_window_); | 971 ShowWindow(mac_fullscreen_overlay_window_); |
| 968 SlideWindowToRect(mac_fullscreen_overlay_window_, | 972 o3d::SlideWindowToRect(mac_fullscreen_overlay_window_, |
| 969 Rect2CGRect(GetOverlayWindowRect(true)), | 973 o3d::Rect2CGRect(o3d::GetOverlayWindowRect(true)), |
| 970 kTransitionTime); | 974 kTransitionTime); |
| 971 | 975 |
| 972 // Hide the overlay text 4 seconds from now. | 976 // Hide the overlay text 4 seconds from now. |
| 973 time_to_hide_overlay_ = [NSDate timeIntervalSinceReferenceDate] + 4.0; | 977 time_to_hide_overlay_ = [NSDate timeIntervalSinceReferenceDate] + 4.0; |
| 974 | 978 |
| 975 return true; | 979 return true; |
| 976 } | 980 } |
| 977 | 981 |
| 978 void PluginObject::CancelFullscreenDisplay() { | 982 void PluginObject::CancelFullscreenDisplay() { |
| 979 // if not in fullscreen mode, do nothing | 983 // if not in fullscreen mode, do nothing |
| 980 if (!GetFullscreenMacWindow()) | 984 if (!GetFullscreenMacWindow()) |
| 981 return; | 985 return; |
| 982 | 986 |
| 983 SetWindowForAGLContext(mac_agl_context_, mac_window_); | 987 o3d::SetWindowForAGLContext(mac_agl_context_, mac_window_); |
| 984 | 988 |
| 985 CleanupFullscreenWindow(this); | 989 o3d::CleanupFullscreenWindow(this); |
| 986 | 990 |
| 987 renderer_->Resize(prev_width_, prev_height_); | 991 renderer_->Resize(prev_width_, prev_height_); |
| 988 aglSetInteger(mac_agl_context_, AGL_BUFFER_RECT, last_buffer_rect_); | 992 aglSetInteger(mac_agl_context_, AGL_BUFFER_RECT, last_buffer_rect_); |
| 989 aglEnable(mac_agl_context_, AGL_BUFFER_RECT); | 993 aglEnable(mac_agl_context_, AGL_BUFFER_RECT); |
| 990 | 994 |
| 991 if (mac_fullscreen_state_) { | 995 if (mac_fullscreen_state_) { |
| 992 EndFullScreen(mac_fullscreen_state_, 0); | 996 EndFullScreen(mac_fullscreen_state_, 0); |
| 993 mac_fullscreen_state_ = NULL; | 997 mac_fullscreen_state_ = NULL; |
| 994 } else { | 998 } else { |
| 995 SetSystemUIMode(kUIModeNormal, 0); | 999 SetSystemUIMode(kUIModeNormal, 0); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1006 } else if (mac_window_) { | 1010 } else if (mac_window_) { |
| 1007 SelectWindow(mac_window_); | 1011 SelectWindow(mac_window_); |
| 1008 } | 1012 } |
| 1009 } | 1013 } |
| 1010 | 1014 |
| 1011 void PluginObject::FullscreenIdle() { | 1015 void PluginObject::FullscreenIdle() { |
| 1012 if ((mac_fullscreen_overlay_window_ != NULL) && | 1016 if ((mac_fullscreen_overlay_window_ != NULL) && |
| 1013 (time_to_hide_overlay_ != 0.0) && | 1017 (time_to_hide_overlay_ != 0.0) && |
| 1014 (time_to_hide_overlay_ < [NSDate timeIntervalSinceReferenceDate])) { | 1018 (time_to_hide_overlay_ < [NSDate timeIntervalSinceReferenceDate])) { |
| 1015 time_to_hide_overlay_ = 0.0; | 1019 time_to_hide_overlay_ = 0.0; |
| 1016 SlideWindowToRect(mac_fullscreen_overlay_window_, | 1020 o3d::SlideWindowToRect(mac_fullscreen_overlay_window_, |
| 1017 Rect2CGRect(GetOverlayWindowRect(false)), | 1021 o3d::Rect2CGRect(o3d::GetOverlayWindowRect(false)), |
| 1018 kTransitionTime); | 1022 kTransitionTime); |
| 1019 } | 1023 } |
| 1020 } | 1024 } |
| 1021 | 1025 |
| 1026 } // namespace o3d |
| OLD | NEW |