summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 21:14:20 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 21:14:20 +0000
commitb3dbb00dddff5009456dd5f6f0667603581909aa (patch)
treec3f5b16cb600e04ac2864c66dd059ebaaa870cbe /chrome
parentf3eff890dc9be42d479833d6461a561b7b14bf6d (diff)
downloadchromium_src-b3dbb00dddff5009456dd5f6f0667603581909aa.zip
chromium_src-b3dbb00dddff5009456dd5f6f0667603581909aa.tar.gz
chromium_src-b3dbb00dddff5009456dd5f6f0667603581909aa.tar.bz2
Gets the full screen bubble to work on views/gtk.
BUG=none TEST=none Review URL: http://codereview.chromium.org/264059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29027 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/frame/browser_view.cc14
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc5
-rw-r--r--chrome/browser/views/fullscreen_exit_bubble.cc70
-rw-r--r--chrome/browser/views/fullscreen_exit_bubble.h10
-rwxr-xr-xchrome/chrome.gyp2
5 files changed, 69 insertions, 32 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 87bc366..48f107a 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -836,7 +836,6 @@ bool BrowserView::IsMaximized() const {
}
void BrowserView::SetFullscreen(bool fullscreen) {
-#if defined(OS_WIN)
if (IsFullscreen() == fullscreen)
return; // Nothing to do.
@@ -846,8 +845,10 @@ void BrowserView::SetFullscreen(bool fullscreen) {
// thus are slow and look ugly
ignore_layout_ = true;
LocationBarView* location_bar = toolbar_->location_bar();
+#if defined(OS_WIN)
AutocompleteEditViewWin* edit_view =
static_cast<AutocompleteEditViewWin*>(location_bar->location_entry());
+#endif
if (IsFullscreen()) {
// Hide the fullscreen bubble as soon as possible, since the mode toggle can
// take enough time for the user to notice.
@@ -859,6 +860,7 @@ void BrowserView::SetFullscreen(bool fullscreen) {
if (focus_manager->GetFocusedView() == location_bar)
focus_manager->ClearFocus();
+#if defined(OS_WIN)
// If we don't hide the edit and force it to not show until we come out of
// fullscreen, then if the user was on the New Tab Page, the edit contents
// will appear atop the web contents once we go into fullscreen mode. This
@@ -866,8 +868,11 @@ void BrowserView::SetFullscreen(bool fullscreen) {
// if we don't hide the main window below, we don't get this problem.
edit_view->set_force_hidden(true);
ShowWindow(edit_view->m_hWnd, SW_HIDE);
+#endif
}
+#if defined(OS_WIN)
frame_->GetWindow()->PushForceHidden();
+#endif
// Notify bookmark bar, so it can set itself to the appropriate drawing state.
if (bookmark_bar_view_.get())
@@ -881,22 +886,23 @@ void BrowserView::SetFullscreen(bool fullscreen) {
// Toggle fullscreen mode.
frame_->GetWindow()->SetFullscreen(fullscreen);
- if (IsFullscreen()) {
+ if (fullscreen) {
fullscreen_bubble_.reset(new FullscreenExitBubble(GetWidget(),
browser_.get()));
} else {
+#if defined(OS_WIN)
// Show the edit again since we're no longer in fullscreen mode.
edit_view->set_force_hidden(false);
ShowWindow(edit_view->m_hWnd, SW_SHOW);
+#endif
}
// Undo our anti-jankiness hacks and force the window to relayout now that
// it's in its final position.
ignore_layout_ = false;
Layout();
+#if defined(OS_WIN)
frame_->GetWindow()->PopForceHidden();
-#else
- NOTIMPLEMENTED();
#endif
}
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 5ebeb71..fd01b30 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -750,8 +750,11 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
if (!browser_view_->IsToolbarVisible())
return;
- ThemeProvider* tp = GetThemeProvider();
gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
+ if (toolbar_bounds.IsEmpty())
+ return;
+
+ ThemeProvider* tp = GetThemeProvider();
gfx::Point toolbar_origin(toolbar_bounds.origin());
View::ConvertPointToView(frame_->GetWindow()->GetClientView(),
this, &toolbar_origin);
diff --git a/chrome/browser/views/fullscreen_exit_bubble.cc b/chrome/browser/views/fullscreen_exit_bubble.cc
index b7e5705..5973e23 100644
--- a/chrome/browser/views/fullscreen_exit_bubble.cc
+++ b/chrome/browser/views/fullscreen_exit_bubble.cc
@@ -6,21 +6,27 @@
#include "app/gfx/canvas.h"
#include "app/l10n_util.h"
-#include "app/l10n_util_win.h"
#include "app/resource_bundle.h"
#include "base/keyboard_codes.h"
#include "chrome/app/chrome_dll_resource.h"
#include "grit/generated_resources.h"
+#include "views/screen.h"
#include "views/widget/root_view.h"
+#include "views/window/window.h"
+
+#if defined(OS_WIN)
+#include "app/l10n_util_win.h"
#include "views/widget/widget_win.h"
+#elif defined(OS_LINUX)
+#include "views/widget/widget_gtk.h"
+#endif
// FullscreenExitView ----------------------------------------------------------
class FullscreenExitBubble::FullscreenExitView : public views::View {
public:
- FullscreenExitView(FullscreenExitBubble* bubble,
- views::WidgetWin* popup,
- const std::wstring& accelerator);
+ FullscreenExitView(FullscreenExitBubble* bubble,
+ const std::wstring& accelerator);
virtual ~FullscreenExitView();
// views::View
@@ -33,9 +39,6 @@ class FullscreenExitBubble::FullscreenExitView : public views::View {
virtual void Layout();
virtual void Paint(gfx::Canvas* canvas);
- // Handle to the HWND that contains us.
- views::WidgetWin* popup_;
-
// Clickable hint text to show in the bubble.
views::Link link_;
};
@@ -44,9 +47,7 @@ const int FullscreenExitBubble::FullscreenExitView::kPaddingPixels = 8;
FullscreenExitBubble::FullscreenExitView::FullscreenExitView(
FullscreenExitBubble* bubble,
- views::WidgetWin* popup,
- const std::wstring& accelerator)
- : popup_(popup) {
+ const std::wstring& accelerator) {
link_.SetParentOwned(false);
link_.SetText(l10n_util::GetStringF(IDS_EXIT_FULLSCREEN_MODE, accelerator));
link_.SetController(bubble);
@@ -97,10 +98,11 @@ void FullscreenExitBubble::FullscreenExitView::Paint(gfx::Canvas* canvas) {
// FullscreenExitPopup ---------------------------------------------------------
+#if defined(OS_WIN)
class FullscreenExitBubble::FullscreenExitPopup : public views::WidgetWin {
public:
- FullscreenExitPopup() : views::WidgetWin() { }
- virtual ~FullscreenExitPopup() { }
+ FullscreenExitPopup() : views::WidgetWin() {}
+ virtual ~FullscreenExitPopup() {}
// views::WidgetWin:
virtual LRESULT OnMouseActivate(HWND window,
@@ -112,7 +114,9 @@ class FullscreenExitBubble::FullscreenExitPopup : public views::WidgetWin {
return MA_NOACTIVATE;
}
};
-
+#elif defined(OS_LINUX)
+// TODO: figure out the equivalent of MA_NOACTIVATE for gtk.
+#endif
// FullscreenExitBubble --------------------------------------------------------
@@ -129,7 +133,7 @@ FullscreenExitBubble::FullscreenExitBubble(
CommandUpdater::CommandUpdaterDelegate* delegate)
: root_view_(frame->GetRootView()),
delegate_(delegate),
- popup_(new FullscreenExitPopup()),
+ popup_(NULL),
size_animation_(new SlideAnimation(this)) {
size_animation_->Reset(1);
@@ -137,23 +141,28 @@ FullscreenExitBubble::FullscreenExitBubble(
views::Accelerator accelerator(base::VKEY_UNKNOWN, false, false, false);
bool got_accelerator = frame->GetAccelerator(IDC_FULLSCREEN, &accelerator);
DCHECK(got_accelerator);
- view_ = new FullscreenExitView(this, popup_, accelerator.GetShortcutText());
+ view_ = new FullscreenExitView(this, accelerator.GetShortcutText());
// Initialize the popup.
- popup_->set_delete_on_destroy(false);
+#if defined(OS_WIN)
+ popup_ = new FullscreenExitPopup();
popup_->set_window_style(WS_POPUP);
popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
l10n_util::GetExtendedTooltipStyles());
+#elif defined(OS_LINUX)
+ popup_ = new views::WidgetGtk(views::WidgetGtk::TYPE_POPUP);
+ popup_->MakeTransparent();
+#endif
popup_->SetOpacity(static_cast<unsigned char>(0xff * kOpacity));
popup_->Init(frame->GetNativeView(), GetPopupRect(false));
+ popup_->set_delete_on_destroy(false);
popup_->SetContentsView(view_);
popup_->Show(); // This does not activate the popup.
// Start the initial delay timer and begin watching the mouse.
initial_delay_.Start(base::TimeDelta::FromMilliseconds(kInitialDelayMs), this,
&FullscreenExitBubble::CheckMousePosition);
- POINT cursor_pos;
- GetCursorPos(&cursor_pos);
+ gfx::Point cursor_pos = views::Screen::GetCursorScreenPoint();
last_mouse_pos_ = cursor_pos;
views::View::ConvertPointToView(NULL, root_view_, &last_mouse_pos_);
mouse_position_checker_.Start(
@@ -185,8 +194,12 @@ void FullscreenExitBubble::AnimationProgressed(
if (popup_rect.IsEmpty()) {
popup_->Hide();
} else {
+#if defined(OS_WIN)
popup_->MoveWindow(popup_rect.x(), popup_rect.y(), popup_rect.width(),
popup_rect.height());
+#elif defined(OS_LINUX)
+ popup_->SetBounds(popup_rect);
+#endif
popup_->Show();
}
}
@@ -216,8 +229,7 @@ void FullscreenExitBubble::CheckMousePosition() {
// either the popup is hidden or the mouse is not idle, so we don't want to
// change anything's state.
- POINT cursor_pos;
- GetCursorPos(&cursor_pos);
+ gfx::Point cursor_pos = views::Screen::GetCursorScreenPoint();
gfx::Point transformed_pos(cursor_pos);
views::View::ConvertPointToView(NULL, root_view_, &transformed_pos);
@@ -230,13 +242,13 @@ void FullscreenExitBubble::CheckMousePosition() {
}
last_mouse_pos_ = transformed_pos;
- if ((GetActiveWindow() != root_view_->GetWidget()->GetNativeView()) ||
+ if ((!root_view_->GetWidget()->IsActive()) ||
!root_view_->HitTest(transformed_pos) ||
- (cursor_pos.y >= GetPopupRect(true).bottom()) ||
+ (cursor_pos.y() >= GetPopupRect(true).bottom()) ||
!idle_timeout_.IsRunning()) {
// The cursor is offscreen, in the slide-out region, or idle.
Hide();
- } else if ((cursor_pos.y < kSlideInRegionHeightPx) ||
+ } else if ((cursor_pos.y() < kSlideInRegionHeightPx) ||
(size_animation_->GetCurrentValue() != 0)) {
// The cursor is not idle, and either it's in the slide-in region or it's in
// the neutral region and we're sliding out.
@@ -248,8 +260,7 @@ void FullscreenExitBubble::CheckMousePosition() {
void FullscreenExitBubble::Hide() {
// Allow the bubble to hide if the window is deactivated or our initial delay
// finishes.
- if ((GetActiveWindow() != root_view_->GetWidget()->GetNativeView()) ||
- !initial_delay_.IsRunning()) {
+ if ((!root_view_->GetWidget()->IsActive()) || !initial_delay_.IsRunning()) {
size_animation_->SetSlideDuration(kSlideOutDurationMs);
size_animation_->Hide();
}
@@ -262,7 +273,12 @@ gfx::Rect FullscreenExitBubble::GetPopupRect(
size.set_height(static_cast<int>(static_cast<double>(size.height()) *
size_animation_->GetCurrentValue()));
}
- gfx::Point origin((root_view_->width() - size.width()) / 2, 0);
- views::View::ConvertPointToScreen(root_view_, &origin);
+ // NOTE: don't use the bounds of the root_view_. On linux changing window
+ // size is async. Instead we use the size of the screen.
+ gfx::Rect screen_bounds = views::Screen::GetMonitorAreaNearestWindow(
+ root_view_->GetWidget()->GetNativeView());
+ gfx::Point origin(screen_bounds.x() +
+ (screen_bounds.width() - size.width()) / 2,
+ screen_bounds.y());
return gfx::Rect(origin, size);
}
diff --git a/chrome/browser/views/fullscreen_exit_bubble.h b/chrome/browser/views/fullscreen_exit_bubble.h
index fc1af3b..3767518 100644
--- a/chrome/browser/views/fullscreen_exit_bubble.h
+++ b/chrome/browser/views/fullscreen_exit_bubble.h
@@ -10,6 +10,12 @@
#include "chrome/browser/command_updater.h"
#include "views/controls/link.h"
+#if defined(OS_LINUX)
+namespace views {
+class WidgetGtk;
+}
+#endif
+
// FullscreenExitBubble is responsible for showing a bubble atop the screen in
// fullscreen mode, telling users how to exit and providing a click target.
// The bubble auto-hides, and re-shows when the user moves to the screen top.
@@ -62,9 +68,13 @@ class FullscreenExitBubble : public views::LinkController,
// it.
CommandUpdater::CommandUpdaterDelegate* delegate_;
+#if defined(OS_WIN)
// The popup itself, which is a slightly modified WidgetWin. We need to use
// a WidgetWin (and thus an HWND) to make the popup float over other HWNDs.
FullscreenExitPopup* popup_;
+#elif defined(OS_LINUX)
+ views::WidgetGtk* popup_;
+#endif
// The contents of the popup.
FullscreenExitView* view_;
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 5b0c2bb..662ba507 100755
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -2674,6 +2674,8 @@
['include', '^browser/views/find_bar_host_gtk.cc'],
['include', '^browser/views/find_bar_host.cc'],
['include', '^browser/views/find_bar_host.h'],
+ ['include', '^browser/views/fullscreen_exit_bubble.cc'],
+ ['include', '^browser/views/fullscreen_exit_bubble.h'],
['include', '^browser/views/go_button.cc'],
['include', '^browser/views/go_button.h'],
['include', '^browser/views/toolbar_star_toggle.h'],