| 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/login/login_controller.h" | 5 #include "window_manager/login/login_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <tr1/memory> | 9 #include <tr1/memory> |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 #ifndef TOUCH_UI | 120 #ifndef TOUCH_UI |
| 121 // Hide the mouse cursor until the user moves the pointer. We map a | 121 // Hide the mouse cursor until the user moves the pointer. We map a |
| 122 // fullscreen input window so we can tell when they've moved it (at which | 122 // fullscreen input window so we can tell when they've moved it (at which |
| 123 // point we'll destroy the window immediately so other windows can receive | 123 // point we'll destroy the window immediately so other windows can receive |
| 124 // input). | 124 // input). |
| 125 DCHECK(!wm_->logged_in()); | 125 DCHECK(!wm_->logged_in()); |
| 126 wm_->xconn()->HideCursor(); | 126 wm_->xconn()->HideCursor(); |
| 127 hide_mouse_cursor_xid_ = | 127 hide_mouse_cursor_xid_ = |
| 128 wm_->CreateInputWindow( | 128 wm_->CreateInputWindow( |
| 129 wm_->bounds(), PointerMotionMask | LeaveWindowMask | ButtonPressMask); | 129 wm_->root_bounds(), |
| 130 PointerMotionMask | LeaveWindowMask | ButtonPressMask); |
| 130 registrar_.RegisterForWindowEvents(hide_mouse_cursor_xid_); | 131 registrar_.RegisterForWindowEvents(hide_mouse_cursor_xid_); |
| 131 wm_->xconn()->RaiseWindow(hide_mouse_cursor_xid_); | 132 wm_->xconn()->RaiseWindow(hide_mouse_cursor_xid_); |
| 132 #endif | 133 #endif |
| 133 } | 134 } |
| 134 | 135 |
| 135 LoginController::~LoginController() { | 136 LoginController::~LoginController() { |
| 136 if (hide_mouse_cursor_xid_) | 137 if (hide_mouse_cursor_xid_) |
| 137 ShowMouseCursor(); | 138 ShowMouseCursor(); |
| 138 } | 139 } |
| 139 | 140 |
| 140 bool LoginController::IsInputWindow(XWindow xid) { | 141 bool LoginController::IsInputWindow(XWindow xid) { |
| 141 return hide_mouse_cursor_xid_ && xid == hide_mouse_cursor_xid_; | 142 return hide_mouse_cursor_xid_ && xid == hide_mouse_cursor_xid_; |
| 142 } | 143 } |
| 143 | 144 |
| 144 void LoginController::HandleScreenResize() { | 145 void LoginController::HandleScreenResize() { |
| 145 if (requested_destruction_) | 146 if (requested_destruction_) |
| 146 return; | 147 return; |
| 147 | 148 |
| 148 if (background_window_) | 149 if (background_window_) |
| 149 background_window_->ResizeClient(wm_->width(), wm_->height(), | 150 background_window_->Resize(wm_->root_size(), GRAVITY_NORTHWEST); |
| 150 GRAVITY_NORTHWEST); | |
| 151 | 151 |
| 152 if (all_windows_are_ready_ && | 152 if (all_windows_are_ready_ && |
| 153 is_entry_selection_enabled_ && | 153 is_entry_selection_enabled_ && |
| 154 !waiting_for_browser_window_) { | 154 !waiting_for_browser_window_) { |
| 155 vector<Point> origins; | 155 vector<Point> origins; |
| 156 CalculateIdealOrigins(&origins); | 156 CalculateIdealOrigins(&origins); |
| 157 for (size_t i = 0; i < entries_.size(); ++i) { | 157 for (size_t i = 0; i < entries_.size(); ++i) { |
| 158 if (!entries_[i]->has_all_windows()) | 158 if (!entries_[i]->has_all_windows()) |
| 159 continue; | 159 continue; |
| 160 entries_[i]->UpdatePositionAndScale( | 160 entries_[i]->UpdatePositionAndScale( |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 if (win == background_window_) { | 444 if (win == background_window_) { |
| 445 DoInitialSetupIfWindowsAreReady(); | 445 DoInitialSetupIfWindowsAreReady(); |
| 446 } else { | 446 } else { |
| 447 LoginEntry* entry = GetEntryForWindow(win, false); | 447 LoginEntry* entry = GetEntryForWindow(win, false); |
| 448 if (entry && entry->HasAllPixmaps()) | 448 if (entry && entry->HasAllPixmaps()) |
| 449 DoInitialSetupIfWindowsAreReady(); | 449 DoInitialSetupIfWindowsAreReady(); |
| 450 } | 450 } |
| 451 } | 451 } |
| 452 } | 452 } |
| 453 | 453 |
| 454 void LoginController::HandleWindowConfigureRequest(Window* win, | 454 void LoginController::HandleWindowConfigureRequest( |
| 455 int req_x, | 455 Window* win, const Rect& requested_bounds) { |
| 456 int req_y, | |
| 457 int req_width, | |
| 458 int req_height) { | |
| 459 if (requested_destruction_) | 456 if (requested_destruction_) |
| 460 return; | 457 return; |
| 461 | 458 |
| 462 if (IsLoginWindow(win)) { | 459 if (IsLoginWindow(win)) { |
| 463 // We manage the x/y, but let Chrome manage the width/height. | 460 // We manage the x/y, but let Chrome manage the width/height. |
| 464 win->ResizeClient(req_width, req_height, GRAVITY_NORTHWEST); | 461 win->Resize(requested_bounds.size(), GRAVITY_NORTHWEST); |
| 465 } else if (non_login_xids_.count(win->xid())) { | 462 } else if (non_login_xids_.count(win->xid())) { |
| 466 // If this is a non-login window that we're managing, just make | 463 // If this is a non-login window that we're managing, just make |
| 467 // whatever changes the client asked for. | 464 // whatever changes the client asked for. |
| 468 win->MoveClient(req_x, req_y); | 465 win->MoveClient(requested_bounds.x, requested_bounds.y); |
| 469 win->MoveCompositedToClient(); | 466 win->MoveCompositedToClient(); |
| 470 win->ResizeClient(req_width, req_height, GRAVITY_NORTHWEST); | 467 win->Resize(requested_bounds.size(), GRAVITY_NORTHWEST); |
| 471 } | 468 } |
| 472 } | 469 } |
| 473 | 470 |
| 474 void LoginController::HandleButtonPress(XWindow xid, | 471 void LoginController::HandleButtonPress(XWindow xid, |
| 475 int x, int y, | 472 const Point& relative_pos, |
| 476 int x_root, int y_root, | 473 const Point& absolute_pos, |
| 477 int button, | 474 int button, |
| 478 XTime timestamp) { | 475 XTime timestamp) { |
| 479 if (requested_destruction_) | 476 if (requested_destruction_) |
| 480 return; | 477 return; |
| 481 | 478 |
| 482 if (hide_mouse_cursor_xid_) | 479 if (hide_mouse_cursor_xid_) |
| 483 ShowMouseCursor(); | 480 ShowMouseCursor(); |
| 484 | 481 |
| 485 // Ignore clicks if a modal window has the focus. | 482 // Ignore clicks if a modal window has the focus. |
| 486 if (wm_->focus_manager()->focused_win() && | 483 if (wm_->focus_manager()->focused_win() && |
| (...skipping 15 matching lines...) Expand all Loading... |
| 502 if (login_xids_.count(xid) == 0) | 499 if (login_xids_.count(xid) == 0) |
| 503 return; | 500 return; |
| 504 | 501 |
| 505 // Otherwise, this was probably just some window that had a button grab | 502 // Otherwise, this was probably just some window that had a button grab |
| 506 // as a result of us calling FocusManager::UseClickToFocusForWindow(). | 503 // as a result of us calling FocusManager::UseClickToFocusForWindow(). |
| 507 if (login_window_to_focus_) | 504 if (login_window_to_focus_) |
| 508 wm_->FocusWindow(login_window_to_focus_, wm_->GetCurrentTimeFromServer()); | 505 wm_->FocusWindow(login_window_to_focus_, wm_->GetCurrentTimeFromServer()); |
| 509 } | 506 } |
| 510 | 507 |
| 511 void LoginController::HandlePointerLeave(XWindow xid, | 508 void LoginController::HandlePointerLeave(XWindow xid, |
| 512 int x, int y, | 509 const Point& relative_pos, |
| 513 int x_root, int y_root, | 510 const Point& absolute_pos, |
| 514 XTime timestamp) { | 511 XTime timestamp) { |
| 515 // We'll get a LeaveNotify event when the pointer is grabbed. We need to show | 512 // We'll get a LeaveNotify event when the pointer is grabbed. We need to show |
| 516 // the mouse cursor in response to this since we won't get any MotionNotify | 513 // the mouse cursor in response to this since we won't get any MotionNotify |
| 517 // events while it's grabbed. If the user opens a menu with the keyboard | 514 // events while it's grabbed. If the user opens a menu with the keyboard |
| 518 // (causing a grab) and then tries to move the mouse, we want to make sure | 515 // (causing a grab) and then tries to move the mouse, we want to make sure |
| 519 // that they can see the cursor. | 516 // that they can see the cursor. |
| 520 if (hide_mouse_cursor_xid_) | 517 if (hide_mouse_cursor_xid_) |
| 521 ShowMouseCursor(); | 518 ShowMouseCursor(); |
| 522 } | 519 } |
| 523 | 520 |
| 524 void LoginController::HandlePointerMotion(XWindow xid, | 521 void LoginController::HandlePointerMotion(XWindow xid, |
| 525 int x, int y, | 522 const Point& relative_pos, |
| 526 int x_root, int y_root, | 523 const Point& absolute_pos, |
| 527 XTime timestamp) { | 524 XTime timestamp) { |
| 528 if (hide_mouse_cursor_xid_) | 525 if (hide_mouse_cursor_xid_) |
| 529 ShowMouseCursor(); | 526 ShowMouseCursor(); |
| 530 } | 527 } |
| 531 | 528 |
| 532 void LoginController::HandleChromeMessage(const WmIpc::Message& msg) { | 529 void LoginController::HandleChromeMessage(const WmIpc::Message& msg) { |
| 533 if (requested_destruction_) | 530 if (requested_destruction_) |
| 534 return; | 531 return; |
| 535 | 532 |
| 536 switch (msg.type()) { | 533 switch (msg.type()) { |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 } | 964 } |
| 968 | 965 |
| 969 void LoginController::NotifySessionManager() { | 966 void LoginController::NotifySessionManager() { |
| 970 wm_->dbus()->CallMethod(login_manager::kSessionManagerServiceName, | 967 wm_->dbus()->CallMethod(login_manager::kSessionManagerServiceName, |
| 971 login_manager::kSessionManagerServicePath, | 968 login_manager::kSessionManagerServicePath, |
| 972 login_manager::kSessionManagerInterface, | 969 login_manager::kSessionManagerInterface, |
| 973 login_manager::kSessionManagerEmitLoginPromptVisible); | 970 login_manager::kSessionManagerEmitLoginPromptVisible); |
| 974 } | 971 } |
| 975 | 972 |
| 976 } // namespace window_manager | 973 } // namespace window_manager |
| OLD | NEW |