diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-19 14:43:12 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-19 14:43:12 +0000 |
commit | 2fc6672f21decd142da98665de2a0330b2e0ac57 (patch) | |
tree | 52246ce158462b88cd4cc8cad667eb28a039e2b3 /views/widget | |
parent | e8491289e4313d396ea9e1522209c1305d60a227 (diff) | |
download | chromium_src-2fc6672f21decd142da98665de2a0330b2e0ac57.zip chromium_src-2fc6672f21decd142da98665de2a0330b2e0ac57.tar.gz chromium_src-2fc6672f21decd142da98665de2a0330b2e0ac57.tar.bz2 |
Rename WidgetWin/Gtk -> NativeWidgetWin/Gtk.
BUG=72040
TEST=none
TBR=sky
Review URL: http://codereview.chromium.org/7039050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85910 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
17 files changed, 459 insertions, 421 deletions
diff --git a/views/widget/child_window_message_processor.h b/views/widget/child_window_message_processor.h index ab18997..a11b187 100644 --- a/views/widget/child_window_message_processor.h +++ b/views/widget/child_window_message_processor.h @@ -17,7 +17,7 @@ namespace views { // Windows sends a handful of messages to the parent window rather than the // window itself. For example, selection changes of a rich edit (EN_SELCHANGE) // are sent to the parent, not the window. Typically such message are best -// dealt with by the window rather than the parent. WidgetWin allows for +// dealt with by the window rather than the parent. NativeWidgetWin allows for // registering a ChildWindowMessageProcessor to handle such messages. class ChildWindowMessageProcessor { public: diff --git a/views/widget/default_theme_provider.cc b/views/widget/default_theme_provider.cc index 7d2dfec..86c3b7b 100644 --- a/views/widget/default_theme_provider.cc +++ b/views/widget/default_theme_provider.cc @@ -7,7 +7,7 @@ #include "ui/base/resource/resource_bundle.h" #if defined(OS_WIN) -#include "views/widget/widget_win.h" +#include "views/widget/native_widget_win.h" #endif namespace views { @@ -33,7 +33,7 @@ bool DefaultThemeProvider::GetDisplayProperty(int id, int* result) const { bool DefaultThemeProvider::ShouldUseNativeFrame() const { #if defined(OS_WIN) - return WidgetWin::IsAeroGlassEnabled(); + return NativeWidgetWin::IsAeroGlassEnabled(); #else return false; #endif diff --git a/views/widget/drop_target_gtk.cc b/views/widget/drop_target_gtk.cc index c135d91..4fecfcb 100644 --- a/views/widget/drop_target_gtk.cc +++ b/views/widget/drop_target_gtk.cc @@ -17,7 +17,7 @@ #include "ui/base/dragdrop/os_exchange_data_provider_gtk.h" #include "ui/gfx/point.h" #include "views/widget/root_view.h" -#include "views/widget/widget_gtk.h" +#include "views/widget/native_widget_gtk.h" using ui::OSExchangeData; @@ -166,7 +166,7 @@ gboolean DropTargetGtk::OnDragDrop(GdkDragContext* context, OnDragMotion(context, x, y, time); if (!pending_view_) { // User isn't over a view, no drop can occur. - static_cast<WidgetGtk*>( + static_cast<NativeWidgetGtk*>( helper_.root_view()->GetWidget()->native_widget())->ResetDropTarget(); // WARNING: we've been deleted. return FALSE; @@ -246,8 +246,8 @@ void DropTargetGtk::FinishDrop(GdkDragContext* context, gtk_drag_finish(context, gdk_action != 0, (gdk_action & GDK_ACTION_MOVE), time); - static_cast<WidgetGtk*>(helper_.root_view()->GetWidget()->native_widget())-> - ResetDropTarget(); + static_cast<NativeWidgetGtk*>(helper_.root_view()->GetWidget()-> + native_widget())->ResetDropTarget(); // WARNING: we've been deleted. } @@ -265,8 +265,8 @@ void DropTargetGtk::RequestFormats(GdkDragContext* context, int formats, const std::set<GdkAtom>& custom_formats, guint time) { - GtkWidget* widget = static_cast<WidgetGtk*>(helper_.root_view()->GetWidget()-> - native_widget())->window_contents(); + GtkWidget* widget = static_cast<NativeWidgetGtk*>(helper_.root_view()-> + GetWidget()->native_widget())->window_contents(); const std::set<GdkAtom>& known_formats = data_provider().known_custom_formats(); diff --git a/views/widget/drop_target_gtk.h b/views/widget/drop_target_gtk.h index eea1df7..75fd1c0 100644 --- a/views/widget/drop_target_gtk.h +++ b/views/widget/drop_target_gtk.h @@ -33,7 +33,7 @@ class View; // the target is notified. Similarly if the drop completes and the data has // not yet been fetched, it is fetched and the target then notified. // -// When a drop finishes this class calls back to the containing WidgetGtk +// When a drop finishes this class calls back to the containing NativeWidgetGtk // which results in deleting the DropTargetGtk. class DropTargetGtk { public: @@ -47,7 +47,8 @@ class DropTargetGtk { // we don't target a view that was removed during dnd. void ResetTargetViewIfEquals(View* view); - // Drop methods from Gtk. These are forwarded from the containing WidgetGtk. + // Drop methods from Gtk. These are forwarded from the containing + // NativeWidgetGtk. void OnDragDataReceived(GdkDragContext* context, gint x, gint y, diff --git a/views/widget/drop_target_win.h b/views/widget/drop_target_win.h index 05ece15..1498841 100644 --- a/views/widget/drop_target_win.h +++ b/views/widget/drop_target_win.h @@ -14,7 +14,7 @@ namespace views { class RootView; class View; -// DropTargetWin takes care of managing drag and drop for WidgetWin. It +// DropTargetWin takes care of managing drag and drop for NativeWidgetWin. It // converts Windows OLE drop messages into Views drop messages. // // DropTargetWin uses DropHelper to manage the appropriate view to target diff --git a/views/widget/widget_gtk.cc b/views/widget/native_widget_gtk.cc index 0e693d8..1dc4f0f 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/native_widget_gtk.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "views/widget/widget_gtk.h" +#include "views/widget/native_widget_gtk.h" #include <gdk/gdk.h> #include <gdk/gdkx.h> @@ -186,7 +186,7 @@ void RemoveExposeHandlerIfExists(GtkWidget* widget) { // have no way to tell the difference between a normal drag leave and a drop. // To work around that we listen for DROP_START, then ignore the subsequent // drag-leave that GTK generates. -class WidgetGtk::DropObserver : public MessageLoopForUI::Observer { +class NativeWidgetGtk::DropObserver : public MessageLoopForUI::Observer { public: DropObserver() {} @@ -196,7 +196,7 @@ class WidgetGtk::DropObserver : public MessageLoopForUI::Observer { virtual void WillProcessEvent(GdkEvent* event) { if (event->type == GDK_DROP_START) { - WidgetGtk* widget = GetWidgetGtkForEvent(event); + NativeWidgetGtk* widget = GetNativeWidgetGtkForEvent(event); if (widget) widget->ignore_drag_leave_ = true; } @@ -206,12 +206,12 @@ class WidgetGtk::DropObserver : public MessageLoopForUI::Observer { } private: - WidgetGtk* GetWidgetGtkForEvent(GdkEvent* event) { + NativeWidgetGtk* GetNativeWidgetGtkForEvent(GdkEvent* event) { GtkWidget* gtk_widget = gtk_get_event_widget(event); if (!gtk_widget) return NULL; - return static_cast<WidgetGtk*>( + return static_cast<NativeWidgetGtk*>( NativeWidget::GetNativeWidgetForNativeView(gtk_widget)); } @@ -278,13 +278,13 @@ static GtkWidget* CreateDragIconWidget(GdkPixbuf* drag_image) { } // static -GtkWidget* WidgetGtk::null_parent_ = NULL; -bool WidgetGtk::debug_paint_enabled_ = false; +GtkWidget* NativeWidgetGtk::null_parent_ = NULL; +bool NativeWidgetGtk::debug_paint_enabled_ = false; //////////////////////////////////////////////////////////////////////////////// -// WidgetGtk, public: +// NativeWidgetGtk, public: -WidgetGtk::WidgetGtk(internal::NativeWidgetDelegate* delegate) +NativeWidgetGtk::NativeWidgetGtk(internal::NativeWidgetDelegate* delegate) : is_window_(false), delegate_(delegate), widget_(NULL), @@ -321,7 +321,7 @@ WidgetGtk::WidgetGtk(internal::NativeWidgetDelegate* delegate) } } -WidgetGtk::~WidgetGtk() { +NativeWidgetGtk::~NativeWidgetGtk() { // We need to delete the input method before calling DestroyRootView(), // because it'll set focus_manager_ to NULL. input_method_.reset(); @@ -333,12 +333,12 @@ WidgetGtk::~WidgetGtk() { ActiveWindowWatcherX::RemoveObserver(this); } -GtkWindow* WidgetGtk::GetTransientParent() const { +GtkWindow* NativeWidgetGtk::GetTransientParent() const { return (!child_ && widget_) ? gtk_window_get_transient_for(GTK_WINDOW(widget_)) : NULL; } -bool WidgetGtk::MakeTransparent() { +bool NativeWidgetGtk::MakeTransparent() { // Transparency can only be enabled only if we haven't realized the widget. DCHECK(!widget_); @@ -359,7 +359,7 @@ bool WidgetGtk::MakeTransparent() { return true; } -void WidgetGtk::EnableDoubleBuffer(bool enabled) { +void NativeWidgetGtk::EnableDoubleBuffer(bool enabled) { is_double_buffered_ = enabled; if (window_contents_) { if (is_double_buffered_) @@ -369,11 +369,11 @@ void WidgetGtk::EnableDoubleBuffer(bool enabled) { } } -void WidgetGtk::AddChild(GtkWidget* child) { +void NativeWidgetGtk::AddChild(GtkWidget* child) { gtk_container_add(GTK_CONTAINER(window_contents_), child); } -void WidgetGtk::RemoveChild(GtkWidget* child) { +void NativeWidgetGtk::RemoveChild(GtkWidget* child) { // We can be called after the contents widget has been destroyed, e.g. any // NativeViewHost not removed from the view hierarchy before the window is // closed. @@ -383,16 +383,17 @@ void WidgetGtk::RemoveChild(GtkWidget* child) { } } -void WidgetGtk::ReparentChild(GtkWidget* child) { +void NativeWidgetGtk::ReparentChild(GtkWidget* child) { gtk_widget_reparent(child, window_contents_); } -void WidgetGtk::PositionChild(GtkWidget* child, int x, int y, int w, int h) { +void NativeWidgetGtk::PositionChild(GtkWidget* child, int x, int y, int w, + int h) { gtk_views_fixed_set_widget_size(child, w, h); gtk_fixed_move(GTK_FIXED(window_contents_), child, x, y); } -void WidgetGtk::DoDrag(const OSExchangeData& data, int operation) { +void NativeWidgetGtk::DoDrag(const OSExchangeData& data, int operation) { const OSExchangeDataProviderGtk& data_provider = static_cast<const OSExchangeDataProviderGtk&>(data.provider()); GtkTargetList* targets = data_provider.GetTargetList(); @@ -446,7 +447,7 @@ void WidgetGtk::DoDrag(const OSExchangeData& data, int operation) { } } -void WidgetGtk::IsActiveChanged() { +void NativeWidgetGtk::IsActiveChanged() { WidgetDelegate* d = GetWidget()->widget_delegate(); if (d) { bool a = IsActive(); @@ -454,7 +455,7 @@ void WidgetGtk::IsActiveChanged() { } } -void WidgetGtk::SetInitialFocus() { +void NativeWidgetGtk::SetInitialFocus() { if (!focus_on_creation_) return; @@ -464,12 +465,12 @@ void WidgetGtk::SetInitialFocus() { v->RequestFocus(); } -void WidgetGtk::ResetDropTarget() { +void NativeWidgetGtk::ResetDropTarget() { ignore_drag_leave_ = false; drop_target_.reset(NULL); } -void WidgetGtk::GetRequestedSize(gfx::Size* out) const { +void NativeWidgetGtk::GetRequestedSize(gfx::Size* out) const { int width, height; if (GTK_IS_VIEWS_FIXED(widget_) && gtk_views_fixed_get_widget_size(GetNativeView(), &width, &height)) { @@ -482,9 +483,9 @@ void WidgetGtk::GetRequestedSize(gfx::Size* out) const { } //////////////////////////////////////////////////////////////////////////////// -// WidgetGtk, ActiveWindowWatcherX::Observer implementation: +// NativeWidgetGtk, ActiveWindowWatcherX::Observer implementation: -void WidgetGtk::ActiveWindowChanged(GdkWindow* active_window) { +void NativeWidgetGtk::ActiveWindowChanged(GdkWindow* active_window) { if (!GetNativeView()) return; @@ -508,9 +509,9 @@ void WidgetGtk::ActiveWindowChanged(GdkWindow* active_window) { } //////////////////////////////////////////////////////////////////////////////// -// WidgetGtk, Widget implementation: +// NativeWidgetGtk, Widget implementation: -void WidgetGtk::ClearNativeFocus() { +void NativeWidgetGtk::ClearNativeFocus() { DCHECK(!child_); if (!GetNativeView()) { NOTREACHED(); @@ -519,7 +520,7 @@ void WidgetGtk::ClearNativeFocus() { gtk_window_set_focus(GTK_WINDOW(GetNativeView()), NULL); } -bool WidgetGtk::HandleKeyboardEvent(const KeyEvent& key) { +bool NativeWidgetGtk::HandleKeyboardEvent(const KeyEvent& key) { if (!GetWidget()->GetFocusManager()) return false; @@ -552,12 +553,13 @@ bool WidgetGtk::HandleKeyboardEvent(const KeyEvent& key) { } // static -void WidgetGtk::EnableDebugPaint() { +void NativeWidgetGtk::EnableDebugPaint() { debug_paint_enabled_ = true; } // static -void WidgetGtk::UpdateFreezeUpdatesProperty(GtkWindow* window, bool enable) { +void NativeWidgetGtk::UpdateFreezeUpdatesProperty(GtkWindow* window, + bool enable) { if (!GTK_WIDGET_REALIZED(GTK_WIDGET(window))) gtk_widget_realize(GTK_WIDGET(window)); GdkWindow* gdk_window = GTK_WIDGET(window)->window; @@ -583,7 +585,7 @@ void WidgetGtk::UpdateFreezeUpdatesProperty(GtkWindow* window, bool enable) { } // static -void WidgetGtk::RegisterChildExposeHandler(GtkWidget* child) { +void NativeWidgetGtk::RegisterChildExposeHandler(GtkWidget* child) { RemoveExposeHandlerIfExists(child); gulong id = g_signal_connect_after(child, "expose-event", G_CALLBACK(&ChildExposeHandler), NULL); @@ -592,16 +594,16 @@ void WidgetGtk::RegisterChildExposeHandler(GtkWidget* child) { } //////////////////////////////////////////////////////////////////////////////// -// WidgetGtk, NativeWidget implementation: +// NativeWidgetGtk, NativeWidget implementation: -void WidgetGtk::InitNativeWidget(const Widget::InitParams& params) { +void NativeWidgetGtk::InitNativeWidget(const Widget::InitParams& params) { SetInitParams(params); Widget::InitParams modified_params = params; gfx::NativeView parent = params.parent; if (params.parent_widget) { - WidgetGtk* parent_gtk = - static_cast<WidgetGtk*>(params.parent_widget->native_widget()); + NativeWidgetGtk* parent_gtk = + static_cast<NativeWidgetGtk*>(params.parent_widget->native_widget()); modified_params.parent = child_ ? parent_gtk->window_contents() : params.parent_widget->GetNativeView(); } @@ -735,75 +737,75 @@ void WidgetGtk::InitNativeWidget(const Widget::InitParams& params) { } } -Widget* WidgetGtk::GetWidget() { +Widget* NativeWidgetGtk::GetWidget() { return delegate_->AsWidget(); } -const Widget* WidgetGtk::GetWidget() const { +const Widget* NativeWidgetGtk::GetWidget() const { return delegate_->AsWidget(); } -gfx::NativeView WidgetGtk::GetNativeView() const { +gfx::NativeView NativeWidgetGtk::GetNativeView() const { return widget_; } -gfx::NativeWindow WidgetGtk::GetNativeWindow() const { +gfx::NativeWindow NativeWidgetGtk::GetNativeWindow() const { return child_ ? NULL : GTK_WINDOW(widget_); } -Window* WidgetGtk::GetContainingWindow() { +Window* NativeWidgetGtk::GetContainingWindow() { return GetWindowImpl(widget_); } -const Window* WidgetGtk::GetContainingWindow() const { +const Window* NativeWidgetGtk::GetContainingWindow() const { return GetWindowImpl(widget_); } -void WidgetGtk::ViewRemoved(View* view) { +void NativeWidgetGtk::ViewRemoved(View* view) { if (drop_target_.get()) drop_target_->ResetTargetViewIfEquals(view); } -void WidgetGtk::SetNativeWindowProperty(const char* name, void* value) { +void NativeWidgetGtk::SetNativeWindowProperty(const char* name, void* value) { g_object_set_data(G_OBJECT(widget_), name, value); } -void* WidgetGtk::GetNativeWindowProperty(const char* name) { +void* NativeWidgetGtk::GetNativeWindowProperty(const char* name) { return g_object_get_data(G_OBJECT(widget_), name); } -TooltipManager* WidgetGtk::GetTooltipManager() const { +TooltipManager* NativeWidgetGtk::GetTooltipManager() const { return tooltip_manager_.get(); } -bool WidgetGtk::IsScreenReaderActive() const { +bool NativeWidgetGtk::IsScreenReaderActive() const { return false; } -void WidgetGtk::SendNativeAccessibilityEvent( +void NativeWidgetGtk::SendNativeAccessibilityEvent( View* view, ui::AccessibilityTypes::Event event_type) { // In the future if we add native GTK accessibility support, the // notification should be sent here. } -void WidgetGtk::SetMouseCapture() { +void NativeWidgetGtk::SetMouseCapture() { DCHECK(!HasMouseCapture()); gtk_grab_add(window_contents_); } -void WidgetGtk::ReleaseMouseCapture() { +void NativeWidgetGtk::ReleaseMouseCapture() { if (HasMouseCapture()) gtk_grab_remove(window_contents_); } -bool WidgetGtk::HasMouseCapture() const { +bool NativeWidgetGtk::HasMouseCapture() const { // TODO(beng): Should be able to use gtk_widget_has_grab() here but the // trybots don't have Gtk 2.18. return GTK_WIDGET_HAS_GRAB(window_contents_); } -bool WidgetGtk::IsMouseButtonDown() const { +bool NativeWidgetGtk::IsMouseButtonDown() const { bool button_pressed = false; GdkEvent* event = gtk_get_current_event(); if (event) { @@ -815,11 +817,11 @@ bool WidgetGtk::IsMouseButtonDown() const { return button_pressed; } -InputMethod* WidgetGtk::GetInputMethodNative() { +InputMethod* NativeWidgetGtk::GetInputMethodNative() { return input_method_.get(); } -void WidgetGtk::ReplaceInputMethod(InputMethod* input_method) { +void NativeWidgetGtk::ReplaceInputMethod(InputMethod* input_method) { input_method_.reset(input_method); if (input_method) { input_method->set_delegate(this); @@ -827,12 +829,12 @@ void WidgetGtk::ReplaceInputMethod(InputMethod* input_method) { } } -gfx::Rect WidgetGtk::GetWindowScreenBounds() const { +gfx::Rect NativeWidgetGtk::GetWindowScreenBounds() const { // Client == Window bounds on Gtk. return GetClientAreaScreenBounds(); } -gfx::Rect WidgetGtk::GetClientAreaScreenBounds() const { +gfx::Rect NativeWidgetGtk::GetClientAreaScreenBounds() const { // Due to timing we can get a request for bounds after Close(). // TODO(beng): Figure out if this is bogus. if (!widget_) @@ -852,19 +854,19 @@ gfx::Rect WidgetGtk::GetClientAreaScreenBounds() const { return gfx::Rect(x, y, w, h); } -void WidgetGtk::SetBounds(const gfx::Rect& bounds) { +void NativeWidgetGtk::SetBounds(const gfx::Rect& bounds) { if (child_) { GtkWidget* parent = gtk_widget_get_parent(widget_); if (GTK_IS_VIEWS_FIXED(parent)) { - WidgetGtk* parent_widget = static_cast<WidgetGtk*>( + NativeWidgetGtk* parent_widget = static_cast<NativeWidgetGtk*>( NativeWidget::GetNativeWidgetForNativeView(parent)); parent_widget->PositionChild(widget_, bounds.x(), bounds.y(), bounds.width(), bounds.height()); } else { DCHECK(GTK_IS_FIXED(parent)) - << "Parent of WidgetGtk has to be Fixed or ViewsFixed"; - // Just request the size if the parent is not WidgetGtk but plain - // GtkFixed. WidgetGtk does not know the minimum size so we assume + << "Parent of NativeWidgetGtk has to be Fixed or ViewsFixed"; + // Just request the size if the parent is not NativeWidgetGtk but plain + // GtkFixed. NativeWidgetGtk does not know the minimum size so we assume // the caller of the SetBounds knows exactly how big it wants to be. gtk_widget_set_size_request(widget_, bounds.width(), bounds.height()); if (parent != null_parent_) @@ -890,14 +892,14 @@ void WidgetGtk::SetBounds(const gfx::Rect& bounds) { } } -void WidgetGtk::SetSize(const gfx::Size& size) { +void NativeWidgetGtk::SetSize(const gfx::Size& size) { if (child_) { GtkWidget* parent = gtk_widget_get_parent(widget_); if (GTK_IS_VIEWS_FIXED(parent)) { gtk_views_fixed_set_widget_size(widget_, size.width(), size.height()); } else { DCHECK(GTK_IS_FIXED(parent)) - << "Parent of WidgetGtk has to be Fixed or ViewsFixed"; + << "Parent of NativeWidgetGtk has to be Fixed or ViewsFixed"; gtk_widget_set_size_request(widget_, size.width(), size.height()); } } else { @@ -909,18 +911,18 @@ void WidgetGtk::SetSize(const gfx::Size& size) { } } -void WidgetGtk::MoveAbove(gfx::NativeView native_view) { +void NativeWidgetGtk::MoveAbove(gfx::NativeView native_view) { ui::StackPopupWindow(GetNativeView(), native_view); } -void WidgetGtk::SetShape(gfx::NativeRegion region) { +void NativeWidgetGtk::SetShape(gfx::NativeRegion region) { DCHECK(widget_); DCHECK(widget_->window); gdk_window_shape_combine_region(widget_->window, region, 0, 0); gdk_region_destroy(region); } -void WidgetGtk::Close() { +void NativeWidgetGtk::Close() { if (!widget_) return; // No need to do anything. @@ -930,18 +932,18 @@ void WidgetGtk::Close() { // And we delay the close just in case we're on the stack. MessageLoop::current()->PostTask(FROM_HERE, close_widget_factory_.NewRunnableMethod( - &WidgetGtk::CloseNow)); + &NativeWidgetGtk::CloseNow)); } } -void WidgetGtk::CloseNow() { +void NativeWidgetGtk::CloseNow() { if (widget_) { input_method_.reset(); gtk_widget_destroy(widget_); // Triggers OnDestroy(). } } -void WidgetGtk::Show() { +void NativeWidgetGtk::Show() { if (widget_) { gtk_widget_show(widget_); if (widget_->window) @@ -949,7 +951,7 @@ void WidgetGtk::Show() { } } -void WidgetGtk::Hide() { +void NativeWidgetGtk::Hide() { if (widget_) { gtk_widget_hide(widget_); if (widget_->window) @@ -957,7 +959,7 @@ void WidgetGtk::Hide() { } } -void WidgetGtk::SetOpacity(unsigned char opacity) { +void NativeWidgetGtk::SetOpacity(unsigned char opacity) { opacity_ = opacity; if (widget_) { // We can only set the opacity when the widget has been realized. @@ -966,39 +968,39 @@ void WidgetGtk::SetOpacity(unsigned char opacity) { } } -void WidgetGtk::SetAlwaysOnTop(bool on_top) { +void NativeWidgetGtk::SetAlwaysOnTop(bool on_top) { DCHECK(!child_); always_on_top_ = on_top; if (widget_) gtk_window_set_keep_above(GTK_WINDOW(widget_), on_top); } -bool WidgetGtk::IsVisible() const { +bool NativeWidgetGtk::IsVisible() const { return GTK_WIDGET_VISIBLE(widget_); } -bool WidgetGtk::IsActive() const { +bool NativeWidgetGtk::IsActive() const { DCHECK(!child_); return is_active_; } -bool WidgetGtk::IsAccessibleWidget() const { +bool NativeWidgetGtk::IsAccessibleWidget() const { return false; } -bool WidgetGtk::ContainsNativeView(gfx::NativeView native_view) const { - // TODO(port) See implementation in WidgetWin::ContainsNativeView. - NOTREACHED() << "WidgetGtk::ContainsNativeView is not implemented."; +bool NativeWidgetGtk::ContainsNativeView(gfx::NativeView native_view) const { + // TODO(port) See implementation in NativeWidgetWin::ContainsNativeView. + NOTREACHED() << "NativeWidgetGtk::ContainsNativeView is not implemented."; return false; } -void WidgetGtk::RunShellDrag(View* view, - const ui::OSExchangeData& data, - int operation) { +void NativeWidgetGtk::RunShellDrag(View* view, + const ui::OSExchangeData& data, + int operation) { DoDrag(data, operation); } -void WidgetGtk::SchedulePaintInRect(const gfx::Rect& rect) { +void NativeWidgetGtk::SchedulePaintInRect(const gfx::Rect& rect) { // No need to schedule paint if // 1) widget_ is NULL. This may happen because this instance may // be deleted after the gtk widget has been destroyed (See OnDestroy()). @@ -1011,7 +1013,7 @@ void WidgetGtk::SchedulePaintInRect(const gfx::Rect& rect) { } } -void WidgetGtk::SetCursor(gfx::NativeCursor cursor) { +void NativeWidgetGtk::SetCursor(gfx::NativeCursor cursor) { #if defined(TOUCH_UI) && defined(HAVE_XINPUT2) if (!TouchFactory::GetInstance()->is_cursor_visible() && !RootView::GetKeepMouseCursor()) @@ -1024,9 +1026,10 @@ void WidgetGtk::SetCursor(gfx::NativeCursor cursor) { } //////////////////////////////////////////////////////////////////////////////// -// WidgetGtk, protected: +// NativeWidgetGtk, protected: -void WidgetGtk::OnSizeRequest(GtkWidget* widget, GtkRequisition* requisition) { +void NativeWidgetGtk::OnSizeRequest(GtkWidget* widget, + GtkRequisition* requisition) { // Do only return the preferred size for child windows. GtkWindow interprets // the requisition as a minimum size for top level windows, returning a // preferred size for these would prevents us from setting smaller window @@ -1038,7 +1041,8 @@ void WidgetGtk::OnSizeRequest(GtkWidget* widget, GtkRequisition* requisition) { } } -void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { +void NativeWidgetGtk::OnSizeAllocate(GtkWidget* widget, + GtkAllocation* allocation) { // See comment next to size_ as to why we do this. Also note, it's tempting // to put this in the static method so subclasses don't need to worry about // it, but if a subclasses needs to set a shape then they need to always @@ -1050,7 +1054,7 @@ void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { delegate_->OnSizeChanged(size_); } -gboolean WidgetGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { +gboolean NativeWidgetGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { if (transparent_ && child_) { // Clear the background before drawing any view and native components. DrawTransparentBackground(widget, event); @@ -1097,11 +1101,11 @@ gboolean WidgetGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { return false; // False indicates other widgets should get the event as well. } -void WidgetGtk::OnDragDataGet(GtkWidget* widget, - GdkDragContext* context, - GtkSelectionData* data, - guint info, - guint time) { +void NativeWidgetGtk::OnDragDataGet(GtkWidget* widget, + GdkDragContext* context, + GtkSelectionData* data, + guint info, + guint time) { if (!drag_data_) { NOTREACHED(); return; @@ -1109,29 +1113,29 @@ void WidgetGtk::OnDragDataGet(GtkWidget* widget, drag_data_->WriteFormatToSelection(info, data); } -void WidgetGtk::OnDragDataReceived(GtkWidget* widget, - GdkDragContext* context, - gint x, - gint y, - GtkSelectionData* data, - guint info, - guint time) { +void NativeWidgetGtk::OnDragDataReceived(GtkWidget* widget, + GdkDragContext* context, + gint x, + gint y, + GtkSelectionData* data, + guint info, + guint time) { if (drop_target_.get()) drop_target_->OnDragDataReceived(context, x, y, data, info, time); } -gboolean WidgetGtk::OnDragDrop(GtkWidget* widget, - GdkDragContext* context, - gint x, - gint y, - guint time) { +gboolean NativeWidgetGtk::OnDragDrop(GtkWidget* widget, + GdkDragContext* context, + gint x, + gint y, + guint time) { if (drop_target_.get()) { return drop_target_->OnDragDrop(context, x, y, time); } return FALSE; } -void WidgetGtk::OnDragEnd(GtkWidget* widget, GdkDragContext* context) { +void NativeWidgetGtk::OnDragEnd(GtkWidget* widget, GdkDragContext* context) { if (!drag_data_) { // This indicates we didn't start a drag operation, and should never // happen. @@ -1142,15 +1146,15 @@ void WidgetGtk::OnDragEnd(GtkWidget* widget, GdkDragContext* context) { MessageLoop::current()->Quit(); } -gboolean WidgetGtk::OnDragFailed(GtkWidget* widget, - GdkDragContext* context, - GtkDragResult result) { +gboolean NativeWidgetGtk::OnDragFailed(GtkWidget* widget, + GdkDragContext* context, + GtkDragResult result) { return FALSE; } -void WidgetGtk::OnDragLeave(GtkWidget* widget, - GdkDragContext* context, - guint time) { +void NativeWidgetGtk::OnDragLeave(GtkWidget* widget, + GdkDragContext* context, + guint time) { if (ignore_drag_leave_) { ignore_drag_leave_ = false; return; @@ -1161,17 +1165,18 @@ void WidgetGtk::OnDragLeave(GtkWidget* widget, } } -gboolean WidgetGtk::OnDragMotion(GtkWidget* widget, - GdkDragContext* context, - gint x, - gint y, - guint time) { +gboolean NativeWidgetGtk::OnDragMotion(GtkWidget* widget, + GdkDragContext* context, + gint x, + gint y, + guint time) { if (!drop_target_.get()) drop_target_.reset(new DropTargetGtk(GetWidget()->GetRootView(), context)); return drop_target_->OnDragMotion(context, x, y, time); } -gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) { +gboolean NativeWidgetGtk::OnEnterNotify(GtkWidget* widget, + GdkEventCrossing* event) { if (HasMouseCapture() && event->mode == GDK_CROSSING_GRAB) { // Doing a grab results an async enter event, regardless of where the mouse // is. We don't want to generate a mouse move in this case. @@ -1198,7 +1203,8 @@ gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) { return false; } -gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) { +gboolean NativeWidgetGtk::OnLeaveNotify(GtkWidget* widget, + GdkEventCrossing* event) { GetWidget()->ResetLastMouseMoveFlag(); if (!HasMouseCapture() && !GetWidget()->is_mouse_button_pressed_) { @@ -1208,13 +1214,15 @@ gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) { return false; } -gboolean WidgetGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) { +gboolean NativeWidgetGtk::OnMotionNotify(GtkWidget* widget, + GdkEventMotion* event) { MouseEvent mouse_event(TransformEvent(event)); delegate_->OnMouseEvent(mouse_event); return true; } -gboolean WidgetGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) { +gboolean NativeWidgetGtk::OnButtonPress(GtkWidget* widget, + GdkEventButton* event) { if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) { // The sequence for double clicks is press, release, press, 2press, release. // This means that at the time we get the second 'press' we don't know @@ -1232,7 +1240,8 @@ gboolean WidgetGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) { return delegate_->OnMouseEvent(mouse_event) || !transparent_; } -gboolean WidgetGtk::OnButtonRelease(GtkWidget* widget, GdkEventButton* event) { +gboolean NativeWidgetGtk::OnButtonRelease(GtkWidget* widget, + GdkEventButton* event) { // GTK generates a mouse release at the end of dnd. We need to ignore it. if (!drag_data_) { MouseEvent mouse_event(TransformEvent(event)); @@ -1241,12 +1250,12 @@ gboolean WidgetGtk::OnButtonRelease(GtkWidget* widget, GdkEventButton* event) { return true; } -gboolean WidgetGtk::OnScroll(GtkWidget* widget, GdkEventScroll* event) { +gboolean NativeWidgetGtk::OnScroll(GtkWidget* widget, GdkEventScroll* event) { MouseEvent mouse_event(TransformEvent(event)); return delegate_->OnMouseEvent(mouse_event); } -gboolean WidgetGtk::OnFocusIn(GtkWidget* widget, GdkEventFocus* event) { +gboolean NativeWidgetGtk::OnFocusIn(GtkWidget* widget, GdkEventFocus* event) { if (has_focus_) return false; // This is the second focus-in event in a row, ignore it. has_focus_ = true; @@ -1268,7 +1277,7 @@ gboolean WidgetGtk::OnFocusIn(GtkWidget* widget, GdkEventFocus* event) { return false; } -gboolean WidgetGtk::OnFocusOut(GtkWidget* widget, GdkEventFocus* event) { +gboolean NativeWidgetGtk::OnFocusOut(GtkWidget* widget, GdkEventFocus* event) { if (!has_focus_) return false; // This is the second focus-out event in a row, ignore it. has_focus_ = false; @@ -1282,7 +1291,7 @@ gboolean WidgetGtk::OnFocusOut(GtkWidget* widget, GdkEventFocus* event) { return false; } -gboolean WidgetGtk::OnEventKey(GtkWidget* widget, GdkEventKey* event) { +gboolean NativeWidgetGtk::OnEventKey(GtkWidget* widget, GdkEventKey* event) { KeyEvent key(reinterpret_cast<NativeEvent>(event)); if (input_method_.get()) input_method_->DispatchKeyEvent(key); @@ -1293,49 +1302,49 @@ gboolean WidgetGtk::OnEventKey(GtkWidget* widget, GdkEventKey* event) { return true; } -gboolean WidgetGtk::OnQueryTooltip(GtkWidget* widget, - gint x, - gint y, - gboolean keyboard_mode, - GtkTooltip* tooltip) { +gboolean NativeWidgetGtk::OnQueryTooltip(GtkWidget* widget, + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip* tooltip) { return tooltip_manager_->ShowTooltip(x, y, keyboard_mode, tooltip); } -gboolean WidgetGtk::OnVisibilityNotify(GtkWidget* widget, - GdkEventVisibility* event) { +gboolean NativeWidgetGtk::OnVisibilityNotify(GtkWidget* widget, + GdkEventVisibility* event) { return false; } -gboolean WidgetGtk::OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) { +gboolean NativeWidgetGtk::OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) { HandleXGrabBroke(); return false; // To let other widgets get the event. } -void WidgetGtk::OnGrabNotify(GtkWidget* widget, gboolean was_grabbed) { +void NativeWidgetGtk::OnGrabNotify(GtkWidget* widget, gboolean was_grabbed) { if (!window_contents_) return; // Grab broke after window destroyed, don't try processing it. gtk_grab_remove(window_contents_); HandleGtkGrabBroke(); } -void WidgetGtk::OnDestroy(GtkWidget* object) { +void NativeWidgetGtk::OnDestroy(GtkWidget* object) { if (!child_) ActiveWindowWatcherX::RemoveObserver(this); // Note that this handler is hooked to GtkObject::destroy. - // NULL out pointers here since we might still be in an observerer list + // NULL out pointers here since we might still be in an observer list // until delstion happens. widget_ = window_contents_ = NULL; if (delete_on_destroy_) { - // Delays the deletion of this WidgetGtk as we want its children to have - // access to it when destroyed. + // Delays the deletion of this NativeWidgetGtk as we want its children to + // have access to it when destroyed. MessageLoop::current()->DeleteSoon(FROM_HERE, this); } } -void WidgetGtk::OnShow(GtkWidget* widget) { +void NativeWidgetGtk::OnShow(GtkWidget* widget) { } -void WidgetGtk::OnMap(GtkWidget* widget) { +void NativeWidgetGtk::OnMap(GtkWidget* widget) { #if defined(TOUCH_UI) // Force an expose event to trigger OnPaint for touch. This is // a workaround for a bug that X Expose event does not trigger @@ -1348,25 +1357,25 @@ void WidgetGtk::OnMap(GtkWidget* widget) { #endif } -void WidgetGtk::OnHide(GtkWidget* widget) { +void NativeWidgetGtk::OnHide(GtkWidget* widget) { } -void WidgetGtk::HandleXGrabBroke() { +void NativeWidgetGtk::HandleXGrabBroke() { } -void WidgetGtk::HandleGtkGrabBroke() { +void NativeWidgetGtk::HandleGtkGrabBroke() { delegate_->OnMouseCaptureLost(); } //////////////////////////////////////////////////////////////////////////////// -// WidgetGtk, private: +// NativeWidgetGtk, private: -gfx::AcceleratedWidget WidgetGtk::GetAcceleratedWidget() { +gfx::AcceleratedWidget NativeWidgetGtk::GetAcceleratedWidget() { DCHECK(window_contents_ && window_contents_->window); return GDK_WINDOW_XID(window_contents_->window); } -void WidgetGtk::DispatchKeyEventPostIME(const KeyEvent& key) { +void NativeWidgetGtk::DispatchKeyEventPostIME(const KeyEvent& key) { // Always reset |should_handle_menu_key_release_| unless we are handling a // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only // be activated when handling a VKEY_MENU key release event which is preceded @@ -1403,16 +1412,16 @@ void WidgetGtk::DispatchKeyEventPostIME(const KeyEvent& key) { gtk_bindings_activate_event(GTK_OBJECT(widget_), event); } -void WidgetGtk::SetInitParams(const Widget::InitParams& params) { +void NativeWidgetGtk::SetInitParams(const Widget::InitParams& params) { DCHECK(!GetNativeView()); delete_on_destroy_ = params.delete_on_destroy; child_ = params.child; // TODO(beng): The secondary checks here actually obviate the need for - // params.transient but that's only because WidgetGtk considers - // any top-level widget to be a transient widget. We will probably - // want to ammend this assumption at some point. + // params.transient but that's only because NativeWidgetGtk + // considers any top-level widget to be a transient widget. We + // will probably want to ammend this assumption at some point. if (params.transient || params.parent || params.parent_widget) transient_to_parent_ = true; if (params.transparent) @@ -1423,7 +1432,8 @@ void WidgetGtk::SetInitParams(const Widget::InitParams& params) { EnableDoubleBuffer(true); } -gboolean WidgetGtk::OnWindowPaint(GtkWidget* widget, GdkEventExpose* event) { +gboolean NativeWidgetGtk::OnWindowPaint(GtkWidget* widget, + GdkEventExpose* event) { // Clear the background to be totally transparent. We don't need to // paint the root view here as that is done by OnPaint. DCHECK(transparent_); @@ -1438,7 +1448,7 @@ gboolean WidgetGtk::OnWindowPaint(GtkWidget* widget, GdkEventExpose* event) { return false; } -void WidgetGtk::OnChildExpose(GtkWidget* child) { +void NativeWidgetGtk::OnChildExpose(GtkWidget* child) { DCHECK(!child_); if (!painted_) { painted_ = true; @@ -1448,23 +1458,23 @@ void WidgetGtk::OnChildExpose(GtkWidget* child) { } // static -gboolean WidgetGtk::ChildExposeHandler(GtkWidget* widget, - GdkEventExpose* event) { +gboolean NativeWidgetGtk::ChildExposeHandler(GtkWidget* widget, + GdkEventExpose* event) { GtkWidget* toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW); CHECK(toplevel); NativeWidget* native_widget = NativeWidget::GetNativeWidgetForNativeView(toplevel); CHECK(native_widget); - WidgetGtk* widget_gtk = static_cast<WidgetGtk*>(native_widget); + NativeWidgetGtk* widget_gtk = static_cast<NativeWidgetGtk*>(native_widget); widget_gtk->OnChildExpose(widget); return false; } // static -Window* WidgetGtk::GetWindowImpl(GtkWidget* widget) { +Window* NativeWidgetGtk::GetWindowImpl(GtkWidget* widget) { GtkWidget* parent = widget; while (parent) { - WidgetGtk* widget_gtk = static_cast<WidgetGtk*>( + NativeWidgetGtk* widget_gtk = static_cast<NativeWidgetGtk*>( NativeWidget::GetNativeWidgetForNativeView(parent)); if (widget_gtk && widget_gtk->is_window_) return static_cast<WindowGtk*>(widget_gtk)->GetWindow(); @@ -1473,7 +1483,7 @@ Window* WidgetGtk::GetWindowImpl(GtkWidget* widget) { return NULL; } -void WidgetGtk::CreateGtkWidget(const Widget::InitParams& params) { +void NativeWidgetGtk::CreateGtkWidget(const Widget::InitParams& params) { // We turn off double buffering for two reasons: // 1. We draw to a canvas then composite to the screen, which means we're // doing our own double buffering already. @@ -1537,14 +1547,14 @@ void WidgetGtk::CreateGtkWidget(const Widget::InitParams& params) { GTK_WIDGET_UNSET_FLAGS(widget_, GTK_DOUBLE_BUFFERED); // Gtk determines the size for windows based on the requested size of the - // child. For WidgetGtk the child is a fixed. If the fixed ends up with a - // child widget it's possible the child widget will drive the requested size - // of the widget, which we don't want. We explicitly set a value of 1x1 here - // so that gtk doesn't attempt to resize the window if we end up with a - // situation where the requested size of a child of the fixed is greater - // than the size of the window. By setting the size in this manner we're - // also allowing users of WidgetGtk to change the requested size at any - // time. + // child. For NativeWidgetGtk the child is a fixed. If the fixed ends up + // with a child widget it's possible the child widget will drive the + // requested size of the widget, which we don't want. We explicitly set a + // value of 1x1 here so that gtk doesn't attempt to resize the window if we + // end up with a situation where the requested size of a child of the fixed + // is greater than the size of the window. By setting the size in this + // manner we're also allowing users of WidgetGtk to change the requested + // size at any time. gtk_widget_set_size_request(widget_, 1, 1); if (!params.bounds.size().IsEmpty()) { @@ -1567,7 +1577,7 @@ void WidgetGtk::CreateGtkWidget(const Widget::InitParams& params) { gtk_container_add(GTK_CONTAINER(widget_), window_contents_); gtk_widget_show(window_contents_); g_object_set_data(G_OBJECT(window_contents_), kNativeWidgetKey, - static_cast<WidgetGtk*>(this)); + static_cast<NativeWidgetGtk*>(this)); if (transparent_) ConfigureWidgetForTransparentBackground(NULL); @@ -1587,7 +1597,8 @@ void WidgetGtk::CreateGtkWidget(const Widget::InitParams& params) { SetNativeWindowProperty(kNativeWidgetKey, this); } -void WidgetGtk::ConfigureWidgetForTransparentBackground(GtkWidget* parent) { +void NativeWidgetGtk::ConfigureWidgetForTransparentBackground( + GtkWidget* parent) { DCHECK(widget_ && window_contents_); GdkColormap* rgba_colormap = @@ -1617,7 +1628,7 @@ void WidgetGtk::ConfigureWidgetForTransparentBackground(GtkWidget* parent) { gtk_widget_set_colormap(window_contents_, rgba_colormap); } -void WidgetGtk::ConfigureWidgetForIgnoreEvents() { +void NativeWidgetGtk::ConfigureWidgetForIgnoreEvents() { gtk_widget_realize(widget_); GdkWindow* gdk_window = widget_->window; Display* display = GDK_WINDOW_XDISPLAY(gdk_window); @@ -1637,8 +1648,8 @@ void WidgetGtk::ConfigureWidgetForIgnoreEvents() { 0); } -void WidgetGtk::DrawTransparentBackground(GtkWidget* widget, - GdkEventExpose* event) { +void NativeWidgetGtk::DrawTransparentBackground(GtkWidget* widget, + GdkEventExpose* event) { cairo_t* cr = gdk_cairo_create(widget->window); cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); gdk_cairo_region(cr, event->region); @@ -1709,7 +1720,7 @@ bool Widget::ConvertRect(const Widget* source, // static NativeWidget* NativeWidget::CreateNativeWidget( internal::NativeWidgetDelegate* delegate) { - return new WidgetGtk(delegate); + return new NativeWidgetGtk(delegate); } // static @@ -1717,7 +1728,7 @@ NativeWidget* NativeWidget::GetNativeWidgetForNativeView( gfx::NativeView native_view) { if (!native_view) return NULL; - return reinterpret_cast<WidgetGtk*>( + return reinterpret_cast<NativeWidgetGtk*>( g_object_get_data(G_OBJECT(native_view), kNativeWidgetKey)); } @@ -1726,7 +1737,7 @@ NativeWidget* NativeWidget::GetNativeWidgetForNativeWindow( gfx::NativeWindow native_window) { if (!native_window) return NULL; - return reinterpret_cast<WidgetGtk*>( + return reinterpret_cast<NativeWidgetGtk*>( g_object_get_data(G_OBJECT(native_window), kNativeWidgetKey)); } diff --git a/views/widget/widget_gtk.h b/views/widget/native_widget_gtk.h index 54acfa6..7d75e12 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/native_widget_gtk.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef VIEWS_WIDGET_WIDGET_GTK_H_ -#define VIEWS_WIDGET_WIDGET_GTK_H_ +#ifndef VIEWS_WIDGET_NATIVE_WIDGET_GTK_H_ +#define VIEWS_WIDGET_NATIVE_WIDGET_GTK_H_ #pragma once #include <gtk/gtk.h> @@ -41,12 +41,12 @@ class NativeWidgetDelegate; } // Widget implementation for GTK. -class WidgetGtk : public NativeWidget, - public ui::ActiveWindowWatcherX::Observer, - public internal::InputMethodDelegate { +class NativeWidgetGtk : public NativeWidget, + public ui::ActiveWindowWatcherX::Observer, + public internal::InputMethodDelegate { public: - explicit WidgetGtk(internal::NativeWidgetDelegate* delegate); - virtual ~WidgetGtk(); + explicit NativeWidgetGtk(internal::NativeWidgetDelegate* delegate); + virtual ~NativeWidgetGtk(); // Returns the transient parent. See make_transient_to_parent for details on // what the transient parent is. @@ -82,10 +82,10 @@ class WidgetGtk : public NativeWidget, // Positions a child GtkWidget at the specified location and bounds. void PositionChild(GtkWidget* child, int x, int y, int w, int h); - // Parent GtkWidget all children are added to. When this WidgetGtk corresponds - // to a top level window, this is the GtkFixed within the GtkWindow, not the - // GtkWindow itself. For child widgets, this is the same GtkFixed as - // |widget_|. + // Parent GtkWidget all children are added to. When this NativeWidgetGtk + // corresponds to a top level window, this is the GtkFixed within the + // GtkWindow, not the GtkWindow itself. For child widgets, this is the same + // GtkFixed as |widget_|. GtkWidget* window_contents() const { return window_contents_; } // Starts a drag on this widget. This blocks until the drag is done. @@ -134,7 +134,7 @@ class WidgetGtk : public NativeWidget, // Registers a expose handler that removes FREEZE_UPDATES property. // If you are adding a GtkWidget with its own GdkWindow that may - // fill the entire area of the WidgetGtk to the view hierachy, you + // fill the entire area of the NativeWidgetGtk to the view hierachy, you // need use this function to tell WM that when the widget is ready // to be shown. // Caller of this method do not need to disconnect this because the @@ -205,42 +205,47 @@ class WidgetGtk : public NativeWidget, } // Event handlers: - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnButtonPress, GdkEventButton*); - CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnSizeRequest, GtkRequisition*); - CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnSizeAllocate, GtkAllocation*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnPaint, GdkEventExpose*); - CHROMEGTK_CALLBACK_4(WidgetGtk, void, OnDragDataGet, + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnButtonPress, + GdkEventButton*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, void, OnSizeRequest, GtkRequisition*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, void, OnSizeAllocate, GtkAllocation*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnPaint, GdkEventExpose*); + CHROMEGTK_CALLBACK_4(NativeWidgetGtk, void, OnDragDataGet, GdkDragContext*, GtkSelectionData*, guint, guint); - CHROMEGTK_CALLBACK_6(WidgetGtk, void, OnDragDataReceived, + CHROMEGTK_CALLBACK_6(NativeWidgetGtk, void, OnDragDataReceived, GdkDragContext*, gint, gint, GtkSelectionData*, guint, guint); - CHROMEGTK_CALLBACK_4(WidgetGtk, gboolean, OnDragDrop, + CHROMEGTK_CALLBACK_4(NativeWidgetGtk, gboolean, OnDragDrop, GdkDragContext*, gint, gint, guint); - CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnDragEnd, GdkDragContext*); - CHROMEGTK_CALLBACK_2(WidgetGtk, gboolean, OnDragFailed, + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, void, OnDragEnd, GdkDragContext*); + CHROMEGTK_CALLBACK_2(NativeWidgetGtk, gboolean, OnDragFailed, GdkDragContext*, GtkDragResult); - CHROMEGTK_CALLBACK_2(WidgetGtk, void, OnDragLeave, + CHROMEGTK_CALLBACK_2(NativeWidgetGtk, void, OnDragLeave, GdkDragContext*, guint); - CHROMEGTK_CALLBACK_4(WidgetGtk, gboolean, OnDragMotion, + CHROMEGTK_CALLBACK_4(NativeWidgetGtk, gboolean, OnDragMotion, GdkDragContext*, gint, gint, guint); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnEnterNotify, GdkEventCrossing*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnLeaveNotify, GdkEventCrossing*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnMotionNotify, GdkEventMotion*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnButtonRelease, GdkEventButton*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnFocusIn, GdkEventFocus*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnFocusOut, GdkEventFocus*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnEventKey, GdkEventKey*); - CHROMEGTK_CALLBACK_4(WidgetGtk, gboolean, OnQueryTooltip, + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnEnterNotify, + GdkEventCrossing*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnLeaveNotify, + GdkEventCrossing*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnMotionNotify, + GdkEventMotion*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnButtonRelease, + GdkEventButton*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnFocusIn, GdkEventFocus*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnFocusOut, GdkEventFocus*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnEventKey, GdkEventKey*); + CHROMEGTK_CALLBACK_4(NativeWidgetGtk, gboolean, OnQueryTooltip, gint, gint, gboolean, GtkTooltip*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnScroll, GdkEventScroll*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnVisibilityNotify, + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnScroll, GdkEventScroll*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnVisibilityNotify, GdkEventVisibility*); - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnGrabBrokeEvent, GdkEvent*); - CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnGrabNotify, gboolean); - CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnDestroy); - CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnShow); - CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnMap); - CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnHide); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnGrabBrokeEvent, GdkEvent*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, void, OnGrabNotify, gboolean); + CHROMEGTK_CALLBACK_0(NativeWidgetGtk, void, OnDestroy); + CHROMEGTK_CALLBACK_0(NativeWidgetGtk, void, OnShow); + CHROMEGTK_CALLBACK_0(NativeWidgetGtk, void, OnMap); + CHROMEGTK_CALLBACK_0(NativeWidgetGtk, void, OnHide); // Invoked when gtk grab is stolen by other GtkWidget in the same // application. @@ -266,7 +271,8 @@ class WidgetGtk : public NativeWidget, void SetInitParams(const Widget::InitParams& params); // This is called only when the window is transparent. - CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnWindowPaint, GdkEventExpose*); + CHROMEGTK_CALLBACK_1(NativeWidgetGtk, gboolean, OnWindowPaint, + GdkEventExpose*); // Callbacks for expose event on child widgets. See the description of // RegisterChildChildExposeHandler. @@ -318,7 +324,7 @@ class WidgetGtk : public NativeWidget, scoped_ptr<DropTargetGtk> drop_target_; // The following factory is used to delay destruction. - ScopedRunnableMethodFactory<WidgetGtk> close_widget_factory_; + ScopedRunnableMethodFactory<NativeWidgetGtk> close_widget_factory_; // See class documentation for Widget in widget.h for a note about ownership. bool delete_on_destroy_; @@ -397,9 +403,9 @@ class WidgetGtk : public NativeWidget, scoped_ptr<InputMethod> input_method_; - DISALLOW_COPY_AND_ASSIGN(WidgetGtk); + DISALLOW_COPY_AND_ASSIGN(NativeWidgetGtk); }; } // namespace views -#endif // VIEWS_WIDGET_WIDGET_GTK_H_ +#endif // VIEWS_WIDGET_NATIVE_WIDGET_GTK_H_ diff --git a/views/widget/native_widget_test_utils_win.cc b/views/widget/native_widget_test_utils_win.cc index fd89efe..5f70439 100644 --- a/views/widget/native_widget_test_utils_win.cc +++ b/views/widget/native_widget_test_utils_win.cc @@ -5,7 +5,8 @@ #include "views/widget/native_widget_test_utils.h" #include "views/view.h" -#include "views/widget/widget_win.h" +#include "views/widget/native_widget.h" +#include "views/widget/widget.h" namespace views { namespace internal { diff --git a/views/widget/native_widget_unittest.cc b/views/widget/native_widget_unittest.cc index 91c29a3..7370840 100644 --- a/views/widget/native_widget_unittest.cc +++ b/views/widget/native_widget_unittest.cc @@ -10,10 +10,6 @@ #include "views/widget/widget.h" #include "views/widget/native_widget_test_utils.h" -#if defined(TOOLKIT_USES_GTK) -#include "views/widget/widget_gtk.h" -#endif - namespace views { class ScopedTestWidget { diff --git a/views/widget/widget_win.cc b/views/widget/native_widget_win.cc index 3d3a2b7..4a0899d 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/native_widget_win.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "views/widget/widget_win.h" +#include "views/widget/native_widget_win.h" #include <dwmapi.h> @@ -127,12 +127,12 @@ const int kCustomObjectID = 1; } // namespace // static -bool WidgetWin::screen_reader_active_ = false; +bool NativeWidgetWin::screen_reader_active_ = false; //////////////////////////////////////////////////////////////////////////////// -// WidgetWin, public: +// NativeWidgetWin, public: -WidgetWin::WidgetWin(internal::NativeWidgetDelegate* delegate) +NativeWidgetWin::NativeWidgetWin(internal::NativeWidgetDelegate* delegate) : delegate_(delegate), close_widget_factory_(this), active_mouse_tracking_flags_(0), @@ -149,7 +149,7 @@ WidgetWin::WidgetWin(internal::NativeWidgetDelegate* delegate) is_input_method_win_(false) { } -WidgetWin::~WidgetWin() { +NativeWidgetWin::~NativeWidgetWin() { // We need to delete the input method before calling DestroyRootView(), // because it'll set focus_manager_ to NULL. input_method_.reset(); @@ -158,7 +158,7 @@ WidgetWin::~WidgetWin() { } // static -bool WidgetWin::IsAeroGlassEnabled() { +bool NativeWidgetWin::IsAeroGlassEnabled() { if (base::win::GetVersion() < base::win::VERSION_VISTA) return false; // If composition is not enabled, we behave like on XP. @@ -166,14 +166,14 @@ bool WidgetWin::IsAeroGlassEnabled() { return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; } -View* WidgetWin::GetAccessibilityViewEventAt(int id) { +View* NativeWidgetWin::GetAccessibilityViewEventAt(int id) { // Convert from MSAA child id. id = -(id + 1); DCHECK(id >= 0 && id < kMaxAccessibilityViewEvents); return accessibility_view_events_[id]; } -int WidgetWin::AddAccessibilityViewEvent(View* view) { +int NativeWidgetWin::AddAccessibilityViewEvent(View* view) { accessibility_view_events_index_ = (accessibility_view_events_index_ + 1) % kMaxAccessibilityViewEvents; accessibility_view_events_[accessibility_view_events_index_] = view; @@ -182,7 +182,7 @@ int WidgetWin::AddAccessibilityViewEvent(View* view) { return -(accessibility_view_events_index_ + 1); } -void WidgetWin::ClearAccessibilityViewEvent(View* view) { +void NativeWidgetWin::ClearAccessibilityViewEvent(View* view) { for (std::vector<View*>::iterator it = accessibility_view_events_.begin(); it != accessibility_view_events_.end(); ++it) { @@ -192,9 +192,9 @@ void WidgetWin::ClearAccessibilityViewEvent(View* view) { } //////////////////////////////////////////////////////////////////////////////// -// WidgetWin, NativeWidget implementation: +// NativeWidgetWin, NativeWidget implementation: -void WidgetWin::InitNativeWidget(const Widget::InitParams& params) { +void NativeWidgetWin::InitNativeWidget(const Widget::InitParams& params) { SetInitParams(params); // Create the window. @@ -203,38 +203,38 @@ void WidgetWin::InitNativeWidget(const Widget::InitParams& params) { WindowImpl::Init(parent, params.bounds); } -Widget* WidgetWin::GetWidget() { +Widget* NativeWidgetWin::GetWidget() { return delegate_->AsWidget(); } -const Widget* WidgetWin::GetWidget() const { +const Widget* NativeWidgetWin::GetWidget() const { return delegate_->AsWidget(); } -gfx::NativeView WidgetWin::GetNativeView() const { +gfx::NativeView NativeWidgetWin::GetNativeView() const { return WindowImpl::hwnd(); } -gfx::NativeWindow WidgetWin::GetNativeWindow() const { +gfx::NativeWindow NativeWidgetWin::GetNativeWindow() const { return WindowImpl::hwnd(); } -Window* WidgetWin::GetContainingWindow() { +Window* NativeWidgetWin::GetContainingWindow() { return GetWindowImpl(hwnd()); } -const Window* WidgetWin::GetContainingWindow() const { +const Window* NativeWidgetWin::GetContainingWindow() const { return GetWindowImpl(hwnd()); } -void WidgetWin::ViewRemoved(View* view) { +void NativeWidgetWin::ViewRemoved(View* view) { if (drop_target_.get()) drop_target_->ResetTargetViewIfEquals(view); ClearAccessibilityViewEvent(view); } -void WidgetWin::SetNativeWindowProperty(const char* name, void* value) { +void NativeWidgetWin::SetNativeWindowProperty(const char* name, void* value) { // Remove the existing property (if any). for (ViewProps::iterator i = props_.begin(); i != props_.end(); ++i) { if ((*i)->Key() == name) { @@ -247,19 +247,19 @@ void WidgetWin::SetNativeWindowProperty(const char* name, void* value) { props_.push_back(new ViewProp(hwnd(), name, value)); } -void* WidgetWin::GetNativeWindowProperty(const char* name) { +void* NativeWidgetWin::GetNativeWindowProperty(const char* name) { return ViewProp::GetValue(hwnd(), name); } -TooltipManager* WidgetWin::GetTooltipManager() const { +TooltipManager* NativeWidgetWin::GetTooltipManager() const { return tooltip_manager_.get(); } -bool WidgetWin::IsScreenReaderActive() const { +bool NativeWidgetWin::IsScreenReaderActive() const { return screen_reader_active_; } -void WidgetWin::SendNativeAccessibilityEvent( +void NativeWidgetWin::SendNativeAccessibilityEvent( View* view, ui::AccessibilityTypes::Event event_type) { // Now call the Windows-specific method to notify MSAA clients of this @@ -272,20 +272,20 @@ void WidgetWin::SendNativeAccessibilityEvent( GetNativeView(), OBJID_CLIENT, child_id); } -void WidgetWin::SetMouseCapture() { +void NativeWidgetWin::SetMouseCapture() { DCHECK(!HasMouseCapture()); SetCapture(hwnd()); } -void WidgetWin::ReleaseMouseCapture() { +void NativeWidgetWin::ReleaseMouseCapture() { ReleaseCapture(); } -bool WidgetWin::HasMouseCapture() const { +bool NativeWidgetWin::HasMouseCapture() const { return GetCapture() == hwnd(); } -bool WidgetWin::IsMouseButtonDown() const { +bool NativeWidgetWin::IsMouseButtonDown() const { return (GetKeyState(VK_LBUTTON) & 0x80) || (GetKeyState(VK_RBUTTON) & 0x80) || (GetKeyState(VK_MBUTTON) & 0x80) || @@ -293,11 +293,11 @@ bool WidgetWin::IsMouseButtonDown() const { (GetKeyState(VK_XBUTTON2) & 0x80); } -InputMethod* WidgetWin::GetInputMethodNative() { +InputMethod* NativeWidgetWin::GetInputMethodNative() { return input_method_.get(); } -void WidgetWin::ReplaceInputMethod(InputMethod* input_method) { +void NativeWidgetWin::ReplaceInputMethod(InputMethod* input_method) { input_method_.reset(input_method); if (input_method) { input_method->set_delegate(this); @@ -306,13 +306,13 @@ void WidgetWin::ReplaceInputMethod(InputMethod* input_method) { is_input_method_win_ = false; } -gfx::Rect WidgetWin::GetWindowScreenBounds() const { +gfx::Rect NativeWidgetWin::GetWindowScreenBounds() const { RECT r; GetWindowRect(&r); return gfx::Rect(r); } -gfx::Rect WidgetWin::GetClientAreaScreenBounds() const { +gfx::Rect NativeWidgetWin::GetClientAreaScreenBounds() const { RECT r; GetClientRect(&r); POINT point = { r.left, r.top }; @@ -320,7 +320,7 @@ gfx::Rect WidgetWin::GetClientAreaScreenBounds() const { return gfx::Rect(point.x, point.y, r.right - r.left, r.bottom - r.top); } -void WidgetWin::SetBounds(const gfx::Rect& bounds) { +void NativeWidgetWin::SetBounds(const gfx::Rect& bounds) { LONG style = GetWindowLong(GWL_STYLE); if (style & WS_MAXIMIZE) SetWindowLong(GWL_STYLE, style & ~WS_MAXIMIZE); @@ -328,21 +328,21 @@ void WidgetWin::SetBounds(const gfx::Rect& bounds) { SWP_NOACTIVATE | SWP_NOZORDER); } -void WidgetWin::SetSize(const gfx::Size& size) { +void NativeWidgetWin::SetSize(const gfx::Size& size) { SetWindowPos(NULL, 0, 0, size.width(), size.height(), SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); } -void WidgetWin::MoveAbove(gfx::NativeView native_view) { +void NativeWidgetWin::MoveAbove(gfx::NativeView native_view) { SetWindowPos(native_view, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); } -void WidgetWin::SetShape(gfx::NativeRegion region) { +void NativeWidgetWin::SetShape(gfx::NativeRegion region) { SetWindowRgn(region, TRUE); } -void WidgetWin::Close() { +void NativeWidgetWin::Close() { if (!IsWindow()) return; // No need to do anything. @@ -356,11 +356,11 @@ void WidgetWin::Close() { // dereference us when the callback returns). MessageLoop::current()->PostTask(FROM_HERE, close_widget_factory_.NewRunnableMethod( - &WidgetWin::CloseNow)); + &NativeWidgetWin::CloseNow)); } } -void WidgetWin::CloseNow() { +void NativeWidgetWin::CloseNow() { // Destroys the input method before closing the window so that it can be // detached from the widget correctly. input_method_.reset(); @@ -374,7 +374,7 @@ void WidgetWin::CloseNow() { DestroyWindow(hwnd()); } -void WidgetWin::Show() { +void NativeWidgetWin::Show() { if (!IsWindow()) return; @@ -382,7 +382,7 @@ void WidgetWin::Show() { SetInitialFocus(); } -void WidgetWin::Hide() { +void NativeWidgetWin::Hide() { if (IsWindow()) { // NOTE: Be careful not to activate any windows here (for example, calling // ShowWindow(SW_HIDE) will automatically activate another window). This @@ -394,43 +394,43 @@ void WidgetWin::Hide() { } } -void WidgetWin::SetOpacity(unsigned char opacity) { +void NativeWidgetWin::SetOpacity(unsigned char opacity) { layered_alpha_ = static_cast<BYTE>(opacity); } -void WidgetWin::SetAlwaysOnTop(bool on_top) { +void NativeWidgetWin::SetAlwaysOnTop(bool on_top) { if (on_top) set_window_ex_style(window_ex_style() | WS_EX_TOPMOST); else set_window_ex_style(window_ex_style() & ~WS_EX_TOPMOST); } -bool WidgetWin::IsVisible() const { +bool NativeWidgetWin::IsVisible() const { return !!::IsWindowVisible(hwnd()); } -bool WidgetWin::IsActive() const { +bool NativeWidgetWin::IsActive() const { return IsWindowActive(hwnd()); } -bool WidgetWin::IsAccessibleWidget() const { +bool NativeWidgetWin::IsAccessibleWidget() const { return screen_reader_active_; } -bool WidgetWin::ContainsNativeView(gfx::NativeView native_view) const { +bool NativeWidgetWin::ContainsNativeView(gfx::NativeView native_view) const { return hwnd() == native_view || ::IsChild(hwnd(), native_view); } -void WidgetWin::RunShellDrag(View* view, - const ui::OSExchangeData& data, - int operation) { +void NativeWidgetWin::RunShellDrag(View* view, + const ui::OSExchangeData& data, + int operation) { scoped_refptr<ui::DragSource> drag_source(new ui::DragSource); DWORD effects; DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source, ui::DragDropTypes::DragOperationToDropEffect(operation), &effects); } -void WidgetWin::SchedulePaintInRect(const gfx::Rect& rect) { +void NativeWidgetWin::SchedulePaintInRect(const gfx::Rect& rect) { if (use_layered_buffer_) { // We must update the back-buffer immediately, since Windows' handling of // invalid rects is somewhat mysterious. @@ -444,7 +444,7 @@ void WidgetWin::SchedulePaintInRect(const gfx::Rect& rect) { if (paint_layered_window_factory_.empty()) { MessageLoop::current()->PostTask(FROM_HERE, paint_layered_window_factory_.NewRunnableMethod( - &WidgetWin::RedrawLayeredWindowContents)); + &NativeWidgetWin::RedrawLayeredWindowContents)); } } else { // InvalidateRect() expects client coordinates. @@ -453,7 +453,7 @@ void WidgetWin::SchedulePaintInRect(const gfx::Rect& rect) { } } -void WidgetWin::SetCursor(gfx::NativeCursor cursor) { +void NativeWidgetWin::SetCursor(gfx::NativeCursor cursor) { if(cursor) { previous_cursor_ = ::SetCursor(cursor); } else if (previous_cursor_) { @@ -463,31 +463,32 @@ void WidgetWin::SetCursor(gfx::NativeCursor cursor) { } //////////////////////////////////////////////////////////////////////////////// -// WidgetWin, MessageLoop::Observer implementation: +// NativeWidgetWin, MessageLoop::Observer implementation: -void WidgetWin::WillProcessMessage(const MSG& msg) { +void NativeWidgetWin::WillProcessMessage(const MSG& msg) { } -void WidgetWin::DidProcessMessage(const MSG& msg) { +void NativeWidgetWin::DidProcessMessage(const MSG& msg) { RedrawInvalidRect(); } //////////////////////////////////////////////////////////////////////////////// -// WidgetWin, WindowImpl overrides: +// NativeWidgetWin, WindowImpl overrides: -HICON WidgetWin::GetDefaultWindowIcon() const { +HICON NativeWidgetWin::GetDefaultWindowIcon() const { if (ViewsDelegate::views_delegate) return ViewsDelegate::views_delegate->GetDefaultWindowIcon(); return NULL; } -LRESULT WidgetWin::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { +LRESULT NativeWidgetWin::OnWndProc(UINT message, WPARAM w_param, + LPARAM l_param) { HWND window = hwnd(); LRESULT result = 0; // First allow messages sent by child controls to be processed directly by // their associated views. If such a view is present, it will handle the - // message *instead of* this WidgetWin. + // message *instead of* this NativeWidgetWin. if (ProcessChildWindowMessage(message, w_param, l_param, &result)) return result; @@ -508,40 +509,44 @@ LRESULT WidgetWin::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { } //////////////////////////////////////////////////////////////////////////////// -// WidgetWin, protected: +// NativeWidgetWin, protected: // Message handlers ------------------------------------------------------------ -void WidgetWin::OnActivate(UINT action, BOOL minimized, HWND window) { +void NativeWidgetWin::OnActivate(UINT action, BOOL minimized, HWND window) { SetMsgHandled(FALSE); } -void WidgetWin::OnActivateApp(BOOL active, DWORD thread_id) { +void NativeWidgetWin::OnActivateApp(BOOL active, DWORD thread_id) { SetMsgHandled(FALSE); } -LRESULT WidgetWin::OnAppCommand(HWND window, short app_command, WORD device, - int keystate) { +LRESULT NativeWidgetWin::OnAppCommand(HWND window, + short app_command, + WORD device, + int keystate) { SetMsgHandled(FALSE); return 0; } -void WidgetWin::OnCancelMode() { +void NativeWidgetWin::OnCancelMode() { } -void WidgetWin::OnCaptureChanged(HWND hwnd) { +void NativeWidgetWin::OnCaptureChanged(HWND hwnd) { delegate_->OnMouseCaptureLost(); } -void WidgetWin::OnClose() { +void NativeWidgetWin::OnClose() { Close(); } -void WidgetWin::OnCommand(UINT notification_code, int command_id, HWND window) { +void NativeWidgetWin::OnCommand(UINT notification_code, + int command_id, + HWND window) { SetMsgHandled(FALSE); } -LRESULT WidgetWin::OnCreate(CREATESTRUCT* create_struct) { +LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) { SetNativeWindowProperty(kNativeWidgetKey, this); CHECK_EQ(this, GetNativeWidgetForNativeView(hwnd())); @@ -598,7 +603,7 @@ LRESULT WidgetWin::OnCreate(CREATESTRUCT* create_struct) { return 0; } -void WidgetWin::OnDestroy() { +void NativeWidgetWin::OnDestroy() { if (drop_target_.get()) { RevokeDragDrop(hwnd()); drop_target_ = NULL; @@ -607,40 +612,42 @@ void WidgetWin::OnDestroy() { props_.reset(); } -void WidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) { +void NativeWidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) { if (GetWidget()->widget_delegate()) GetWidget()->widget_delegate()->OnDisplayChanged(); } -LRESULT WidgetWin::OnDwmCompositionChanged(UINT msg, - WPARAM w_param, - LPARAM l_param) { +LRESULT NativeWidgetWin::OnDwmCompositionChanged(UINT msg, + WPARAM w_param, + LPARAM l_param) { SetMsgHandled(FALSE); return 0; } -void WidgetWin::OnEndSession(BOOL ending, UINT logoff) { +void NativeWidgetWin::OnEndSession(BOOL ending, UINT logoff) { SetMsgHandled(FALSE); } -void WidgetWin::OnEnterSizeMove() { +void NativeWidgetWin::OnEnterSizeMove() { SetMsgHandled(FALSE); } -LRESULT WidgetWin::OnEraseBkgnd(HDC dc) { +LRESULT NativeWidgetWin::OnEraseBkgnd(HDC dc) { // This is needed for magical win32 flicker ju-ju. return 1; } -void WidgetWin::OnExitMenuLoop(BOOL is_track_popup_menu) { +void NativeWidgetWin::OnExitMenuLoop(BOOL is_track_popup_menu) { SetMsgHandled(FALSE); } -void WidgetWin::OnExitSizeMove() { +void NativeWidgetWin::OnExitSizeMove() { SetMsgHandled(FALSE); } -LRESULT WidgetWin::OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param) { +LRESULT NativeWidgetWin::OnGetObject(UINT uMsg, + WPARAM w_param, + LPARAM l_param) { LRESULT reference_result = static_cast<LRESULT>(0L); // Accessibility readers will send an OBJID_CLIENT message @@ -667,15 +674,19 @@ LRESULT WidgetWin::OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param) { return reference_result; } -void WidgetWin::OnGetMinMaxInfo(MINMAXINFO* minmax_info) { +void NativeWidgetWin::OnGetMinMaxInfo(MINMAXINFO* minmax_info) { SetMsgHandled(FALSE); } -void WidgetWin::OnHScroll(int scroll_type, short position, HWND scrollbar) { +void NativeWidgetWin::OnHScroll(int scroll_type, + short position, + HWND scrollbar) { SetMsgHandled(FALSE); } -LRESULT WidgetWin::OnImeMessages(UINT message, WPARAM w_param, LPARAM l_param) { +LRESULT NativeWidgetWin::OnImeMessages(UINT message, + WPARAM w_param, + LPARAM l_param) { if (!is_input_method_win_) { SetMsgHandled(FALSE); return 0; @@ -714,24 +725,27 @@ LRESULT WidgetWin::OnImeMessages(UINT message, WPARAM w_param, LPARAM l_param) { return result; } -void WidgetWin::OnInitMenu(HMENU menu) { +void NativeWidgetWin::OnInitMenu(HMENU menu) { SetMsgHandled(FALSE); } -void WidgetWin::OnInitMenuPopup(HMENU menu, - UINT position, - BOOL is_system_menu) { +void NativeWidgetWin::OnInitMenuPopup(HMENU menu, + UINT position, + BOOL is_system_menu) { SetMsgHandled(FALSE); } -void WidgetWin::OnInputLangChange(DWORD character_set, HKL input_language_id) { +void NativeWidgetWin::OnInputLangChange(DWORD character_set, + HKL input_language_id) { if (is_input_method_win_) { static_cast<InputMethodWin*>(input_method_.get())->OnInputLangChange( character_set, input_language_id); } } -LRESULT WidgetWin::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { +LRESULT NativeWidgetWin::OnKeyEvent(UINT message, + WPARAM w_param, + LPARAM l_param) { MSG msg = { hwnd(), message, w_param, l_param }; KeyEvent key(msg); if (input_method_.get()) @@ -741,23 +755,25 @@ LRESULT WidgetWin::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { return 0; } -void WidgetWin::OnKillFocus(HWND focused_window) { +void NativeWidgetWin::OnKillFocus(HWND focused_window) { delegate_->OnNativeBlur(focused_window); if (input_method_.get()) input_method_->OnBlur(); SetMsgHandled(FALSE); } -LRESULT WidgetWin::OnMouseActivate(UINT message, - WPARAM w_param, - LPARAM l_param) { +LRESULT NativeWidgetWin::OnMouseActivate(UINT message, + WPARAM w_param, + LPARAM l_param) { if (GetWindowLong(GWL_EXSTYLE) & WS_EX_NOACTIVATE) return MA_NOACTIVATE; SetMsgHandled(FALSE); return MA_ACTIVATE; } -LRESULT WidgetWin::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) { +LRESULT NativeWidgetWin::OnMouseRange(UINT message, + WPARAM w_param, + LPARAM l_param) { MSG msg = { hwnd(), message, w_param, l_param, 0, { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) } }; MouseEvent event(msg); @@ -772,8 +788,9 @@ LRESULT WidgetWin::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) { TrackMouseEvents((message == WM_NCMOUSEMOVE) ? TME_NONCLIENT | TME_LEAVE : TME_LEAVE); } else if (event.type() == ui::ET_MOUSE_EXITED) { - // Reset our tracking flags so future mouse movement over this WidgetWin - // results in a new tracking session. Fall through for OnMouseEvent. + // Reset our tracking flags so future mouse movement over this + // NativeWidgetWin results in a new tracking session. Fall through for + // OnMouseEvent. active_mouse_tracking_flags_ = 0; } else if (event.type() == ui::ET_MOUSEWHEEL) { // Reroute the mouse wheel to the window under the pointer if applicable. @@ -785,51 +802,53 @@ LRESULT WidgetWin::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) { return 0; } -void WidgetWin::OnMove(const CPoint& point) { +void NativeWidgetWin::OnMove(const CPoint& point) { // TODO(beng): move to Widget. if (GetWidget()->widget_delegate()) GetWidget()->widget_delegate()->OnWidgetMove(); SetMsgHandled(FALSE); } -void WidgetWin::OnMoving(UINT param, const LPRECT new_bounds) { +void NativeWidgetWin::OnMoving(UINT param, const LPRECT new_bounds) { // TODO(beng): move to Widget. if (GetWidget()->widget_delegate()) GetWidget()->widget_delegate()->OnWidgetMove(); } -LRESULT WidgetWin::OnNCActivate(BOOL active) { +LRESULT NativeWidgetWin::OnNCActivate(BOOL active) { SetMsgHandled(FALSE); return 0; } -LRESULT WidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) { +LRESULT NativeWidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) { SetMsgHandled(FALSE); return 0; } -LRESULT WidgetWin::OnNCHitTest(const CPoint& pt) { +LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& pt) { SetMsgHandled(FALSE); return 0; } -void WidgetWin::OnNCPaint(HRGN rgn) { +void NativeWidgetWin::OnNCPaint(HRGN rgn) { SetMsgHandled(FALSE); } -LRESULT WidgetWin::OnNCUAHDrawCaption(UINT msg, - WPARAM w_param, - LPARAM l_param) { +LRESULT NativeWidgetWin::OnNCUAHDrawCaption(UINT msg, + WPARAM w_param, + LPARAM l_param) { SetMsgHandled(FALSE); return 0; } -LRESULT WidgetWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param) { +LRESULT NativeWidgetWin::OnNCUAHDrawFrame(UINT msg, + WPARAM w_param, + LPARAM l_param) { SetMsgHandled(FALSE); return 0; } -LRESULT WidgetWin::OnNotify(int w_param, NMHDR* l_param) { +LRESULT NativeWidgetWin::OnNotify(int w_param, NMHDR* l_param) { // We can be sent this message before the tooltip manager is created, if a // subclass overrides OnCreate and creates some kind of Windows control there // that sends WM_NOTIFY messages. @@ -843,7 +862,7 @@ LRESULT WidgetWin::OnNotify(int w_param, NMHDR* l_param) { return 0; } -void WidgetWin::OnPaint(HDC dc) { +void NativeWidgetWin::OnPaint(HDC dc) { RECT dirty_rect; // Try to paint accelerated first. if (GetUpdateRect(hwnd(), &dirty_rect, FALSE) && @@ -859,7 +878,7 @@ void WidgetWin::OnPaint(HDC dc) { } } -LRESULT WidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) { +LRESULT NativeWidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) { base::SystemMonitor* monitor = base::SystemMonitor::Get(); if (monitor) monitor->ProcessWmPowerBroadcastMessage(power_event); @@ -867,77 +886,81 @@ LRESULT WidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) { return 0; } -LRESULT WidgetWin::OnReflectedMessage(UINT msg, - WPARAM w_param, - LPARAM l_param) { +LRESULT NativeWidgetWin::OnReflectedMessage(UINT msg, + WPARAM w_param, + LPARAM l_param) { SetMsgHandled(FALSE); return 0; } -LRESULT WidgetWin::OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param) { +LRESULT NativeWidgetWin::OnSetCursor(UINT message, + WPARAM w_param, + LPARAM l_param) { SetMsgHandled(FALSE); return 0; } -void WidgetWin::OnSetFocus(HWND focused_window) { +void NativeWidgetWin::OnSetFocus(HWND focused_window) { delegate_->OnNativeFocus(focused_window); if (input_method_.get()) input_method_->OnFocus(); SetMsgHandled(FALSE); } -LRESULT WidgetWin::OnSetIcon(UINT size_type, HICON new_icon) { +LRESULT NativeWidgetWin::OnSetIcon(UINT size_type, HICON new_icon) { SetMsgHandled(FALSE); return 0; } -LRESULT WidgetWin::OnSetText(const wchar_t* text) { +LRESULT NativeWidgetWin::OnSetText(const wchar_t* text) { SetMsgHandled(FALSE); return 0; } -void WidgetWin::OnSettingChange(UINT flags, const wchar_t* section) { +void NativeWidgetWin::OnSettingChange(UINT flags, const wchar_t* section) { // TODO(beng): move to Widget. if (flags == SPI_SETWORKAREA && GetWidget()->widget_delegate()) GetWidget()->widget_delegate()->OnWorkAreaChanged(); SetMsgHandled(FALSE); } -void WidgetWin::OnSize(UINT param, const CSize& size) { +void NativeWidgetWin::OnSize(UINT param, const CSize& size) { SetMsgHandled(FALSE); } -void WidgetWin::OnSysCommand(UINT notification_code, CPoint click) { +void NativeWidgetWin::OnSysCommand(UINT notification_code, CPoint click) { } -void WidgetWin::OnThemeChanged() { +void NativeWidgetWin::OnThemeChanged() { // Notify NativeThemeWin. gfx::NativeThemeWin::instance()->CloseHandles(); } -void WidgetWin::OnVScroll(int scroll_type, short position, HWND scrollbar) { +void NativeWidgetWin::OnVScroll(int scroll_type, + short position, + HWND scrollbar) { SetMsgHandled(FALSE); } -void WidgetWin::OnWindowPosChanging(WINDOWPOS* window_pos) { +void NativeWidgetWin::OnWindowPosChanging(WINDOWPOS* window_pos) { SetMsgHandled(FALSE); } -void WidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) { +void NativeWidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) { if (DidClientAreaSizeChange(window_pos)) ClientAreaSizeChanged(); SetMsgHandled(FALSE); } -void WidgetWin::OnFinalMessage(HWND window) { +void NativeWidgetWin::OnFinalMessage(HWND window) { if (delete_on_destroy_) delete this; } //////////////////////////////////////////////////////////////////////////////// -// WidgetWin, protected: +// NativeWidgetWin, protected: -void WidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) { +void NativeWidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) { // Begin tracking mouse events for this HWND so that we get WM_MOUSELEAVE // when the user moves the mouse outside this HWND's bounds. if (active_mouse_tracking_flags_ == 0 || mouse_tracking_flags & TME_CANCEL) { @@ -961,11 +984,11 @@ void WidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) { } } -void WidgetWin::OnScreenReaderDetected() { +void NativeWidgetWin::OnScreenReaderDetected() { screen_reader_active_ = true; } -void WidgetWin::SetInitialFocus() { +void NativeWidgetWin::SetInitialFocus() { // TODO(beng): move to Widget. View* v = GetWidget()->widget_delegate() ? GetWidget()->widget_delegate()->GetInitiallyFocusedView() : NULL; @@ -974,16 +997,16 @@ void WidgetWin::SetInitialFocus() { } //////////////////////////////////////////////////////////////////////////////// -// WidgetWin, private: +// NativeWidgetWin, private: // static -Window* WidgetWin::GetWindowImpl(HWND hwnd) { +Window* NativeWidgetWin::GetWindowImpl(HWND hwnd) { // NOTE: we can't use GetAncestor here as constrained windows are a Window, // but not a top level window. HWND parent = hwnd; while (parent) { - WidgetWin* widget = - reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent)); + NativeWidgetWin* widget = + reinterpret_cast<NativeWidgetWin*>(ui::GetWindowUserData(parent)); if (widget && widget->is_window_) return static_cast<WindowWin*>(widget)->GetWindow(); parent = ::GetParent(parent); @@ -992,8 +1015,8 @@ Window* WidgetWin::GetWindowImpl(HWND hwnd) { } // static -void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, - int activation_state) { +void NativeWidgetWin::PostProcessActivateMessage(NativeWidgetWin* widget, + int activation_state) { if (!widget->delegate_->HasFocusManager()) { NOTREACHED(); return; @@ -1022,7 +1045,7 @@ void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, } } -void WidgetWin::SetInitParams(const Widget::InitParams& params) { +void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) { // Set non-style attributes. delete_on_destroy_ = params.delete_on_destroy; @@ -1069,7 +1092,7 @@ void WidgetWin::SetInitParams(const Widget::InitParams& params) { set_window_ex_style(window_ex_style() | ex_style); } -void WidgetWin::RedrawInvalidRect() { +void NativeWidgetWin::RedrawInvalidRect() { if (!use_layered_buffer_) { RECT r = { 0, 0, 0, 0 }; if (GetUpdateRect(hwnd(), &r, FALSE) && !IsRectEmpty(&r)) { @@ -1079,7 +1102,7 @@ void WidgetWin::RedrawInvalidRect() { } } -void WidgetWin::RedrawLayeredWindowContents() { +void NativeWidgetWin::RedrawLayeredWindowContents() { if (invalid_rect_.IsEmpty()) return; @@ -1105,7 +1128,7 @@ void WidgetWin::RedrawLayeredWindowContents() { layered_window_contents_->endPlatformPaint(); } -void WidgetWin::ClientAreaSizeChanged() { +void NativeWidgetWin::ClientAreaSizeChanged() { RECT r; Window* window = GetWidget()->GetContainingWindow(); if (IsZoomed() || (window && window->ShouldUseNativeFrame())) @@ -1121,12 +1144,12 @@ void WidgetWin::ClientAreaSizeChanged() { } } -gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { +gfx::AcceleratedWidget NativeWidgetWin::GetAcceleratedWidget() { // TODO(sky): return gfx::kNullAcceleratedWidget; } -void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { +void NativeWidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { SetMsgHandled(delegate_->OnKeyEvent(key)); } @@ -1184,13 +1207,13 @@ bool Widget::ConvertRect(const Widget* source, // static NativeWidget* NativeWidget::CreateNativeWidget( internal::NativeWidgetDelegate* delegate) { - return new WidgetWin(delegate); + return new NativeWidgetWin(delegate); } // static NativeWidget* NativeWidget::GetNativeWidgetForNativeView( gfx::NativeView native_view) { - return reinterpret_cast<WidgetWin*>( + return reinterpret_cast<NativeWidgetWin*>( ViewProp::GetValue(native_view, kNativeWidgetKey)); } diff --git a/views/widget/widget_win.h b/views/widget/native_widget_win.h index 79f3f49..72152fc 100644 --- a/views/widget/widget_win.h +++ b/views/widget/native_widget_win.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef VIEWS_WIDGET_WIDGET_WIN_H_ -#define VIEWS_WIDGET_WIDGET_WIN_H_ +#ifndef VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ +#define VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ #pragma once #include <atlbase.h> @@ -65,7 +65,7 @@ const int WM_NCUAHDRAWFRAME = 0xAF; /////////////////////////////////////////////////////////////////////////////// // -// WidgetWin +// NativeWidgetWin // A Widget for a views hierarchy used to represent anything that can be // contained within an HWND, e.g. a control, a window, etc. Specializations // suitable for specific tasks, e.g. top level window, are derived from this. @@ -76,13 +76,13 @@ const int WM_NCUAHDRAWFRAME = 0xAF; // then responsible for cleaning up after it. // /////////////////////////////////////////////////////////////////////////////// -class WidgetWin : public ui::WindowImpl, - public NativeWidget, - public MessageLoopForUI::Observer, - public internal::InputMethodDelegate { +class NativeWidgetWin : public ui::WindowImpl, + public NativeWidget, + public MessageLoopForUI::Observer, + public internal::InputMethodDelegate { public: - explicit WidgetWin(internal::NativeWidgetDelegate* delegate); - virtual ~WidgetWin(); + explicit NativeWidgetWin(internal::NativeWidgetDelegate* delegate); + virtual ~NativeWidgetWin(); // Returns true if we are on Windows Vista or greater and composition is // enabled. @@ -103,7 +103,7 @@ class WidgetWin : public ui::WindowImpl, // child id which is generated by: -(index of view in vector + 1) which // guarantees a negative child id. This distinguishes the view from // positive MSAA child id's which are direct leaf children of views that have - // associated hWnd's (e.g. WidgetWin). + // associated hWnd's (e.g. NativeWidgetWin). int AddAccessibilityViewEvent(View* view); // Clear a view that has recently been removed on a hierarchy change. @@ -222,7 +222,7 @@ class WidgetWin : public ui::WindowImpl, // Message Handlers ---------------------------------------------------------- - BEGIN_MSG_MAP_EX(WidgetWin) + BEGIN_MSG_MAP_EX(NativeWidgetWin) // Range handlers must go first! MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCXBUTTONDBLCLK, OnMouseRange) @@ -408,7 +408,7 @@ class WidgetWin : public ui::WindowImpl, // Called after the WM_ACTIVATE message has been processed by the default // windows procedure. - static void PostProcessActivateMessage(WidgetWin* widget, + static void PostProcessActivateMessage(NativeWidgetWin* widget, int activation_state); void SetInitParams(const Widget::InitParams& params); @@ -434,9 +434,9 @@ class WidgetWin : public ui::WindowImpl, // See class documentation for Widget in widget.h for a note about ownership. internal::NativeWidgetDelegate* delegate_; - // The following factory is used for calls to close the WidgetWin + // The following factory is used for calls to close the NativeWidgetWin // instance. - ScopedRunnableMethodFactory<WidgetWin> close_widget_factory_; + ScopedRunnableMethodFactory<NativeWidgetWin> close_widget_factory_; // The flags currently being used with TrackMouseEvent to track mouse // messages. 0 if there is no active tracking. The value of this member is @@ -472,7 +472,7 @@ class WidgetWin : public ui::WindowImpl, gfx::Rect invalid_rect_; // A factory that allows us to schedule a redraw for layered windows. - ScopedRunnableMethodFactory<WidgetWin> paint_layered_window_factory_; + ScopedRunnableMethodFactory<NativeWidgetWin> paint_layered_window_factory_; // See class documentation for Widget in widget.h for a note about ownership. bool delete_on_destroy_; @@ -513,9 +513,9 @@ class WidgetWin : public ui::WindowImpl, // Indicates if the |input_method_| is an InputMethodWin instance. bool is_input_method_win_; - DISALLOW_COPY_AND_ASSIGN(WidgetWin); + DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); }; } // namespace views -#endif // VIEWS_WIDGET_WIDGET_WIN_H_ +#endif // VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ diff --git a/views/widget/widget_win_unittest.cc b/views/widget/native_widget_win_unittest.cc index c9a33e8..cc59e75 100644 --- a/views/widget/widget_win_unittest.cc +++ b/views/widget/native_widget_win_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "views/widget/widget_win.h" +#include "views/widget/native_widget_win.h" #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" @@ -12,13 +12,13 @@ namespace views { namespace { -class WidgetWinTest : public testing::Test { +class NativeWidgetWinTest : public testing::Test { public: - WidgetWinTest() { + NativeWidgetWinTest() { OleInitialize(NULL); } - ~WidgetWinTest() { + ~NativeWidgetWinTest() { OleUninitialize(); } @@ -30,7 +30,7 @@ class WidgetWinTest : public testing::Test { // Create a simple widget win. The caller is responsible for taking ownership // of the returned value. - WidgetWin* CreateWidgetWin(); + NativeWidgetWin* CreateNativeWidgetWin(); void RunPendingMessages() { message_loop_.RunAllPending(); @@ -39,20 +39,20 @@ class WidgetWinTest : public testing::Test { private: MessageLoopForUI message_loop_; - DISALLOW_COPY_AND_ASSIGN(WidgetWinTest); + DISALLOW_COPY_AND_ASSIGN(NativeWidgetWinTest); }; -WidgetWin* WidgetWinTest::CreateWidgetWin() { +NativeWidgetWin* NativeWidgetWinTest::CreateNativeWidgetWin() { scoped_ptr<Widget> widget(new Widget); Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); params.delete_on_destroy = false; params.bounds = gfx::Rect(50, 50, 650, 650); widget->Init(params); - return static_cast<WidgetWin*>(widget.release()->native_widget()); + return static_cast<NativeWidgetWin*>(widget.release()->native_widget()); } -TEST_F(WidgetWinTest, ZoomWindow) { - scoped_ptr<WidgetWin> window(CreateWidgetWin()); +TEST_F(NativeWidgetWinTest, ZoomWindow) { + scoped_ptr<NativeWidgetWin> window(CreateNativeWidgetWin()); window->ShowWindow(SW_HIDE); EXPECT_FALSE(window->IsActive()); window->ShowWindow(SW_MAXIMIZE); @@ -60,13 +60,13 @@ TEST_F(WidgetWinTest, ZoomWindow) { window->CloseNow(); } -TEST_F(WidgetWinTest, SetBoundsForZoomedWindow) { - scoped_ptr<WidgetWin> window(CreateWidgetWin()); +TEST_F(NativeWidgetWinTest, SetBoundsForZoomedWindow) { + scoped_ptr<NativeWidgetWin> window(CreateNativeWidgetWin()); window->ShowWindow(SW_MAXIMIZE); EXPECT_TRUE(window->IsZoomed()); // Create another window, so that it will be active. - scoped_ptr<WidgetWin> window2(CreateWidgetWin()); + scoped_ptr<NativeWidgetWin> window2(CreateNativeWidgetWin()); window2->ShowWindow(SW_MAXIMIZE); EXPECT_TRUE(window2->IsActive()); EXPECT_FALSE(window->IsActive()); diff --git a/views/widget/tooltip_manager_gtk.cc b/views/widget/tooltip_manager_gtk.cc index 7c8c0dd..909dc57 100644 --- a/views/widget/tooltip_manager_gtk.cc +++ b/views/widget/tooltip_manager_gtk.cc @@ -9,8 +9,8 @@ #include "ui/gfx/font.h" #include "views/focus/focus_manager.h" #include "views/screen.h" +#include "views/widget/native_widget_gtk.h" #include "views/widget/root_view.h" -#include "views/widget/widget_gtk.h" // WARNING: this implementation is good for a start, but it doesn't give us // control of tooltip positioning both on mouse events and when showing from @@ -71,7 +71,7 @@ int TooltipManager::GetMaxWidth(int x, int y) { return monitor_bounds.width() == 0 ? 800 : (monitor_bounds.width() + 1) / 2; } -TooltipManagerGtk::TooltipManagerGtk(WidgetGtk* widget) +TooltipManagerGtk::TooltipManagerGtk(NativeWidgetGtk* widget) : widget_(widget), keyboard_view_(NULL), tooltip_window_(widget->window_contents()) { diff --git a/views/widget/tooltip_manager_gtk.h b/views/widget/tooltip_manager_gtk.h index 0eb4aba..7ced5f3 100644 --- a/views/widget/tooltip_manager_gtk.h +++ b/views/widget/tooltip_manager_gtk.h @@ -13,12 +13,12 @@ namespace views { -class WidgetGtk; +class NativeWidgetGtk; // TooltipManager implementation for Gtk. class TooltipManagerGtk : public TooltipManager { public: - explicit TooltipManagerGtk(WidgetGtk* widget); + explicit TooltipManagerGtk(NativeWidgetGtk* widget); virtual ~TooltipManagerGtk() {} // Shows the tooltip at the specified location. Returns true if the tooltip @@ -37,7 +37,7 @@ class TooltipManagerGtk : public TooltipManager { bool SendShowHelpSignal(); // Our owner. - WidgetGtk* widget_; + NativeWidgetGtk* widget_; // The view supplied to the last invocation of ShowKeyboardTooltip. View* keyboard_view_; diff --git a/views/widget/tooltip_manager_win.h b/views/widget/tooltip_manager_win.h index d6a9a35..881ce20 100644 --- a/views/widget/tooltip_manager_win.h +++ b/views/widget/tooltip_manager_win.h @@ -28,7 +28,7 @@ class Widget; // TooltipManager implementation for Windows. // -// This class is intended to be used by WidgetWin. To use this, you must +// This class is intended to be used by NativeWidgetWin. To use this, you must // do the following: // Add the following to your MSG_MAP: // @@ -55,7 +55,7 @@ class Widget; // // Lastly, you'll need to override GetTooltipManager. // -// See WidgetWin for an example of this in action. +// See NativeWidgetWin for an example of this in action. class TooltipManagerWin : public TooltipManager { public: // Creates a TooltipManager for the specified Widget and parent window. diff --git a/views/widget/widget.cc b/views/widget/widget.cc index e02f8f9d..6e1e693 100644 --- a/views/widget/widget.cc +++ b/views/widget/widget.cc @@ -476,12 +476,12 @@ void Widget::DestroyRootView() { root_view_.reset(); // Defer focus manager's destruction. This is for the case when the - // focus manager is referenced by a child WidgetGtk (e.g. TabbedPane in a - // dialog). When gtk_widget_destroy is called on the parent, the destroy + // focus manager is referenced by a child NativeWidgetGtk (e.g. TabbedPane in + // a dialog). When gtk_widget_destroy is called on the parent, the destroy // signal reaches parent first and then the child. Thus causing the parent - // WidgetGtk's dtor executed before the child's. If child's view hierarchy - // references this focus manager, it crashes. This will defer focus manager's - // destruction after child WidgetGtk's dtor. + // NativeWidgetGtk's dtor executed before the child's. If child's view + // hierarchy references this focus manager, it crashes. This will defer focus + // manager's destruction after child NativeWidgetGtk's dtor. FocusManager* focus_manager = focus_manager_.release(); if (focus_manager) MessageLoop::current()->DeleteSoon(FROM_HERE, focus_manager); diff --git a/views/widget/widget.h b/views/widget/widget.h index 13d7b5b..f7c12ae 100644 --- a/views/widget/widget.h +++ b/views/widget/widget.h @@ -328,15 +328,15 @@ class Widget : public internal::NativeWidgetDelegate, virtual View* GetFocusTraversableParentView() OVERRIDE; protected: - // TODO(beng): Remove WidgetGtk's dependence on the mouse state flags. - friend class WidgetGtk; + // TODO(beng): Remove NativeWidgetGtk's dependence on the mouse state flags. + friend class NativeWidgetGtk; // Creates the RootView to be used within this Widget. Subclasses may override // to create custom RootViews that do specialized event processing. // TODO(beng): Investigate whether or not this is needed. virtual RootView* CreateRootView(); - // Provided to allow the WidgetWin/Gtk implementations to destroy the RootView + // Provided to allow the NativeWidget implementations to destroy the RootView // _before_ the focus manager/tooltip manager. // TODO(beng): remove once we fold those objects onto this one. void DestroyRootView(); @@ -344,12 +344,12 @@ class Widget : public internal::NativeWidgetDelegate, // Used for testing. void ReplaceFocusManager(FocusManager* focus_manager); - // TODO(beng): Remove WidgetGtk's dependence on these: + // TODO(beng): Remove NativeWidgetGtk's dependence on these: // TODO(msw): Make this mouse state member private. // If true, the mouse is currently down. bool is_mouse_button_pressed_; - // TODO(beng): Remove WidgetGtk's dependence on these: + // TODO(beng): Remove NativeWidgetGtk's dependence on these: // TODO(msw): Make these mouse state members private. // The following are used to detect duplicate mouse move events and not // deliver them. Displaying a window may result in the system generating |