| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
| 6 #include "ash/display/display_manager.h" | 6 #include "ash/display/display_manager.h" |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 Shell::GetInstance()->display_manager()-> | 41 Shell::GetInstance()->display_manager()-> |
| 42 SetLayoutForCurrentDisplays(layout); | 42 SetLayoutForCurrentDisplays(layout); |
| 43 } | 43 } |
| 44 | 44 |
| 45 class ModalWidgetDelegate : public views::WidgetDelegateView { | 45 class ModalWidgetDelegate : public views::WidgetDelegateView { |
| 46 public: | 46 public: |
| 47 ModalWidgetDelegate() {} | 47 ModalWidgetDelegate() {} |
| 48 virtual ~ModalWidgetDelegate() {} | 48 virtual ~ModalWidgetDelegate() {} |
| 49 | 49 |
| 50 // Overridden from views::WidgetDelegate: | 50 // Overridden from views::WidgetDelegate: |
| 51 virtual views::View* GetContentsView() OVERRIDE { | 51 virtual views::View* GetContentsView() override { |
| 52 return this; | 52 return this; |
| 53 } | 53 } |
| 54 virtual ui::ModalType GetModalType() const OVERRIDE { | 54 virtual ui::ModalType GetModalType() const override { |
| 55 return ui::MODAL_TYPE_SYSTEM; | 55 return ui::MODAL_TYPE_SYSTEM; |
| 56 } | 56 } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); | 59 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // An event handler which moves the target window to the secondary root window | 62 // An event handler which moves the target window to the secondary root window |
| 63 // at pre-handle phase of a mouse release event. | 63 // at pre-handle phase of a mouse release event. |
| 64 class MoveWindowByClickEventHandler : public ui::EventHandler { | 64 class MoveWindowByClickEventHandler : public ui::EventHandler { |
| 65 public: | 65 public: |
| 66 explicit MoveWindowByClickEventHandler(aura::Window* target) | 66 explicit MoveWindowByClickEventHandler(aura::Window* target) |
| 67 : target_(target) {} | 67 : target_(target) {} |
| 68 virtual ~MoveWindowByClickEventHandler() {} | 68 virtual ~MoveWindowByClickEventHandler() {} |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 // ui::EventHandler overrides: | 71 // ui::EventHandler overrides: |
| 72 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 72 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
| 73 if (event->type() == ui::ET_MOUSE_RELEASED) { | 73 if (event->type() == ui::ET_MOUSE_RELEASED) { |
| 74 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 74 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 75 DCHECK_LT(1u, root_windows.size()); | 75 DCHECK_LT(1u, root_windows.size()); |
| 76 root_windows[1]->AddChild(target_); | 76 root_windows[1]->AddChild(target_); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 aura::Window* target_; | 80 aura::Window* target_; |
| 81 DISALLOW_COPY_AND_ASSIGN(MoveWindowByClickEventHandler); | 81 DISALLOW_COPY_AND_ASSIGN(MoveWindowByClickEventHandler); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 // An event handler which records the event's locations. | 84 // An event handler which records the event's locations. |
| 85 class EventLocationRecordingEventHandler : public ui::EventHandler { | 85 class EventLocationRecordingEventHandler : public ui::EventHandler { |
| 86 public: | 86 public: |
| 87 explicit EventLocationRecordingEventHandler() { | 87 explicit EventLocationRecordingEventHandler() { |
| 88 reset(); | 88 reset(); |
| 89 } | 89 } |
| 90 virtual ~EventLocationRecordingEventHandler() {} | 90 virtual ~EventLocationRecordingEventHandler() {} |
| 91 | 91 |
| 92 std::string GetLocationsAndReset() { | 92 std::string GetLocationsAndReset() { |
| 93 std::string result = | 93 std::string result = |
| 94 location_.ToString() + " " + root_location_.ToString(); | 94 location_.ToString() + " " + root_location_.ToString(); |
| 95 reset(); | 95 reset(); |
| 96 return result; | 96 return result; |
| 97 } | 97 } |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 // ui::EventHandler overrides: | 100 // ui::EventHandler overrides: |
| 101 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 101 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
| 102 if (event->type() == ui::ET_MOUSE_MOVED || | 102 if (event->type() == ui::ET_MOUSE_MOVED || |
| 103 event->type() == ui::ET_MOUSE_DRAGGED) { | 103 event->type() == ui::ET_MOUSE_DRAGGED) { |
| 104 location_ = event->location(); | 104 location_ = event->location(); |
| 105 root_location_ = event->root_location(); | 105 root_location_ = event->root_location(); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 void reset() { | 109 void reset() { |
| 110 location_.SetPoint(-999, -999); | 110 location_.SetPoint(-999, -999); |
| 111 root_location_.SetPoint(-999, -999); | 111 root_location_.SetPoint(-999, -999); |
| 112 } | 112 } |
| 113 | 113 |
| 114 gfx::Point root_location_; | 114 gfx::Point root_location_; |
| 115 gfx::Point location_; | 115 gfx::Point location_; |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(EventLocationRecordingEventHandler); | 117 DISALLOW_COPY_AND_ASSIGN(EventLocationRecordingEventHandler); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 class EventLocationHandler : public ui::EventHandler { | 120 class EventLocationHandler : public ui::EventHandler { |
| 121 public: | 121 public: |
| 122 EventLocationHandler() {} | 122 EventLocationHandler() {} |
| 123 virtual ~EventLocationHandler() {} | 123 virtual ~EventLocationHandler() {} |
| 124 | 124 |
| 125 const gfx::Point& press_location() const { return press_location_; } | 125 const gfx::Point& press_location() const { return press_location_; } |
| 126 const gfx::Point& release_location() const { return release_location_; } | 126 const gfx::Point& release_location() const { return release_location_; } |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 // ui::EventHandler: | 129 // ui::EventHandler: |
| 130 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 130 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
| 131 if (event->type() == ui::ET_MOUSE_PRESSED) | 131 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 132 press_location_ = event->location(); | 132 press_location_ = event->location(); |
| 133 else if (event->type() == ui::ET_MOUSE_RELEASED) | 133 else if (event->type() == ui::ET_MOUSE_RELEASED) |
| 134 release_location_ = event->location(); | 134 release_location_ = event->location(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 gfx::Point press_location_; | 137 gfx::Point press_location_; |
| 138 gfx::Point release_location_; | 138 gfx::Point release_location_; |
| 139 | 139 |
| 140 DISALLOW_COPY_AND_ASSIGN(EventLocationHandler); | 140 DISALLOW_COPY_AND_ASSIGN(EventLocationHandler); |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 generator.ReleaseLeftButton(); | 929 generator.ReleaseLeftButton(); |
| 930 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 930 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); |
| 931 | 931 |
| 932 generator.MoveMouseTo(400, 150); | 932 generator.MoveMouseTo(400, 150); |
| 933 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 933 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); |
| 934 | 934 |
| 935 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 935 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 936 } | 936 } |
| 937 | 937 |
| 938 } // namespace ash | 938 } // namespace ash |
| OLD | NEW |