Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(867)

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller.cc

Issue 1336823003: Move chrome::HostDesktopType to ui::HostDesktopType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base_session_service_delegate_impl
Patch Set: Fix build on Mac and CrOS Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 const int TabDragController::kTouchVerticalDetachMagnetism = 50; 190 const int TabDragController::kTouchVerticalDetachMagnetism = 50;
191 191
192 // static 192 // static
193 const int TabDragController::kVerticalDetachMagnetism = 15; 193 const int TabDragController::kVerticalDetachMagnetism = 15;
194 194
195 TabDragController::TabDragController() 195 TabDragController::TabDragController()
196 : event_source_(EVENT_SOURCE_MOUSE), 196 : event_source_(EVENT_SOURCE_MOUSE),
197 source_tabstrip_(NULL), 197 source_tabstrip_(NULL),
198 attached_tabstrip_(NULL), 198 attached_tabstrip_(NULL),
199 screen_(NULL), 199 screen_(NULL),
200 host_desktop_type_(chrome::HOST_DESKTOP_TYPE_NATIVE), 200 host_desktop_type_(ui::HOST_DESKTOP_TYPE_NATIVE),
201 can_release_capture_(true), 201 can_release_capture_(true),
202 offset_to_width_ratio_(0), 202 offset_to_width_ratio_(0),
203 old_focused_view_id_( 203 old_focused_view_id_(views::ViewStorage::GetInstance()
204 views::ViewStorage::GetInstance()->CreateStorageID()), 204 ->CreateStorageID()),
205 last_move_screen_loc_(0), 205 last_move_screen_loc_(0),
206 started_drag_(false), 206 started_drag_(false),
207 active_(true), 207 active_(true),
208 source_tab_index_(std::numeric_limits<size_t>::max()), 208 source_tab_index_(std::numeric_limits<size_t>::max()),
209 initial_move_(true), 209 initial_move_(true),
210 detach_behavior_(DETACHABLE), 210 detach_behavior_(DETACHABLE),
211 move_behavior_(REORDER), 211 move_behavior_(REORDER),
212 mouse_move_direction_(0), 212 mouse_move_direction_(0),
213 is_dragging_window_(false), 213 is_dragging_window_(false),
214 is_dragging_new_browser_(false), 214 is_dragging_new_browser_(false),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // Do not release capture when transferring capture between widgets on: 268 // Do not release capture when transferring capture between widgets on:
269 // - Desktop Linux 269 // - Desktop Linux
270 // Mouse capture is not synchronous on desktop Linux. Chrome makes 270 // Mouse capture is not synchronous on desktop Linux. Chrome makes
271 // transferring capture between widgets without releasing capture appear 271 // transferring capture between widgets without releasing capture appear
272 // synchronous on desktop Linux, so use that. 272 // synchronous on desktop Linux, so use that.
273 // - Ash 273 // - Ash
274 // Releasing capture on Ash cancels gestures so avoid it. 274 // Releasing capture on Ash cancels gestures so avoid it.
275 #if defined(OS_LINUX) 275 #if defined(OS_LINUX)
276 can_release_capture_ = false; 276 can_release_capture_ = false;
277 #else 277 #else
278 can_release_capture_ = 278 can_release_capture_ = (host_desktop_type_ != ui::HOST_DESKTOP_TYPE_ASH);
279 (host_desktop_type_ != chrome::HOST_DESKTOP_TYPE_ASH);
280 #endif 279 #endif
281 start_point_in_screen_ = gfx::Point(source_tab_offset, mouse_offset.y()); 280 start_point_in_screen_ = gfx::Point(source_tab_offset, mouse_offset.y());
282 views::View::ConvertPointToScreen(source_tab, &start_point_in_screen_); 281 views::View::ConvertPointToScreen(source_tab, &start_point_in_screen_);
283 event_source_ = event_source; 282 event_source_ = event_source;
284 mouse_offset_ = mouse_offset; 283 mouse_offset_ = mouse_offset;
285 move_behavior_ = move_behavior; 284 move_behavior_ = move_behavior;
286 last_point_in_screen_ = start_point_in_screen_; 285 last_point_in_screen_ = start_point_in_screen_;
287 last_move_screen_loc_ = start_point_in_screen_.x(); 286 last_move_screen_loc_ = start_point_in_screen_.x();
288 initial_tab_positions_ = source_tabstrip->GetTabXCoordinates(); 287 initial_tab_positions_ = source_tabstrip->GetTabXCoordinates();
289 288
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 // Only Aura windows are gesture consumers. 596 // Only Aura windows are gesture consumers.
598 ui::GestureRecognizer::Get()->TransferEventsTo( 597 ui::GestureRecognizer::Get()->TransferEventsTo(
599 GetAttachedBrowserWidget()->GetNativeView(), 598 GetAttachedBrowserWidget()->GetNativeView(),
600 target_tabstrip->GetWidget()->GetNativeView()); 599 target_tabstrip->GetWidget()->GetNativeView());
601 #endif 600 #endif
602 601
603 if (is_dragging_window_) { 602 if (is_dragging_window_) {
604 // ReleaseCapture() is going to result in calling back to us (because it 603 // ReleaseCapture() is going to result in calling back to us (because it
605 // results in a move). That'll cause all sorts of problems. Reset the 604 // results in a move). That'll cause all sorts of problems. Reset the
606 // observer so we don't get notified and process the event. 605 // observer so we don't get notified and process the event.
607 if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { 606 if (host_desktop_type_ == ui::HOST_DESKTOP_TYPE_ASH) {
608 move_loop_widget_->RemoveObserver(this); 607 move_loop_widget_->RemoveObserver(this);
609 move_loop_widget_ = NULL; 608 move_loop_widget_ = NULL;
610 } 609 }
611 views::Widget* browser_widget = GetAttachedBrowserWidget(); 610 views::Widget* browser_widget = GetAttachedBrowserWidget();
612 // Need to release the drag controller before starting the move loop as it's 611 // Need to release the drag controller before starting the move loop as it's
613 // going to trigger capture lost, which cancels drag. 612 // going to trigger capture lost, which cancels drag.
614 attached_tabstrip_->ReleaseDragController(); 613 attached_tabstrip_->ReleaseDragController();
615 target_tabstrip->OwnDragController(this); 614 target_tabstrip->OwnDragController(this);
616 // Disable animations so that we don't see a close animation on aero. 615 // Disable animations so that we don't see a close animation on aero.
617 browser_widget->SetVisibilityChangedAnimationsEnabled(false); 616 browser_widget->SetVisibilityChangedAnimationsEnabled(false);
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 contentses, window_bounds, widget->IsMaximized()); 1536 contentses, window_bounds, widget->IsMaximized());
1538 ResetSelection(new_browser->tab_strip_model()); 1537 ResetSelection(new_browser->tab_strip_model());
1539 new_browser->window()->Show(); 1538 new_browser->window()->Show();
1540 } 1539 }
1541 } 1540 }
1542 1541
1543 void TabDragController::MaximizeAttachedWindow() { 1542 void TabDragController::MaximizeAttachedWindow() {
1544 GetAttachedBrowserWidget()->Maximize(); 1543 GetAttachedBrowserWidget()->Maximize();
1545 #if defined(USE_ASH) 1544 #if defined(USE_ASH)
1546 if (was_source_fullscreen_ && 1545 if (was_source_fullscreen_ &&
1547 host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { 1546 host_desktop_type_ == ui::HOST_DESKTOP_TYPE_ASH) {
1548 // In fullscreen mode it is only possible to get here if the source 1547 // In fullscreen mode it is only possible to get here if the source
1549 // was in "immersive fullscreen" mode, so toggle it back on. 1548 // was in "immersive fullscreen" mode, so toggle it back on.
1550 ash::accelerators::ToggleFullscreen(); 1549 ash::accelerators::ToggleFullscreen();
1551 } 1550 }
1552 #endif 1551 #endif
1553 } 1552 }
1554 1553
1555 gfx::Rect TabDragController::GetViewScreenBounds( 1554 gfx::Rect TabDragController::GetViewScreenBounds(
1556 views::View* view) const { 1555 views::View* view) const {
1557 gfx::Point view_topleft; 1556 gfx::Point view_topleft;
(...skipping 12 matching lines...) Expand all
1570 if (!GetTabStripForWindow(window)) 1569 if (!GetTabStripForWindow(window))
1571 return; 1570 return;
1572 1571
1573 if (window) { 1572 if (window) {
1574 views::Widget* widget_window = views::Widget::GetWidgetForNativeWindow( 1573 views::Widget* widget_window = views::Widget::GetWidgetForNativeWindow(
1575 window); 1574 window);
1576 if (!widget_window) 1575 if (!widget_window)
1577 return; 1576 return;
1578 1577
1579 #if defined(USE_ASH) 1578 #if defined(USE_ASH)
1580 if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { 1579 if (host_desktop_type_ == ui::HOST_DESKTOP_TYPE_ASH) {
1581 // TODO(varkha): The code below ensures that the phantom drag widget 1580 // TODO(varkha): The code below ensures that the phantom drag widget
1582 // is shown on top of browser windows. The code should be moved to ash/ 1581 // is shown on top of browser windows. The code should be moved to ash/
1583 // and the phantom should be able to assert its top-most state on its own. 1582 // and the phantom should be able to assert its top-most state on its own.
1584 // One strategy would be for DragWindowController to 1583 // One strategy would be for DragWindowController to
1585 // be able to observe stacking changes to the phantom drag widget's 1584 // be able to observe stacking changes to the phantom drag widget's
1586 // siblings in order to keep it on top. One way is to implement a 1585 // siblings in order to keep it on top. One way is to implement a
1587 // notification that is sent to a window parent's observers when a 1586 // notification that is sent to a window parent's observers when a
1588 // stacking order is changed among the children of that same parent. 1587 // stacking order is changed among the children of that same parent.
1589 // Note that OnWindowStackingChanged is sent only to the child that is the 1588 // Note that OnWindowStackingChanged is sent only to the child that is the
1590 // argument of one of the Window::StackChildX calls and not to all its 1589 // argument of one of the Window::StackChildX calls and not to all its
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 SetWindowPositionManaged(browser->window()->GetNativeWindow(), false); 1754 SetWindowPositionManaged(browser->window()->GetNativeWindow(), false);
1756 // If the window is created maximized then the bounds we supplied are ignored. 1755 // If the window is created maximized then the bounds we supplied are ignored.
1757 // We need to reset them again so they are honored. 1756 // We need to reset them again so they are honored.
1758 browser->window()->SetBounds(new_bounds); 1757 browser->window()->SetBounds(new_bounds);
1759 1758
1760 return browser; 1759 return browser;
1761 } 1760 }
1762 1761
1763 gfx::Point TabDragController::GetCursorScreenPoint() { 1762 gfx::Point TabDragController::GetCursorScreenPoint() {
1764 #if defined(USE_ASH) 1763 #if defined(USE_ASH)
1765 if (host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH && 1764 if (host_desktop_type_ == ui::HOST_DESKTOP_TYPE_ASH &&
1766 event_source_ == EVENT_SOURCE_TOUCH && 1765 event_source_ == EVENT_SOURCE_TOUCH &&
1767 aura::Env::GetInstance()->is_touch_down()) { 1766 aura::Env::GetInstance()->is_touch_down()) {
1768 views::Widget* widget = GetAttachedBrowserWidget(); 1767 views::Widget* widget = GetAttachedBrowserWidget();
1769 DCHECK(widget); 1768 DCHECK(widget);
1770 aura::Window* widget_window = widget->GetNativeWindow(); 1769 aura::Window* widget_window = widget->GetNativeWindow();
1771 DCHECK(widget_window->GetRootWindow()); 1770 DCHECK(widget_window->GetRootWindow());
1772 gfx::PointF touch_point_f; 1771 gfx::PointF touch_point_f;
1773 bool got_touch_point = ui::GestureRecognizer::Get()-> 1772 bool got_touch_point = ui::GestureRecognizer::Get()->
1774 GetLastTouchPointForTarget(widget_window, &touch_point_f); 1773 GetLastTouchPointForTarget(widget_window, &touch_point_f);
1775 CHECK(got_touch_point); 1774 CHECK(got_touch_point);
(...skipping 27 matching lines...) Expand all
1803 attached_tabstrip_->GetWidget()->GetNativeWindow(); 1802 attached_tabstrip_->GetWidget()->GetNativeWindow();
1804 if (dragged_window) 1803 if (dragged_window)
1805 exclude.insert(dragged_window); 1804 exclude.insert(dragged_window);
1806 } 1805 }
1807 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 1806 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1808 // Exclude windows which are pending deletion via Browser::TabStripEmpty(). 1807 // Exclude windows which are pending deletion via Browser::TabStripEmpty().
1809 // These windows can be returned in the Linux Aura port because the browser 1808 // These windows can be returned in the Linux Aura port because the browser
1810 // window which was used for dragging is not hidden once all of its tabs are 1809 // window which was used for dragging is not hidden once all of its tabs are
1811 // attached to another browser window in DragBrowserToNewTabStrip(). 1810 // attached to another browser window in DragBrowserToNewTabStrip().
1812 // TODO(pkotwicz): Fix this properly (crbug.com/358482) 1811 // TODO(pkotwicz): Fix this properly (crbug.com/358482)
1813 BrowserList* browser_list = BrowserList::GetInstance( 1812 BrowserList* browser_list =
1814 chrome::HOST_DESKTOP_TYPE_NATIVE); 1813 BrowserList::GetInstance(ui::HOST_DESKTOP_TYPE_NATIVE);
1815 for (BrowserList::const_iterator it = browser_list->begin(); 1814 for (BrowserList::const_iterator it = browser_list->begin();
1816 it != browser_list->end(); ++it) { 1815 it != browser_list->end(); ++it) {
1817 if ((*it)->tab_strip_model()->empty()) 1816 if ((*it)->tab_strip_model()->empty())
1818 exclude.insert((*it)->window()->GetNativeWindow()); 1817 exclude.insert((*it)->window()->GetNativeWindow());
1819 } 1818 }
1820 #endif 1819 #endif
1821 return GetLocalProcessWindowAtPoint(host_desktop_type_, 1820 return GetLocalProcessWindowAtPoint(host_desktop_type_,
1822 screen_point, 1821 screen_point,
1823 exclude); 1822 exclude);
1824 1823
1825 } 1824 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698