| 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 |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 return false; | 877 return false; |
| 878 | 878 |
| 879 KeyEvent key(event); | 879 KeyEvent key(event); |
| 880 int key_code = key.GetKeyCode(); | 880 int key_code = key.GetKeyCode(); |
| 881 bool handled = false; | 881 bool handled = false; |
| 882 | 882 |
| 883 // Always reset |should_handle_menu_key_release_| unless we are handling a | 883 // Always reset |should_handle_menu_key_release_| unless we are handling a |
| 884 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only | 884 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only |
| 885 // be activated when handling a VKEY_MENU key release event which is preceded | 885 // be activated when handling a VKEY_MENU key release event which is preceded |
| 886 // by an unhandled VKEY_MENU key press event. | 886 // by an unhandled VKEY_MENU key press event. |
| 887 if (key_code != base::VKEY_MENU || event->type != GDK_KEY_RELEASE) | 887 if (key_code != app::VKEY_MENU || event->type != GDK_KEY_RELEASE) |
| 888 should_handle_menu_key_release_ = false; | 888 should_handle_menu_key_release_ = false; |
| 889 | 889 |
| 890 if (event->type == GDK_KEY_PRESS) { | 890 if (event->type == GDK_KEY_PRESS) { |
| 891 // VKEY_MENU is triggered by key release event. | 891 // VKEY_MENU is triggered by key release event. |
| 892 // FocusManager::OnKeyEvent() returns false when the key has been consumed. | 892 // FocusManager::OnKeyEvent() returns false when the key has been consumed. |
| 893 if (key_code != base::VKEY_MENU) | 893 if (key_code != app::VKEY_MENU) |
| 894 handled = !focus_manager_->OnKeyEvent(key); | 894 handled = !focus_manager_->OnKeyEvent(key); |
| 895 else | 895 else |
| 896 should_handle_menu_key_release_ = true; | 896 should_handle_menu_key_release_ = true; |
| 897 } else if (key_code == base::VKEY_MENU && should_handle_menu_key_release_ && | 897 } else if (key_code == app::VKEY_MENU && should_handle_menu_key_release_ && |
| 898 (key.GetFlags() & ~Event::EF_ALT_DOWN) == 0) { | 898 (key.GetFlags() & ~Event::EF_ALT_DOWN) == 0) { |
| 899 // Trigger VKEY_MENU when only this key is pressed and released, and both | 899 // Trigger VKEY_MENU when only this key is pressed and released, and both |
| 900 // press and release events are not handled by others. | 900 // press and release events are not handled by others. |
| 901 Accelerator accelerator(base::VKEY_MENU, false, false, false); | 901 Accelerator accelerator(app::VKEY_MENU, false, false, false); |
| 902 handled = focus_manager_->ProcessAccelerator(accelerator); | 902 handled = focus_manager_->ProcessAccelerator(accelerator); |
| 903 } | 903 } |
| 904 | 904 |
| 905 return handled; | 905 return handled; |
| 906 } | 906 } |
| 907 | 907 |
| 908 //////////////////////////////////////////////////////////////////////////////// | 908 //////////////////////////////////////////////////////////////////////////////// |
| 909 // WidgetGtk, protected: | 909 // WidgetGtk, protected: |
| 910 | 910 |
| 911 // static | 911 // static |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 return false; | 1160 return false; |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 gboolean WidgetGtk::OnKeyEvent(GtkWidget* widget, GdkEventKey* event) { | 1163 gboolean WidgetGtk::OnKeyEvent(GtkWidget* widget, GdkEventKey* event) { |
| 1164 KeyEvent key(event); | 1164 KeyEvent key(event); |
| 1165 | 1165 |
| 1166 // Always reset |should_handle_menu_key_release_| unless we are handling a | 1166 // Always reset |should_handle_menu_key_release_| unless we are handling a |
| 1167 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only | 1167 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only |
| 1168 // be activated when handling a VKEY_MENU key release event which is preceded | 1168 // be activated when handling a VKEY_MENU key release event which is preceded |
| 1169 // by an unhandled VKEY_MENU key press event. See also HandleKeyboardEvent(). | 1169 // by an unhandled VKEY_MENU key press event. See also HandleKeyboardEvent(). |
| 1170 if (key.GetKeyCode() != base::VKEY_MENU || event->type != GDK_KEY_RELEASE) | 1170 if (key.GetKeyCode() != app::VKEY_MENU || event->type != GDK_KEY_RELEASE) |
| 1171 should_handle_menu_key_release_ = false; | 1171 should_handle_menu_key_release_ = false; |
| 1172 | 1172 |
| 1173 bool handled = false; | 1173 bool handled = false; |
| 1174 | 1174 |
| 1175 // Dispatch the key event to View hierarchy first. | 1175 // Dispatch the key event to View hierarchy first. |
| 1176 handled = root_view_->ProcessKeyEvent(key); | 1176 handled = root_view_->ProcessKeyEvent(key); |
| 1177 | 1177 |
| 1178 // Dispatch the key event to native GtkWidget hierarchy. | 1178 // Dispatch the key event to native GtkWidget hierarchy. |
| 1179 // To prevent GtkWindow from handling the key event as a keybinding, we need | 1179 // To prevent GtkWindow from handling the key event as a keybinding, we need |
| 1180 // to bypass GtkWindow's default key event handler and dispatch the event | 1180 // to bypass GtkWindow's default key event handler and dispatch the event |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 GtkWindow* window = GTK_WINDOW(element->data); | 1634 GtkWindow* window = GTK_WINDOW(element->data); |
| 1635 DCHECK(window); | 1635 DCHECK(window); |
| 1636 RootView *root_view = FindRootView(window); | 1636 RootView *root_view = FindRootView(window); |
| 1637 if (root_view) | 1637 if (root_view) |
| 1638 root_view->NotifyLocaleChanged(); | 1638 root_view->NotifyLocaleChanged(); |
| 1639 } | 1639 } |
| 1640 g_list_free(window_list); | 1640 g_list_free(window_list); |
| 1641 } | 1641 } |
| 1642 | 1642 |
| 1643 } // namespace views | 1643 } // namespace views |
| OLD | NEW |