Chromium Code Reviews| 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); |
|
oshima
2011/09/19 22:31:03
#if !defined(USE_AURA)
Emmanuel Saint-loubert-Bié
2011/09/19 23:26:02
Done.
| |
| 193 gtk_widget_set_size_request(title_window_->GetNativeView(), | 190 gtk_widget_set_size_request(title_window_->GetNativeView(), |
| 194 title_bounds.width(), title_bounds.height()); | 191 title_bounds.width(), title_bounds.height()); |
| 195 title_ = title_window_->GetNativeView(); | 192 title_ = title_window_->GetNativeView(); |
| 196 title_xid_ = ui::GetX11WindowFromGtkWidget(title_); | 193 title_xid_ = ui::GetX11WindowFromGtkWidget(title_); |
| 197 | 194 |
| 198 WmIpc::instance()->SetWindowType( | 195 WmIpc::instance()->SetWindowType( |
| 199 title_, | 196 title_, |
| 200 WM_IPC_WINDOW_CHROME_PANEL_TITLEBAR, | 197 WM_IPC_WINDOW_CHROME_PANEL_TITLEBAR, |
| 201 NULL); | 198 NULL); |
| 202 std::vector<int> type_params; | 199 std::vector<int> type_params; |
| 203 type_params.push_back(title_xid_); | 200 type_params.push_back(title_xid_); |
| 204 type_params.push_back(expanded_ ? 1 : 0); | 201 type_params.push_back(expanded_ ? 1 : 0); |
| 205 type_params.push_back(initial_focus ? 1 : 0); | 202 type_params.push_back(initial_focus ? 1 : 0); |
| 206 type_params.push_back(creator_xid); | 203 type_params.push_back(creator_xid); |
| 207 type_params.push_back(resize_type); | 204 type_params.push_back(resize_type); |
| 208 WmIpc::instance()->SetWindowType( | 205 WmIpc::instance()->SetWindowType( |
| 209 GTK_WIDGET(panel_), | 206 GTK_WIDGET(panel_), |
| 210 WM_IPC_WINDOW_CHROME_PANEL_CONTENT, | 207 WM_IPC_WINDOW_CHROME_PANEL_CONTENT, |
| 211 &type_params); | 208 &type_params); |
| 212 | 209 |
| 213 client_event_handler_id_ = g_signal_connect( | 210 client_event_handler_id_ = g_signal_connect( |
| 214 panel_, "client-event", G_CALLBACK(OnPanelClientEvent), this); | 211 panel_, "client-event", G_CALLBACK(OnPanelClientEvent), this); |
| 215 | 212 |
|
oshima
2011/09/19 22:31:03
#end
exclude OnPanelClientEvent for AURA.
Emmanuel Saint-loubert-Bié
2011/09/19 23:26:02
Done.
| |
| 216 title_content_ = new TitleContentView(this); | 213 title_content_ = new TitleContentView(this); |
| 217 title_window_->SetContentsView(title_content_); | 214 title_window_->SetContentsView(title_content_); |
| 218 UpdateTitleBar(); | 215 UpdateTitleBar(); |
| 219 title_window_->Show(); | 216 title_window_->Show(); |
| 220 #endif | |
| 221 } | 217 } |
| 222 | 218 |
| 223 void PanelController::UpdateTitleBar() { | 219 void PanelController::UpdateTitleBar() { |
| 224 if (!delegate_ || !title_window_) | 220 if (!delegate_ || !title_window_) |
| 225 return; | 221 return; |
| 226 title_content_->title_label()->SetText( | 222 title_content_->title_label()->SetText( |
| 227 UTF16ToWideHack(delegate_->GetPanelTitle())); | 223 UTF16ToWideHack(delegate_->GetPanelTitle())); |
| 228 title_content_->title_icon()->SetImage(delegate_->GetPanelIcon()); | 224 title_content_->title_icon()->SetImage(delegate_->GetPanelIcon()); |
| 229 } | 225 } |
| 230 | 226 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 261 // titlebar window. See WM_IPC_MESSAGE_WM_NOTIFY_PANEL_DRAGGED's declaration | 257 // titlebar window. See WM_IPC_MESSAGE_WM_NOTIFY_PANEL_DRAGGED's declaration |
| 262 // for details. | 258 // for details. |
| 263 gint title_width = 1; | 259 gint title_width = 1; |
| 264 gtk_window_get_size(GTK_WINDOW(title_), &title_width, NULL); | 260 gtk_window_get_size(GTK_WINDOW(title_), &title_width, NULL); |
| 265 | 261 |
| 266 mouse_down_ = true; | 262 mouse_down_ = true; |
| 267 mouse_down_offset_x_ = event.x() - title_width; | 263 mouse_down_offset_x_ = event.x() - title_width; |
| 268 mouse_down_offset_y_ = event.y(); | 264 mouse_down_offset_y_ = event.y(); |
| 269 dragging_ = false; | 265 dragging_ = false; |
| 270 | 266 |
| 271 #if !defined(TOUCH_UI) && !defined(USE_AURA) | 267 #if !defined(TOUCH_UI) |
|
oshima
2011/09/19 22:31:03
USE_ONLY_PURE_VIEWS (or TOOLKIT_USES_GTK after sad
| |
| 272 const GdkEvent* gdk_event = event.native_event(); | 268 const GdkEvent* gdk_event = event.native_event(); |
| 273 GdkEventButton last_button_event = gdk_event->button; | 269 GdkEventButton last_button_event = gdk_event->button; |
| 274 mouse_down_abs_x_ = last_button_event.x_root; | 270 mouse_down_abs_x_ = last_button_event.x_root; |
| 275 mouse_down_abs_y_ = last_button_event.y_root; | 271 mouse_down_abs_y_ = last_button_event.y_root; |
| 276 #else | 272 #else |
| 277 const XEvent* xev = event.native_event_2(); | 273 const XEvent* xev = event.native_event_2(); |
| 278 gfx::Point abs_location = RootLocationFromXEvent(xev); | 274 gfx::Point abs_location = RootLocationFromXEvent(xev); |
| 279 mouse_down_abs_x_ = abs_location.x(); | 275 mouse_down_abs_x_ = abs_location.x(); |
| 280 mouse_down_abs_y_ = abs_location.y(); | 276 mouse_down_abs_y_ = abs_location.y(); |
| 281 #endif | 277 #endif |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 views::Button* sender, const views::Event& event) { | 509 views::Button* sender, const views::Event& event) { |
| 514 if (panel_controller_ && sender == close_button_) | 510 if (panel_controller_ && sender == close_button_) |
| 515 panel_controller_->OnCloseButtonPressed(); | 511 panel_controller_->OnCloseButtonPressed(); |
| 516 } | 512 } |
| 517 | 513 |
| 518 PanelController::TitleContentView::~TitleContentView() { | 514 PanelController::TitleContentView::~TitleContentView() { |
| 519 VLOG(1) << "panel: delete " << this; | 515 VLOG(1) << "panel: delete " << this; |
| 520 } | 516 } |
| 521 | 517 |
| 522 } // namespace chromeos | 518 } // namespace chromeos |
| OLD | NEW |