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

Side by Side Diff: chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc

Issue 165463003: Copies DockInfoGtk into WindowFinder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
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/gtk/tabs/dragged_tab_controller_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/platform_util.h" 13 #include "chrome/browser/platform_util.h"
14 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" 14 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 16 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
17 #include "chrome/browser/ui/gtk/gtk_util.h" 17 #include "chrome/browser/ui/gtk/gtk_util.h"
18 #include "chrome/browser/ui/gtk/tabs/dragged_view_gtk.h" 18 #include "chrome/browser/ui/gtk/tabs/dragged_view_gtk.h"
19 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" 19 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h"
20 #include "chrome/browser/ui/gtk/tabs/window_finder.h"
20 #include "chrome/browser/ui/media_utils.h" 21 #include "chrome/browser/ui/media_utils.h"
22 #include "chrome/browser/ui/tabs/dock_info.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
23 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
24 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
25 #include "content/public/browser/web_contents_view.h" 27 #include "content/public/browser/web_contents_view.h"
26 #include "ui/base/gtk/gtk_screen_util.h" 28 #include "ui/base/gtk/gtk_screen_util.h"
27 #include "ui/gfx/screen.h" 29 #include "ui/gfx/screen.h"
28 30
29 using content::OpenURLParams; 31 using content::OpenURLParams;
30 using content::WebContents; 32 using content::WebContents;
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 357
356 void DraggedTabControllerGtk::MoveDetached(const gfx::Point& screen_point) { 358 void DraggedTabControllerGtk::MoveDetached(const gfx::Point& screen_point) {
357 DCHECK(!attached_tabstrip_); 359 DCHECK(!attached_tabstrip_);
358 // Just moving the dragged view. There are no changes to the model if we're 360 // Just moving the dragged view. There are no changes to the model if we're
359 // detached. 361 // detached.
360 dragged_view_->MoveDetachedTo(screen_point); 362 dragged_view_->MoveDetachedTo(screen_point);
361 } 363 }
362 364
363 TabStripGtk* DraggedTabControllerGtk::GetTabStripForPoint( 365 TabStripGtk* DraggedTabControllerGtk::GetTabStripForPoint(
364 const gfx::Point& screen_point) { 366 const gfx::Point& screen_point) {
365 GtkWidget* dragged_window = dragged_view_->widget(); 367 gfx::NativeWindow local_window = GetLocalProcessWindow(screen_point);
366 dock_windows_.insert(dragged_window);
367 gfx::NativeWindow local_window =
368 DockInfo::GetLocalProcessWindowAtPoint(
369 chrome::HOST_DESKTOP_TYPE_NATIVE, screen_point, dock_windows_);
370 dock_windows_.erase(dragged_window);
371 if (!local_window) 368 if (!local_window)
372 return NULL; 369 return NULL;
373 370
374 BrowserWindowGtk* browser = 371 BrowserWindowGtk* browser =
375 BrowserWindowGtk::GetBrowserWindowForNativeWindow(local_window); 372 BrowserWindowGtk::GetBrowserWindowForNativeWindow(local_window);
376 if (!browser) 373 if (!browser)
377 return NULL; 374 return NULL;
378 375
379 TabStripGtk* other_tabstrip = browser->tabstrip(); 376 TabStripGtk* other_tabstrip = browser->tabstrip();
380 if (!other_tabstrip->IsCompatibleWith(source_tabstrip_)) 377 if (!other_tabstrip->IsCompatibleWith(source_tabstrip_))
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 std::vector<TabStripModelDelegate::NewStripContents> contentses; 768 std::vector<TabStripModelDelegate::NewStripContents> contentses;
772 for (size_t i = 0; i < drag_data_->size(); ++i) { 769 for (size_t i = 0; i < drag_data_->size(); ++i) {
773 TabStripModelDelegate::NewStripContents item; 770 TabStripModelDelegate::NewStripContents item;
774 item.web_contents = drag_data_->get(i)->contents_; 771 item.web_contents = drag_data_->get(i)->contents_;
775 item.add_types = drag_data_->GetAddTypesForDraggedTabAt(i); 772 item.add_types = drag_data_->GetAddTypesForDraggedTabAt(i);
776 contentses.push_back(item); 773 contentses.push_back(item);
777 }; 774 };
778 775
779 Browser* new_browser = 776 Browser* new_browser =
780 source_tabstrip_->model()->delegate()->CreateNewStripWithContents( 777 source_tabstrip_->model()->delegate()->CreateNewStripWithContents(
781 contentses, window_bounds, dock_info_, window->IsMaximized()); 778 contentses, window_bounds, DockInfo(), window->IsMaximized());
782 RestoreSelection(new_browser->tab_strip_model()); 779 RestoreSelection(new_browser->tab_strip_model());
783 new_browser->window()->Show(); 780 new_browser->window()->Show();
784 CleanUpHiddenFrame(); 781 CleanUpHiddenFrame();
785 } 782 }
786 783
787 return destroy_immediately; 784 return destroy_immediately;
788 } 785 }
789 786
790 void DraggedTabControllerGtk::ResetDelegates() { 787 void DraggedTabControllerGtk::ResetDelegates() {
791 for (size_t i = 0; i < drag_data_->size(); ++i) { 788 for (size_t i = 0; i < drag_data_->size(); ++i) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 SetDraggedTabsVisible(true, true); 864 SetDraggedTabsVisible(true, true);
868 865
869 CleanUpHiddenFrame(); 866 CleanUpHiddenFrame();
870 867
871 if (!in_destructor_) 868 if (!in_destructor_)
872 source_tabstrip_->DestroyDragController(); 869 source_tabstrip_->DestroyDragController();
873 } 870 }
874 871
875 void DraggedTabControllerGtk::BringWindowUnderMouseToFront() { 872 void DraggedTabControllerGtk::BringWindowUnderMouseToFront() {
876 // If we're going to dock to another window, bring it to the front. 873 // If we're going to dock to another window, bring it to the front.
877 gfx::NativeWindow window = dock_info_.window(); 874 gfx::NativeWindow window = GetLocalProcessWindow(
878 if (!window) { 875 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint());
879 gfx::NativeView dragged_tab = dragged_view_->widget();
880 dock_windows_.insert(dragged_tab);
881 window = DockInfo::GetLocalProcessWindowAtPoint(
882 chrome::HOST_DESKTOP_TYPE_NATIVE,
883 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(),
884 dock_windows_);
885 dock_windows_.erase(dragged_tab);
886 }
887
888 if (window) 876 if (window)
889 gtk_window_present(GTK_WINDOW(window)); 877 gtk_window_present(GTK_WINDOW(window));
890 } 878 }
891 879
892 bool DraggedTabControllerGtk::AreTabsConsecutive() { 880 bool DraggedTabControllerGtk::AreTabsConsecutive() {
893 for (size_t i = 1; i < drag_data_->size(); ++i) { 881 for (size_t i = 1; i < drag_data_->size(); ++i) {
894 if (drag_data_->get(i - 1)->source_model_index_ + 1 != 882 if (drag_data_->get(i - 1)->source_model_index_ + 1 !=
895 drag_data_->get(i)->source_model_index_) { 883 drag_data_->get(i)->source_model_index_) {
896 return false; 884 return false;
897 } 885 }
898 } 886 }
899 return true; 887 return true;
900 } 888 }
889
890 gfx::NativeWindow DraggedTabControllerGtk::GetLocalProcessWindow(
891 const gfx::Point& screen_point) {
892 std::set<GtkWidget*> dragged_window;
893 dragged_window.insert(dragged_view_->widget());
894 return GetLocalProcessWindowAtPoint(
895 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(),
896 dragged_window);
897
898 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h ('k') | chrome/browser/ui/gtk/tabs/window_finder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698