Commit a5238b91 authored by prasadt@chromium.org's avatar prasadt@chromium.org

Make panels not show on top when there is an app running in full screen mode.

BUG=102731
TEST=Manual steps in the bug report.

Review URL: http://codereview.chromium.org/8686012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112755 0039d316-1c4b-4281-b951-d872f2087c98
parent c761a5fd
...@@ -59,6 +59,7 @@ class NativePanel { ...@@ -59,6 +59,7 @@ class NativePanel {
const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) = 0; const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) = 0;
virtual void HandlePanelKeyboardEvent( virtual void HandlePanelKeyboardEvent(
const NativeWebKeyboardEvent& event) = 0; const NativeWebKeyboardEvent& event) = 0;
virtual void FullScreenModeChanged(bool is_full_screen) = 0;
virtual Browser* GetPanelBrowser() const = 0; virtual Browser* GetPanelBrowser() const = 0;
virtual void DestroyPanelBrowser() = 0; virtual void DestroyPanelBrowser() = 0;
......
...@@ -189,6 +189,10 @@ bool Panel::IsDrawingAttention() const { ...@@ -189,6 +189,10 @@ bool Panel::IsDrawingAttention() const {
return native_panel_->IsDrawingAttention(); return native_panel_->IsDrawingAttention();
} }
void Panel::FullScreenModeChanged(bool is_full_screen) {
native_panel_->FullScreenModeChanged(is_full_screen);
}
void Panel::Show() { void Panel::Show() {
native_panel_->ShowPanel(); native_panel_->ShowPanel();
} }
......
...@@ -63,6 +63,13 @@ class Panel : public BrowserWindow, ...@@ -63,6 +63,13 @@ class Panel : public BrowserWindow,
bool IsDrawingAttention() const; bool IsDrawingAttention() const;
// This function will only get called by PanelManager when full screen mode
// changes i.e it gets called when an app goes into full screen mode or when
// an app exits full screen mode. Panel should respond by making sure
// a) it does not go on top when some app enters full screen mode.
// b) it remains on top when an app exits full screen mode.
void FullScreenModeChanged(bool is_full_screen);
// BrowserWindow overrides. // BrowserWindow overrides.
virtual void Show() OVERRIDE; virtual void Show() OVERRIDE;
virtual void ShowInactive() OVERRIDE; virtual void ShowInactive() OVERRIDE;
......
...@@ -58,6 +58,11 @@ PanelBrowserView::~PanelBrowserView() { ...@@ -58,6 +58,11 @@ PanelBrowserView::~PanelBrowserView() {
} }
void PanelBrowserView::Init() { void PanelBrowserView::Init() {
if (!panel_->manager()->is_full_screen()) {
// TODO(prasadt): Implement this code.
// HideThePanel.
}
BrowserView::Init(); BrowserView::Init();
GetWidget()->non_client_view()->SetAccessibleName( GetWidget()->non_client_view()->SetAccessibleName(
...@@ -353,6 +358,14 @@ bool PanelBrowserView::PreHandlePanelKeyboardEvent( ...@@ -353,6 +358,14 @@ bool PanelBrowserView::PreHandlePanelKeyboardEvent(
return PreHandleKeyboardEvent(event, is_keyboard_shortcut); return PreHandleKeyboardEvent(event, is_keyboard_shortcut);
} }
void PanelBrowserView::FullScreenModeChanged(bool is_full_screen) {
// TODO(prasadt): Enable this code.
// if (is_full_screen)
// HideThePanel.
// else
// ShowThePanel.
}
void PanelBrowserView::HandlePanelKeyboardEvent( void PanelBrowserView::HandlePanelKeyboardEvent(
const NativeWebKeyboardEvent& event) { const NativeWebKeyboardEvent& event) {
HandleKeyboardEvent(event); HandleKeyboardEvent(event);
......
...@@ -99,6 +99,7 @@ class PanelBrowserView : public BrowserView, ...@@ -99,6 +99,7 @@ class PanelBrowserView : public BrowserView,
virtual bool PreHandlePanelKeyboardEvent( virtual bool PreHandlePanelKeyboardEvent(
const NativeWebKeyboardEvent& event, const NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) OVERRIDE; bool* is_keyboard_shortcut) OVERRIDE;
virtual void FullScreenModeChanged(bool is_full_screen) OVERRIDE;
virtual void HandlePanelKeyboardEvent( virtual void HandlePanelKeyboardEvent(
const NativeWebKeyboardEvent& event) OVERRIDE; const NativeWebKeyboardEvent& event) OVERRIDE;
virtual gfx::Size WindowSizeFromContentSize( virtual gfx::Size WindowSizeFromContentSize(
......
...@@ -54,6 +54,7 @@ class PanelBrowserWindowCocoa : public NativePanel, ...@@ -54,6 +54,7 @@ class PanelBrowserWindowCocoa : public NativePanel,
bool* is_keyboard_shortcut) OVERRIDE; bool* is_keyboard_shortcut) OVERRIDE;
virtual void HandlePanelKeyboardEvent( virtual void HandlePanelKeyboardEvent(
const NativeWebKeyboardEvent& event) OVERRIDE; const NativeWebKeyboardEvent& event) OVERRIDE;
virtual void FullScreenModeChanged(bool is_full_screen) OVERRIDE;
virtual Browser* GetPanelBrowser() const OVERRIDE; virtual Browser* GetPanelBrowser() const OVERRIDE;
virtual void DestroyPanelBrowser() OVERRIDE; virtual void DestroyPanelBrowser() OVERRIDE;
virtual gfx::Size IconOnlySize() const OVERRIDE; virtual gfx::Size IconOnlySize() const OVERRIDE;
......
...@@ -247,6 +247,11 @@ void PanelBrowserWindowCocoa::HandlePanelKeyboardEvent( ...@@ -247,6 +247,11 @@ void PanelBrowserWindowCocoa::HandlePanelKeyboardEvent(
} }
} }
void PanelBrowserWindowCocoa::FullScreenModeChanged(
bool is_full_screen) {
[controller_ fullScreenModeChanged:is_full_screen];
}
Browser* PanelBrowserWindowCocoa::GetPanelBrowser() const { Browser* PanelBrowserWindowCocoa::GetPanelBrowser() const {
return browser(); return browser();
} }
......
...@@ -366,6 +366,11 @@ bool PanelBrowserWindowGtk::PreHandlePanelKeyboardEvent( ...@@ -366,6 +366,11 @@ bool PanelBrowserWindowGtk::PreHandlePanelKeyboardEvent(
return PreHandleKeyboardEvent(event, is_keyboard_shortcut); return PreHandleKeyboardEvent(event, is_keyboard_shortcut);
} }
void PanelBrowserWindowGtk::FullScreenModeChanged(bool is_full_screen) {
// Nothing to do here as z-order rules for panels ensures that they're below
// any app running in full screen mode.
}
void PanelBrowserWindowGtk::HandlePanelKeyboardEvent( void PanelBrowserWindowGtk::HandlePanelKeyboardEvent(
const NativeWebKeyboardEvent& event) { const NativeWebKeyboardEvent& event) {
HandleKeyboardEvent(event); HandleKeyboardEvent(event);
......
...@@ -92,6 +92,7 @@ class PanelBrowserWindowGtk : public BrowserWindowGtk, ...@@ -92,6 +92,7 @@ class PanelBrowserWindowGtk : public BrowserWindowGtk,
bool* is_keyboard_shortcut) OVERRIDE; bool* is_keyboard_shortcut) OVERRIDE;
virtual void HandlePanelKeyboardEvent( virtual void HandlePanelKeyboardEvent(
const NativeWebKeyboardEvent& event) OVERRIDE; const NativeWebKeyboardEvent& event) OVERRIDE;
virtual void FullScreenModeChanged(bool is_full_screen) OVERRIDE;
virtual Browser* GetPanelBrowser() const OVERRIDE; virtual Browser* GetPanelBrowser() const OVERRIDE;
virtual void DestroyPanelBrowser() OVERRIDE; virtual void DestroyPanelBrowser() OVERRIDE;
virtual gfx::Size WindowSizeFromContentSize( virtual gfx::Size WindowSizeFromContentSize(
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chrome/browser/fullscreen.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/panels/panel_mouse_watcher.h" #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
...@@ -25,6 +26,8 @@ const int kPanelStripRightMargin = 24; ...@@ -25,6 +26,8 @@ const int kPanelStripRightMargin = 24;
// Height of panel strip is based on the factor of the working area. // Height of panel strip is based on the factor of the working area.
const double kPanelStripHeightFactor = 0.5; const double kPanelStripHeightFactor = 0.5;
static const int kFullScreenModeCheckIntervalMs = 1000;
} // namespace } // namespace
// static // static
...@@ -35,7 +38,8 @@ PanelManager* PanelManager::GetInstance() { ...@@ -35,7 +38,8 @@ PanelManager* PanelManager::GetInstance() {
PanelManager::PanelManager() PanelManager::PanelManager()
: panel_mouse_watcher_(PanelMouseWatcher::Create()), : panel_mouse_watcher_(PanelMouseWatcher::Create()),
auto_sizing_enabled_(true) { auto_sizing_enabled_(true),
is_full_screen_(false) {
panel_strip_.reset(new PanelStrip(this)); panel_strip_.reset(new PanelStrip(this));
auto_hiding_desktop_bar_ = AutoHidingDesktopBar::Create(this); auto_hiding_desktop_bar_ = AutoHidingDesktopBar::Create(this);
OnDisplayChanged(); OnDisplayChanged();
...@@ -90,6 +94,12 @@ Panel* PanelManager::CreatePanel(Browser* browser) { ...@@ -90,6 +94,12 @@ Panel* PanelManager::CreatePanel(Browser* browser) {
content::Source<Panel>(panel), content::Source<Panel>(panel),
content::NotificationService::NoDetails()); content::NotificationService::NoDetails());
if (num_panels() == 1) {
full_screen_mode_timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kFullScreenModeCheckIntervalMs),
this, &PanelManager::CheckFullScreenMode);
}
return panel; return panel;
} }
...@@ -97,7 +107,18 @@ int PanelManager::StartingRightPosition() const { ...@@ -97,7 +107,18 @@ int PanelManager::StartingRightPosition() const {
return panel_strip_->StartingRightPosition(); return panel_strip_->StartingRightPosition();
} }
void PanelManager::CheckFullScreenMode() {
bool is_full_screen_new = IsFullScreenMode();
if (is_full_screen_ == is_full_screen_new)
return;
is_full_screen_ = is_full_screen_new;
panel_strip_->OnFullScreenModeChanged(is_full_screen_);
}
void PanelManager::Remove(Panel* panel) { void PanelManager::Remove(Panel* panel) {
if (num_panels() == 1)
full_screen_mode_timer_.Stop();
if (panel_strip_->Remove(panel)) if (panel_strip_->Remove(panel))
return; return;
// TODO(jianli): else try removing from overflow strip // TODO(jianli): else try removing from overflow strip
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/timer.h"
#include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h"
#include "chrome/browser/ui/panels/panel.h" #include "chrome/browser/ui/panels/panel.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
...@@ -100,6 +101,8 @@ class PanelManager : public AutoHidingDesktopBar::Observer { ...@@ -100,6 +101,8 @@ class PanelManager : public AutoHidingDesktopBar::Observer {
return panel_strip_.get(); return panel_strip_.get();
} }
bool is_full_screen() const { return is_full_screen_; }
#ifdef UNIT_TEST #ifdef UNIT_TEST
static int horizontal_spacing() { return PanelStrip::horizontal_spacing(); } static int horizontal_spacing() { return PanelStrip::horizontal_spacing(); }
...@@ -155,6 +158,9 @@ class PanelManager : public AutoHidingDesktopBar::Observer { ...@@ -155,6 +158,9 @@ class PanelManager : public AutoHidingDesktopBar::Observer {
// Positions the various groupings of panels. // Positions the various groupings of panels.
void Layout(); void Layout();
// Tests if the current active app is in full screen mode.
void CheckFullScreenMode();
scoped_ptr<PanelStrip> panel_strip_; scoped_ptr<PanelStrip> panel_strip_;
// Use a mouse watcher to know when to bring up titlebars to "peek" at // Use a mouse watcher to know when to bring up titlebars to "peek" at
...@@ -179,6 +185,12 @@ class PanelManager : public AutoHidingDesktopBar::Observer { ...@@ -179,6 +185,12 @@ class PanelManager : public AutoHidingDesktopBar::Observer {
// will not be affected. // will not be affected.
bool auto_sizing_enabled_; bool auto_sizing_enabled_;
// Timer used to track if the current active app is in full screen mode.
base::RepeatingTimer<PanelManager> full_screen_mode_timer_;
// True if current active app is in full screen mode.
bool is_full_screen_;
DISALLOW_COPY_AND_ASSIGN(PanelManager); DISALLOW_COPY_AND_ASSIGN(PanelManager);
}; };
......
...@@ -559,6 +559,11 @@ void PanelStrip::OnAutoHidingDesktopBarVisibilityChanged( ...@@ -559,6 +559,11 @@ void PanelStrip::OnAutoHidingDesktopBarVisibilityChanged(
delayed_titlebar_action_ = NO_ACTION; delayed_titlebar_action_ = NO_ACTION;
} }
void PanelStrip::OnFullScreenModeChanged(bool is_full_screen) {
for (size_t i = 0; i < panels_.size(); ++i)
panels_[i]->FullScreenModeChanged(is_full_screen);
}
void PanelStrip::Rearrange() { void PanelStrip::Rearrange() {
int rightmost_position = StartingRightPosition(); int rightmost_position = StartingRightPosition();
......
...@@ -82,6 +82,8 @@ class PanelStrip : public PanelMouseWatcherObserver { ...@@ -82,6 +82,8 @@ class PanelStrip : public PanelMouseWatcherObserver {
AutoHidingDesktopBar::Alignment alignment, AutoHidingDesktopBar::Alignment alignment,
AutoHidingDesktopBar::Visibility visibility); AutoHidingDesktopBar::Visibility visibility);
void OnFullScreenModeChanged(bool is_full_screen);
#ifdef UNIT_TEST #ifdef UNIT_TEST
static int horizontal_spacing() { return kPanelsHorizontalSpacing; } static int horizontal_spacing() { return kPanelsHorizontalSpacing; }
......
...@@ -129,6 +129,9 @@ class PanelBrowserWindowCocoa; ...@@ -129,6 +129,9 @@ class PanelBrowserWindowCocoa;
// Removes the Key status from the panel to some other window. // Removes the Key status from the panel to some other window.
- (void)deactivate; - (void)deactivate;
// See Panel::FullScreenModeChanged.
- (void)fullScreenModeChanged:(bool)isFullScreen;
// Helper for NSWindow, returns NO for minimized panels in some cases, so they // Helper for NSWindow, returns NO for minimized panels in some cases, so they
// are not un-minimized when another panel is minimized. // are not un-minimized when another panel is minimized.
- (BOOL)canBecomeKeyWindow; - (BOOL)canBecomeKeyWindow;
......
...@@ -112,7 +112,8 @@ enum { ...@@ -112,7 +112,8 @@ enum {
DCHECK(titlebar_view_); DCHECK(titlebar_view_);
DCHECK_EQ(self, [window delegate]); DCHECK_EQ(self, [window delegate]);
[window setLevel:NSStatusWindowLevel]; if (!windowShim_->panel()->manager()->is_full_screen())
[window setLevel:NSStatusWindowLevel];
if (base::mac::IsOSSnowLeopardOrLater()) { if (base::mac::IsOSSnowLeopardOrLater()) {
[window setCollectionBehavior: [window setCollectionBehavior:
...@@ -610,6 +611,11 @@ enum { ...@@ -610,6 +611,11 @@ enum {
[NSApp deactivate]; [NSApp deactivate];
} }
- (void)fullScreenModeChanged:(bool)isFullScreen {
NSWindow* window = [self window];
[window setLevel:(isFullScreen ? NSNormalWindowLevel : NSStatusWindowLevel)];
}
- (BOOL)canBecomeKeyWindow { - (BOOL)canBecomeKeyWindow {
// Panel can only gain focus if it is expanded. Minimized panels do not // Panel can only gain focus if it is expanded. Minimized panels do not
// participate in Cmd-~ rotation. // participate in Cmd-~ rotation.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment