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 <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 #include <X11/Xatom.h> | 10 #include <X11/Xatom.h> |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 bool NativeWidgetGtk::HasMouseCapture() const { | 959 bool NativeWidgetGtk::HasMouseCapture() const { |
960 return GTK_WIDGET_HAS_GRAB(window_contents_) || has_pointer_grab_; | 960 return GTK_WIDGET_HAS_GRAB(window_contents_) || has_pointer_grab_; |
961 } | 961 } |
962 | 962 |
963 InputMethod* NativeWidgetGtk::CreateInputMethod() { | 963 InputMethod* NativeWidgetGtk::CreateInputMethod() { |
964 // Create input method when pure views is enabled. | 964 // Create input method when pure views is enabled. |
965 // TODO(suzhe): Always enable input method when we start to use | 965 // TODO(suzhe): Always enable input method when we start to use |
966 // RenderWidgetHostViewViews in normal ChromeOS. | 966 // RenderWidgetHostViewViews in normal ChromeOS. |
967 if (views::Widget::IsPureViews()) { | 967 if (views::Widget::IsPureViews()) { |
968 #if defined(HAVE_IBUS) | 968 #if defined(HAVE_IBUS) |
969 return InputMethodIBus::IsInputMethodIBusEnabled() ? | 969 InputMethod* input_method = |
| 970 InputMethodIBus::IsInputMethodIBusEnabled() ? |
970 static_cast<InputMethod*>(new InputMethodIBus(this)) : | 971 static_cast<InputMethod*>(new InputMethodIBus(this)) : |
971 static_cast<InputMethod*>(new InputMethodGtk(this)); | 972 static_cast<InputMethod*>(new InputMethodGtk(this)); |
972 #else | 973 #else |
973 return new InputMethodGtk(this); | 974 InputMethod* input_method = new InputMethodGtk(this); |
974 #endif | 975 #endif |
| 976 if (has_focus_) |
| 977 input_method->OnFocus(); |
| 978 return input_method; |
975 } | 979 } |
976 // GTK's textfield handles IME. | 980 // GTK's textfield handles IME. |
977 return NULL; | 981 return NULL; |
978 } | 982 } |
979 | 983 |
980 void NativeWidgetGtk::CenterWindow(const gfx::Size& size) { | 984 void NativeWidgetGtk::CenterWindow(const gfx::Size& size) { |
981 gfx::Rect center_rect; | 985 gfx::Rect center_rect; |
982 | 986 |
983 GtkWindow* parent = gtk_window_get_transient_for(GetNativeWindow()); | 987 GtkWindow* parent = gtk_window_get_transient_for(GetNativeWindow()); |
984 if (parent) { | 988 if (parent) { |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 GetWidget()->SetInitialFocus(); | 1655 GetWidget()->SetInitialFocus(); |
1652 } | 1656 } |
1653 return false; | 1657 return false; |
1654 } | 1658 } |
1655 | 1659 |
1656 gboolean NativeWidgetGtk::OnFocusOut(GtkWidget* widget, GdkEventFocus* event) { | 1660 gboolean NativeWidgetGtk::OnFocusOut(GtkWidget* widget, GdkEventFocus* event) { |
1657 if (!has_focus_) | 1661 if (!has_focus_) |
1658 return false; // This is the second focus-out event in a row, ignore it. | 1662 return false; // This is the second focus-out event in a row, ignore it. |
1659 has_focus_ = false; | 1663 has_focus_ = false; |
1660 | 1664 |
1661 if (GetWidget()->is_top_level()) | 1665 if (!GetWidget()->is_top_level()) |
1662 return false; | 1666 return false; |
1663 | 1667 |
1664 // Only top-level Widget should have an InputMethod instance. | 1668 // Only top-level Widget should have an InputMethod instance. |
1665 InputMethod* input_method = GetWidget()->GetInputMethodDirect(); | 1669 InputMethod* input_method = GetWidget()->GetInputMethodDirect(); |
1666 if (input_method) | 1670 if (input_method) |
1667 input_method->OnBlur(); | 1671 input_method->OnBlur(); |
1668 return false; | 1672 return false; |
1669 } | 1673 } |
1670 | 1674 |
1671 gboolean NativeWidgetGtk::OnEventKey(GtkWidget* widget, GdkEventKey* event) { | 1675 gboolean NativeWidgetGtk::OnEventKey(GtkWidget* widget, GdkEventKey* event) { |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2240 button_pressed = event->type == GDK_BUTTON_PRESS || | 2244 button_pressed = event->type == GDK_BUTTON_PRESS || |
2241 event->type == GDK_2BUTTON_PRESS || | 2245 event->type == GDK_2BUTTON_PRESS || |
2242 event->type == GDK_3BUTTON_PRESS; | 2246 event->type == GDK_3BUTTON_PRESS; |
2243 gdk_event_free(event); | 2247 gdk_event_free(event); |
2244 } | 2248 } |
2245 return button_pressed; | 2249 return button_pressed; |
2246 } | 2250 } |
2247 | 2251 |
2248 } // namespace internal | 2252 } // namespace internal |
2249 } // namespace views | 2253 } // namespace views |
OLD | NEW |