OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/widget/root_view.h" | 5 #include "views/widget/root_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/drag_drop_types.h" | 9 #include "app/drag_drop_types.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 | 299 |
300 ViewStorage::GetInstance()->ViewRemoved(parent, child); | 300 ViewStorage::GetInstance()->ViewRemoved(parent, child); |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 void RootView::SetFocusOnMousePressed(bool f) { | 304 void RootView::SetFocusOnMousePressed(bool f) { |
305 focus_on_mouse_pressed_ = f; | 305 focus_on_mouse_pressed_ = f; |
306 } | 306 } |
307 | 307 |
308 #if defined(TOUCH_UI) | 308 #if defined(TOUCH_UI) |
309 bool RootView::OnTouchEvent(const TouchEvent& e) { | 309 View::TouchStatus RootView::OnTouchEvent(const TouchEvent& e) { |
310 // If touch_pressed_handler_ is non null, we are currently processing | 310 // If touch_pressed_handler_ is non null, we are currently processing |
311 // a touch down on the screen situation. In that case we send the | 311 // a touch down on the screen situation. In that case we send the |
312 // event to touch_pressed_handler_ | 312 // event to touch_pressed_handler_ |
313 View::TouchStatus status = TOUCH_STATUS_UNKNOWN; | |
313 | 314 |
314 if (touch_pressed_handler_) { | 315 if (touch_pressed_handler_) { |
315 TouchEvent touch_event(e, this, touch_pressed_handler_); | 316 TouchEvent touch_event(e, this, touch_pressed_handler_); |
316 touch_pressed_handler_->ProcessTouchEvent(touch_event); | 317 status = touch_pressed_handler_->ProcessTouchEvent(touch_event); |
317 gesture_manager_->ProcessTouchEventForGesture(e, this, true); | 318 gesture_manager_->ProcessTouchEventForGesture(e, this, true); |
318 return true; | 319 if (status == TOUCH_STATUS_END) |
320 touch_pressed_handler_ = NULL; | |
321 return status; | |
319 } | 322 } |
320 | 323 |
321 bool handled = false; | 324 bool handled = false; |
322 // Walk up the tree until we find a view that wants the touch event. | 325 // Walk up the tree until we find a view that wants the touch event. |
323 for (touch_pressed_handler_ = GetViewForPoint(e.location()); | 326 for (touch_pressed_handler_ = GetViewForPoint(e.location()); |
324 touch_pressed_handler_ && (touch_pressed_handler_ != this); | 327 touch_pressed_handler_ && (touch_pressed_handler_ != this); |
325 touch_pressed_handler_ = touch_pressed_handler_->GetParent()) { | 328 touch_pressed_handler_ = touch_pressed_handler_->GetParent()) { |
326 if (!touch_pressed_handler_->IsEnabled()) { | 329 if (!touch_pressed_handler_->IsEnabled()) { |
327 // Disabled views eat events but are treated as not handled by the | 330 // Disabled views eat events but are treated as not handled by the |
328 // the GestureManager. | 331 // the GestureManager. |
329 handled = false; | 332 handled = false; |
333 status = TOUCH_STATUS_UNKNOWN; | |
330 break; | 334 break; |
331 } | 335 } |
332 | 336 |
333 // See if this view wants to handle the touch | 337 // See if this view wants to handle the touch |
334 TouchEvent touch_event(e, this, touch_pressed_handler_); | 338 TouchEvent touch_event(e, this, touch_pressed_handler_); |
335 handled = touch_pressed_handler_->ProcessTouchEvent(touch_event); | 339 status = touch_pressed_handler_->ProcessTouchEvent(touch_event); |
340 if (status == TOUCH_STATUS_END) | |
341 touch_pressed_handler_ = NULL; | |
342 | |
343 handled = status != TOUCH_STATUS_UNKNOWN; | |
336 | 344 |
337 // The view could have removed itself from the tree when handling | 345 // The view could have removed itself from the tree when handling |
338 // OnTouchEvent(). So handle as per OnMousePressed. NB: we | 346 // OnTouchEvent(). So handle as per OnMousePressed. NB: we |
339 // assume that the RootView itself cannot be so removed. | 347 // assume that the RootView itself cannot be so removed. |
340 // | 348 // |
341 // NOTE: Don't return true here, because we don't want the frame to | 349 // NOTE: Don't return true here, because we don't want the frame to |
342 // forward future events to us when there's no handler. | 350 // forward future events to us when there's no handler. |
343 if (!touch_pressed_handler_) | 351 if (!touch_pressed_handler_) |
344 break; | 352 break; |
345 | 353 |
346 // If the view handled the event, leave touch_pressed_handler_ set and | 354 // If the view handled the event, leave touch_pressed_handler_ set and |
347 // return true, which will cause subsequent drag/release events to get | 355 // return true, which will cause subsequent drag/release events to get |
348 // forwarded to that view. | 356 // forwarded to that view. |
349 if (handled) { | 357 if (handled) { |
350 gesture_manager_->ProcessTouchEventForGesture(e, this, handled); | 358 gesture_manager_->ProcessTouchEventForGesture(e, this, handled); |
rjkroege
2011/01/17 19:27:40
there should probably be a TODO (and it can be for
sadrul
2011/01/18 03:50:15
Done.
| |
351 return true; | 359 return status; |
352 } | 360 } |
353 } | 361 } |
354 | 362 |
355 // Reset touch_pressed_handler_ to indicate that no processing is occurring. | 363 // Reset touch_pressed_handler_ to indicate that no processing is occurring. |
356 touch_pressed_handler_ = NULL; | 364 touch_pressed_handler_ = NULL; |
357 | 365 |
358 // Give the touch event to the gesture manager. | 366 // Give the touch event to the gesture manager. |
359 gesture_manager_->ProcessTouchEventForGesture(e, this, handled); | 367 gesture_manager_->ProcessTouchEventForGesture(e, this, handled); |
360 return handled; | 368 return status; |
361 } | 369 } |
362 #endif | 370 #endif |
363 | 371 |
364 bool RootView::OnMousePressed(const MouseEvent& e) { | 372 bool RootView::OnMousePressed(const MouseEvent& e) { |
365 // This function does not normally handle non-client messages except for | 373 // This function does not normally handle non-client messages except for |
366 // non-client double-clicks. Actually, all double-clicks are special as the | 374 // non-client double-clicks. Actually, all double-clicks are special as the |
367 // are formed from a single-click followed by a double-click event. When the | 375 // are formed from a single-click followed by a double-click event. When the |
368 // double-click event lands on a different view than its single-click part, | 376 // double-click event lands on a different view than its single-click part, |
369 // we transform it into a single-click which prevents odd things. | 377 // we transform it into a single-click which prevents odd things. |
370 if ((e.GetFlags() & MouseEvent::EF_IS_NON_CLIENT) && | 378 if ((e.GetFlags() & MouseEvent::EF_IS_NON_CLIENT) && |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
785 #elif defined(OS_LINUX) | 793 #elif defined(OS_LINUX) |
786 gfx::NativeView native_view = | 794 gfx::NativeView native_view = |
787 static_cast<WidgetGtk*>(GetWidget())->window_contents(); | 795 static_cast<WidgetGtk*>(GetWidget())->window_contents(); |
788 if (!native_view) | 796 if (!native_view) |
789 return; | 797 return; |
790 gdk_window_set_cursor(native_view->window, cursor); | 798 gdk_window_set_cursor(native_view->window, cursor); |
791 #endif | 799 #endif |
792 } | 800 } |
793 | 801 |
794 } // namespace views | 802 } // namespace views |
OLD | NEW |