| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/shelf/shelf_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/focus_cycler.h" | 8 #include "ash/focus_cycler.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "ui/compositor/layer.h" | 29 #include "ui/compositor/layer.h" |
| 30 #include "ui/compositor/scoped_layer_animation_settings.h" | 30 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 31 #include "ui/events/event_constants.h" | 31 #include "ui/events/event_constants.h" |
| 32 #include "ui/gfx/canvas.h" | 32 #include "ui/gfx/canvas.h" |
| 33 #include "ui/gfx/image/image.h" | 33 #include "ui/gfx/image/image.h" |
| 34 #include "ui/gfx/image/image_skia_operations.h" | 34 #include "ui/gfx/image/image_skia_operations.h" |
| 35 #include "ui/gfx/skbitmap_operations.h" | 35 #include "ui/gfx/skbitmap_operations.h" |
| 36 #include "ui/views/accessible_pane_view.h" | 36 #include "ui/views/accessible_pane_view.h" |
| 37 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
| 38 #include "ui/views/widget/widget_delegate.h" | 38 #include "ui/views/widget/widget_delegate.h" |
| 39 #include "ui/wm/core/coordinate_conversion.h" |
| 39 #include "ui/wm/core/easy_resize_window_targeter.h" | 40 #include "ui/wm/core/easy_resize_window_targeter.h" |
| 40 #include "ui/wm/public/activation_client.h" | 41 #include "ui/wm/public/activation_client.h" |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 // Size of black border at bottom (or side) of shelf. | 44 // Size of black border at bottom (or side) of shelf. |
| 44 const int kNumBlackPixels = 3; | 45 const int kNumBlackPixels = 3; |
| 45 // Alpha to paint dimming image with. | 46 // Alpha to paint dimming image with. |
| 46 const int kDimAlpha = 128; | 47 const int kDimAlpha = 128; |
| 47 | 48 |
| 48 // The time to dim and un-dim. | 49 // The time to dim and un-dim. |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 207 } |
| 207 | 208 |
| 208 DimmerView::DimmerEventFilter::~DimmerEventFilter() { | 209 DimmerView::DimmerEventFilter::~DimmerEventFilter() { |
| 209 ash::Shell::GetInstance()->RemovePreTargetHandler(this); | 210 ash::Shell::GetInstance()->RemovePreTargetHandler(this); |
| 210 } | 211 } |
| 211 | 212 |
| 212 void DimmerView::DimmerEventFilter::OnMouseEvent(ui::MouseEvent* event) { | 213 void DimmerView::DimmerEventFilter::OnMouseEvent(ui::MouseEvent* event) { |
| 213 if (event->type() != ui::ET_MOUSE_MOVED && | 214 if (event->type() != ui::ET_MOUSE_MOVED && |
| 214 event->type() != ui::ET_MOUSE_DRAGGED) | 215 event->type() != ui::ET_MOUSE_DRAGGED) |
| 215 return; | 216 return; |
| 216 bool inside = owner_->GetBoundsInScreen().Contains(event->root_location()); | 217 |
| 218 gfx::Point screen_point(event->location()); |
| 219 ::wm::ConvertPointToScreen(static_cast<aura::Window*>(event->target()), |
| 220 &screen_point); |
| 221 bool inside = owner_->GetBoundsInScreen().Contains(screen_point); |
| 217 if (mouse_inside_ || touch_inside_ != inside || touch_inside_) | 222 if (mouse_inside_ || touch_inside_ != inside || touch_inside_) |
| 218 owner_->SetHovered(inside || touch_inside_); | 223 owner_->SetHovered(inside || touch_inside_); |
| 219 mouse_inside_ = inside; | 224 mouse_inside_ = inside; |
| 220 } | 225 } |
| 221 | 226 |
| 222 void DimmerView::DimmerEventFilter::OnTouchEvent(ui::TouchEvent* event) { | 227 void DimmerView::DimmerEventFilter::OnTouchEvent(ui::TouchEvent* event) { |
| 223 bool touch_inside = false; | 228 bool touch_inside = false; |
| 224 if (event->type() != ui::ET_TOUCH_RELEASED && | 229 if (event->type() != ui::ET_TOUCH_RELEASED && |
| 225 event->type() != ui::ET_TOUCH_CANCELLED) | 230 event->type() != ui::ET_TOUCH_CANCELLED) { |
| 226 touch_inside = owner_->GetBoundsInScreen().Contains(event->root_location()); | 231 gfx::Point screen_point(event->location()); |
| 232 ::wm::ConvertPointToScreen(static_cast<aura::Window*>(event->target()), |
| 233 &screen_point); |
| 234 touch_inside = owner_->GetBoundsInScreen().Contains(screen_point); |
| 235 } |
| 227 | 236 |
| 228 if (mouse_inside_ || touch_inside_ != mouse_inside_ || touch_inside) | 237 if (mouse_inside_ || touch_inside_ != mouse_inside_ || touch_inside) |
| 229 owner_->SetHovered(mouse_inside_ || touch_inside); | 238 owner_->SetHovered(mouse_inside_ || touch_inside); |
| 230 touch_inside_ = touch_inside; | 239 touch_inside_ = touch_inside; |
| 231 } | 240 } |
| 232 | 241 |
| 233 using ash::ShelfLayoutManager; | 242 using ash::ShelfLayoutManager; |
| 234 | 243 |
| 235 // ShelfWindowTargeter makes it easier to resize windows with the mouse when the | 244 // ShelfWindowTargeter makes it easier to resize windows with the mouse when the |
| 236 // window-edge slightly overlaps with the shelf edge. The targeter also makes it | 245 // window-edge slightly overlaps with the shelf edge. The targeter also makes it |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 DCHECK(delegate_view_); | 838 DCHECK(delegate_view_); |
| 830 return delegate_view_->disable_dimming_animations_for_test(); | 839 return delegate_view_->disable_dimming_animations_for_test(); |
| 831 } | 840 } |
| 832 | 841 |
| 833 void ShelfWidget::WillDeleteShelf() { | 842 void ShelfWidget::WillDeleteShelf() { |
| 834 shelf_layout_manager_->RemoveObserver(this); | 843 shelf_layout_manager_->RemoveObserver(this); |
| 835 shelf_layout_manager_ = NULL; | 844 shelf_layout_manager_ = NULL; |
| 836 } | 845 } |
| 837 | 846 |
| 838 } // namespace ash | 847 } // namespace ash |
| OLD | NEW |