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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); | 90 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); |
91 | 91 |
92 g_signal_connect(window_, "enter-notify-event", | 92 g_signal_connect(window_, "enter-notify-event", |
93 G_CALLBACK(OnEnterNotifyThunk), this); | 93 G_CALLBACK(OnEnterNotifyThunk), this); |
94 g_signal_connect(window_, "leave-notify-event", | 94 g_signal_connect(window_, "leave-notify-event", |
95 G_CALLBACK(OnLeaveNotifyThunk), this); | 95 G_CALLBACK(OnLeaveNotifyThunk), this); |
96 | 96 |
97 ui::WorkAreaWatcherX::AddObserver(this); | 97 ui::WorkAreaWatcherX::AddObserver(this); |
98 registrar_.Add( | 98 registrar_.Add( |
99 this, | 99 this, |
| 100 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, |
| 101 content::Source<Panel>(panel_.get())); |
| 102 registrar_.Add( |
| 103 this, |
100 chrome::NOTIFICATION_PANEL_CHANGED_LAYOUT_MODE, | 104 chrome::NOTIFICATION_PANEL_CHANGED_LAYOUT_MODE, |
101 content::Source<Panel>(panel_.get())); | 105 content::Source<Panel>(panel_.get())); |
102 registrar_.Add( | 106 registrar_.Add( |
103 this, | 107 this, |
104 chrome::NOTIFICATION_WINDOW_CLOSED, | 108 chrome::NOTIFICATION_WINDOW_CLOSED, |
105 content::Source<GtkWindow>(window())); | 109 content::Source<GtkWindow>(window())); |
106 } | 110 } |
107 | 111 |
108 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { | 112 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { |
109 // Since panels are not resizable or movable by the user, we should not | 113 // Since panels are not resizable or movable by the user, we should not |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 panel_->manager()->OnDisplayChanged(); | 268 panel_->manager()->OnDisplayChanged(); |
265 } | 269 } |
266 | 270 |
267 void PanelBrowserWindowGtk::Observe( | 271 void PanelBrowserWindowGtk::Observe( |
268 int type, | 272 int type, |
269 const content::NotificationSource& source, | 273 const content::NotificationSource& source, |
270 const content::NotificationDetails& details) { | 274 const content::NotificationDetails& details) { |
271 switch (type) { | 275 switch (type) { |
272 case chrome::NOTIFICATION_PANEL_CHANGED_LAYOUT_MODE: | 276 case chrome::NOTIFICATION_PANEL_CHANGED_LAYOUT_MODE: |
273 titlebar()->UpdateCustomFrame(true); | 277 titlebar()->UpdateCustomFrame(true); |
| 278 // No break. Accept focus code should execute for both cases. |
| 279 case chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE: |
| 280 gtk_window_set_accept_focus(window(), !panel_->IsMinimized()); |
274 break; | 281 break; |
275 case chrome::NOTIFICATION_WINDOW_CLOSED: | 282 case chrome::NOTIFICATION_WINDOW_CLOSED: |
276 // Cleanup. | 283 // Cleanup. |
277 if (bounds_animator_.get()) | 284 if (bounds_animator_.get()) |
278 bounds_animator_.reset(); | 285 bounds_animator_.reset(); |
279 | 286 |
280 CleanupDragDrop(); | 287 CleanupDragDrop(); |
281 if (drag_widget_) { | 288 if (drag_widget_) { |
282 // Terminate the grab if we have it. We could do this using any widget, | 289 // Terminate the grab if we have it. We could do this using any widget, |
283 // |drag_widget_| is just convenient. | 290 // |drag_widget_| is just convenient. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 browser_window->Activate(); | 380 browser_window->Activate(); |
374 } else { | 381 } else { |
375 Deactivate(); | 382 Deactivate(); |
376 } | 383 } |
377 } | 384 } |
378 | 385 |
379 bool PanelBrowserWindowGtk::IsPanelActive() const { | 386 bool PanelBrowserWindowGtk::IsPanelActive() const { |
380 return IsActive(); | 387 return IsActive(); |
381 } | 388 } |
382 | 389 |
383 void PanelBrowserWindowGtk::PreventActivationByOS(bool prevent_activation) { | |
384 gtk_window_set_accept_focus(window(), !prevent_activation); | |
385 return; | |
386 } | |
387 | |
388 gfx::NativeWindow PanelBrowserWindowGtk::GetNativePanelHandle() { | 390 gfx::NativeWindow PanelBrowserWindowGtk::GetNativePanelHandle() { |
389 return GetNativeHandle(); | 391 return GetNativeHandle(); |
390 } | 392 } |
391 | 393 |
392 void PanelBrowserWindowGtk::UpdatePanelTitleBar() { | 394 void PanelBrowserWindowGtk::UpdatePanelTitleBar() { |
393 UpdateTitleBar(); | 395 UpdateTitleBar(); |
394 } | 396 } |
395 | 397 |
396 void PanelBrowserWindowGtk::UpdatePanelLoadingAnimations(bool should_animate) { | 398 void PanelBrowserWindowGtk::UpdatePanelLoadingAnimations(bool should_animate) { |
397 UpdateLoadingAnimations(should_animate); | 399 UpdateLoadingAnimations(should_animate); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 MessageLoopForUI::current()->RunAllPending(); | 877 MessageLoopForUI::current()->RunAllPending(); |
876 } | 878 } |
877 | 879 |
878 bool NativePanelTestingGtk::IsWindowSizeKnown() const { | 880 bool NativePanelTestingGtk::IsWindowSizeKnown() const { |
879 return panel_browser_window_gtk_->window_size_known_; | 881 return panel_browser_window_gtk_->window_size_known_; |
880 } | 882 } |
881 | 883 |
882 bool NativePanelTestingGtk::IsAnimatingBounds() const { | 884 bool NativePanelTestingGtk::IsAnimatingBounds() const { |
883 return panel_browser_window_gtk_->IsAnimatingBounds(); | 885 return panel_browser_window_gtk_->IsAnimatingBounds(); |
884 } | 886 } |
OLD | NEW |