| 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/transient_window_collection.h" | 5 #include "window_manager/transient_window_collection.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "window_manager/stacking_manager.h" | 9 #include "window_manager/stacking_manager.h" |
| 10 #include "window_manager/window_manager.h" | 10 #include "window_manager/window_manager.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 transients_[transient_win->xid()] = transient; | 98 transients_[transient_win->xid()] = transient; |
| 99 | 99 |
| 100 // Info bubbles always keep their initial positions. | 100 // Info bubbles always keep their initial positions. |
| 101 if (transient_win->type() == chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE) { | 101 if (transient_win->type() == chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE) { |
| 102 transient->SaveOffsetsRelativeToWindow( | 102 transient->SaveOffsetsRelativeToWindow( |
| 103 owner_win_, | 103 owner_win_, |
| 104 Point(transient_win->composited_x(), transient_win->composited_y())); | 104 Point(transient_win->composited_x(), transient_win->composited_y())); |
| 105 transient->centered = false; | 105 transient->centered = false; |
| 106 } else { | 106 } else { |
| 107 transient->UpdateOffsetsToCenterOverWindow( | 107 transient->UpdateOffsetsToCenterOverWindow( |
| 108 owner_win_, | 108 owner_win_, wm()->root_bounds(), constrain_onscreen_); |
| 109 Rect(0, 0, wm()->width(), wm()->height()), | |
| 110 constrain_onscreen_); | |
| 111 transient->centered = true; | 109 transient->centered = true; |
| 112 } | 110 } |
| 113 | 111 |
| 114 // If the new transient is non-modal, stack it above the top non-modal | 112 // If the new transient is non-modal, stack it above the top non-modal |
| 115 // transient that we have. If it's modal, just put it on top of all | 113 // transient that we have. If it's modal, just put it on top of all |
| 116 // other transients. | 114 // other transients. |
| 117 TransientWindow* transient_to_stack_above = NULL; | 115 TransientWindow* transient_to_stack_above = NULL; |
| 118 for (list<TransientWindow*>::const_iterator it = | 116 for (list<TransientWindow*>::const_iterator it = |
| 119 stacked_transients_->items().begin(); | 117 stacked_transients_->items().begin(); |
| 120 it != stacked_transients_->items().end(); ++it) { | 118 it != stacked_transients_->items().end(); ++it) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 stacked_transients_->items().rbegin(); | 178 stacked_transients_->items().rbegin(); |
| 181 it != stacked_transients_->items().rend(); | 179 it != stacked_transients_->items().rend(); |
| 182 ++it) { | 180 ++it) { |
| 183 TransientWindow* transient = *it; | 181 TransientWindow* transient = *it; |
| 184 ApplyStackingForTransientWindow(transient, prev_win); | 182 ApplyStackingForTransientWindow(transient, prev_win); |
| 185 prev_win = transient->win; | 183 prev_win = transient->win; |
| 186 } | 184 } |
| 187 } | 185 } |
| 188 | 186 |
| 189 void TransientWindowCollection::HandleConfigureRequest( | 187 void TransientWindowCollection::HandleConfigureRequest( |
| 190 Window* transient_win, | 188 Window* transient_win, const Rect& requested_bounds) { |
| 191 int req_x, int req_y, | |
| 192 int req_width, int req_height) { | |
| 193 CHECK(transient_win); | 189 CHECK(transient_win); |
| 194 TransientWindow* transient = GetTransientWindow(*transient_win); | 190 TransientWindow* transient = GetTransientWindow(*transient_win); |
| 195 CHECK(transient); | 191 CHECK(transient); |
| 196 | 192 |
| 197 Rect orig_client_bounds = transient_win->client_bounds(); | 193 const Rect orig_client_bounds = transient_win->client_bounds(); |
| 198 | 194 |
| 199 // Move and resize the transient window as requested (only let info bubbles | 195 // Move and resize the transient window as requested (only let info bubbles |
| 200 // move themselves). | 196 // move themselves). |
| 201 if (transient_win->type() == chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE) { | 197 if (transient_win->type() == chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE) { |
| 202 transient->SaveOffsetsRelativeToWindow(owner_win_, Point(req_x, req_y)); | 198 transient->SaveOffsetsRelativeToWindow( |
| 199 owner_win_, requested_bounds.position()); |
| 203 transient->centered = false; | 200 transient->centered = false; |
| 204 } | 201 } |
| 205 | 202 |
| 206 if (req_width != transient_win->client_width() || | 203 if (requested_bounds.size() != transient_win->client_size()) { |
| 207 req_height != transient_win->client_height()) { | 204 transient_win->Resize(requested_bounds.size(), GRAVITY_NORTHWEST); |
| 208 transient_win->ResizeClient(req_width, req_height, GRAVITY_NORTHWEST); | |
| 209 if (transient->centered) { | 205 if (transient->centered) { |
| 210 transient->UpdateOffsetsToCenterOverWindow( | 206 transient->UpdateOffsetsToCenterOverWindow( |
| 211 owner_win_, | 207 owner_win_, wm()->root_bounds(), constrain_onscreen_); |
| 212 Rect(0, 0, wm()->width(), wm()->height()), | |
| 213 constrain_onscreen_); | |
| 214 } | 208 } |
| 215 } | 209 } |
| 216 | 210 |
| 217 ConfigureTransientWindow(transient, 0); | 211 ConfigureTransientWindow(transient, 0); |
| 218 | 212 |
| 219 // If the window didn't change, send a fake ConfigureNotify to the | 213 // If the window didn't change, send a fake ConfigureNotify to the |
| 220 // client to let it know that we at least considered its request. | 214 // client to let it know that we at least considered its request. |
| 221 if (transient_win->client_bounds() == orig_client_bounds) | 215 if (transient_win->client_bounds() == orig_client_bounds) |
| 222 transient_win->SendSyntheticConfigureNotify(); | 216 transient_win->SendSyntheticConfigureNotify(); |
| 223 } | 217 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 DCHECK(stacked_transients_->Contains(transient)); | 350 DCHECK(stacked_transients_->Contains(transient)); |
| 357 DCHECK_GT(stacked_transients_->items().size(), 1U); | 351 DCHECK_GT(stacked_transients_->items().size(), 1U); |
| 358 TransientWindow* transient_to_stack_above = | 352 TransientWindow* transient_to_stack_above = |
| 359 stacked_transients_->items().front(); | 353 stacked_transients_->items().front(); |
| 360 stacked_transients_->Remove(transient); | 354 stacked_transients_->Remove(transient); |
| 361 stacked_transients_->AddOnTop(transient); | 355 stacked_transients_->AddOnTop(transient); |
| 362 ApplyStackingForTransientWindow(transient, transient_to_stack_above->win); | 356 ApplyStackingForTransientWindow(transient, transient_to_stack_above->win); |
| 363 } | 357 } |
| 364 | 358 |
| 365 } // namespace window_manager | 359 } // namespace window_manager |
| OLD | NEW |