diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura_shell/aura_shell.gyp | 16 | ||||
-rw-r--r-- | ui/views/aura_desktop/aura_desktop_main.cc | 188 | ||||
-rw-r--r-- | ui/views/desktop/desktop_background.cc | 55 | ||||
-rw-r--r-- | ui/views/desktop/desktop_background.h | 29 | ||||
-rw-r--r-- | ui/views/desktop/desktop_main.cc | 90 | ||||
-rw-r--r-- | ui/views/desktop/desktop_views_delegate.cc | 76 | ||||
-rw-r--r-- | ui/views/desktop/desktop_views_delegate.h | 51 | ||||
-rw-r--r-- | ui/views/desktop/desktop_window_manager.cc | 305 | ||||
-rw-r--r-- | ui/views/desktop/desktop_window_manager.h | 99 | ||||
-rw-r--r-- | ui/views/desktop/desktop_window_view.cc | 295 | ||||
-rw-r--r-- | ui/views/desktop/desktop_window_view.h | 100 | ||||
-rw-r--r-- | ui/views/events/event_wayland.cc | 23 | ||||
-rw-r--r-- | ui/views/examples/examples_main.cc | 2 | ||||
-rw-r--r-- | ui/views/focus/accelerator_handler_touch.cc | 188 | ||||
-rw-r--r-- | ui/views/ime/input_method_wayland.cc | 76 | ||||
-rw-r--r-- | ui/views/ime/input_method_wayland.h | 36 | ||||
-rw-r--r-- | ui/views/test/test_views_delegate.cc | 7 | ||||
-rw-r--r-- | ui/views/test/test_views_delegate.h | 6 | ||||
-rw-r--r-- | ui/views/touchui/gesture_manager.cc | 32 |
19 files changed, 11 insertions, 1663 deletions
diff --git a/ui/aura_shell/aura_shell.gyp b/ui/aura_shell/aura_shell.gyp index 1b8667e..5639feb 100644 --- a/ui/aura_shell/aura_shell.gyp +++ b/ui/aura_shell/aura_shell.gyp @@ -185,21 +185,5 @@ '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.rc', ], }, - # It's convenient for aura_shell developers to be able to build all - # compositor and aura targets from within this solution. - { - 'target_name': 'buildbot_targets', - 'type': 'none', - 'dependencies': [ - '../../views/views.gyp:views', - '../../views/views.gyp:views_aura_desktop', - '../../views/views.gyp:views_desktop', - '../../views/views.gyp:views_desktop_lib', - '../../views/views.gyp:views_unittests', - '../aura/aura.gyp:*', - '../gfx/compositor/compositor.gyp:*', - 'aura_shell_exe', - ], - }, ], } diff --git a/ui/views/aura_desktop/aura_desktop_main.cc b/ui/views/aura_desktop/aura_desktop_main.cc deleted file mode 100644 index 4fb47e5..0000000 --- a/ui/views/aura_desktop/aura_desktop_main.cc +++ /dev/null @@ -1,188 +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 "base/at_exit.h" -#include "base/command_line.h" -#include "base/i18n/icu_util.h" -#include "base/memory/scoped_ptr.h" -#include "base/message_loop.h" -#include "base/utf_string_conversions.h" -#include "third_party/skia/include/core/SkXfermode.h" -#include "ui/aura/desktop.h" -#include "ui/aura/desktop_host.h" -#include "ui/aura/window.h" -#include "ui/aura/window_delegate.h" -#include "ui/base/hit_test.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/base/ui_base_paths.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/canvas_skia.h" -#include "ui/gfx/rect.h" -#include "views/widget/widget.h" -#include "views/widget/widget_delegate.h" - -namespace { - -// Trivial WindowDelegate implementation that draws a colored background. -class DemoWindowDelegate : public aura::WindowDelegate { - public: - explicit DemoWindowDelegate(SkColor color) : color_(color) {} - - // Overridden from aura::WindowDelegate: - virtual void OnBoundsChanging(gfx::Rect* new_bounds) OVERRIDE {} - virtual void OnBoundsChanged(const gfx::Rect& old_bounds, - const gfx::Rect& new_bounds) OVERRIDE {} - virtual void OnFocus() OVERRIDE {} - virtual void OnBlur() OVERRIDE {} - virtual bool OnKeyEvent(aura::KeyEvent* event) OVERRIDE { - return false; - } - virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE { - return gfx::kNullCursor; - } - virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE { - return HTCLIENT; - } - virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE { - return true; - } - virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE { - return ui::TOUCH_STATUS_END; - } - virtual bool ShouldActivate(aura::Event* event) OVERRIDE { - return true; - } - virtual void OnActivated() OVERRIDE {} - virtual void OnLostActive() OVERRIDE {} - virtual void OnCaptureLost() OVERRIDE {} - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { - canvas->GetSkCanvas()->drawColor(color_, SkXfermode::kSrc_Mode); - } - virtual void OnWindowDestroying() OVERRIDE { - } - virtual void OnWindowDestroyed() OVERRIDE { - } - virtual void OnWindowVisibilityChanged(bool visible) OVERRIDE { - } - - private: - SkColor color_; - - DISALLOW_COPY_AND_ASSIGN(DemoWindowDelegate); -}; - -class TestView : public views::View { - public: - TestView() : color_shifting_(false), color_(SK_ColorYELLOW) {} - virtual ~TestView() {} - - private: - // Overridden from views::View: - virtual void OnPaint(gfx::Canvas* canvas) { - canvas->FillRect(color_, GetLocalBounds()); - } - virtual bool OnMousePressed(const views::MouseEvent& event) { - color_shifting_ = true; - return true; - } - virtual void OnMouseMoved(const views::MouseEvent& event) { - if (color_shifting_) { - color_ = SkColorSetRGB((SkColorGetR(color_) + 5) % 255, - SkColorGetG(color_), - SkColorGetB(color_)); - SchedulePaint(); - } - } - virtual void OnMouseReleased(const views::MouseEvent& event) { - color_shifting_ = false; - } - - bool color_shifting_; - SkColor color_; - - DISALLOW_COPY_AND_ASSIGN(TestView); -}; - -class TestWindowContents : public views::WidgetDelegateView { - public: - TestWindowContents() {} - virtual ~TestWindowContents() {} - - private: - // Overridden from views::View: - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { - canvas->FillRect(SK_ColorGRAY, GetLocalBounds()); - } - - // Overridden from views::WidgetDelegateView: - virtual string16 GetWindowTitle() const OVERRIDE { - return ASCIIToUTF16("Test Window!"); - } - virtual View* GetContentsView() OVERRIDE { - return this; - } - - DISALLOW_COPY_AND_ASSIGN(TestWindowContents); -}; - -} // namespace - -int main(int argc, char** argv) { - CommandLine::Init(argc, argv); - - // The exit manager is in charge of calling the dtors of singleton objects. - base::AtExitManager exit_manager; - - ui::RegisterPathProvider(); - icu_util::Initialize(); - ResourceBundle::InitSharedInstance("en-US"); - - // Create the message-loop here before creating the desktop. - MessageLoop message_loop(MessageLoop::TYPE_UI); - - aura::Desktop::GetInstance(); - - // Create a hierarchy of test windows. - DemoWindowDelegate window_delegate1(SK_ColorBLUE); - aura::Window* window1 = new aura::Window(&window_delegate1); - window1->set_id(1); - window1->Init(ui::Layer::LAYER_HAS_TEXTURE); - window1->SetBounds(gfx::Rect(100, 100, 400, 400)); - window1->Show(); - window1->SetParent(NULL); - - DemoWindowDelegate window_delegate2(SK_ColorRED); - aura::Window* window2 = new aura::Window(&window_delegate2); - window2->set_id(2); - window2->Init(ui::Layer::LAYER_HAS_TEXTURE); - window2->SetBounds(gfx::Rect(200, 200, 350, 350)); - window2->Show(); - window2->SetParent(NULL); - - DemoWindowDelegate window_delegate3(SK_ColorGREEN); - aura::Window* window3 = new aura::Window(&window_delegate3); - window3->set_id(3); - window3->Init(ui::Layer::LAYER_HAS_TEXTURE); - window3->SetBounds(gfx::Rect(10, 10, 50, 50)); - window3->Show(); - window3->SetParent(window2); - - views::Widget* widget = new views::Widget; - views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); - params.bounds = gfx::Rect(75, 75, 80, 80); - params.parent = window2; - widget->Init(params); - widget->SetContentsView(new TestView); - - TestWindowContents* contents = new TestWindowContents; - views::Widget* views_window = views::Widget::CreateWindowWithParentAndBounds( - contents, window2, gfx::Rect(120, 150, 200, 200)); - views_window->Show(); - - aura::Desktop::GetInstance()->Run(); - - delete aura::Desktop::GetInstance(); - - return 0; -} diff --git a/ui/views/desktop/desktop_background.cc b/ui/views/desktop/desktop_background.cc deleted file mode 100644 index 7f2ab85..0000000 --- a/ui/views/desktop/desktop_background.cc +++ /dev/null @@ -1,55 +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 "ui/views/desktop/desktop_background.h" - -#include "ui/gfx/canvas_skia.h" -#include "ui/gfx/path.h" -#include "views/view.h" - -namespace views { -namespace desktop { - -DesktopBackground::DesktopBackground() { -} - -DesktopBackground::~DesktopBackground() { -} - -void DesktopBackground::Paint(gfx::Canvas* canvas, View* view) const { - // Paint the sky. - canvas->FillRect(SK_ColorCYAN, view->GetLocalBounds()); - - SkPaint paint; - paint.setAntiAlias(true); - paint.setStyle(SkPaint::kFill_Style); - - // Paint the rolling fields of green. - { - gfx::Path path; - path.moveTo(0, view->height() / 2); - path.cubicTo(view->height() / 4, view->height() / 4, - view->height() / 2, view->height() / 2, - SkIntToScalar(view->width()), view->height() / 2); - path.lineTo(SkIntToScalar(view->width()), SkIntToScalar(view->height())); - path.lineTo(0, SkIntToScalar(view->height())); - path.close(); - - paint.setColor(SK_ColorGREEN); - canvas->GetSkCanvas()->drawPath(path, paint); - } - - // Paint the shining sun. - { - gfx::Path path; - path.addCircle(view->height() / 4, view->height() / 8, view->height() / 16); - path.close(); - - paint.setColor(SK_ColorYELLOW); - canvas->GetSkCanvas()->drawPath(path, paint); - } -} - -} // namespace desktop -} // namespace views diff --git a/ui/views/desktop/desktop_background.h b/ui/views/desktop/desktop_background.h deleted file mode 100644 index a4f1de8..0000000 --- a/ui/views/desktop/desktop_background.h +++ /dev/null @@ -1,29 +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 UI_VIEWS_DESKTOP_DESKTOP_BACKGROUND_H_ -#define UI_VIEWS_DESKTOP_DESKTOP_BACKGROUND_H_ - -#include "base/compiler_specific.h" -#include "views/background.h" - -namespace views { -namespace desktop { - -class DesktopBackground : public Background { - public: - DesktopBackground(); - virtual ~DesktopBackground(); - - private: - // Overridden from Background: - virtual void Paint(gfx::Canvas* canvas, View* view) const OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(DesktopBackground); -}; - -} // namespace desktop -} // namespace views - -#endif // UI_VIEWS_DESKTOP_DESKTOP_BACKGROUND_H_ diff --git a/ui/views/desktop/desktop_main.cc b/ui/views/desktop/desktop_main.cc deleted file mode 100644 index 9fed7a0..0000000 --- a/ui/views/desktop/desktop_main.cc +++ /dev/null @@ -1,90 +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 "base/at_exit.h" -#include "base/command_line.h" -#include "base/i18n/icu_util.h" -#include "base/process_util.h" -#include "base/utf_string_conversions.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/base/ui_base_paths.h" -#include "ui/views/desktop/desktop_views_delegate.h" -#include "ui/views/desktop/desktop_window_view.h" -#include "ui/views/focus/accelerator_handler.h" -#include "views/widget/widget.h" - -#if defined(OS_WIN) -#include <ole2.h> -#endif - -#if defined(USE_WAYLAND) -#include "ui/gfx/gl/gl_surface_egl.h" -#include "ui/wayland/wayland_display.h" -#include "ui/wayland/wayland_message_pump.h" -#endif - -#if defined(TOOLKIT_USES_GTK) -#include <gtk/gtk.h> -#elif defined(OS_LINUX) -#include <glib.h> -#include <glib-object.h> -#endif - -int main(int argc, char** argv) { -#if defined(OS_WIN) - OleInitialize(NULL); -#elif defined(OS_LINUX) - // Initializes gtk stuff. - g_type_init(); -#if defined(TOOLKIT_USES_GTK) && !defined(USE_WAYLAND) - gtk_init(&argc, &argv); -#endif -#endif - - CommandLine::Init(argc, argv); - - base::EnableTerminationOnHeapCorruption(); - - // The exit manager is in charge of calling the dtors of singleton objects. - base::AtExitManager exit_manager; - - ui::RegisterPathProvider(); - icu_util::Initialize(); - - ResourceBundle::InitSharedInstance("en-US"); - -#if defined(USE_WAYLAND) - // Wayland uses EGL for drawing, so we need to initialize this as early as - // possible. - if (!gfx::GLSurface::InitializeOneOff()) { - LOG(ERROR) << "Failed to initialize GLSurface"; - return -1; - } - ui::WaylandMessagePump wayland_message_pump( - ui::WaylandDisplay::GetDisplay(gfx::GLSurfaceEGL::GetNativeDisplay())); -#endif - MessageLoop main_message_loop(MessageLoop::TYPE_UI); - - views::desktop::DesktopViewsDelegate views_delegate; - - // Desktop mode only supports a pure-views configuration. - views::Widget::SetPureViews(true); - - views::desktop::DesktopWindowView::CreateDesktopWindow( - views::desktop::DesktopWindowView::DESKTOP_DEFAULT); - views::desktop::DesktopWindowView::desktop_window_view->CreateTestWindow( - ASCIIToUTF16("Sample Window 1"), SK_ColorWHITE, - gfx::Rect(500, 200, 400, 400), true); - views::desktop::DesktopWindowView::desktop_window_view->CreateTestWindow( - ASCIIToUTF16("Sample Window 2"), SK_ColorRED, - gfx::Rect(600, 450, 450, 300), false); - - views::AcceleratorHandler accelerator_handler; - MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); - -#if defined(OS_WIN) - OleUninitialize(); -#endif - return 0; -} diff --git a/ui/views/desktop/desktop_views_delegate.cc b/ui/views/desktop/desktop_views_delegate.cc deleted file mode 100644 index f288998..0000000 --- a/ui/views/desktop/desktop_views_delegate.cc +++ /dev/null @@ -1,76 +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 "ui/views/desktop/desktop_views_delegate.h" - -#include "base/logging.h" -#include "ui/views/desktop/desktop_window_view.h" - -namespace views { -namespace desktop { - -//////////////////////////////////////////////////////////////////////////////// -// DesktopViewsDelegate, public: - -DesktopViewsDelegate::DesktopViewsDelegate() { - DCHECK(!views::ViewsDelegate::views_delegate); - views::ViewsDelegate::views_delegate = this; -} - -DesktopViewsDelegate::~DesktopViewsDelegate() { -} - -//////////////////////////////////////////////////////////////////////////////// -// DesktopViewsDelegate, ViewsDelegate implementation: - -ui::Clipboard* DesktopViewsDelegate::GetClipboard() const { - return NULL; -} - -View* DesktopViewsDelegate::GetDefaultParentView() { - return DesktopWindowView::desktop_window_view; -} - -void DesktopViewsDelegate::SaveWindowPlacement(const Widget* widget, - const std::string& window_name, - const gfx::Rect& bounds, - ui::WindowShowState show_state) { -} - -bool DesktopViewsDelegate::GetSavedWindowPlacement( - const std::string& window_name, - gfx::Rect* bounds, - ui::WindowShowState* show_state) const { - return false; -} - -void DesktopViewsDelegate::NotifyAccessibilityEvent( - views::View* view, ui::AccessibilityTypes::Event event_type) { -} - -void DesktopViewsDelegate::NotifyMenuItemFocused(const string16& menu_name, - const string16& menu_item_name, - int item_index, - int item_count, - bool has_submenu) { -} - -#if defined(OS_WIN) -HICON DesktopViewsDelegate::GetDefaultWindowIcon() const { - return NULL; -} -#endif - -void DesktopViewsDelegate::AddRef() { -} - -void DesktopViewsDelegate::ReleaseRef() { -} - -int DesktopViewsDelegate::GetDispositionForEvent(int event_flags) { - return 0; -} - -} // namespace desktop -} // namespace views diff --git a/ui/views/desktop/desktop_views_delegate.h b/ui/views/desktop/desktop_views_delegate.h deleted file mode 100644 index 662d9dd..0000000 --- a/ui/views/desktop/desktop_views_delegate.h +++ /dev/null @@ -1,51 +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 UI_VIEWS_DESKTOP_DESKTOP_VIEWS_DELEGATE_H_ -#define UI_VIEWS_DESKTOP_DESKTOP_VIEWS_DELEGATE_H_ - -#include "base/compiler_specific.h" -#include "views/views_delegate.h" - -namespace views { -namespace desktop { - -class DesktopViewsDelegate : public ViewsDelegate { - public: - DesktopViewsDelegate(); - virtual ~DesktopViewsDelegate(); - - private: - // Overridden from ViewsDelegate: - virtual ui::Clipboard* GetClipboard() const OVERRIDE; - virtual View* GetDefaultParentView() OVERRIDE; - virtual void SaveWindowPlacement(const Widget* widget, - const std::string& window_name, - const gfx::Rect& bounds, - ui::WindowShowState show_state) OVERRIDE; - virtual bool GetSavedWindowPlacement( - const std::string& window_name, - gfx::Rect* bounds, - ui::WindowShowState* show_state) const OVERRIDE; - virtual void NotifyAccessibilityEvent( - views::View* view, ui::AccessibilityTypes::Event event_type) OVERRIDE; - virtual void NotifyMenuItemFocused(const string16& menu_name, - const string16& menu_item_name, - int item_index, - int item_count, - bool has_submenu) OVERRIDE; -#if defined(OS_WIN) - virtual HICON GetDefaultWindowIcon() const OVERRIDE; -#endif - virtual void AddRef() OVERRIDE; - virtual void ReleaseRef() OVERRIDE; - virtual int GetDispositionForEvent(int event_flags) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(DesktopViewsDelegate); -}; - -} // namespace desktop -} // namespace views - -#endif // UI_VIEWS_DESKTOP_DESKTOP_VIEWS_DELEGATE_H_ diff --git a/ui/views/desktop/desktop_window_manager.cc b/ui/views/desktop/desktop_window_manager.cc deleted file mode 100644 index 0275673..0000000 --- a/ui/views/desktop/desktop_window_manager.cc +++ /dev/null @@ -1,305 +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 "ui/views/desktop/desktop_window_manager.h" - -#include "ui/base/hit_test.h" -#include "ui/gfx/point.h" -#include "ui/gfx/rect.h" -#include "ui/views/events/event.h" -#include "ui/views/window/non_client_view.h" -#include "views/widget/native_widget_private.h" -#include "views/widget/native_widget_view.h" -#include "views/widget/native_widget_views.h" -#include "views/widget/widget_delegate.h" - -namespace { - -class MoveWindowController : public views::desktop::WindowController { - public: - MoveWindowController(views::Widget* widget, const gfx::Point& start) - : target_(widget), - offset_(start) { - } - - virtual ~MoveWindowController() { - } - - bool OnMouseEvent(const views::MouseEvent& event) { - if (event.type()== ui::ET_MOUSE_DRAGGED) { - gfx::Point origin = event.location().Subtract(offset_); - gfx::Rect rect = target_->GetWindowScreenBounds(); - rect.set_origin(origin); - target_->SetBounds(rect); - return true; - } - return false; - } - - private: - views::Widget* target_; - gfx::Point offset_; - - DISALLOW_COPY_AND_ASSIGN(MoveWindowController); -}; - -// Simple resize controller that handle all resize as if the bottom -// right corner is selected. -class ResizeWindowController : public views::desktop::WindowController { - public: - ResizeWindowController(views::Widget* widget) - : target_(widget) { - } - - virtual ~ResizeWindowController() { - } - - bool OnMouseEvent(const views::MouseEvent& event) OVERRIDE { - if (event.type()== ui::ET_MOUSE_DRAGGED) { - gfx::Point location = event.location(); - gfx::Rect rect = target_->GetWindowScreenBounds(); - gfx::Point size = location.Subtract(rect.origin()); - target_->SetSize(gfx::Size(std::max(10, size.x()), - std::max(10, size.y()))); - return true; - } - return false; - } - - private: - views::Widget* target_; - - DISALLOW_COPY_AND_ASSIGN(ResizeWindowController); -}; - -} // namespace - -namespace views { -namespace desktop { - -WindowController::WindowController() { -} - -WindowController::~WindowController() { -} - -//////////////////////////////////////////////////////////////////////////////// -// DesktopWindowManager, public: - -DesktopWindowManager::DesktopWindowManager(Widget* desktop) - : desktop_(desktop), - mouse_capture_(NULL), - active_widget_(NULL) { -} - -DesktopWindowManager::~DesktopWindowManager() { - DCHECK_EQ(0U, toplevels_.size()) << "Window manager getting destroyed " - << "before all the windows are closed."; -} - -void DesktopWindowManager::UpdateWindowsAfterScreenSizeChanged( - const gfx::Rect& new_size) { - for (std::vector<Widget*>::iterator i = toplevels_.begin(); - i != toplevels_.end(); ++i) { - Widget* toplevel = *i; - if (!toplevel->IsMaximized()) - continue; - - // If the window is maximized, then resize it! - toplevel->SetSize(new_size.size()); - } -} - -//////////////////////////////////////////////////////////////////////////////// -// DesktopWindowManager, WindowManager implementation: - -void DesktopWindowManager::StartMoveDrag( - views::Widget* widget, - const gfx::Point& point) { - DCHECK(!window_controller_.get()); - DCHECK(!HasMouseCapture()); - if (!widget->IsMaximized() && !widget->IsMinimized()) { - gfx::Point new_point = point; - if (desktop_->non_client_view()) { - gfx::Rect client = - desktop_->non_client_view()->frame_view()->GetBoundsForClientView(); - new_point.Offset(client.x(), client.y()); - } - SetMouseCapture(); - window_controller_.reset(new MoveWindowController(widget, new_point)); - } -} - -void DesktopWindowManager::StartResizeDrag( - views::Widget* widget, const gfx::Point& point, int hittest_code) { - DCHECK(!window_controller_.get()); - DCHECK(!HasMouseCapture()); - if (!widget->IsMaximized() && - !widget->IsMinimized() && - (widget->widget_delegate() || widget->widget_delegate()->CanResize())) { - SetMouseCapture(); - window_controller_.reset(new ResizeWindowController(widget)); - } -} - -bool DesktopWindowManager::SetMouseCapture(views::Widget* widget) { - if (mouse_capture_) - return false; - if (mouse_capture_ == widget) - return true; - DCHECK(!HasMouseCapture()); - SetMouseCapture(); - mouse_capture_ = widget; - return true; -} - -bool DesktopWindowManager::ReleaseMouseCapture(views::Widget* widget) { - if (!widget || mouse_capture_ != widget) - return false; - DCHECK(HasMouseCapture()); - ReleaseMouseCapture(); - mouse_capture_ = NULL; - return true; -} - -bool DesktopWindowManager::HasMouseCapture(const views::Widget* widget) const { - return widget && mouse_capture_ == widget; -} - -bool DesktopWindowManager::HandleKeyEvent( - views::Widget* widget, const views::KeyEvent& event) { - return active_widget_ ? - static_cast<NativeWidgetViews*>(active_widget_->native_widget_private()) - ->OnKeyEvent(event) : false; -} - -bool DesktopWindowManager::HandleMouseEvent( - views::Widget* widget, const views::MouseEvent& event) { - if (mouse_capture_) { - views::MouseEvent translated(event, widget->GetRootView(), - mouse_capture_->GetRootView()); - mouse_capture_->OnMouseEvent(translated); - return true; - } - - if (event.type() == ui::ET_MOUSE_PRESSED) - ActivateWidgetAtLocation(widget, event.location()); - else if (event.type() == ui::ET_MOUSEWHEEL && active_widget_) - return active_widget_->OnMouseEvent(event); - - if (window_controller_.get()) { - if (!window_controller_->OnMouseEvent(event)) { - ReleaseMouseCapture(); - window_controller_.reset(); - } - return true; - } - - return false; -} - -ui::TouchStatus DesktopWindowManager::HandleTouchEvent(Widget* widget, - const TouchEvent& event) { - // If there is a widget capturing mouse events, the widget should also receive - // touch events. - if (mouse_capture_) { - views::TouchEvent translated(event, widget->GetRootView(), - mouse_capture_->GetRootView()); - return mouse_capture_->OnTouchEvent(translated); - } - - // If a touch event activates a Widget, let the event still go through to the - // activated Widget. - if (event.type() == ui::ET_TOUCH_PRESSED) - ActivateWidgetAtLocation(widget, event.location()); - return ui::TOUCH_STATUS_UNKNOWN; -} - -void DesktopWindowManager::Register(Widget* widget) { - DCHECK(!widget->HasObserver(this)); - if (widget->is_top_level()) - toplevels_.push_back(widget); - widget->AddObserver(this); -} - -//////////////////////////////////////////////////////////////////////////////// -// DesktopWindowManager, private: - -void DesktopWindowManager::OnWidgetClosing(Widget* widget) { - if (active_widget_ && active_widget_ == widget) - active_widget_ = NULL; - if (widget->is_top_level()) { - for (std::vector<Widget*>::iterator i = toplevels_.begin(); - i != toplevels_.end(); ++i) { - if (*i == widget) { - toplevels_.erase(i); - break; - } - } - } -} - -void DesktopWindowManager::OnWidgetVisibilityChanged(Widget* widget, - bool visible) { - // If there's no active Widget, then activate the first visible toplevel - // Widget. - if (widget->is_top_level() && widget->CanActivate() && visible && - active_widget_ == NULL) { - Activate(widget); - } -} - -void DesktopWindowManager::OnWidgetActivationChanged(Widget* widget, - bool active) { - if (active) { - if (active_widget_) - active_widget_->Deactivate(); - active_widget_ = widget; - } else if (widget == active_widget_) { - active_widget_ = NULL; - } -} - -void DesktopWindowManager::SetMouseCapture() { - return desktop_->native_widget_private()->SetMouseCapture(); -} - -void DesktopWindowManager::ReleaseMouseCapture() { - return desktop_->native_widget_private()->ReleaseMouseCapture(); -} - -bool DesktopWindowManager::HasMouseCapture() const { - return desktop_->native_widget_private()->HasMouseCapture(); -} - -void DesktopWindowManager::Activate(Widget* widget) { - if (widget && widget->IsActive()) - return; - - if (widget) { - if (!widget->HasObserver(this)) - widget->AddObserver(this); - widget->Activate(); - } -} - -bool DesktopWindowManager::ActivateWidgetAtLocation(Widget* widget, - const gfx::Point& point) { - View* target = widget->GetRootView()->GetEventHandlerForPoint(point); - - if (target->GetClassName() == internal::NativeWidgetView::kViewClassName) { - internal::NativeWidgetView* native_widget_view = - static_cast<internal::NativeWidgetView*>(target); - views::Widget* target_widget = native_widget_view->GetAssociatedWidget(); - if (!target_widget->IsActive() && target_widget->CanActivate()) { - Activate(target_widget); - return true; - } - } - - return false; -} - -} // namespace desktop -} // namespace views diff --git a/ui/views/desktop/desktop_window_manager.h b/ui/views/desktop/desktop_window_manager.h deleted file mode 100644 index 982da1b..0000000 --- a/ui/views/desktop/desktop_window_manager.h +++ /dev/null @@ -1,99 +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 UI_VIEWS_DESKTOP_DESKTOP_WINDOW_MANAGER_H_ -#define UI_VIEWS_DESKTOP_DESKTOP_WINDOW_MANAGER_H_ -#pragma once - -#include <vector> - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" -#include "views/widget/widget.h" -#include "views/widget/window_manager.h" - - -namespace gfx { -class Point; -} - -namespace views { -namespace desktop { - -class WindowController; - -// A tentative window manager for views destktop until we have *right* -// implementation based on aura/layer API. This is minimum -// implmenetation and complicated actio like moving transformed window -// doesn't work. -class DesktopWindowManager : public views::WindowManager, - public Widget::Observer { - public: - DesktopWindowManager(Widget* desktop); - virtual ~DesktopWindowManager(); - - void UpdateWindowsAfterScreenSizeChanged(const gfx::Rect& new_size); - - // views::WindowManager implementations: - virtual void StartMoveDrag(views::Widget* widget, - const gfx::Point& point) OVERRIDE; - virtual void StartResizeDrag(views::Widget* widget, - const gfx::Point& point, - int hittest_code); - virtual bool SetMouseCapture(views::Widget* widget) OVERRIDE; - virtual bool ReleaseMouseCapture(views::Widget* widget) OVERRIDE; - virtual bool HasMouseCapture(const views::Widget* widget) const OVERRIDE; - virtual bool HandleKeyEvent(views::Widget* widget, - const views::KeyEvent& event) OVERRIDE; - virtual bool HandleMouseEvent(views::Widget* widget, - const views::MouseEvent& event) OVERRIDE; - virtual ui::TouchStatus HandleTouchEvent(views::Widget* widget, - const views::TouchEvent& event) OVERRIDE; - - virtual void Register(Widget* widget) OVERRIDE; - - private: - // Overridden from Widget::Observer. - virtual void OnWidgetClosing(Widget* widget) OVERRIDE; - virtual void OnWidgetVisibilityChanged(Widget* widget, bool visible) OVERRIDE; - virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE; - - void SetMouseCapture(); - void ReleaseMouseCapture(); - bool HasMouseCapture() const; - - void Activate(Widget* widget); - - // Returns true if a deactivated widget at the location was activated. Returns - // false otherwise. - bool ActivateWidgetAtLocation(Widget* widget, const gfx::Point& point); - - views::Widget* desktop_; - views::Widget* mouse_capture_; - views::Widget* active_widget_; - - // An unordered list of all the top-level Widgets. - std::vector<views::Widget*> toplevels_; - - scoped_ptr<WindowController> window_controller_; - - DISALLOW_COPY_AND_ASSIGN(DesktopWindowManager); -}; - -// An behavioral interface for objects implements window resize/movement. -class WindowController { - public: - WindowController(); - virtual ~WindowController(); - virtual bool OnMouseEvent(const views::MouseEvent& event) = 0; - - private: - DISALLOW_COPY_AND_ASSIGN(WindowController); -}; - -} // namespace desktop -} // namespace views - -#endif // UI_VIEWS_DESKTOP_DESKTOP_WINDOW_MANAGER_H_ diff --git a/ui/views/desktop/desktop_window_view.cc b/ui/views/desktop/desktop_window_view.cc deleted file mode 100644 index e1ef7fa..0000000 --- a/ui/views/desktop/desktop_window_view.cc +++ /dev/null @@ -1,295 +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 "ui/views/desktop/desktop_window_view.h" - -#include "base/utf_string_conversions.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/compositor/layer.h" -#include "ui/gfx/compositor/layer_animator.h" -#include "ui/gfx/transform.h" -#include "ui/views/desktop/desktop_background.h" -#include "ui/views/desktop/desktop_window_manager.h" -#include "ui/views/window/native_frame_view.h" -#include "views/widget/native_widget_view.h" -#include "views/widget/native_widget_views.h" -#include "views/widget/widget.h" - -#if defined(USE_AURA) -#include "views/widget/native_widget_aura.h" -#elif defined(OS_WIN) -#include "views/widget/native_widget_win.h" -#elif defined(USE_WAYLAND) -#include "views/widget/native_widget_wayland.h" -#elif defined(TOOLKIT_USES_GTK) -#include "views/widget/native_widget_gtk.h" -#endif - -namespace views { -namespace desktop { - -// The Widget that hosts the DesktopWindowView. Subclasses Widget to override -// CreateRootView() so that the DesktopWindowRootView can be supplied instead -// for custom event filtering. -class DesktopWindow : public Widget { - public: - explicit DesktopWindow(DesktopWindowView* desktop_window_view) - : desktop_window_view_(desktop_window_view) {} - virtual ~DesktopWindow() {} - - private: - // Overridden from Widget: - virtual bool OnKeyEvent(const KeyEvent& event) OVERRIDE { - return WindowManager::Get()->HandleKeyEvent(this, event); - } - - virtual bool OnMouseEvent(const MouseEvent& event) OVERRIDE { - return WindowManager::Get()->HandleMouseEvent(this, event) || - Widget::OnMouseEvent(event); - } - - virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE { - ui::TouchStatus status = WindowManager::Get()-> - HandleTouchEvent(this, event); - if (status == ui::TOUCH_STATUS_UNKNOWN) - status = Widget::OnTouchEvent(event); - return status; - } - - DesktopWindowView* desktop_window_view_; - - DISALLOW_COPY_AND_ASSIGN(DesktopWindow); -}; - -class TestWindowContentView : public WidgetDelegateView { - public: - TestWindowContentView(const string16& title, SkColor color) - : title_(title), - color_(color) { - } - virtual ~TestWindowContentView() {} - - private: - // Overridden from View: - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { - canvas->FillRect(color_, GetLocalBounds()); - } - - // Overridden from WindowDelegate: - virtual string16 GetWindowTitle() const OVERRIDE { - return title_; - } - virtual View* GetContentsView() { - return this; - } - virtual bool CanMaximize() const OVERRIDE { - return true; - } - virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE { - Widget* widget = View::GetWidget(); - if (widget->IsMinimized()) - widget->Restore(); - else - widget->Minimize(); - return true; - } - - string16 title_; - SkColor color_; - - DISALLOW_COPY_AND_ASSIGN(TestWindowContentView); -}; - -//////////////////////////////////////////////////////////////////////////////// -// DesktopWindowView, public: - -// static -DesktopWindowView* DesktopWindowView::desktop_window_view = NULL; - -DesktopWindowView::DesktopWindowView(DesktopType type) - : type_(type) { - switch (type_) { - case DESKTOP_DEFAULT: - case DESKTOP_NETBOOK: - set_background(new DesktopBackground); - break; - case DESKTOP_OTHER: - set_background(Background::CreateStandardPanelBackground()); - break; - } -} - -DesktopWindowView::~DesktopWindowView() { -} - -// static -void DesktopWindowView::CreateDesktopWindow(DesktopType type) { - DCHECK(!desktop_window_view); - desktop_window_view = new DesktopWindowView(type); - views::Widget* window = new DesktopWindow(desktop_window_view); - desktop_window_view->widget_ = window; - - WindowManager::Install(new DesktopWindowManager(window)); - - views::Widget::InitParams params; - params.delegate = desktop_window_view; - // In this environment, CreateChromeWindow will default to creating a views- - // window, so we need to construct a NativeWidgetWin by hand. - // TODO(beng): Replace this with NativeWindow::CreateNativeRootWindow(). -#if defined(USE_AURA) - params.native_widget = new views::NativeWidgetAura(window); -#elif defined(OS_WIN) - params.native_widget = new views::NativeWidgetWin(window); -#elif defined(USE_WAYLAND) - params.native_widget = new views::NativeWidgetWayland(window); -#elif defined(TOOLKIT_USES_GTK) - params.native_widget = new views::NativeWidgetGtk(window); - params.show_state = ui::SHOW_STATE_MAXIMIZED; -#endif - params.bounds = gfx::Rect(20, 20, 1920, 1200); - window->Init(params); - window->Show(); -} - -void DesktopWindowView::CreateTestWindow(const string16& title, - SkColor color, - gfx::Rect initial_bounds, - bool rotate) { - views::Widget* window = views::Widget::CreateWindowWithBounds( - new TestWindowContentView(title, color), - initial_bounds); - window->Show(); - - NativeWidgetViews* native_widget_views = - static_cast<NativeWidgetViews*>(window->native_widget()); - - if (rotate) { - ui::Transform transform; - transform.SetRotate(90.0f); - transform.SetTranslateX(window->GetWindowScreenBounds().width()); - native_widget_views->GetView()->SetTransform(transform); - } - - native_widget_views->GetView()->SetPaintToLayer(true); - if (native_widget_views->GetView()->layer()) { - native_widget_views->GetView()->layer()->SetAnimator( - ui::LayerAnimator::CreateImplicitAnimator()); - } -} - -void DesktopWindowView::AddObserver(DesktopWindowView::Observer* observer) { - observers_.AddObserver(observer); -} - -void DesktopWindowView::RemoveObserver(DesktopWindowView::Observer* observer) { - observers_.RemoveObserver(observer); -} - -bool DesktopWindowView::HasObserver(DesktopWindowView::Observer* observer) { - return observers_.HasObserver(observer); -} - -//////////////////////////////////////////////////////////////////////////////// -// DesktopWindowView, View overrides: - -void DesktopWindowView::Layout() { -} - -void DesktopWindowView::OnBoundsChanged(const gfx::Rect& previous_bounds) { - static_cast<DesktopWindowManager*>(WindowManager::Get())-> - UpdateWindowsAfterScreenSizeChanged(bounds()); - - FOR_EACH_OBSERVER(Observer, observers_, - OnDesktopBoundsChanged(previous_bounds)); -} - -void DesktopWindowView::ViewHierarchyChanged( - bool is_add, View* parent, View* child) { - if (child->GetClassName() == internal::NativeWidgetView::kViewClassName) { - Widget* widget = - static_cast<internal::NativeWidgetView*>(child)->GetAssociatedWidget(); - if (is_add) - WindowManager::Get()->Register(widget); - } -} - -//////////////////////////////////////////////////////////////////////////////// -// DesktopWindowView, WidgetDelegate implementation: - -Widget* DesktopWindowView::GetWidget() { - return widget_; -} - -const Widget* DesktopWindowView::GetWidget() const { - return widget_; -} - -bool DesktopWindowView::CanResize() const { - return true; -} - -bool DesktopWindowView::CanMaximize() const { - return CanResize(); -} - -string16 DesktopWindowView::GetWindowTitle() const { - return ASCIIToUTF16("Aura Desktop"); -} - -SkBitmap DesktopWindowView::GetWindowAppIcon() { - return SkBitmap(); -} - -SkBitmap DesktopWindowView::GetWindowIcon() { - return SkBitmap(); -} - -bool DesktopWindowView::ShouldShowWindowIcon() const { - return false; -} - -void DesktopWindowView::WindowClosing() { - MessageLoopForUI::current()->Quit(); -} - -View* DesktopWindowView::GetContentsView() { - return this; -} - -NonClientFrameView* DesktopWindowView::CreateNonClientFrameView() { - switch (type_) { - case DESKTOP_DEFAULT: - case DESKTOP_NETBOOK: - return NULL; - - case DESKTOP_OTHER: - return new NativeFrameView(widget_); - } - return NULL; -} - -//////////////////////////////////////////////////////////////////////////////// -// ui::LayerAnimationObserver Implementation: - -void DesktopWindowView::OnLayerAnimationEnded( - const ui::LayerAnimationSequence* animation) { - // The layer, and all the observers should be notified of the - // transformed size of the desktop. - if (widget_) { - gfx::Rect current_bounds(widget_->GetClientAreaScreenBounds().size()); - layer()->transform().TransformRect(¤t_bounds); - SetBoundsRect(gfx::Rect(current_bounds.size())); - } -} - -void DesktopWindowView::OnLayerAnimationScheduled( - const ui::LayerAnimationSequence* animation) { -} - -void DesktopWindowView::OnLayerAnimationAborted( - const ui::LayerAnimationSequence* animation) { -} - -} // namespace desktop -} // namespace views diff --git a/ui/views/desktop/desktop_window_view.h b/ui/views/desktop/desktop_window_view.h deleted file mode 100644 index 475f92c..0000000 --- a/ui/views/desktop/desktop_window_view.h +++ /dev/null @@ -1,100 +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 UI_VIEWS_DESKTOP_DESKTOP_WINDOW_VIEW_H_ -#define UI_VIEWS_DESKTOP_DESKTOP_WINDOW_VIEW_H_ - -#include "base/observer_list.h" -#include "ui/gfx/compositor/layer_animation_observer.h" -#include "views/view.h" -#include "views/widget/widget_delegate.h" - -namespace ui { -class LayerAnimationSequence; -} // namespace ui - -namespace views { - -class Widget; - -namespace desktop { - -class DesktopWindowView : public WidgetDelegateView, - public ui::LayerAnimationObserver { - public: - // Observers can listen to various events on the desktop. - class Observer { - public: - virtual void OnDesktopBoundsChanged(const gfx::Rect& previous_bounds) = 0; - - protected: - virtual ~Observer() {} - }; - - // The look and feel will be slightly different for different kinds of - // desktop. - enum DesktopType { - DESKTOP_DEFAULT, - DESKTOP_NETBOOK, - DESKTOP_OTHER - }; - - static DesktopWindowView* desktop_window_view; - - explicit DesktopWindowView(DesktopType type); - virtual ~DesktopWindowView(); - - static void CreateDesktopWindow(DesktopType type); - - void CreateTestWindow(const string16& title, - SkColor color, - gfx::Rect initial_bounds, - bool rotate); - - DesktopType type() const { return type_; } - - // Add/remove observer. - void AddObserver(Observer* observer); - void RemoveObserver(Observer* observer); - bool HasObserver(Observer* observer); - - private: - // Overridden from View: - virtual void Layout() OVERRIDE; - virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; - virtual void ViewHierarchyChanged( - bool is_add, View* parent, View* child) OVERRIDE; - - // Overridden from WidgetDelegate: - virtual Widget* GetWidget() OVERRIDE; - virtual const Widget* GetWidget() const OVERRIDE; - virtual bool CanResize() const OVERRIDE; - virtual bool CanMaximize() const OVERRIDE; - virtual string16 GetWindowTitle() const OVERRIDE; - virtual SkBitmap GetWindowAppIcon() OVERRIDE; - virtual SkBitmap GetWindowIcon() OVERRIDE; - virtual bool ShouldShowWindowIcon() const OVERRIDE; - virtual void WindowClosing() OVERRIDE; - virtual View* GetContentsView() OVERRIDE; - virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; - - // Implementation of ui::LayerAnimationObserver: - virtual void OnLayerAnimationEnded( - const ui::LayerAnimationSequence* animation) OVERRIDE; - virtual void OnLayerAnimationScheduled( - const ui::LayerAnimationSequence* animation) OVERRIDE; - virtual void OnLayerAnimationAborted( - const ui::LayerAnimationSequence* animation) OVERRIDE; - - ObserverList<Observer> observers_; - DesktopType type_; - Widget* widget_; - - DISALLOW_COPY_AND_ASSIGN(DesktopWindowView); -}; - -} // namespace desktop -} // namespace views - -#endif // UI_VIEWS_DESKTOP_DESKTOP_WINDOW_VIEW_H_ diff --git a/ui/views/events/event_wayland.cc b/ui/views/events/event_wayland.cc deleted file mode 100644 index be248d1..0000000 --- a/ui/views/events/event_wayland.cc +++ /dev/null @@ -1,23 +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 "ui/views/events/event.h" - -#include "base/logging.h" -#include "ui/base/keycodes/keyboard_code_conversion.h" - -namespace views { - -////////////////////////////////////////////////////////////////////////////// -// KeyEvent, public: - -uint16 KeyEvent::GetCharacter() const { - return ui::GetCharacterFromKeyCode(key_code_, flags()); -} - -uint16 KeyEvent::GetUnmodifiedCharacter() const { - return ui::GetCharacterFromKeyCode(key_code_, flags() & ui::EF_SHIFT_DOWN); -} - -} // namespace views diff --git a/ui/views/examples/examples_main.cc b/ui/views/examples/examples_main.cc index 1205196..819e6f0 100644 --- a/ui/views/examples/examples_main.cc +++ b/ui/views/examples/examples_main.cc @@ -21,7 +21,6 @@ #include "ui/views/examples/message_box_example.h" #include "ui/views/examples/native_theme_button_example.h" #include "ui/views/examples/native_theme_checkbox_example.h" -#include "ui/views/examples/native_widget_views_example.h" #include "ui/views/examples/progress_bar_example.h" #include "ui/views/examples/radio_button_example.h" #include "ui/views/examples/scroll_view_example.h" @@ -93,7 +92,6 @@ void ExamplesMain::Init() { examples_.push_back(new MessageBoxExample(this)); examples_.push_back(new NativeThemeButtonExample(this)); examples_.push_back(new NativeThemeCheckboxExample(this)); - examples_.push_back(new NativeWidgetViewsExample(this)); examples_.push_back(new ProgressBarExample(this)); examples_.push_back(new RadioButtonExample(this)); examples_.push_back(new ScrollViewExample(this)); diff --git a/ui/views/focus/accelerator_handler_touch.cc b/ui/views/focus/accelerator_handler_touch.cc deleted file mode 100644 index 5012dc2..0000000 --- a/ui/views/focus/accelerator_handler_touch.cc +++ /dev/null @@ -1,188 +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 "ui/views/focus/accelerator_handler.h" - -#include <X11/extensions/XInput2.h> -#include <gtk/gtk.h> - -#include <bitset> - -#include "ui/base/touch/touch_factory.h" -#include "ui/views/events/event.h" -#include "ui/views/focus/focus_manager.h" -#include "ui/views/ime/input_method.h" -#include "views/view.h" -#include "views/widget/native_widget.h" - -namespace views { - -namespace { - -Widget* FindWidgetForGdkWindow(GdkWindow* gdk_window) { - gpointer data = NULL; - gdk_window_get_user_data(gdk_window, &data); - GtkWidget* gtk_widget = reinterpret_cast<GtkWidget*>(data); - if (!gtk_widget || !GTK_IS_WIDGET(gtk_widget)) { - DLOG(WARNING) << "no GtkWidget found for that GdkWindow"; - return NULL; - } - Widget* widget = Widget::GetWidgetForNativeView(gtk_widget); - - if (!widget) { - DLOG(WARNING) << "no NativeWidgetGtk found for that GtkWidget"; - return NULL; - } - return widget; -} - -} // namespace - -bool DispatchX2Event(Widget* widget, XEvent* xev) { - XGenericEventCookie* cookie = &xev->xcookie; - switch (cookie->evtype) { - case XI_KeyPress: - case XI_KeyRelease: { - // TODO(sad): We don't capture XInput2 events from keyboard yet. - break; - } -#if defined(USE_XI2_MT) - case XI_TouchBegin: - case XI_TouchEnd: - case XI_TouchUpdate: { - // Hide the cursor when a touch event comes in. - ui::TouchFactory::GetInstance()->SetCursorVisible(false, false); - - // If the TouchEvent is processed by |widget|, then return. - TouchEvent touch(xev); - if (widget->OnTouchEvent(touch) != ui::TOUCH_STATUS_UNKNOWN) - return true; - - // We do not want to generate a mouse event for an unprocessed touch - // event here. That is already done by the gesture manager in - // RootView::OnTouchEvent. - return false; - } -#endif - case XI_ButtonPress: - case XI_ButtonRelease: - case XI_Motion: { - XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(cookie->data); - - // Scrolling the wheel generates press/release events with button id's 4 - // and 5. In case of a wheelscroll, we do not want to show the cursor. - if (xievent->detail == 4 || xievent->detail == 5) { - MouseWheelEvent wheelev(xev); - return widget->OnMouseEvent(wheelev); - } - - ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); - // Is the event coming from a touch device? - if (factory->IsTouchDevice(xievent->sourceid)) { - // Hide the cursor when a touch event comes in. - factory->SetCursorVisible(false, false); - - // With XInput 2.0, XI_ButtonPress and XI_ButtonRelease events are - // ignored, as XI_Motion events contain enough data to detect finger - // press and release. See more notes in TouchFactory::TouchParam. - if ((cookie->evtype == XI_ButtonPress || - cookie->evtype == XI_ButtonRelease) && - factory->IsRealTouchDevice(xievent->sourceid)) - return false; - - // If the TouchEvent is processed by |widget|, then return. Otherwise - // let it fall through so it can be used as a MouseEvent, if desired. - TouchEvent touch(xev); - if (widget->OnTouchEvent(touch) != ui::TOUCH_STATUS_UNKNOWN) - return true; - - // We do not want to generate a mouse event for an unprocessed touch - // event here. That is already done by the gesture manager in - // RootView::OnTouchEvent. - return false; - } else { - MouseEvent mouseev(xev); - - // Show the cursor. Start a timer to hide the cursor after a delay on - // move (not drag) events, or if the only button pressed is released. - bool start_timer = mouseev.type() == ui::ET_MOUSE_MOVED; - start_timer |= mouseev.type() == ui::ET_MOUSE_RELEASED && - (mouseev.IsOnlyLeftMouseButton() || - mouseev.IsOnlyMiddleMouseButton() || - mouseev.IsOnlyRightMouseButton()); - factory->SetCursorVisible(true, start_timer); - - return widget->OnMouseEvent(mouseev); - } - } - } - return false; -} - -bool DispatchXEvent(XEvent* xev) { - GdkDisplay* gdisp = gdk_display_get_default(); - XID xwindow = xev->xany.window; - - if (xev->type == GenericEvent) { - if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(xev)) - return true; // Consume the event. - - XGenericEventCookie* cookie = &xev->xcookie; - if (cookie->evtype == XI_HierarchyChanged) { - ui::TouchFactory::GetInstance()->UpdateDeviceList(cookie->display); - return true; - } - - XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(cookie->data); - xwindow = xiev->event; - } - - GdkWindow* gwind = gdk_window_lookup_for_display(gdisp, xwindow); - Widget* widget = FindWidgetForGdkWindow(gwind); - if (widget) { - switch (xev->type) { - case KeyPress: - case KeyRelease: { - KeyEvent keyev(xev); - InputMethod* ime = widget->GetInputMethod(); - // Always dispatch key events to the input method first, to make sure - // that the input method's hotkeys work all time. - if (ime) { - ime->DispatchKeyEvent(keyev); - return true; - } - return widget->OnKeyEvent(keyev); - } - case ButtonPress: - case ButtonRelease: - if (xev->xbutton.button == 4 || xev->xbutton.button == 5) { - // Scrolling the wheel triggers button press/release events. - MouseWheelEvent wheelev(xev); - return widget->OnMouseEvent(wheelev); - } - // fallthrough - case MotionNotify: { - MouseEvent mouseev(xev); - return widget->OnMouseEvent(mouseev); - } - - case GenericEvent: { - return DispatchX2Event(widget, xev); - } - } - } - - return false; -} - -AcceleratorHandler::AcceleratorHandler() {} - -base::MessagePumpDispatcher::DispatchStatus - AcceleratorHandler::Dispatch(XEvent* xev) { - return DispatchXEvent(xev) ? - base::MessagePumpDispatcher::EVENT_PROCESSED : - base::MessagePumpDispatcher::EVENT_IGNORED; -} - -} // namespace views diff --git a/ui/views/ime/input_method_wayland.cc b/ui/views/ime/input_method_wayland.cc deleted file mode 100644 index d35b1bd..0000000 --- a/ui/views/ime/input_method_wayland.cc +++ /dev/null @@ -1,76 +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 "ui/views/ime/input_method_wayland.h" - -#include "views/widget/widget.h" - -namespace views { - -InputMethodWayland::InputMethodWayland( - internal::InputMethodDelegate *delegate) { - set_delegate(delegate); -} - -void InputMethodWayland::DispatchKeyEvent(const KeyEvent& key) { - if (!GetTextInputClient()) { - DispatchKeyEventPostIME(key); - return; - } - - if (key.type() == ui::ET_KEY_PRESSED) { - ProcessKeyPressEvent(key); - } else if (key.type() == ui::ET_KEY_RELEASED) { - DispatchKeyEventPostIME(key); - } -} - -void InputMethodWayland::OnTextInputTypeChanged(View* view) { - NOTIMPLEMENTED(); -} - -void InputMethodWayland::OnCaretBoundsChanged(View* view) { - NOTIMPLEMENTED(); -} - -void InputMethodWayland::CancelComposition(View* view) { - NOTIMPLEMENTED(); -} - -std::string InputMethodWayland::GetInputLocale() { - return std::string(""); -} - -base::i18n::TextDirection InputMethodWayland::GetInputTextDirection() { - return base::i18n::UNKNOWN_DIRECTION; -} - -bool InputMethodWayland::IsActive() { - return true; -} - -////////////////////////////////////////////////////////////////////////////// -// InputMethodWayland private - -void InputMethodWayland::ProcessKeyPressEvent(const KeyEvent& key) { - const View* old_focused_view = focused_view(); - DispatchKeyEventPostIME(key); - - // We shouldn't dispatch the character anymore if the key event caused focus - // change. - if (old_focused_view != focused_view()) - return; - - // If a key event was not filtered by |context_| or |context_simple_|, then - // it means the key event didn't generate any result text. For some cases, - // the key event may still generate a valid character, eg. a control-key - // event (ctrl-a, return, tab, etc.). We need to send the character to the - // focused text input client by calling TextInputClient::InsertChar(). - char16 ch = key.GetCharacter(); - ui::TextInputClient* client = GetTextInputClient(); - if (ch && client) - client->InsertChar(ch, key.flags()); -} - -} // namespace views diff --git a/ui/views/ime/input_method_wayland.h b/ui/views/ime/input_method_wayland.h deleted file mode 100644 index 7e937bf..0000000 --- a/ui/views/ime/input_method_wayland.h +++ /dev/null @@ -1,36 +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 UI_VIEWS_IME_INPUT_METHOD_WAYLAND_H_ -#define UI_VIEWS_IME_INPUT_METHOD_WAYLAND_H_ -#pragma once - -#include <string> - -#include "ui/views/ime/input_method_base.h" - -namespace views { - -class InputMethodWayland : public InputMethodBase { - public: - explicit InputMethodWayland(internal::InputMethodDelegate *delegate); - - virtual void DispatchKeyEvent(const KeyEvent& key) OVERRIDE; - virtual void OnTextInputTypeChanged(View* view) OVERRIDE; - virtual void OnCaretBoundsChanged(View* view) OVERRIDE; - virtual void CancelComposition(View* view) OVERRIDE; - virtual std::string GetInputLocale() OVERRIDE; - virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; - virtual bool IsActive() OVERRIDE; - - private: - - void ProcessKeyPressEvent(const KeyEvent& key); - - DISALLOW_COPY_AND_ASSIGN(InputMethodWayland); -}; - -} // namespace views - -#endif // UI_VIEWS_IME_INPUT_METHOD_WAYLAND_H_ diff --git a/ui/views/test/test_views_delegate.cc b/ui/views/test/test_views_delegate.cc index 086e987..779e23c 100644 --- a/ui/views/test/test_views_delegate.cc +++ b/ui/views/test/test_views_delegate.cc @@ -9,8 +9,7 @@ namespace views { -TestViewsDelegate::TestViewsDelegate() - : default_parent_view_(NULL) { +TestViewsDelegate::TestViewsDelegate() { DCHECK(!ViewsDelegate::views_delegate); ViewsDelegate::views_delegate = this; } @@ -27,10 +26,6 @@ ui::Clipboard* TestViewsDelegate::GetClipboard() const { return clipboard_.get(); } -View* TestViewsDelegate::GetDefaultParentView() { - return default_parent_view_; -} - void TestViewsDelegate::SaveWindowPlacement(const Widget* window, const std::string& window_name, const gfx::Rect& bounds, diff --git a/ui/views/test/test_views_delegate.h b/ui/views/test/test_views_delegate.h index eece1f1..7812701 100644 --- a/ui/views/test/test_views_delegate.h +++ b/ui/views/test/test_views_delegate.h @@ -25,13 +25,8 @@ class TestViewsDelegate : public ViewsDelegate { TestViewsDelegate(); virtual ~TestViewsDelegate(); - void set_default_parent_view(View* view) { - default_parent_view_ = view; - } - // Overridden from ViewsDelegate: virtual ui::Clipboard* GetClipboard() const OVERRIDE; - virtual View* GetDefaultParentView() OVERRIDE; virtual void SaveWindowPlacement(const Widget* window, const std::string& window_name, const gfx::Rect& bounds, @@ -61,7 +56,6 @@ class TestViewsDelegate : public ViewsDelegate { virtual int GetDispositionForEvent(int event_flags) OVERRIDE; private: - View* default_parent_view_; mutable scoped_ptr<ui::Clipboard> clipboard_; DISALLOW_COPY_AND_ASSIGN(TestViewsDelegate); diff --git a/ui/views/touchui/gesture_manager.cc b/ui/views/touchui/gesture_manager.cc index 0508592..51b2c79 100644 --- a/ui/views/touchui/gesture_manager.cc +++ b/ui/views/touchui/gesture_manager.cc @@ -11,7 +11,6 @@ #include "base/logging.h" #include "ui/views/events/event.h" #include "views/view.h" -#include "views/views_delegate.h" #include "views/widget/widget.h" namespace views { @@ -38,28 +37,17 @@ bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event, // location information from the native-event, so it needs to convert the // coordinate to the target widget. MouseEvent mouseev(event); - if (ViewsDelegate::views_delegate->GetDefaultParentView()) { - // TODO(oshima): We may need to send the event back through - // window manager to handle mouse capture correctly. - Widget* desktop = - ViewsDelegate::views_delegate->GetDefaultParentView()->GetWidget(); - Widget* source_widget = source->GetWidget(); - MouseEvent converted( - mouseev, desktop->GetRootView(), source_widget->GetRootView()); - source_widget->OnMouseEvent(converted); + Widget* source_widget = source->GetWidget(); + Widget* top_widget = source_widget->GetTopLevelWidget(); + if (source_widget != top_widget && top_widget) { + // This is necessary as TYPE_CHILD widget is still NativeWidgetGtk. + // Fix this once TYPE_CHILD is switched to NativeWidgetViews. + MouseEvent converted(mouseev, + top_widget->GetRootView(), + source_widget->GetRootView()); + source_widget->OnMouseEvent(mouseev); } else { - Widget* source_widget = source->GetWidget(); - Widget* top_widget = source_widget->GetTopLevelWidget(); - if (source_widget != top_widget && top_widget) { - // This is necessary as TYPE_CHILD widget is still NativeWidgetGtk. - // Fix this once TYPE_CHILD is switched to NativeWidgetViews. - MouseEvent converted(mouseev, - top_widget->GetRootView(), - source_widget->GetRootView()); - source_widget->OnMouseEvent(mouseev); - } else { - source_widget->OnMouseEvent(mouseev); - } + source_widget->OnMouseEvent(mouseev); } return true; } |