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 maximizer_.reset(); | |
sky
2012/08/07 23:11:18
Add a comment as to why this needs to be first.
Mr4D (OOO till 08-26)
2012/08/08 01:02:28
Done.
| |
116 if (window_) | 117 if (window_) |
117 OnWindowDestroying(window_); | 118 OnWindowDestroying(window_); |
118 } | 119 } |
119 | 120 |
120 void FrameMaximizeButton::SnapButtonHovered(SnapType type) { | 121 void FrameMaximizeButton::SnapButtonHovered(SnapType type) { |
121 // Make sure to only show hover operations when no button is pressed and | 122 // 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. | 123 // a similar snap operation in progress does not get re-applied. |
123 if (is_snap_enabled_ || (type == snap_type_ && snap_sizer_.get())) | 124 if (is_snap_enabled_ || (type == snap_type_ && snap_sizer_.get())) |
124 return; | 125 return; |
125 // Prime the mouse location with the center of the (local) button. | 126 // Prime the mouse location with the center of the (local) button. |
(...skipping 18 matching lines...) Expand all Loading... | |
144 return; | 145 return; |
145 default: | 146 default: |
146 // We should not come here. | 147 // We should not come here. |
147 NOTREACHED(); | 148 NOTREACHED(); |
148 } | 149 } |
149 UpdateSnap(location); | 150 UpdateSnap(location); |
150 } | 151 } |
151 | 152 |
152 void FrameMaximizeButton::ExecuteSnapAndCloseMenu(SnapType snap_type) { | 153 void FrameMaximizeButton::ExecuteSnapAndCloseMenu(SnapType snap_type) { |
153 DCHECK_NE(snap_type_, SNAP_NONE); | 154 DCHECK_NE(snap_type_, SNAP_NONE); |
154 snap_type_ = snap_type; | 155 // SNAP_MINIMIZE might destroy |this| for windows like the file manager. |
sky
2012/08/07 23:11:18
This is too fragile. Can't the code be like Proces
Mr4D (OOO till 08-26)
2012/08/08 01:02:28
Okay. Changed it. However - I did not move the cas
| |
155 Snap(); | 156 // To avoid crashes we have therefore to execute that command at the end. |
157 // All other commands need the snap_sizer to know the target size, so they | |
158 // have to be executed before we start destroying the rest. | |
159 if (snap_type != SNAP_MINIMIZE) { | |
160 snap_type_ = snap_type; | |
161 Snap(); | |
162 } | |
156 // Remove any pending snap previews. | 163 // Remove any pending snap previews. |
157 SnapButtonHovered(SNAP_NONE); | 164 SnapButtonHovered(SNAP_NONE); |
158 // At this point the operation has been performed and the menu should be | 165 // At this point the operation has been performed and the menu should be |
159 // closed - if not, it'll get now closed. | 166 // closed - if not, it'll get now closed. |
160 maximizer_.reset(); | 167 maximizer_.reset(); |
168 if (snap_type == SNAP_MINIMIZE) { | |
169 snap_type_ = snap_type; | |
170 Snap(); | |
171 // |this| might now be destroyed. | |
172 } | |
161 } | 173 } |
162 | 174 |
163 void FrameMaximizeButton::DestroyMaximizeMenu() { | 175 void FrameMaximizeButton::DestroyMaximizeMenu() { |
164 maximizer_.reset(); | 176 maximizer_.reset(); |
165 } | 177 } |
166 | 178 |
167 void FrameMaximizeButton::OnWindowBoundsChanged( | 179 void FrameMaximizeButton::OnWindowBoundsChanged( |
168 aura::Window* window, | 180 aura::Window* window, |
169 const gfx::Rect& old_bounds, | 181 const gfx::Rect& old_bounds, |
170 const gfx::Rect& new_bounds) { | 182 const gfx::Rect& new_bounds) { |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 break; | 485 break; |
474 case SNAP_RESTORE: | 486 case SNAP_RESTORE: |
475 frame_->GetWidget()->Restore(); | 487 frame_->GetWidget()->Restore(); |
476 break; | 488 break; |
477 case SNAP_NONE: | 489 case SNAP_NONE: |
478 NOTREACHED(); | 490 NOTREACHED(); |
479 } | 491 } |
480 } | 492 } |
481 | 493 |
482 } // namespace ash | 494 } // namespace ash |
OLD | NEW |