| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/tabs/dragged_tab_controller.h" | 5 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
| 25 #include "content/browser/user_metrics.h" | 25 #include "content/browser/user_metrics.h" |
| 26 #include "content/public/browser/notification_details.h" | 26 #include "content/public/browser/notification_details.h" |
| 27 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
| 28 #include "content/public/browser/notification_types.h" | 28 #include "content/public/browser/notification_types.h" |
| 29 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 30 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
| 31 #include "ui/base/animation/animation.h" | 31 #include "ui/base/animation/animation.h" |
| 32 #include "ui/base/animation/animation_delegate.h" | 32 #include "ui/base/animation/animation_delegate.h" |
| 33 #include "ui/base/animation/slide_animation.h" | 33 #include "ui/base/animation/slide_animation.h" |
| 34 #include "ui/base/events.h" |
| 34 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
| 35 #include "ui/gfx/canvas_skia.h" | 36 #include "ui/gfx/canvas_skia.h" |
| 36 #include "ui/gfx/screen.h" | 37 #include "ui/gfx/screen.h" |
| 37 #include "views/events/event.h" | 38 #include "views/events/event.h" |
| 38 #include "views/widget/widget.h" | 39 #include "views/widget/widget.h" |
| 39 | 40 |
| 40 #if defined(TOOLKIT_USES_GTK) | 41 #if defined(TOOLKIT_USES_GTK) |
| 41 #include <gdk/gdk.h> // NOLINT | 42 #include <gdk/gdk.h> // NOLINT |
| 42 #include <gdk/gdkkeysyms.h> // NOLINT | 43 #include <gdk/gdkkeysyms.h> // NOLINT |
| 43 #endif | 44 #endif |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 return; | 495 return; |
| 495 } | 496 } |
| 496 } | 497 } |
| 497 // If we get here it means we got notification for a tab we don't know about. | 498 // If we get here it means we got notification for a tab we don't know about. |
| 498 NOTREACHED(); | 499 NOTREACHED(); |
| 499 } | 500 } |
| 500 | 501 |
| 501 /////////////////////////////////////////////////////////////////////////////// | 502 /////////////////////////////////////////////////////////////////////////////// |
| 502 // DraggedTabController, MessageLoop::Observer implementation: | 503 // DraggedTabController, MessageLoop::Observer implementation: |
| 503 | 504 |
| 504 #if defined(OS_WIN) | 505 #if defined(OS_WIN) || defined(TOUCH_UI) || defined(USE_AURA) |
| 505 base::EventStatus DraggedTabController::WillProcessEvent( | 506 base::EventStatus DraggedTabController::WillProcessEvent( |
| 506 const base::NativeEvent& event) { | 507 const base::NativeEvent& event) { |
| 507 return base::EVENT_CONTINUE; | 508 return base::EVENT_CONTINUE; |
| 508 } | 509 } |
| 509 | 510 |
| 510 void DraggedTabController::DidProcessEvent(const base::NativeEvent& event) { | 511 void DraggedTabController::DidProcessEvent(const base::NativeEvent& event) { |
| 511 // If the user presses ESC during a drag, we need to abort and revert things | 512 // If the user presses ESC during a drag, we need to abort and revert things |
| 512 // to the way they were. This is the most reliable way to do this since no | 513 // to the way they were. This is the most reliable way to do this since no |
| 513 // single view or window reliably receives events throughout all the various | 514 // single view or window reliably receives events throughout all the various |
| 514 // kinds of tab dragging. | 515 // kinds of tab dragging. |
| 515 if (event.message == WM_KEYDOWN && event.wParam == VK_ESCAPE) | 516 if (ui::EventTypeFromNative(event) == ui::ET_KEY_PRESSED && |
| 517 ui::KeyboardCodeFromNative(event) == ui::VKEY_ESCAPE) { |
| 516 EndDrag(true); | 518 EndDrag(true); |
| 517 } | 519 } |
| 518 #elif defined(TOUCH_UI) || defined(USE_AURA) | |
| 519 base::EventStatus DraggedTabController::WillProcessEvent( | |
| 520 const base::NativeEvent& event) { | |
| 521 return base::EVENT_CONTINUE; | |
| 522 } | |
| 523 | |
| 524 void DraggedTabController::DidProcessEvent(const base::NativeEvent& event) { | |
| 525 NOTIMPLEMENTED(); | |
| 526 } | 520 } |
| 527 #elif defined(TOOLKIT_USES_GTK) | 521 #elif defined(TOOLKIT_USES_GTK) |
| 528 void DraggedTabController::WillProcessEvent(GdkEvent* event) { | 522 void DraggedTabController::WillProcessEvent(GdkEvent* event) { |
| 529 } | 523 } |
| 530 | 524 |
| 531 void DraggedTabController::DidProcessEvent(GdkEvent* event) { | 525 void DraggedTabController::DidProcessEvent(GdkEvent* event) { |
| 532 if (event->type == GDK_KEY_PRESS && | 526 if (event->type == GDK_KEY_PRESS && |
| 533 reinterpret_cast<GdkEventKey*>(event)->keyval == GDK_Escape) { | 527 reinterpret_cast<GdkEventKey*>(event)->keyval == GDK_Escape) { |
| 534 EndDrag(true); | 528 EndDrag(true); |
| 535 } | 529 } |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 | 1372 |
| 1379 bool DraggedTabController::AreTabsConsecutive() { | 1373 bool DraggedTabController::AreTabsConsecutive() { |
| 1380 for (size_t i = 1; i < drag_data_.size(); ++i) { | 1374 for (size_t i = 1; i < drag_data_.size(); ++i) { |
| 1381 if (drag_data_[i - 1].source_model_index + 1 != | 1375 if (drag_data_[i - 1].source_model_index + 1 != |
| 1382 drag_data_[i].source_model_index) { | 1376 drag_data_[i].source_model_index) { |
| 1383 return false; | 1377 return false; |
| 1384 } | 1378 } |
| 1385 } | 1379 } |
| 1386 return true; | 1380 return true; |
| 1387 } | 1381 } |
| OLD | NEW |