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/chromeos/frame/panel_controller.h" | 5 #include "chrome/browser/chromeos/frame/panel_controller.h" |
6 | 6 |
7 #if defined(TOUCH_UI) | 7 #if defined(TOUCH_UI) |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
10 #endif | 10 #endif |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 dragging_(false), | 172 dragging_(false), |
173 client_event_handler_id_(0), | 173 client_event_handler_id_(0), |
174 focused_(false), | 174 focused_(false), |
175 urgent_(false) { | 175 urgent_(false) { |
176 } | 176 } |
177 | 177 |
178 void PanelController::Init(bool initial_focus, | 178 void PanelController::Init(bool initial_focus, |
179 const gfx::Rect& window_bounds, | 179 const gfx::Rect& window_bounds, |
180 XID creator_xid, | 180 XID creator_xid, |
181 WmIpcPanelUserResizeType resize_type) { | 181 WmIpcPanelUserResizeType resize_type) { |
182 #if defined(USE_AURA) | |
183 // TODO(saintlou): Need PureView for panels. | |
184 #else | |
185 gfx::Rect title_bounds(0, 0, window_bounds.width(), kTitleHeight); | 182 gfx::Rect title_bounds(0, 0, window_bounds.width(), kTitleHeight); |
186 | 183 |
187 title_window_ = new views::Widget; | 184 title_window_ = new views::Widget; |
188 views::Widget::InitParams params( | 185 views::Widget::InitParams params( |
189 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 186 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
190 params.transparent = true; | 187 params.transparent = true; |
191 params.bounds = title_bounds; | 188 params.bounds = title_bounds; |
192 title_window_->Init(params); | 189 title_window_->Init(params); |
| 190 |
| 191 #if !defined(USE_AURA) |
193 gtk_widget_set_size_request(title_window_->GetNativeView(), | 192 gtk_widget_set_size_request(title_window_->GetNativeView(), |
194 title_bounds.width(), title_bounds.height()); | 193 title_bounds.width(), title_bounds.height()); |
195 title_ = title_window_->GetNativeView(); | 194 title_ = title_window_->GetNativeView(); |
196 title_xid_ = ui::GetX11WindowFromGtkWidget(title_); | 195 title_xid_ = ui::GetX11WindowFromGtkWidget(title_); |
197 | 196 |
198 WmIpc::instance()->SetWindowType( | 197 WmIpc::instance()->SetWindowType( |
199 title_, | 198 title_, |
200 WM_IPC_WINDOW_CHROME_PANEL_TITLEBAR, | 199 WM_IPC_WINDOW_CHROME_PANEL_TITLEBAR, |
201 NULL); | 200 NULL); |
202 std::vector<int> type_params; | 201 std::vector<int> type_params; |
203 type_params.push_back(title_xid_); | 202 type_params.push_back(title_xid_); |
204 type_params.push_back(expanded_ ? 1 : 0); | 203 type_params.push_back(expanded_ ? 1 : 0); |
205 type_params.push_back(initial_focus ? 1 : 0); | 204 type_params.push_back(initial_focus ? 1 : 0); |
206 type_params.push_back(creator_xid); | 205 type_params.push_back(creator_xid); |
207 type_params.push_back(resize_type); | 206 type_params.push_back(resize_type); |
208 WmIpc::instance()->SetWindowType( | 207 WmIpc::instance()->SetWindowType( |
209 GTK_WIDGET(panel_), | 208 GTK_WIDGET(panel_), |
210 WM_IPC_WINDOW_CHROME_PANEL_CONTENT, | 209 WM_IPC_WINDOW_CHROME_PANEL_CONTENT, |
211 &type_params); | 210 &type_params); |
212 | 211 |
213 client_event_handler_id_ = g_signal_connect( | 212 client_event_handler_id_ = g_signal_connect( |
214 panel_, "client-event", G_CALLBACK(OnPanelClientEvent), this); | 213 panel_, "client-event", G_CALLBACK(OnPanelClientEvent), this); |
| 214 #endif // !USE_AURA |
215 | 215 |
216 title_content_ = new TitleContentView(this); | 216 title_content_ = new TitleContentView(this); |
217 title_window_->SetContentsView(title_content_); | 217 title_window_->SetContentsView(title_content_); |
218 UpdateTitleBar(); | 218 UpdateTitleBar(); |
219 title_window_->Show(); | 219 title_window_->Show(); |
220 #endif | |
221 } | 220 } |
222 | 221 |
223 void PanelController::UpdateTitleBar() { | 222 void PanelController::UpdateTitleBar() { |
224 if (!delegate_ || !title_window_) | 223 if (!delegate_ || !title_window_) |
225 return; | 224 return; |
226 title_content_->title_label()->SetText( | 225 title_content_->title_label()->SetText( |
227 UTF16ToWideHack(delegate_->GetPanelTitle())); | 226 UTF16ToWideHack(delegate_->GetPanelTitle())); |
228 title_content_->title_icon()->SetImage(delegate_->GetPanelIcon()); | 227 title_content_->title_icon()->SetImage(delegate_->GetPanelIcon()); |
229 } | 228 } |
230 | 229 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 views::Button* sender, const views::Event& event) { | 512 views::Button* sender, const views::Event& event) { |
514 if (panel_controller_ && sender == close_button_) | 513 if (panel_controller_ && sender == close_button_) |
515 panel_controller_->OnCloseButtonPressed(); | 514 panel_controller_->OnCloseButtonPressed(); |
516 } | 515 } |
517 | 516 |
518 PanelController::TitleContentView::~TitleContentView() { | 517 PanelController::TitleContentView::~TitleContentView() { |
519 VLOG(1) << "panel: delete " << this; | 518 VLOG(1) << "panel: delete " << this; |
520 } | 519 } |
521 | 520 |
522 } // namespace chromeos | 521 } // namespace chromeos |
OLD | NEW |