diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/mac_util.h | 12 | ||||
-rw-r--r-- | base/mac_util.mm | 22 |
2 files changed, 34 insertions, 0 deletions
diff --git a/base/mac_util.h b/base/mac_util.h index 0baab02..fc886e54 100644 --- a/base/mac_util.h +++ b/base/mac_util.h @@ -60,6 +60,18 @@ CGColorSpaceRef GetSRGBColorSpace(); // is a static value; do not release it! CGColorSpaceRef GetSystemColorSpace(); +// Add a request for full screen mode. This does not by itself create a +// fullscreen window; rather, it manages per-application state related to +// fullscreen windows. For example, if the menu bar is not currently +// hidden, this will hide it. Must be called on main thread. +void RequestFullScreen(); + +// Release a request for full screen mode. As with RequestFullScree(), this +// does not affect windows directly, but rather manages per-application state. +// For example, if there are no other outstanding requests for full screen, +// this will show the menu bar. Must be called on main thread. +void ReleaseFullScreen(); + } // namespace mac_util #endif // BASE_MAC_UTIL_H_ diff --git a/base/mac_util.mm b/base/mac_util.mm index 014342c..f31ca42 100644 --- a/base/mac_util.mm +++ b/base/mac_util.mm @@ -8,6 +8,7 @@ #include "base/file_path.h" #include "base/logging.h" +#include "base/message_loop.h" #include "base/scoped_cftyperef.h" #include "base/sys_string_conversions.h" @@ -138,4 +139,25 @@ CGColorSpaceRef GetSystemColorSpace() { return g_system_color_space; } +// a count of currently outstanding requests for full screen mode from browser +// windows, plugins, etc. +static int g_full_screen_requests = 0; + +// Add a request for full screen mode. If the menu bar is not currently +// hidden, hide it. Must be called on main thread. +void RequestFullScreen() { + if (!g_full_screen_requests) + SetSystemUIMode(kUIModeAllSuppressed, kUIOptionAutoShowMenuBar); + ++g_full_screen_requests; +} + +// Release a request for full screen mode. If there are no other outstanding +// requests, show the menu bar. Must be called on main thread. +void ReleaseFullScreen() { + DCHECK(g_full_screen_requests > 0); + --g_full_screen_requests; + if (g_full_screen_requests == 0) + SetSystemUIMode(kUIModeNormal, 0); +} + } // namespace mac_util |