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

Side by Side Diff: chrome/browser/views/tabs/dragged_tab_controller.cc

Issue 210035: Makes tab dragging on views restrict the drag to the main window.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/views/tabs/dragged_tab_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/views/tabs/dragged_tab_controller.h" 5 #include "chrome/browser/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 "app/animation.h" 10 #include "app/animation.h"
11 #include "app/gfx/canvas.h" 11 #include "app/gfx/canvas.h"
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 // think we could just convert them to screen coordinates, however in the 604 // think we could just convert them to screen coordinates, however in the
605 // situation where we're dragging the last tab in a window when multiple 605 // situation where we're dragging the last tab in a window when multiple
606 // windows are open, the coordinates of |source_tab_| are way off in 606 // windows are open, the coordinates of |source_tab_| are way off in
607 // hyperspace since the window was moved there instead of being closed so 607 // hyperspace since the window was moved there instead of being closed so
608 // that we'd keep receiving events. And our ConvertPointToScreen methods 608 // that we'd keep receiving events. And our ConvertPointToScreen methods
609 // aren't really multi-screen aware. So really it's just safer to get the 609 // aren't really multi-screen aware. So really it's just safer to get the
610 // actual position of the mouse cursor directly from Windows here, which is 610 // actual position of the mouse cursor directly from Windows here, which is
611 // guaranteed to be correct regardless of monitor config. 611 // guaranteed to be correct regardless of monitor config.
612 gfx::Point screen_point = GetCursorScreenPoint(); 612 gfx::Point screen_point = GetCursorScreenPoint();
613 613
614 // TODO(sky): make this define OS_CHROMEOS when we merge views and chromeos.
615 #if defined(OS_LINUX)
616 // We don't allow detaching in chrome os.
617 TabStrip* target_tabstrip = source_tabstrip_;
618 #else
614 // Determine whether or not we have dragged over a compatible TabStrip in 619 // Determine whether or not we have dragged over a compatible TabStrip in
615 // another browser window. If we have, we should attach to it and start 620 // another browser window. If we have, we should attach to it and start
616 // dragging within it. 621 // dragging within it.
617 TabStrip* target_tabstrip = GetTabStripForPoint(screen_point); 622 TabStrip* target_tabstrip = GetTabStripForPoint(screen_point);
623 #endif
618 if (target_tabstrip != attached_tabstrip_) { 624 if (target_tabstrip != attached_tabstrip_) {
619 // Make sure we're fully detached from whatever TabStrip we're attached to 625 // Make sure we're fully detached from whatever TabStrip we're attached to
620 // (if any). 626 // (if any).
621 if (attached_tabstrip_) 627 if (attached_tabstrip_)
622 Detach(); 628 Detach();
623 if (target_tabstrip) 629 if (target_tabstrip)
624 Attach(target_tabstrip, screen_point); 630 Attach(target_tabstrip, screen_point);
625 } 631 }
626 if (!target_tabstrip) { 632 if (!target_tabstrip) {
627 bring_to_front_timer_.Start( 633 bring_to_front_timer_.Start(
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 // the width of one tab until the mouse pointer (screen_point) exceeds the 1058 // the width of one tab until the mouse pointer (screen_point) exceeds the
1053 // screen bounds of the TabStrip. 1059 // screen bounds of the TabStrip.
1054 int max_x = tabstrip_bounds.right() - tab_size.width(); 1060 int max_x = tabstrip_bounds.right() - tab_size.width();
1055 int max_y = tabstrip_bounds.bottom() - tab_size.height(); 1061 int max_y = tabstrip_bounds.bottom() - tab_size.height();
1056 if (x > max_x && screen_point.x() <= tabstrip_bounds.right()) 1062 if (x > max_x && screen_point.x() <= tabstrip_bounds.right())
1057 x = max_x; 1063 x = max_x;
1058 if (y > max_y && screen_point.y() <= 1064 if (y > max_y && screen_point.y() <=
1059 (tabstrip_bounds.bottom() + vertical_drag_magnetism)) { 1065 (tabstrip_bounds.bottom() + vertical_drag_magnetism)) {
1060 y = max_y; 1066 y = max_y;
1061 } 1067 }
1068 // TODO(sky): make this define OS_CHROMEOS when we merge views and
1069 // chromeos.
1070 #if defined(OS_LINUX)
1071 // We currently don't allow detaching on chromeos. This restricts dragging
1072 // to the main window.
1073 x = std::min(std::max(x, tabstrip_bounds.x()), max_x);
1074 y = tabstrip_bounds.y();
1075 #endif
1062 } 1076 }
1063 return gfx::Point(x, y); 1077 return gfx::Point(x, y);
1064 } 1078 }
1065 1079
1066 1080
1067 Tab* DraggedTabController::GetTabMatchingDraggedContents( 1081 Tab* DraggedTabController::GetTabMatchingDraggedContents(
1068 TabStrip* tabstrip) const { 1082 TabStrip* tabstrip) const {
1069 int index = tabstrip->model()->GetIndexOfTabContents(dragged_contents_); 1083 int index = tabstrip->model()->GetIndexOfTabContents(dragged_contents_);
1070 return index == TabStripModel::kNoTab ? NULL : tabstrip->GetTabAt(index); 1084 return index == TabStripModel::kNoTab ? NULL : tabstrip->GetTabAt(index);
1071 } 1085 }
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 1400
1387 // The previous call made the window appear on top of the dragged window, 1401 // The previous call made the window appear on top of the dragged window,
1388 // move the dragged window to the front. 1402 // move the dragged window to the front.
1389 SetWindowPos(view_->GetWidget()->GetNativeView(), HWND_TOP, 0, 0, 0, 0, 1403 SetWindowPos(view_->GetWidget()->GetNativeView(), HWND_TOP, 0, 0, 0, 0,
1390 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); 1404 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1391 #else 1405 #else
1392 NOTIMPLEMENTED(); 1406 NOTIMPLEMENTED();
1393 #endif 1407 #endif
1394 } 1408 }
1395 } 1409 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/views/tabs/dragged_tab_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698