| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 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_bar.h" | 5 #include "window_manager/panels/panel_bar.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include <gflags/gflags.h> | 9 #include <gflags/gflags.h> |
| 10 | 10 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 panel->StackAtTopOfLayer(source == PANEL_SOURCE_DRAGGED ? | 185 panel->StackAtTopOfLayer(source == PANEL_SOURCE_DRAGGED ? |
| 186 StackingManager::LAYER_DRAGGED_PANEL : | 186 StackingManager::LAYER_DRAGGED_PANEL : |
| 187 StackingManager::LAYER_PACKED_PANEL_IN_BAR); | 187 StackingManager::LAYER_PACKED_PANEL_IN_BAR); |
| 188 | 188 |
| 189 const int final_y = ComputePanelY(*panel); | 189 const int final_y = ComputePanelY(*panel); |
| 190 | 190 |
| 191 // Now move the panel to its final position. | 191 // Now move the panel to its final position. |
| 192 switch (source) { | 192 switch (source) { |
| 193 case PANEL_SOURCE_NEW: | 193 case PANEL_SOURCE_NEW: |
| 194 // Make newly-created panels slide in from the bottom of the screen. | 194 // Make newly-created panels slide in from the bottom of the screen. |
| 195 panel->Move(info->desired_right, wm()->height(), 0); | 195 panel->Move(Point(info->desired_right, wm()->height()), 0); |
| 196 panel->MoveY(final_y, kPanelStateAnimMs); | 196 panel->MoveY(final_y, kPanelStateAnimMs); |
| 197 break; | 197 break; |
| 198 case PANEL_SOURCE_DRAGGED: | 198 case PANEL_SOURCE_DRAGGED: |
| 199 panel->MoveY(final_y, 0); | 199 panel->MoveY(final_y, 0); |
| 200 break; | 200 break; |
| 201 case PANEL_SOURCE_DROPPED: | 201 case PANEL_SOURCE_DROPPED: |
| 202 panel->Move(info->desired_right, final_y, kDroppedPanelAnimMs); | 202 panel->Move(Point(info->desired_right, final_y), kDroppedPanelAnimMs); |
| 203 break; | 203 break; |
| 204 default: | 204 default: |
| 205 NOTREACHED() << "Unknown panel source " << source; | 205 NOTREACHED() << "Unknown panel source " << source; |
| 206 } | 206 } |
| 207 | 207 |
| 208 ArrangePanels(true, NULL); | 208 ArrangePanels(true, NULL); |
| 209 panel->SetResizable(panel->is_expanded()); | 209 panel->SetResizable(panel->is_expanded()); |
| 210 | 210 |
| 211 // If this is a new panel and it requested the focus, or it was already | 211 // If this is a new panel and it requested the focus, or it was already |
| 212 // focused (e.g. it was focused when it got detached, and now it's being | 212 // focused (e.g. it was focused when it got detached, and now it's being |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 if (dragged_panel_ && !(GetPanelInfoOrDie(dragged_panel_)->is_floating)) | 268 if (dragged_panel_ && !(GetPanelInfoOrDie(dragged_panel_)->is_floating)) |
| 269 if (ReorderPanelInVector(dragged_panel_, &packed_panels_)) | 269 if (ReorderPanelInVector(dragged_panel_, &packed_panels_)) |
| 270 ArrangePanels(false, NULL); | 270 ArrangePanels(false, NULL); |
| 271 | 271 |
| 272 // If this was the last collapsed panel, move the input window offscreen. | 272 // If this was the last collapsed panel, move the input window offscreen. |
| 273 if (was_collapsed && GetNumCollapsedPanels() == 0) | 273 if (was_collapsed && GetNumCollapsedPanels() == 0) |
| 274 ConfigureShowCollapsedPanelsInputWindow(false); | 274 ConfigureShowCollapsedPanelsInputWindow(false); |
| 275 } | 275 } |
| 276 | 276 |
| 277 bool PanelBar::ShouldAddDraggedPanel(const Panel* panel, | 277 bool PanelBar::ShouldAddDraggedPanel(const Panel* panel, |
| 278 int drag_x, | 278 const Point& drag_pos) { |
| 279 int drag_y) { | 279 return drag_pos.y + panel->total_height() > |
| 280 return drag_y + panel->total_height() > | |
| 281 wm()->height() - kPanelAttachThresholdPixels; | 280 wm()->height() - kPanelAttachThresholdPixels; |
| 282 } | 281 } |
| 283 | 282 |
| 284 void PanelBar::HandleInputWindowButtonPress(XWindow xid, | 283 void PanelBar::HandleInputWindowButtonPress(XWindow xid, |
| 285 int x, int y, | 284 const Point& relative_pos, |
| 286 int x_root, int y_root, | 285 const Point& absolute_pos, |
| 287 int button, | 286 int button, |
| 288 XTime timestamp) { | 287 XTime timestamp) { |
| 289 if (wm()->IsModalWindowFocused()) | 288 if (wm()->IsModalWindowFocused()) |
| 290 return; | 289 return; |
| 291 | 290 |
| 292 CHECK(xid == anchor_input_xid_); | 291 CHECK(xid == anchor_input_xid_); |
| 293 if (button != 1) | 292 if (button != 1) |
| 294 return; | 293 return; |
| 295 | 294 |
| 296 // Destroy the anchor and collapse the corresponding panel. | 295 // Destroy the anchor and collapse the corresponding panel. |
| 297 DLOG(INFO) << "Got button press in anchor window"; | 296 DLOG(INFO) << "Got button press in anchor window"; |
| 298 Panel* panel = anchor_panel_; | 297 Panel* panel = anchor_panel_; |
| 299 DestroyAnchor(); | 298 DestroyAnchor(); |
| 300 if (panel) | 299 if (panel) |
| 301 CollapsePanel(panel, kPanelStateAnimMs); | 300 CollapsePanel(panel, kPanelStateAnimMs); |
| 302 else | 301 else |
| 303 LOG(WARNING) << "Anchor panel no longer exists"; | 302 LOG(WARNING) << "Anchor panel no longer exists"; |
| 304 } | 303 } |
| 305 | 304 |
| 306 void PanelBar::HandleInputWindowPointerEnter(XWindow xid, | 305 void PanelBar::HandleInputWindowPointerEnter(XWindow xid, |
| 307 int x, int y, | 306 const Point& relative_pos, |
| 308 int x_root, int y_root, | 307 const Point& absolute_pos, |
| 309 XTime timestamp) { | 308 XTime timestamp) { |
| 310 if (xid == show_collapsed_panels_input_xid_) { | 309 if (xid == show_collapsed_panels_input_xid_) { |
| 311 DLOG(INFO) << "Got mouse enter in show-collapsed-panels window"; | 310 DLOG(INFO) << "Got mouse enter in show-collapsed-panels window"; |
| 312 if (x_root >= wm()->width() - packed_panel_width_) { | 311 if (absolute_pos.x >= wm()->width() - packed_panel_width_) { |
| 313 // If the user moves the pointer down quickly to the bottom of the | 312 // If the user moves the pointer down quickly to the bottom of the |
| 314 // screen, it's possible that it could end up below a collapsed panel | 313 // screen, it's possible that it could end up below a collapsed panel |
| 315 // without us having received an enter event in the panel's titlebar. | 314 // without us having received an enter event in the panel's titlebar. |
| 316 // Show the panels immediately in this case. | 315 // Show the panels immediately in this case. |
| 317 ShowCollapsedPanels(); | 316 ShowCollapsedPanels(); |
| 318 } else { | 317 } else { |
| 319 // Otherwise, set up a timeout to show the panels if we're not already | 318 // Otherwise, set up a timeout to show the panels if we're not already |
| 320 // doing so. | 319 // doing so. |
| 321 if (collapsed_panel_state_ != COLLAPSED_PANEL_STATE_SHOWN && | 320 if (collapsed_panel_state_ != COLLAPSED_PANEL_STATE_SHOWN && |
| 322 collapsed_panel_state_ != COLLAPSED_PANEL_STATE_WAITING_TO_SHOW) { | 321 collapsed_panel_state_ != COLLAPSED_PANEL_STATE_WAITING_TO_SHOW) { |
| 323 collapsed_panel_state_ = COLLAPSED_PANEL_STATE_WAITING_TO_SHOW; | 322 collapsed_panel_state_ = COLLAPSED_PANEL_STATE_WAITING_TO_SHOW; |
| 324 DCHECK_EQ(show_collapsed_panels_timeout_id_, -1); | 323 DCHECK_EQ(show_collapsed_panels_timeout_id_, -1); |
| 325 show_collapsed_panels_timeout_id_ = | 324 show_collapsed_panels_timeout_id_ = |
| 326 wm()->event_loop()->AddTimeout( | 325 wm()->event_loop()->AddTimeout( |
| 327 NewPermanentCallback( | 326 NewPermanentCallback( |
| 328 this, &PanelBar::HandleShowCollapsedPanelsTimeout), | 327 this, &PanelBar::HandleShowCollapsedPanelsTimeout), |
| 329 kShowCollapsedPanelsDelayMs, 0); | 328 kShowCollapsedPanelsDelayMs, 0); |
| 330 } | 329 } |
| 331 } | 330 } |
| 332 } | 331 } |
| 333 } | 332 } |
| 334 | 333 |
| 335 void PanelBar::HandleInputWindowPointerLeave(XWindow xid, | 334 void PanelBar::HandleInputWindowPointerLeave(XWindow xid, |
| 336 int x, int y, | 335 const Point& relative_pos, |
| 337 int x_root, int y_root, | 336 const Point& absolute_pos, |
| 338 XTime timestamp) { | 337 XTime timestamp) { |
| 339 if (xid == show_collapsed_panels_input_xid_) { | 338 if (xid == show_collapsed_panels_input_xid_) { |
| 340 DLOG(INFO) << "Got mouse leave in show-collapsed-panels window"; | 339 DLOG(INFO) << "Got mouse leave in show-collapsed-panels window"; |
| 341 if (collapsed_panel_state_ == COLLAPSED_PANEL_STATE_WAITING_TO_SHOW) { | 340 if (collapsed_panel_state_ == COLLAPSED_PANEL_STATE_WAITING_TO_SHOW) { |
| 342 collapsed_panel_state_ = COLLAPSED_PANEL_STATE_HIDDEN; | 341 collapsed_panel_state_ = COLLAPSED_PANEL_STATE_HIDDEN; |
| 343 DisableShowCollapsedPanelsTimeout(); | 342 DisableShowCollapsedPanelsTimeout(); |
| 344 } | 343 } |
| 345 } | 344 } |
| 346 } | 345 } |
| 347 | 346 |
| 348 void PanelBar::HandlePanelButtonPress( | 347 void PanelBar::HandlePanelButtonPress(Panel* panel, |
| 349 Panel* panel, int button, XTime timestamp) { | 348 int button, |
| 349 XTime timestamp) { |
| 350 if (wm()->IsModalWindowFocused()) | 350 if (wm()->IsModalWindowFocused()) |
| 351 return; | 351 return; |
| 352 DCHECK(panel); | 352 DCHECK(panel); |
| 353 DLOG(INFO) << "Got button press in panel " << panel->xid_str() | 353 DLOG(INFO) << "Got button press in panel " << panel->xid_str() |
| 354 << "; giving it the focus"; | 354 << "; giving it the focus"; |
| 355 // Get rid of the passive button grab, and then ungrab the pointer | 355 // Get rid of the passive button grab, and then ungrab the pointer |
| 356 // and replay events so the panel will get a copy of the click. | 356 // and replay events so the panel will get a copy of the click. |
| 357 FocusPanel(panel, timestamp); | 357 FocusPanel(panel, timestamp); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void PanelBar::HandlePanelTitlebarPointerEnter(Panel* panel, XTime timestamp) { | 360 void PanelBar::HandlePanelTitlebarPointerEnter(Panel* panel, XTime timestamp) { |
| 361 DCHECK(panel); | 361 DCHECK(panel); |
| 362 DLOG(INFO) << "Got pointer enter in panel " << panel->xid_str() | 362 DLOG(INFO) << "Got pointer enter in panel " << panel->xid_str() |
| 363 << "'s titlebar"; | 363 << "'s titlebar"; |
| 364 if (collapsed_panel_state_ != COLLAPSED_PANEL_STATE_SHOWN && | 364 if (collapsed_panel_state_ != COLLAPSED_PANEL_STATE_SHOWN && |
| 365 !panel->is_expanded()) { | 365 !panel->is_expanded()) { |
| 366 ShowCollapsedPanels(); | 366 ShowCollapsedPanels(); |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 | 369 |
| 370 void PanelBar::HandleSetPanelStateMessage(Panel* panel, bool expand) { | 370 void PanelBar::HandleSetPanelStateMessage(Panel* panel, bool expand) { |
| 371 DCHECK(panel); | 371 DCHECK(panel); |
| 372 if (expand) | 372 if (expand) |
| 373 ExpandPanel(panel, true, kPanelStateAnimMs); | 373 ExpandPanel(panel, true, kPanelStateAnimMs); |
| 374 else | 374 else |
| 375 CollapsePanel(panel, kPanelStateAnimMs); | 375 CollapsePanel(panel, kPanelStateAnimMs); |
| 376 } | 376 } |
| 377 | 377 |
| 378 bool PanelBar::HandleNotifyPanelDraggedMessage(Panel* panel, | 378 bool PanelBar::HandleNotifyPanelDraggedMessage(Panel* panel, |
| 379 int drag_x, | 379 const Point& drag_pos) { |
| 380 int drag_y) { | |
| 381 DCHECK(panel); | 380 DCHECK(panel); |
| 382 DLOG(INFO) << "Notified about drag of panel " << panel->xid_str() | 381 DLOG(INFO) << "Notified about drag of panel " << panel->xid_str() |
| 383 << " to (" << drag_x << ", " << drag_y << ")"; | 382 << " to " << drag_pos; |
| 384 | 383 |
| 385 if (FLAGS_allow_panels_to_be_detached) { | 384 if (FLAGS_allow_panels_to_be_detached) { |
| 386 const int y_threshold = | 385 const int y_threshold = |
| 387 wm()->height() - panel->total_height() - kPanelDetachThresholdPixels; | 386 wm()->height() - panel->total_height() - kPanelDetachThresholdPixels; |
| 388 if (drag_y <= y_threshold) | 387 if (drag_pos.y <= y_threshold) |
| 389 return false; | 388 return false; |
| 390 } | 389 } |
| 391 | 390 |
| 392 if (dragged_panel_ != panel) { | 391 if (dragged_panel_ != panel) { |
| 393 if (dragged_panel_) { | 392 if (dragged_panel_) { |
| 394 LOG(WARNING) << "Abandoning dragged panel " << dragged_panel_->xid_str() | 393 LOG(WARNING) << "Abandoning dragged panel " << dragged_panel_->xid_str() |
| 395 << " in favor of " << panel->xid_str(); | 394 << " in favor of " << panel->xid_str(); |
| 396 HandlePanelDragComplete(dragged_panel_); | 395 HandlePanelDragComplete(dragged_panel_); |
| 397 } | 396 } |
| 398 | 397 |
| 399 DLOG(INFO) << "Starting drag of panel " << panel->xid_str(); | 398 DLOG(INFO) << "Starting drag of panel " << panel->xid_str(); |
| 400 dragged_panel_ = panel; | 399 dragged_panel_ = panel; |
| 401 dragging_panel_horizontally_ = | 400 dragging_panel_horizontally_ = |
| 402 (abs(drag_x - panel->right()) > abs(drag_y - panel->titlebar_y())); | 401 (abs(drag_pos.x - panel->right()) > |
| 402 abs(drag_pos.y - panel->titlebar_y())); |
| 403 panel->StackAtTopOfLayer(StackingManager::LAYER_DRAGGED_PANEL); | 403 panel->StackAtTopOfLayer(StackingManager::LAYER_DRAGGED_PANEL); |
| 404 } | 404 } |
| 405 | 405 |
| 406 if (dragging_panel_horizontally_) { | 406 if (dragging_panel_horizontally_) { |
| 407 panel->MoveX(drag_x, 0); | 407 panel->MoveX(drag_pos.x, 0); |
| 408 PanelInfo* info = GetPanelInfoOrDie(panel); | 408 PanelInfo* info = GetPanelInfoOrDie(panel); |
| 409 | 409 |
| 410 // Make sure that the panel is in the correct vector (floating vs. | 410 // Make sure that the panel is in the correct vector (floating vs. |
| 411 // packed) for its current position. | 411 // packed) for its current position. |
| 412 | 412 |
| 413 // We want to find the total width of all packed panels (except the | 413 // We want to find the total width of all packed panels (except the |
| 414 // dragged panel, if it's packed), plus the padding that would go to | 414 // dragged panel, if it's packed), plus the padding that would go to |
| 415 // the right of the dragged panel (which differs depending on whether | 415 // the right of the dragged panel (which differs depending on whether |
| 416 // there are other packed panels or not). | 416 // there are other packed panels or not). |
| 417 int packed_width_with_padding = packed_panel_width_; | 417 int packed_width_with_padding = packed_panel_width_; |
| 418 if (!info->is_floating) { | 418 if (!info->is_floating) { |
| 419 packed_width_with_padding -= panel->width(); | 419 packed_width_with_padding -= panel->width(); |
| 420 } else { | 420 } else { |
| 421 packed_width_with_padding += | 421 packed_width_with_padding += |
| 422 packed_panels_.empty() ? kRightPaddingPixels : kPixelsBetweenPanels; | 422 packed_panels_.empty() ? kRightPaddingPixels : kPixelsBetweenPanels; |
| 423 } | 423 } |
| 424 | 424 |
| 425 const int floating_threshold = | 425 const int floating_threshold = |
| 426 wm()->width() - packed_width_with_padding - | 426 wm()->width() - packed_width_with_padding - |
| 427 kFloatingPanelThresholdPixels; | 427 kFloatingPanelThresholdPixels; |
| 428 | 428 |
| 429 bool moved_to_other_vector = false; | 429 bool moved_to_other_vector = false; |
| 430 if (drag_x < floating_threshold) { | 430 if (drag_pos.x < floating_threshold) { |
| 431 moved_to_other_vector = MovePanelToFloatingVector(panel, info); | 431 moved_to_other_vector = MovePanelToFloatingVector(panel, info); |
| 432 info->desired_right = drag_x; | 432 info->desired_right = drag_pos.x; |
| 433 ArrangePanels(false, NULL); | 433 ArrangePanels(false, NULL); |
| 434 } else { | 434 } else { |
| 435 moved_to_other_vector = MovePanelToPackedVector(panel, info); | 435 moved_to_other_vector = MovePanelToPackedVector(panel, info); |
| 436 ArrangePanels(false, NULL); | 436 ArrangePanels(false, NULL); |
| 437 } | 437 } |
| 438 | 438 |
| 439 if (!moved_to_other_vector) { | 439 if (!moved_to_other_vector) { |
| 440 // If we didn't move the panel to the other vector, then just make | 440 // If we didn't move the panel to the other vector, then just make |
| 441 // sure that it's in the correct position within its current vector. | 441 // sure that it's in the correct position within its current vector. |
| 442 PanelVector* panel_vector = | 442 PanelVector* panel_vector = |
| 443 info->is_floating ? &floating_panels_ : &packed_panels_; | 443 info->is_floating ? &floating_panels_ : &packed_panels_; |
| 444 if (ReorderPanelInVector(panel, panel_vector) && !info->is_floating) | 444 if (ReorderPanelInVector(panel, panel_vector) && !info->is_floating) |
| 445 ArrangePanels(false, NULL); | 445 ArrangePanels(false, NULL); |
| 446 } | 446 } |
| 447 | 447 |
| 448 } else { | 448 } else { |
| 449 // If we're dragging vertically, cap the Y value between the lowest and | 449 // If we're dragging vertically, cap the Y value between the lowest and |
| 450 // highest positions that the panel can take while in the bar. | 450 // highest positions that the panel can take while in the bar. |
| 451 const int capped_y = | 451 const int capped_y = |
| 452 max(min(drag_y, wm()->height() - panel->titlebar_height()), | 452 max(min(drag_pos.y, wm()->height() - panel->titlebar_height()), |
| 453 wm()->height() - panel->total_height()); | 453 wm()->height() - panel->total_height()); |
| 454 panel->MoveY(capped_y, 0); | 454 panel->MoveY(capped_y, 0); |
| 455 } | 455 } |
| 456 return true; | 456 return true; |
| 457 } | 457 } |
| 458 | 458 |
| 459 void PanelBar::HandleNotifyPanelDragCompleteMessage(Panel* panel) { | 459 void PanelBar::HandleNotifyPanelDragCompleteMessage(Panel* panel) { |
| 460 DCHECK(panel); | 460 DCHECK(panel); |
| 461 HandlePanelDragComplete(panel); | 461 HandlePanelDragComplete(panel); |
| 462 } | 462 } |
| 463 | 463 |
| 464 void PanelBar::HandleFocusPanelMessage(Panel* panel, XTime timestamp) { | 464 void PanelBar::HandleFocusPanelMessage(Panel* panel, XTime timestamp) { |
| 465 DCHECK(panel); | 465 DCHECK(panel); |
| 466 if (!panel->is_expanded()) | 466 if (!panel->is_expanded()) |
| 467 ExpandPanel(panel, false, kPanelStateAnimMs); | 467 ExpandPanel(panel, false, kPanelStateAnimMs); |
| 468 FocusPanel(panel, timestamp); | 468 FocusPanel(panel, timestamp); |
| 469 } | 469 } |
| 470 | 470 |
| 471 void PanelBar::HandlePanelResizeRequest(Panel* panel, | 471 void PanelBar::HandlePanelResizeRequest(Panel* panel, |
| 472 int req_width, int req_height) { | 472 const Size& requested_size) { |
| 473 DCHECK(panel); | 473 DCHECK(panel); |
| 474 panel->ResizeContent(req_width, req_height, GRAVITY_SOUTHEAST, true); | 474 panel->ResizeContent(requested_size, GRAVITY_SOUTHEAST, true); |
| 475 ArrangePanels(true, NULL); | 475 ArrangePanels(true, NULL); |
| 476 } | 476 } |
| 477 | 477 |
| 478 void PanelBar::HandlePanelResizeByUser(Panel* panel) { | 478 void PanelBar::HandlePanelResizeByUser(Panel* panel) { |
| 479 DCHECK(panel); | 479 DCHECK(panel); |
| 480 Panel* fixed_floating_panel = NULL; | 480 Panel* fixed_floating_panel = NULL; |
| 481 PanelInfo* info = GetPanelInfoOrDie(panel); | 481 PanelInfo* info = GetPanelInfoOrDie(panel); |
| 482 if (info->is_floating) { | 482 if (info->is_floating) { |
| 483 info->desired_right = panel->right(); | 483 info->desired_right = panel->right(); |
| 484 fixed_floating_panel = panel; | 484 fixed_floating_panel = panel; |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 if (info->desired_right - panel->width() < left_edge) | 876 if (info->desired_right - panel->width() < left_edge) |
| 877 info->desired_right = left_edge + panel->width(); | 877 info->desired_right = left_edge + panel->width(); |
| 878 left_edge = info->desired_right + kPixelsBetweenPanels; | 878 left_edge = info->desired_right + kPixelsBetweenPanels; |
| 879 } | 879 } |
| 880 } | 880 } |
| 881 | 881 |
| 882 void PanelBar::CreateAnchor(Panel* panel) { | 882 void PanelBar::CreateAnchor(Panel* panel) { |
| 883 Point pointer_pos; | 883 Point pointer_pos; |
| 884 wm()->xconn()->QueryPointerPosition(&pointer_pos); | 884 wm()->xconn()->QueryPointerPosition(&pointer_pos); |
| 885 | 885 |
| 886 const int width = anchor_actor_->GetWidth(); | 886 const Rect anchor_bounds( |
| 887 const int height = anchor_actor_->GetHeight(); | 887 min(max(static_cast<int>(pointer_pos.x - 0.5 * anchor_actor_->GetWidth()), |
| 888 const int x = min(max(static_cast<int>(pointer_pos.x - 0.5 * width), 0), | 888 0), |
| 889 wm()->width() - width); | 889 wm()->width() - anchor_actor_->GetWidth()), |
| 890 const int y = wm()->height() - height; | 890 wm()->height() - anchor_actor_->GetHeight(), |
| 891 | 891 anchor_actor_->GetWidth(), |
| 892 wm()->ConfigureInputWindow(anchor_input_xid_, Rect(x, y, width, height)); | 892 anchor_actor_->GetHeight()); |
| 893 wm()->ConfigureInputWindow(anchor_input_xid_, anchor_bounds); |
| 893 anchor_panel_ = panel; | 894 anchor_panel_ = panel; |
| 894 anchor_actor_->Move(x, y, 0); | 895 anchor_actor_->Move(anchor_bounds.x, anchor_bounds.y, 0); |
| 895 anchor_actor_->SetOpacity(1, kAnchorFadeAnimMs); | 896 anchor_actor_->SetOpacity(1, kAnchorFadeAnimMs); |
| 896 | 897 |
| 897 // We might not get a LeaveNotify event*, so we also poll the pointer | 898 // We might not get a LeaveNotify event*, so we also poll the pointer |
| 898 // position. | 899 // position. |
| 899 | 900 |
| 900 // * If the mouse cursor has already been moved away before the anchor | 901 // * If the mouse cursor has already been moved away before the anchor |
| 901 // input window gets created, the anchor never gets a mouse leave event. | 902 // input window gets created, the anchor never gets a mouse leave event. |
| 902 // Additionally, Chrome appears to be stacking its status bubble window | 903 // Additionally, Chrome appears to be stacking its status bubble window |
| 903 // above all other windows, so we sometimes get a leave event as soon as | 904 // above all other windows, so we sometimes get a leave event as soon as |
| 904 // we slide a panel up. | 905 // we slide a panel up. |
| 905 anchor_pointer_watcher_.reset( | 906 anchor_pointer_watcher_.reset( |
| 906 new PointerPositionWatcher( | 907 new PointerPositionWatcher( |
| 907 wm()->event_loop(), | 908 wm()->event_loop(), |
| 908 wm()->xconn(), | 909 wm()->xconn(), |
| 909 NewPermanentCallback(this, &PanelBar::DestroyAnchor), | 910 NewPermanentCallback(this, &PanelBar::DestroyAnchor), |
| 910 false, // watch_for_entering_target=false | 911 false, // watch_for_entering_target=false |
| 911 x, y, width, height)); | 912 anchor_bounds)); |
| 912 } | 913 } |
| 913 | 914 |
| 914 void PanelBar::DestroyAnchor() { | 915 void PanelBar::DestroyAnchor() { |
| 915 wm()->xconn()->ConfigureWindowOffscreen(anchor_input_xid_); | 916 wm()->xconn()->ConfigureWindowOffscreen(anchor_input_xid_); |
| 916 anchor_actor_->SetOpacity(0, kAnchorFadeAnimMs); | 917 anchor_actor_->SetOpacity(0, kAnchorFadeAnimMs); |
| 917 anchor_panel_ = NULL; | 918 anchor_panel_ = NULL; |
| 918 anchor_pointer_watcher_.reset(); | 919 anchor_pointer_watcher_.reset(); |
| 919 } | 920 } |
| 920 | 921 |
| 921 Panel* PanelBar::GetNearestExpandedPanel(Panel* panel) { | 922 Panel* PanelBar::GetNearestExpandedPanel(Panel* panel) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 } | 960 } |
| 960 } | 961 } |
| 961 | 962 |
| 962 void PanelBar::StartHideCollapsedPanelsWatcher() { | 963 void PanelBar::StartHideCollapsedPanelsWatcher() { |
| 963 hide_collapsed_panels_pointer_watcher_.reset( | 964 hide_collapsed_panels_pointer_watcher_.reset( |
| 964 new PointerPositionWatcher( | 965 new PointerPositionWatcher( |
| 965 wm()->event_loop(), | 966 wm()->event_loop(), |
| 966 wm()->xconn(), | 967 wm()->xconn(), |
| 967 NewPermanentCallback(this, &PanelBar::HideCollapsedPanels), | 968 NewPermanentCallback(this, &PanelBar::HideCollapsedPanels), |
| 968 false, // watch_for_entering_target=false | 969 false, // watch_for_entering_target=false |
| 969 0, wm()->height() - kHideCollapsedPanelsDistancePixels, | 970 Rect(0, wm()->height() - kHideCollapsedPanelsDistancePixels, |
| 970 wm()->width(), kHideCollapsedPanelsDistancePixels)); | 971 wm()->width(), kHideCollapsedPanelsDistancePixels))); |
| 971 } | 972 } |
| 972 | 973 |
| 973 void PanelBar::ShowCollapsedPanels() { | 974 void PanelBar::ShowCollapsedPanels() { |
| 974 DLOG(INFO) << "Showing collapsed panels"; | 975 DLOG(INFO) << "Showing collapsed panels"; |
| 975 DisableShowCollapsedPanelsTimeout(); | 976 DisableShowCollapsedPanelsTimeout(); |
| 976 collapsed_panel_state_ = COLLAPSED_PANEL_STATE_SHOWN; | 977 collapsed_panel_state_ = COLLAPSED_PANEL_STATE_SHOWN; |
| 977 | 978 |
| 978 for (PanelSet::iterator it = all_panels_.begin(); | 979 for (PanelSet::iterator it = all_panels_.begin(); |
| 979 it != all_panels_.end(); ++it) { | 980 it != all_panels_.end(); ++it) { |
| 980 Panel* panel = *it; | 981 Panel* panel = *it; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 } | 1026 } |
| 1026 } | 1027 } |
| 1027 | 1028 |
| 1028 void PanelBar::HandleShowCollapsedPanelsTimeout() { | 1029 void PanelBar::HandleShowCollapsedPanelsTimeout() { |
| 1029 DCHECK(collapsed_panel_state_ == COLLAPSED_PANEL_STATE_WAITING_TO_SHOW); | 1030 DCHECK(collapsed_panel_state_ == COLLAPSED_PANEL_STATE_WAITING_TO_SHOW); |
| 1030 DisableShowCollapsedPanelsTimeout(); | 1031 DisableShowCollapsedPanelsTimeout(); |
| 1031 ShowCollapsedPanels(); | 1032 ShowCollapsedPanels(); |
| 1032 } | 1033 } |
| 1033 | 1034 |
| 1034 } // namespace window_manager | 1035 } // namespace window_manager |
| OLD | NEW |