diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-25 21:31:10 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-25 21:31:10 +0000 |
commit | abd6052b2b96066f75252b46e9fb856ec3512795 (patch) | |
tree | 74bc0b5a541e2b96e6801f4564729b7024bbc2f8 /views | |
parent | 346e2ce5fa245d37b56aabb0f591750f99a5cee1 (diff) | |
download | chromium_src-abd6052b2b96066f75252b46e9fb856ec3512795.zip chromium_src-abd6052b2b96066f75252b46e9fb856ec3512795.tar.gz chromium_src-abd6052b2b96066f75252b46e9fb856ec3512795.tar.bz2 |
Hook up empty interfaces for NativeWidget/NativeWidgetDelegate.
These will be filled out in subsequent changelists to isolate the communication between Widget and WidgetWin/Gtk.
BUG=72040
TEST=existing
Review URL: http://codereview.chromium.org/6596013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76100 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/views.gyp | 2 | ||||
-rw-r--r-- | views/widget/native_widget.h | 26 | ||||
-rw-r--r-- | views/widget/native_widget_delegate.h | 26 | ||||
-rw-r--r-- | views/widget/widget.cc | 2 | ||||
-rw-r--r-- | views/widget/widget.h | 16 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 4 | ||||
-rw-r--r-- | views/widget/widget_gtk.h | 14 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 4 | ||||
-rw-r--r-- | views/widget/widget_win.h | 10 |
9 files changed, 93 insertions, 11 deletions
diff --git a/views/views.gyp b/views/views.gyp index abe63ca..f81e669 100644 --- a/views/views.gyp +++ b/views/views.gyp @@ -346,6 +346,8 @@ 'widget/tooltip_window_gtk.h', 'widget/monitor_win.cc', 'widget/monitor_win.h', + 'widget/native_widget.h', + 'widget/native_widget_delegate.h', 'widget/widget.cc', 'widget/widget.h', 'widget/widget_gtk.cc', diff --git a/views/widget/native_widget.h b/views/widget/native_widget.h new file mode 100644 index 0000000..2700f8c --- /dev/null +++ b/views/widget/native_widget.h @@ -0,0 +1,26 @@ +// Copyright (c) 2011 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. + +#ifndef VIEWS_WIDGET_NATIVE_WIDGET_H_ +#define VIEWS_WIDGET_NATIVE_WIDGET_H_ +#pragma once + +namespace views { +namespace internal { + +//////////////////////////////////////////////////////////////////////////////// +// NativeWidget interface +// +// An interface implemented by an object that encapsulates rendering, event +// handling and widget management provided by an underlying native toolkit. +// +class NativeWidget { + public: + virtual ~NativeWidget() {} +}; + +} // namespace internal +} // namespace views + +#endif // VIEWS_WIDGET_NATIVE_WIDGET_H_ diff --git a/views/widget/native_widget_delegate.h b/views/widget/native_widget_delegate.h new file mode 100644 index 0000000..5a64392 --- /dev/null +++ b/views/widget/native_widget_delegate.h @@ -0,0 +1,26 @@ +// Copyright (c) 2011 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. + +#ifndef VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_ +#define VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_ +#pragma once + +namespace views { +namespace internal { + +//////////////////////////////////////////////////////////////////////////////// +// NativeWidgetDelegate +// +// An interface implemented by the object that handles events sent by a +// NativeWidget implementation. +// +class NativeWidgetDelegate { + public: + virtual ~NativeWidgetDelegate() {} +}; + +} // namespace internal +} // namespace views + +#endif // VIEWS_WIDGET_NATIVE_WIDGET_DELEGATE_H_ diff --git a/views/widget/widget.cc b/views/widget/widget.cc index 487b3c0..0299c2d 100644 --- a/views/widget/widget.cc +++ b/views/widget/widget.cc @@ -13,7 +13,7 @@ namespace views { //////////////////////////////////////////////////////////////////////////////// // Widget, public: -Widget::Widget() : delegate_(NULL) { +Widget::Widget() : native_widget_(NULL), delegate_(NULL) { } Widget::~Widget() { diff --git a/views/widget/widget.h b/views/widget/widget.h index 7d2d9a3..89e9061 100644 --- a/views/widget/widget.h +++ b/views/widget/widget.h @@ -11,6 +11,7 @@ #include "base/scoped_ptr.h" #include "ui/gfx/native_widget_types.h" #include "views/focus/focus_manager.h" +#include "views/widget/native_widget_delegate.h" namespace gfx { class Path; @@ -34,6 +35,10 @@ class View; class WidgetDelegate; class Window; +namespace internal { +class NativeWidget; +} + //////////////////////////////////////////////////////////////////////////////// // Widget class // @@ -51,7 +56,8 @@ class Window; // implementation. Multiple inheritance is required for this // transitional step. // -class Widget : public FocusTraversable { +class Widget : public internal::NativeWidgetDelegate, + public FocusTraversable { public: enum TransparencyParam { Transparent, @@ -272,12 +278,20 @@ class Widget : public FocusTraversable { // TODO(beng): remove once we fold those objects onto this one. void DestroyRootView(); + // TODO(beng): Temporarily provided as a way to associate the subclass' + // implementation of NativeWidget with this. + void set_native_widget(internal::NativeWidget* native_widget) { + native_widget_ = native_widget; + } + // Overridden from FocusTraversable: virtual FocusSearch* GetFocusSearch(); virtual FocusTraversable* GetFocusTraversableParent(); virtual View* GetFocusTraversableParentView(); private: + internal::NativeWidget* native_widget_; + // Non-owned pointer to the Widget's delegate. May be NULL if no delegate is // being used. WidgetDelegate* delegate_; diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 1485820..bb61a3e 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -241,6 +241,7 @@ bool WidgetGtk::debug_paint_enabled_ = false; WidgetGtk::WidgetGtk(Type type) : is_window_(false), + ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)), type_(type), widget_(NULL), window_contents_(NULL), @@ -259,11 +260,11 @@ WidgetGtk::WidgetGtk(Type type) transient_to_parent_(false), got_initial_focus_in_(false), has_focus_(false), - delegate_(NULL), always_on_top_(false), is_double_buffered_(false), should_handle_menu_key_release_(false), dragged_view_(NULL) { + set_native_widget(this); static bool installed_message_loop_observer = false; if (!installed_message_loop_observer) { installed_message_loop_observer = true; @@ -1257,7 +1258,6 @@ void WidgetGtk::OnDestroy(GtkWidget* object) { // NULL out pointers here since we might still be in an observerer list // until delstion happens. widget_ = window_contents_ = NULL; - delegate_ = NULL; if (delete_on_destroy_) { // Delays the deletion of this WidgetGtk as we want its children to have // access to it when destroyed. diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h index 067f522..8c0cacd 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -13,6 +13,7 @@ #include "ui/base/x/active_window_watcher_x.h" #include "ui/gfx/size.h" #include "views/focus/focus_manager.h" +#include "views/widget/native_widget.h" #include "views/widget/widget.h" namespace gfx { @@ -29,13 +30,17 @@ using ui::OSExchangeDataProviderGtk; namespace views { class DropTargetGtk; -class FocusSearch; class TooltipManagerGtk; class View; class WindowGtk; +namespace internal { +class NativeWidgetDelegate; +} + // Widget implementation for GTK. class WidgetGtk : public Widget, + public internal::NativeWidget, public ui::ActiveWindowWatcherX::Observer { public: // Type of widget. @@ -323,6 +328,9 @@ class WidgetGtk : public Widget, static void DrawTransparentBackground(GtkWidget* widget, GdkEventExpose* event); + // A delegate implementation that handles events received here. + internal::NativeWidgetDelegate* delegate_; + const Type type_; // Our native views. If we're a window/popup, then widget_ is the window and @@ -419,10 +427,6 @@ class WidgetGtk : public Widget, // this to determine whether we should process the event. bool has_focus_; - // Non owned pointer to optional delegate. May be NULL if no delegate is - // being used. - WidgetDelegate* delegate_; - // If true, the window stays on top of the screen. This is only used // for types other than TYPE_CHILD. bool always_on_top_; diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index 3f1ca3c..cddc03b 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -74,7 +74,8 @@ RootView* GetRootViewForHWND(HWND hwnd) { // WidgetWin, public WidgetWin::WidgetWin() - : close_widget_factory_(this), + : ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)), + close_widget_factory_(this), active_mouse_tracking_flags_(0), has_capture_(false), use_layered_buffer_(false), @@ -89,6 +90,7 @@ WidgetWin::WidgetWin() accessibility_view_events_(kMaxAccessibilityViewEvents), dragged_view_(NULL), previous_cursor_(NULL) { + set_native_widget(this); } WidgetWin::~WidgetWin() { diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h index 071040f..2f46c18 100644 --- a/views/widget/widget_win.h +++ b/views/widget/widget_win.h @@ -21,6 +21,7 @@ #include "ui/base/win/window_impl.h" #include "views/focus/focus_manager.h" #include "views/layout/layout_manager.h" +#include "views/widget/native_widget.h" #include "views/widget/widget.h" namespace ui { @@ -35,11 +36,14 @@ class Rect; namespace views { class DropTargetWin; -class FocusSearch; class RootView; class TooltipManagerWin; class Window; +namespace internal { +class NativeWidgetDelegate; +} + RootView* GetRootViewForHWND(HWND hwnd); // A Windows message reflected from other windows. This message is sent @@ -76,6 +80,7 @@ const int WM_NCUAHDRAWFRAME = 0xAF; /////////////////////////////////////////////////////////////////////////////// class WidgetWin : public ui::WindowImpl, public Widget, + public internal::NativeWidget, public MessageLoopForUI::Observer { public: WidgetWin(); @@ -499,6 +504,9 @@ class WidgetWin : public ui::WindowImpl, // Synchronously paints the invalid contents of the Widget. void RedrawInvalidRect(); + // A delegate implementation that handles events received here. + internal::NativeWidgetDelegate* delegate_; + // The following factory is used for calls to close the WidgetWin // instance. ScopedRunnableMethodFactory<WidgetWin> close_widget_factory_; |