| 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/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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 break; | 454 break; |
| 455 default: | 455 default: |
| 456 return FALSE; | 456 return FALSE; |
| 457 } | 457 } |
| 458 | 458 |
| 459 return TRUE; | 459 return TRUE; |
| 460 } | 460 } |
| 461 | 461 |
| 462 gboolean BubbleGtk::OnExpose(GtkWidget* widget, GdkEventExpose* expose) { | 462 gboolean BubbleGtk::OnExpose(GtkWidget* widget, GdkEventExpose* expose) { |
| 463 // TODO(erg): This whole method will need to be rewritten in cairo. | 463 // TODO(erg): This whole method will need to be rewritten in cairo. |
| 464 GdkDrawable* drawable = GDK_DRAWABLE(window_->window); | 464 GdkDrawable* drawable = GDK_DRAWABLE(gtk_widget_get_window(window_)); |
| 465 GdkGC* gc = gdk_gc_new(drawable); | 465 GdkGC* gc = gdk_gc_new(drawable); |
| 466 gdk_gc_set_rgb_fg_color(gc, &kFrameColor); | 466 gdk_gc_set_rgb_fg_color(gc, &kFrameColor); |
| 467 | 467 |
| 468 // Stroke the frame border. | 468 // Stroke the frame border. |
| 469 GtkAllocation allocation; | 469 GtkAllocation allocation; |
| 470 gtk_widget_get_allocation(window_, &allocation); | 470 gtk_widget_get_allocation(window_, &allocation); |
| 471 std::vector<GdkPoint> points = MakeFramePolygonPoints( | 471 std::vector<GdkPoint> points = MakeFramePolygonPoints( |
| 472 current_arrow_location_, allocation.width, allocation.height, | 472 current_arrow_location_, allocation.width, allocation.height, |
| 473 FRAME_STROKE); | 473 FRAME_STROKE); |
| 474 gdk_draw_polygon(drawable, gc, FALSE, &points[0], points.size()); | 474 gdk_draw_polygon(drawable, gc, FALSE, &points[0], points.size()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 487 MoveWindow(); | 487 MoveWindow(); |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 | 490 |
| 491 gboolean BubbleGtk::OnButtonPress(GtkWidget* widget, | 491 gboolean BubbleGtk::OnButtonPress(GtkWidget* widget, |
| 492 GdkEventButton* event) { | 492 GdkEventButton* event) { |
| 493 // If we got a click in our own window, that's okay (we need to additionally | 493 // If we got a click in our own window, that's okay (we need to additionally |
| 494 // check that it falls within our bounds, since we've grabbed the pointer and | 494 // check that it falls within our bounds, since we've grabbed the pointer and |
| 495 // some events that actually occurred in other windows will be reported with | 495 // some events that actually occurred in other windows will be reported with |
| 496 // respect to our window). | 496 // respect to our window). |
| 497 if (event->window == window_->window && | 497 GdkWindow* gdk_window = gtk_widget_get_window(window_); |
| 498 if (event->window == gdk_window && |
| 498 (mask_region_ && gdk_region_point_in(mask_region_, event->x, event->y))) { | 499 (mask_region_ && gdk_region_point_in(mask_region_, event->x, event->y))) { |
| 499 return FALSE; // Propagate. | 500 return FALSE; // Propagate. |
| 500 } | 501 } |
| 501 | 502 |
| 502 // Our content widget got a click. | 503 // Our content widget got a click. |
| 503 if (event->window != window_->window && | 504 if (event->window != gdk_window && |
| 504 gdk_window_get_toplevel(event->window) == window_->window) { | 505 gdk_window_get_toplevel(event->window) == gdk_window) { |
| 505 return FALSE; | 506 return FALSE; |
| 506 } | 507 } |
| 507 | 508 |
| 508 if (grab_input_) { | 509 if (grab_input_) { |
| 509 // Otherwise we had a click outside of our window, close ourself. | 510 // Otherwise we had a click outside of our window, close ourself. |
| 510 Close(); | 511 Close(); |
| 511 return TRUE; | 512 return TRUE; |
| 512 } | 513 } |
| 513 | 514 |
| 514 return FALSE; | 515 return FALSE; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 537 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { | 538 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { |
| 538 Close(); | 539 Close(); |
| 539 return FALSE; | 540 return FALSE; |
| 540 } | 541 } |
| 541 | 542 |
| 542 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, | 543 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, |
| 543 GtkAllocation* allocation) { | 544 GtkAllocation* allocation) { |
| 544 if (!UpdateArrowLocation(false)) | 545 if (!UpdateArrowLocation(false)) |
| 545 MoveWindow(); | 546 MoveWindow(); |
| 546 } | 547 } |
| OLD | NEW |