OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/native_widget_gtk.h" | 5 #include "views/widget/native_widget_gtk.h" |
6 | 6 |
7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 #include <X11/extensions/shape.h> | 9 #include <X11/extensions/shape.h> |
10 #include <gdk/gdk.h> | 10 #include <gdk/gdk.h> |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "ui/gfx/path.h" | 33 #include "ui/gfx/path.h" |
34 #include "ui/gfx/screen.h" | 34 #include "ui/gfx/screen.h" |
35 #include "ui/views/bubble/bubble_delegate.h" | 35 #include "ui/views/bubble/bubble_delegate.h" |
36 #include "ui/views/focus/view_storage.h" | 36 #include "ui/views/focus/view_storage.h" |
37 #include "ui/views/ime/input_method_gtk.h" | 37 #include "ui/views/ime/input_method_gtk.h" |
38 #include "views/controls/textfield/native_textfield_views.h" | 38 #include "views/controls/textfield/native_textfield_views.h" |
39 #include "views/views_delegate.h" | 39 #include "views/views_delegate.h" |
40 #include "views/widget/drop_target_gtk.h" | 40 #include "views/widget/drop_target_gtk.h" |
41 #include "views/widget/gtk_views_fixed.h" | 41 #include "views/widget/gtk_views_fixed.h" |
42 #include "views/widget/gtk_views_window.h" | 42 #include "views/widget/gtk_views_window.h" |
43 #include "views/widget/native_widget_views.h" | |
44 #include "views/widget/root_view.h" | 43 #include "views/widget/root_view.h" |
45 #include "views/widget/widget_delegate.h" | 44 #include "views/widget/widget_delegate.h" |
46 | 45 |
47 #if defined(TOUCH_UI) | 46 #if defined(TOUCH_UI) |
48 #include "ui/base/touch/touch_factory.h" | 47 #include "ui/base/touch/touch_factory.h" |
49 #include "views/widget/tooltip_manager_views.h" | 48 #include "views/widget/tooltip_manager_views.h" |
50 #else | 49 #else |
51 #include "views/widget/tooltip_manager_gtk.h" | 50 #include "views/widget/tooltip_manager_gtk.h" |
52 #endif | 51 #endif |
53 | 52 |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 } | 984 } |
986 | 985 |
987 bool NativeWidgetGtk::HasMouseCapture() const { | 986 bool NativeWidgetGtk::HasMouseCapture() const { |
988 return GTK_WIDGET_HAS_GRAB(window_contents_) || has_pointer_grab_; | 987 return GTK_WIDGET_HAS_GRAB(window_contents_) || has_pointer_grab_; |
989 } | 988 } |
990 | 989 |
991 InputMethod* NativeWidgetGtk::CreateInputMethod() { | 990 InputMethod* NativeWidgetGtk::CreateInputMethod() { |
992 // Create input method when pure views is enabled but not on views desktop. | 991 // Create input method when pure views is enabled but not on views desktop. |
993 // TODO(suzhe): Always enable input method when we start to use | 992 // TODO(suzhe): Always enable input method when we start to use |
994 // RenderWidgetHostViewViews in normal ChromeOS. | 993 // RenderWidgetHostViewViews in normal ChromeOS. |
995 if (views::Widget::IsPureViews() && | 994 if (views::Widget::IsPureViews()) { |
996 !ViewsDelegate::views_delegate->GetDefaultParentView()) { | |
997 #if defined(HAVE_IBUS) | 995 #if defined(HAVE_IBUS) |
998 InputMethod* input_method = | 996 InputMethod* input_method = |
999 InputMethodIBus::IsInputMethodIBusEnabled() ? | 997 InputMethodIBus::IsInputMethodIBusEnabled() ? |
1000 static_cast<InputMethod*>(new InputMethodIBus(this)) : | 998 static_cast<InputMethod*>(new InputMethodIBus(this)) : |
1001 static_cast<InputMethod*>(new InputMethodGtk(this)); | 999 static_cast<InputMethod*>(new InputMethodGtk(this)); |
1002 #else | 1000 #else |
1003 InputMethod* input_method = new InputMethodGtk(this); | 1001 InputMethod* input_method = new InputMethodGtk(this); |
1004 #endif | 1002 #endif |
1005 input_method->Init(GetWidget()); | 1003 input_method->Init(GetWidget()); |
1006 return input_method; | 1004 return input_method; |
1007 } | 1005 } |
1008 // GTK's textfield or InputMethod in NativeWidgetViews will handle IME. | 1006 // GTK's textfield will handle IME. |
1009 return NULL; | 1007 return NULL; |
1010 } | 1008 } |
1011 | 1009 |
1012 void NativeWidgetGtk::CenterWindow(const gfx::Size& size) { | 1010 void NativeWidgetGtk::CenterWindow(const gfx::Size& size) { |
1013 gfx::Rect center_rect; | 1011 gfx::Rect center_rect; |
1014 | 1012 |
1015 GtkWindow* parent = gtk_window_get_transient_for(GetNativeWindow()); | 1013 GtkWindow* parent = gtk_window_get_transient_for(GetNativeWindow()); |
1016 if (parent) { | 1014 if (parent) { |
1017 // We have a parent window, center over it. | 1015 // We have a parent window, center over it. |
1018 gint parent_x = 0; | 1016 gint parent_x = 0; |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 gtk_widget_grab_focus(native_view); | 1347 gtk_widget_grab_focus(native_view); |
1350 } | 1348 } |
1351 | 1349 |
1352 bool NativeWidgetGtk::ConvertPointFromAncestor( | 1350 bool NativeWidgetGtk::ConvertPointFromAncestor( |
1353 const Widget* ancestor, gfx::Point* point) const { | 1351 const Widget* ancestor, gfx::Point* point) const { |
1354 NOTREACHED(); | 1352 NOTREACHED(); |
1355 return false; | 1353 return false; |
1356 } | 1354 } |
1357 | 1355 |
1358 gfx::Rect NativeWidgetGtk::GetWorkAreaBoundsInScreen() const { | 1356 gfx::Rect NativeWidgetGtk::GetWorkAreaBoundsInScreen() const { |
1359 ViewsDelegate *delegate = ViewsDelegate::views_delegate; | 1357 return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView()); |
1360 if (delegate && delegate->GetDefaultParentView()) { | |
1361 // For views-desktop, the work area is the entire space inside this | |
1362 // containter window. | |
1363 return gfx::Rect(gfx::Point(0, 0), | |
1364 delegate->GetDefaultParentView()->size()); | |
1365 } else | |
1366 return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView()); | |
1367 } | 1358 } |
1368 | 1359 |
1369 void NativeWidgetGtk::SetInactiveRenderingDisabled(bool value) { | 1360 void NativeWidgetGtk::SetInactiveRenderingDisabled(bool value) { |
1370 } | 1361 } |
1371 | 1362 |
1372 //////////////////////////////////////////////////////////////////////////////// | 1363 //////////////////////////////////////////////////////////////////////////////// |
1373 // NativeWidgetGtk, protected: | 1364 // NativeWidgetGtk, protected: |
1374 | 1365 |
1375 void NativeWidgetGtk::OnSizeRequest(GtkWidget* widget, | 1366 void NativeWidgetGtk::OnSizeRequest(GtkWidget* widget, |
1376 GtkRequisition* requisition) { | 1367 GtkRequisition* requisition) { |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2208 } | 2199 } |
2209 | 2200 |
2210 namespace internal { | 2201 namespace internal { |
2211 | 2202 |
2212 //////////////////////////////////////////////////////////////////////////////// | 2203 //////////////////////////////////////////////////////////////////////////////// |
2213 // NativeWidgetPrivate, public: | 2204 // NativeWidgetPrivate, public: |
2214 | 2205 |
2215 // static | 2206 // static |
2216 NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( | 2207 NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget( |
2217 NativeWidgetDelegate* delegate) { | 2208 NativeWidgetDelegate* delegate) { |
2218 if (Widget::IsPureViews() && ViewsDelegate::views_delegate && | |
2219 ViewsDelegate::views_delegate->GetDefaultParentView()) { | |
2220 return new NativeWidgetViews(delegate); | |
2221 } | |
2222 return new NativeWidgetGtk(delegate); | 2209 return new NativeWidgetGtk(delegate); |
2223 } | 2210 } |
2224 | 2211 |
2225 // static | 2212 // static |
2226 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView( | 2213 NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView( |
2227 gfx::NativeView native_view) { | 2214 gfx::NativeView native_view) { |
2228 if (!native_view) | 2215 if (!native_view) |
2229 return NULL; | 2216 return NULL; |
2230 return reinterpret_cast<NativeWidgetGtk*>( | 2217 return reinterpret_cast<NativeWidgetGtk*>( |
2231 g_object_get_data(G_OBJECT(native_view), kNativeWidgetKey)); | 2218 g_object_get_data(G_OBJECT(native_view), kNativeWidgetKey)); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2316 button_pressed = event->type == GDK_BUTTON_PRESS || | 2303 button_pressed = event->type == GDK_BUTTON_PRESS || |
2317 event->type == GDK_2BUTTON_PRESS || | 2304 event->type == GDK_2BUTTON_PRESS || |
2318 event->type == GDK_3BUTTON_PRESS; | 2305 event->type == GDK_3BUTTON_PRESS; |
2319 gdk_event_free(event); | 2306 gdk_event_free(event); |
2320 } | 2307 } |
2321 return button_pressed; | 2308 return button_pressed; |
2322 } | 2309 } |
2323 | 2310 |
2324 } // namespace internal | 2311 } // namespace internal |
2325 } // namespace views | 2312 } // namespace views |
OLD | NEW |