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/extensions/shell_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/extensions/shell_window_gtk.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
9 #include "content/public/browser/render_widget_host_view.h" | 9 #include "content/public/browser/render_widget_host_view.h" |
10 #include "ui/base/x/active_window_watcher_x.h" | 10 #include "ui/base/x/active_window_watcher_x.h" |
11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
12 | 12 |
13 ShellWindowGtk::ShellWindowGtk(ExtensionHost* host) | 13 ShellWindowGtk::ShellWindowGtk(ExtensionHost* host) |
14 : ShellWindow(host), | 14 : ShellWindow(host), |
15 state_(GDK_WINDOW_STATE_WITHDRAWN), | 15 state_(GDK_WINDOW_STATE_WITHDRAWN), |
16 is_active_(!ui::ActiveWindowWatcherX::WMSupportsActivation()) { | 16 is_active_(!ui::ActiveWindowWatcherX::WMSupportsActivation()) { |
17 host_->view()->SetContainer(this); | 17 host_->view()->SetContainer(this); |
18 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | 18 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
19 | 19 |
20 gtk_container_add(GTK_CONTAINER(window_), host_->view()->native_view()); | 20 gtk_container_add(GTK_CONTAINER(window_), host_->view()->native_view()); |
21 | 21 |
| 22 gtk_window_set_default_size(window_, kDefaultWidth, kDefaultHeight); |
| 23 |
22 const Extension* extension = host_->extension(); | 24 const Extension* extension = host_->extension(); |
23 | 25 |
24 // TOOD(mihaip): restore prior window dimensions and positions on relaunch. | |
25 gtk_window_set_default_size( | |
26 window_, extension->launch_width(), extension->launch_height()); | |
27 | |
28 int min_width = extension->launch_min_width(); | |
29 int min_height = extension->launch_min_height(); | |
30 int max_width = extension->launch_max_width(); | |
31 int max_height = extension->launch_max_height(); | |
32 GdkGeometry hints; | |
33 int hints_mask = 0; | |
34 if (min_width || min_height) { | |
35 hints.min_height = min_height; | |
36 hints.min_width = min_width; | |
37 hints_mask |= GDK_HINT_MIN_SIZE; | |
38 } | |
39 if (max_width || max_height) { | |
40 hints.max_height = max_height ? max_height : G_MAXINT; | |
41 hints.max_width = max_width ? max_width : G_MAXINT; | |
42 hints_mask |= GDK_HINT_MAX_SIZE; | |
43 } | |
44 if (hints_mask) { | |
45 gtk_window_set_geometry_hints( | |
46 window_, | |
47 GTK_WIDGET(window_), | |
48 &hints, | |
49 static_cast<GdkWindowHints>(hints_mask)); | |
50 } | |
51 | |
52 // TODO(mihaip): Mirror contents of <title> tag in window title | 26 // TODO(mihaip): Mirror contents of <title> tag in window title |
53 gtk_window_set_title(window_, extension->name().c_str()); | 27 gtk_window_set_title(window_, extension->name().c_str()); |
54 | 28 |
55 g_signal_connect(window_, "delete-event", | 29 g_signal_connect(window_, "delete-event", |
56 G_CALLBACK(OnMainWindowDeleteEventThunk), this); | 30 G_CALLBACK(OnMainWindowDeleteEventThunk), this); |
57 g_signal_connect(window_, "configure-event", | 31 g_signal_connect(window_, "configure-event", |
58 G_CALLBACK(OnConfigureThunk), this); | 32 G_CALLBACK(OnConfigureThunk), this); |
59 g_signal_connect(window_, "window-state-event", | 33 g_signal_connect(window_, "window-state-event", |
60 G_CALLBACK(OnWindowStateThunk), this); | 34 G_CALLBACK(OnWindowStateThunk), this); |
61 | 35 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 gboolean ShellWindowGtk::OnWindowState(GtkWidget* sender, | 160 gboolean ShellWindowGtk::OnWindowState(GtkWidget* sender, |
187 GdkEventWindowState* event) { | 161 GdkEventWindowState* event) { |
188 state_ = event->new_window_state; | 162 state_ = event->new_window_state; |
189 return FALSE; | 163 return FALSE; |
190 } | 164 } |
191 | 165 |
192 // static | 166 // static |
193 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { | 167 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { |
194 return new ShellWindowGtk(host); | 168 return new ShellWindowGtk(host); |
195 } | 169 } |
OLD | NEW |