Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(815)

Unified Diff: ui/views/corewm/tooltip_aura.cc

Issue 290573003: Make tooltips toplevel windows on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/corewm/tooltip_aura.h ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/corewm/tooltip_aura.cc
diff --git a/ui/views/corewm/tooltip_aura.cc b/ui/views/corewm/tooltip_aura.cc
index 777603cbeac70def1ed7e14d968cbbe9c6ef74a6..caa7aed3b9f0614d9b9caae99fd59c20668d3abb 100644
--- a/ui/views/corewm/tooltip_aura.cc
+++ b/ui/views/corewm/tooltip_aura.cc
@@ -147,25 +147,9 @@ void TooltipAura::TrimTooltipToFit(const gfx::FontList& font_list,
int TooltipAura::GetMaxWidth(const gfx::Point& location) const {
// TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure
// out a way to merge.
- gfx::Rect display_bounds = GetBoundsForTooltip(location);
- return (display_bounds.width() + 1) / 2;
-}
-
-gfx::Rect TooltipAura::GetBoundsForTooltip(
- const gfx::Point& origin) const {
- DCHECK(tooltip_window_);
- gfx::Rect widget_bounds;
- // For Desktop aura we constrain the tooltip to the bounds of the Widget
- // (which comes from the RootWindow).
- if (screen_type_ == gfx::SCREEN_TYPE_NATIVE &&
- gfx::SCREEN_TYPE_NATIVE != gfx::SCREEN_TYPE_ALTERNATE) {
- widget_bounds = tooltip_window_->GetHost()->GetBounds();
- }
gfx::Screen* screen = gfx::Screen::GetScreenByType(screen_type_);
- gfx::Rect bounds(screen->GetDisplayNearestPoint(origin).bounds());
- if (!widget_bounds.IsEmpty())
- bounds.Intersect(widget_bounds);
- return bounds;
+ gfx::Rect display_bounds(screen->GetDisplayNearestPoint(location).bounds());
+ return (display_bounds.width() + 1) / 2;
}
void TooltipAura::SetTooltipBounds(const gfx::Point& mouse_pos,
@@ -175,7 +159,8 @@ void TooltipAura::SetTooltipBounds(const gfx::Point& mouse_pos,
tooltip_height);
tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY);
- gfx::Rect display_bounds = GetBoundsForTooltip(mouse_pos);
+ gfx::Screen* screen = gfx::Screen::GetScreenByType(screen_type_);
+ gfx::Rect display_bounds(screen->GetDisplayNearestPoint(mouse_pos).bounds());
// If tooltip is out of bounds on the x axis, we simply shift it
// horizontally by the offset.
@@ -193,22 +178,6 @@ void TooltipAura::SetTooltipBounds(const gfx::Point& mouse_pos,
widget_->SetBounds(tooltip_rect);
}
-void TooltipAura::CreateWidget() {
- if (widget_) {
- // If the window for which the tooltip is being displayed changes and if the
- // tooltip window and the tooltip widget belong to different rootwindows
- // then we need to recreate the tooltip widget under the active root window
- // hierarchy to get it to display.
- if (widget_->GetNativeWindow()->GetRootWindow() ==
- tooltip_window_->GetRootWindow())
- return;
- DestroyWidget();
- }
- widget_ = CreateTooltipWidget(tooltip_window_);
- widget_->SetContentsView(&label_);
- widget_->AddObserver(this);
-}
-
void TooltipAura::DestroyWidget() {
if (widget_) {
widget_->RemoveObserver(this);
@@ -230,18 +199,31 @@ void TooltipAura::SetText(aura::Window* window,
int width = max_width + 2 * kTooltipHorizontalPadding;
int height = label_.GetHeightForWidth(max_width) +
2 * kTooltipVerticalPadding;
- CreateWidget();
+
+ if (!widget_) {
+ widget_ = CreateTooltipWidget(tooltip_window_);
+ widget_->SetContentsView(&label_);
+ widget_->AddObserver(this);
+ }
+
SetTooltipBounds(location, width, height);
+ ui::NativeTheme* native_theme = widget_->GetNativeTheme();
label_.set_background(
views::Background::CreateSolidBackground(
- widget_->GetNativeTheme()->GetSystemColor(
+ native_theme->GetSystemColor(
ui::NativeTheme::kColorId_TooltipBackground)));
+
+ label_.SetAutoColorReadabilityEnabled(false);
+ label_.SetEnabledColor(native_theme->GetSystemColor(
+ ui::NativeTheme::kColorId_TooltipText));
}
void TooltipAura::Show() {
- if (widget_)
+ if (widget_) {
widget_->Show();
+ widget_->StackAtTop();
+ }
}
void TooltipAura::Hide() {
« no previous file with comments | « ui/views/corewm/tooltip_aura.h ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698