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

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

Issue 38073004: Not moving a docked window when restoring a previously maximized window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Not moving a docked window when restoring a previously maximized window (IsDocked local to TabDragC… Created 7 years, 1 month 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 ash::wm::GetWindowState(window)->SetTrackedByWorkspace(value); 202 ash::wm::GetWindowState(window)->SetTrackedByWorkspace(value);
203 #endif 203 #endif
204 } 204 }
205 205
206 void SetWindowPositionManaged(gfx::NativeWindow window, bool value) { 206 void SetWindowPositionManaged(gfx::NativeWindow window, bool value) {
207 #if defined(USE_ASH) 207 #if defined(USE_ASH)
208 ash::wm::GetWindowState(window)->set_window_position_managed(value); 208 ash::wm::GetWindowState(window)->set_window_position_managed(value);
209 #endif 209 #endif
210 } 210 }
211 211
212 // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate 212 // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate
sky 2013/10/29 20:46:42 Move IsDocked here please.
varkha 2013/10/29 21:08:32 Done.
213 // of |bounds| is adjusted by |vertical_adjustment|. 213 // of |bounds| is adjusted by |vertical_adjustment|.
214 bool DoesRectContainVerticalPointExpanded( 214 bool DoesRectContainVerticalPointExpanded(
215 const gfx::Rect& bounds, 215 const gfx::Rect& bounds,
216 int vertical_adjustment, 216 int vertical_adjustment,
217 int y) { 217 int y) {
218 int upper_threshold = bounds.bottom() + vertical_adjustment; 218 int upper_threshold = bounds.bottom() + vertical_adjustment;
219 int lower_threshold = bounds.y() - vertical_adjustment; 219 int lower_threshold = bounds.y() - vertical_adjustment;
220 return y >= lower_threshold && y <= upper_threshold; 220 return y >= lower_threshold && y <= upper_threshold;
221 } 221 }
222 222
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 if (source_tab->width() > 0) { 477 if (source_tab->width() > 0) {
478 offset_to_width_ratio_ = static_cast<float>( 478 offset_to_width_ratio_ = static_cast<float>(
479 source_tab->GetMirroredXInView(source_tab_offset)) / 479 source_tab->GetMirroredXInView(source_tab_offset)) /
480 static_cast<float>(source_tab->width()); 480 static_cast<float>(source_tab->width());
481 } 481 }
482 InitWindowCreatePoint(); 482 InitWindowCreatePoint();
483 initial_selection_model_.Copy(initial_selection_model); 483 initial_selection_model_.Copy(initial_selection_model);
484 } 484 }
485 485
486 // static 486 // static
487 bool TabDragController::IsAttachedTo(TabStrip* tab_strip) { 487 bool TabDragController::IsAttachedTo(const TabStrip* tab_strip) {
488 return (instance_ && instance_->active() && 488 return (instance_ && instance_->active() &&
489 instance_->attached_tabstrip() == tab_strip); 489 instance_->attached_tabstrip() == tab_strip);
490 } 490 }
491 491
492 // static 492 // static
493 bool TabDragController::IsActive() { 493 bool TabDragController::IsActive() {
494 return instance_ && instance_->active(); 494 return instance_ && instance_->active();
495 } 495 }
496 496
497 // static 497 // static
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 data->source_model_index, data->contents, 1866 data->source_model_index, data->contents,
1867 (data->pinned ? TabStripModel::ADD_PINNED : 0)); 1867 (data->pinned ? TabStripModel::ADD_PINNED : 0));
1868 } 1868 }
1869 } 1869 }
1870 1870
1871 void TabDragController::CompleteDrag() { 1871 void TabDragController::CompleteDrag() {
1872 DCHECK(started_drag_); 1872 DCHECK(started_drag_);
1873 1873
1874 if (attached_tabstrip_) { 1874 if (attached_tabstrip_) {
1875 if (is_dragging_new_browser_) { 1875 if (is_dragging_new_browser_) {
1876 if (IsDocked(attached_tabstrip_)) {
1877 DCHECK_EQ(host_desktop_type_, chrome::HOST_DESKTOP_TYPE_ASH);
1878 was_source_maximized_ = false;
1879 was_source_fullscreen_ = false;
1880 }
1876 // If source window was maximized - maximize the new window as well. 1881 // If source window was maximized - maximize the new window as well.
1877 if (was_source_maximized_) 1882 if (was_source_maximized_)
1878 attached_tabstrip_->GetWidget()->Maximize(); 1883 attached_tabstrip_->GetWidget()->Maximize();
1879 #if defined(USE_ASH) 1884 #if defined(USE_ASH)
1880 if (was_source_fullscreen_ && 1885 if (was_source_fullscreen_ &&
1881 host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { 1886 host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) {
1882 // In fullscreen mode it is only possible to get here if the source 1887 // In fullscreen mode it is only possible to get here if the source
1883 // was in "immersive fullscreen" mode, so toggle it back on. 1888 // was in "immersive fullscreen" mode, so toggle it back on.
1884 ash::Shell::GetInstance()->delegate()->ToggleFullscreen(); 1889 ash::Shell::GetInstance()->delegate()->ToggleFullscreen();
1885 } 1890 }
1886 #endif 1891 #endif
1892 } else {
1893 // When dragging results in maximized or fullscreen browser window getting
1894 // docked, restore it.
1895 if ((was_source_fullscreen_ || was_source_maximized_) &&
1896 (IsDocked(attached_tabstrip_))) {
1897 DCHECK_EQ(host_desktop_type_, chrome::HOST_DESKTOP_TYPE_ASH);
1898 attached_tabstrip_->GetWidget()->Restore();
1899 }
1887 } 1900 }
1888 attached_tabstrip_->StoppedDraggingTabs( 1901 attached_tabstrip_->StoppedDraggingTabs(
1889 GetTabsMatchingDraggedContents(attached_tabstrip_), 1902 GetTabsMatchingDraggedContents(attached_tabstrip_),
1890 initial_tab_positions_, 1903 initial_tab_positions_,
1891 move_behavior_ == MOVE_VISIBILE_TABS, 1904 move_behavior_ == MOVE_VISIBILE_TABS,
1892 true); 1905 true);
1893 } else { 1906 } else {
1894 if (dock_info_.type() != DockInfo::NONE) { 1907 if (dock_info_.type() != DockInfo::NONE) {
1895 switch (dock_info_.type()) { 1908 switch (dock_info_.type()) {
1896 case DockInfo::LEFT_OF_WINDOW: 1909 case DockInfo::LEFT_OF_WINDOW:
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2258 gfx::Vector2d TabDragController::GetWindowOffset( 2271 gfx::Vector2d TabDragController::GetWindowOffset(
2259 const gfx::Point& point_in_screen) { 2272 const gfx::Point& point_in_screen) {
2260 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? 2273 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ?
2261 attached_tabstrip_ : source_tabstrip_; 2274 attached_tabstrip_ : source_tabstrip_;
2262 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); 2275 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView();
2263 2276
2264 gfx::Point point = point_in_screen; 2277 gfx::Point point = point_in_screen;
2265 views::View::ConvertPointFromScreen(toplevel_view, &point); 2278 views::View::ConvertPointFromScreen(toplevel_view, &point);
2266 return point.OffsetFromOrigin(); 2279 return point.OffsetFromOrigin();
2267 } 2280 }
2281
2282 // static
2283 bool TabDragController::IsDocked(const TabStrip* tab_strip) {
2284 #if defined(USE_ASH)
2285 DCHECK(tab_strip);
2286 return ash::wm::GetWindowState(
2287 tab_strip->GetWidget()->GetNativeWindow())->IsDocked();
2288 #endif
2289 return false;
2290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698