OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/panels/panel.h" | 9 #include "chrome/browser/ui/panels/panel.h" |
10 #include "chrome/browser/ui/panels/panel_manager.h" | 10 #include "chrome/browser/ui/panels/panel_manager.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 | 63 |
64 PanelBrowserWindowGtk::~PanelBrowserWindowGtk() { | 64 PanelBrowserWindowGtk::~PanelBrowserWindowGtk() { |
65 if (drag_widget_) { | 65 if (drag_widget_) { |
66 // Terminate the grab if we have it. We could do this using any widget, | 66 // Terminate the grab if we have it. We could do this using any widget, |
67 // |drag_widget_| is just convenient. | 67 // |drag_widget_| is just convenient. |
68 gtk_grab_add(drag_widget_); | 68 gtk_grab_add(drag_widget_); |
69 gtk_grab_remove(drag_widget_); | 69 gtk_grab_remove(drag_widget_); |
70 DestroyDragWidget(); | 70 DestroyDragWidget(); |
71 } | 71 } |
72 panel_->OnNativePanelClosed(); | 72 panel_->OnNativePanelClosed(); |
73 ui::WorkAreaWatcherX::RemoveObserver(this); | |
73 } | 74 } |
74 | 75 |
75 void PanelBrowserWindowGtk::Init() { | 76 void PanelBrowserWindowGtk::Init() { |
76 BrowserWindowGtk::Init(); | 77 BrowserWindowGtk::Init(); |
77 | 78 |
78 // Keep the window docked to the bottom of the screen on resizes. | 79 // Keep the window docked to the bottom of the screen on resizes. |
79 gtk_window_set_gravity(window(), GDK_GRAVITY_SOUTH_EAST); | 80 gtk_window_set_gravity(window(), GDK_GRAVITY_SOUTH_EAST); |
80 | 81 |
81 // Keep the window always on top. | 82 // Keep the window always on top. |
82 gtk_window_set_keep_above(window(), TRUE); | 83 gtk_window_set_keep_above(window(), TRUE); |
83 | 84 |
84 // Show the window on all the virtual desktops. | 85 // Show the window on all the virtual desktops. |
85 gtk_window_stick(window()); | 86 gtk_window_stick(window()); |
86 | 87 |
87 // 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, |
88 // minimize etc. can only be done from the panel UI. | 89 // minimize etc. can only be done from the panel UI. |
89 gtk_window_set_skip_taskbar_hint(window(), TRUE); | 90 gtk_window_set_skip_taskbar_hint(window(), TRUE); |
90 | 91 |
91 g_signal_connect(titlebar_widget(), "button-press-event", | 92 g_signal_connect(titlebar_widget(), "button-press-event", |
92 G_CALLBACK(OnTitlebarButtonPressEventThunk), this); | 93 G_CALLBACK(OnTitlebarButtonPressEventThunk), this); |
93 g_signal_connect(titlebar_widget(), "button-release-event", | 94 g_signal_connect(titlebar_widget(), "button-release-event", |
94 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); | 95 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); |
96 | |
97 // Strictly speaking we should have a single observer for work area changed | |
Dmitry Titov
2011/11/18 04:56:37
Not sure that long comment has to be here. If it's
prasadt
2011/11/18 22:31:42
Just a clarification in case someone wonders why i
| |
98 // notification. There are a few reasons for doing it this way: | |
99 // 1) Keep it consistent with the way we do it on other platforms. | |
100 // 2) This is a rare enough event to create a separate class with | |
101 // implementations for all platforms. | |
102 // 3) It may not be possible to listen to this event without assoicating it | |
103 // with a window on all platforms. | |
104 ui::WorkAreaWatcherX::AddObserver(this); | |
95 } | 105 } |
96 | 106 |
97 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { | 107 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { |
98 // Since panels are not resizable or movable by the user, we should not | 108 // Since panels are not resizable or movable by the user, we should not |
99 // detect the window edge for behavioral purposes. The edge, if any, | 109 // detect the window edge for behavioral purposes. The edge, if any, |
100 // is present only for visual aspects. | 110 // is present only for visual aspects. |
101 return FALSE; | 111 return FALSE; |
102 } | 112 } |
103 | 113 |
104 bool PanelBrowserWindowGtk::HandleTitleBarLeftMousePress( | 114 bool PanelBrowserWindowGtk::HandleTitleBarLeftMousePress( |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 NULL); | 228 NULL); |
219 *title = title_with_markup; | 229 *title = title_with_markup; |
220 g_free(title_escaped); | 230 g_free(title_escaped); |
221 g_free(title_with_markup); | 231 g_free(title_with_markup); |
222 return BrowserWindowGtk::PANGO_MARKUP; | 232 return BrowserWindowGtk::PANGO_MARKUP; |
223 } else { | 233 } else { |
224 return BrowserWindowGtk::GetWindowTitle(title); | 234 return BrowserWindowGtk::GetWindowTitle(title); |
225 } | 235 } |
226 } | 236 } |
227 | 237 |
238 void PanelBrowserWindowGtk::WorkAreaChanged() { | |
239 panel_->manager()->OnDisplayChanged(); | |
240 } | |
241 | |
228 void PanelBrowserWindowGtk::ShowPanel() { | 242 void PanelBrowserWindowGtk::ShowPanel() { |
229 Show(); | 243 Show(); |
230 } | 244 } |
231 | 245 |
232 void PanelBrowserWindowGtk::ShowPanelInactive() { | 246 void PanelBrowserWindowGtk::ShowPanelInactive() { |
233 ShowInactive(); | 247 ShowInactive(); |
234 } | 248 } |
235 | 249 |
236 gfx::Rect PanelBrowserWindowGtk::GetPanelBounds() const { | 250 gfx::Rect PanelBrowserWindowGtk::GetPanelBounds() const { |
237 return bounds_; | 251 return bounds_; |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 } | 742 } |
729 } | 743 } |
730 | 744 |
731 bool NativePanelTestingGtk::IsWindowSizeKnown() const { | 745 bool NativePanelTestingGtk::IsWindowSizeKnown() const { |
732 return panel_browser_window_gtk_->window_size_known_; | 746 return panel_browser_window_gtk_->window_size_known_; |
733 } | 747 } |
734 | 748 |
735 bool NativePanelTestingGtk::IsAnimatingBounds() const { | 749 bool NativePanelTestingGtk::IsAnimatingBounds() const { |
736 return panel_browser_window_gtk_->IsAnimatingBounds(); | 750 return panel_browser_window_gtk_->IsAnimatingBounds(); |
737 } | 751 } |
OLD | NEW |