Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/ui/views/tabs/tab_drag_controller.h" | 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 // work in all cases. Hence this hack. | 687 // work in all cases. Hence this hack. |
| 688 ui::GestureRecognizer::Get()->TransferEventsTo( | 688 ui::GestureRecognizer::Get()->TransferEventsTo( |
| 689 browser_widget->GetNativeView(), | 689 browser_widget->GetNativeView(), |
| 690 target_tabstrip->GetWidget()->GetNativeView()); | 690 target_tabstrip->GetWidget()->GetNativeView()); |
| 691 #endif | 691 #endif |
| 692 | 692 |
| 693 // The window is going away. Since the drag is still on going we don't want | 693 // The window is going away. Since the drag is still on going we don't want |
| 694 // that to effect the position of any windows. | 694 // that to effect the position of any windows. |
| 695 SetWindowPositionManaged(browser_widget->GetNativeView(), false); | 695 SetWindowPositionManaged(browser_widget->GetNativeView(), false); |
| 696 | 696 |
| 697 #if !defined(OS_LINUX) | |
|
Elliot Glaysher
2014/02/26 20:33:17
Isn't this code used on chromeos, too?
varkha
2014/02/26 20:59:35
It is, but I did not see any visual impact from sk
| |
| 697 // EndMoveLoop is going to snap the window back to its original location. | 698 // EndMoveLoop is going to snap the window back to its original location. |
| 698 // Hide it so users don't see this. | 699 // Hide it so users don't see this. Hiding a window in Linux aura causes |
| 700 // it to lose capture so skip it. | |
| 699 browser_widget->Hide(); | 701 browser_widget->Hide(); |
|
varkha
2014/02/26 20:30:18
Not calling Hide on Linux seems to be lesser evil
| |
| 702 #endif | |
| 700 browser_widget->EndMoveLoop(); | 703 browser_widget->EndMoveLoop(); |
| 701 | 704 |
| 702 // Ideally we would always swap the tabs now, but on non-ash it seems that | 705 // Ideally we would always swap the tabs now, but on non-ash it seems that |
| 703 // running the move loop implicitly activates the window when done, leading | 706 // running the move loop implicitly activates the window when done, leading |
| 704 // to all sorts of flicker. So, on non-ash, instead we process the move | 707 // to all sorts of flicker. So, on non-ash, instead we process the move |
| 705 // after the loop completes. But on chromeos, we can do tab swapping now to | 708 // after the loop completes. But on chromeos, we can do tab swapping now to |
| 706 // avoid the tab flashing issue(crbug.com/116329). | 709 // avoid the tab flashing issue(crbug.com/116329). |
| 707 if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { | 710 if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { |
| 708 is_dragging_window_ = false; | 711 is_dragging_window_ = false; |
| 709 Detach(DONT_RELEASE_CAPTURE); | 712 Detach(DONT_RELEASE_CAPTURE); |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1204 // Under chromeos we immediately set the |move_loop_widget_| to NULL. | 1207 // Under chromeos we immediately set the |move_loop_widget_| to NULL. |
| 1205 if (move_loop_widget_) { | 1208 if (move_loop_widget_) { |
| 1206 move_loop_widget_->RemoveObserver(this); | 1209 move_loop_widget_->RemoveObserver(this); |
| 1207 move_loop_widget_ = NULL; | 1210 move_loop_widget_ = NULL; |
| 1208 } | 1211 } |
| 1209 is_dragging_window_ = false; | 1212 is_dragging_window_ = false; |
| 1210 waiting_for_run_loop_to_exit_ = false; | 1213 waiting_for_run_loop_to_exit_ = false; |
| 1211 if (end_run_loop_behavior_ == END_RUN_LOOP_CONTINUE_DRAGGING) { | 1214 if (end_run_loop_behavior_ == END_RUN_LOOP_CONTINUE_DRAGGING) { |
| 1212 end_run_loop_behavior_ = END_RUN_LOOP_STOP_DRAGGING; | 1215 end_run_loop_behavior_ = END_RUN_LOOP_STOP_DRAGGING; |
| 1213 if (tab_strip_to_attach_to_after_exit_) { | 1216 if (tab_strip_to_attach_to_after_exit_) { |
| 1217 tab_strip_to_attach_to_after_exit_->GetWidget()->Activate(); | |
|
varkha
2014/02/26 20:30:18
Activating before calling Detach (which may close
Elliot Glaysher
2014/02/26 20:33:17
What's the effect on Windows here?
varkha
2014/02/26 20:59:35
I didn't have a chance to test this on Windows yet
| |
| 1218 // Activate may trigger a focus loss, destroying us. | |
| 1219 if (!ref) | |
| 1220 return; | |
| 1214 gfx::Point point_in_screen(GetCursorScreenPoint()); | 1221 gfx::Point point_in_screen(GetCursorScreenPoint()); |
| 1215 Detach(DONT_RELEASE_CAPTURE); | 1222 Detach(DONT_RELEASE_CAPTURE); |
| 1216 Attach(tab_strip_to_attach_to_after_exit_, point_in_screen); | 1223 Attach(tab_strip_to_attach_to_after_exit_, point_in_screen); |
| 1217 // Move the tabs into position. | 1224 // Move the tabs into position. |
| 1218 MoveAttached(point_in_screen); | 1225 MoveAttached(point_in_screen); |
| 1219 attached_tabstrip_->GetWidget()->Activate(); | |
| 1220 // Activate may trigger a focus loss, destroying us. | |
| 1221 if (!ref) | |
| 1222 return; | |
| 1223 tab_strip_to_attach_to_after_exit_ = NULL; | 1226 tab_strip_to_attach_to_after_exit_ = NULL; |
| 1224 } | 1227 } |
| 1225 DCHECK(attached_tabstrip_); | 1228 DCHECK(attached_tabstrip_); |
| 1226 attached_tabstrip_->GetWidget()->SetCapture(attached_tabstrip_); | 1229 attached_tabstrip_->GetWidget()->SetCapture(attached_tabstrip_); |
| 1227 } else if (active_) { | 1230 } else if (active_) { |
| 1228 EndDrag(result == views::Widget::MOVE_LOOP_CANCELED ? | 1231 EndDrag(result == views::Widget::MOVE_LOOP_CANCELED ? |
| 1229 END_DRAG_CANCEL : END_DRAG_COMPLETE); | 1232 END_DRAG_CANCEL : END_DRAG_COMPLETE); |
| 1230 } | 1233 } |
| 1231 } | 1234 } |
| 1232 | 1235 |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1899 aura::Window* dragged_window = | 1902 aura::Window* dragged_window = |
| 1900 attached_tabstrip_->GetWidget()->GetNativeView(); | 1903 attached_tabstrip_->GetWidget()->GetNativeView(); |
| 1901 if (dragged_window) | 1904 if (dragged_window) |
| 1902 exclude.insert(dragged_window); | 1905 exclude.insert(dragged_window); |
| 1903 } | 1906 } |
| 1904 return GetLocalProcessWindowAtPoint(host_desktop_type_, | 1907 return GetLocalProcessWindowAtPoint(host_desktop_type_, |
| 1905 screen_point, | 1908 screen_point, |
| 1906 exclude); | 1909 exclude); |
| 1907 | 1910 |
| 1908 } | 1911 } |
| OLD | NEW |