diff options
Diffstat (limited to 'views')
24 files changed, 107 insertions, 2679 deletions
diff --git a/views/controls/combobox/native_combobox_wayland.cc b/views/controls/combobox/native_combobox_wayland.cc deleted file mode 100644 index c54b068..0000000 --- a/views/controls/combobox/native_combobox_wayland.cc +++ /dev/null @@ -1,15 +0,0 @@ -// 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. - -#include "views/controls/combobox/native_combobox_views.h" - -namespace views { - -// static -NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( - Combobox* combobox) { - return new NativeComboboxViews(combobox); -} - -} // namespace views diff --git a/views/controls/native/native_view_host.cc b/views/controls/native/native_view_host.cc index 0981b9d..e8c5710 100644 --- a/views/controls/native/native_view_host.cc +++ b/views/controls/native/native_view_host.cc @@ -6,7 +6,6 @@ #include "base/logging.h" #include "ui/gfx/canvas.h" -#include "views/controls/native/native_view_host_views.h" #include "views/controls/native/native_view_host_wrapper.h" #include "views/widget/widget.h" @@ -29,7 +28,6 @@ const bool NativeViewHost::kRenderNativeControlFocus = true; NativeViewHost::NativeViewHost() : native_view_(NULL), - views_view_(NULL), fast_resize_(false), fast_resize_at_last_layout_(false), focus_view_(NULL) { @@ -41,7 +39,6 @@ NativeViewHost::~NativeViewHost() { void NativeViewHost::Attach(gfx::NativeView native_view) { DCHECK(native_view); DCHECK(!native_view_); - DCHECK(!views_view_); native_view_ = native_view; // If set_focus_view() has not been invoked, this view is the one that should // be seen as focused when the native view receives focus. @@ -50,21 +47,6 @@ void NativeViewHost::Attach(gfx::NativeView native_view) { native_wrapper_->NativeViewAttached(); } -void NativeViewHost::AttachToView(View* view) { - if (view == views_view_) - return; - DCHECK(view); - DCHECK(!native_view_); - DCHECK(!views_view_); - native_wrapper_.reset(new NativeViewHostViews(this)); - views_view_ = view; - // If set_focus_view() has not been invoked, this view is the one that should - // be seen as focused when the native view receives focus. - if (!focus_view_) - focus_view_ = this; - native_wrapper_->NativeViewAttached(); -} - void NativeViewHost::Detach() { Detach(false); } @@ -88,7 +70,7 @@ gfx::Size NativeViewHost::GetPreferredSize() { } void NativeViewHost::Layout() { - if ((!native_view_ && !views_view_) || !native_wrapper_.get()) + if (!native_view_ || !native_wrapper_.get()) return; gfx::Rect vis_bounds = GetVisibleBounds(); @@ -197,10 +179,9 @@ gfx::NativeViewAccessible NativeViewHost::GetNativeViewAccessible() { // NativeViewHost, private: void NativeViewHost::Detach(bool destroyed) { - if (native_view_ || views_view_) { + if (native_view_) { native_wrapper_->NativeViewDetaching(destroyed); native_view_ = NULL; - views_view_ = NULL; } } diff --git a/views/controls/native/native_view_host.h b/views/controls/native/native_view_host.h index 94315be..a7a9c93 100644 --- a/views/controls/native/native_view_host.h +++ b/views/controls/native/native_view_host.h @@ -38,9 +38,6 @@ class VIEWS_EXPORT NativeViewHost : public View { // added to a View hierarchy hosted within a valid Widget. void Attach(gfx::NativeView native_view); - // Attach a views::View instead of a native view to this host. - void AttachToView(View* view); - // Detach the attached native view. Its bounds and visibility will no // longer be manipulated by this View. The native view may be destroyed and // detached before calling this function, and this has no effect in that case. @@ -76,9 +73,6 @@ class VIEWS_EXPORT NativeViewHost : public View { // Accessor for |native_view_|. gfx::NativeView native_view() const { return native_view_; } - // Accessor for |views_view_|. - View* views_view() const { return views_view_; } - void NativeViewDestroyed(); // Overridden from View: @@ -104,11 +98,6 @@ class VIEWS_EXPORT NativeViewHost : public View { // attached. gfx::NativeView native_view_; - // The attached view. There is exactly one native_view_ or views_view_ - // attached. - // TODO(oshima): Delete views_view_ once TOUCH_UI migrates to aura. - View* views_view_; - // A platform-specific wrapper that does the OS-level manipulation of the // attached gfx::NativeView. scoped_ptr<NativeViewHostWrapper> native_wrapper_; diff --git a/views/controls/native/native_view_host_gtk.cc b/views/controls/native/native_view_host_gtk.cc index cdb8290..85ad105 100644 --- a/views/controls/native/native_view_host_gtk.cc +++ b/views/controls/native/native_view_host_gtk.cc @@ -10,7 +10,6 @@ #include "base/logging.h" #include "views/controls/native/native_view_host.h" -#include "views/controls/native/native_view_host_views.h" #include "ui/views/focus/focus_manager.h" #include "views/views_delegate.h" #include "views/widget/gtk_views_fixed.h" @@ -405,9 +404,6 @@ gboolean NativeViewHostGtk::CallFocusIn(GtkWidget* gtk_widget, // static NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( NativeViewHost* host) { - if (Widget::IsPureViews() && - views::ViewsDelegate::views_delegate->GetDefaultParentView()) - return new NativeViewHostViews(host); return new NativeViewHostGtk(host); } diff --git a/views/controls/native/native_view_host_views.cc b/views/controls/native/native_view_host_views.cc deleted file mode 100644 index 56e6e37..0000000 --- a/views/controls/native/native_view_host_views.cc +++ /dev/null @@ -1,82 +0,0 @@ -// 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. - -#include "views/controls/native/native_view_host_views.h" - -#include "base/logging.h" -#include "ui/gfx/canvas.h" -#include "ui/views/focus/focus_manager.h" -#include "views/controls/native/native_view_host.h" -#include "views/widget/root_view.h" -#include "views/widget/widget.h" - -namespace views { - -//////////////////////////////////////////////////////////////////////////////// -// NativeViewHostViews, public: - -NativeViewHostViews::NativeViewHostViews(NativeViewHost* host) - : host_(host), - installed_clip_(false) { -} - -NativeViewHostViews::~NativeViewHostViews() { - NOTIMPLEMENTED(); -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeViewHostViews, NativeViewHostWrapper implementation: -void NativeViewHostViews::NativeViewAttached() { - host_->AddChildView(host_->views_view()); - host_->Layout(); -} - -void NativeViewHostViews::NativeViewDetaching(bool destroyed) { - host_->RemoveChildView(host_->views_view()); -} - -void NativeViewHostViews::AddedToWidget() { - // nothing to do -} - -void NativeViewHostViews::RemovedFromWidget() { - // nothing to do -} - -void NativeViewHostViews::InstallClip(int x, int y, int w, int h) { - NOTIMPLEMENTED(); -} - -bool NativeViewHostViews::HasInstalledClip() { - return installed_clip_; -} - -void NativeViewHostViews::UninstallClip() { - installed_clip_ = false; -} - -void NativeViewHostViews::ShowWidget(int x, int y, int w, int h) { - // x, y are in the coordinate system of the root view, but we're - // already properly positioned by virtue of being an actual views - // child of the NativeHostView, so disregard the origin. - // It is important to update the visibility first, so that when the bounds is - // set, the contents get notified of the resize (because resizing a hidden - // views may not actually resize the contents). - host_->views_view()->SetVisible(true); - host_->views_view()->SetBounds(0, 0, w, h); -} - -void NativeViewHostViews::HideWidget() { - host_->views_view()->SetVisible(false); -} - -void NativeViewHostViews::SetFocus() { - host_->views_view()->RequestFocus(); -} - -gfx::NativeViewAccessible NativeViewHostViews::GetNativeViewAccessible() { - return NULL; -} - -} // namespace views diff --git a/views/controls/native/native_view_host_views.h b/views/controls/native/native_view_host_views.h deleted file mode 100644 index cd9f96b..0000000 --- a/views/controls/native/native_view_host_views.h +++ /dev/null @@ -1,47 +0,0 @@ -// 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_CONTROLS_NATIVE_NATIVE_VIEW_HOST_VIEWS_H_ -#define VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_VIEWS_H_ -#pragma once - -#include "base/basictypes.h" -#include "views/controls/native/native_view_host_wrapper.h" - -namespace views { - -class NativeViewHost; - -// A Views implementation of NativeViewHostWrapper -class NativeViewHostViews : public NativeViewHostWrapper { - public: - explicit NativeViewHostViews(NativeViewHost* host); - virtual ~NativeViewHostViews(); - - // Overridden from NativeViewHostWrapper: - virtual void NativeViewAttached(); - virtual void NativeViewDetaching(bool destroyed); - virtual void AddedToWidget(); - virtual void RemovedFromWidget(); - virtual void InstallClip(int x, int y, int w, int h); - virtual bool HasInstalledClip(); - virtual void UninstallClip(); - virtual void ShowWidget(int x, int y, int w, int h); - virtual void HideWidget(); - virtual void SetFocus(); - virtual gfx::NativeViewAccessible GetNativeViewAccessible(); - - private: - // Our associated NativeViewHost. - NativeViewHost* host_; - - // Have we installed a clip region? - bool installed_clip_; - - DISALLOW_COPY_AND_ASSIGN(NativeViewHostViews); -}; - -} // namespace views - -#endif // VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_VIEWS_H_ diff --git a/views/controls/native/native_view_host_wayland.cc b/views/controls/native/native_view_host_wayland.cc deleted file mode 100644 index 11e6a2b..0000000 --- a/views/controls/native/native_view_host_wayland.cc +++ /dev/null @@ -1,16 +0,0 @@ -// 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. - -#include "views/controls/native/native_view_host.h" -#include "views/controls/native/native_view_host_views.h" - -namespace views { - -// static -NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( - NativeViewHost* host) { - return new NativeViewHostViews(host); -} - -} // namespace views diff --git a/views/metrics_wayland.cc b/views/metrics_wayland.cc deleted file mode 100644 index 7d3beb1..0000000 --- a/views/metrics_wayland.cc +++ /dev/null @@ -1,17 +0,0 @@ -// 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. - -#include "views/metrics.h" - -namespace views { - -int GetDoubleClickInterval() { - return 500; -} - -int GetMenuShowDelay() { - return kDefaultMenuShowDelay; -} - -} // namespace views diff --git a/views/view.cc b/views/view.cc index 301138c..152e416 100644 --- a/views/view.cc +++ b/views/view.cc @@ -29,7 +29,6 @@ #include "views/drag_controller.h" #include "views/views_delegate.h" #include "views/widget/native_widget_private.h" -#include "views/widget/native_widget_views.h" #include "views/widget/root_view.h" #include "views/widget/tooltip_manager.h" #include "views/widget/widget.h" diff --git a/views/view_unittest.cc b/views/view_unittest.cc index cdcf545..eac26ed 100644 --- a/views/view_unittest.cc +++ b/views/view_unittest.cc @@ -2949,54 +2949,6 @@ TEST_F(ViewLayerTest, OrphanLayerAfterViewRemove) { EXPECT_TRUE(v2->layer()->IsDrawn()); } -// TODO(sky): reenable once focus issues are straightened out so that this -// doesn't crash. -TEST_F(ViewLayerTest, DISABLED_NativeWidgetView) { - View* content_view = new View; - widget()->SetContentsView(content_view); - View* view = new View; - content_view->AddChildView(view); - view->SetBounds(10, 20, 300, 400); - - views_delegate().set_default_parent_view(view); - Widget::SetPureViews(true); - scoped_ptr<Widget> child_widget(new Widget); - Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); - params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - params.bounds = gfx::Rect(1, 2, 100, 200); - child_widget->Init(params); - - // NativeWidgetView should have been added to view. - ASSERT_EQ(1, view->child_count()); - View* widget_view_host = view->child_at(0); - ASSERT_TRUE(widget_view_host->layer() != NULL); - EXPECT_EQ(gfx::Rect(11, 22, 100, 200), widget_view_host->layer()->bounds()); - - View* widget_content_view = new View; - child_widget->SetContentsView(widget_content_view); - View* child_view = new View; - child_view->SetPaintToLayer(true); - child_view->SetBounds(5, 6, 10, 11); - widget_content_view->AddChildView(child_view); - - ASSERT_TRUE(child_view->layer() != NULL); - EXPECT_EQ(gfx::Rect(5, 6, 10, 11), child_view->layer()->bounds()); - - widget_view_host->SetPaintToLayer(false); - EXPECT_TRUE(widget_view_host->layer() == NULL); - - ASSERT_TRUE(child_view->layer() != NULL); - EXPECT_EQ(gfx::Rect(16, 28, 10, 11), child_view->layer()->bounds()); - - widget_view_host->SetPaintToLayer(true); - ASSERT_TRUE(widget_view_host->layer() != NULL); - EXPECT_EQ(gfx::Rect(11, 22, 100, 200), widget_view_host->layer()->bounds()); - ASSERT_TRUE(child_view->layer() != NULL); - EXPECT_EQ(gfx::Rect(5, 6, 10, 11), child_view->layer()->bounds()); - - child_widget->CloseNow(); -} - class PaintTrackingView : public View { public: PaintTrackingView() : painted_(false) { diff --git a/views/view_wayland.cc b/views/view_wayland.cc deleted file mode 100644 index 7524858..0000000 --- a/views/view_wayland.cc +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -#include "views/view.h" - -#include "base/logging.h" - -namespace views { - -gfx::NativeViewAccessible View::GetNativeViewAccessible() { - NOTIMPLEMENTED(); - return NULL; -} - -int View::GetHorizontalDragThreshold() { - return 8; -} - -int View::GetVerticalDragThreshold() { - return GetHorizontalDragThreshold(); -} - -} // namespace views diff --git a/views/views.gyp b/views/views.gyp index 6a183c1..ce53e67 100644 --- a/views/views.gyp +++ b/views/views.gyp @@ -24,11 +24,6 @@ ['exclude', '_x\\.(h|cc)$'] ], 'dependencies': [ '../ui/aura/aura.gyp:aura', ], }], - ['use_wayland == 1', { - 'dependencies': [ - '../build/linux/system.gyp:wayland', - ], - }], ], }, 'targets': [ @@ -84,7 +79,6 @@ 'controls/combobox/native_combobox_gtk.h', 'controls/combobox/native_combobox_views.cc', 'controls/combobox/native_combobox_views.h', - 'controls/combobox/native_combobox_wayland.cc', 'controls/combobox/native_combobox_win.cc', 'controls/combobox/native_combobox_win.h', 'controls/combobox/native_combobox_wrapper.h', @@ -167,10 +161,6 @@ 'controls/native/native_view_host_gtk.h', 'controls/native/native_view_host_win.cc', 'controls/native/native_view_host_win.h', - 'controls/native/native_view_host_views.cc', - 'controls/native/native_view_host_views.h', - 'controls/native/native_view_host_wayland.cc', - 'controls/native/native_view_host_wrapper.h', 'controls/progress_bar.h', 'controls/progress_bar.cc', 'controls/resize_area.cc', @@ -233,7 +223,6 @@ 'controls/textfield/textfield_views_model.h', 'controls/textfield/native_textfield_gtk.cc', 'controls/textfield/native_textfield_gtk.h', - 'controls/textfield/native_textfield_wayland.cc', 'controls/textfield/native_textfield_win.cc', 'controls/textfield/native_textfield_win.h', 'controls/textfield/native_textfield_wrapper.h', @@ -255,7 +244,6 @@ 'metrics.h', 'metrics_aura.cc', 'metrics_gtk.cc', - 'metrics_wayland.cc', 'metrics_win.cc', 'mouse_watcher.cc', 'mouse_watcher.h', @@ -276,7 +264,6 @@ 'view_gtk.cc', 'view_text_utils.cc', 'view_text_utils.h', - 'view_wayland.cc', 'view_win.cc', 'views_delegate.h', 'widget/aero_tooltip_manager.cc', @@ -314,12 +301,6 @@ 'widget/native_widget_private.h', 'widget/native_widget_gtk.cc', 'widget/native_widget_gtk.h', - 'widget/native_widget_wayland.cc', - 'widget/native_widget_wayland.h', - 'widget/native_widget_view.cc', - 'widget/native_widget_view.h', - 'widget/native_widget_views.cc', - 'widget/native_widget_views.h', 'widget/native_widget_win.cc', 'widget/native_widget_win.h', 'widget/widget.cc', @@ -344,14 +325,11 @@ '../ui/views/events/event.h', '../ui/views/events/event_aura.cc', '../ui/views/events/event_gtk.cc', - '../ui/views/events/event_wayland.cc', '../ui/views/events/event_win.cc', '../ui/views/events/event_x.cc', '../ui/views/focus/accelerator_handler.h', '../ui/views/focus/accelerator_handler_aura.cc', '../ui/views/focus/accelerator_handler_gtk.cc', - '../ui/views/focus/accelerator_handler_touch.cc', - '../ui/views/focus/accelerator_handler_wayland.cc', '../ui/views/focus/accelerator_handler_win.cc', '../ui/views/focus/external_focus_tracker.cc', '../ui/views/focus/external_focus_tracker.h', @@ -373,8 +351,6 @@ '../ui/views/ime/input_method.h', '../ui/views/ime/input_method_ibus.cc', '../ui/views/ime/input_method_ibus.h', - '../ui/views/ime/input_method_wayland.cc', - '../ui/views/ime/input_method_wayland.h', '../ui/views/ime/input_method_win.cc', '../ui/views/ime/input_method_win.h', '../ui/views/ime/mock_input_method.cc', @@ -416,20 +392,6 @@ '../third_party/wtl/include', ], 'conditions': [ - ['use_wayland == 1', { - 'dependencies': [ - '../ui/wayland/wayland.gyp:wayland', - ], - 'sources/': [ - ['exclude', '_(gtk|x)\\.cc$'], - ['exclude', '/(gtk|x)_[^/]*\\.cc$'], - ['exclude', '../ui/views/focus/accelerator_handler_touch.cc'], - ['include', 'controls/menu/native_menu_views.cc'], - ['include', 'controls/menu/native_menu_views.h'], - ['include', 'drag_utils_gtk.cc'], - ['include', 'widget/tooltip_manager_views.cc'], - ], - }], ['use_aura==1', { 'sources/': [ ['exclude', '_(gtk|x)\\.cc$'], @@ -437,7 +399,6 @@ ['exclude', 'controls/menu/menu_2.*'], ], 'sources!': [ - '../ui/views/focus/accelerator_handler_touch.cc', 'controls/menu/menu_config_linux.cc', 'controls/menu/menu_item_view_linux.cc', 'controls/menu/menu_separator_linux.cc', @@ -702,8 +663,6 @@ '../ui/views/examples/native_theme_button_example.h', '../ui/views/examples/native_theme_checkbox_example.cc', '../ui/views/examples/native_theme_checkbox_example.h', - '../ui/views/examples/native_widget_views_example.cc', - '../ui/views/examples/native_widget_views_example.h', '../ui/views/examples/progress_bar_example.cc', '../ui/views/examples/progress_bar_example.h', '../ui/views/examples/radio_button_example.cc', @@ -766,165 +725,5 @@ }], ], }, - { - 'target_name': 'views_desktop_lib', - 'type': 'static_library', - 'dependencies': [ - '../base/base.gyp:base', - '../chrome/chrome_resources.gyp:packed_resources', - '../skia/skia.gyp:skia', - '../third_party/icu/icu.gyp:icui18n', - '../third_party/icu/icu.gyp:icuuc', - '../ui/gfx/compositor/compositor.gyp:compositor', - '../ui/ui.gyp:gfx_resources', - '../ui/ui.gyp:ui', - '../ui/ui.gyp:ui_resources', - 'views', - ], - 'include_dirs': [ - '..', - ], - 'sources': [ - '../ui/views/desktop/desktop_background.cc', - '../ui/views/desktop/desktop_background.h', - '../ui/views/desktop/desktop_window_manager.cc', - '../ui/views/desktop/desktop_window_manager.h', - '../ui/views/desktop/desktop_window_view.cc', - '../ui/views/desktop/desktop_window_view.h', - ], - 'conditions': [ - ['toolkit_uses_gtk == 1', { - 'dependencies': [ - '../build/linux/system.gyp:gtk', - ], - 'conditions': [ - ['linux_use_tcmalloc==1', { - 'dependencies': [ - '../base/allocator/allocator.gyp:allocator', - ], - }], - ], - }, - ], - ['OS=="win"', { - 'link_settings': { - 'libraries': [ - '-limm32.lib', - '-loleacc.lib', - ] - }, - 'include_dirs': [ - '../third_party/wtl/include', - ], - }], - ], - }, - { - 'target_name': 'views_desktop', - 'type': 'executable', - 'dependencies': [ - '../base/base.gyp:base', - '../base/base.gyp:base_i18n', - '../chrome/chrome_resources.gyp:packed_resources', - '../skia/skia.gyp:skia', - '../third_party/icu/icu.gyp:icui18n', - '../third_party/icu/icu.gyp:icuuc', - '../ui/ui.gyp:gfx_resources', - '../ui/ui.gyp:ui', - '../ui/ui.gyp:ui_resources', - '../ui/ui.gyp:ui_resources_standard', - '../ui/gfx/compositor/compositor.gyp:compositor', - 'views', - 'views_desktop_lib', - ], - 'include_dirs': [ - '..', - ], - 'sources': [ - '../ui/views/desktop/desktop_main.cc', - '../ui/views/desktop/desktop_views_delegate.cc', - '../ui/views/desktop/desktop_views_delegate.h', - '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc', - '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc', - '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.rc', - ], - 'conditions': [ - ['toolkit_uses_gtk == 1', { - 'dependencies': [ - '../build/linux/system.gyp:gtk', - ], - }, - ], - ['use_glib == 1', { - 'dependencies': [ - '../build/linux/system.gyp:glib', - ], - 'conditions': [ - ['linux_use_tcmalloc==1', { - 'dependencies': [ - '../base/allocator/allocator.gyp:allocator', - ], - }], - ], - }], - ['OS=="win"', { - 'link_settings': { - 'libraries': [ - '-limm32.lib', - '-loleacc.lib', - ] - }, - 'include_dirs': [ - '../third_party/wtl/include', - ], - }], - ], - }, - ], - 'conditions': [ - ['use_aura==1', { - 'targets': [ - { - 'target_name': 'views_aura_desktop', - 'type': 'executable', - 'dependencies': [ - '../base/base.gyp:base', - '../base/base.gyp:base_i18n', - '../chrome/chrome_resources.gyp:packed_resources', - '../skia/skia.gyp:skia', - '../third_party/icu/icu.gyp:icui18n', - '../third_party/icu/icu.gyp:icuuc', - '../ui/aura/aura.gyp:aura', - '../ui/ui.gyp:gfx_resources', - '../ui/ui.gyp:ui', - '../ui/ui.gyp:ui_resources', - '../ui/ui.gyp:ui_resources_standard', - 'views', - ], - 'include_dirs': [ - '..', - ], - 'sources': [ - '../ui/views/aura_desktop/aura_desktop_main.cc', - '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc', - '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc', - '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.rc', - ], - 'conditions': [ - ['OS=="win"', { - 'link_settings': { - 'libraries': [ - '-limm32.lib', - '-loleacc.lib', - ] - }, - 'include_dirs': [ - '../third_party/wtl/include', - ], - }], - ], - }, - ], - }], ], } diff --git a/views/views_delegate.h b/views/views_delegate.h index 1be6657..210031a 100644 --- a/views/views_delegate.h +++ b/views/views_delegate.h @@ -46,12 +46,6 @@ class VIEWS_EXPORT ViewsDelegate { // Gets the clipboard. virtual ui::Clipboard* GetClipboard() const = 0; - // Returns the View that all synthetic widgets created without a specified - // parent will be parented to if they do not specify a parent in their - // InitParams, or NULL if they should have no parent. - // TODO(beng): perhaps this should be a Widget. - virtual View* GetDefaultParentView() = 0; - // Saves the position, size and "show" state for the window with the // specified name. virtual void SaveWindowPlacement(const Widget* widget, diff --git a/views/widget/native_widget_aura.h b/views/widget/native_widget_aura.h index 05f687c..8f1383a 100644 --- a/views/widget/native_widget_aura.h +++ b/views/widget/native_widget_aura.h @@ -150,6 +150,9 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, virtual void OnDragExited() OVERRIDE; virtual int OnPerformDrop(const aura::DropTargetEvent& event) OVERRIDE; + protected: + internal::NativeWidgetDelegate* delegate() { return delegate_; } + private: class DesktopObserverImpl; diff --git a/views/widget/native_widget_delegate.h b/views/widget/native_widget_delegate.h index b02cf52..3732e97 100644 --- a/views/widget/native_widget_delegate.h +++ b/views/widget/native_widget_delegate.h @@ -7,20 +7,19 @@ #pragma once #include "views/views_export.h" +#include "ui/base/events.h" namespace gfx { class Canvas; +class Point; class Size; } -#if defined(TOUCH_UI) -namespace ui { -enum TouchStatus; -} -#endif - namespace views { class InputMethod; +class KeyEvent; +class MouseEvent; +class TouchEvent; namespace internal { diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc index 6d79ac2..c7ef5e2 100644 --- a/views/widget/native_widget_gtk.cc +++ b/views/widget/native_widget_gtk.cc @@ -40,7 +40,6 @@ #include "views/widget/drop_target_gtk.h" #include "views/widget/gtk_views_fixed.h" #include "views/widget/gtk_views_window.h" -#include "views/widget/native_widget_views.h" #include "views/widget/root_view.h" #include "views/widget/widget_delegate.h" @@ -992,8 +991,7 @@ InputMethod* NativeWidgetGtk::CreateInputMethod() { // Create input method when pure views is enabled but not on views desktop. // TODO(suzhe): Always enable input method when we start to use // RenderWidgetHostViewViews in normal ChromeOS. - if (views::Widget::IsPureViews() && - !ViewsDelegate::views_delegate->GetDefaultParentView()) { + if (views::Widget::IsPureViews()) { #if defined(HAVE_IBUS) InputMethod* input_method = InputMethodIBus::IsInputMethodIBusEnabled() ? @@ -1005,7 +1003,7 @@ InputMethod* NativeWidgetGtk::CreateInputMethod() { input_method->Init(GetWidget()); return input_method; } - // GTK's textfield or InputMethod in NativeWidgetViews will handle IME. + // GTK's textfield will handle IME. return NULL; } @@ -1356,14 +1354,7 @@ bool NativeWidgetGtk::ConvertPointFromAncestor( } gfx::Rect NativeWidgetGtk::GetWorkAreaBoundsInScreen() const { - ViewsDelegate *delegate = ViewsDelegate::views_delegate; - if (delegate && delegate->GetDefaultParentView()) { - // For views-desktop, the work area is the entire space inside this - // containter window. - return gfx::Rect(gfx::Point(0, 0), - delegate->GetDefaultParentView()->size()); - } else - return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView()); + return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView()); } void NativeWidgetGtk::SetInactiveRenderingDisabled(bool value) { @@ -2215,10 +2206,6 @@ namespace internal { // static NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( NativeWidgetDelegate* delegate) { - if (Widget::IsPureViews() && ViewsDelegate::views_delegate && - ViewsDelegate::views_delegate->GetDefaultParentView()) { - return new NativeWidgetViews(delegate); - } return new NativeWidgetGtk(delegate); } diff --git a/views/widget/native_widget_view.cc b/views/widget/native_widget_view.cc deleted file mode 100644 index 98b8bd5..0000000 --- a/views/widget/native_widget_view.cc +++ /dev/null @@ -1,178 +0,0 @@ -// 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. - -#include "views/widget/native_widget_view.h" - -#include "ui/gfx/canvas.h" -#include "ui/gfx/compositor/layer.h" -#include "ui/gfx/native_widget_types.h" - -namespace views { -namespace internal { - -//////////////////////////////////////////////////////////////////////////////// -// NativeWidgetView, public: - -// static -const char NativeWidgetView::kViewClassName[] = "views/NativeWidgetView"; - -NativeWidgetView::NativeWidgetView(NativeWidgetViews* native_widget) - : native_widget_(native_widget), - sent_create_(false), - delete_native_widget_(true), - cursor_(gfx::kNullCursor) { -} - -NativeWidgetView::~NativeWidgetView() { - // Don't let NativeWidgetViews delete this again. This must be outside - // the |delete_native_widget_| clause so it gets invoked for - // WIDGET_OWNS_NATIVE_WIDGET. It is safe because |native_widget_| will - // still exist in both ways NativeWidgetView can be destroyed: by view - // hierarchy teardown and from the NativeWidgetViews destructor. - native_widget_->set_delete_native_view(false); - if (delete_native_widget_) - delete native_widget_; -} - -Widget* NativeWidgetView::GetAssociatedWidget() { - return native_widget_->delegate()->AsWidget(); -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeWidgetView, View overrides: - -void NativeWidgetView::CalculateOffsetToAncestorWithLayer( - gfx::Point* offset, - ui::Layer** layer_parent) { - View::CalculateOffsetToAncestorWithLayer(offset, layer_parent); -} - -void NativeWidgetView::ReorderLayers() { - View::ReorderLayers(); -} - -#if !defined(NDEBUG) -std::string NativeWidgetView::PrintViewGraph(bool first) { - return DoPrintViewGraph(first, GetAssociatedWidget()->GetRootView()); -} -#endif - -void NativeWidgetView::ViewHierarchyChanged(bool is_add, - View* parent, - View* child) { - if (is_add && child == this) { - GetAssociatedWidget()->GetRootView()->UpdateParentLayers(); - if (!sent_create_) { - sent_create_ = true; - delegate()->OnNativeWidgetCreated(); - } - } -} - -void NativeWidgetView::OnBoundsChanged(const gfx::Rect& previous_bounds) { - native_widget_->OnBoundsChanged(bounds(), previous_bounds); -} - -void NativeWidgetView::OnPaint(gfx::Canvas* canvas) { - delegate()->OnNativeWidgetPaint(canvas); -} - -gfx::NativeCursor NativeWidgetView::GetCursor(const MouseEvent& event) { - return cursor_; -} - -bool NativeWidgetView::OnMousePressed(const MouseEvent& event) { - return native_widget_->OnMouseEvent(event); -} - -bool NativeWidgetView::OnMouseDragged(const MouseEvent& event) { - return native_widget_->OnMouseEvent(event); -} - -void NativeWidgetView::OnMouseReleased(const MouseEvent& event) { - native_widget_->OnMouseEvent(event); -} - -void NativeWidgetView::OnMouseCaptureLost() { - delegate()->OnMouseCaptureLost(); -} - -void NativeWidgetView::OnMouseMoved(const MouseEvent& event) { - native_widget_->OnMouseEvent(event); -} - -void NativeWidgetView::OnMouseEntered(const MouseEvent& event) { - native_widget_->OnMouseEvent(event); -} - -void NativeWidgetView::OnMouseExited(const MouseEvent& event) { - native_widget_->OnMouseEvent(event); -} - -ui::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& event) { - return delegate()->OnTouchEvent(event); -} - -bool NativeWidgetView::OnKeyPressed(const KeyEvent& event) { - return delegate()->OnKeyEvent(event); -} - -bool NativeWidgetView::OnKeyReleased(const KeyEvent& event) { - return delegate()->OnKeyEvent(event); -} - -bool NativeWidgetView::OnMouseWheel(const MouseWheelEvent& event) { - return native_widget_->OnMouseEvent(event); -} - -void NativeWidgetView::VisibilityChanged(View* starting_from, - bool visible) { - delegate()->OnNativeWidgetVisibilityChanged(visible); -} - -void NativeWidgetView::OnFocus() { - // TODO(beng): check if we have to do this. - //delegate()->OnNativeFocus(NULL); -} - -void NativeWidgetView::OnBlur() { - // TODO(beng): check if we have to do this. - //delegate()->OnNativeBlur(NULL); -} - -std::string NativeWidgetView::GetClassName() const { - return kViewClassName; -} - -void NativeWidgetView::MoveLayerToParent(ui::Layer* parent_layer, - const gfx::Point& point) { - View::MoveLayerToParent(parent_layer, point); - if (!layer() || parent_layer == layer()) { - gfx::Point new_offset(point); - if (layer() != parent_layer) - new_offset.Offset(x(), y()); - GetAssociatedWidget()->GetRootView()->MoveLayerToParent( - parent_layer, new_offset); - } -} - -void NativeWidgetView::UpdateChildLayerBounds(const gfx::Point& offset) { - View::UpdateChildLayerBounds(offset); - if (!layer()) { - const gfx::Rect& bounds = GetAssociatedWidget()->GetRootView()->bounds(); - gfx::Point new_offset(offset.x() + bounds.x(), offset.y() + bounds.y()); - GetAssociatedWidget()->GetRootView()->UpdateChildLayerBounds(new_offset); - } -} - -void NativeWidgetView::ReorderChildLayers(ui::Layer* parent_layer) { - if (layer()) { - View::ReorderChildLayers(parent_layer); - } else { - GetAssociatedWidget()->GetRootView()->ReorderChildLayers(parent_layer); - } -} - -} // namespace internal -} // namespace views diff --git a/views/widget/native_widget_view.h b/views/widget/native_widget_view.h deleted file mode 100644 index a64cbf7..0000000 --- a/views/widget/native_widget_view.h +++ /dev/null @@ -1,101 +0,0 @@ -// 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_VIEW_H_ -#define VIEWS_WIDGET_NATIVE_WIDGET_VIEW_H_ -#pragma once - -#include "views/view.h" -#include "views/widget/native_widget_delegate.h" -#include "views/widget/native_widget_views.h" - -namespace ui { -enum TouchStatus; -} - -namespace views { -namespace internal { - -//////////////////////////////////////////////////////////////////////////////// -// NativeWidgetView -// -// This class represents the View that is the "native view" for a -// NativeWidgetViews. It is the View that is a member of the parent Widget's -// View hierarchy. It is responsible for receiving relevant events from that -// hierarchy and forwarding them to its NativeWidgetViews' delegate's hierarchy. -// -class VIEWS_EXPORT NativeWidgetView : public View { - public: - static const char kViewClassName[]; - - explicit NativeWidgetView(NativeWidgetViews* native_widget); - virtual ~NativeWidgetView(); - - Widget* GetAssociatedWidget(); - - void set_delete_native_widget(bool delete_native_widget) { - delete_native_widget_ = delete_native_widget; - } - - void set_cursor(gfx::NativeCursor cursor) { cursor_ = cursor; } - - // Overridden from View: - virtual void CalculateOffsetToAncestorWithLayer( - gfx::Point* offset, - ui::Layer** layer_parent) OVERRIDE; - virtual void ReorderLayers() OVERRIDE; - -#if !defined(NDEBUG) - virtual std::string PrintViewGraph(bool first) OVERRIDE; -#endif - - private: - // Overridden from View: - virtual void ViewHierarchyChanged(bool is_add, - View* parent, - View* child) OVERRIDE; - virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - virtual gfx::NativeCursor GetCursor(const MouseEvent& event) OVERRIDE; - virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; - virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; - virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; - virtual void OnMouseCaptureLost() OVERRIDE; - virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; - virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE; - virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; - virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; - virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE; - virtual bool OnKeyReleased(const KeyEvent& event) OVERRIDE; - virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE; - virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE; - virtual void OnFocus() OVERRIDE; - virtual void OnBlur() OVERRIDE; - virtual std::string GetClassName() const OVERRIDE; - virtual void MoveLayerToParent(ui::Layer* parent_layer, - const gfx::Point& point) OVERRIDE; - virtual void UpdateChildLayerBounds(const gfx::Point& offset) OVERRIDE; - virtual void ReorderChildLayers(ui::Layer* parent_layer) OVERRIDE; - - internal::NativeWidgetDelegate* delegate() { - return native_widget_->delegate(); - } - - NativeWidgetViews* native_widget_; - - // Have we sent OnNativeWidgetCreated? - bool sent_create_; - - bool delete_native_widget_; - - // The cursor set for the associated widget. - gfx::NativeCursor cursor_; - - DISALLOW_COPY_AND_ASSIGN(NativeWidgetView); -}; - -} // namespace internal -} // namespace views - -#endif // VIEWS_WIDGET_NATIVE_WIDGET_VIEW_H_ diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc deleted file mode 100644 index 6ebe1d7..0000000 --- a/views/widget/native_widget_views.cc +++ /dev/null @@ -1,648 +0,0 @@ -// 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. - -#include "views/widget/native_widget_views.h" - -#include "base/bind.h" -#include "ui/base/hit_test.h" -#include "ui/gfx/compositor/compositor.h" -#include "ui/gfx/compositor/layer.h" -#include "ui/gfx/compositor/layer_animator.h" -#include "views/view.h" -#include "views/views_delegate.h" -#include "views/widget/native_widget_view.h" -#include "views/widget/root_view.h" -#include "views/widget/tooltip_manager_views.h" -#include "views/widget/window_manager.h" - -#if defined(HAVE_IBUS) -#include "ui/views/ime/input_method_ibus.h" -#else -#include "ui/views/ime/mock_input_method.h" -#endif - -namespace { - -gfx::Rect AdjustRectOriginForParentWidget(const gfx::Rect& rect, - const views::Widget* parent) { - if (!parent) - return rect; - - gfx::Rect adjusted = rect; - gfx::Rect parent_bounds = parent->GetWindowScreenBounds(); - adjusted.Offset(-parent_bounds.x(), -parent_bounds.y()); - return adjusted; -} - -} // namespace - -namespace views { - -//////////////////////////////////////////////////////////////////////////////// -// NativeWidgetViews, public: - -NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate) - : delegate_(delegate), - parent_(NULL), - view_(NULL), - active_(false), - window_state_(ui::SHOW_STATE_DEFAULT), - always_on_top_(false), - ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), - ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), - delete_native_view_(true) { -} - -NativeWidgetViews::~NativeWidgetViews() { - delegate_->OnNativeWidgetDestroying(); - - if (view_ && delete_native_view_) { - // We must prevent the NativeWidgetView from attempting to delete us. - view_->set_delete_native_widget(false); - delete view_; - } - - delegate_->OnNativeWidgetDestroyed(); - if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) - delete delegate_; -} - -View* NativeWidgetViews::GetView() { - return view_; -} - -const View* NativeWidgetViews::GetView() const { - return view_; -} - -void NativeWidgetViews::OnActivate(bool active) { - // TODO(oshima): find out if we should check toplevel here. - if (active_ == active) - return; - active_ = active; - delegate_->OnNativeWidgetActivationChanged(active); - - // TODO(oshima): Focus change should be separated from window activation. - // This will be fixed when we have WM API. - Widget* widget = GetWidget(); - if (widget->is_top_level()) { - InputMethod* input_method = widget->GetInputMethod(); - if (active) { - input_method->OnFocus(); - // See description of got_initial_focus_in_ for details on this. - widget->GetFocusManager()->RestoreFocusedView(); - } else { - input_method->OnBlur(); - widget->GetFocusManager()->StoreFocusedView(); - } - } - view_->SchedulePaint(); -} - -bool NativeWidgetViews::OnKeyEvent(const KeyEvent& key_event) { - InputMethod* input_method = GetWidget()->GetInputMethod(); - DCHECK(input_method); - input_method->DispatchKeyEvent(key_event); - return true; -} - -void NativeWidgetViews::DispatchKeyEventPostIME(const KeyEvent& key) { - // TODO(oshima): GTK impl handles menu_key in special way. This may be - // necessary when running under NativeWidgetX. - if (delegate_->OnKeyEvent(key)) - return; - if (key.type() == ui::ET_KEY_PRESSED && GetWidget()->GetFocusManager()) - GetWidget()->GetFocusManager()->OnKeyEvent(key); -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeWidgetViews, protected: - -void NativeWidgetViews::OnBoundsChanged(const gfx::Rect& new_bounds, - const gfx::Rect& old_bounds) { - delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); -} - -bool NativeWidgetViews::OnMouseEvent(const MouseEvent& event) { -#if defined(TOUCH_UI) || defined(USE_AURA) - TooltipManagerViews* tooltip_manager = - static_cast<TooltipManagerViews*>(GetTooltipManager()); - if (tooltip_manager) - tooltip_manager->UpdateForMouseEvent(event); -#endif - return HandleWindowOperation(event) ? true : delegate_->OnMouseEvent(event); -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeWidgetViews, NativeWidget implementation: - -void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { - parent_ = params.parent_widget; - ownership_ = params.ownership; - always_on_top_ = params.keep_on_top; - View* parent_view = NULL; - if (params.parent_widget) { - parent_view = params.parent_widget->GetChildViewParent(); - } else if (ViewsDelegate::views_delegate && - ViewsDelegate::views_delegate->GetDefaultParentView() && - !params.child) { - parent_view = ViewsDelegate::views_delegate->GetDefaultParentView(); - } else if (params.parent) { - Widget* widget = Widget::GetWidgetForNativeView(params.parent); - parent_view = widget->GetChildViewParent(); - } - - gfx::Rect bounds = GetWidget()->is_top_level() ? - AdjustRectOriginForParentWidget(params.bounds, parent_) : params.bounds; - view_ = new internal::NativeWidgetView(this); - view_->SetBoundsRect(bounds); - view_->SetVisible(params.type == Widget::InitParams::TYPE_CONTROL); - - // With the default NATIVE_WIDGET_OWNS_WIDGET ownership, the - // deletion of either of the NativeWidgetViews or NativeWidgetView - // (e.g. via View hierarchy destruction) will delete the other. - // With WIDGET_OWNS_NATIVE_WIDGET, NativeWidgetViews should only - // be deleted by its Widget. - if (ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET) - view_->set_delete_native_widget(false); - - if (parent_view) - parent_view->AddChildView(view_); - view_->SetPaintToLayer(true); - if (View::get_use_acceleration_when_possible()) - view_->SetFillsBoundsOpaquely(!params.transparent); - // TODO(beng): SetInitParams(). -} - -NonClientFrameView* NativeWidgetViews::CreateNonClientFrameView() { - return NULL; -} - -void NativeWidgetViews::UpdateFrameAfterFrameChange() { -} - -bool NativeWidgetViews::ShouldUseNativeFrame() const { -// NOTIMPLEMENTED(); - return false; -} - -void NativeWidgetViews::FrameTypeChanged() { -} - -Widget* NativeWidgetViews::GetWidget() { - return delegate_->AsWidget(); -} - -const Widget* NativeWidgetViews::GetWidget() const { - return delegate_->AsWidget(); -} - -gfx::NativeView NativeWidgetViews::GetNativeView() const { - return GetParentNativeWidget() ? - GetParentNativeWidget()->GetNativeView() : NULL; -} - -gfx::NativeWindow NativeWidgetViews::GetNativeWindow() const { - return GetParentNativeWidget() ? - GetParentNativeWidget()->GetNativeWindow() : NULL; -} - -Widget* NativeWidgetViews::GetTopLevelWidget() { - // This can get called when this is in the process of being destroyed, and - // view_ has already been unset. - if (!view_) - return GetWidget(); - if (ViewsDelegate::views_delegate && - view_->parent() == ViewsDelegate::views_delegate->GetDefaultParentView()) - return GetWidget(); - // During Widget destruction, this function may be called after |view_| is - // detached from a Widget, at which point this NativeWidget's Widget becomes - // the effective toplevel. - Widget* containing_widget = view_->GetWidget(); - return containing_widget ? containing_widget->GetTopLevelWidget() - : GetWidget(); -} - -const ui::Compositor* NativeWidgetViews::GetCompositor() const { - return view_->GetWidget() ? view_->GetWidget()->GetCompositor() : NULL; -} - -ui::Compositor* NativeWidgetViews::GetCompositor() { - return view_->GetWidget() ? view_->GetWidget()->GetCompositor() : NULL; -} - -void NativeWidgetViews::CalculateOffsetToAncestorWithLayer( - gfx::Point* offset, - ui::Layer** layer_parent) { - view_->CalculateOffsetToAncestorWithLayer(offset, layer_parent); -} - -void NativeWidgetViews::ReorderLayers() { - view_->ReorderLayers(); -} - -void NativeWidgetViews::ViewRemoved(View* view) { - internal::NativeWidgetPrivate* parent = GetParentNativeWidget(); - if (parent) - parent->ViewRemoved(view); -} - -void NativeWidgetViews::SetNativeWindowProperty(const char* name, void* value) { - if (value) - props_map_[name] = value; - else - props_map_.erase(name); -} - -void* NativeWidgetViews::GetNativeWindowProperty(const char* name) const { - PropsMap::const_iterator iter = props_map_.find(name); - return iter != props_map_.end() ? iter->second : NULL; -} - -TooltipManager* NativeWidgetViews::GetTooltipManager() const { - const internal::NativeWidgetPrivate* parent = GetParentNativeWidget(); - return parent ? parent->GetTooltipManager() : NULL; -} - -bool NativeWidgetViews::IsScreenReaderActive() const { - return GetParentNativeWidget()->IsScreenReaderActive(); -} - -void NativeWidgetViews::SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) { - return GetParentNativeWidget()->SendNativeAccessibilityEvent(view, - event_type); -} - -void NativeWidgetViews::SetMouseCapture() { - WindowManager::Get()->SetMouseCapture(GetWidget()); -} - -void NativeWidgetViews::ReleaseMouseCapture() { - WindowManager::Get()->ReleaseMouseCapture(GetWidget()); -} - -bool NativeWidgetViews::HasMouseCapture() const { - return WindowManager::Get()->HasMouseCapture(GetWidget()); -} - -InputMethod* NativeWidgetViews::CreateInputMethod() { -#if defined(HAVE_IBUS) - InputMethod* input_method = new InputMethodIBus(this); -#else - InputMethod* input_method = new MockInputMethod(this); -#endif - input_method->Init(GetWidget()); - return input_method; -} - -void NativeWidgetViews::CenterWindow(const gfx::Size& size) { - const gfx::Size parent_size = GetView()->parent()->size(); - GetView()->SetBounds((parent_size.width() - size.width())/2, - (parent_size.height() - size.height())/2, - size.width(), size.height()); -} - -void NativeWidgetViews::GetWindowPlacement( - gfx::Rect* bounds, - ui::WindowShowState* show_state) const { - *bounds = GetView()->bounds(); - *show_state = ui::SHOW_STATE_NORMAL; -} - -void NativeWidgetViews::SetWindowTitle(const string16& title) { -} - -void NativeWidgetViews::SetWindowIcons(const SkBitmap& window_icon, - const SkBitmap& app_icon) { -} - -void NativeWidgetViews::SetAccessibleName(const string16& name) { -} - -void NativeWidgetViews::SetAccessibleRole(ui::AccessibilityTypes::Role role) { -} - -void NativeWidgetViews::SetAccessibleState( - ui::AccessibilityTypes::State state) { -} - -void NativeWidgetViews::BecomeModal() { - NOTIMPLEMENTED(); -} - -gfx::Rect NativeWidgetViews::GetWindowScreenBounds() const { - if (GetWidget() == GetWidget()->GetTopLevelWidget() && - !parent_) - return view_->bounds(); - gfx::Point origin = view_->bounds().origin(); - View::ConvertPointToScreen(view_->parent(), &origin); - return gfx::Rect(origin.x(), origin.y(), view_->width(), view_->height()); -} - -gfx::Rect NativeWidgetViews::GetClientAreaScreenBounds() const { - return GetWindowScreenBounds(); -} - -gfx::Rect NativeWidgetViews::GetRestoredBounds() const { - return GetWindowScreenBounds(); -} - -void NativeWidgetViews::SetBounds(const gfx::Rect& bounds) { - // |bounds| are supplied in the coordinates of the parent. - if (GetWidget()->is_top_level()) - view_->SetBoundsRect(AdjustRectOriginForParentWidget(bounds, parent_)); - else - view_->SetBoundsRect(bounds); -} - -void NativeWidgetViews::SetSize(const gfx::Size& size) { - view_->SetSize(size); -} - -void NativeWidgetViews::MoveAbove(gfx::NativeView native_view) { - NOTIMPLEMENTED(); -} - -void NativeWidgetViews::MoveToTop() { - view_->parent()->ReorderChildView(view_, -1); -} - -void NativeWidgetViews::SetShape(gfx::NativeRegion region) { - NOTIMPLEMENTED(); -} - -void NativeWidgetViews::Close() { - Hide(); - if (!close_widget_factory_.HasWeakPtrs()) { - MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&NativeWidgetViews::CloseNow, - close_widget_factory_.GetWeakPtr())); - } -} - -void NativeWidgetViews::CloseNow() { - delete view_; - view_ = NULL; -} - -void NativeWidgetViews::EnableClose(bool enable) { -} - -void NativeWidgetViews::Show() { - if (always_on_top_) - MoveToTop(); - view_->SetVisible(true); - GetWidget()->SetInitialFocus(); -} - -void NativeWidgetViews::Hide() { - view_->SetVisible(false); - if (HasMouseCapture()) - ReleaseMouseCapture(); - - // This is necessary because views desktop's window manager doesn't - // set the focus back to parent. - if (GetWidget()->is_top_level()) { - Widget* parent_widget = view_->GetWidget(); - if (parent_widget && parent_widget->GetInputMethod()) - parent_widget->GetInputMethod()->OnFocus(); - } -} - -void NativeWidgetViews::ShowWithWindowState(ui::WindowShowState show_state) { - Show(); -} - -void NativeWidgetViews::ShowMaximizedWithBounds( - const gfx::Rect& restored_bounds) { - Show(); -} - -bool NativeWidgetViews::IsVisible() const { - return view_->IsVisible() && (GetWidget()->is_top_level() || - GetWidget()->GetTopLevelWidget()->IsVisible()); -} - -void NativeWidgetViews::Activate() { - // Enable WidgetObserverTest.ActivationChange when this is implemented. - MoveToTop(); - OnActivate(true); -} - -void NativeWidgetViews::Deactivate() { - OnActivate(false); -} - -bool NativeWidgetViews::IsActive() const { - return active_; -} - -void NativeWidgetViews::SetAlwaysOnTop(bool on_top) { - always_on_top_ = on_top; - // This is not complete yet. At least |MoveToTop| will need to be updated to - // make sure a 'normal' window does not get on top of a window with - // |always_on_top_| set. - NOTIMPLEMENTED(); -} - -void NativeWidgetViews::Maximize() { - if (window_state_ == ui::SHOW_STATE_MAXIMIZED) - return; - - if (window_state_ != ui::SHOW_STATE_MINIMIZED) { - // Remember bounds and transform to use when unmaximized. - restored_bounds_ = view_->bounds(); - restored_transform_ = view_->GetTransform(); - } - - window_state_ = ui::SHOW_STATE_MAXIMIZED; - gfx::Size size = GetParentNativeWidget()->GetWindowScreenBounds().size(); - SetBounds(gfx::Rect(gfx::Point(), size)); -} - -void NativeWidgetViews::Minimize() { - if (view_->layer() && view_->layer()->GetAnimator()->is_animating()) - return; - - gfx::Rect view_bounds = view_->bounds(); - gfx::Rect parent_bounds = view_->parent()->bounds(); - - if (window_state_ != ui::SHOW_STATE_MAXIMIZED) { - restored_bounds_ = view_bounds; - restored_transform_ = view_->GetTransform(); - } - - float aspect_ratio = static_cast<float>(view_bounds.width()) / - static_cast<float>(view_bounds.height()); - int target_size = 100; - int target_height = target_size; - int target_width = static_cast<int>(aspect_ratio * target_height); - if (target_width > target_size) { - target_width = target_size; - target_height = static_cast<int>(target_width / aspect_ratio); - } - - int target_x = 20; - int target_y = parent_bounds.height() - target_size - 20; - - view_->SetBounds( - target_x, target_y, view_bounds.width(), view_bounds.height()); - - ui::Transform transform; - transform.SetScale((float)target_width / (float)view_bounds.width(), - (float)target_height / (float)view_bounds.height()); - view_->SetTransform(transform); - - window_state_ = ui::SHOW_STATE_MINIMIZED; -} - -bool NativeWidgetViews::IsMaximized() const { - return window_state_ == ui::SHOW_STATE_MAXIMIZED; -} - -bool NativeWidgetViews::IsMinimized() const { - return window_state_ == ui::SHOW_STATE_MINIMIZED; -} - -void NativeWidgetViews::Restore() { - if (view_->layer() && view_->layer()->GetAnimator()->is_animating()) - return; - - window_state_ = ui::SHOW_STATE_NORMAL; - view_->SetBoundsRect(restored_bounds_); - view_->SetTransform(restored_transform_); -} - -void NativeWidgetViews::SetFullscreen(bool fullscreen) { - NOTIMPLEMENTED(); -} - -bool NativeWidgetViews::IsFullscreen() const { - // NOTIMPLEMENTED(); - return false; -} - -void NativeWidgetViews::SetOpacity(unsigned char opacity) { - NOTIMPLEMENTED(); -} - -void NativeWidgetViews::SetUseDragFrame(bool use_drag_frame) { - NOTIMPLEMENTED(); -} - -bool NativeWidgetViews::IsAccessibleWidget() const { - NOTIMPLEMENTED(); - return false; -} - -void NativeWidgetViews::RunShellDrag(View* view, - const ui::OSExchangeData& data, - int operation) { - GetParentNativeWidget()->RunShellDrag(view, data, operation); -} - -void NativeWidgetViews::SchedulePaintInRect(const gfx::Rect& rect) { - view_->SchedulePaintInRect(rect); -} - -void NativeWidgetViews::SetCursor(gfx::NativeCursor cursor) { - view_->set_cursor(cursor); - GetParentNativeWidget()->SetCursor(cursor); -} - -void NativeWidgetViews::ClearNativeFocus() { - GetParentNativeWidget()->ClearNativeFocus(); -} - -void NativeWidgetViews::FocusNativeView(gfx::NativeView native_view) { - GetParentNativeWidget()->FocusNativeView(native_view); -} - -bool NativeWidgetViews::ConvertPointFromAncestor( - const Widget* ancestor, gfx::Point* point) const { - // This method converts the point from ancestor's coordinates to - // this widget's coordinate using recursion as the widget hierachy - // is usually shallow. - - if (ancestor == GetWidget()) - return true; // no conversion necessary - - const Widget* parent_widget = view_->GetWidget(); - if (!parent_widget) // couldn't reach the ancestor. - return false; - - if (parent_widget == ancestor || - parent_widget->ConvertPointFromAncestor(ancestor, point)) { - View::ConvertPointToView(parent_widget->GetRootView(), GetView(), point); - return true; - } - return false; -} - -gfx::Rect NativeWidgetViews::GetWorkAreaBoundsInScreen() const { - return GetParentNativeWidget()->GetWorkAreaBoundsInScreen(); -} - -void NativeWidgetViews::SetInactiveRenderingDisabled(bool value) { -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeWidgetViews, private: - -internal::NativeWidgetPrivate* NativeWidgetViews::GetParentNativeWidget() { - Widget* containing_widget = view_ ? view_->GetWidget() : NULL; - return containing_widget ? static_cast<internal::NativeWidgetPrivate*>( - containing_widget->native_widget()) : - NULL; -} - -const internal::NativeWidgetPrivate* - NativeWidgetViews::GetParentNativeWidget() const { - const Widget* containing_widget = view_ ? view_->GetWidget() : NULL; - return containing_widget ? static_cast<const internal::NativeWidgetPrivate*>( - containing_widget->native_widget()) : - NULL; -} - -bool NativeWidgetViews::HandleWindowOperation(const MouseEvent& event) { - if (event.type() != ui::ET_MOUSE_PRESSED) - return false; - - Widget* widget = GetWidget(); - if (widget->non_client_view()) { - int hittest_code = widget->non_client_view()->NonClientHitTest( - event.location()); - switch (hittest_code) { - case HTCAPTION: { - if (!event.IsOnlyRightMouseButton()) { - WindowManager::Get()->StartMoveDrag(widget, event.location()); - return true; - } - break; - } - case HTBOTTOM: - case HTBOTTOMLEFT: - case HTBOTTOMRIGHT: - case HTGROWBOX: - case HTLEFT: - case HTRIGHT: - case HTTOP: - case HTTOPLEFT: - case HTTOPRIGHT: { - WindowManager::Get()->StartResizeDrag( - widget, event.location(), hittest_code); - return true; - } - default: - // Everything else falls into standard client event handling. - break; - } - } - return false; -} - -} // namespace views diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h deleted file mode 100644 index caf48dd..0000000 --- a/views/widget/native_widget_views.h +++ /dev/null @@ -1,190 +0,0 @@ -// 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_VIEWS_H_ -#define VIEWS_WIDGET_NATIVE_WIDGET_VIEWS_H_ -#pragma once - -#include <map> - -#include "base/memory/weak_ptr.h" -#include "base/message_loop.h" -#include "ui/base/ui_base_types.h" -#include "ui/gfx/transform.h" -#include "views/widget/native_widget_private.h" -#include "views/widget/widget.h" - -namespace views { -namespace desktop { -class DesktopWindowView; -} - -namespace internal { -class NativeWidgetView; -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeWidgetViews -// -// A NativeWidget implementation that uses another View as its native widget. -// -class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate { - public: - explicit NativeWidgetViews(internal::NativeWidgetDelegate* delegate); - virtual ~NativeWidgetViews(); - - // TODO(beng): remove. - View* GetView(); - const View* GetView() const; - - // TODO(oshima): These will be moved to WM API. - void OnActivate(bool active); - bool OnKeyEvent(const KeyEvent& key_event); - - void set_delete_native_view(bool delete_native_view) { - delete_native_view_ = delete_native_view; - } - - internal::NativeWidgetDelegate* delegate() const { return delegate_; } - - protected: - friend class internal::NativeWidgetView; - - // Event handlers that subclass can implmenet custom behavior. - virtual void OnBoundsChanged(const gfx::Rect& new_bounds, - const gfx::Rect& old_bounds); - virtual bool OnMouseEvent(const MouseEvent& event); - - // Overridden from internal::NativeWidgetPrivate: - virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; - virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; - virtual void UpdateFrameAfterFrameChange() OVERRIDE; - virtual bool ShouldUseNativeFrame() const OVERRIDE; - virtual void FrameTypeChanged() OVERRIDE; - virtual Widget* GetWidget() OVERRIDE; - virtual const Widget* GetWidget() const OVERRIDE; - virtual gfx::NativeView GetNativeView() const OVERRIDE; - virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; - virtual Widget* GetTopLevelWidget() OVERRIDE; - virtual const ui::Compositor* GetCompositor() const OVERRIDE; - virtual ui::Compositor* GetCompositor() OVERRIDE; - virtual void CalculateOffsetToAncestorWithLayer( - gfx::Point* offset, - ui::Layer** layer_parent) OVERRIDE; - virtual void ReorderLayers() OVERRIDE; - virtual void ViewRemoved(View* view) OVERRIDE; - virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; - virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE; - virtual TooltipManager* GetTooltipManager() const OVERRIDE; - virtual bool IsScreenReaderActive() const OVERRIDE; - virtual void SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) OVERRIDE; - virtual void SetMouseCapture() OVERRIDE; - virtual void ReleaseMouseCapture() OVERRIDE; - virtual bool HasMouseCapture() const OVERRIDE; - virtual InputMethod* CreateInputMethod() OVERRIDE; - virtual void CenterWindow(const gfx::Size& size) OVERRIDE; - virtual void GetWindowPlacement( - gfx::Rect* bounds, - ui::WindowShowState* show_state) const OVERRIDE; - virtual void SetWindowTitle(const string16& title) OVERRIDE; - virtual void SetWindowIcons(const SkBitmap& window_icon, - const SkBitmap& app_icon) OVERRIDE; - virtual void SetAccessibleName(const string16& name) OVERRIDE; - virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; - virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; - virtual void BecomeModal() OVERRIDE; - virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; - virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; - virtual gfx::Rect GetRestoredBounds() const OVERRIDE; - virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; - virtual void SetSize(const gfx::Size& size) OVERRIDE; - virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; - virtual void MoveToTop() OVERRIDE; - virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; - virtual void Close() OVERRIDE; - virtual void CloseNow() OVERRIDE; - virtual void EnableClose(bool enable) OVERRIDE; - virtual void Show() OVERRIDE; - virtual void Hide() OVERRIDE; - virtual void ShowMaximizedWithBounds( - const gfx::Rect& restored_bounds) OVERRIDE; - virtual void ShowWithWindowState(ui::WindowShowState window_state) OVERRIDE; - virtual bool IsVisible() const OVERRIDE; - virtual void Activate() OVERRIDE; - virtual void Deactivate() OVERRIDE; - virtual bool IsActive() const OVERRIDE; - virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE; - virtual void Maximize() OVERRIDE; - virtual void Minimize() OVERRIDE; - virtual bool IsMaximized() const OVERRIDE; - virtual bool IsMinimized() const OVERRIDE; - virtual void Restore() OVERRIDE; - virtual void SetFullscreen(bool fullscreen) OVERRIDE; - virtual bool IsFullscreen() const OVERRIDE; - virtual void SetOpacity(unsigned char opacity) OVERRIDE; - virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE; - virtual bool IsAccessibleWidget() const OVERRIDE; - virtual void RunShellDrag(View* view, - const ui::OSExchangeData& data, - int operation) OVERRIDE; - virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; - virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; - virtual void ClearNativeFocus() OVERRIDE; - virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; - virtual bool ConvertPointFromAncestor( - const Widget* ancestor, gfx::Point* point) const OVERRIDE; - virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE; - virtual void SetInactiveRenderingDisabled(bool value) OVERRIDE; - - // Overridden from internal::InputMethodDelegate - virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE; - - private: - friend class desktop::DesktopWindowView; - - typedef std::map<const char*, void*> PropsMap; - - // These functions may return NULL during Widget destruction. - internal::NativeWidgetPrivate* GetParentNativeWidget(); - const internal::NativeWidgetPrivate* GetParentNativeWidget() const; - - bool HandleWindowOperation(const MouseEvent& event); - - internal::NativeWidgetDelegate* delegate_; - - // Parent Widget (can be NULL). - Widget* parent_; - - internal::NativeWidgetView* view_; - - bool active_; - - ui::WindowShowState window_state_; - - // Set when SetAlwaysOnTop is called, or keep_on_top is set during creation. - bool always_on_top_; - - // The following factory is used for calls to close the NativeWidgetViews - // instance. - base::WeakPtrFactory<NativeWidgetViews> close_widget_factory_; - - gfx::Rect restored_bounds_; - ui::Transform restored_transform_; - - // See class documentation for Widget in widget.h for a note about ownership. - Widget::InitParams::Ownership ownership_; - - bool delete_native_view_; - - // Map used by Set/GetNativeWindowProperty. - PropsMap props_map_; - - DISALLOW_COPY_AND_ASSIGN(NativeWidgetViews); -}; - -} // namespace views - -#endif // VIEWS_WIDGET_NATIVE_WIDGET_VIEWS_H_ diff --git a/views/widget/native_widget_wayland.cc b/views/widget/native_widget_wayland.cc deleted file mode 100644 index 989d08d..0000000 --- a/views/widget/native_widget_wayland.cc +++ /dev/null @@ -1,683 +0,0 @@ -// 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. - -#include "views/widget/native_widget_wayland.h" - -#include <EGL/egl.h> -#include <GL/gl.h> -#include <cairo-gl.h> -#include <cairo.h> -#include <wayland-egl.h> - -#include <algorithm> -#include <list> - -#include "base/bind.h" -#include "base/memory/scoped_ptr.h" -#include "base/wayland/wayland_event.h" -#include "ui/base/view_prop.h" -#include "ui/gfx/canvas_skia_paint.h" -#include "ui/gfx/compositor/compositor.h" -#include "ui/gfx/gl/gl_surface.h" -#include "ui/gfx/gl/gl_surface_egl.h" -#include "ui/views/ime/input_method_wayland.h" -#include "ui/wayland/wayland_display.h" -#include "ui/wayland/wayland_input_device.h" -#include "ui/wayland/wayland_screen.h" -#include "ui/wayland/wayland_window.h" -#include "views/views_delegate.h" -#include "views/widget/native_widget_views.h" -#include "views/widget/root_view.h" -#include "views/widget/tooltip_manager_views.h" - -using ui::ViewProp; - -using base::wayland::WaylandEvent; - -namespace views { - -namespace { - -// Links the WaylandWidget to its NativeWidget. -const char* const kNativeWidgetKey = "__VIEWS_NATIVE_WIDGET__"; - -} // namespace - -NativeWidgetWayland::NativeWidgetWayland( - internal::NativeWidgetDelegate* delegate) - : delegate_(delegate), - ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), - ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), - has_mouse_capture_(false), - wayland_display_( - ui:: WaylandDisplay::GetDisplay(gfx::GLSurfaceEGL::GetNativeDisplay())), - wayland_window_(new ui::WaylandWindow(this, wayland_display_)), - surface_data_key_(), - damage_area_() { -} - -NativeWidgetWayland::~NativeWidgetWayland() { - if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) - delete delegate_; - - if (!View::get_use_acceleration_when_possible()) { - cairo_surface_destroy(cairo_surface_); - cairo_device_destroy(device_); - } - - if (egl_window_) - wl_egl_window_destroy(egl_window_); - - if (wayland_window_) - delete wayland_window_; -} - -void NativeWidgetWayland::InitNativeWidget(const Widget::InitParams& params) { - // Cannot create a window with a size smaller than 1x1 - allocation_.set_width(std::max(params.bounds.width(), 1)); - allocation_.set_height(std::max(params.bounds.height(), 1)); - - egl_window_ = wl_egl_window_create(wayland_window_->surface(), - allocation_.width(), - allocation_.height()); - - SetNativeWindowProperty(kNativeWidgetKey, this); - - if (View::get_use_acceleration_when_possible()) { - if (ui::Compositor::compositor_factory()) { - compositor_ = (*ui::Compositor::compositor_factory())(this); - } else { - compositor_ = ui::Compositor::Create(this, - egl_window_, - allocation_.size()); - } - if (compositor_.get()) - delegate_->AsWidget()->GetRootView()->SetPaintToLayer(true); - } else { - surface_ = gfx::GLSurface::CreateViewGLSurface(false, egl_window_); - context_ = gfx::GLContext::CreateGLContext( - NULL, - surface_.get(), - gfx::PreferIntegratedGpu); - - if (!context_->MakeCurrent(surface_.get())) - DLOG(ERROR) << "Failed to make surface current"; - - device_ = cairo_egl_device_create(gfx::GLSurfaceEGL::GetHardwareDisplay(), - context_->GetHandle()); - if (cairo_device_status(device_) != CAIRO_STATUS_SUCCESS) - DLOG(ERROR) << "Failed to create cairo egl device"; - - cairo_surface_ = cairo_gl_surface_create_for_egl(device_, - surface_->GetHandle(), - allocation_.width(), - allocation_.height()); - cairo_surface_set_user_data(cairo_surface_, - &surface_data_key_, - this, - NULL); - } - - delegate_->OnNativeWidgetCreated(); - - if (params.type != Widget::InitParams::TYPE_TOOLTIP) { - // TODO(dnicoara) Enable this once it works with Wayland - /* - views::TooltipManagerViews* manager = new views::TooltipManagerViews( - static_cast<internal::RootView*>(GetWidget()->GetRootView())); - tooltip_manager_.reset(manager); - */ - } - - // TODO(dnicoara) This should be removed when we can specify the (x, y) - // coordinates for a window. We use fullscreen since it will center the - // window rather than give it random (x, y) coordinates. - wayland_window_->set_fullscreen(true); - Show(); - OnPaint(allocation_); -} - -NonClientFrameView* NativeWidgetWayland::CreateNonClientFrameView() { - return NULL; -} - -void NativeWidgetWayland::UpdateFrameAfterFrameChange() { - NOTIMPLEMENTED(); -} - -bool NativeWidgetWayland::ShouldUseNativeFrame() const { - NOTIMPLEMENTED(); - return false; -} - -void NativeWidgetWayland::FrameTypeChanged() { - // Called when the Theme has changed, so forward the event to the root - // widget - GetWidget()->ThemeChanged(); - GetWidget()->GetRootView()->SchedulePaint(); -} - -Widget* NativeWidgetWayland::GetWidget() { - return delegate_->AsWidget(); -} - -const Widget* NativeWidgetWayland::GetWidget() const { - return delegate_->AsWidget(); -} - -gfx::NativeView NativeWidgetWayland::GetNativeView() const { - return wayland_window_; -} - -gfx::NativeWindow NativeWidgetWayland::GetNativeWindow() const { - return wayland_window_; -} - -Widget* NativeWidgetWayland::GetTopLevelWidget() { - NativeWidgetPrivate* native_widget = GetTopLevelNativeWidget(GetNativeView()); - return native_widget ? native_widget->GetWidget() : NULL; -} - -const ui::Compositor* NativeWidgetWayland::GetCompositor() const { - return compositor_.get(); -} - -ui::Compositor* NativeWidgetWayland::GetCompositor() { - return compositor_.get(); -} - -void NativeWidgetWayland::CalculateOffsetToAncestorWithLayer( - gfx::Point* offset, - ui::Layer** layer_parent) { -} - -void NativeWidgetWayland::ReorderLayers() { -} - -void NativeWidgetWayland::ViewRemoved(View* view) { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::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) { - props_.erase(i); - break; - } - } - - if (value) - props_.push_back(new ViewProp(wayland_window_, name, value)); -} - -void* NativeWidgetWayland::GetNativeWindowProperty(const char* name) const { - return ViewProp::GetValue(wayland_window_, name); -} - -TooltipManager* NativeWidgetWayland::GetTooltipManager() const { - return tooltip_manager_.get(); -} - -bool NativeWidgetWayland::IsScreenReaderActive() const { - return false; -} - -void NativeWidgetWayland::SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::SetMouseCapture() { - NOTIMPLEMENTED(); - has_mouse_capture_ = true; -} - -void NativeWidgetWayland::ReleaseMouseCapture() { - NOTIMPLEMENTED(); - has_mouse_capture_ = false; -} - -bool NativeWidgetWayland::HasMouseCapture() const { - NOTIMPLEMENTED(); - return has_mouse_capture_; -} - -InputMethod* NativeWidgetWayland::CreateInputMethod() { - return new InputMethodWayland(this); -} - -void NativeWidgetWayland::CenterWindow(const gfx::Size& size) { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::GetWindowPlacement( - gfx::Rect* bounds, - ui::WindowShowState* show_state) const { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::SetWindowTitle(const string16& title) { -} - -void NativeWidgetWayland::SetWindowIcons(const SkBitmap& window_icon, - const SkBitmap& app_icon) { -} - -void NativeWidgetWayland::SetAccessibleName(const string16& name) { -} - -void NativeWidgetWayland::SetAccessibleRole( - ui::AccessibilityTypes::Role role) { -} - -void NativeWidgetWayland::SetAccessibleState( - ui::AccessibilityTypes::State state) { -} - -void NativeWidgetWayland::BecomeModal() { - NOTIMPLEMENTED(); -} - -gfx::Rect NativeWidgetWayland::GetWindowScreenBounds() const { - return GetClientAreaScreenBounds(); -} - -gfx::Rect NativeWidgetWayland::GetClientAreaScreenBounds() const { - return allocation_; -} - -gfx::Rect NativeWidgetWayland::GetRestoredBounds() const { - return GetWindowScreenBounds(); -} - -void NativeWidgetWayland::SetBounds(const gfx::Rect& bounds) { - saved_allocation_ = allocation_; - allocation_ = bounds; - - // TODO(dnicoara) This needs to be updated to include (x, y). - wl_egl_window_resize(egl_window_, - allocation_.width(), - allocation_.height(), - 0, 0); - if (!View::get_use_acceleration_when_possible()) { - cairo_gl_surface_set_size(cairo_surface_, - allocation_.width(), - allocation_.height()); - } - - if (compositor_.get()) - compositor_->WidgetSizeChanged(allocation_.size()); - delegate_->OnNativeWidgetSizeChanged(allocation_.size()); -} - -void NativeWidgetWayland::SetSize(const gfx::Size& size) { - gfx::Rect new_alloc = allocation_; - new_alloc.set_size(size); - - SetBounds(new_alloc); -} - -void NativeWidgetWayland::MoveAbove(gfx::NativeView native_view) { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::MoveToTop() { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::SetShape(gfx::NativeRegion shape) { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::Close() { - Hide(); - if (!close_widget_factory_.HasWeakPtrs()) { - MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&NativeWidgetWayland::CloseNow, - close_widget_factory_.GetWeakPtr())); - } -} - -void NativeWidgetWayland::CloseNow() { - delegate_->OnNativeWidgetDestroying(); - delegate_->OnNativeWidgetDestroyed(); - if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) - delete this; -} - -void NativeWidgetWayland::EnableClose(bool enable) { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::Show() { - wayland_window_->SetVisible(true); - delegate_->OnNativeWidgetVisibilityChanged(true); -} - -void NativeWidgetWayland::Hide() { - wayland_window_->SetVisible(false); - delegate_->OnNativeWidgetVisibilityChanged(false); -} - -void NativeWidgetWayland::ShowMaximizedWithBounds( - const gfx::Rect& restored_bounds) { - Show(); - Maximize(); - saved_allocation_ = restored_bounds; -} - -void NativeWidgetWayland::ShowWithWindowState(ui::WindowShowState state) { - NOTIMPLEMENTED(); -} - -bool NativeWidgetWayland::IsVisible() const { - return wayland_window_->IsVisible(); -} - -void NativeWidgetWayland::Activate() { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::Deactivate() { - NOTIMPLEMENTED(); -} - -bool NativeWidgetWayland::IsActive() const { - NOTIMPLEMENTED(); - return true; -} - -void NativeWidgetWayland::SetAlwaysOnTop(bool always_on_top) { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::Maximize() { - std::list<ui::WaylandScreen*> screens = wayland_display_->GetScreenList(); - - if (screens.empty()) - return; - - // TODO(dnicoara) We need to intersect the current coordinates with the - // screen ones and decide the correct screen to fullscreen on. - ui::WaylandScreen* screen = screens.front(); - - SetBounds(screen->GetAllocation()); -} - -void NativeWidgetWayland::Minimize() { - NOTIMPLEMENTED(); -} - -bool NativeWidgetWayland::IsMaximized() const { - NOTIMPLEMENTED(); - return true; -} - -bool NativeWidgetWayland::IsMinimized() const { - NOTIMPLEMENTED(); - return false; -} - -void NativeWidgetWayland::Restore() { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::SetFullscreen(bool fullscreen) { - gfx::Rect new_allocation = allocation_; - - if (fullscreen) { - std::list<ui::WaylandScreen*> screens = wayland_display_->GetScreenList(); - - if (screens.empty()) - return; - - // TODO(dnicoara) What does it mean to be fullscreen when having multiple - // monitors? If we're going fullscreen only on one screen then we need to - // intersect the current coordinates with the screen ones and decide the - // correct screen to fullscreen on. - ui::WaylandScreen* screen = screens.front(); - new_allocation = screen->GetAllocation(); - } else { - new_allocation = saved_allocation_; - } - - wayland_window_->set_fullscreen(fullscreen); - SetBounds(new_allocation); -} - -bool NativeWidgetWayland::IsFullscreen() const { - return wayland_window_->fullscreen(); -} - -void NativeWidgetWayland::SetOpacity(unsigned char opacity) { - NOTIMPLEMENTED(); -} - -void NativeWidgetWayland::SetUseDragFrame(bool use_drag_frame) { - NOTIMPLEMENTED(); -} - -bool NativeWidgetWayland::IsAccessibleWidget() const { - NOTIMPLEMENTED(); - return true; -} - -void NativeWidgetWayland::RunShellDrag(View* view, - const ui::OSExchangeData& data, - int operation) { - NOTIMPLEMENTED(); -} - -gboolean NativeWidgetWayland::IdleRedraw(void* ptr) { - NativeWidgetWayland* widget = static_cast<NativeWidgetWayland*>(ptr); - gfx::Rect damage_area = widget->damage_area_; - widget->damage_area_ = gfx::Rect(); - - widget->OnPaint(damage_area); - - return FALSE; -} - -void NativeWidgetWayland::SchedulePaintInRect(const gfx::Rect& rect) { - if (damage_area_.IsEmpty()) - g_idle_add(NativeWidgetWayland::IdleRedraw, this); - - damage_area_ = damage_area_.Union(rect); -} - -void NativeWidgetWayland::SetCursor(gfx::NativeCursor cursor) { - NOTIMPLEMENTED(); -} - - -void NativeWidgetWayland::ClearNativeFocus() { - NOTIMPLEMENTED(); -} - - -void NativeWidgetWayland::FocusNativeView(gfx::NativeView native_view) { - NOTIMPLEMENTED(); -} - -bool NativeWidgetWayland::ConvertPointFromAncestor( - const Widget* ancestor, gfx::Point* point) const { - NOTREACHED(); - return false; -} - -void NativeWidgetWayland::ScheduleDraw() { - SchedulePaintInRect(allocation_); -} - -// Overridden from NativeWidget -gfx::AcceleratedWidget NativeWidgetWayland::GetAcceleratedWidget() { - return egl_window_; -} - - -// Overridden from internal::InputMethodDelegate -void NativeWidgetWayland::DispatchKeyEventPostIME(const KeyEvent& key) { - NOTIMPLEMENTED(); - delegate_->OnKeyEvent(key); -} - -///////////////////////////////////////////////////////////////////////////// -// NativeWidgetWayland, private, event handlers - -void NativeWidgetWayland::OnPaint(gfx::Rect damage_area) { - if (!delegate_->OnNativeWidgetPaintAccelerated(damage_area)) { - // This is required since the CanvasSkiaPaint damages the surface - // in the destructor so we need to have this done before calling - // swapbuffers. - { - cairo_rectangle_int_t region = damage_area.ToCairoRectangle(); - gfx::CanvasSkiaPaint canvas(cairo_surface_, ®ion); - if (!canvas.is_empty()) { - canvas.set_composite_alpha(false); - delegate_->OnNativeWidgetPaint(&canvas); - } - } - - // Have cairo swap buffers, then let Wayland know of the damaged area. - cairo_gl_surface_swapbuffers(cairo_surface_); - wl_surface_damage(wayland_window_->surface(), - damage_area.x(), damage_area.y(), - damage_area.width(), damage_area.height()); - } -} - -void NativeWidgetWayland::OnMotionNotify(WaylandEvent event) { - MouseEvent mouse_event(&event); - delegate_->OnMouseEvent(mouse_event); -} - -void NativeWidgetWayland::OnButtonNotify(WaylandEvent event) { - if (event.button.button == ui::SCROLL_UP || - event.button.button == ui::SCROLL_DOWN) { - MouseWheelEvent mouse_event(&event); - delegate_->OnMouseEvent(mouse_event); - } else { - MouseEvent mouse_event(&event); - delegate_->OnMouseEvent(mouse_event); - } -} - -void NativeWidgetWayland::OnKeyNotify(WaylandEvent event) { - KeyEvent key_event(&event); - InputMethod* input_method = GetWidget()->GetInputMethodDirect(); - if (input_method) - input_method->DispatchKeyEvent(key_event); - else - DispatchKeyEventPostIME(key_event); -} - -void NativeWidgetWayland::OnPointerFocus(WaylandEvent event) { - MouseEvent mouse_event(&event); - delegate_->OnMouseEvent(mouse_event); -} - -void NativeWidgetWayland::OnKeyboardFocus(WaylandEvent event) { - InputMethod* input_method = GetWidget()->GetInputMethodDirect(); - if (input_method) { - if (event.keyboard_focus.state) - input_method->OnFocus(); - else - input_method->OnBlur(); - } -} - -void NativeWidgetWayland::OnGeometryChange(WaylandEvent event) { - SetSize(gfx::Size(event.geometry_change.width, - event.geometry_change.height)); -} - -///////////////////////////////////////////////////////////////////////////// -// Widget - -// static -bool Widget::ConvertRect(const Widget* source, - const Widget* target, - gfx::Rect* rect) { - DCHECK(source); - DCHECK(target); - DCHECK(rect); - - gfx::NativeView source_widget = source->GetNativeView(); - gfx::NativeView target_widget = target->GetNativeView(); - if (source_widget == target_widget) - return true; - - if (!source_widget || !target_widget) - return false; - - NOTIMPLEMENTED(); - return false; -} - -namespace internal { - -///////////////////////////////////////////////////////////////////////////// -// NativeWidget - -// static -NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( - internal::NativeWidgetDelegate* delegate) { - if (Widget::IsPureViews() && - ViewsDelegate::views_delegate->GetDefaultParentView()) { - return new NativeWidgetViews(delegate); - } - return new NativeWidgetWayland(delegate); -} - -// static -NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView( - gfx::NativeView native_view) { - return reinterpret_cast<NativeWidgetWayland*>( - ViewProp::GetValue(native_view, kNativeWidgetKey)); -} - -// static -NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow( - gfx::NativeWindow native_window) { - return GetNativeWidgetForNativeView(native_window); -} - -// static -NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget( - gfx::NativeView native_view) { - // TODO(dnicoara) What would be the best way to implement this? - // Since there isn't any actual parenting concept in Wayland, we could - // implement it using WaylandWindow->SetParent/GetParent calls. - return GetNativeWidgetForNativeView(native_view); -} - -// static -void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view, - Widget::Widgets* children) { - NOTIMPLEMENTED(); - if (!native_view) - return; -} - -// static -void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, - gfx::NativeView new_parent) { - NOTIMPLEMENTED(); - if (!native_view) - return; -} - -// static -bool NativeWidgetPrivate::IsMouseButtonDown() { - NOTIMPLEMENTED(); - return false; -} - -} // namespace internal - -} // namespace views diff --git a/views/widget/native_widget_wayland.h b/views/widget/native_widget_wayland.h deleted file mode 100644 index 0632c1a..0000000 --- a/views/widget/native_widget_wayland.h +++ /dev/null @@ -1,215 +0,0 @@ -// 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_WAYLAND_H_ -#define VIEWS_WIDGET_NATIVE_WIDGET_WAYLAND_H_ -#pragma once - -#include <wayland-client.h> - -#include "base/memory/scoped_vector.h" -#include "base/memory/weak_ptr.h" -#include "ui/gfx/compositor/compositor.h" -#include "ui/gfx/gl/gl_context.h" -#include "ui/gfx/gl/gl_surface.h" -#include "ui/gfx/size.h" -#include "ui/wayland/wayland_widget.h" -#include "views/widget/native_widget_private.h" -#include "views/widget/widget.h" - -typedef struct _cairo_device cairo_device_t; -typedef struct _cairo_surface cairo_surface_t; - -namespace base { -namespace wayland { -union WaylandEvent; -} -} - -namespace gfx { -class Rect; -} - -namespace ui { -class ViewProp; -class WaylandDisplay; -class WaylandWindow; -} - -namespace views { - -namespace internal { -class NativeWidgetDelegate; -} - -// Widget implementation for Wayland -class NativeWidgetWayland : public internal::NativeWidgetPrivate, - public ui::CompositorDelegate, - public ui::WaylandWidget { - public: - explicit NativeWidgetWayland(internal::NativeWidgetDelegate* delegate); - virtual ~NativeWidgetWayland(); - - // Overridden from NativeWidget: - virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; - virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; - virtual void UpdateFrameAfterFrameChange() OVERRIDE; - virtual bool ShouldUseNativeFrame() const OVERRIDE; - virtual void FrameTypeChanged() OVERRIDE; - virtual Widget* GetWidget() OVERRIDE; - virtual const Widget* GetWidget() const OVERRIDE; - virtual gfx::NativeView GetNativeView() const OVERRIDE; - virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; - virtual Widget* GetTopLevelWidget() OVERRIDE; - virtual const ui::Compositor* GetCompositor() const OVERRIDE; - virtual ui::Compositor* GetCompositor() OVERRIDE; - virtual void CalculateOffsetToAncestorWithLayer( - gfx::Point* offset, - ui::Layer** layer_parent) OVERRIDE; - virtual void ReorderLayers() OVERRIDE; - virtual void ViewRemoved(View* view) OVERRIDE; - virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; - virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE; - virtual TooltipManager* GetTooltipManager() const OVERRIDE; - virtual bool IsScreenReaderActive() const OVERRIDE; - virtual void SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) OVERRIDE; - virtual void SetMouseCapture() OVERRIDE; - virtual void ReleaseMouseCapture() OVERRIDE; - virtual bool HasMouseCapture() const OVERRIDE; - virtual InputMethod* CreateInputMethod() OVERRIDE; - virtual void CenterWindow(const gfx::Size& size) OVERRIDE; - virtual void GetWindowPlacement( - gfx::Rect* bounds, - ui::WindowShowState* show_state) const OVERRIDE; - virtual void SetWindowTitle(const string16& title) OVERRIDE; - virtual void SetWindowIcons(const SkBitmap& window_icon, - const SkBitmap& app_icon) OVERRIDE; - virtual void SetAccessibleName(const string16& name) OVERRIDE; - virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; - virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; - virtual void BecomeModal() OVERRIDE; - virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; - virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; - virtual gfx::Rect GetRestoredBounds() const OVERRIDE; - virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; - virtual void SetSize(const gfx::Size& size) OVERRIDE; - virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; - virtual void MoveToTop() OVERRIDE; - virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; - virtual void Close() OVERRIDE; - virtual void CloseNow() OVERRIDE; - virtual void EnableClose(bool enable) OVERRIDE; - virtual void Show() OVERRIDE; - virtual void Hide() OVERRIDE; - virtual void ShowMaximizedWithBounds( - const gfx::Rect& restored_bounds) OVERRIDE; - virtual void ShowWithWindowState(ui::WindowShowState window_state) OVERRIDE; - virtual bool IsVisible() const OVERRIDE; - virtual void Activate() OVERRIDE; - virtual void Deactivate() OVERRIDE; - virtual bool IsActive() const OVERRIDE; - virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE; - virtual void Maximize() OVERRIDE; - virtual void Minimize() OVERRIDE; - virtual bool IsMaximized() const OVERRIDE; - virtual bool IsMinimized() const OVERRIDE; - virtual void Restore() OVERRIDE; - virtual void SetFullscreen(bool fullscreen) OVERRIDE; - virtual bool IsFullscreen() const OVERRIDE; - virtual void SetOpacity(unsigned char opacity) OVERRIDE; - virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE; - virtual bool IsAccessibleWidget() const OVERRIDE; - virtual void RunShellDrag(View* view, - const ui::OSExchangeData& data, - int operation) OVERRIDE; - virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; - virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; - virtual void ClearNativeFocus() OVERRIDE; - virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; - virtual bool ConvertPointFromAncestor( - const Widget* ancestor, gfx::Point* point) const OVERRIDE; - - virtual void OnMotionNotify(WaylandEvent event) OVERRIDE; - virtual void OnButtonNotify(WaylandEvent event) OVERRIDE; - virtual void OnKeyNotify(WaylandEvent event) OVERRIDE; - virtual void OnPointerFocus(WaylandEvent event) OVERRIDE; - virtual void OnKeyboardFocus(WaylandEvent event) OVERRIDE; - - virtual void OnGeometryChange(WaylandEvent event) OVERRIDE; - - private: - typedef ScopedVector<ui::ViewProp> ViewProps; - - // Overridden from ui::CompositorDelegate - virtual void ScheduleDraw(); - - // Overridden from NativeWidget - virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; - - // Overridden from internal::InputMethodDelegate - virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE; - - void OnPaint(gfx::Rect damage_area); - - static gboolean IdleRedraw(void* ptr); - - // A delegate implementation that handles events received here. - // See class documentation for Widget in widget.h for a note about ownership. - internal::NativeWidgetDelegate* delegate_; - - scoped_ptr<TooltipManager> tooltip_manager_; - - // The following factory is used to delay destruction. - base::WeakPtrFactory<NativeWidgetWayland> close_widget_factory_; - - // See class documentation for Widget in widget.h for a note about ownership. - Widget::InitParams::Ownership ownership_; - - // Keeps track of mause capture for this widget. - bool has_mouse_capture_; - - // Current window allocation - gfx::Rect allocation_; - // Previous allocation. Used to restore the size and location. - gfx::Rect saved_allocation_; - - // The compositor for accelerated drawing. - scoped_refptr<ui::Compositor> compositor_; - - ViewProps props_; - - // Pointer to the Wayland display. This object doesn't own the pointer. - ui::WaylandDisplay* wayland_display_; - - // Wayland window associated with this widget. - ui::WaylandWindow* wayland_window_; - - // The accelerated surface associated with a Wayland window. - struct wl_egl_window* egl_window_; - - cairo_device_t* device_; - - // Cairo surface associated with the Wayland accelerated surface. This is - // used when we're not using the accelerated painting path. - cairo_surface_t* cairo_surface_; - const cairo_user_data_key_t surface_data_key_; - - // Used to accumulate damaged area between repaints. - // Necessary since Wayland seems to expect at most one paint per frame. - gfx::Rect damage_area_; - - // The GL surface and context used to render when we're using unaccelerated - // rendering. If we're using accelerated rendering, we'll have a compositor - // and the compositor will have these, so we don't need to worry about them. - scoped_refptr<gfx::GLSurface> surface_; - scoped_refptr<gfx::GLContext> context_; - - DISALLOW_COPY_AND_ASSIGN(NativeWidgetWayland); -}; - -} // namespace views - -#endif // VIEWS_WIDGET_NATIVE_WIDGET_WAYLAND_H_ diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc index 2b512ea..7c013f9 100644 --- a/views/widget/native_widget_win.cc +++ b/views/widget/native_widget_win.cc @@ -45,7 +45,6 @@ #include "views/widget/drop_target_win.h" #include "views/widget/monitor_win.h" #include "views/widget/native_widget_delegate.h" -#include "views/widget/native_widget_views.h" #include "views/widget/root_view.h" #include "views/widget/widget_delegate.h" @@ -2412,10 +2411,6 @@ namespace internal { // static NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( internal::NativeWidgetDelegate* delegate) { - if (Widget::IsPureViews() && - ViewsDelegate::views_delegate->GetDefaultParentView()) { - return new NativeWidgetViews(delegate); - } return new NativeWidgetWin(delegate); } diff --git a/views/widget/widget_unittest.cc b/views/widget/widget_unittest.cc index f4a72f9..736d699 100644 --- a/views/widget/widget_unittest.cc +++ b/views/widget/widget_unittest.cc @@ -2,15 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "views/widget/native_widget_views.h" - #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/views/test/test_views_delegate.h" #include "ui/views/test/views_test_base.h" +#include "ui/gfx/point.h" +#include "ui/gfx/native_widget_types.h" #include "views/views_delegate.h" +#include "views/widget/native_widget_delegate.h" #if defined(USE_AURA) #include "ui/aura/window.h" @@ -24,14 +25,25 @@ namespace views { namespace { -#if defined(TOOLKIT_USES_GTK) -// A widget that assumes mouse capture always works. -class NativeWidgetGtkCapture : public NativeWidgetGtk { +// A generic typedef to pick up relevant NativeWidget implementations. +#if defined(USE_AURA) +typedef NativeWidgetAura NativeWidgetPlatform; +#elif defined(OS_WIN) +typedef NativeWidgetWin NativeWidgetPlatform; +#elif defined(TOOLKIT_USES_GTK) +typedef NativeWidgetGtk NativeWidgetPlatform; +#endif + +// A widget that assumes mouse capture always works. It won't on Gtk/Aura in +// testing, so we mock it. +#if defined(TOOLKIT_USES_GTK) || defined(USE_AURA) +class NativeWidgetCapture : public NativeWidgetPlatform { public: - NativeWidgetGtkCapture(internal::NativeWidgetDelegate* delegate) - : NativeWidgetGtk(delegate), + NativeWidgetCapture(internal::NativeWidgetDelegate* delegate) + : NativeWidgetPlatform(delegate), mouse_capture_(false) {} - virtual ~NativeWidgetGtkCapture() {} + virtual ~NativeWidgetCapture() {} + virtual void SetMouseCapture() OVERRIDE { mouse_capture_ = true; } @@ -47,10 +59,20 @@ class NativeWidgetGtkCapture : public NativeWidgetGtk { private: bool mouse_capture_; - DISALLOW_COPY_AND_ASSIGN(NativeWidgetGtkCapture); + DISALLOW_COPY_AND_ASSIGN(NativeWidgetCapture); }; #endif +// A typedef that inserts our mock-capture NativeWidget implementation for +// relevant platforms. +#if defined(USE_AURA) +typedef NativeWidgetCapture NativeWidgetPlatformForTest; +#elif defined(OS_WIN) +typedef NativeWidgetWin NativeWidgetPlatformForTest; +#elif defined(TOOLKIT_USES_GTK) +typedef NativeWidgetCapture NativeWidgetPlatformForTest; +#endif + // A view that always processes all mouse events. class MouseView : public View { public: @@ -63,56 +85,11 @@ class MouseView : public View { } }; -class WidgetTestViewsDelegate : public TestViewsDelegate { - public: - WidgetTestViewsDelegate() : default_parent_view_(NULL) { - } - virtual ~WidgetTestViewsDelegate() {} - - void set_default_parent_view(View* default_parent_view) { - default_parent_view_ = default_parent_view; - } - - // Overridden from TestViewsDelegate: - virtual View* GetDefaultParentView() OVERRIDE { - return default_parent_view_; - } - - private: - View* default_parent_view_; - - DISALLOW_COPY_AND_ASSIGN(WidgetTestViewsDelegate); -}; - -class WidgetTest : public ViewsTestBase { - public: - WidgetTest() { - } - virtual ~WidgetTest() { - } - - virtual void SetUp() OVERRIDE { - set_views_delegate(new WidgetTestViewsDelegate()); - ViewsTestBase::SetUp(); - } - - WidgetTestViewsDelegate& widget_views_delegate() const { - return static_cast<WidgetTestViewsDelegate&>(views_delegate()); - } - - private: - DISALLOW_COPY_AND_ASSIGN(WidgetTest); -}; +typedef ViewsTestBase WidgetTest; NativeWidget* CreatePlatformNativeWidget( internal::NativeWidgetDelegate* delegate) { -#if defined(USE_AURA) - return new NativeWidgetAura(delegate); -#elif defined(OS_WIN) - return new NativeWidgetWin(delegate); -#elif defined(TOOLKIT_USES_GTK) - return new NativeWidgetGtkCapture(delegate); -#endif + return new NativeWidgetPlatformForTest(delegate); } Widget* CreateTopLevelPlatformWidget() { @@ -147,32 +124,30 @@ Widget* CreateChildPopupPlatformWidget(gfx::NativeView parent_native_view) { } #endif -Widget* CreateTopLevelNativeWidgetViews() { +Widget* CreateTopLevelNativeWidget() { Widget* toplevel = new Widget; Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); - params.native_widget = new NativeWidgetViews(toplevel); toplevel->Init(params); toplevel->SetContentsView(new View); return toplevel; } -Widget* CreateChildNativeWidgetViewsWithParent(Widget* parent) { +Widget* CreateChildNativeWidgetWithParent(Widget* parent) { Widget* child = new Widget; Widget::InitParams params(Widget::InitParams::TYPE_CONTROL); - params.native_widget = new NativeWidgetViews(child); params.parent_widget = parent; child->Init(params); child->SetContentsView(new View); return child; } -Widget* CreateChildNativeWidgetViews() { - return CreateChildNativeWidgetViewsWithParent(NULL); +Widget* CreateChildNativeWidget() { + return CreateChildNativeWidgetWithParent(NULL); } bool WidgetHasMouseCapture(const Widget* widget) { return static_cast<const internal::NativeWidgetPrivate*>(widget-> - native_widget())-> HasMouseCapture(); + native_widget())->HasMouseCapture(); } //////////////////////////////////////////////////////////////////////////////// @@ -199,10 +174,9 @@ TEST_F(WidgetTest, GetTopLevelWidget_Native) { TEST_F(WidgetTest, GetTopLevelWidget_Synthetic) { // Create a hierarchy consisting of a top level platform native widget and a - // child NativeWidgetViews. + // child NativeWidget. Widget* toplevel = CreateTopLevelPlatformWidget(); - widget_views_delegate().set_default_parent_view(toplevel->GetRootView()); - Widget* child = CreateTopLevelNativeWidgetViews(); + Widget* child = CreateTopLevelNativeWidget(); EXPECT_EQ(toplevel, toplevel->GetTopLevelWidget()); EXPECT_EQ(child, child->GetTopLevelWidget()); @@ -212,18 +186,16 @@ TEST_F(WidgetTest, GetTopLevelWidget_Synthetic) { } // Creates a hierarchy consisting of a desktop platform native widget, a -// toplevel NativeWidgetViews, and a child of that toplevel, another -// NativeWidgetViews. +// toplevel NativeWidget, and a child of that toplevel, another NativeWidget. TEST_F(WidgetTest, GetTopLevelWidget_SyntheticDesktop) { // Create a hierarchy consisting of a desktop platform native widget, - // a toplevel NativeWidgetViews and a chlid NativeWidgetViews. + // a toplevel NativeWidget and a chlid NativeWidget. Widget* desktop = CreateTopLevelPlatformWidget(); - widget_views_delegate().set_default_parent_view(desktop->GetRootView()); - Widget* toplevel = CreateTopLevelNativeWidgetViews(); // Will be parented - // automatically to - // |toplevel|. + Widget* toplevel = CreateTopLevelNativeWidget(); // Will be parented + // automatically to + // |toplevel|. - Widget* child = CreateChildNativeWidgetViewsWithParent(toplevel); + Widget* child = CreateChildNativeWidgetWithParent(toplevel); EXPECT_EQ(desktop, desktop->GetTopLevelWidget()); EXPECT_EQ(toplevel, toplevel->GetTopLevelWidget()); @@ -233,17 +205,11 @@ TEST_F(WidgetTest, GetTopLevelWidget_SyntheticDesktop) { // |toplevel|, |child| should be automatically destroyed with |toplevel|. } -// This is flaky on touch build. See crbug.com/94137. -#if defined(TOUCH_UI) -#define MAYBE_GrabUngrab DISABLED_GrabUngrab -#else -#define MAYBE_GrabUngrab GrabUngrab -#endif // Tests some grab/ungrab events. -TEST_F(WidgetTest, MAYBE_GrabUngrab) { +TEST_F(WidgetTest, DISABLED_GrabUngrab) { Widget* toplevel = CreateTopLevelPlatformWidget(); - Widget* child1 = CreateChildNativeWidgetViewsWithParent(toplevel); - Widget* child2 = CreateChildNativeWidgetViewsWithParent(toplevel); + Widget* child1 = CreateChildNativeWidgetWithParent(toplevel); + Widget* child2 = CreateChildNativeWidgetWithParent(toplevel); toplevel->SetBounds(gfx::Rect(0, 0, 500, 500)); @@ -379,16 +345,15 @@ TEST_F(WidgetTest, Visibility_ChildPopup) { // Tests visibility of synthetic child widgets. TEST_F(WidgetTest, Visibility_Synthetic) { // Create a hierarchy consisting of a desktop platform native widget, - // a toplevel NativeWidgetViews and a chlid NativeWidgetViews. + // a toplevel NativeWidget and a chlid NativeWidget. Widget* desktop = CreateTopLevelPlatformWidget(); desktop->Show(); - widget_views_delegate().set_default_parent_view(desktop->GetRootView()); - Widget* toplevel = CreateTopLevelNativeWidgetViews(); // Will be parented - // automatically to - // |toplevel|. + Widget* toplevel = CreateTopLevelNativeWidget(); // Will be parented + // automatically to + // |toplevel|. - Widget* child = CreateChildNativeWidgetViewsWithParent(toplevel); + Widget* child = CreateChildNativeWidgetWithParent(toplevel); EXPECT_FALSE(toplevel->IsVisible()); EXPECT_FALSE(child->IsVisible()); @@ -412,8 +377,7 @@ TEST_F(WidgetTest, Visibility_Synthetic) { // Tests various permutations of Widget ownership specified in the // InitParams::Ownership param. -// A WidgetTest that supplies a toplevel widget for NativeWidgetViews to parent -// to. +// A WidgetTest that supplies a toplevel widget for NativeWidget to parent to. class WidgetOwnershipTest : public WidgetTest { public: WidgetOwnershipTest() {} @@ -422,8 +386,6 @@ class WidgetOwnershipTest : public WidgetTest { virtual void SetUp() { WidgetTest::SetUp(); desktop_widget_ = CreateTopLevelPlatformWidget(); - widget_views_delegate().set_default_parent_view( - desktop_widget_->GetRootView()); } virtual void TearDown() { @@ -447,25 +409,12 @@ struct OwnershipTestState { // A platform NativeWidget subclass that updates a bag of state when it is // destroyed. -class OwnershipTestNativeWidget : -#if defined(USE_AURA) - public NativeWidgetAura { -#elif defined(OS_WIN) - public NativeWidgetWin { -#elif defined(TOOLKIT_USES_GTK) - public NativeWidgetGtk { -#endif -public: +class OwnershipTestNativeWidget : public NativeWidgetPlatform { + public: OwnershipTestNativeWidget(internal::NativeWidgetDelegate* delegate, OwnershipTestState* state) -#if defined(USE_AURA) - : NativeWidgetAura(delegate), -#elif defined(OS_WIN) - : NativeWidgetWin(delegate), -#elif defined(TOOLKIT_USES_GTK) - : NativeWidgetGtk(delegate), -#endif - state_(state) { + : NativeWidgetPlatform(delegate), + state_(state) { } virtual ~OwnershipTestNativeWidget() { state_->native_widget_deleted = true; @@ -479,21 +428,21 @@ public: // A views NativeWidget subclass that updates a bag of state when it is // destroyed. -class OwnershipTestNativeWidgetViews : public NativeWidgetViews { +class OwnershipTestNativeWidgetPlatform : public NativeWidgetPlatformForTest { public: - OwnershipTestNativeWidgetViews(internal::NativeWidgetDelegate* delegate, - OwnershipTestState* state) - : NativeWidgetViews(delegate), + OwnershipTestNativeWidgetPlatform(internal::NativeWidgetDelegate* delegate, + OwnershipTestState* state) + : NativeWidgetPlatformForTest(delegate), state_(state) { } - virtual ~OwnershipTestNativeWidgetViews() { + virtual ~OwnershipTestNativeWidgetPlatform() { state_->native_widget_deleted = true; } private: OwnershipTestState* state_; - DISALLOW_COPY_AND_ASSIGN(OwnershipTestNativeWidgetViews); + DISALLOW_COPY_AND_ASSIGN(OwnershipTestNativeWidgetPlatform); }; // A Widget subclass that updates a bag of state when it is destroyed. @@ -517,7 +466,8 @@ TEST_F(WidgetOwnershipTest, Ownership_WidgetOwnsPlatformNativeWidget) { scoped_ptr<Widget> widget(new OwnershipTestWidget(&state)); Widget::InitParams params(Widget::InitParams::TYPE_POPUP); - params.native_widget = new OwnershipTestNativeWidget(widget.get(), &state); + params.native_widget = + new OwnershipTestNativeWidgetPlatform(widget.get(), &state); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget->Init(params); @@ -531,14 +481,14 @@ TEST_F(WidgetOwnershipTest, Ownership_WidgetOwnsPlatformNativeWidget) { // being deleted out from under the Widget. } -// Widget owns its NativeWidget, part 2: NativeWidget is a NativeWidgetViews. +// Widget owns its NativeWidget, part 2: NativeWidget is a NativeWidget. TEST_F(WidgetOwnershipTest, Ownership_WidgetOwnsViewsNativeWidget) { OwnershipTestState state; scoped_ptr<Widget> widget(new OwnershipTestWidget(&state)); Widget::InitParams params(Widget::InitParams::TYPE_POPUP); params.native_widget = - new OwnershipTestNativeWidgetViews(widget.get(), &state); + new OwnershipTestNativeWidgetPlatform(widget.get(), &state); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget->Init(params); @@ -552,7 +502,7 @@ TEST_F(WidgetOwnershipTest, Ownership_WidgetOwnsViewsNativeWidget) { // being deleted out from under the Widget. } -// Widget owns its NativeWidget, part 3: NativeWidget is a NativeWidgetViews, +// Widget owns its NativeWidget, part 3: NativeWidget is a NativeWidget, // destroy the parent view. TEST_F(WidgetOwnershipTest, Ownership_WidgetOwnsViewsNativeWidget_DestroyParentView) { @@ -562,8 +512,8 @@ TEST_F(WidgetOwnershipTest, scoped_ptr<Widget> widget(new OwnershipTestWidget(&state)); Widget::InitParams params(Widget::InitParams::TYPE_POPUP); - params.native_widget = new OwnershipTestNativeWidgetViews(widget.get(), - &state); + params.native_widget = + new OwnershipTestNativeWidgetPlatform(widget.get(), &state); params.parent_widget = toplevel; params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget->Init(params); @@ -592,7 +542,8 @@ TEST_F(WidgetOwnershipTest, Ownership_PlatformNativeWidgetOwnsWidget) { Widget* widget = new OwnershipTestWidget(&state); Widget::InitParams params(Widget::InitParams::TYPE_POPUP); - params.native_widget = new OwnershipTestNativeWidget(widget, &state); + params.native_widget = + new OwnershipTestNativeWidgetPlatform(widget, &state); widget->Init(params); // Now destroy the native widget. @@ -602,7 +553,7 @@ TEST_F(WidgetOwnershipTest, Ownership_PlatformNativeWidgetOwnsWidget) { EXPECT_TRUE(state.native_widget_deleted); } -// NativeWidget owns its Widget, part 2: NativeWidget is a NativeWidgetViews. +// NativeWidget owns its Widget, part 2: NativeWidget is a NativeWidget. TEST_F(WidgetOwnershipTest, Ownership_ViewsNativeWidgetOwnsWidget) { OwnershipTestState state; @@ -610,16 +561,16 @@ TEST_F(WidgetOwnershipTest, Ownership_ViewsNativeWidgetOwnsWidget) { Widget* widget = new OwnershipTestWidget(&state); Widget::InitParams params(Widget::InitParams::TYPE_POPUP); - params.native_widget = new OwnershipTestNativeWidgetViews(widget, &state); + params.native_widget = + new OwnershipTestNativeWidgetPlatform(widget, &state); params.parent_widget = toplevel; widget->Init(params); // Now destroy the native widget. This is achieved by closing the toplevel. toplevel->CloseNow(); - // The NativeWidgetViews won't be deleted until after a return to the message - // loop so we have to run pending messages before testing the destruction - // status. + // The NativeWidget won't be deleted until after a return to the message loop + // so we have to run pending messages before testing the destruction status. RunPendingMessages(); EXPECT_TRUE(state.widget_deleted); @@ -634,7 +585,8 @@ TEST_F(WidgetOwnershipTest, Widget* widget = new OwnershipTestWidget(&state); Widget::InitParams params(Widget::InitParams::TYPE_POPUP); - params.native_widget = new OwnershipTestNativeWidget(widget, &state); + params.native_widget = + new OwnershipTestNativeWidgetPlatform(widget, &state); widget->Init(params); // Now simulate a destroy of the platform native widget from the OS: @@ -650,7 +602,7 @@ TEST_F(WidgetOwnershipTest, EXPECT_TRUE(state.native_widget_deleted); } -// NativeWidget owns its Widget, part 4: NativeWidget is a NativeWidgetViews, +// NativeWidget owns its Widget, part 4: NativeWidget is a NativeWidget, // destroyed by the view hierarchy that contains it. TEST_F(WidgetOwnershipTest, Ownership_ViewsNativeWidgetOwnsWidget_NativeDestroy) { @@ -660,23 +612,23 @@ TEST_F(WidgetOwnershipTest, Widget* widget = new OwnershipTestWidget(&state); Widget::InitParams params(Widget::InitParams::TYPE_POPUP); - params.native_widget = new OwnershipTestNativeWidgetViews(widget, &state); + params.native_widget = + new OwnershipTestNativeWidgetPlatform(widget, &state); params.parent_widget = toplevel; widget->Init(params); // Destroy the widget (achieved by closing the toplevel). toplevel->CloseNow(); - // The NativeWidgetViews won't be deleted until after a return to the message - // loop so we have to run pending messages before testing the destruction - // status. + // The NativeWidget won't be deleted until after a return to the message loop + // so we have to run pending messages before testing the destruction status. RunPendingMessages(); EXPECT_TRUE(state.widget_deleted); EXPECT_TRUE(state.native_widget_deleted); } -// NativeWidget owns its Widget, part 5: NativeWidget is a NativeWidgetViews, +// NativeWidget owns its Widget, part 5: NativeWidget is a NativeWidget, // we close it directly. TEST_F(WidgetOwnershipTest, Ownership_ViewsNativeWidgetOwnsWidget_Close) { @@ -686,7 +638,8 @@ TEST_F(WidgetOwnershipTest, Widget* widget = new OwnershipTestWidget(&state); Widget::InitParams params(Widget::InitParams::TYPE_POPUP); - params.native_widget = new OwnershipTestNativeWidgetViews(widget, &state); + params.native_widget = + new OwnershipTestNativeWidgetPlatform(widget, &state); params.parent_widget = toplevel; widget->Init(params); @@ -694,9 +647,8 @@ TEST_F(WidgetOwnershipTest, widget->Close(); toplevel->CloseNow(); - // The NativeWidgetViews won't be deleted until after a return to the message - // loop so we have to run pending messages before testing the destruction - // status. + // The NativeWidget won't be deleted until after a return to the message loop + // so we have to run pending messages before testing the destruction status. RunPendingMessages(); EXPECT_TRUE(state.widget_deleted); @@ -758,7 +710,7 @@ class WidgetObserverTest : public WidgetTest, } Widget* NewWidget() { - Widget* widget = CreateTopLevelNativeWidgetViews(); + Widget* widget = CreateTopLevelNativeWidget(); widget->AddObserver(this); return widget; } @@ -781,9 +733,8 @@ class WidgetObserverTest : public WidgetTest, Widget* widget_hidden_; }; -TEST_F(WidgetObserverTest, ActivationChange) { +TEST_F(WidgetObserverTest, DISABLED_ActivationChange) { Widget* toplevel = CreateTopLevelPlatformWidget(); - widget_views_delegate().set_default_parent_view(toplevel->GetRootView()); Widget* toplevel1 = NewWidget(); Widget* toplevel2 = NewWidget(); @@ -807,9 +758,8 @@ TEST_F(WidgetObserverTest, ActivationChange) { toplevel->CloseNow(); } -TEST_F(WidgetObserverTest, VisibilityChange) { +TEST_F(WidgetObserverTest, DISABLED_VisibilityChange) { Widget* toplevel = CreateTopLevelPlatformWidget(); - widget_views_delegate().set_default_parent_view(toplevel->GetRootView()); Widget* child1 = NewWidget(); Widget* child2 = NewWidget(); |