| 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 "chrome/browser/ui/views/apps/chrome_native_app_window_views_aura.h" | 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_aura.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "apps/ui/views/app_window_frame_view.h" | 9 #include "apps/ui/views/app_window_frame_view.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // window. The root window does not have a delegate, which is needed to | 86 // window. The root window does not have a delegate, which is needed to |
| 87 // handle the event in Linux. | 87 // handle the event in Linux. |
| 88 window->SetEventTargeter( | 88 window->SetEventTargeter( |
| 89 std::unique_ptr<ui::EventTargeter>(new AppWindowEasyResizeWindowTargeter( | 89 std::unique_ptr<ui::EventTargeter>(new AppWindowEasyResizeWindowTargeter( |
| 90 window, gfx::Insets(frame->resize_inside_bounds_size()), this))); | 90 window, gfx::Insets(frame->resize_inside_bounds_size()), this))); |
| 91 | 91 |
| 92 return frame; | 92 return frame; |
| 93 } | 93 } |
| 94 | 94 |
| 95 ui::WindowShowState ChromeNativeAppWindowViewsAura::GetRestoredState() const { | 95 ui::WindowShowState ChromeNativeAppWindowViewsAura::GetRestoredState() const { |
| 96 // Use kRestoreShowStateKey in case a window is minimized/hidden. | |
| 97 ui::WindowShowState restore_state = widget()->GetNativeWindow()->GetProperty( | |
| 98 aura::client::kRestoreShowStateKey); | |
| 99 | |
| 100 // First normal states are checked. | 96 // First normal states are checked. |
| 101 if (IsMaximized()) | 97 if (IsMaximized()) |
| 102 return ui::SHOW_STATE_MAXIMIZED; | 98 return ui::SHOW_STATE_MAXIMIZED; |
| 103 if (IsFullscreen()) { | 99 if (IsFullscreen()) { |
| 104 return ui::SHOW_STATE_FULLSCREEN; | 100 return ui::SHOW_STATE_FULLSCREEN; |
| 105 } | 101 } |
| 106 | 102 |
| 107 if (widget()->GetNativeWindow()->GetProperty( | 103 // Use kPreMinimizedShowStateKey in case a window is minimized/hidden. |
| 108 aura::client::kShowStateKey) == ui::SHOW_STATE_DOCKED || | 104 ui::WindowShowState restore_state = widget()->GetNativeWindow()->GetProperty( |
| 109 widget()->GetNativeWindow()->GetProperty( | 105 aura::client::kPreMinimizedShowStateKey); |
| 110 aura::client::kRestoreShowStateKey) == ui::SHOW_STATE_DOCKED) { | 106 if (widget()->GetNativeWindow()->GetProperty(aura::client::kShowStateKey) == |
| 107 ui::SHOW_STATE_DOCKED || |
| 108 restore_state == ui::SHOW_STATE_DOCKED) { |
| 111 return ui::SHOW_STATE_DOCKED; | 109 return ui::SHOW_STATE_DOCKED; |
| 112 } | 110 } |
| 113 | 111 |
| 114 return GetRestorableState(restore_state); | 112 return GetRestorableState(restore_state); |
| 115 } | 113 } |
| 116 | 114 |
| 117 bool ChromeNativeAppWindowViewsAura::IsAlwaysOnTop() const { | 115 bool ChromeNativeAppWindowViewsAura::IsAlwaysOnTop() const { |
| 118 return widget()->IsAlwaysOnTop(); | 116 return widget()->IsAlwaysOnTop(); |
| 119 } | 117 } |
| 120 | 118 |
| 121 void ChromeNativeAppWindowViewsAura::UpdateShape( | 119 void ChromeNativeAppWindowViewsAura::UpdateShape( |
| 122 std::unique_ptr<SkRegion> region) { | 120 std::unique_ptr<SkRegion> region) { |
| 123 bool had_shape = !!shape(); | 121 bool had_shape = !!shape(); |
| 124 | 122 |
| 125 ChromeNativeAppWindowViews::UpdateShape(std::move(region)); | 123 ChromeNativeAppWindowViews::UpdateShape(std::move(region)); |
| 126 | 124 |
| 127 aura::Window* native_window = widget()->GetNativeWindow(); | 125 aura::Window* native_window = widget()->GetNativeWindow(); |
| 128 if (shape() && !had_shape) { | 126 if (shape() && !had_shape) { |
| 129 native_window->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | 127 native_window->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
| 130 new ShapedAppWindowTargeter(native_window, this))); | 128 new ShapedAppWindowTargeter(native_window, this))); |
| 131 } else if (!shape() && had_shape) { | 129 } else if (!shape() && had_shape) { |
| 132 native_window->SetEventTargeter(std::unique_ptr<ui::EventTargeter>()); | 130 native_window->SetEventTargeter(std::unique_ptr<ui::EventTargeter>()); |
| 133 } | 131 } |
| 134 } | 132 } |
| OLD | NEW |