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

Side by Side Diff: chrome/browser/ui/libgtk2ui/gtk2_util.cc

Issue 304223012: Fixes crash of SetGtkTransientForAura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_util.h" 5 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkx.h> 8 #include <gdk/gdkx.h>
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 flags |= (state & GDK_SHIFT_MASK) ? ui::EF_SHIFT_DOWN : ui::EF_NONE; 97 flags |= (state & GDK_SHIFT_MASK) ? ui::EF_SHIFT_DOWN : ui::EF_NONE;
98 flags |= (state & GDK_MOD1_MASK) ? ui::EF_ALT_DOWN : ui::EF_NONE; 98 flags |= (state & GDK_MOD1_MASK) ? ui::EF_ALT_DOWN : ui::EF_NONE;
99 flags |= (state & GDK_BUTTON1_MASK) ? ui::EF_LEFT_MOUSE_BUTTON : ui::EF_NONE; 99 flags |= (state & GDK_BUTTON1_MASK) ? ui::EF_LEFT_MOUSE_BUTTON : ui::EF_NONE;
100 flags |= 100 flags |=
101 (state & GDK_BUTTON2_MASK) ? ui::EF_MIDDLE_MOUSE_BUTTON : ui::EF_NONE; 101 (state & GDK_BUTTON2_MASK) ? ui::EF_MIDDLE_MOUSE_BUTTON : ui::EF_NONE;
102 flags |= (state & GDK_BUTTON3_MASK) ? ui::EF_RIGHT_MOUSE_BUTTON : ui::EF_NONE; 102 flags |= (state & GDK_BUTTON3_MASK) ? ui::EF_RIGHT_MOUSE_BUTTON : ui::EF_NONE;
103 return flags; 103 return flags;
104 } 104 }
105 105
106 void SetGtkTransientForAura(GtkWidget* dialog, aura::Window* parent) { 106 void SetGtkTransientForAura(GtkWidget* dialog, aura::Window* parent) {
107 if (!parent) 107 if (!parent || !parent->GetHost())
108 return; 108 return;
109 109
110 gtk_widget_realize(dialog); 110 gtk_widget_realize(dialog);
111 GdkWindow* gdk_window = gtk_widget_get_window(dialog); 111 GdkWindow* gdk_window = gtk_widget_get_window(dialog);
112 112
113 // TODO(erg): Check to make sure we're using X11 if wayland or some other 113 // TODO(erg): Check to make sure we're using X11 if wayland or some other
114 // display server ever happens. Otherwise, this will crash. 114 // display server ever happens. Otherwise, this will crash.
115 XSetTransientForHint(GDK_WINDOW_XDISPLAY(gdk_window), 115 XSetTransientForHint(GDK_WINDOW_XDISPLAY(gdk_window),
116 GDK_WINDOW_XID(gdk_window), 116 GDK_WINDOW_XID(gdk_window),
117 parent->GetHost()->GetAcceleratedWidget()); 117 parent->GetHost()->GetAcceleratedWidget());
118 118
119 // We also set the |parent| as a property of |dialog|, so that we can unlink 119 // We also set the |parent| as a property of |dialog|, so that we can unlink
120 // the two later. 120 // the two later.
121 g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, parent); 121 g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, parent);
122 } 122 }
123 123
124 aura::Window* GetAuraTransientParent(GtkWidget* dialog) { 124 aura::Window* GetAuraTransientParent(GtkWidget* dialog) {
125 return reinterpret_cast<aura::Window*>( 125 return reinterpret_cast<aura::Window*>(
126 g_object_get_data(G_OBJECT(dialog), kAuraTransientParent)); 126 g_object_get_data(G_OBJECT(dialog), kAuraTransientParent));
127 } 127 }
128 128
129 void ClearAuraTransientParent(GtkWidget* dialog) { 129 void ClearAuraTransientParent(GtkWidget* dialog) {
130 g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, NULL); 130 g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, NULL);
131 } 131 }
132 132
133 } // namespace libgtk2ui 133 } // namespace libgtk2ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698