| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/libgtk2ui/gtk2_key_bindings_handler.h" | 5 #include "chrome/browser/ui/libgtk2ui/gtk2_key_bindings_handler.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 #include <X11/XKBlib.h> | 9 #include <X11/XKBlib.h> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); | 54 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); |
| 55 if (key_event.is_char() || !key_event.native_event()) | 55 if (key_event.is_char() || !key_event.native_event()) |
| 56 return false; | 56 return false; |
| 57 | 57 |
| 58 GdkEventKey gdk_event; | 58 GdkEventKey gdk_event; |
| 59 BuildGdkEventKeyFromXEvent(key_event.native_event(), &gdk_event); | 59 BuildGdkEventKeyFromXEvent(key_event.native_event(), &gdk_event); |
| 60 | 60 |
| 61 edit_commands_.clear(); | 61 edit_commands_.clear(); |
| 62 // If this key event matches a predefined key binding, corresponding signal | 62 // If this key event matches a predefined key binding, corresponding signal |
| 63 // will be emitted. | 63 // will be emitted. |
| 64 gtk_bindings_activate_event(GTK_OBJECT(handler_.get()), &gdk_event); | 64 |
| 65 gtk_bindings_activate_event( |
| 66 #if GDK_MAJOR_VERSION >= 3 |
| 67 G_OBJECT(handler_.get()), |
| 68 #else |
| 69 GTK_OBJECT(handler_.get()), |
| 70 #endif |
| 71 &gdk_event); |
| 65 | 72 |
| 66 bool matched = !edit_commands_.empty(); | 73 bool matched = !edit_commands_.empty(); |
| 67 if (edit_commands) | 74 if (edit_commands) |
| 68 edit_commands->swap(edit_commands_); | 75 edit_commands->swap(edit_commands_); |
| 69 return matched; | 76 return matched; |
| 70 } | 77 } |
| 71 | 78 |
| 72 GtkWidget* Gtk2KeyBindingsHandler::CreateNewHandler() { | 79 GtkWidget* Gtk2KeyBindingsHandler::CreateNewHandler() { |
| 73 Handler* handler = | 80 Handler* handler = |
| 74 static_cast<Handler*>(g_object_new(HandlerGetType(), NULL)); | 81 static_cast<Handler*>(g_object_new(HandlerGetType(), NULL)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // whether a modifier key affects the keybinding, but that should be | 123 // whether a modifier key affects the keybinding, but that should be |
| 117 // extremely rare. | 124 // extremely rare. |
| 118 static bool logged = false; | 125 static bool logged = false; |
| 119 if (!logged) { | 126 if (!logged) { |
| 120 NOTIMPLEMENTED(); | 127 NOTIMPLEMENTED(); |
| 121 logged = true; | 128 logged = true; |
| 122 } | 129 } |
| 123 gdk_event->group = 0; | 130 gdk_event->group = 0; |
| 124 } | 131 } |
| 125 | 132 |
| 126 gdk_event->keyval = GDK_VoidSymbol; | 133 gdk_event->keyval = GDK_KEY_VoidSymbol; |
| 127 gdk_keymap_translate_keyboard_state( | 134 gdk_keymap_translate_keyboard_state( |
| 128 keymap, | 135 keymap, |
| 129 gdk_event->hardware_keycode, | 136 gdk_event->hardware_keycode, |
| 130 static_cast<GdkModifierType>(gdk_event->state), | 137 static_cast<GdkModifierType>(gdk_event->state), |
| 131 gdk_event->group, | 138 gdk_event->group, |
| 132 &gdk_event->keyval, | 139 &gdk_event->keyval, |
| 133 NULL, NULL, &consumed); | 140 NULL, NULL, &consumed); |
| 134 | 141 |
| 135 state = static_cast<GdkModifierType>(gdk_event->state & ~consumed); | 142 state = static_cast<GdkModifierType>(gdk_event->state & ~consumed); |
| 136 gdk_keymap_add_virtual_modifiers(keymap, &state); | 143 gdk_keymap_add_virtual_modifiers(keymap, &state); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 // Just for disabling the default handler. | 394 // Just for disabling the default handler. |
| 388 return FALSE; | 395 return FALSE; |
| 389 } | 396 } |
| 390 | 397 |
| 391 void Gtk2KeyBindingsHandler::MoveFocus(GtkWidget* widget, | 398 void Gtk2KeyBindingsHandler::MoveFocus(GtkWidget* widget, |
| 392 GtkDirectionType arg1) { | 399 GtkDirectionType arg1) { |
| 393 // Just for disabling the default handler. | 400 // Just for disabling the default handler. |
| 394 } | 401 } |
| 395 | 402 |
| 396 } // namespace libgtk2ui | 403 } // namespace libgtk2ui |
| OLD | NEW |