diff options
Diffstat (limited to 'views/widget')
-rw-r--r-- | views/widget/root_view.cc | 4 | ||||
-rw-r--r-- | views/widget/tooltip_manager_gtk.cc | 4 | ||||
-rw-r--r-- | views/widget/widget.cc | 11 | ||||
-rw-r--r-- | views/widget/widget.h | 1 |
4 files changed, 12 insertions, 8 deletions
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index 712bc52a..878e236 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -320,8 +320,8 @@ void RootView::OnMouseExited(const MouseEvent& event) { bool RootView::OnMouseWheel(const MouseWheelEvent& event) { MouseWheelEvent e(event, this); bool consumed = false; - View* v = GetFocusManager()->GetFocusedView(); - for (; v && v != this && !consumed; v = v->parent()) + for (View* v = GetFocusManager()->GetFocusedView(); + v && v != this && !consumed; v = v->parent()) consumed = v->OnMouseWheel(e); return consumed; } diff --git a/views/widget/tooltip_manager_gtk.cc b/views/widget/tooltip_manager_gtk.cc index 8515fa9..f9993196 100644 --- a/views/widget/tooltip_manager_gtk.cc +++ b/views/widget/tooltip_manager_gtk.cc @@ -71,7 +71,7 @@ TooltipManagerGtk::TooltipManagerGtk(NativeWidgetGtk* widget) bool TooltipManagerGtk::ShowTooltip(int x, int y, bool for_keyboard, GtkTooltip* tooltip) { - View* view = NULL; + const View* view = NULL; gfx::Point view_loc; if (keyboard_view_) { view = keyboard_view_; @@ -82,7 +82,7 @@ bool TooltipManagerGtk::ShowTooltip(int x, int y, bool for_keyboard, view_loc.SetPoint(x, y); View::ConvertPointFromWidget(view, &view_loc); } else { - FocusManager* focus_manager = widget_->GetWidget()->GetFocusManager(); + const FocusManager* focus_manager = widget_->GetWidget()->GetFocusManager(); if (focus_manager) { view = focus_manager->GetFocusedView(); if (view) diff --git a/views/widget/widget.cc b/views/widget/widget.cc index 891bafd..6670fe84 100644 --- a/views/widget/widget.cc +++ b/views/widget/widget.cc @@ -388,7 +388,7 @@ void Widget::NotifyNativeViewHierarchyChanged(bool attached, Widget* Widget::GetTopLevelWidget() { return const_cast<Widget*>( - const_cast<const Widget*>(this)->GetTopLevelWidget()); + static_cast<const Widget*>(this)->GetTopLevelWidget()); } const Widget* Widget::GetTopLevelWidget() const { @@ -396,9 +396,7 @@ const Widget* Widget::GetTopLevelWidget() const { // property is gone after gobject gets deleted. Short circuit here // for toplevel so that InputMethod can remove itself from // focus manager. - if (is_top_level()) - return this; - return native_widget_->GetTopLevelWidget(); + return is_top_level() ? this : native_widget_->GetTopLevelWidget(); } void Widget::SetContentsView(View* view) { @@ -618,6 +616,11 @@ ThemeProvider* Widget::GetThemeProvider() const { } FocusManager* Widget::GetFocusManager() { + Widget* toplevel_widget = GetTopLevelWidget(); + return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; +} + +const FocusManager* Widget::GetFocusManager() const { const Widget* toplevel_widget = GetTopLevelWidget(); return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; } diff --git a/views/widget/widget.h b/views/widget/widget.h index d4b4f37..ba0445b 100644 --- a/views/widget/widget.h +++ b/views/widget/widget.h @@ -402,6 +402,7 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // Note that all widgets in a widget hierarchy share the same focus manager. // TODO(beng): remove virtual. virtual FocusManager* GetFocusManager(); + virtual const FocusManager* GetFocusManager() const; // Returns the InputMethod for this widget. // Note that all widgets in a widget hierarchy share the same input method. |