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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 window->SetName("ExoShellSurface"); | 925 window->SetName("ExoShellSurface"); |
| 926 window->AddChild(surface_->window()); | 926 window->AddChild(surface_->window()); |
| 927 window->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); | 927 window->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); |
| 928 SetApplicationId(window, &application_id_); | 928 SetApplicationId(window, &application_id_); |
| 929 SetMainSurface(window, surface_); | 929 SetMainSurface(window, surface_); |
| 930 | 930 |
| 931 // Start tracking changes to window bounds and window state. | 931 // Start tracking changes to window bounds and window state. |
| 932 window->AddObserver(this); | 932 window->AddObserver(this); |
| 933 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window); | 933 ash::wm::WindowState* window_state = ash::wm::GetWindowState(window); |
| 934 window_state->AddObserver(this); | 934 window_state->AddObserver(this); |
| 935 | |
| 936 // Absolete positioned shell surfaces may request the bounds that does not | |
| 937 // fill the entire work area / display in maximized / fullscreen state. | |
| 938 // Allow such clients to update the bounds in these states. | |
| 939 if (!initial_bounds_.IsEmpty() && activatable_) | |
| 940 window_state->set_allow_set_bounds_in_maximized(true); | |
| 941 | |
| 935 // Notify client of initial state if different than normal. | 942 // Notify client of initial state if different than normal. |
| 936 if (window_state->GetStateType() != ash::wm::WINDOW_STATE_TYPE_NORMAL && | 943 if (window_state->GetStateType() != ash::wm::WINDOW_STATE_TYPE_NORMAL && |
| 937 !state_changed_callback_.is_null()) { | 944 !state_changed_callback_.is_null()) { |
| 938 state_changed_callback_.Run(ash::wm::WINDOW_STATE_TYPE_NORMAL, | 945 state_changed_callback_.Run(ash::wm::WINDOW_STATE_TYPE_NORMAL, |
| 939 window_state->GetStateType()); | 946 window_state->GetStateType()); |
| 940 } | 947 } |
| 941 | 948 |
| 942 // Disable movement if initial bounds were specified. | 949 // Disable movement if initial bounds were specified. |
| 943 widget_->set_movement_disabled(!initial_bounds_.IsEmpty()); | 950 widget_->set_movement_disabled(!initial_bounds_.IsEmpty()); |
| 944 window_state->set_ignore_keyboard_bounds_change(!initial_bounds_.IsEmpty()); | 951 window_state->set_ignore_keyboard_bounds_change(!initial_bounds_.IsEmpty()); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1146 default: | 1153 default: |
| 1147 NOTREACHED(); | 1154 NOTREACHED(); |
| 1148 return gfx::Point(); | 1155 return gfx::Point(); |
| 1149 } | 1156 } |
| 1150 } | 1157 } |
| 1151 | 1158 |
| 1152 void ShellSurface::UpdateWidgetBounds() { | 1159 void ShellSurface::UpdateWidgetBounds() { |
| 1153 DCHECK(widget_); | 1160 DCHECK(widget_); |
| 1154 | 1161 |
| 1155 // Return early if the shell is currently managing the bounds of the widget. | 1162 // Return early if the shell is currently managing the bounds of the widget. |
| 1156 if (widget_->IsMaximized() || widget_->IsFullscreen() || IsResizing()) | 1163 if (((widget_->IsMaximized() || widget_->IsFullscreen()) && |
|
reveman
2016/08/12 23:44:40
please split this into multiple early outs. someth
oshima
2016/08/13 00:45:07
splitting done. I still think it's better to use a
| |
| 1164 !ash::wm::GetWindowState(widget_->GetNativeWindow()) | |
| 1165 ->allow_set_bounds_in_maximized()) || | |
| 1166 IsResizing()) { | |
| 1157 return; | 1167 return; |
| 1168 } | |
| 1158 | 1169 |
| 1159 // Return early if there is pending configure requests. | 1170 // Return early if there is pending configure requests. |
| 1160 if (!pending_configs_.empty() || scoped_configure_) | 1171 if (!pending_configs_.empty() || scoped_configure_) |
| 1161 return; | 1172 return; |
| 1162 | 1173 |
| 1163 gfx::Rect visible_bounds = GetVisibleBounds(); | 1174 gfx::Rect visible_bounds = GetVisibleBounds(); |
| 1164 gfx::Rect new_widget_bounds = visible_bounds; | 1175 gfx::Rect new_widget_bounds = visible_bounds; |
| 1165 | 1176 |
| 1166 // Avoid changing widget origin unless initial bounds were specified and | 1177 // Avoid changing widget origin unless initial bounds were specified and |
| 1167 // widget origin is always relative to it. | 1178 // widget origin is always relative to it. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1242 shadow_overlay_->layer()->Add(shadow->layer()); | 1253 shadow_overlay_->layer()->Add(shadow->layer()); |
| 1243 window->AddChild(shadow_overlay_); | 1254 window->AddChild(shadow_overlay_); |
| 1244 shadow_overlay_->Show(); | 1255 shadow_overlay_->Show(); |
| 1245 } | 1256 } |
| 1246 shadow_overlay_->SetBounds(shadow_bounds); | 1257 shadow_overlay_->SetBounds(shadow_bounds); |
| 1247 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); | 1258 shadow->SetContentBounds(gfx::Rect(shadow_bounds.size())); |
| 1248 } | 1259 } |
| 1249 } | 1260 } |
| 1250 | 1261 |
| 1251 } // namespace exo | 1262 } // namespace exo |
| OLD | NEW |