diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-02 13:54:29 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-02 13:54:29 +0000 |
commit | e6269fd0e957510a2536a77e5a2fcabf799ccd20 (patch) | |
tree | e2185f9d89325d873fe3bd99ed27baf6224ed578 /views | |
parent | 1505fa2d80afe698db06150512b26c2d08d0e088 (diff) | |
download | chromium_src-e6269fd0e957510a2536a77e5a2fcabf799ccd20.zip chromium_src-e6269fd0e957510a2536a77e5a2fcabf799ccd20.tar.gz chromium_src-e6269fd0e957510a2536a77e5a2fcabf799ccd20.tar.bz2 |
views: implement a TODO to move WidgetGtk::GetWindowForNative to WindowGtk.
BUG=NONE
TEST=compiles.
Review URL: http://codereview.chromium.org/1640003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48717 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/focus/accelerator_handler_gtk.cc | 5 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 12 | ||||
-rw-r--r-- | views/widget/widget_gtk.h | 9 | ||||
-rw-r--r-- | views/window/window_gtk.cc | 15 | ||||
-rw-r--r-- | views/window/window_gtk.h | 8 |
5 files changed, 24 insertions, 25 deletions
diff --git a/views/focus/accelerator_handler_gtk.cc b/views/focus/accelerator_handler_gtk.cc index f7fff91..1218340 100644 --- a/views/focus/accelerator_handler_gtk.cc +++ b/views/focus/accelerator_handler_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,6 @@ #include "views/accelerator.h" #include "views/focus/accelerator_handler.h" #include "views/focus/focus_manager.h" -#include "views/widget/widget_gtk.h" #include "views/window/window_gtk.h" namespace views { @@ -46,7 +45,7 @@ bool AcceleratorHandler::Dispatch(GdkEvent* event) { DCHECK(ptr); // The top-level window is expected to always be associated // with the top-level gtk widget. WindowGtk* widget = - WidgetGtk::GetWindowForNative(reinterpret_cast<GtkWidget*>(ptr)); + WindowGtk::GetWindowForNative(reinterpret_cast<GtkWidget*>(ptr)); if (!widget) { // During dnd we get events for windows we don't control (such as the // window being dragged). diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index b166fce..5ca89a5 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -423,12 +423,6 @@ WidgetGtk* WidgetGtk::GetViewForNative(GtkWidget* widget) { return static_cast<WidgetGtk*>(GetWidgetFromNativeView(widget)); } -// static -WindowGtk* WidgetGtk::GetWindowForNative(GtkWidget* widget) { - gpointer user_data = g_object_get_data(G_OBJECT(widget), "chrome-window"); - return static_cast<WindowGtk*>(user_data); -} - void WidgetGtk::ResetDropTarget() { ignore_drag_leave_ = false; drop_target_.reset(NULL); @@ -1156,11 +1150,6 @@ void WidgetGtk::ReleaseGrab() { } } -// static -void WidgetGtk::SetWindowForNative(GtkWidget* widget, WindowGtk* window) { - g_object_set_data(G_OBJECT(widget), "chrome-window", window); -} - //////////////////////////////////////////////////////////////////////////////// // WidgetGtk, private: @@ -1330,7 +1319,6 @@ void WidgetGtk::CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds) { // We'll take care of positioning our window. gtk_window_set_position(GTK_WINDOW(widget_), GTK_WIN_POS_NONE); } - SetWindowForNative(widget_, static_cast<WindowGtk*>(this)); window_contents_ = gtk_views_fixed_new(); gtk_widget_set_name(window_contents_, "views-gtkwidget-window-fixed"); diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h index ad794e1..980baaf 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -140,10 +140,6 @@ class WidgetGtk // Gets the WidgetGtk in the userdata section of the widget. static WidgetGtk* GetViewForNative(GtkWidget* widget); - // Gets the WindowGtk in the userdata section of the widget. - // TODO(beng): move to WindowGtk - static WindowGtk* GetWindowForNative(GtkWidget* widget); - // Sets the drop target to NULL. This is invoked by DropTargetGTK when the // drop is done. void ResetDropTarget(); @@ -278,9 +274,6 @@ class WidgetGtk // Releases a grab done by this widget. virtual void ReleaseGrab(); - // Sets the WindowGtk in the userdata section of the widget. - static void SetWindowForNative(GtkWidget* widget, WindowGtk* window); - // Are we a subclass of WindowGtk? bool is_window_; diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc index 1a5147f..8a3e7b9 100644 --- a/views/window/window_gtk.cc +++ b/views/window/window_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -366,6 +366,17 @@ gboolean WindowGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) { return WidgetGtk::OnLeaveNotify(widget, event); } +// static +WindowGtk* WindowGtk::GetWindowForNative(GtkWidget* widget) { + gpointer user_data = g_object_get_data(G_OBJECT(widget), "chrome-window"); + return static_cast<WindowGtk*>(user_data); +} + +// static +void WindowGtk::SetWindowForNative(GtkWidget* widget, WindowGtk* window) { + g_object_set_data(G_OBJECT(widget), "chrome-window", window); +} + //////////////////////////////////////////////////////////////////////////////// // WindowGtk, protected: @@ -405,6 +416,8 @@ void WindowGtk::Init(GtkWindow* parent, const gfx::Rect& bounds) { UpdateWindowTitle(); SetInitialBounds(parent, bounds); + SetWindowForNative(GTK_WIDGET(GetNativeWindow()), this); + // if (!IsAppWindow()) { // notification_registrar_.Add( // this, diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h index 865ac81..fffa6cb 100644 --- a/views/window/window_gtk.h +++ b/views/window/window_gtk.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -69,6 +69,12 @@ class WindowGtk : public WidgetGtk, public Window { GdkEventWindowState* event); virtual gboolean OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event); + // Gets the WindowGtk in the userdata section of the widget. + static WindowGtk* GetWindowForNative(GtkWidget* widget); + + // Sets the WindowGtk in the userdata section of the widget. + static void SetWindowForNative(GtkWidget* widget, WindowGtk* window); + protected: // For the constructor. friend class Window; |