diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 16:43:46 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 16:43:46 +0000 |
commit | ce4056a1697df5bd050d70bff7f7dd2b741eafe8 (patch) | |
tree | 411942d54613a60ae70528ca0459adb7f529937f | |
parent | e9e2112725868a0bc343775d336a94197efb3809 (diff) | |
download | chromium_src-ce4056a1697df5bd050d70bff7f7dd2b741eafe8.zip chromium_src-ce4056a1697df5bd050d70bff7f7dd2b741eafe8.tar.gz chromium_src-ce4056a1697df5bd050d70bff7f7dd2b741eafe8.tar.bz2 |
Makes tab dragging on views restrict the drag to the main window.
As X is async, this results in annoying flicker right now. If we stick
with this we're going to need to avoid creating a new window. But this
is good enough for now.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/210035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26820 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/views/tabs/dragged_tab_controller.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/tabs/dragged_tab_view.cc | 37 |
2 files changed, 35 insertions, 18 deletions
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index 9922404..7a00715 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -611,10 +611,16 @@ void DraggedTabController::ContinueDragging() { // guaranteed to be correct regardless of monitor config. gfx::Point screen_point = GetCursorScreenPoint(); + // TODO(sky): make this define OS_CHROMEOS when we merge views and chromeos. +#if defined(OS_LINUX) + // We don't allow detaching in chrome os. + TabStrip* target_tabstrip = source_tabstrip_; +#else // Determine whether or not we have dragged over a compatible TabStrip in // another browser window. If we have, we should attach to it and start // dragging within it. TabStrip* target_tabstrip = GetTabStripForPoint(screen_point); +#endif if (target_tabstrip != attached_tabstrip_) { // Make sure we're fully detached from whatever TabStrip we're attached to // (if any). @@ -1059,6 +1065,14 @@ gfx::Point DraggedTabController::GetDraggedViewPoint( (tabstrip_bounds.bottom() + vertical_drag_magnetism)) { y = max_y; } + // TODO(sky): make this define OS_CHROMEOS when we merge views and + // chromeos. +#if defined(OS_LINUX) + // We currently don't allow detaching on chromeos. This restricts dragging + // to the main window. + x = std::min(std::max(x, tabstrip_bounds.x()), max_x); + y = tabstrip_bounds.y(); +#endif } return gfx::Point(x, y); } diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc index 2c0a573..293b47b 100644 --- a/chrome/browser/views/tabs/dragged_tab_view.cc +++ b/chrome/browser/views/tabs/dragged_tab_view.cc @@ -61,6 +61,7 @@ DraggedTabView::DraggedTabView(TabContents* datasource, } #else container_.reset(new views::WidgetGtk(views::WidgetGtk::TYPE_POPUP)); + container_->MakeTransparent(); container_->set_delete_on_destroy(false); container_->Init(NULL, gfx::Rect(0, 0, 0, 0)); container_->SetContentsView(this); @@ -71,17 +72,10 @@ DraggedTabView::~DraggedTabView() { if (close_animation_.IsAnimating()) close_animation_.Stop(); GetParent()->RemoveChildView(this); -#if defined(OS_WIN) container_->CloseNow(); -#else - NOTIMPLEMENTED(); -#endif } void DraggedTabView::MoveTo(const gfx::Point& screen_point) { -#if defined(OS_WIN) - int show_flags = container_->IsVisible() ? SWP_NOZORDER : SWP_SHOWWINDOW; - int x; if (UILayoutIsRightToLeft() && !attached_) { // On RTL locales, a dragged tab (when it is not attached to a tab strip) @@ -98,10 +92,17 @@ void DraggedTabView::MoveTo(const gfx::Point& screen_point) { int y = screen_point.y() + mouse_tab_offset_.y() - ScaleValue(mouse_tab_offset_.y()); +#if defined(OS_WIN) + int show_flags = container_->IsVisible() ? SWP_NOZORDER : SWP_SHOWWINDOW; + container_->SetWindowPos(HWND_TOP, x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | show_flags); #else - NOTIMPLEMENTED(); + gfx::Rect bounds; + container_->GetBounds(&bounds, true); + container_->SetBounds(gfx::Rect(x, y, bounds.width(), bounds.height())); + if (!container_->IsVisible()) + container_->Show(); #endif } @@ -110,8 +111,6 @@ void DraggedTabView::Attach(int selected_width) { photobooth_ = NULL; #if defined(OS_WIN) container_->SetOpacity(kOpaqueAlpha); -#else - NOTIMPLEMENTED(); #endif Resize(selected_width); } @@ -143,8 +142,6 @@ void DraggedTabView::Detach(NativeViewPhotobooth* photobooth) { photobooth_ = photobooth; #if defined(OS_WIN) container_->SetOpacity(kTransparentAlpha); -#else - NOTIMPLEMENTED(); #endif ResizeContainer(); Update(); @@ -157,7 +154,7 @@ void DraggedTabView::Update() { container_->PaintNow(gfx::Rect()); container_->set_can_update_layered_window(false); #else - NOTIMPLEMENTED(); + SchedulePaint(); #endif } @@ -182,13 +179,16 @@ void DraggedTabView::AnimateToBounds(const gfx::Rect& bounds, // DraggedTabView, AnimationDelegate implementation: void DraggedTabView::AnimationProgressed(const Animation* animation) { -#if defined(OS_WIN) int delta_x = (animation_end_bounds_.x() - animation_start_bounds_.x()); int x = animation_start_bounds_.x() + static_cast<int>(delta_x * animation->GetCurrentValue()); int y = animation_end_bounds_.y(); +#if defined(OS_WIN) container_->SetWindowPos(NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE); #else + gfx::Rect bounds; + container_->GetBounds(&bounds, true); + container_->SetBounds(gfx::Rect(x, y, bounds.width(), bounds.height())); #endif } @@ -305,12 +305,15 @@ void DraggedTabView::PaintFocusRect(gfx::Canvas* canvas) { void DraggedTabView::ResizeContainer() { gfx::Size ps = GetPreferredSize(); + int w = ScaleValue(ps.width()); + int h = ScaleValue(ps.height()); #if defined(OS_WIN) - SetWindowPos(container_->GetNativeView(), HWND_TOPMOST, 0, 0, - ScaleValue(ps.width()), ScaleValue(ps.height()), + SetWindowPos(container_->GetNativeView(), HWND_TOPMOST, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); #else - NOTIMPLEMENTED(); + gfx::Rect bounds; + container_->GetBounds(&bounds, true); + container_->SetBounds(gfx::Rect(bounds.x(), bounds.y(), w, h)); #endif } |