Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: ash/common/wm/window_state.cc

Issue 2778733004: Add WindowPinType property on arua::Window (Closed)
Patch Set: Address review issues. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/common/wm/window_state.h" 5 #include "ash/common/wm/window_state.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/wm/default_state.h" 9 #include "ash/common/wm/default_state.h"
10 #include "ash/common/wm/window_positioning_utils.h" 10 #include "ash/common/wm/window_positioning_utils.h"
(...skipping 23 matching lines...) Expand all
34 case ui::SHOW_STATE_INACTIVE: 34 case ui::SHOW_STATE_INACTIVE:
35 return WM_EVENT_SHOW_INACTIVE; 35 return WM_EVENT_SHOW_INACTIVE;
36 36
37 case ui::SHOW_STATE_END: 37 case ui::SHOW_STATE_END:
38 NOTREACHED() << "No WMEvent defined for the show state:" 38 NOTREACHED() << "No WMEvent defined for the show state:"
39 << requested_show_state; 39 << requested_show_state;
40 } 40 }
41 return WM_EVENT_NORMAL; 41 return WM_EVENT_NORMAL;
42 } 42 }
43 43
44 WMEventType WMEventTypeFromWindowPinType(aura::client::WindowPinType type) {
45 switch (type) {
46 case aura::client::WindowPinType::NONE:
47 return WM_EVENT_NORMAL;
48 case aura::client::WindowPinType::PINNED:
49 return WM_EVENT_PIN;
50 case aura::client::WindowPinType::TRUSTED_PINNED:
51 return WM_EVENT_TRUSTED_PIN;
52 }
53 return WM_EVENT_NORMAL;
54 }
55
44 } // namespace 56 } // namespace
45 57
46 WindowState::~WindowState() {} 58 WindowState::~WindowState() {}
47 59
48 bool WindowState::HasDelegate() const { 60 bool WindowState::HasDelegate() const {
49 return !!delegate_; 61 return !!delegate_;
50 } 62 }
51 63
52 void WindowState::SetDelegate(std::unique_ptr<WindowStateDelegate> delegate) { 64 void WindowState::SetDelegate(std::unique_ptr<WindowStateDelegate> delegate) {
53 DCHECK(!delegate_.get()); 65 DCHECK(!delegate_.get());
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 ClearRestoreBounds(); 291 ClearRestoreBounds();
280 } 292 }
281 293
282 void WindowState::OnWindowShowStateChanged() { 294 void WindowState::OnWindowShowStateChanged() {
283 if (!ignore_property_change_) { 295 if (!ignore_property_change_) {
284 WMEvent event(WMEventTypeFromShowState(GetShowState())); 296 WMEvent event(WMEventTypeFromShowState(GetShowState()));
285 OnWMEvent(&event); 297 OnWMEvent(&event);
286 } 298 }
287 } 299 }
288 300
301 void WindowState::OnWindowPinTypeChanged() {
302 if (!ignore_property_change_) {
303 WMEvent event(WMEventTypeFromWindowPinType(window_->GetPinType()));
304 OnWMEvent(&event);
305 }
306 }
307
289 WindowState::WindowState(WmWindow* window) 308 WindowState::WindowState(WmWindow* window)
290 : window_(window), 309 : window_(window),
291 window_position_managed_(false), 310 window_position_managed_(false),
292 bounds_changed_by_user_(false), 311 bounds_changed_by_user_(false),
293 ignored_by_shelf_(false), 312 ignored_by_shelf_(false),
294 can_consume_system_keys_(false), 313 can_consume_system_keys_(false),
295 unminimize_to_restore_bounds_(false), 314 unminimize_to_restore_bounds_(false),
296 in_immersive_fullscreen_(false), 315 in_immersive_fullscreen_(false),
297 hide_shelf_when_fullscreen_(true), 316 hide_shelf_when_fullscreen_(true),
298 minimum_visibility_(false), 317 minimum_visibility_(false),
(...skipping 21 matching lines...) Expand all
320 return; 339 return;
321 gfx::Rect maximized_bounds = GetMaximizedWindowBoundsInParent(window_); 340 gfx::Rect maximized_bounds = GetMaximizedWindowBoundsInParent(window_);
322 if (GetStateType() == WINDOW_STATE_TYPE_LEFT_SNAPPED) 341 if (GetStateType() == WINDOW_STATE_TYPE_LEFT_SNAPPED)
323 bounds->set_x(maximized_bounds.x()); 342 bounds->set_x(maximized_bounds.x());
324 else if (GetStateType() == WINDOW_STATE_TYPE_RIGHT_SNAPPED) 343 else if (GetStateType() == WINDOW_STATE_TYPE_RIGHT_SNAPPED)
325 bounds->set_x(maximized_bounds.right() - bounds->width()); 344 bounds->set_x(maximized_bounds.right() - bounds->width());
326 bounds->set_y(maximized_bounds.y()); 345 bounds->set_y(maximized_bounds.y());
327 bounds->set_height(maximized_bounds.height()); 346 bounds->set_height(maximized_bounds.height());
328 } 347 }
329 348
330 void WindowState::UpdateWindowShowStateFromStateType() { 349 void WindowState::UpdateWindowPropertiesFromStateType() {
331 ui::WindowShowState new_window_state = 350 ui::WindowShowState new_window_state =
332 ToWindowShowState(current_state_->GetType()); 351 ToWindowShowState(current_state_->GetType());
333 if (new_window_state != GetShowState()) { 352 if (new_window_state != GetShowState()) {
334 base::AutoReset<bool> resetter(&ignore_property_change_, true); 353 base::AutoReset<bool> resetter(&ignore_property_change_, true);
335 window_->SetShowState(new_window_state); 354 window_->SetShowState(new_window_state);
336 } 355 }
356
357 // sync up current window show state with PinType property.
358 aura::client::WindowPinType pin_type = aura::client::WindowPinType::NONE;
359 if (GetStateType() == WINDOW_STATE_TYPE_PINNED)
360 pin_type = aura::client::WindowPinType::PINNED;
361 else if (GetStateType() == WINDOW_STATE_TYPE_TRUSTED_PINNED)
362 pin_type = aura::client::WindowPinType::TRUSTED_PINNED;
363 if (pin_type != window_->GetPinType()) {
364 base::AutoReset<bool> resetter(&ignore_property_change_, true);
365 window_->SetPinType(pin_type);
366 }
337 } 367 }
338 368
339 void WindowState::NotifyPreStateTypeChange( 369 void WindowState::NotifyPreStateTypeChange(
340 WindowStateType old_window_state_type) { 370 WindowStateType old_window_state_type) {
341 for (auto& observer : observer_list_) 371 for (auto& observer : observer_list_)
342 observer.OnPreWindowStateTypeChange(this, old_window_state_type); 372 observer.OnPreWindowStateTypeChange(this, old_window_state_type);
343 } 373 }
344 374
345 void WindowState::NotifyPostStateTypeChange( 375 void WindowState::NotifyPostStateTypeChange(
346 WindowStateType old_window_state_type) { 376 WindowStateType old_window_state_type) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 if (!window_->GetTargetVisibility()) { 413 if (!window_->GetTargetVisibility()) {
384 SetBoundsConstrained(new_bounds); 414 SetBoundsConstrained(new_bounds);
385 return; 415 return;
386 } 416 }
387 417
388 window_->SetBoundsDirectCrossFade(new_bounds); 418 window_->SetBoundsDirectCrossFade(new_bounds);
389 } 419 }
390 420
391 } // namespace wm 421 } // namespace wm
392 } // namespace ash 422 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698