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

Side by Side Diff: views/widget/native_widget_gtk.cc

Issue 7744029: Possible fix for the issue that keyboard doesn't show up. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git-try Created 9 years, 3 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
« no previous file with comments | « no previous file | views/widget/native_widget_views.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 if (views::Widget::IsPureViews()) { 967 if (views::Widget::IsPureViews()) {
968 #if defined(HAVE_IBUS) 968 #if defined(HAVE_IBUS)
969 InputMethod* input_method = 969 InputMethod* input_method =
970 InputMethodIBus::IsInputMethodIBusEnabled() ? 970 InputMethodIBus::IsInputMethodIBusEnabled() ?
971 static_cast<InputMethod*>(new InputMethodIBus(this)) : 971 static_cast<InputMethod*>(new InputMethodIBus(this)) :
972 static_cast<InputMethod*>(new InputMethodGtk(this)); 972 static_cast<InputMethod*>(new InputMethodGtk(this));
973 #else 973 #else
974 InputMethod* input_method = new InputMethodGtk(this); 974 InputMethod* input_method = new InputMethodGtk(this);
975 #endif 975 #endif
976 input_method->Init(GetWidget()); 976 input_method->Init(GetWidget());
977 if (has_focus_)
978 input_method->OnFocus();
979 return input_method; 977 return input_method;
980 } 978 }
981 // GTK's textfield handles IME. 979 // GTK's textfield handles IME.
982 return NULL; 980 return NULL;
983 } 981 }
984 982
985 void NativeWidgetGtk::CenterWindow(const gfx::Size& size) { 983 void NativeWidgetGtk::CenterWindow(const gfx::Size& size) {
986 gfx::Rect center_rect; 984 gfx::Rect center_rect;
987 985
988 GtkWindow* parent = gtk_window_get_transient_for(GetNativeWindow()); 986 GtkWindow* parent = gtk_window_get_transient_for(GetNativeWindow());
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 if (has_focus_) 1634 if (has_focus_)
1637 return false; // This is the second focus-in event in a row, ignore it. 1635 return false; // This is the second focus-in event in a row, ignore it.
1638 has_focus_ = true; 1636 has_focus_ = true;
1639 1637
1640 should_handle_menu_key_release_ = false; 1638 should_handle_menu_key_release_ = false;
1641 1639
1642 if (!GetWidget()->is_top_level()) 1640 if (!GetWidget()->is_top_level())
1643 return false; 1641 return false;
1644 1642
1645 // Only top-level Widget should have an InputMethod instance. 1643 // Only top-level Widget should have an InputMethod instance.
1646 InputMethod* input_method = GetWidget()->GetInputMethodDirect(); 1644 InputMethod* input_method = GetWidget()->GetInputMethod();
1647 if (input_method) 1645 if (input_method)
1648 input_method->OnFocus(); 1646 input_method->OnFocus();
1649 1647
1650 // See description of got_initial_focus_in_ for details on this. 1648 // See description of got_initial_focus_in_ for details on this.
1651 if (!got_initial_focus_in_) { 1649 if (!got_initial_focus_in_) {
1652 got_initial_focus_in_ = true; 1650 got_initial_focus_in_ = true;
1653 // Sets initial focus here. On X11/Gtk, window creation 1651 // Sets initial focus here. On X11/Gtk, window creation
1654 // is asynchronous and a focus request has to be made after a window 1652 // is asynchronous and a focus request has to be made after a window
1655 // gets created. 1653 // gets created.
1656 GetWidget()->SetInitialFocus(); 1654 GetWidget()->SetInitialFocus();
1657 } 1655 }
1658 return false; 1656 return false;
1659 } 1657 }
1660 1658
1661 gboolean NativeWidgetGtk::OnFocusOut(GtkWidget* widget, GdkEventFocus* event) { 1659 gboolean NativeWidgetGtk::OnFocusOut(GtkWidget* widget, GdkEventFocus* event) {
1662 if (!has_focus_) 1660 if (!has_focus_)
1663 return false; // This is the second focus-out event in a row, ignore it. 1661 return false; // This is the second focus-out event in a row, ignore it.
1664 has_focus_ = false; 1662 has_focus_ = false;
1665 1663
1666 if (!GetWidget()->is_top_level()) 1664 if (!GetWidget()->is_top_level())
1667 return false; 1665 return false;
1668 1666
1669 // Only top-level Widget should have an InputMethod instance. 1667 // Only top-level Widget should have an InputMethod instance.
1670 InputMethod* input_method = GetWidget()->GetInputMethodDirect(); 1668 InputMethod* input_method = GetWidget()->GetInputMethod();
1671 if (input_method) 1669 if (input_method)
1672 input_method->OnBlur(); 1670 input_method->OnBlur();
1673 return false; 1671 return false;
1674 } 1672 }
1675 1673
1676 gboolean NativeWidgetGtk::OnEventKey(GtkWidget* widget, GdkEventKey* event) { 1674 gboolean NativeWidgetGtk::OnEventKey(GtkWidget* widget, GdkEventKey* event) {
1677 KeyEvent key(reinterpret_cast<NativeEvent>(event)); 1675 KeyEvent key(reinterpret_cast<NativeEvent>(event));
1678 InputMethod* input_method = GetWidget()->GetInputMethodDirect(); 1676 InputMethod* input_method = GetWidget()->GetInputMethod();
1679 if (input_method) 1677 if (input_method)
1680 input_method->DispatchKeyEvent(key); 1678 input_method->DispatchKeyEvent(key);
1681 else 1679 else
1682 DispatchKeyEventPostIME(key); 1680 DispatchKeyEventPostIME(key);
1683 1681
1684 // Returns true to prevent GtkWindow's default key event handler. 1682 // Returns true to prevent GtkWindow's default key event handler.
1685 return true; 1683 return true;
1686 } 1684 }
1687 1685
1688 gboolean NativeWidgetGtk::OnQueryTooltip(GtkWidget* widget, 1686 gboolean NativeWidgetGtk::OnQueryTooltip(GtkWidget* widget,
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 button_pressed = event->type == GDK_BUTTON_PRESS || 2243 button_pressed = event->type == GDK_BUTTON_PRESS ||
2246 event->type == GDK_2BUTTON_PRESS || 2244 event->type == GDK_2BUTTON_PRESS ||
2247 event->type == GDK_3BUTTON_PRESS; 2245 event->type == GDK_3BUTTON_PRESS;
2248 gdk_event_free(event); 2246 gdk_event_free(event);
2249 } 2247 }
2250 return button_pressed; 2248 return button_pressed;
2251 } 2249 }
2252 2250
2253 } // namespace internal 2251 } // namespace internal
2254 } // namespace views 2252 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | views/widget/native_widget_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698