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

Unified Diff: ash/common/wm/window_state.cc

Issue 2778733004: Add WindowPinType property on arua::Window (Closed)
Patch Set: Address review issues. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ash/common/wm/window_state.cc
diff --git a/ash/common/wm/window_state.cc b/ash/common/wm/window_state.cc
index 04f737ab16dce75e84a8f246341e97774589f8cb..2d836b9639f144e7007a5af0410279177056d7c5 100644
--- a/ash/common/wm/window_state.cc
+++ b/ash/common/wm/window_state.cc
@@ -41,6 +41,18 @@ WMEventType WMEventTypeFromShowState(ui::WindowShowState requested_show_state) {
return WM_EVENT_NORMAL;
}
+WMEventType WMEventTypeFromWindowPinType(aura::client::WindowPinType type) {
+ switch (type) {
+ case aura::client::WindowPinType::NONE:
+ return WM_EVENT_NORMAL;
+ case aura::client::WindowPinType::PINNED:
+ return WM_EVENT_PIN;
+ case aura::client::WindowPinType::TRUSTED_PINNED:
+ return WM_EVENT_TRUSTED_PIN;
+ }
+ return WM_EVENT_NORMAL;
+}
+
} // namespace
WindowState::~WindowState() {}
@@ -286,6 +298,13 @@ void WindowState::OnWindowShowStateChanged() {
}
}
+void WindowState::OnWindowPinTypeChanged() {
+ if (!ignore_property_change_) {
+ WMEvent event(WMEventTypeFromWindowPinType(window_->GetPinType()));
+ OnWMEvent(&event);
+ }
+}
+
WindowState::WindowState(WmWindow* window)
: window_(window),
window_position_managed_(false),
@@ -327,13 +346,24 @@ void WindowState::AdjustSnappedBounds(gfx::Rect* bounds) {
bounds->set_height(maximized_bounds.height());
}
-void WindowState::UpdateWindowShowStateFromStateType() {
+void WindowState::UpdateWindowPropertiesFromStateType() {
ui::WindowShowState new_window_state =
ToWindowShowState(current_state_->GetType());
if (new_window_state != GetShowState()) {
base::AutoReset<bool> resetter(&ignore_property_change_, true);
window_->SetShowState(new_window_state);
}
+
+ // sync up current window show state with PinType property.
+ aura::client::WindowPinType pin_type = aura::client::WindowPinType::NONE;
+ if (GetStateType() == WINDOW_STATE_TYPE_PINNED)
+ pin_type = aura::client::WindowPinType::PINNED;
+ else if (GetStateType() == WINDOW_STATE_TYPE_TRUSTED_PINNED)
+ pin_type = aura::client::WindowPinType::TRUSTED_PINNED;
+ if (pin_type != window_->GetPinType()) {
+ base::AutoReset<bool> resetter(&ignore_property_change_, true);
+ window_->SetPinType(pin_type);
+ }
}
void WindowState::NotifyPreStateTypeChange(

Powered by Google App Engine
This is Rietveld 408576698