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/panels/panel_browser_window_gtk.h" | 5 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
9 #include "chrome/browser/ui/gtk/browser_titlebar.h" | 9 #include "chrome/browser/ui/gtk/browser_titlebar.h" |
10 #include "chrome/browser/ui/panels/panel.h" | 10 #include "chrome/browser/ui/panels/panel.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // Do not show an icon in the task bar. Window operations such as close, | 88 // Do not show an icon in the task bar. Window operations such as close, |
89 // minimize etc. can only be done from the panel UI. | 89 // minimize etc. can only be done from the panel UI. |
90 gtk_window_set_skip_taskbar_hint(window(), TRUE); | 90 gtk_window_set_skip_taskbar_hint(window(), TRUE); |
91 | 91 |
92 g_signal_connect(titlebar_widget(), "button-press-event", | 92 g_signal_connect(titlebar_widget(), "button-press-event", |
93 G_CALLBACK(OnTitlebarButtonPressEventThunk), this); | 93 G_CALLBACK(OnTitlebarButtonPressEventThunk), this); |
94 g_signal_connect(titlebar_widget(), "button-release-event", | 94 g_signal_connect(titlebar_widget(), "button-release-event", |
95 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); | 95 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); |
96 | 96 |
97 ui::WorkAreaWatcherX::AddObserver(this); | 97 ui::WorkAreaWatcherX::AddObserver(this); |
| 98 registrar_.Add( |
| 99 this, |
| 100 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, |
| 101 content::Source<Panel>(panel_.get())); |
98 } | 102 } |
99 | 103 |
100 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { | 104 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { |
101 // Since panels are not resizable or movable by the user, we should not | 105 // Since panels are not resizable or movable by the user, we should not |
102 // detect the window edge for behavioral purposes. The edge, if any, | 106 // detect the window edge for behavioral purposes. The edge, if any, |
103 // is present only for visual aspects. | 107 // is present only for visual aspects. |
104 return FALSE; | 108 return FALSE; |
105 } | 109 } |
106 | 110 |
107 bool PanelBrowserWindowGtk::HandleTitleBarLeftMousePress( | 111 bool PanelBrowserWindowGtk::HandleTitleBarLeftMousePress( |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 return BrowserWindowGtk::PANGO_MARKUP; | 228 return BrowserWindowGtk::PANGO_MARKUP; |
225 } else { | 229 } else { |
226 return BrowserWindowGtk::GetWindowTitle(title); | 230 return BrowserWindowGtk::GetWindowTitle(title); |
227 } | 231 } |
228 } | 232 } |
229 | 233 |
230 void PanelBrowserWindowGtk::WorkAreaChanged() { | 234 void PanelBrowserWindowGtk::WorkAreaChanged() { |
231 panel_->manager()->OnDisplayChanged(); | 235 panel_->manager()->OnDisplayChanged(); |
232 } | 236 } |
233 | 237 |
| 238 void PanelBrowserWindowGtk::Observe( |
| 239 int type, |
| 240 const content::NotificationSource& source, |
| 241 const content::NotificationDetails& details) { |
| 242 if (type == chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE) { |
| 243 bool accept_focus = (panel_->expansion_state() == Panel::EXPANDED); |
| 244 gdk_window_set_accept_focus( |
| 245 gtk_widget_get_window(GTK_WIDGET(window())), accept_focus); |
| 246 } |
| 247 |
| 248 BrowserWindowGtk::Observe(type, source, details); |
| 249 } |
| 250 |
234 void PanelBrowserWindowGtk::ShowPanel() { | 251 void PanelBrowserWindowGtk::ShowPanel() { |
235 Show(); | 252 Show(); |
236 } | 253 } |
237 | 254 |
238 void PanelBrowserWindowGtk::ShowPanelInactive() { | 255 void PanelBrowserWindowGtk::ShowPanelInactive() { |
239 ShowInactive(); | 256 ShowInactive(); |
240 } | 257 } |
241 | 258 |
242 gfx::Rect PanelBrowserWindowGtk::GetPanelBounds() const { | 259 gfx::Rect PanelBrowserWindowGtk::GetPanelBounds() const { |
243 return bounds_; | 260 return bounds_; |
(...skipping 28 matching lines...) Expand all Loading... |
272 | 289 |
273 void PanelBrowserWindowGtk::ClosePanel() { | 290 void PanelBrowserWindowGtk::ClosePanel() { |
274 // Cancel any currently running animation since we're closing down. | 291 // Cancel any currently running animation since we're closing down. |
275 if (bounds_animator_.get()) | 292 if (bounds_animator_.get()) |
276 bounds_animator_.reset(); | 293 bounds_animator_.reset(); |
277 | 294 |
278 Close(); | 295 Close(); |
279 } | 296 } |
280 | 297 |
281 void PanelBrowserWindowGtk::ActivatePanel() { | 298 void PanelBrowserWindowGtk::ActivatePanel() { |
282 gdk_window_set_accept_focus( | |
283 gtk_widget_get_window(GTK_WIDGET(window())), TRUE); | |
284 Activate(); | 299 Activate(); |
285 } | 300 } |
286 | 301 |
287 void PanelBrowserWindowGtk::DeactivatePanel() { | 302 void PanelBrowserWindowGtk::DeactivatePanel() { |
288 BrowserWindow* browser_window = | 303 BrowserWindow* browser_window = |
289 panel_->manager()->GetNextBrowserWindowToActivate(panel_.get()); | 304 panel_->manager()->GetNextBrowserWindowToActivate(panel_.get()); |
290 if (browser_window) { | 305 if (browser_window) { |
291 browser_window->Activate(); | 306 browser_window->Activate(); |
292 } else { | 307 } else { |
293 Deactivate(); | 308 Deactivate(); |
294 } | 309 } |
295 | |
296 if (panel_->expansion_state() == Panel::MINIMIZED) { | |
297 gdk_window_set_accept_focus( | |
298 gtk_widget_get_window(GTK_WIDGET(window())), FALSE); | |
299 } | |
300 } | 310 } |
301 | 311 |
302 bool PanelBrowserWindowGtk::IsPanelActive() const { | 312 bool PanelBrowserWindowGtk::IsPanelActive() const { |
303 return IsActive(); | 313 return IsActive(); |
304 } | 314 } |
305 | 315 |
306 gfx::NativeWindow PanelBrowserWindowGtk::GetNativePanelHandle() { | 316 gfx::NativeWindow PanelBrowserWindowGtk::GetNativePanelHandle() { |
307 return GetNativeHandle(); | 317 return GetNativeHandle(); |
308 } | 318 } |
309 | 319 |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 } | 795 } |
786 } | 796 } |
787 | 797 |
788 bool NativePanelTestingGtk::IsWindowSizeKnown() const { | 798 bool NativePanelTestingGtk::IsWindowSizeKnown() const { |
789 return panel_browser_window_gtk_->window_size_known_; | 799 return panel_browser_window_gtk_->window_size_known_; |
790 } | 800 } |
791 | 801 |
792 bool NativePanelTestingGtk::IsAnimatingBounds() const { | 802 bool NativePanelTestingGtk::IsAnimatingBounds() const { |
793 return panel_browser_window_gtk_->IsAnimatingBounds(); | 803 return panel_browser_window_gtk_->IsAnimatingBounds(); |
794 } | 804 } |
OLD | NEW |