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

Side by Side Diff: panels/panel_manager.cc

Issue 6902072: wm: Update a lot of code to use structs from geometry.h. (Closed) Base URL: ssh://gitrw.chromium.org:9222/window_manager.git@master
Patch Set: move override-redirect stacking and visibility into Window Created 9 years, 7 months 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) 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_manager.h" 5 #include "window_manager/panels/panel_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "cros/chromeos_wm_ipc_enums.h" 10 #include "cros/chromeos_wm_ipc_enums.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 235 }
236 for (vector<XWindow>::const_iterator it = orphaned_transient_xids.begin(); 236 for (vector<XWindow>::const_iterator it = orphaned_transient_xids.begin();
237 it != orphaned_transient_xids.end(); ++it) { 237 it != orphaned_transient_xids.end(); ++it) {
238 CHECK(transient_xids_to_owners_.erase(*it) == 1); 238 CHECK(transient_xids_to_owners_.erase(*it) == 1);
239 } 239 }
240 240
241 CHECK(panels_by_titlebar_xid_.erase(panel->titlebar_xid()) == 1); 241 CHECK(panels_by_titlebar_xid_.erase(panel->titlebar_xid()) == 1);
242 CHECK(panels_.erase(panel->content_xid()) == 1); 242 CHECK(panels_.erase(panel->content_xid()) == 1);
243 } 243 }
244 244
245 void PanelManager::HandleWindowConfigureRequest( 245 void PanelManager::HandleWindowConfigureRequest(Window* win,
246 Window* win, int req_x, int req_y, int req_width, int req_height) { 246 const Rect& requested_bounds) {
247 if (Panel* owner_panel = GetPanelOwningTransientWindow(*win)) { 247 if (Panel* owner_panel = GetPanelOwningTransientWindow(*win)) {
248 owner_panel->HandleTransientWindowConfigureRequest( 248 owner_panel->HandleTransientWindowConfigureRequest(win, requested_bounds);
249 win, req_x, req_y, req_width, req_height);
250 return; 249 return;
251 } 250 }
252 251
253 Panel* panel = GetPanelByWindow(*win); 252 Panel* panel = GetPanelByWindow(*win);
254 if (!panel) 253 if (!panel)
255 return; 254 return;
256 255
257 if (win != panel->content_win()) { 256 if (win != panel->content_win()) {
258 LOG(WARNING) << "Ignoring request to configure non-content window " 257 LOG(WARNING) << "Ignoring request to configure non-content window "
259 << win->xid_str() << " for panel " << panel->xid_str(); 258 << win->xid_str() << " for panel " << panel->xid_str();
260 return; 259 return;
261 } 260 }
262 PanelContainer* container = GetContainerForPanel(*panel); 261 PanelContainer* container = GetContainerForPanel(*panel);
263 if (!container) { 262 if (!container) {
264 LOG(WARNING) << "Ignoring request to configure panel " << panel->xid_str() 263 LOG(WARNING) << "Ignoring request to configure panel " << panel->xid_str()
265 << " while it's not in a container"; 264 << " while it's not in a container";
266 return; 265 return;
267 } 266 }
268 if (panel->is_being_resized_by_user()) { 267 if (panel->is_being_resized_by_user()) {
269 LOG(WARNING) << "Ignoring request to configure panel " << panel->xid_str() 268 LOG(WARNING) << "Ignoring request to configure panel " << panel->xid_str()
270 << " while it's being manually resized"; 269 << " while it's being manually resized";
271 win->SendSyntheticConfigureNotify(); 270 win->SendSyntheticConfigureNotify();
272 return; 271 return;
273 } 272 }
274 273
275 if (req_width != panel->content_width() || 274 if (requested_bounds.size() != panel->content_size())
276 req_height != panel->content_height()) { 275 container->HandlePanelResizeRequest(panel, requested_bounds.size());
277 container->HandlePanelResizeRequest(panel, req_width, req_height); 276 else
278 } else {
279 win->SendSyntheticConfigureNotify(); 277 win->SendSyntheticConfigureNotify();
280 }
281 } 278 }
282 279
283 void PanelManager::HandleButtonPress(XWindow xid, 280 void PanelManager::HandleButtonPress(XWindow xid,
284 int x, int y, 281 const Point& relative_pos,
285 int x_root, int y_root, 282 const Point& absolute_pos,
286 int button, 283 int button,
287 XTime timestamp) { 284 XTime timestamp) {
288 // If this is a container's input window, notify the container. 285 // If this is a container's input window, notify the container.
289 PanelContainer* container = GetContainerOwningInputWindow(xid); 286 PanelContainer* container = GetContainerOwningInputWindow(xid);
290 if (container) { 287 if (container) {
291 container->HandleInputWindowButtonPress( 288 container->HandleInputWindowButtonPress(
292 xid, x, y, x_root, y_root, button, timestamp); 289 xid, relative_pos, absolute_pos, button, timestamp);
293 return; 290 return;
294 } 291 }
295 292
296 // If this is a panel's input window, notify the panel. 293 // If this is a panel's input window, notify the panel.
297 Panel* panel = GetPanelOwningInputWindow(xid); 294 Panel* panel = GetPanelOwningInputWindow(xid);
298 if (panel) { 295 if (panel) {
299 panel->HandleInputWindowButtonPress(xid, x, y, button, timestamp); 296 panel->HandleInputWindowButtonPress(xid, relative_pos, button, timestamp);
300 return; 297 return;
301 } 298 }
302 299
303 Window* win = wm_->GetWindow(xid); 300 Window* win = wm_->GetWindow(xid);
304 if (!win) 301 if (!win)
305 return; 302 return;
306 303
307 // If it's a panel's content window, notify the panel's container. 304 // If it's a panel's content window, notify the panel's container.
308 panel = GetPanelByWindow(*win); 305 panel = GetPanelByWindow(*win);
309 if (panel) { 306 if (panel) {
310 container = GetContainerForPanel(*panel); 307 container = GetContainerForPanel(*panel);
311 if (container) 308 if (container)
312 container->HandlePanelButtonPress(panel, button, timestamp); 309 container->HandlePanelButtonPress(panel, button, timestamp);
313 return; 310 return;
314 } 311 }
315 312
316 panel = GetPanelOwningTransientWindow(*win); 313 panel = GetPanelOwningTransientWindow(*win);
317 if (panel) { 314 if (panel) {
318 panel->HandleTransientWindowButtonPress(win, button, timestamp); 315 panel->HandleTransientWindowButtonPress(win, button, timestamp);
319 return; 316 return;
320 } 317 }
321 } 318 }
322 319
323 void PanelManager::HandleButtonRelease(XWindow xid, 320 void PanelManager::HandleButtonRelease(XWindow xid,
324 int x, int y, 321 const Point& relative_pos,
325 int x_root, int y_root, 322 const Point& absolute_pos,
326 int button, 323 int button,
327 XTime timestamp) { 324 XTime timestamp) {
328 // We only care if button releases happened in container or panel input 325 // We only care if button releases happened in container or panel input
329 // windows -- there's no current need to notify containers about button 326 // windows -- there's no current need to notify containers about button
330 // releases in their panels. 327 // releases in their panels.
331 PanelContainer* container = GetContainerOwningInputWindow(xid); 328 PanelContainer* container = GetContainerOwningInputWindow(xid);
332 if (container) { 329 if (container) {
333 container->HandleInputWindowButtonRelease( 330 container->HandleInputWindowButtonRelease(
334 xid, x, y, x_root, y_root, button, timestamp); 331 xid, relative_pos, absolute_pos, button, timestamp);
335 return; 332 return;
336 } 333 }
337 334
338 Panel* panel = GetPanelOwningInputWindow(xid); 335 Panel* panel = GetPanelOwningInputWindow(xid);
339 if (panel) { 336 if (panel) {
340 panel->HandleInputWindowButtonRelease(xid, x, y, button, timestamp); 337 panel->HandleInputWindowButtonRelease(xid, relative_pos, button, timestamp);
341 return; 338 return;
342 } 339 }
343 } 340 }
344 341
345 void PanelManager::HandlePointerEnter(XWindow xid, 342 void PanelManager::HandlePointerEnter(XWindow xid,
346 int x, int y, 343 const Point& relative_pos,
347 int x_root, int y_root, 344 const Point& absolute_pos,
348 XTime timestamp) { 345 XTime timestamp) {
349 PanelContainer* container = GetContainerOwningInputWindow(xid); 346 PanelContainer* container = GetContainerOwningInputWindow(xid);
350 if (container) { 347 if (container) {
351 container->HandleInputWindowPointerEnter( 348 container->HandleInputWindowPointerEnter(
352 xid, x, y, x_root, y_root, timestamp); 349 xid, relative_pos, absolute_pos, timestamp);
353 return; 350 return;
354 } 351 }
355 352
356 // If it's a panel's titlebar window, notify the panel's container. 353 // If it's a panel's titlebar window, notify the panel's container.
357 Window* win = wm_->GetWindow(xid); 354 Window* win = wm_->GetWindow(xid);
358 if (win) { 355 if (win) {
359 Panel* panel = GetPanelByWindow(*win); 356 Panel* panel = GetPanelByWindow(*win);
360 if (panel) { 357 if (panel) {
361 container = GetContainerForPanel(*panel); 358 container = GetContainerForPanel(*panel);
362 if (container && xid == panel->titlebar_xid()) 359 if (container && xid == panel->titlebar_xid())
363 container->HandlePanelTitlebarPointerEnter(panel, timestamp); 360 container->HandlePanelTitlebarPointerEnter(panel, timestamp);
364 return; 361 return;
365 } 362 }
366 } 363 }
367 } 364 }
368 365
369 void PanelManager::HandlePointerLeave(XWindow xid, 366 void PanelManager::HandlePointerLeave(XWindow xid,
370 int x, int y, 367 const Point& relative_pos,
371 int x_root, int y_root, 368 const Point& absolute_pos,
372 XTime timestamp) { 369 XTime timestamp) {
373 PanelContainer* container = GetContainerOwningInputWindow(xid); 370 PanelContainer* container = GetContainerOwningInputWindow(xid);
374 if (container) 371 if (container)
375 container->HandleInputWindowPointerLeave( 372 container->HandleInputWindowPointerLeave(
376 xid, x, y, x_root, y_root, timestamp); 373 xid, relative_pos, absolute_pos, timestamp);
377 } 374 }
378 375
379 void PanelManager::HandlePointerMotion(XWindow xid, 376 void PanelManager::HandlePointerMotion(XWindow xid,
380 int x, int y, 377 const Point& relative_pos,
381 int x_root, int y_root, 378 const Point& absolute_pos,
382 XTime timestamp) { 379 XTime timestamp) {
383 Panel* panel = GetPanelOwningInputWindow(xid); 380 Panel* panel = GetPanelOwningInputWindow(xid);
384 if (panel) 381 if (panel)
385 panel->HandleInputWindowPointerMotion(xid, x, y); 382 panel->HandleInputWindowPointerMotion(xid, relative_pos);
386 } 383 }
387 384
388 void PanelManager::HandleChromeMessage(const WmIpc::Message& msg) { 385 void PanelManager::HandleChromeMessage(const WmIpc::Message& msg) {
389 switch (msg.type()) { 386 switch (msg.type()) {
390 case chromeos::WM_IPC_MESSAGE_WM_SET_PANEL_STATE: { 387 case chromeos::WM_IPC_MESSAGE_WM_SET_PANEL_STATE: {
391 XWindow xid = msg.param(0); 388 XWindow xid = msg.param(0);
392 Panel* panel = GetPanelByXid(xid); 389 Panel* panel = GetPanelByXid(xid);
393 if (!panel) { 390 if (!panel) {
394 LOG(WARNING) << "Ignoring WM_SET_PANEL_STATE message for non-panel " 391 LOG(WARNING) << "Ignoring WM_SET_PANEL_STATE message for non-panel "
395 << "window " << XidStr(xid); 392 << "window " << XidStr(xid);
(...skipping 15 matching lines...) Expand all
411 if (dragged_panel_ && panel != dragged_panel_) 408 if (dragged_panel_ && panel != dragged_panel_)
412 HandlePanelDragComplete(dragged_panel_, false); // removed=false 409 HandlePanelDragComplete(dragged_panel_, false); // removed=false
413 if (panel != dragged_panel_) { 410 if (panel != dragged_panel_) {
414 dragged_panel_ = panel; 411 dragged_panel_ = panel;
415 panel->HandleDragStart(); 412 panel->HandleDragStart();
416 } 413 }
417 if (!dragged_panel_event_coalescer_->IsRunning()) 414 if (!dragged_panel_event_coalescer_->IsRunning())
418 dragged_panel_event_coalescer_->Start(); 415 dragged_panel_event_coalescer_->Start();
419 // We want the right edge of the panel, but pre-IPC-version-1 Chrome 416 // We want the right edge of the panel, but pre-IPC-version-1 Chrome
420 // sends us the left edge of the titlebar instead. 417 // sends us the left edge of the titlebar instead.
421 int drag_x = (wm()->wm_ipc_version() >= 1) ? 418 Point drag_pos(
422 msg.param(1) : msg.param(1) + panel->titlebar_width(); 419 (wm()->wm_ipc_version() >= 1) ?
423 int drag_y = msg.param(2); 420 msg.param(1) : msg.param(1) + panel->titlebar_width(),
424 dragged_panel_event_coalescer_->StorePosition(drag_x, drag_y); 421 msg.param(2));
422 dragged_panel_event_coalescer_->StorePosition(drag_pos);
425 break; 423 break;
426 } 424 }
427 case chromeos::WM_IPC_MESSAGE_WM_NOTIFY_PANEL_DRAG_COMPLETE: { 425 case chromeos::WM_IPC_MESSAGE_WM_NOTIFY_PANEL_DRAG_COMPLETE: {
428 XWindow xid = msg.param(0); 426 XWindow xid = msg.param(0);
429 Panel* panel = GetPanelByXid(xid); 427 Panel* panel = GetPanelByXid(xid);
430 if (!panel) { 428 if (!panel) {
431 LOG(WARNING) << "Ignoring WM_NOTIFY_PANEL_DRAG_COMPLETE message for " 429 LOG(WARNING) << "Ignoring WM_NOTIFY_PANEL_DRAG_COMPLETE message for "
432 << "non-panel window " << XidStr(xid); 430 << "non-panel window " << XidStr(xid);
433 return; 431 return;
434 } 432 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 598
601 void PanelManager::DoInitialSetupForWindow(Window* win) { 599 void PanelManager::DoInitialSetupForWindow(Window* win) {
602 win->SetVisibility(Window::VISIBILITY_HIDDEN); 600 win->SetVisibility(Window::VISIBILITY_HIDDEN);
603 } 601 }
604 602
605 void PanelManager::HandlePeriodicPanelDragMotion() { 603 void PanelManager::HandlePeriodicPanelDragMotion() {
606 DCHECK(dragged_panel_); 604 DCHECK(dragged_panel_);
607 if (!dragged_panel_) 605 if (!dragged_panel_)
608 return; 606 return;
609 607
610 const int x = dragged_panel_event_coalescer_->x(); 608 const Point pos = dragged_panel_event_coalescer_->position();
611 const int y = dragged_panel_event_coalescer_->y();
612 609
613 bool container_handled_drag = false; 610 bool container_handled_drag = false;
614 bool panel_was_detached = false; 611 bool panel_was_detached = false;
615 PanelContainer* container = GetContainerForPanel(*dragged_panel_); 612 PanelContainer* container = GetContainerForPanel(*dragged_panel_);
616 if (container) { 613 if (container) {
617 if (container->HandleNotifyPanelDraggedMessage(dragged_panel_, x, y)) { 614 if (container->HandleNotifyPanelDraggedMessage(dragged_panel_, pos)) {
618 container_handled_drag = true; 615 container_handled_drag = true;
619 } else { 616 } else {
620 DLOG(INFO) << "Container " << container << " told us to detach panel " 617 DLOG(INFO) << "Container " << container << " told us to detach panel "
621 << dragged_panel_->xid_str() 618 << dragged_panel_->xid_str() << " at " << pos;
622 << " at (" << x << ", " << y << ")";
623 RemovePanelFromContainer(dragged_panel_, container); 619 RemovePanelFromContainer(dragged_panel_, container);
624 panel_was_detached = true; 620 panel_was_detached = true;
625 } 621 }
626 } 622 }
627 623
628 if (!container_handled_drag) { 624 if (!container_handled_drag) {
629 if (panel_was_detached) { 625 if (panel_was_detached) {
630 dragged_panel_->SetTitlebarWidth(dragged_panel_->content_width()); 626 dragged_panel_->SetTitlebarWidth(dragged_panel_->content_width());
631 dragged_panel_->StackAtTopOfLayer(StackingManager::LAYER_DRAGGED_PANEL); 627 dragged_panel_->StackAtTopOfLayer(StackingManager::LAYER_DRAGGED_PANEL);
632 } 628 }
633 629
634 // Offer the panel to all of the containers. If we find one that wants 630 // Offer the panel to all of the containers. If we find one that wants
635 // it, attach it; otherwise we just move the panel to the dragged location. 631 // it, attach it; otherwise we just move the panel to the dragged location.
636 bool panel_was_reattached = false; 632 bool panel_was_reattached = false;
637 for (vector<PanelContainer*>::iterator it = containers_.begin(); 633 for (vector<PanelContainer*>::iterator it = containers_.begin();
638 it != containers_.end(); ++it) { 634 it != containers_.end(); ++it) {
639 if ((*it)->ShouldAddDraggedPanel(dragged_panel_, x, y)) { 635 if ((*it)->ShouldAddDraggedPanel(dragged_panel_, pos)) {
640 DLOG(INFO) << "Container " << *it << " told us to attach panel " 636 DLOG(INFO) << "Container " << *it << " told us to attach panel "
641 << dragged_panel_->xid_str() 637 << dragged_panel_->xid_str() << " at " << pos;
642 << " at (" << x << ", " << y << ")";
643 AddPanelToContainer(dragged_panel_, 638 AddPanelToContainer(dragged_panel_,
644 *it, 639 *it,
645 PanelContainer::PANEL_SOURCE_DRAGGED); 640 PanelContainer::PANEL_SOURCE_DRAGGED);
646 CHECK((*it)->HandleNotifyPanelDraggedMessage(dragged_panel_, x, y)); 641 CHECK((*it)->HandleNotifyPanelDraggedMessage(dragged_panel_, pos));
647 panel_was_reattached = true; 642 panel_was_reattached = true;
648 break; 643 break;
649 } 644 }
650 } 645 }
651 if (!panel_was_reattached) { 646 if (!panel_was_reattached) {
652 dragged_panel_->Move( 647 dragged_panel_->Move(pos, panel_was_detached ? kDetachPanelAnimMs : 0);
653 x, y, panel_was_detached ? kDetachPanelAnimMs : 0);
654 } 648 }
655 } 649 }
656 } 650 }
657 651
658 void PanelManager::HandlePanelDragComplete(Panel* panel, bool removed) { 652 void PanelManager::HandlePanelDragComplete(Panel* panel, bool removed) {
659 DCHECK(panel); 653 DCHECK(panel);
660 DCHECK(dragged_panel_ == panel); 654 DCHECK(dragged_panel_ == panel);
661 if (dragged_panel_ != panel) 655 if (dragged_panel_ != panel)
662 return; 656 return;
663 657
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 << panel->xid_str(); 717 << panel->xid_str();
724 return; 718 return;
725 } 719 }
726 720
727 panel->SetFullscreenState(false); 721 panel->SetFullscreenState(false);
728 if (fullscreen_panel_ == panel) 722 if (fullscreen_panel_ == panel)
729 fullscreen_panel_ = NULL; 723 fullscreen_panel_ = NULL;
730 } 724 }
731 725
732 } // namespace window_manager 726 } // namespace window_manager
OLDNEW
« no previous file with comments | « panels/panel_manager.h ('k') | panels/panel_manager_test.cc » ('j') | window.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698