From e6269fd0e957510a2536a77e5a2fcabf799ccd20 Mon Sep 17 00:00:00 2001 From: "tfarina@chromium.org" Date: Wed, 2 Jun 2010 13:54:29 +0000 Subject: 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 --- views/window/window_gtk.cc | 15 ++++++++++++++- views/window/window_gtk.h | 8 +++++++- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'views/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(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; -- cgit v1.1