| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS 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 "window_manager/panels/panel.h" | 5 #include "window_manager/panels/panel.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 top_left_input_xid_(wm()->CreateInputWindow(Rect(-1, -1, 1, 1), 0)), | 92 top_left_input_xid_(wm()->CreateInputWindow(Rect(-1, -1, 1, 1), 0)), |
| 93 top_right_input_xid_(wm()->CreateInputWindow(Rect(-1, -1, 1, 1), 0)), | 93 top_right_input_xid_(wm()->CreateInputWindow(Rect(-1, -1, 1, 1), 0)), |
| 94 left_input_xid_(wm()->CreateInputWindow(Rect(-1, -1, 1, 1), 0)), | 94 left_input_xid_(wm()->CreateInputWindow(Rect(-1, -1, 1, 1), 0)), |
| 95 right_input_xid_(wm()->CreateInputWindow(Rect(-1, -1, 1, 1), 0)), | 95 right_input_xid_(wm()->CreateInputWindow(Rect(-1, -1, 1, 1), 0)), |
| 96 resizable_(false), | 96 resizable_(false), |
| 97 horizontal_resize_allowed_(true), | 97 horizontal_resize_allowed_(true), |
| 98 vertical_resize_allowed_(true), | 98 vertical_resize_allowed_(true), |
| 99 composited_windows_set_up_(false), | 99 composited_windows_set_up_(false), |
| 100 being_dragged_to_new_position_(false), | 100 being_dragged_to_new_position_(false), |
| 101 resize_drag_xid_(0), | 101 resize_drag_xid_(0), |
| 102 resize_drag_start_x_(0), | |
| 103 resize_drag_start_y_(0), | |
| 104 resize_drag_orig_width_(1), | |
| 105 resize_drag_orig_height_(1), | |
| 106 resize_drag_last_width_(1), | |
| 107 resize_drag_last_height_(1), | |
| 108 event_consumer_registrar_( | 102 event_consumer_registrar_( |
| 109 new EventConsumerRegistrar(wm(), panel_manager)), | 103 new EventConsumerRegistrar(wm(), panel_manager)), |
| 110 transients_( | 104 transients_( |
| 111 new TransientWindowCollection( | 105 new TransientWindowCollection( |
| 112 content_win_, titlebar_win_, true, panel_manager)), | 106 content_win_, titlebar_win_, true, panel_manager)), |
| 113 separator_shadow_( | 107 separator_shadow_( |
| 114 Shadow::Create(wm()->compositor(), Shadow::TYPE_PANEL_SEPARATOR)) { | 108 Shadow::Create(wm()->compositor(), Shadow::TYPE_PANEL_SEPARATOR)) { |
| 115 CHECK(content_win_); | 109 CHECK(content_win_); |
| 116 CHECK(titlebar_win_); | 110 CHECK(titlebar_win_); |
| 117 | 111 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 wm()->xconn()->AddButtonGrabOnWindow(right_input_xid_, 1, event_mask, false); | 145 wm()->xconn()->AddButtonGrabOnWindow(right_input_xid_, 1, event_mask, false); |
| 152 | 146 |
| 153 content_win_->SetVisibility(Window::VISIBILITY_HIDDEN); | 147 content_win_->SetVisibility(Window::VISIBILITY_HIDDEN); |
| 154 titlebar_win_->SetVisibility(Window::VISIBILITY_HIDDEN); | 148 titlebar_win_->SetVisibility(Window::VISIBILITY_HIDDEN); |
| 155 | 149 |
| 156 content_win_->SetShadowType(Shadow::TYPE_PANEL_CONTENT); | 150 content_win_->SetShadowType(Shadow::TYPE_PANEL_CONTENT); |
| 157 titlebar_win_->SetShadowType(Shadow::TYPE_PANEL_TITLEBAR); | 151 titlebar_win_->SetShadowType(Shadow::TYPE_PANEL_TITLEBAR); |
| 158 | 152 |
| 159 // Make sure that the content window's size is within the allowable range. | 153 // Make sure that the content window's size is within the allowable range. |
| 160 UpdateContentWindowSizeLimits(); | 154 UpdateContentWindowSizeLimits(); |
| 161 const int capped_width = | 155 const Size capped_size( |
| 162 min(max(content_win_->client_width(), min_content_width_), | 156 min(max(content_win_->client_width(), min_content_width_), |
| 163 max_content_width_); | 157 max_content_width_), |
| 164 const int capped_height = | |
| 165 min(max(content_win_->client_height(), min_content_height_), | 158 min(max(content_win_->client_height(), min_content_height_), |
| 166 max_content_height_); | 159 max_content_height_)); |
| 167 if (capped_width != content_win_->client_width() || | 160 if (capped_size != content_win_->client_size()) |
| 168 capped_height != content_win_->client_height()) { | 161 content_win_->Resize(capped_size, GRAVITY_NORTHWEST); |
| 169 content_win_->ResizeClient(capped_width, capped_height, GRAVITY_NORTHWEST); | |
| 170 } | |
| 171 | 162 |
| 172 content_win_->CopyClientBoundsToRect(&content_bounds_); | 163 content_win_->CopyClientBoundsToRect(&content_bounds_); |
| 173 titlebar_win_->CopyClientBoundsToRect(&titlebar_bounds_); | 164 titlebar_win_->CopyClientBoundsToRect(&titlebar_bounds_); |
| 174 | 165 |
| 175 if (!kTopCursor) | 166 if (!kTopCursor) |
| 176 InitCursors(wm()->xconn()); | 167 InitCursors(wm()->xconn()); |
| 177 wm()->xconn()->SetWindowCursor(top_input_xid_, kTopCursor); | 168 wm()->xconn()->SetWindowCursor(top_input_xid_, kTopCursor); |
| 178 wm()->xconn()->SetWindowCursor(top_left_input_xid_, kTopLeftCursor); | 169 wm()->xconn()->SetWindowCursor(top_left_input_xid_, kTopLeftCursor); |
| 179 wm()->xconn()->SetWindowCursor(top_right_input_xid_, kTopRightCursor); | 170 wm()->xconn()->SetWindowCursor(top_right_input_xid_, kTopRightCursor); |
| 180 wm()->xconn()->SetWindowCursor(left_input_xid_, kLeftCursor); | 171 wm()->xconn()->SetWindowCursor(left_input_xid_, kLeftCursor); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 windows_out->clear(); | 254 windows_out->clear(); |
| 264 windows_out->reserve(5); | 255 windows_out->reserve(5); |
| 265 windows_out->push_back(top_input_xid_); | 256 windows_out->push_back(top_input_xid_); |
| 266 windows_out->push_back(top_left_input_xid_); | 257 windows_out->push_back(top_left_input_xid_); |
| 267 windows_out->push_back(top_right_input_xid_); | 258 windows_out->push_back(top_right_input_xid_); |
| 268 windows_out->push_back(left_input_xid_); | 259 windows_out->push_back(left_input_xid_); |
| 269 windows_out->push_back(right_input_xid_); | 260 windows_out->push_back(right_input_xid_); |
| 270 } | 261 } |
| 271 | 262 |
| 272 void Panel::HandleInputWindowButtonPress( | 263 void Panel::HandleInputWindowButtonPress( |
| 273 XWindow xid, int x, int y, int button, XTime timestamp) { | 264 XWindow xid, const Point& relative_pos, int button, XTime timestamp) { |
| 274 if (wm()->IsModalWindowFocused()) | 265 if (wm()->IsModalWindowFocused()) |
| 275 return; | 266 return; |
| 276 if (button != 1) | 267 if (button != 1) |
| 277 return; | 268 return; |
| 278 DCHECK(resize_drag_xid_ == 0) | 269 DCHECK(resize_drag_xid_ == 0) |
| 279 << "Panel " << xid_str() << " got button press in " << XidStr(xid) | 270 << "Panel " << xid_str() << " got button press in " << XidStr(xid) |
| 280 << " but already has resize drag XID " << XidStr(resize_drag_xid_); | 271 << " but already has resize drag XID " << XidStr(resize_drag_xid_); |
| 281 | 272 |
| 282 resize_drag_xid_ = xid; | 273 resize_drag_xid_ = xid; |
| 283 resize_drag_start_x_ = x; | 274 resize_drag_start_pos_ = relative_pos; |
| 284 resize_drag_start_y_ = y; | 275 resize_drag_orig_size_ = content_size(); |
| 285 resize_drag_orig_width_ = resize_drag_last_width_ = content_width(); | 276 resize_drag_last_size_ = content_size(); |
| 286 resize_drag_orig_height_ = resize_drag_last_height_ = content_height(); | |
| 287 resize_event_coalescer_.Start(); | 277 resize_event_coalescer_.Start(); |
| 288 | 278 |
| 289 if (!FLAGS_panel_opaque_resize) { | 279 if (!FLAGS_panel_opaque_resize) { |
| 290 DCHECK(!resize_box_.get()); | 280 DCHECK(!resize_box_.get()); |
| 291 resize_box_.reset(new ResizeBox(wm()->compositor())); | 281 resize_box_.reset(new ResizeBox(wm()->compositor())); |
| 292 resize_box_->SetBounds( | 282 resize_box_->SetBounds( |
| 293 Rect(titlebar_x(), titlebar_y(), content_width(), total_height()), 0); | 283 Rect(titlebar_x(), titlebar_y(), content_width(), total_height()), 0); |
| 294 wm()->stage()->AddActor(resize_box_->actor()); | 284 wm()->stage()->AddActor(resize_box_->actor()); |
| 295 resize_box_->actor()->SetOpacity(kResizeBoxOpacity, 0); | 285 resize_box_->actor()->SetOpacity(kResizeBoxOpacity, 0); |
| 296 wm()->stacking_manager()->StackActorAtTopOfLayer( | 286 wm()->stacking_manager()->StackActorAtTopOfLayer( |
| 297 resize_box_->actor(), StackingManager::LAYER_DRAGGED_PANEL); | 287 resize_box_->actor(), StackingManager::LAYER_DRAGGED_PANEL); |
| 298 resize_box_->actor()->Show(); | 288 resize_box_->actor()->Show(); |
| 299 } | 289 } |
| 300 } | 290 } |
| 301 | 291 |
| 302 void Panel::HandleInputWindowButtonRelease( | 292 void Panel::HandleInputWindowButtonRelease( |
| 303 XWindow xid, int x, int y, int button, XTime timestamp) { | 293 XWindow xid, const Point& relative_pos, int button, XTime timestamp) { |
| 304 if (button != 1) | 294 if (button != 1) |
| 305 return; | 295 return; |
| 306 if (xid != resize_drag_xid_) { | 296 if (xid != resize_drag_xid_) { |
| 307 LOG(WARNING) << "Ignoring button release for unexpected input window " | 297 LOG(WARNING) << "Ignoring button release for unexpected input window " |
| 308 << XidStr(xid) << " (currently in resize drag initiated by " | 298 << XidStr(xid) << " (currently in resize drag initiated by " |
| 309 << XidStr(resize_drag_xid_) << ")"; | 299 << XidStr(resize_drag_xid_) << ")"; |
| 310 return; | 300 return; |
| 311 } | 301 } |
| 312 // GrabButton-initiated asynchronous pointer grabs are automatically removed | 302 // GrabButton-initiated asynchronous pointer grabs are automatically removed |
| 313 // by the X server when *all* buttons are released, but we specifically | 303 // by the X server when *all* buttons are released, but we specifically |
| 314 // want the grab to end when the first button is released, to prevent the | 304 // want the grab to end when the first button is released, to prevent the |
| 315 // user from essentially transferring the grab from one button to | 305 // user from essentially transferring the grab from one button to |
| 316 // another: see http://crosbug.com/4267. | 306 // another: see http://crosbug.com/4267. |
| 317 wm()->xconn()->UngrabPointer(false, timestamp); | 307 wm()->xconn()->UngrabPointer(false, timestamp); |
| 318 resize_event_coalescer_.StorePosition(x, y); | 308 resize_event_coalescer_.StorePosition(relative_pos); |
| 319 resize_event_coalescer_.Stop(); | 309 resize_event_coalescer_.Stop(); |
| 320 resize_drag_xid_ = 0; | 310 resize_drag_xid_ = 0; |
| 321 | 311 |
| 322 if (FLAGS_panel_opaque_resize) { | 312 if (FLAGS_panel_opaque_resize) { |
| 323 ConfigureInputWindows(); | 313 ConfigureInputWindows(); |
| 324 } else { | 314 } else { |
| 325 DCHECK(resize_box_.get()); | 315 DCHECK(resize_box_.get()); |
| 326 resize_box_.reset(NULL); | 316 resize_box_.reset(NULL); |
| 327 ResizeContent(resize_drag_last_width_, resize_drag_last_height_, | 317 ResizeContent(resize_drag_last_size_, resize_drag_gravity_, true); |
| 328 resize_drag_gravity_, true); | |
| 329 } | 318 } |
| 330 | 319 |
| 331 // Let the container know about the resize. | 320 // Let the container know about the resize. |
| 332 panel_manager_->HandlePanelResizeByUser(this); | 321 panel_manager_->HandlePanelResizeByUser(this); |
| 333 } | 322 } |
| 334 | 323 |
| 335 void Panel::HandleInputWindowPointerMotion(XWindow xid, int x, int y) { | 324 void Panel::HandleInputWindowPointerMotion(XWindow xid, |
| 325 const Point& relative_pos) { |
| 336 if (xid != resize_drag_xid_) { | 326 if (xid != resize_drag_xid_) { |
| 337 LOG(WARNING) << "Ignoring motion event for unexpected input window " | 327 LOG(WARNING) << "Ignoring motion event for unexpected input window " |
| 338 << XidStr(xid) << " (currently in resize drag initiated by " | 328 << XidStr(xid) << " (currently in resize drag initiated by " |
| 339 << XidStr(resize_drag_xid_) << ")"; | 329 << XidStr(resize_drag_xid_) << ")"; |
| 340 return; | 330 return; |
| 341 } | 331 } |
| 342 resize_event_coalescer_.StorePosition(x, y); | 332 resize_event_coalescer_.StorePosition(relative_pos); |
| 343 } | 333 } |
| 344 | 334 |
| 345 void Panel::Move(int right, int y, int anim_ms) { | 335 void Panel::Move(const Point& top_right_origin, int anim_ms) { |
| 346 titlebar_bounds_.x = right - titlebar_bounds_.width; | 336 titlebar_bounds_.x = top_right_origin.x - titlebar_bounds_.width; |
| 347 titlebar_bounds_.y = y; | 337 titlebar_bounds_.y = top_right_origin.y; |
| 348 content_bounds_.x = right - content_bounds_.width; | 338 content_bounds_.x = top_right_origin.x - content_bounds_.width; |
| 349 content_bounds_.y = y + titlebar_bounds_.height; | 339 content_bounds_.y = top_right_origin.y + titlebar_bounds_.height; |
| 350 | 340 |
| 351 transients_->CloseAllWindows(); | 341 transients_->CloseAllWindows(); |
| 352 | 342 |
| 353 if (can_configure_windows()) { | 343 if (can_configure_windows()) { |
| 354 titlebar_win_->Move(titlebar_bounds_.position(), anim_ms); | 344 titlebar_win_->Move(titlebar_bounds_.position(), anim_ms); |
| 355 content_win_->Move(content_bounds_.position(), anim_ms); | 345 content_win_->Move(content_bounds_.position(), anim_ms); |
| 356 separator_shadow_->Move(content_bounds_.x, content_bounds_.y, anim_ms); | 346 separator_shadow_->Move(content_bounds_.x, content_bounds_.y, anim_ms); |
| 357 if (!composited_windows_set_up_) { | 347 if (!composited_windows_set_up_) { |
| 358 titlebar_win_->SetVisibility(Window::VISIBILITY_SHOWN); | 348 titlebar_win_->SetVisibility(Window::VISIBILITY_SHOWN); |
| 359 content_win_->SetVisibility(Window::VISIBILITY_SHOWN); | 349 content_win_->SetVisibility(Window::VISIBILITY_SHOWN); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 separator_shadow_->MoveY(content_bounds_.y, anim_ms); | 386 separator_shadow_->MoveY(content_bounds_.y, anim_ms); |
| 397 if (!being_dragged_to_new_position_) | 387 if (!being_dragged_to_new_position_) |
| 398 ConfigureInputWindows(); | 388 ConfigureInputWindows(); |
| 399 } | 389 } |
| 400 } | 390 } |
| 401 | 391 |
| 402 void Panel::SetTitlebarWidth(int width) { | 392 void Panel::SetTitlebarWidth(int width) { |
| 403 CHECK(width > 0); | 393 CHECK(width > 0); |
| 404 titlebar_bounds_.resize(width, titlebar_bounds_.height, GRAVITY_NORTHEAST); | 394 titlebar_bounds_.resize(width, titlebar_bounds_.height, GRAVITY_NORTHEAST); |
| 405 if (can_configure_windows()) { | 395 if (can_configure_windows()) { |
| 406 titlebar_win_->ResizeClient( | 396 titlebar_win_->Resize( |
| 407 width, titlebar_win_->client_height(), GRAVITY_NORTHEAST); | 397 Size(width, titlebar_win_->client_height()), GRAVITY_NORTHEAST); |
| 408 } | 398 } |
| 409 } | 399 } |
| 410 | 400 |
| 411 void Panel::SetShadowOpacity(double opacity, int anim_ms) { | 401 void Panel::SetShadowOpacity(double opacity, int anim_ms) { |
| 412 titlebar_win_->SetShadowOpacity(opacity, anim_ms); | 402 titlebar_win_->SetShadowOpacity(opacity, anim_ms); |
| 413 content_win_->SetShadowOpacity(opacity, anim_ms); | 403 content_win_->SetShadowOpacity(opacity, anim_ms); |
| 414 } | 404 } |
| 415 | 405 |
| 416 void Panel::SetResizable(bool resizable) { | 406 void Panel::SetResizable(bool resizable) { |
| 417 if (resizable != resizable_) { | 407 if (resizable != resizable_) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 } | 444 } |
| 455 | 445 |
| 456 WindowManager* Panel::wm() { | 446 WindowManager* Panel::wm() { |
| 457 return panel_manager_->wm(); | 447 return panel_manager_->wm(); |
| 458 } | 448 } |
| 459 | 449 |
| 460 void Panel::TakeFocus(XTime timestamp) { | 450 void Panel::TakeFocus(XTime timestamp) { |
| 461 wm()->FocusWindow(content_win_, timestamp); | 451 wm()->FocusWindow(content_win_, timestamp); |
| 462 } | 452 } |
| 463 | 453 |
| 464 void Panel::ResizeContent(int width, int height, | 454 void Panel::ResizeContent(const Size& size, |
| 465 Gravity gravity, | 455 Gravity gravity, |
| 466 bool configure_input_windows) { | 456 bool configure_input_windows) { |
| 467 DCHECK_GT(width, 0); | 457 DCHECK(!size.empty()); |
| 468 DCHECK_GT(height, 0); | |
| 469 | 458 |
| 470 const int capped_width = | 459 const Size capped_size( |
| 471 min(max(width, min_content_width_), max_content_width_); | 460 min(max(size.width, min_content_width_), max_content_width_), |
| 472 const int capped_height = | 461 min(max(size.height, min_content_height_), max_content_height_)); |
| 473 min(max(height, min_content_height_), max_content_height_); | |
| 474 | 462 |
| 475 if (capped_width != width || capped_height != height) { | 463 if (capped_size != size) { |
| 476 LOG(WARNING) << "Capped resize of panel " << xid_str() << " to " | 464 LOG(WARNING) << "Capped resize of panel " << xid_str() << " to " |
| 477 << capped_width << "x" << capped_height | 465 << capped_size << " (request was for " << size << ")"; |
| 478 << " (request was for " << width << "x" << height << ")"; | |
| 479 width = capped_width; | |
| 480 height = capped_height; | |
| 481 } | 466 } |
| 482 | 467 |
| 483 if (width == content_bounds_.width && height == content_bounds_.height) | 468 if (capped_size == content_bounds_.size()) |
| 484 return; | 469 return; |
| 485 | 470 |
| 486 bool changing_height = (height != content_bounds_.height); | 471 bool changing_height = (capped_size.height != content_bounds_.height); |
| 487 | 472 |
| 488 content_bounds_.resize(width, height, gravity); | 473 content_bounds_.resize(capped_size, gravity); |
| 489 titlebar_bounds_.resize(width, titlebar_bounds_.height, gravity); | 474 titlebar_bounds_.resize(capped_size.width, titlebar_bounds_.height, gravity); |
| 490 if (changing_height) | 475 if (changing_height) |
| 491 titlebar_bounds_.y = content_bounds_.y - titlebar_bounds_.height; | 476 titlebar_bounds_.y = content_bounds_.y - titlebar_bounds_.height; |
| 492 | 477 |
| 493 transients_->CloseAllWindows(); | 478 transients_->CloseAllWindows(); |
| 494 | 479 |
| 495 if (can_configure_windows()) { | 480 if (can_configure_windows()) { |
| 496 content_win_->ResizeClient(width, height, gravity); | 481 content_win_->Resize(capped_size, gravity); |
| 497 titlebar_win_->ResizeClient(width, titlebar_bounds_.height, gravity); | 482 titlebar_win_->Resize(Size(capped_size.width, titlebar_bounds_.height), |
| 483 gravity); |
| 498 separator_shadow_->Move(content_x(), content_y(), 0); | 484 separator_shadow_->Move(content_x(), content_y(), 0); |
| 499 separator_shadow_->Resize(content_width(), 0, 0); | 485 separator_shadow_->Resize(content_width(), 0, 0); |
| 500 | 486 |
| 501 // TODO: This is broken if we start resizing scaled windows. | 487 // TODO: This is broken if we start resizing scaled windows. |
| 502 if (changing_height) | 488 if (changing_height) |
| 503 titlebar_win_->Move(titlebar_bounds_.position(), 0); | 489 titlebar_win_->Move(titlebar_bounds_.position(), 0); |
| 504 } | 490 } |
| 505 | 491 |
| 506 if (configure_input_windows) | 492 if (configure_input_windows) |
| 507 ConfigureInputWindows(); | 493 ConfigureInputWindows(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 523 wm_state[wm()->GetXAtom(ATOM_NET_WM_STATE_FULLSCREEN)] = is_fullscreen_; | 509 wm_state[wm()->GetXAtom(ATOM_NET_WM_STATE_FULLSCREEN)] = is_fullscreen_; |
| 524 content_win_->ChangeWmState(wm_state); | 510 content_win_->ChangeWmState(wm_state); |
| 525 } | 511 } |
| 526 | 512 |
| 527 if (fullscreen) { | 513 if (fullscreen) { |
| 528 wm()->stacking_manager()->StackWindowAtTopOfLayer( | 514 wm()->stacking_manager()->StackWindowAtTopOfLayer( |
| 529 content_win_, | 515 content_win_, |
| 530 StackingManager::LAYER_FULLSCREEN_WINDOW, | 516 StackingManager::LAYER_FULLSCREEN_WINDOW, |
| 531 StackingManager::SHADOW_AT_BOTTOM_OF_LAYER); | 517 StackingManager::SHADOW_AT_BOTTOM_OF_LAYER); |
| 532 content_win_->Move(Point(0, 0), 0); | 518 content_win_->Move(Point(0, 0), 0); |
| 533 content_win_->ResizeClient( | 519 content_win_->Resize(wm()->root_size(), GRAVITY_NORTHWEST); |
| 534 wm()->width(), wm()->height(), GRAVITY_NORTHWEST); | |
| 535 if (!content_win_->IsFocused()) { | 520 if (!content_win_->IsFocused()) { |
| 536 LOG(WARNING) << "Fullscreening unfocused panel " << xid_str() | 521 LOG(WARNING) << "Fullscreening unfocused panel " << xid_str() |
| 537 << ", so automatically giving it the focus"; | 522 << ", so automatically giving it the focus"; |
| 538 wm()->FocusWindow(content_win_, wm()->GetCurrentTimeFromServer()); | 523 wm()->FocusWindow(content_win_, wm()->GetCurrentTimeFromServer()); |
| 539 } | 524 } |
| 540 } else { | 525 } else { |
| 541 content_win_->ResizeClient( | 526 content_win_->Resize(content_bounds_.size(), GRAVITY_NORTHWEST); |
| 542 content_bounds_.width, content_bounds_.height, GRAVITY_NORTHWEST); | |
| 543 content_win_->Move(content_bounds_.position(), 0); | 527 content_win_->Move(content_bounds_.position(), 0); |
| 544 titlebar_win_->ResizeClient( | 528 titlebar_win_->Resize(titlebar_bounds_.size(), GRAVITY_NORTHWEST); |
| 545 titlebar_bounds_.width, titlebar_bounds_.height, GRAVITY_NORTHWEST); | |
| 546 titlebar_win_->Move(titlebar_bounds_.position(), 0); | 529 titlebar_win_->Move(titlebar_bounds_.position(), 0); |
| 547 separator_shadow_->Move(content_x(), content_y(), 0); | 530 separator_shadow_->Move(content_x(), content_y(), 0); |
| 548 separator_shadow_->Resize(content_width(), 0, 0); | 531 separator_shadow_->Resize(content_width(), 0, 0); |
| 549 StackAtTopOfLayer(stacking_layer_); | 532 StackAtTopOfLayer(stacking_layer_); |
| 550 } | 533 } |
| 551 } | 534 } |
| 552 | 535 |
| 553 void Panel::HandleScreenResize() { | 536 void Panel::HandleScreenResize() { |
| 554 if (is_fullscreen_) { | 537 if (is_fullscreen_) { |
| 555 DLOG(INFO) << "Resizing fullscreen panel to " << wm()->width() | 538 DLOG(INFO) << "Resizing fullscreen panel to " << wm()->root_size() |
| 556 << "x" << wm()->height() << " in response to screen resize"; | 539 << " in response to screen resize"; |
| 557 content_win_->ResizeClient( | 540 content_win_->Resize(wm()->root_size(), GRAVITY_NORTHWEST); |
| 558 wm()->width(), wm()->height(), GRAVITY_NORTHWEST); | |
| 559 } | 541 } |
| 560 } | 542 } |
| 561 | 543 |
| 562 void Panel::HandleContentWindowSizeHintsChange() { | 544 void Panel::HandleContentWindowSizeHintsChange() { |
| 563 UpdateContentWindowSizeLimits(); | 545 UpdateContentWindowSizeLimits(); |
| 564 } | 546 } |
| 565 | 547 |
| 566 void Panel::HandleDragStart() { | 548 void Panel::HandleDragStart() { |
| 567 if (being_dragged_to_new_position_) | 549 if (being_dragged_to_new_position_) |
| 568 return; | 550 return; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 states.find(wm()->GetXAtom(ATOM_NET_WM_STATE_MODAL)); | 599 states.find(wm()->GetXAtom(ATOM_NET_WM_STATE_MODAL)); |
| 618 if (it != states.end()) { | 600 if (it != states.end()) { |
| 619 map<XAtom, bool> new_state; | 601 map<XAtom, bool> new_state; |
| 620 new_state[it->first] = it->second; | 602 new_state[it->first] = it->second; |
| 621 win->ChangeWmState(new_state); | 603 win->ChangeWmState(new_state); |
| 622 } | 604 } |
| 623 } | 605 } |
| 624 } | 606 } |
| 625 | 607 |
| 626 void Panel::HandleTransientWindowConfigureRequest( | 608 void Panel::HandleTransientWindowConfigureRequest( |
| 627 Window* win, int req_x, int req_y, int req_width, int req_height) { | 609 Window* win, const Rect& requested_bounds) { |
| 628 DCHECK(win); | 610 DCHECK(win); |
| 629 DCHECK(transients_->ContainsWindow(*win)); | 611 DCHECK(transients_->ContainsWindow(*win)); |
| 630 transients_->HandleConfigureRequest( | 612 transients_->HandleConfigureRequest(win, requested_bounds); |
| 631 win, req_x, req_y, req_width, req_height); | |
| 632 } | 613 } |
| 633 | 614 |
| 634 void Panel::ConfigureInputWindows() { | 615 void Panel::ConfigureInputWindows() { |
| 635 if (!resizable_ || | 616 if (!resizable_ || |
| 636 (!horizontal_resize_allowed_ && !vertical_resize_allowed_)) { | 617 (!horizontal_resize_allowed_ && !vertical_resize_allowed_)) { |
| 637 wm()->xconn()->ConfigureWindowOffscreen(top_input_xid_); | 618 wm()->xconn()->ConfigureWindowOffscreen(top_input_xid_); |
| 638 wm()->xconn()->ConfigureWindowOffscreen(top_left_input_xid_); | 619 wm()->xconn()->ConfigureWindowOffscreen(top_left_input_xid_); |
| 639 wm()->xconn()->ConfigureWindowOffscreen(top_right_input_xid_); | 620 wm()->xconn()->ConfigureWindowOffscreen(top_right_input_xid_); |
| 640 wm()->xconn()->ConfigureWindowOffscreen(left_input_xid_); | 621 wm()->xconn()->ConfigureWindowOffscreen(left_input_xid_); |
| 641 wm()->xconn()->ConfigureWindowOffscreen(right_input_xid_); | 622 wm()->xconn()->ConfigureWindowOffscreen(right_input_xid_); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 // (which is stacked beneath the titlebar) -- we don't want the | 682 // (which is stacked beneath the titlebar) -- we don't want the |
| 702 // corner windows to occlude the titlebar. | 683 // corner windows to occlude the titlebar. |
| 703 wm()->xconn()->StackWindow(top_input_xid_, content_win_->xid(), false); | 684 wm()->xconn()->StackWindow(top_input_xid_, content_win_->xid(), false); |
| 704 wm()->xconn()->StackWindow(top_left_input_xid_, content_win_->xid(), false); | 685 wm()->xconn()->StackWindow(top_left_input_xid_, content_win_->xid(), false); |
| 705 wm()->xconn()->StackWindow(top_right_input_xid_, content_win_->xid(), false); | 686 wm()->xconn()->StackWindow(top_right_input_xid_, content_win_->xid(), false); |
| 706 wm()->xconn()->StackWindow(left_input_xid_, content_win_->xid(), false); | 687 wm()->xconn()->StackWindow(left_input_xid_, content_win_->xid(), false); |
| 707 wm()->xconn()->StackWindow(right_input_xid_, content_win_->xid(), false); | 688 wm()->xconn()->StackWindow(right_input_xid_, content_win_->xid(), false); |
| 708 } | 689 } |
| 709 | 690 |
| 710 void Panel::ApplyResize() { | 691 void Panel::ApplyResize() { |
| 711 int dx = resize_event_coalescer_.x() - resize_drag_start_x_; | 692 int dx = resize_event_coalescer_.x() - resize_drag_start_pos_.x; |
| 712 int dy = resize_event_coalescer_.y() - resize_drag_start_y_; | 693 int dy = resize_event_coalescer_.y() - resize_drag_start_pos_.y; |
| 713 resize_drag_gravity_ = GRAVITY_NORTHWEST; | 694 resize_drag_gravity_ = GRAVITY_NORTHWEST; |
| 714 | 695 |
| 715 if (resize_drag_xid_ == top_input_xid_) { | 696 if (resize_drag_xid_ == top_input_xid_) { |
| 716 resize_drag_gravity_ = GRAVITY_SOUTHWEST; | 697 resize_drag_gravity_ = GRAVITY_SOUTHWEST; |
| 717 dx = 0; | 698 dx = 0; |
| 718 dy *= -1; | 699 dy *= -1; |
| 719 } else if (resize_drag_xid_ == top_left_input_xid_) { | 700 } else if (resize_drag_xid_ == top_left_input_xid_) { |
| 720 resize_drag_gravity_ = GRAVITY_SOUTHEAST; | 701 resize_drag_gravity_ = GRAVITY_SOUTHEAST; |
| 721 dx *= -1; | 702 dx *= -1; |
| 722 dy *= -1; | 703 dy *= -1; |
| 723 } else if (resize_drag_xid_ == top_right_input_xid_) { | 704 } else if (resize_drag_xid_ == top_right_input_xid_) { |
| 724 resize_drag_gravity_ = GRAVITY_SOUTHWEST; | 705 resize_drag_gravity_ = GRAVITY_SOUTHWEST; |
| 725 dy *= -1; | 706 dy *= -1; |
| 726 } else if (resize_drag_xid_ == left_input_xid_) { | 707 } else if (resize_drag_xid_ == left_input_xid_) { |
| 727 resize_drag_gravity_ = GRAVITY_NORTHEAST; | 708 resize_drag_gravity_ = GRAVITY_NORTHEAST; |
| 728 dx *= -1; | 709 dx *= -1; |
| 729 dy = 0; | 710 dy = 0; |
| 730 } else if (resize_drag_xid_ == right_input_xid_) { | 711 } else if (resize_drag_xid_ == right_input_xid_) { |
| 731 resize_drag_gravity_ = GRAVITY_NORTHWEST; | 712 resize_drag_gravity_ = GRAVITY_NORTHWEST; |
| 732 dy = 0; | 713 dy = 0; |
| 733 } | 714 } |
| 734 | 715 |
| 735 resize_drag_last_width_ = | 716 resize_drag_last_size_.reset( |
| 736 min(max(resize_drag_orig_width_ + dx, min_content_width_), | 717 min(max(resize_drag_orig_size_.width + dx, min_content_width_), |
| 737 max_content_width_); | 718 max_content_width_), |
| 738 resize_drag_last_height_ = | 719 min(max(resize_drag_orig_size_.height + dy, min_content_height_), |
| 739 min(max(resize_drag_orig_height_ + dy, min_content_height_), | 720 max_content_height_)); |
| 740 max_content_height_); | |
| 741 | 721 |
| 742 if (FLAGS_panel_opaque_resize) { | 722 if (FLAGS_panel_opaque_resize) { |
| 743 // Avoid reconfiguring the input windows until the end of the resize; moving | 723 // Avoid reconfiguring the input windows until the end of the resize; moving |
| 744 // them now would affect the positions of subsequent motion events from the | 724 // them now would affect the positions of subsequent motion events from the |
| 745 // drag. | 725 // drag. |
| 746 ResizeContent(resize_drag_last_width_, resize_drag_last_height_, | 726 ResizeContent(resize_drag_last_size_, resize_drag_gravity_, false); |
| 747 resize_drag_gravity_, false); | |
| 748 } else { | 727 } else { |
| 749 if (resize_box_.get()) { | 728 if (resize_box_.get()) { |
| 750 int actor_x = titlebar_x(); | 729 int actor_x = titlebar_x(); |
| 751 if (resize_drag_gravity_ == GRAVITY_SOUTHEAST || | 730 if (resize_drag_gravity_ == GRAVITY_SOUTHEAST || |
| 752 resize_drag_gravity_ == GRAVITY_NORTHEAST) { | 731 resize_drag_gravity_ == GRAVITY_NORTHEAST) { |
| 753 actor_x -= (resize_drag_last_width_ - resize_drag_orig_width_); | 732 actor_x -= (resize_drag_last_size_.width - |
| 733 resize_drag_orig_size_.width); |
| 754 } | 734 } |
| 755 int actor_y = titlebar_y(); | 735 int actor_y = titlebar_y(); |
| 756 if (resize_drag_gravity_ == GRAVITY_SOUTHWEST || | 736 if (resize_drag_gravity_ == GRAVITY_SOUTHWEST || |
| 757 resize_drag_gravity_ == GRAVITY_SOUTHEAST) { | 737 resize_drag_gravity_ == GRAVITY_SOUTHEAST) { |
| 758 actor_y -= (resize_drag_last_height_ - resize_drag_orig_height_); | 738 actor_y -= (resize_drag_last_size_.height - |
| 739 resize_drag_orig_size_.height); |
| 759 } | 740 } |
| 760 | 741 |
| 761 Rect bounds(actor_x, actor_y, resize_drag_last_width_, | 742 Rect bounds(actor_x, actor_y, |
| 762 resize_drag_last_height_ + titlebar_height()); | 743 resize_drag_last_size_.width, |
| 744 resize_drag_last_size_.height + titlebar_height()); |
| 763 resize_box_->SetBounds(bounds, 0); | 745 resize_box_->SetBounds(bounds, 0); |
| 764 } | 746 } |
| 765 } | 747 } |
| 766 } | 748 } |
| 767 | 749 |
| 768 bool Panel::SendStateMessageToChrome() { | 750 bool Panel::SendStateMessageToChrome() { |
| 769 WmIpc::Message msg(chromeos::WM_IPC_MESSAGE_CHROME_NOTIFY_PANEL_STATE); | 751 WmIpc::Message msg(chromeos::WM_IPC_MESSAGE_CHROME_NOTIFY_PANEL_STATE); |
| 770 msg.set_param(0, is_expanded_); | 752 msg.set_param(0, is_expanded_); |
| 771 return wm()->wm_ipc()->SendMessage(content_win_->xid(), msg); | 753 return wm()->wm_ipc()->SendMessage(content_win_->xid(), msg); |
| 772 } | 754 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 787 | 769 |
| 788 max_content_width_ = content_win_->size_hints().max_size.width > 0 ? | 770 max_content_width_ = content_win_->size_hints().max_size.width > 0 ? |
| 789 content_win_->size_hints().max_size.width : | 771 content_win_->size_hints().max_size.width : |
| 790 numeric_limits<int>::max(); | 772 numeric_limits<int>::max(); |
| 791 max_content_height_ = content_win_->size_hints().max_size.height > 0 ? | 773 max_content_height_ = content_win_->size_hints().max_size.height > 0 ? |
| 792 content_win_->size_hints().max_size.height : | 774 content_win_->size_hints().max_size.height : |
| 793 numeric_limits<int>::max(); | 775 numeric_limits<int>::max(); |
| 794 } | 776 } |
| 795 | 777 |
| 796 } // namespace window_manager | 778 } // namespace window_manager |
| OLD | NEW |