| 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 "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 5 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/ui/gtk/bubble/bubble_accelerators_gtk.h" | 10 #include "chrome/browser/ui/gtk/bubble/bubble_accelerators_gtk.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 402 |
| 403 switch (keyval) { | 403 switch (keyval) { |
| 404 case GDK_Escape: | 404 case GDK_Escape: |
| 405 // Close on Esc and trap the accelerator | 405 // Close on Esc and trap the accelerator |
| 406 closed_by_escape_ = true; | 406 closed_by_escape_ = true; |
| 407 Close(); | 407 Close(); |
| 408 return TRUE; | 408 return TRUE; |
| 409 case GDK_w: | 409 case GDK_w: |
| 410 // Close on C-w and forward the accelerator | 410 // Close on C-w and forward the accelerator |
| 411 if (modifier & GDK_CONTROL_MASK) { | 411 if (modifier & GDK_CONTROL_MASK) { |
| 412 gdk_keymap_get_entries_for_keyval(NULL, |
| 413 keyval, |
| 414 &keys, |
| 415 &n_keys); |
| 416 if (n_keys) { |
| 417 // Forward the accelerator to root window the bubble is anchored |
| 418 // to for further processing |
| 419 msg.type = GDK_KEY_PRESS; |
| 420 msg.window = GTK_WIDGET(toplevel_window_)->window; |
| 421 msg.send_event = TRUE; |
| 422 msg.time = GDK_CURRENT_TIME; |
| 423 msg.state = modifier | GDK_MOD2_MASK; |
| 424 msg.keyval = keyval; |
| 425 // length and string are deprecated and thus zeroed out |
| 426 msg.length = 0; |
| 427 msg.string = NULL; |
| 428 msg.hardware_keycode = keys[0].keycode; |
| 429 msg.group = keys[0].group; |
| 430 msg.is_modifier = 0; |
| 431 |
| 432 g_free(keys); |
| 433 |
| 434 gtk_main_do_event(reinterpret_cast<GdkEvent*>(&msg)); |
| 435 } else { |
| 436 // This means that there isn't a h/w code for the keyval in the |
| 437 // current keymap, which is weird but possible if the keymap just |
| 438 // changed. This isn't a critical error, but might be indicative |
| 439 // of something off if it happens regularly. |
| 440 DLOG(WARNING) << "Found no keys for value " << keyval; |
| 441 } |
| 412 Close(); | 442 Close(); |
| 413 } | 443 } |
| 414 break; | 444 break; |
| 415 default: | 445 default: |
| 416 return FALSE; | 446 return FALSE; |
| 417 } | 447 } |
| 418 | 448 |
| 419 gdk_keymap_get_entries_for_keyval(NULL, | |
| 420 keyval, | |
| 421 &keys, | |
| 422 &n_keys); | |
| 423 if (n_keys) { | |
| 424 // Forward the accelerator to root window the bubble is anchored | |
| 425 // to for further processing | |
| 426 msg.type = GDK_KEY_PRESS; | |
| 427 msg.window = GTK_WIDGET(toplevel_window_)->window; | |
| 428 msg.send_event = TRUE; | |
| 429 msg.time = GDK_CURRENT_TIME; | |
| 430 msg.state = modifier | GDK_MOD2_MASK; | |
| 431 msg.keyval = keyval; | |
| 432 // length and string are deprecated and thus zeroed out | |
| 433 msg.length = 0; | |
| 434 msg.string = NULL; | |
| 435 msg.hardware_keycode = keys[0].keycode; | |
| 436 msg.group = keys[0].group; | |
| 437 msg.is_modifier = 0; | |
| 438 | |
| 439 g_free(keys); | |
| 440 | |
| 441 gtk_main_do_event(reinterpret_cast<GdkEvent*>(&msg)); | |
| 442 } else { | |
| 443 // This means that there isn't a h/w code for the keyval in the | |
| 444 // current keymap, which is weird but possible if the keymap just | |
| 445 // changed. This isn't a critical error, but might be indicative | |
| 446 // of something off if it happens regularly. | |
| 447 DLOG(WARNING) << "Found no keys for value " << keyval; | |
| 448 } | |
| 449 return TRUE; | 449 return TRUE; |
| 450 } | 450 } |
| 451 | 451 |
| 452 gboolean BubbleGtk::OnExpose(GtkWidget* widget, GdkEventExpose* expose) { | 452 gboolean BubbleGtk::OnExpose(GtkWidget* widget, GdkEventExpose* expose) { |
| 453 GdkDrawable* drawable = GDK_DRAWABLE(window_->window); | 453 GdkDrawable* drawable = GDK_DRAWABLE(window_->window); |
| 454 GdkGC* gc = gdk_gc_new(drawable); | 454 GdkGC* gc = gdk_gc_new(drawable); |
| 455 gdk_gc_set_rgb_fg_color(gc, &kFrameColor); | 455 gdk_gc_set_rgb_fg_color(gc, &kFrameColor); |
| 456 | 456 |
| 457 // Stroke the frame border. | 457 // Stroke the frame border. |
| 458 std::vector<GdkPoint> points = MakeFramePolygonPoints( | 458 std::vector<GdkPoint> points = MakeFramePolygonPoints( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { | 525 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { |
| 526 Close(); | 526 Close(); |
| 527 return FALSE; | 527 return FALSE; |
| 528 } | 528 } |
| 529 | 529 |
| 530 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, | 530 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, |
| 531 GtkAllocation* allocation) { | 531 GtkAllocation* allocation) { |
| 532 if (!UpdateArrowLocation(false)) | 532 if (!UpdateArrowLocation(false)) |
| 533 MoveWindow(); | 533 MoveWindow(); |
| 534 } | 534 } |
| OLD | NEW |