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

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 moved to namespac… 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 |tab_strip| browser window is docked.
213 bool IsDocked(const TabStrip* tab_strip) {
214 #if defined(USE_ASH)
215 DCHECK(tab_strip);
216 return ash::wm::GetWindowState(
217 tab_strip->GetWidget()->GetNativeWindow())->IsDocked();
218 #endif
219 return false;
220 }
221
212 // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate 222 // Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate
213 // of |bounds| is adjusted by |vertical_adjustment|. 223 // of |bounds| is adjusted by |vertical_adjustment|.
214 bool DoesRectContainVerticalPointExpanded( 224 bool DoesRectContainVerticalPointExpanded(
215 const gfx::Rect& bounds, 225 const gfx::Rect& bounds,
216 int vertical_adjustment, 226 int vertical_adjustment,
217 int y) { 227 int y) {
218 int upper_threshold = bounds.bottom() + vertical_adjustment; 228 int upper_threshold = bounds.bottom() + vertical_adjustment;
219 int lower_threshold = bounds.y() - vertical_adjustment; 229 int lower_threshold = bounds.y() - vertical_adjustment;
220 return y >= lower_threshold && y <= upper_threshold; 230 return y >= lower_threshold && y <= upper_threshold;
221 } 231 }
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 if (source_tab->width() > 0) { 487 if (source_tab->width() > 0) {
478 offset_to_width_ratio_ = static_cast<float>( 488 offset_to_width_ratio_ = static_cast<float>(
479 source_tab->GetMirroredXInView(source_tab_offset)) / 489 source_tab->GetMirroredXInView(source_tab_offset)) /
480 static_cast<float>(source_tab->width()); 490 static_cast<float>(source_tab->width());
481 } 491 }
482 InitWindowCreatePoint(); 492 InitWindowCreatePoint();
483 initial_selection_model_.Copy(initial_selection_model); 493 initial_selection_model_.Copy(initial_selection_model);
484 } 494 }
485 495
486 // static 496 // static
487 bool TabDragController::IsAttachedTo(TabStrip* tab_strip) { 497 bool TabDragController::IsAttachedTo(const TabStrip* tab_strip) {
488 return (instance_ && instance_->active() && 498 return (instance_ && instance_->active() &&
489 instance_->attached_tabstrip() == tab_strip); 499 instance_->attached_tabstrip() == tab_strip);
490 } 500 }
491 501
492 // static 502 // static
493 bool TabDragController::IsActive() { 503 bool TabDragController::IsActive() {
494 return instance_ && instance_->active(); 504 return instance_ && instance_->active();
495 } 505 }
496 506
497 // static 507 // static
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 data->source_model_index, data->contents, 1876 data->source_model_index, data->contents,
1867 (data->pinned ? TabStripModel::ADD_PINNED : 0)); 1877 (data->pinned ? TabStripModel::ADD_PINNED : 0));
1868 } 1878 }
1869 } 1879 }
1870 1880
1871 void TabDragController::CompleteDrag() { 1881 void TabDragController::CompleteDrag() {
1872 DCHECK(started_drag_); 1882 DCHECK(started_drag_);
1873 1883
1874 if (attached_tabstrip_) { 1884 if (attached_tabstrip_) {
1875 if (is_dragging_new_browser_) { 1885 if (is_dragging_new_browser_) {
1886 if (IsDocked(attached_tabstrip_)) {
1887 DCHECK_EQ(host_desktop_type_, chrome::HOST_DESKTOP_TYPE_ASH);
1888 was_source_maximized_ = false;
1889 was_source_fullscreen_ = false;
1890 }
1876 // If source window was maximized - maximize the new window as well. 1891 // If source window was maximized - maximize the new window as well.
1877 if (was_source_maximized_) 1892 if (was_source_maximized_)
1878 attached_tabstrip_->GetWidget()->Maximize(); 1893 attached_tabstrip_->GetWidget()->Maximize();
1879 #if defined(USE_ASH) 1894 #if defined(USE_ASH)
1880 if (was_source_fullscreen_ && 1895 if (was_source_fullscreen_ &&
1881 host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { 1896 host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) {
1882 // In fullscreen mode it is only possible to get here if the source 1897 // In fullscreen mode it is only possible to get here if the source
1883 // was in "immersive fullscreen" mode, so toggle it back on. 1898 // was in "immersive fullscreen" mode, so toggle it back on.
1884 ash::Shell::GetInstance()->delegate()->ToggleFullscreen(); 1899 ash::Shell::GetInstance()->delegate()->ToggleFullscreen();
1885 } 1900 }
1886 #endif 1901 #endif
1902 } else {
1903 // When dragging results in maximized or fullscreen browser window getting
1904 // docked, restore it.
1905 if ((was_source_fullscreen_ || was_source_maximized_) &&
1906 (IsDocked(attached_tabstrip_))) {
1907 DCHECK_EQ(host_desktop_type_, chrome::HOST_DESKTOP_TYPE_ASH);
1908 attached_tabstrip_->GetWidget()->Restore();
1909 }
1887 } 1910 }
1888 attached_tabstrip_->StoppedDraggingTabs( 1911 attached_tabstrip_->StoppedDraggingTabs(
1889 GetTabsMatchingDraggedContents(attached_tabstrip_), 1912 GetTabsMatchingDraggedContents(attached_tabstrip_),
1890 initial_tab_positions_, 1913 initial_tab_positions_,
1891 move_behavior_ == MOVE_VISIBILE_TABS, 1914 move_behavior_ == MOVE_VISIBILE_TABS,
1892 true); 1915 true);
1893 } else { 1916 } else {
1894 if (dock_info_.type() != DockInfo::NONE) { 1917 if (dock_info_.type() != DockInfo::NONE) {
1895 switch (dock_info_.type()) { 1918 switch (dock_info_.type()) {
1896 case DockInfo::LEFT_OF_WINDOW: 1919 case DockInfo::LEFT_OF_WINDOW:
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2258 gfx::Vector2d TabDragController::GetWindowOffset( 2281 gfx::Vector2d TabDragController::GetWindowOffset(
2259 const gfx::Point& point_in_screen) { 2282 const gfx::Point& point_in_screen) {
2260 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? 2283 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ?
2261 attached_tabstrip_ : source_tabstrip_; 2284 attached_tabstrip_ : source_tabstrip_;
2262 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); 2285 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView();
2263 2286
2264 gfx::Point point = point_in_screen; 2287 gfx::Point point = point_in_screen;
2265 views::View::ConvertPointFromScreen(toplevel_view, &point); 2288 views::View::ConvertPointFromScreen(toplevel_view, &point);
2266 return point.OffsetFromOrigin(); 2289 return point.OffsetFromOrigin();
2267 } 2290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698