Chromium Code Reviews| 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/property_util.h" | 10 #include "ash/wm/property_util.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 frame_(frame), | 106 frame_(frame), |
| 107 is_snap_enabled_(false), | 107 is_snap_enabled_(false), |
| 108 exceeded_drag_threshold_(false), | 108 exceeded_drag_threshold_(false), |
| 109 window_(NULL), | 109 window_(NULL), |
| 110 snap_type_(SNAP_NONE) { | 110 snap_type_(SNAP_NONE) { |
| 111 // TODO(sky): nuke this. It's temporary while we don't have good images. | 111 // TODO(sky): nuke this. It's temporary while we don't have good images. |
| 112 SetImageAlignment(ALIGN_LEFT, ALIGN_BOTTOM); | 112 SetImageAlignment(ALIGN_LEFT, ALIGN_BOTTOM); |
| 113 } | 113 } |
| 114 | 114 |
| 115 FrameMaximizeButton::~FrameMaximizeButton() { | 115 FrameMaximizeButton::~FrameMaximizeButton() { |
| 116 // Before the window gets destroyed, the maximizer dialog needs to be shut | |
| 117 // down since it would otherwise call into a deleted object. | |
| 118 maximizer_.reset(); | |
| 116 if (window_) | 119 if (window_) |
| 117 OnWindowDestroying(window_); | 120 OnWindowDestroying(window_); |
| 118 } | 121 } |
| 119 | 122 |
| 120 void FrameMaximizeButton::SnapButtonHovered(SnapType type) { | 123 void FrameMaximizeButton::SnapButtonHovered(SnapType type) { |
| 121 // Make sure to only show hover operations when no button is pressed and | 124 // Make sure to only show hover operations when no button is pressed and |
| 122 // a similar snap operation in progress does not get re-applied. | 125 // a similar snap operation in progress does not get re-applied. |
| 123 if (is_snap_enabled_ || (type == snap_type_ && snap_sizer_.get())) | 126 if (is_snap_enabled_ || (type == snap_type_ && snap_sizer_.get())) |
| 124 return; | 127 return; |
| 125 // Prime the mouse location with the center of the (local) button. | 128 // Prime the mouse location with the center of the (local) button. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 144 return; | 147 return; |
| 145 default: | 148 default: |
| 146 // We should not come here. | 149 // We should not come here. |
| 147 NOTREACHED(); | 150 NOTREACHED(); |
| 148 } | 151 } |
| 149 UpdateSnap(location); | 152 UpdateSnap(location); |
| 150 } | 153 } |
| 151 | 154 |
| 152 void FrameMaximizeButton::ExecuteSnapAndCloseMenu(SnapType snap_type) { | 155 void FrameMaximizeButton::ExecuteSnapAndCloseMenu(SnapType snap_type) { |
| 153 DCHECK_NE(snap_type_, SNAP_NONE); | 156 DCHECK_NE(snap_type_, SNAP_NONE); |
| 157 Cancel(true); | |
| 158 // Tell our menu to close. | |
| 159 maximizer_.reset(); | |
| 154 snap_type_ = snap_type; | 160 snap_type_ = snap_type; |
| 155 Snap(); | 161 Snap(); |
| 156 // Remove any pending snap previews. | 162 // Note: |this| might now be destroyed. |
| 157 SnapButtonHovered(SNAP_NONE); | |
| 158 // At this point the operation has been performed and the menu should be | |
| 159 // closed - if not, it'll get now closed. | |
| 160 maximizer_.reset(); | |
| 161 } | 163 } |
| 162 | 164 |
| 163 void FrameMaximizeButton::DestroyMaximizeMenu() { | 165 void FrameMaximizeButton::DestroyMaximizeMenu() { |
| 164 maximizer_.reset(); | 166 maximizer_.reset(); |
| 165 } | 167 } |
| 166 | 168 |
| 167 void FrameMaximizeButton::OnWindowBoundsChanged( | 169 void FrameMaximizeButton::OnWindowBoundsChanged( |
| 168 aura::Window* window, | 170 aura::Window* window, |
| 169 const gfx::Rect& old_bounds, | 171 const gfx::Rect& old_bounds, |
| 170 const gfx::Rect& new_bounds) { | 172 const gfx::Rect& new_bounds) { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 phantom_window_.reset(); | 325 phantom_window_.reset(); |
| 324 Snap(); | 326 Snap(); |
| 325 return true; | 327 return true; |
| 326 } | 328 } |
| 327 | 329 |
| 328 void FrameMaximizeButton::Cancel(bool keep_menu_open) { | 330 void FrameMaximizeButton::Cancel(bool keep_menu_open) { |
| 329 if (!keep_menu_open) { | 331 if (!keep_menu_open) { |
| 330 maximizer_.reset(); | 332 maximizer_.reset(); |
| 331 UninstallEventFilter(); | 333 UninstallEventFilter(); |
| 332 is_snap_enabled_ = false; | 334 is_snap_enabled_ = false; |
| 335 snap_sizer_.reset(); | |
|
sky
2012/08/08 04:39:17
Persisting the snap_sizer_ makes me nervous. In pa
Mr4D (OOO till 08-26)
2012/08/08 14:26:46
When doing the change I thought the same thing - b
| |
| 333 } | 336 } |
| 334 phantom_window_.reset(); | 337 phantom_window_.reset(); |
| 335 snap_sizer_.reset(); | |
| 336 snap_type_ = SNAP_NONE; | 338 snap_type_ = SNAP_NONE; |
| 337 update_timer_.Stop(); | 339 update_timer_.Stop(); |
| 338 SchedulePaint(); | 340 SchedulePaint(); |
| 339 } | 341 } |
| 340 | 342 |
| 341 void FrameMaximizeButton::InstallEventFilter() { | 343 void FrameMaximizeButton::InstallEventFilter() { |
| 342 if (escape_event_filter_.get()) | 344 if (escape_event_filter_.get()) |
| 343 return; | 345 return; |
| 344 | 346 |
| 345 escape_event_filter_.reset(new EscapeEventFilter(this)); | 347 escape_event_filter_.reset(new EscapeEventFilter(this)); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 break; | 475 break; |
| 474 case SNAP_RESTORE: | 476 case SNAP_RESTORE: |
| 475 frame_->GetWidget()->Restore(); | 477 frame_->GetWidget()->Restore(); |
| 476 break; | 478 break; |
| 477 case SNAP_NONE: | 479 case SNAP_NONE: |
| 478 NOTREACHED(); | 480 NOTREACHED(); |
| 479 } | 481 } |
| 480 } | 482 } |
| 481 | 483 |
| 482 } // namespace ash | 484 } // namespace ash |
| OLD | NEW |