| 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/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 #include <stddef.h> | 10 #include <stddef.h> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/debug/leak_annotations.h" | 13 #include "base/debug/leak_annotations.h" |
| 14 #include "base/environment.h" | 14 #include "base/environment.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_tree_host.h" | 17 #include "ui/aura/window_tree_host.h" |
| 18 #include "ui/base/accelerators/accelerator.h" | 18 #include "ui/base/accelerators/accelerator.h" |
| 19 #include "ui/events/event_constants.h" | 19 #include "ui/events/event_constants.h" |
| 20 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 20 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
| 21 #include "ui/gfx/geometry/size.h" | 21 #include "ui/gfx/geometry/size.h" |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 const char kAuraTransientParent[] = "aura-transient-parent"; | 25 const char kAuraTransientParent[] = "aura-transient-parent"; |
| 26 const char kDesktopWindowTreeHost[] = "desktop-window-tree-Host"; |
| 27 |
| 26 | 28 |
| 27 void CommonInitFromCommandLine(const base::CommandLine& command_line, | 29 void CommonInitFromCommandLine(const base::CommandLine& command_line, |
| 28 void (*init_func)(gint*, gchar***)) { | 30 void (*init_func)(gint*, gchar***)) { |
| 29 const std::vector<std::string>& args = command_line.argv(); | 31 const std::vector<std::string>& args = command_line.argv(); |
| 30 int argc = args.size(); | 32 int argc = args.size(); |
| 31 scoped_ptr<char *[]> argv(new char *[argc + 1]); | 33 scoped_ptr<char *[]> argv(new char *[argc + 1]); |
| 32 for (size_t i = 0; i < args.size(); ++i) { | 34 for (size_t i = 0; i < args.size(); ++i) { |
| 33 // TODO(piman@google.com): can gtk_init modify argv? Just being safe | 35 // TODO(piman@google.com): can gtk_init modify argv? Just being safe |
| 34 // here. | 36 // here. |
| 35 argv[i] = strdup(args[i].c_str()); | 37 argv[i] = strdup(args[i].c_str()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 135 |
| 134 aura::Window* GetAuraTransientParent(GtkWidget* dialog) { | 136 aura::Window* GetAuraTransientParent(GtkWidget* dialog) { |
| 135 return reinterpret_cast<aura::Window*>( | 137 return reinterpret_cast<aura::Window*>( |
| 136 g_object_get_data(G_OBJECT(dialog), kAuraTransientParent)); | 138 g_object_get_data(G_OBJECT(dialog), kAuraTransientParent)); |
| 137 } | 139 } |
| 138 | 140 |
| 139 void ClearAuraTransientParent(GtkWidget* dialog) { | 141 void ClearAuraTransientParent(GtkWidget* dialog) { |
| 140 g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, NULL); | 142 g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, NULL); |
| 141 } | 143 } |
| 142 | 144 |
| 145 void SetDesktopWindowTreeHost(GtkWidget* dialog, |
| 146 views::DesktopWindowTreeHostX11* host) { |
| 147 g_object_set_data(G_OBJECT(dialog), kDesktopWindowTreeHost, host); |
| 148 } |
| 149 |
| 150 views::DesktopWindowTreeHostX11* GetDesktopWindowTreeHost(GtkWidget* dialog) { |
| 151 return reinterpret_cast<views::DesktopWindowTreeHostX11*>( |
| 152 g_object_get_data(G_OBJECT(dialog), kDesktopWindowTreeHost)); |
| 153 } |
| 154 |
| 143 } // namespace libgtk2ui | 155 } // namespace libgtk2ui |
| OLD | NEW |