Index: services/ui/ws/window_tree.cc |
diff --git a/services/ui/ws/window_tree.cc b/services/ui/ws/window_tree.cc |
index f642e1f1c3291f98d25ebcc946bb1336a56e9068..e71d4a3ae0bb84deb01662ec28b55f4a2c6a654d 100644 |
--- a/services/ui/ws/window_tree.cc |
+++ b/services/ui/ws/window_tree.cc |
@@ -352,25 +352,33 @@ bool WindowTree::DeleteWindow(const ClientWindowId& window_id) { |
return tree && tree->DeleteWindowImpl(this, window); |
} |
-bool WindowTree::SetModal(const ClientWindowId& window_id) { |
+bool WindowTree::SetModal(const ClientWindowId& window_id, |
+ ModalType modal_type) { |
ServerWindow* window = GetWindowByClientId(window_id); |
- if (window && access_policy_->CanSetModal(window)) { |
- WindowManagerDisplayRoot* display_root = |
- GetWindowManagerDisplayRoot(window); |
- if (window->transient_parent()) { |
- window->SetModal(); |
- } else if (user_id_ != InvalidUserId()) { |
- if (display_root) |
- display_root->window_manager_state()->AddSystemModalWindow(window); |
- } else { |
- return false; |
- } |
- if (display_root) |
- display_root->window_manager_state()->ReleaseCaptureBlockedByModalWindow( |
- window); |
- return true; |
+ if (!window || !access_policy_->CanSetModal(window)) |
+ return false; |
+ // TODO(moshayedi): crbug.com/697176. When modality of a window that used to |
+ // be a system modal changes, notify window manager state. |
+ auto* display_root = GetWindowManagerDisplayRoot(window); |
+ switch (modal_type) { |
sky
2017/03/01 00:13:35
Early out if modal_type matches?
Hadi
2017/03/06 20:07:05
Done. Should we return true or false in this case?
sky
2017/03/06 22:26:45
Return true.
|
+ case MODAL_TYPE_NONE: |
sky
2017/03/01 00:13:35
Move this to MODEL_TYPE_WINDOW as it's the same im
Hadi
2017/03/06 20:07:05
I thought we shouldn't release capture when MODAL_
|
+ window->SetModal(MODAL_TYPE_NONE); |
+ return true; |
+ case MODAL_TYPE_SYSTEM: |
+ if (user_id_ == InvalidUserId() || !display_root) |
sky
2017/03/01 00:13:35
Why the InvalidUserId check?
Hadi
2017/03/06 20:07:05
The previous implementation checks for InvalidUser
|
+ return false; |
+ display_root->window_manager_state()->AddSystemModalWindow(window); |
sky
2017/03/01 00:13:35
How come you don't SetModal(modal_type) in this ca
Hadi
2017/03/06 20:07:05
AddSystemModalWindow() does this. I agree my imple
|
+ break; |
+ case MODAL_TYPE_WINDOW: |
+ case MODAL_TYPE_CHILD: |
+ window->SetModal(modal_type); |
+ break; |
+ } |
+ if (display_root) { |
+ display_root->window_manager_state()->ReleaseCaptureBlockedByModalWindow( |
+ window); |
} |
- return false; |
+ return true; |
} |
std::vector<const ServerWindow*> WindowTree::GetWindowTree( |
@@ -1278,8 +1286,11 @@ void WindowTree::RemoveTransientWindowFromParent(uint32_t change_id, |
client()->OnChangeCompleted(change_id, success); |
} |
-void WindowTree::SetModal(uint32_t change_id, Id window_id) { |
- client()->OnChangeCompleted(change_id, SetModal(ClientWindowId(window_id))); |
+void WindowTree::SetModal(uint32_t change_id, |
+ Id window_id, |
+ ModalType modal_type) { |
+ client()->OnChangeCompleted(change_id, |
+ SetModal(ClientWindowId(window_id), modal_type)); |
} |
void WindowTree::ReorderWindow(uint32_t change_id, |