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