| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame/caption_buttons/frame_size_button.h" | 5 #include "ash/frame/caption_buttons/frame_size_button.h" |
| 6 | 6 |
| 7 #include "ash/shell_port.h" | 7 #include "ash/shell_port.h" |
| 8 #include "ash/wm/window_positioning_utils.h" | 8 #include "ash/wm/window_positioning_utils.h" |
| 9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
| 10 #include "ash/wm/wm_event.h" | 10 #include "ash/wm/wm_event.h" |
| 11 #include "ash/wm/workspace/phantom_window_controller.h" | 11 #include "ash/wm/workspace/phantom_window_controller.h" |
| 12 #include "ash/wm_window.h" | |
| 13 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 14 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 15 #include "ui/gfx/geometry/vector2d.h" | 14 #include "ui/gfx/geometry/vector2d.h" |
| 16 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 17 #include "ui/wm/core/coordinate_conversion.h" | 16 #include "ui/wm/core/coordinate_conversion.h" |
| 18 | 17 |
| 19 namespace ash { | 18 namespace ash { |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 case CAPTION_BUTTON_ICON_LOCATION: | 206 case CAPTION_BUTTON_ICON_LOCATION: |
| 208 case CAPTION_BUTTON_ICON_COUNT: | 207 case CAPTION_BUTTON_ICON_COUNT: |
| 209 NOTREACHED(); | 208 NOTREACHED(); |
| 210 break; | 209 break; |
| 211 } | 210 } |
| 212 } | 211 } |
| 213 | 212 |
| 214 if (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT) { | 213 if (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT) { |
| 215 aura::Window* window = frame_->GetNativeWindow(); | 214 aura::Window* window = frame_->GetNativeWindow(); |
| 216 if (!phantom_window_controller_.get()) { | 215 if (!phantom_window_controller_.get()) { |
| 217 phantom_window_controller_.reset( | 216 phantom_window_controller_.reset(new PhantomWindowController(window)); |
| 218 new PhantomWindowController(WmWindow::Get(window))); | |
| 219 } | 217 } |
| 220 gfx::Rect phantom_bounds_in_screen = | 218 gfx::Rect phantom_bounds_in_screen = |
| 221 (snap_type_ == SNAP_LEFT) | 219 (snap_type_ == SNAP_LEFT) |
| 222 ? wm::GetDefaultLeftSnappedWindowBoundsInParent(window) | 220 ? wm::GetDefaultLeftSnappedWindowBoundsInParent(window) |
| 223 : wm::GetDefaultRightSnappedWindowBoundsInParent(window); | 221 : wm::GetDefaultRightSnappedWindowBoundsInParent(window); |
| 224 ::wm::ConvertRectToScreen(window->parent(), &phantom_bounds_in_screen); | 222 ::wm::ConvertRectToScreen(window->parent(), &phantom_bounds_in_screen); |
| 225 phantom_window_controller_->Show(phantom_bounds_in_screen); | 223 phantom_window_controller_->Show(phantom_bounds_in_screen); |
| 226 } else { | 224 } else { |
| 227 phantom_window_controller_.reset(); | 225 phantom_window_controller_.reset(); |
| 228 } | 226 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 239 } | 237 } |
| 240 return NULL; | 238 return NULL; |
| 241 } | 239 } |
| 242 | 240 |
| 243 bool FrameSizeButton::CommitSnap(const ui::LocatedEvent& event) { | 241 bool FrameSizeButton::CommitSnap(const ui::LocatedEvent& event) { |
| 244 // The position of |event| may be different than the position of the previous | 242 // The position of |event| may be different than the position of the previous |
| 245 // event. | 243 // event. |
| 246 UpdateSnapType(event); | 244 UpdateSnapType(event); |
| 247 | 245 |
| 248 if (in_snap_mode_ && (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT)) { | 246 if (in_snap_mode_ && (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT)) { |
| 249 WmWindow* window = WmWindow::Get(frame_->GetNativeWindow()); | 247 wm::WindowState* window_state = |
| 250 wm::WindowState* window_state = window->GetWindowState(); | 248 wm::GetWindowState(frame_->GetNativeWindow()); |
| 251 const wm::WMEvent snap_event(snap_type_ == SNAP_LEFT | 249 const wm::WMEvent snap_event(snap_type_ == SNAP_LEFT |
| 252 ? wm::WM_EVENT_SNAP_LEFT | 250 ? wm::WM_EVENT_SNAP_LEFT |
| 253 : wm::WM_EVENT_SNAP_RIGHT); | 251 : wm::WM_EVENT_SNAP_RIGHT); |
| 254 window_state->OnWMEvent(&snap_event); | 252 window_state->OnWMEvent(&snap_event); |
| 255 ShellPort::Get()->RecordUserMetricsAction( | 253 ShellPort::Get()->RecordUserMetricsAction( |
| 256 snap_type_ == SNAP_LEFT ? UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT | 254 snap_type_ == SNAP_LEFT ? UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT |
| 257 : UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT); | 255 : UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT); |
| 258 SetButtonsToNormalMode(FrameSizeButtonDelegate::ANIMATE_NO); | 256 SetButtonsToNormalMode(FrameSizeButtonDelegate::ANIMATE_NO); |
| 259 return true; | 257 return true; |
| 260 } | 258 } |
| 261 SetButtonsToNormalMode(FrameSizeButtonDelegate::ANIMATE_YES); | 259 SetButtonsToNormalMode(FrameSizeButtonDelegate::ANIMATE_YES); |
| 262 return false; | 260 return false; |
| 263 } | 261 } |
| 264 | 262 |
| 265 void FrameSizeButton::SetButtonsToNormalMode( | 263 void FrameSizeButton::SetButtonsToNormalMode( |
| 266 FrameSizeButtonDelegate::Animate animate) { | 264 FrameSizeButtonDelegate::Animate animate) { |
| 267 in_snap_mode_ = false; | 265 in_snap_mode_ = false; |
| 268 snap_type_ = SNAP_NONE; | 266 snap_type_ = SNAP_NONE; |
| 269 set_buttons_to_snap_mode_timer_.Stop(); | 267 set_buttons_to_snap_mode_timer_.Stop(); |
| 270 delegate_->SetButtonsToNormal(animate); | 268 delegate_->SetButtonsToNormal(animate); |
| 271 phantom_window_controller_.reset(); | 269 phantom_window_controller_.reset(); |
| 272 } | 270 } |
| 273 | 271 |
| 274 } // namespace ash | 272 } // namespace ash |
| OLD | NEW |