| 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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 return false; | 882 return false; |
| 883 | 883 |
| 884 KeyEvent key(event); | 884 KeyEvent key(event); |
| 885 int key_code = key.GetKeyCode(); | 885 int key_code = key.GetKeyCode(); |
| 886 bool handled = false; | 886 bool handled = false; |
| 887 | 887 |
| 888 // Always reset |should_handle_menu_key_release_| unless we are handling a | 888 // Always reset |should_handle_menu_key_release_| unless we are handling a |
| 889 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only | 889 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only |
| 890 // be activated when handling a VKEY_MENU key release event which is preceded | 890 // be activated when handling a VKEY_MENU key release event which is preceded |
| 891 // by an unhandled VKEY_MENU key press event. | 891 // by an unhandled VKEY_MENU key press event. |
| 892 if (key_code != app::VKEY_MENU || event->type != GDK_KEY_RELEASE) | 892 if (key_code != ui::VKEY_MENU || event->type != GDK_KEY_RELEASE) |
| 893 should_handle_menu_key_release_ = false; | 893 should_handle_menu_key_release_ = false; |
| 894 | 894 |
| 895 if (event->type == GDK_KEY_PRESS) { | 895 if (event->type == GDK_KEY_PRESS) { |
| 896 // VKEY_MENU is triggered by key release event. | 896 // VKEY_MENU is triggered by key release event. |
| 897 // FocusManager::OnKeyEvent() returns false when the key has been consumed. | 897 // FocusManager::OnKeyEvent() returns false when the key has been consumed. |
| 898 if (key_code != app::VKEY_MENU) | 898 if (key_code != ui::VKEY_MENU) |
| 899 handled = !focus_manager_->OnKeyEvent(key); | 899 handled = !focus_manager_->OnKeyEvent(key); |
| 900 else | 900 else |
| 901 should_handle_menu_key_release_ = true; | 901 should_handle_menu_key_release_ = true; |
| 902 } else if (key_code == app::VKEY_MENU && should_handle_menu_key_release_ && | 902 } else if (key_code == ui::VKEY_MENU && should_handle_menu_key_release_ && |
| 903 (key.GetFlags() & ~Event::EF_ALT_DOWN) == 0) { | 903 (key.GetFlags() & ~Event::EF_ALT_DOWN) == 0) { |
| 904 // Trigger VKEY_MENU when only this key is pressed and released, and both | 904 // Trigger VKEY_MENU when only this key is pressed and released, and both |
| 905 // press and release events are not handled by others. | 905 // press and release events are not handled by others. |
| 906 Accelerator accelerator(app::VKEY_MENU, false, false, false); | 906 Accelerator accelerator(ui::VKEY_MENU, false, false, false); |
| 907 handled = focus_manager_->ProcessAccelerator(accelerator); | 907 handled = focus_manager_->ProcessAccelerator(accelerator); |
| 908 } | 908 } |
| 909 | 909 |
| 910 return handled; | 910 return handled; |
| 911 } | 911 } |
| 912 | 912 |
| 913 // static | 913 // static |
| 914 int WidgetGtk::GetFlagsForEventButton(const GdkEventButton& event) { | 914 int WidgetGtk::GetFlagsForEventButton(const GdkEventButton& event) { |
| 915 int flags = Event::GetFlagsFromGdkState(event.state); | 915 int flags = Event::GetFlagsFromGdkState(event.state); |
| 916 switch (event.button) { | 916 switch (event.button) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 return false; | 1166 return false; |
| 1167 } | 1167 } |
| 1168 | 1168 |
| 1169 gboolean WidgetGtk::OnKeyEvent(GtkWidget* widget, GdkEventKey* event) { | 1169 gboolean WidgetGtk::OnKeyEvent(GtkWidget* widget, GdkEventKey* event) { |
| 1170 KeyEvent key(event); | 1170 KeyEvent key(event); |
| 1171 | 1171 |
| 1172 // Always reset |should_handle_menu_key_release_| unless we are handling a | 1172 // Always reset |should_handle_menu_key_release_| unless we are handling a |
| 1173 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only | 1173 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only |
| 1174 // be activated when handling a VKEY_MENU key release event which is preceded | 1174 // be activated when handling a VKEY_MENU key release event which is preceded |
| 1175 // by an unhandled VKEY_MENU key press event. See also HandleKeyboardEvent(). | 1175 // by an unhandled VKEY_MENU key press event. See also HandleKeyboardEvent(). |
| 1176 if (key.GetKeyCode() != app::VKEY_MENU || event->type != GDK_KEY_RELEASE) | 1176 if (key.GetKeyCode() != ui::VKEY_MENU || event->type != GDK_KEY_RELEASE) |
| 1177 should_handle_menu_key_release_ = false; | 1177 should_handle_menu_key_release_ = false; |
| 1178 | 1178 |
| 1179 bool handled = false; | 1179 bool handled = false; |
| 1180 | 1180 |
| 1181 // Dispatch the key event to View hierarchy first. | 1181 // Dispatch the key event to View hierarchy first. |
| 1182 handled = root_view_->ProcessKeyEvent(key); | 1182 handled = root_view_->ProcessKeyEvent(key); |
| 1183 | 1183 |
| 1184 // Dispatch the key event to native GtkWidget hierarchy. | 1184 // Dispatch the key event to native GtkWidget hierarchy. |
| 1185 // To prevent GtkWindow from handling the key event as a keybinding, we need | 1185 // To prevent GtkWindow from handling the key event as a keybinding, we need |
| 1186 // to bypass GtkWindow's default key event handler and dispatch the event | 1186 // to bypass GtkWindow's default key event handler and dispatch the event |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 GtkWindow* window = GTK_WINDOW(element->data); | 1658 GtkWindow* window = GTK_WINDOW(element->data); |
| 1659 DCHECK(window); | 1659 DCHECK(window); |
| 1660 RootView *root_view = FindRootView(window); | 1660 RootView *root_view = FindRootView(window); |
| 1661 if (root_view) | 1661 if (root_view) |
| 1662 root_view->NotifyLocaleChanged(); | 1662 root_view->NotifyLocaleChanged(); |
| 1663 } | 1663 } |
| 1664 g_list_free(window_list); | 1664 g_list_free(window_list); |
| 1665 } | 1665 } |
| 1666 | 1666 |
| 1667 } // namespace views | 1667 } // namespace views |
| OLD | NEW |