| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/gfx/path.h" | 7 #include "app/gfx/path.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "views/fill_layout.h" | 9 #include "views/fill_layout.h" |
| 10 #include "views/widget/default_theme_provider.h" | 10 #include "views/widget/default_theme_provider.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), | 70 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), |
| 71 delete_on_destroy_(true), | 71 delete_on_destroy_(true), |
| 72 transparent_(false) { | 72 transparent_(false) { |
| 73 } | 73 } |
| 74 | 74 |
| 75 WidgetGtk::~WidgetGtk() { | 75 WidgetGtk::~WidgetGtk() { |
| 76 MessageLoopForUI::current()->RemoveObserver(this); | 76 MessageLoopForUI::current()->RemoveObserver(this); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void WidgetGtk::Init(GtkWidget* parent, | 79 void WidgetGtk::Init(GtkWidget* parent, |
| 80 const gfx::Rect& bounds, | 80 const gfx::Rect& bounds) { |
| 81 bool has_own_focus_manager) { | |
| 82 // Force creation of the RootView if it hasn't been created yet. | 81 // Force creation of the RootView if it hasn't been created yet. |
| 83 GetRootView(); | 82 GetRootView(); |
| 84 | 83 |
| 85 #if !defined(LINUX2) | 84 #if !defined(LINUX2) |
| 86 default_theme_provider_.reset(new DefaultThemeProvider()); | 85 default_theme_provider_.reset(new DefaultThemeProvider()); |
| 87 #endif | 86 #endif |
| 88 | 87 |
| 89 // Make container here. | 88 // Make container here. |
| 90 CreateGtkWidget(parent, bounds); | 89 CreateGtkWidget(parent, bounds); |
| 91 | 90 |
| 92 // Make sure we receive our motion events. | 91 // Make sure we receive our motion events. |
| 93 | 92 |
| 94 // In general we register most events on the parent of all widgets. At a | 93 // In general we register most events on the parent of all widgets. At a |
| 95 // minimum we need painting to happen on the parent (otherwise painting | 94 // minimum we need painting to happen on the parent (otherwise painting |
| 96 // doesn't work at all), and similarly we need mouse release events on the | 95 // doesn't work at all), and similarly we need mouse release events on the |
| 97 // parent as windows don't get mouse releases. | 96 // parent as windows don't get mouse releases. |
| 98 gtk_widget_add_events(window_contents_, | 97 gtk_widget_add_events(window_contents_, |
| 99 GDK_ENTER_NOTIFY_MASK | | 98 GDK_ENTER_NOTIFY_MASK | |
| 100 GDK_LEAVE_NOTIFY_MASK | | 99 GDK_LEAVE_NOTIFY_MASK | |
| 101 GDK_BUTTON_PRESS_MASK | | 100 GDK_BUTTON_PRESS_MASK | |
| 102 GDK_BUTTON_RELEASE_MASK | | 101 GDK_BUTTON_RELEASE_MASK | |
| 103 GDK_POINTER_MOTION_MASK | | 102 GDK_POINTER_MOTION_MASK | |
| 104 GDK_KEY_PRESS_MASK | | 103 GDK_KEY_PRESS_MASK | |
| 105 GDK_KEY_RELEASE_MASK); | 104 GDK_KEY_RELEASE_MASK); |
| 106 | 105 |
| 107 root_view_->OnWidgetCreated(); | 106 root_view_->OnWidgetCreated(); |
| 108 | 107 |
| 109 // TODO(port): if(has_own_focus_manager) block | |
| 110 | |
| 111 SetRootViewForWidget(widget_, root_view_.get()); | 108 SetRootViewForWidget(widget_, root_view_.get()); |
| 112 | 109 |
| 113 MessageLoopForUI::current()->AddObserver(this); | 110 MessageLoopForUI::current()->AddObserver(this); |
| 114 | 111 |
| 115 // TODO(beng): make these take this rather than NULL. | 112 // TODO(beng): make these take this rather than NULL. |
| 116 g_signal_connect_after(G_OBJECT(window_contents_), "size_allocate", | 113 g_signal_connect_after(G_OBJECT(window_contents_), "size_allocate", |
| 117 G_CALLBACK(CallSizeAllocate), NULL); | 114 G_CALLBACK(CallSizeAllocate), NULL); |
| 118 g_signal_connect(G_OBJECT(window_contents_), "expose_event", | 115 g_signal_connect(G_OBJECT(window_contents_), "expose_event", |
| 119 G_CALLBACK(CallPaint), NULL); | 116 G_CALLBACK(CallPaint), NULL); |
| 120 g_signal_connect(G_OBJECT(window_contents_), "enter_notify_event", | 117 g_signal_connect(G_OBJECT(window_contents_), "enter_notify_event", |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 void WidgetGtk::HandleGrabBroke() { | 819 void WidgetGtk::HandleGrabBroke() { |
| 823 if (has_capture_) { | 820 if (has_capture_) { |
| 824 if (is_mouse_down_) | 821 if (is_mouse_down_) |
| 825 root_view_->ProcessMouseDragCanceled(); | 822 root_view_->ProcessMouseDragCanceled(); |
| 826 is_mouse_down_ = false; | 823 is_mouse_down_ = false; |
| 827 has_capture_ = false; | 824 has_capture_ = false; |
| 828 } | 825 } |
| 829 } | 826 } |
| 830 | 827 |
| 831 } // namespace views | 828 } // namespace views |
| OLD | NEW |