| 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 27 matching lines...) Expand all Loading... |
| 38 DisplayLayout layout = | 38 DisplayLayout layout = |
| 39 Shell::GetInstance()->display_manager()->GetCurrentDisplayLayout(); | 39 Shell::GetInstance()->display_manager()->GetCurrentDisplayLayout(); |
| 40 layout.position = position; | 40 layout.position = position; |
| 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 ~ModalWidgetDelegate() override {} |
| 49 | 49 |
| 50 // Overridden from views::WidgetDelegate: | 50 // Overridden from views::WidgetDelegate: |
| 51 virtual views::View* GetContentsView() override { | 51 views::View* GetContentsView() override { return this; } |
| 52 return this; | 52 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_SYSTEM; } |
| 53 } | |
| 54 virtual ui::ModalType GetModalType() const override { | |
| 55 return ui::MODAL_TYPE_SYSTEM; | |
| 56 } | |
| 57 | 53 |
| 58 private: | 54 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); | 55 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); |
| 60 }; | 56 }; |
| 61 | 57 |
| 62 // An event handler which moves the target window to the secondary root window | 58 // An event handler which moves the target window to the secondary root window |
| 63 // at pre-handle phase of a mouse release event. | 59 // at pre-handle phase of a mouse release event. |
| 64 class MoveWindowByClickEventHandler : public ui::EventHandler { | 60 class MoveWindowByClickEventHandler : public ui::EventHandler { |
| 65 public: | 61 public: |
| 66 explicit MoveWindowByClickEventHandler(aura::Window* target) | 62 explicit MoveWindowByClickEventHandler(aura::Window* target) |
| 67 : target_(target) {} | 63 : target_(target) {} |
| 68 virtual ~MoveWindowByClickEventHandler() {} | 64 ~MoveWindowByClickEventHandler() override {} |
| 69 | 65 |
| 70 private: | 66 private: |
| 71 // ui::EventHandler overrides: | 67 // ui::EventHandler overrides: |
| 72 virtual void OnMouseEvent(ui::MouseEvent* event) override { | 68 void OnMouseEvent(ui::MouseEvent* event) override { |
| 73 if (event->type() == ui::ET_MOUSE_RELEASED) { | 69 if (event->type() == ui::ET_MOUSE_RELEASED) { |
| 74 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 70 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 75 DCHECK_LT(1u, root_windows.size()); | 71 DCHECK_LT(1u, root_windows.size()); |
| 76 root_windows[1]->AddChild(target_); | 72 root_windows[1]->AddChild(target_); |
| 77 } | 73 } |
| 78 } | 74 } |
| 79 | 75 |
| 80 aura::Window* target_; | 76 aura::Window* target_; |
| 81 DISALLOW_COPY_AND_ASSIGN(MoveWindowByClickEventHandler); | 77 DISALLOW_COPY_AND_ASSIGN(MoveWindowByClickEventHandler); |
| 82 }; | 78 }; |
| 83 | 79 |
| 84 // An event handler which records the event's locations. | 80 // An event handler which records the event's locations. |
| 85 class EventLocationRecordingEventHandler : public ui::EventHandler { | 81 class EventLocationRecordingEventHandler : public ui::EventHandler { |
| 86 public: | 82 public: |
| 87 explicit EventLocationRecordingEventHandler() { | 83 explicit EventLocationRecordingEventHandler() { |
| 88 reset(); | 84 reset(); |
| 89 } | 85 } |
| 90 virtual ~EventLocationRecordingEventHandler() {} | 86 ~EventLocationRecordingEventHandler() override {} |
| 91 | 87 |
| 92 std::string GetLocationsAndReset() { | 88 std::string GetLocationsAndReset() { |
| 93 std::string result = | 89 std::string result = |
| 94 location_.ToString() + " " + root_location_.ToString(); | 90 location_.ToString() + " " + root_location_.ToString(); |
| 95 reset(); | 91 reset(); |
| 96 return result; | 92 return result; |
| 97 } | 93 } |
| 98 | 94 |
| 99 private: | 95 private: |
| 100 // ui::EventHandler overrides: | 96 // ui::EventHandler overrides: |
| 101 virtual void OnMouseEvent(ui::MouseEvent* event) override { | 97 void OnMouseEvent(ui::MouseEvent* event) override { |
| 102 if (event->type() == ui::ET_MOUSE_MOVED || | 98 if (event->type() == ui::ET_MOUSE_MOVED || |
| 103 event->type() == ui::ET_MOUSE_DRAGGED) { | 99 event->type() == ui::ET_MOUSE_DRAGGED) { |
| 104 location_ = event->location(); | 100 location_ = event->location(); |
| 105 root_location_ = event->root_location(); | 101 root_location_ = event->root_location(); |
| 106 } | 102 } |
| 107 } | 103 } |
| 108 | 104 |
| 109 void reset() { | 105 void reset() { |
| 110 location_.SetPoint(-999, -999); | 106 location_.SetPoint(-999, -999); |
| 111 root_location_.SetPoint(-999, -999); | 107 root_location_.SetPoint(-999, -999); |
| 112 } | 108 } |
| 113 | 109 |
| 114 gfx::Point root_location_; | 110 gfx::Point root_location_; |
| 115 gfx::Point location_; | 111 gfx::Point location_; |
| 116 | 112 |
| 117 DISALLOW_COPY_AND_ASSIGN(EventLocationRecordingEventHandler); | 113 DISALLOW_COPY_AND_ASSIGN(EventLocationRecordingEventHandler); |
| 118 }; | 114 }; |
| 119 | 115 |
| 120 class EventLocationHandler : public ui::EventHandler { | 116 class EventLocationHandler : public ui::EventHandler { |
| 121 public: | 117 public: |
| 122 EventLocationHandler() {} | 118 EventLocationHandler() {} |
| 123 virtual ~EventLocationHandler() {} | 119 ~EventLocationHandler() override {} |
| 124 | 120 |
| 125 const gfx::Point& press_location() const { return press_location_; } | 121 const gfx::Point& press_location() const { return press_location_; } |
| 126 const gfx::Point& release_location() const { return release_location_; } | 122 const gfx::Point& release_location() const { return release_location_; } |
| 127 | 123 |
| 128 private: | 124 private: |
| 129 // ui::EventHandler: | 125 // ui::EventHandler: |
| 130 virtual void OnMouseEvent(ui::MouseEvent* event) override { | 126 void OnMouseEvent(ui::MouseEvent* event) override { |
| 131 if (event->type() == ui::ET_MOUSE_PRESSED) | 127 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 132 press_location_ = event->location(); | 128 press_location_ = event->location(); |
| 133 else if (event->type() == ui::ET_MOUSE_RELEASED) | 129 else if (event->type() == ui::ET_MOUSE_RELEASED) |
| 134 release_location_ = event->location(); | 130 release_location_ = event->location(); |
| 135 } | 131 } |
| 136 | 132 |
| 137 gfx::Point press_location_; | 133 gfx::Point press_location_; |
| 138 gfx::Point release_location_; | 134 gfx::Point release_location_; |
| 139 | 135 |
| 140 DISALLOW_COPY_AND_ASSIGN(EventLocationHandler); | 136 DISALLOW_COPY_AND_ASSIGN(EventLocationHandler); |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 generator.ReleaseLeftButton(); | 925 generator.ReleaseLeftButton(); |
| 930 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 926 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); |
| 931 | 927 |
| 932 generator.MoveMouseTo(400, 150); | 928 generator.MoveMouseTo(400, 150); |
| 933 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 929 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); |
| 934 | 930 |
| 935 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 931 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 936 } | 932 } |
| 937 | 933 |
| 938 } // namespace ash | 934 } // namespace ash |
| OLD | NEW |