| 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/wm/workspace/frame_maximize_button.h" | 5 #include "ash/wm/workspace/frame_maximize_button.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/maximize_bubble_controller.h" | 10 #include "ash/wm/maximize_bubble_controller.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 // EscapeEventFilter is installed on the RootWindow to track when the escape key | 41 // EscapeEventFilter is installed on the RootWindow to track when the escape key |
| 42 // is pressed. We use an EventFilter for this as the FrameMaximizeButton | 42 // is pressed. We use an EventFilter for this as the FrameMaximizeButton |
| 43 // normally does not get focus. | 43 // normally does not get focus. |
| 44 class FrameMaximizeButton::EscapeEventFilter : public ui::EventHandler { | 44 class FrameMaximizeButton::EscapeEventFilter : public ui::EventHandler { |
| 45 public: | 45 public: |
| 46 explicit EscapeEventFilter(FrameMaximizeButton* button); | 46 explicit EscapeEventFilter(FrameMaximizeButton* button); |
| 47 virtual ~EscapeEventFilter(); | 47 virtual ~EscapeEventFilter(); |
| 48 | 48 |
| 49 // EventFilter overrides: | 49 // EventFilter overrides: |
| 50 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 50 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 FrameMaximizeButton* button_; | 53 FrameMaximizeButton* button_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(EscapeEventFilter); | 55 DISALLOW_COPY_AND_ASSIGN(EscapeEventFilter); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 FrameMaximizeButton::EscapeEventFilter::EscapeEventFilter( | 58 FrameMaximizeButton::EscapeEventFilter::EscapeEventFilter( |
| 59 FrameMaximizeButton* button) | 59 FrameMaximizeButton* button) |
| 60 : button_(button) { | 60 : button_(button) { |
| 61 Shell::GetInstance()->AddPreTargetHandler(this); | 61 Shell::GetInstance()->AddPreTargetHandler(this); |
| 62 } | 62 } |
| 63 | 63 |
| 64 FrameMaximizeButton::EscapeEventFilter::~EscapeEventFilter() { | 64 FrameMaximizeButton::EscapeEventFilter::~EscapeEventFilter() { |
| 65 Shell::GetInstance()->RemovePreTargetHandler(this); | 65 Shell::GetInstance()->RemovePreTargetHandler(this); |
| 66 } | 66 } |
| 67 | 67 |
| 68 ui::EventResult FrameMaximizeButton::EscapeEventFilter::OnKeyEvent( | 68 void FrameMaximizeButton::EscapeEventFilter::OnKeyEvent( |
| 69 ui::KeyEvent* event) { | 69 ui::KeyEvent* event) { |
| 70 if (event->type() == ui::ET_KEY_PRESSED && | 70 if (event->type() == ui::ET_KEY_PRESSED && |
| 71 event->key_code() == ui::VKEY_ESCAPE) { | 71 event->key_code() == ui::VKEY_ESCAPE) { |
| 72 button_->Cancel(false); | 72 button_->Cancel(false); |
| 73 } | 73 } |
| 74 return ui::ER_UNHANDLED; | |
| 75 } | 74 } |
| 76 | 75 |
| 77 // FrameMaximizeButton --------------------------------------------------------- | 76 // FrameMaximizeButton --------------------------------------------------------- |
| 78 | 77 |
| 79 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener, | 78 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener, |
| 80 views::NonClientFrameView* frame) | 79 views::NonClientFrameView* frame) |
| 81 : ImageButton(listener), | 80 : ImageButton(listener), |
| 82 frame_(frame), | 81 frame_(frame), |
| 83 is_snap_enabled_(false), | 82 is_snap_enabled_(false), |
| 84 exceeded_drag_threshold_(false), | 83 exceeded_drag_threshold_(false), |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 return FRAME_STATE_SNAP_LEFT; | 557 return FRAME_STATE_SNAP_LEFT; |
| 559 if (bounds.right() == screen.right()) | 558 if (bounds.right() == screen.right()) |
| 560 return FRAME_STATE_SNAP_RIGHT; | 559 return FRAME_STATE_SNAP_RIGHT; |
| 561 // If we come here, it is likely caused by the fact that the | 560 // If we come here, it is likely caused by the fact that the |
| 562 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case | 561 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case |
| 563 // we allow all maximize operations (and keep the restore rectangle). | 562 // we allow all maximize operations (and keep the restore rectangle). |
| 564 return FRAME_STATE_NONE; | 563 return FRAME_STATE_NONE; |
| 565 } | 564 } |
| 566 | 565 |
| 567 } // namespace ash | 566 } // namespace ash |
| OLD | NEW |