Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Side by Side Diff: chrome/browser/ui/panels/panel_browser_window_gtk.cc

Issue 8595003: Have panels respond to changes in work area on Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move observers into their own header files. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" 11 #include "chrome/browser/ui/panels/panel_settings_menu_model.h"
12 #include "chrome/common/chrome_notification_types.h" 12 #include "chrome/common/chrome_notification_types.h"
13 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
14 #include "ui/base/animation/slide_animation.h" 14 #include "ui/base/animation/slide_animation.h"
15 #include "ui/base/dragdrop/gtk_dnd_util.h" 15 #include "ui/base/dragdrop/gtk_dnd_util.h"
16 #include "ui/base/x/work_area_watcher_x.h"
16 17
17 namespace { 18 namespace {
18 19
19 // This value is experimental and subjective. 20 // This value is experimental and subjective.
20 const int kSetBoundsAnimationMs = 180; 21 const int kSetBoundsAnimationMs = 180;
21 22
22 // RGB values for titlebar in draw attention state. A shade of orange. 23 // RGB values for titlebar in draw attention state. A shade of orange.
23 const int kDrawAttentionR = 0xfa; 24 const int kDrawAttentionR = 0xfa;
24 const int kDrawAttentionG = 0x98; 25 const int kDrawAttentionG = 0x98;
25 const int kDrawAttentionB = 0x3a; 26 const int kDrawAttentionB = 0x3a;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 64
64 PanelBrowserWindowGtk::~PanelBrowserWindowGtk() { 65 PanelBrowserWindowGtk::~PanelBrowserWindowGtk() {
65 if (drag_widget_) { 66 if (drag_widget_) {
66 // Terminate the grab if we have it. We could do this using any widget, 67 // Terminate the grab if we have it. We could do this using any widget,
67 // |drag_widget_| is just convenient. 68 // |drag_widget_| is just convenient.
68 gtk_grab_add(drag_widget_); 69 gtk_grab_add(drag_widget_);
69 gtk_grab_remove(drag_widget_); 70 gtk_grab_remove(drag_widget_);
70 DestroyDragWidget(); 71 DestroyDragWidget();
71 } 72 }
72 panel_->OnNativePanelClosed(); 73 panel_->OnNativePanelClosed();
74 ui::WorkAreaWatcherX::RemoveObserver(this);
73 } 75 }
74 76
75 void PanelBrowserWindowGtk::Init() { 77 void PanelBrowserWindowGtk::Init() {
76 BrowserWindowGtk::Init(); 78 BrowserWindowGtk::Init();
77 79
78 // Keep the window docked to the bottom of the screen on resizes. 80 // Keep the window docked to the bottom of the screen on resizes.
79 gtk_window_set_gravity(window(), GDK_GRAVITY_SOUTH_EAST); 81 gtk_window_set_gravity(window(), GDK_GRAVITY_SOUTH_EAST);
80 82
81 // Keep the window always on top. 83 // Keep the window always on top.
82 gtk_window_set_keep_above(window(), TRUE); 84 gtk_window_set_keep_above(window(), TRUE);
83 85
84 // Show the window on all the virtual desktops. 86 // Show the window on all the virtual desktops.
85 gtk_window_stick(window()); 87 gtk_window_stick(window());
86 88
87 // Do not show an icon in the task bar. Window operations such as close, 89 // 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. 90 // minimize etc. can only be done from the panel UI.
89 gtk_window_set_skip_taskbar_hint(window(), TRUE); 91 gtk_window_set_skip_taskbar_hint(window(), TRUE);
90 92
91 g_signal_connect(titlebar_widget(), "button-press-event", 93 g_signal_connect(titlebar_widget(), "button-press-event",
92 G_CALLBACK(OnTitlebarButtonPressEventThunk), this); 94 G_CALLBACK(OnTitlebarButtonPressEventThunk), this);
93 g_signal_connect(titlebar_widget(), "button-release-event", 95 g_signal_connect(titlebar_widget(), "button-release-event",
94 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this); 96 G_CALLBACK(OnTitlebarButtonReleaseEventThunk), this);
97
98 ui::WorkAreaWatcherX::AddObserver(this);
95 } 99 }
96 100
97 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { 101 bool PanelBrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) {
98 // Since panels are not resizable or movable by the user, we should not 102 // 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, 103 // detect the window edge for behavioral purposes. The edge, if any,
100 // is present only for visual aspects. 104 // is present only for visual aspects.
101 return FALSE; 105 return FALSE;
102 } 106 }
103 107
104 bool PanelBrowserWindowGtk::HandleTitleBarLeftMousePress( 108 bool PanelBrowserWindowGtk::HandleTitleBarLeftMousePress(
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 NULL); 222 NULL);
219 *title = title_with_markup; 223 *title = title_with_markup;
220 g_free(title_escaped); 224 g_free(title_escaped);
221 g_free(title_with_markup); 225 g_free(title_with_markup);
222 return BrowserWindowGtk::PANGO_MARKUP; 226 return BrowserWindowGtk::PANGO_MARKUP;
223 } else { 227 } else {
224 return BrowserWindowGtk::GetWindowTitle(title); 228 return BrowserWindowGtk::GetWindowTitle(title);
225 } 229 }
226 } 230 }
227 231
232 void PanelBrowserWindowGtk::WorkAreaChanged() {
233 panel_->manager()->OnDisplayChanged();
234 }
235
228 void PanelBrowserWindowGtk::ShowPanel() { 236 void PanelBrowserWindowGtk::ShowPanel() {
229 Show(); 237 Show();
230 } 238 }
231 239
232 void PanelBrowserWindowGtk::ShowPanelInactive() { 240 void PanelBrowserWindowGtk::ShowPanelInactive() {
233 ShowInactive(); 241 ShowInactive();
234 } 242 }
235 243
236 gfx::Rect PanelBrowserWindowGtk::GetPanelBounds() const { 244 gfx::Rect PanelBrowserWindowGtk::GetPanelBounds() const {
237 return bounds_; 245 return bounds_;
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 } 736 }
729 } 737 }
730 738
731 bool NativePanelTestingGtk::IsWindowSizeKnown() const { 739 bool NativePanelTestingGtk::IsWindowSizeKnown() const {
732 return panel_browser_window_gtk_->window_size_known_; 740 return panel_browser_window_gtk_->window_size_known_;
733 } 741 }
734 742
735 bool NativePanelTestingGtk::IsAnimatingBounds() const { 743 bool NativePanelTestingGtk::IsAnimatingBounds() const {
736 return panel_browser_window_gtk_->IsAnimatingBounds(); 744 return panel_browser_window_gtk_->IsAnimatingBounds();
737 } 745 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698