| 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/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "chrome/browser/ui/gtk/bubble/bubble_accelerators_gtk.h" | 10 #include "chrome/browser/ui/gtk/bubble/bubble_accelerators_gtk.h" |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 550 } |
| 551 | 551 |
| 552 void BubbleGtk::Close() { | 552 void BubbleGtk::Close() { |
| 553 // We don't need to ungrab the pointer or keyboard here; the X server will | 553 // We don't need to ungrab the pointer or keyboard here; the X server will |
| 554 // automatically do that when we destroy our window. | 554 // automatically do that when we destroy our window. |
| 555 DCHECK(window_); | 555 DCHECK(window_); |
| 556 gtk_widget_destroy(window_); | 556 gtk_widget_destroy(window_); |
| 557 // |this| has been deleted, see OnDestroy. | 557 // |this| has been deleted, see OnDestroy. |
| 558 } | 558 } |
| 559 | 559 |
| 560 void BubbleGtk::SetPositionRelativeToAnchor(const gfx::Rect* rect) { |
| 561 rect_ = rect ? *rect : gtk_util::WidgetBounds(anchor_widget_); |
| 562 if (!UpdateFrameStyle(false)) |
| 563 MoveWindow(); |
| 564 } |
| 565 |
| 560 void BubbleGtk::GrabPointerAndKeyboard() { | 566 void BubbleGtk::GrabPointerAndKeyboard() { |
| 561 GdkWindow* gdk_window = gtk_widget_get_window(window_); | 567 GdkWindow* gdk_window = gtk_widget_get_window(window_); |
| 562 | 568 |
| 563 // Install X pointer and keyboard grabs to make sure that we have the focus | 569 // Install X pointer and keyboard grabs to make sure that we have the focus |
| 564 // and get all mouse and keyboard events until we're closed. As a hack, grab | 570 // and get all mouse and keyboard events until we're closed. As a hack, grab |
| 565 // the pointer even if |grab_input_| is false to prevent a weird error | 571 // the pointer even if |grab_input_| is false to prevent a weird error |
| 566 // rendering the bubble's frame. See | 572 // rendering the bubble's frame. See |
| 567 // https://code.google.com/p/chromium/issues/detail?id=130820. | 573 // https://code.google.com/p/chromium/issues/detail?id=130820. |
| 568 GdkGrabStatus pointer_grab_status = | 574 GdkGrabStatus pointer_grab_status = |
| 569 gdk_pointer_grab(gdk_window, | 575 gdk_pointer_grab(gdk_window, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 anchor_widget_ = NULL; | 777 anchor_widget_ = NULL; |
| 772 Close(); | 778 Close(); |
| 773 // |this| is deleted. | 779 // |this| is deleted. |
| 774 } | 780 } |
| 775 | 781 |
| 776 void BubbleGtk::OnToplevelDestroy(GtkWidget* widget) { | 782 void BubbleGtk::OnToplevelDestroy(GtkWidget* widget) { |
| 777 toplevel_window_ = NULL; | 783 toplevel_window_ = NULL; |
| 778 Close(); | 784 Close(); |
| 779 // |this| is deleted. | 785 // |this| is deleted. |
| 780 } | 786 } |
| OLD | NEW |