| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/widget/widget_gtk.h" | 5 #include "views/widget/widget_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
| 9 #include <X11/extensions/shape.h> | 9 #include <X11/extensions/shape.h> |
| 10 | 10 |
| 11 #include <set> | 11 #include <set> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/auto_reset.h" | 14 #include "base/auto_reset.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "ui/base/dragdrop/drag_drop_types.h" | 18 #include "ui/base/dragdrop/drag_drop_types.h" |
| 19 #include "ui/base/dragdrop/os_exchange_data.h" | 19 #include "ui/base/dragdrop/os_exchange_data.h" |
| 20 #include "ui/base/dragdrop/os_exchange_data_provider_gtk.h" | 20 #include "ui/base/dragdrop/os_exchange_data_provider_gtk.h" |
| 21 #include "ui/gfx/path.h" | 21 #include "ui/gfx/path.h" |
| 22 #include "views/focus/view_storage.h" |
| 22 #include "views/widget/default_theme_provider.h" | 23 #include "views/widget/default_theme_provider.h" |
| 23 #include "views/widget/drop_target_gtk.h" | 24 #include "views/widget/drop_target_gtk.h" |
| 24 #include "views/widget/gtk_views_fixed.h" | 25 #include "views/widget/gtk_views_fixed.h" |
| 25 #include "views/widget/gtk_views_window.h" | 26 #include "views/widget/gtk_views_window.h" |
| 26 #include "views/widget/root_view.h" | 27 #include "views/widget/root_view.h" |
| 27 #include "views/widget/tooltip_manager_gtk.h" | 28 #include "views/widget/tooltip_manager_gtk.h" |
| 28 #include "views/widget/widget_delegate.h" | 29 #include "views/widget/widget_delegate.h" |
| 29 #include "views/widget/widget_utils.h" | 30 #include "views/widget/widget_utils.h" |
| 30 #include "views/window/window_gtk.h" | 31 #include "views/window/window_gtk.h" |
| 31 | 32 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 opacity_(255), | 245 opacity_(255), |
| 245 drag_data_(NULL), | 246 drag_data_(NULL), |
| 246 in_paint_now_(false), | 247 in_paint_now_(false), |
| 247 is_active_(false), | 248 is_active_(false), |
| 248 transient_to_parent_(false), | 249 transient_to_parent_(false), |
| 249 got_initial_focus_in_(false), | 250 got_initial_focus_in_(false), |
| 250 has_focus_(false), | 251 has_focus_(false), |
| 251 delegate_(NULL), | 252 delegate_(NULL), |
| 252 always_on_top_(false), | 253 always_on_top_(false), |
| 253 is_double_buffered_(false), | 254 is_double_buffered_(false), |
| 254 should_handle_menu_key_release_(false) { | 255 should_handle_menu_key_release_(false), |
| 256 dragged_view_(NULL) { |
| 255 static bool installed_message_loop_observer = false; | 257 static bool installed_message_loop_observer = false; |
| 256 if (!installed_message_loop_observer) { | 258 if (!installed_message_loop_observer) { |
| 257 installed_message_loop_observer = true; | 259 installed_message_loop_observer = true; |
| 258 MessageLoopForUI* loop = MessageLoopForUI::current(); | 260 MessageLoopForUI* loop = MessageLoopForUI::current(); |
| 259 if (loop) | 261 if (loop) |
| 260 loop->AddObserver(DropObserver::GetInstance()); | 262 loop->AddObserver(DropObserver::GetInstance()); |
| 261 } | 263 } |
| 262 | 264 |
| 263 if (type_ != TYPE_CHILD) | 265 if (type_ != TYPE_CHILD) |
| 264 focus_manager_ = new FocusManager(this); | 266 focus_manager_ = new FocusManager(this); |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 // dealing with cases where the widget has been unparented. | 835 // dealing with cases where the widget has been unparented. |
| 834 return root->GetFocusManager(); | 836 return root->GetFocusManager(); |
| 835 } | 837 } |
| 836 return NULL; | 838 return NULL; |
| 837 } | 839 } |
| 838 | 840 |
| 839 void WidgetGtk::ViewHierarchyChanged(bool is_add, View *parent, | 841 void WidgetGtk::ViewHierarchyChanged(bool is_add, View *parent, |
| 840 View *child) { | 842 View *child) { |
| 841 if (drop_target_.get()) | 843 if (drop_target_.get()) |
| 842 drop_target_->ResetTargetViewIfEquals(child); | 844 drop_target_->ResetTargetViewIfEquals(child); |
| 845 |
| 846 if (!is_add) { |
| 847 if (child == dragged_view_) |
| 848 dragged_view_ = NULL; |
| 849 |
| 850 FocusManager* focus_manager = GetFocusManager(); |
| 851 if (focus_manager) { |
| 852 // Mysteriously, this is needed only for WidgetGtk. |
| 853 focus_manager->SetFocusedView(NULL); |
| 854 focus_manager->ViewRemoved(parent, child); |
| 855 } |
| 856 ViewStorage::GetInstance()->ViewRemoved(parent, child); |
| 857 } |
| 843 } | 858 } |
| 844 | 859 |
| 845 bool WidgetGtk::ContainsNativeView(gfx::NativeView native_view) { | 860 bool WidgetGtk::ContainsNativeView(gfx::NativeView native_view) { |
| 846 // TODO(port) See implementation in WidgetWin::ContainsNativeView. | 861 // TODO(port) See implementation in WidgetWin::ContainsNativeView. |
| 847 NOTREACHED() << "WidgetGtk::ContainsNativeView is not implemented."; | 862 NOTREACHED() << "WidgetGtk::ContainsNativeView is not implemented."; |
| 848 return false; | 863 return false; |
| 849 } | 864 } |
| 850 | 865 |
| 866 void WidgetGtk::StartDragForViewFromMouseEvent( |
| 867 View* view, |
| 868 const OSExchangeData& data, |
| 869 int operation) { |
| 870 // NOTE: view may be null. |
| 871 dragged_view_ = view; |
| 872 DoDrag(data, operation); |
| 873 // If the view is removed during the drag operation, dragged_view_ is set to |
| 874 // NULL. |
| 875 if (view && dragged_view_ == view) { |
| 876 dragged_view_ = NULL; |
| 877 view->OnDragDone(); |
| 878 } |
| 879 } |
| 880 |
| 881 View* WidgetGtk::GetDraggedView() { |
| 882 return dragged_view_; |
| 883 } |
| 884 |
| 851 //////////////////////////////////////////////////////////////////////////////// | 885 //////////////////////////////////////////////////////////////////////////////// |
| 852 // WidgetGtk, FocusTraversable implementation: | 886 // WidgetGtk, FocusTraversable implementation: |
| 853 | 887 |
| 854 FocusSearch* WidgetGtk::GetFocusSearch() { | 888 FocusSearch* WidgetGtk::GetFocusSearch() { |
| 855 return root_view_->GetFocusSearch(); | 889 return root_view_->GetFocusSearch(); |
| 856 } | 890 } |
| 857 | 891 |
| 858 FocusTraversable* WidgetGtk::GetFocusTraversableParent() { | 892 FocusTraversable* WidgetGtk::GetFocusTraversableParent() { |
| 859 // We are a proxy to the root view, so we should be bypassed when traversing | 893 // We are a proxy to the root view, so we should be bypassed when traversing |
| 860 // up and as a result this should not be called. | 894 // up and as a result this should not be called. |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 GtkWindow* window = GTK_WINDOW(element->data); | 1693 GtkWindow* window = GTK_WINDOW(element->data); |
| 1660 DCHECK(window); | 1694 DCHECK(window); |
| 1661 RootView *root_view = FindRootView(window); | 1695 RootView *root_view = FindRootView(window); |
| 1662 if (root_view) | 1696 if (root_view) |
| 1663 root_view->NotifyLocaleChanged(); | 1697 root_view->NotifyLocaleChanged(); |
| 1664 } | 1698 } |
| 1665 g_list_free(window_list); | 1699 g_list_free(window_list); |
| 1666 } | 1700 } |
| 1667 | 1701 |
| 1668 } // namespace views | 1702 } // namespace views |
| OLD | NEW |