Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1163)

Unified Diff: chrome/browser/gtk/focus_store_gtk.cc

Issue 3235010: reland r57885 with a fix for linux/views. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: . Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/gtk/focus_store_gtk.h ('k') | chrome/browser/gtk/gtk_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/focus_store_gtk.cc
diff --git a/chrome/browser/gtk/focus_store_gtk.cc b/chrome/browser/gtk/focus_store_gtk.cc
index dc099fca198e3273da68861869adc3df236131ca..50ebfa766baaf2dc7ee951194256b858c4e60d6b 100644
--- a/chrome/browser/gtk/focus_store_gtk.cc
+++ b/chrome/browser/gtk/focus_store_gtk.cc
@@ -19,19 +19,22 @@ FocusStoreGtk::~FocusStoreGtk() {
}
void FocusStoreGtk::Store(GtkWidget* widget) {
- DisconnectDestroyHandler();
- if (!widget) {
- widget_ = NULL;
- return;
+ GtkWidget* focus_widget = NULL;
+ if (widget) {
+ GtkWindow* window = platform_util::GetTopLevel(widget);
+ if (window)
+ focus_widget = window->focus_widget;
}
- GtkWindow* window = platform_util::GetTopLevel(widget);
- if (!window) {
- widget_ = NULL;
- return;
- }
+ SetWidget(focus_widget);
+}
- widget_ = window->focus_widget;
+void FocusStoreGtk::SetWidget(GtkWidget* widget) {
+ DisconnectDestroyHandler();
+
+ // We don't add a ref. The signal handler below effectively gives us a weak
+ // reference.
+ widget_ = widget;
if (widget_) {
// When invoked, |gtk_widget_destroyed| will set |widget_| to NULL.
destroy_handler_id_ = g_signal_connect(widget_, "destroy",
@@ -41,6 +44,8 @@ void FocusStoreGtk::Store(GtkWidget* widget) {
}
void FocusStoreGtk::DisconnectDestroyHandler() {
- if (widget_)
+ if (widget_) {
g_signal_handler_disconnect(widget_, destroy_handler_id_);
+ widget_ = NULL;
+ }
}
« no previous file with comments | « chrome/browser/gtk/focus_store_gtk.h ('k') | chrome/browser/gtk/gtk_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698