| 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/layout/toplevel_window.h" | 5 #include "window_manager/layout/toplevel_window.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 new EventConsumerRegistrar(wm(), layout_manager_)), | 75 new EventConsumerRegistrar(wm(), layout_manager_)), |
| 76 is_fullscreen_(false) { | 76 is_fullscreen_(false) { |
| 77 #if defined(EXTRA_LOGGING) | 77 #if defined(EXTRA_LOGGING) |
| 78 DLOG(INFO) << "Creating ToplevelWindow for window " << XidStr(win_->xid()); | 78 DLOG(INFO) << "Creating ToplevelWindow for window " << XidStr(win_->xid()); |
| 79 #endif | 79 #endif |
| 80 | 80 |
| 81 event_consumer_registrar_->RegisterForWindowEvents(win_->xid()); | 81 event_consumer_registrar_->RegisterForWindowEvents(win_->xid()); |
| 82 | 82 |
| 83 int width = layout_manager_->width(); | 83 int width = layout_manager_->width(); |
| 84 int height = layout_manager_->height(); | 84 int height = layout_manager_->height(); |
| 85 win->ResizeClient(width, height, GRAVITY_NORTHWEST); | 85 win->Resize(Size(width, height), GRAVITY_NORTHWEST); |
| 86 | 86 |
| 87 // Let the window know that it's maximized. | 87 // Let the window know that it's maximized. |
| 88 map<XAtom, bool> wm_state; | 88 map<XAtom, bool> wm_state; |
| 89 wm_state[wm()->GetXAtom(ATOM_NET_WM_STATE_MAXIMIZED_HORZ)] = true; | 89 wm_state[wm()->GetXAtom(ATOM_NET_WM_STATE_MAXIMIZED_HORZ)] = true; |
| 90 wm_state[wm()->GetXAtom(ATOM_NET_WM_STATE_MAXIMIZED_VERT)] = true; | 90 wm_state[wm()->GetXAtom(ATOM_NET_WM_STATE_MAXIMIZED_VERT)] = true; |
| 91 win->ChangeWmState(wm_state); | 91 win->ChangeWmState(wm_state); |
| 92 | 92 |
| 93 // Initialize local properties from the window properties. | 93 // Initialize local properties from the window properties. |
| 94 PropertiesChanged(); | 94 PropertiesChanged(); |
| 95 | 95 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 map<XAtom, bool> wm_state; | 233 map<XAtom, bool> wm_state; |
| 234 wm_state[wm()->GetXAtom(ATOM_NET_WM_STATE_FULLSCREEN)] = is_fullscreen_; | 234 wm_state[wm()->GetXAtom(ATOM_NET_WM_STATE_FULLSCREEN)] = is_fullscreen_; |
| 235 win_->ChangeWmState(wm_state); | 235 win_->ChangeWmState(wm_state); |
| 236 } | 236 } |
| 237 | 237 |
| 238 if (is_fullscreen_) { | 238 if (is_fullscreen_) { |
| 239 wm()->stacking_manager()->StackWindowAtTopOfLayer( | 239 wm()->stacking_manager()->StackWindowAtTopOfLayer( |
| 240 win_, | 240 win_, |
| 241 StackingManager::LAYER_FULLSCREEN_WINDOW, | 241 StackingManager::LAYER_FULLSCREEN_WINDOW, |
| 242 StackingManager::SHADOW_AT_BOTTOM_OF_LAYER); | 242 StackingManager::SHADOW_AT_BOTTOM_OF_LAYER); |
| 243 win_->ResizeClient(wm()->width(), wm()->height(), GRAVITY_NORTHWEST); | 243 win_->Resize(wm()->root_size(), GRAVITY_NORTHWEST); |
| 244 win_->MoveClient(0, 0); | 244 win_->MoveClient(0, 0); |
| 245 win_->MoveCompositedToClient(); | 245 win_->MoveCompositedToClient(); |
| 246 // If a window has its fullscreen hint set when it's first mapped, | 246 // If a window has its fullscreen hint set when it's first mapped, |
| 247 // LayoutManager will avoid calling ConfigureForActiveMode(), so we | 247 // LayoutManager will avoid calling ConfigureForActiveMode(), so we |
| 248 // need to manually make sure that the window is visible here. | 248 // need to manually make sure that the window is visible here. |
| 249 win_->SetCompositedOpacity(1, 0); | 249 win_->SetCompositedOpacity(1, 0); |
| 250 } else { | 250 } else { |
| 251 wm()->stacking_manager()->StackWindowAtTopOfLayer( | 251 wm()->stacking_manager()->StackWindowAtTopOfLayer( |
| 252 win_, | 252 win_, |
| 253 StackingManager::LAYER_TOPLEVEL_WINDOW, | 253 StackingManager::LAYER_TOPLEVEL_WINDOW, |
| 254 StackingManager::SHADOW_AT_BOTTOM_OF_LAYER); | 254 StackingManager::SHADOW_AT_BOTTOM_OF_LAYER); |
| 255 win_->ResizeClient(layout_manager_->width(), layout_manager_->height(), | 255 win_->Resize(Size(layout_manager_->width(), layout_manager_->height()), |
| 256 GRAVITY_NORTHWEST); | 256 GRAVITY_NORTHWEST); |
| 257 win_->MoveClient(layout_manager_->x(), layout_manager_->y()); | 257 win_->MoveClient(layout_manager_->x(), layout_manager_->y()); |
| 258 win_->MoveCompositedToClient(); | 258 win_->MoveCompositedToClient(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 const bool stack_transient_directly_above_win = | 261 const bool stack_transient_directly_above_win = |
| 262 is_fullscreen_ || state_ == STATE_OVERVIEW_MODE; | 262 is_fullscreen_ || state_ == STATE_OVERVIEW_MODE; |
| 263 transients_->ApplyStackingForAllWindows(stack_transient_directly_above_win); | 263 transients_->ApplyStackingForAllWindows(stack_transient_directly_above_win); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void LayoutManager::ToplevelWindow::DoNudgeAnimation(bool move_to_left) { | 266 void LayoutManager::ToplevelWindow::DoNudgeAnimation(bool move_to_left) { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 const bool stack_directly_above_toplevel = in_overview_mode || is_fullscreen_; | 490 const bool stack_directly_above_toplevel = in_overview_mode || is_fullscreen_; |
| 491 transients_->AddWindow(transient_win, stack_directly_above_toplevel); | 491 transients_->AddWindow(transient_win, stack_directly_above_toplevel); |
| 492 } | 492 } |
| 493 | 493 |
| 494 void LayoutManager::ToplevelWindow::HandleTransientWindowUnmap( | 494 void LayoutManager::ToplevelWindow::HandleTransientWindowUnmap( |
| 495 Window* transient_win) { | 495 Window* transient_win) { |
| 496 transients_->RemoveWindow(transient_win); | 496 transients_->RemoveWindow(transient_win); |
| 497 } | 497 } |
| 498 | 498 |
| 499 void LayoutManager::ToplevelWindow::HandleTransientWindowConfigureRequest( | 499 void LayoutManager::ToplevelWindow::HandleTransientWindowConfigureRequest( |
| 500 Window* transient_win, | 500 Window* transient_win, const Rect& requested_bounds) { |
| 501 int req_x, int req_y, int req_width, int req_height) { | 501 transients_->HandleConfigureRequest(transient_win, requested_bounds); |
| 502 transients_->HandleConfigureRequest(transient_win, req_x, req_y, | |
| 503 req_width, req_height); | |
| 504 } | 502 } |
| 505 | 503 |
| 506 void LayoutManager::ToplevelWindow::HandleButtonPress( | 504 void LayoutManager::ToplevelWindow::HandleButtonPress( |
| 507 Window* button_win, XTime timestamp) { | 505 Window* button_win, XTime timestamp) { |
| 508 // Don't reassign the focus if it's already held by a modal window. | 506 // Don't reassign the focus if it's already held by a modal window. |
| 509 if (wm()->IsModalWindowFocused()) | 507 if (wm()->IsModalWindowFocused()) |
| 510 return; | 508 return; |
| 511 | 509 |
| 512 transients_->SetPreferredWindowToFocus( | 510 transients_->SetPreferredWindowToFocus( |
| 513 transients_->ContainsWindow(*button_win) ? button_win : NULL); | 511 transients_->ContainsWindow(*button_win) ? button_win : NULL); |
| 514 TakeFocus(timestamp); | 512 TakeFocus(timestamp); |
| 515 } | 513 } |
| 516 | 514 |
| 517 } // namespace window_manager | 515 } // namespace window_manager |
| OLD | NEW |