Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium 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 "components/exo/shell_surface.h" | 5 #include "components/exo/shell_surface.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/shell_window_ids.h" | 8 #include "ash/common/shell_window_ids.h" |
| 9 #include "ash/common/wm/window_resizer.h" | 9 #include "ash/common/wm/window_resizer.h" |
| 10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 880 DCHECK(enabled()); | 880 DCHECK(enabled()); |
| 881 DCHECK(!widget_); | 881 DCHECK(!widget_); |
| 882 | 882 |
| 883 views::Widget::InitParams params; | 883 views::Widget::InitParams params; |
| 884 params.type = views::Widget::InitParams::TYPE_WINDOW; | 884 params.type = views::Widget::InitParams::TYPE_WINDOW; |
| 885 params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; | 885 params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; |
| 886 params.delegate = this; | 886 params.delegate = this; |
| 887 params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE; | 887 params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE; |
| 888 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 888 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 889 params.show_state = show_state; | 889 params.show_state = show_state; |
| 890 params.parent = | 890 // Make shell surface a transient child if |parent_| has been set. |
| 891 ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), container_); | 891 params.parent = parent_ ? parent_ : |
|
reveman
2016/07/29 18:27:07
Pretty sure this will break xdg shell modal dialog
oshima
2016/07/29 20:35:58
That's still not right. Let's discuss offline.
Dominik Laskowski
2016/07/29 20:37:09
Unless |params.child| is true, Widget::Init makes
| |
| 892 ash::Shell::GetContainer(ash::Shell::GetTargetRootWindow(), container_); | |
| 892 params.bounds = initial_bounds_; | 893 params.bounds = initial_bounds_; |
| 893 bool activatable = activatable_; | 894 bool activatable = activatable_; |
| 894 // ShellSurfaces in system modal container are only activatable if input | 895 // ShellSurfaces in system modal container are only activatable if input |
| 895 // region is non-empty. See OnCommitSurface() for more details. | 896 // region is non-empty. See OnCommitSurface() for more details. |
| 896 if (container_ == ash::kShellWindowId_SystemModalContainer) | 897 if (container_ == ash::kShellWindowId_SystemModalContainer) |
| 897 activatable &= !surface_->GetHitTestBounds().IsEmpty(); | 898 activatable &= !surface_->GetHitTestBounds().IsEmpty(); |
| 898 params.activatable = activatable ? views::Widget::InitParams::ACTIVATABLE_YES | 899 params.activatable = activatable ? views::Widget::InitParams::ACTIVATABLE_YES |
| 899 : views::Widget::InitParams::ACTIVATABLE_NO; | 900 : views::Widget::InitParams::ACTIVATABLE_NO; |
| 900 | 901 |
| 901 // Note: NativeWidget owns this widget. | 902 // Note: NativeWidget owns this widget. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 917 if (window_state->GetStateType() != ash::wm::WINDOW_STATE_TYPE_NORMAL && | 918 if (window_state->GetStateType() != ash::wm::WINDOW_STATE_TYPE_NORMAL && |
| 918 !state_changed_callback_.is_null()) { | 919 !state_changed_callback_.is_null()) { |
| 919 state_changed_callback_.Run(ash::wm::WINDOW_STATE_TYPE_NORMAL, | 920 state_changed_callback_.Run(ash::wm::WINDOW_STATE_TYPE_NORMAL, |
| 920 window_state->GetStateType()); | 921 window_state->GetStateType()); |
| 921 } | 922 } |
| 922 | 923 |
| 923 // Disable movement if initial bounds were specified. | 924 // Disable movement if initial bounds were specified. |
| 924 widget_->set_movement_disabled(!initial_bounds_.IsEmpty()); | 925 widget_->set_movement_disabled(!initial_bounds_.IsEmpty()); |
| 925 window_state->set_ignore_keyboard_bounds_change(!initial_bounds_.IsEmpty()); | 926 window_state->set_ignore_keyboard_bounds_change(!initial_bounds_.IsEmpty()); |
| 926 | 927 |
| 927 // Make shell surface a transient child if |parent_| has been set. | |
| 928 if (parent_) | |
| 929 wm::AddTransientChild(parent_, window); | |
| 930 | |
| 931 // Allow Ash to manage the position of a top-level shell surfaces if show | 928 // Allow Ash to manage the position of a top-level shell surfaces if show |
| 932 // state is one that allows auto positioning and |initial_bounds_| has | 929 // state is one that allows auto positioning and |initial_bounds_| has |
| 933 // not been set. | 930 // not been set. |
| 934 window_state->set_window_position_managed( | 931 window_state->set_window_position_managed( |
| 935 ash::wm::ToWindowShowState(ash::wm::WINDOW_STATE_TYPE_AUTO_POSITIONED) == | 932 ash::wm::ToWindowShowState(ash::wm::WINDOW_STATE_TYPE_AUTO_POSITIONED) == |
| 936 show_state && | 933 show_state && |
| 937 initial_bounds_.IsEmpty()); | 934 initial_bounds_.IsEmpty()); |
| 938 | 935 |
| 939 // Register close window accelerators. | 936 // Register close window accelerators. |
| 940 views::FocusManager* focus_manager = widget_->GetFocusManager(); | 937 views::FocusManager* focus_manager = widget_->GetFocusManager(); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1223 shadow_origin -= origin.OffsetFromOrigin(); | 1220 shadow_origin -= origin.OffsetFromOrigin(); |
| 1224 gfx::Rect shadow_bounds(shadow_origin, shadow_content_bounds_.size()); | 1221 gfx::Rect shadow_bounds(shadow_origin, shadow_content_bounds_.size()); |
| 1225 | 1222 |
| 1226 shadow_overlay_->SetBounds(shadow_bounds); | 1223 shadow_overlay_->SetBounds(shadow_bounds); |
| 1227 shadow_underlay_->SetBounds(shadow_bounds); | 1224 shadow_underlay_->SetBounds(shadow_bounds); |
| 1228 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); | 1225 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); |
| 1229 } | 1226 } |
| 1230 } | 1227 } |
| 1231 | 1228 |
| 1232 } // namespace exo | 1229 } // namespace exo |
| OLD | NEW |