diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-02-15 18:33:02 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-02-15 18:33:02 +0100 |
| commit | b269554390967750612ed3d368e985e8be6e17fc (patch) | |
| tree | b43eada8e7dfd77f44f71c221a57a80d06db7c7f /unity-shared | |
| parent | 56bf317b03358b317e33a889b7a828e6a455d4c9 (diff) | |
WindowButtons: toggle the overlay_mode to match spread state
(bzr r3656.2.9)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/WindowButtons.cpp | 41 | ||||
| -rw-r--r-- | unity-shared/WindowButtons.h | 3 |
2 files changed, 39 insertions, 5 deletions
diff --git a/unity-shared/WindowButtons.cpp b/unity-shared/WindowButtons.cpp index ba62f487b..6f6c2d862 100644 --- a/unity-shared/WindowButtons.cpp +++ b/unity-shared/WindowButtons.cpp @@ -317,6 +317,8 @@ WindowButtons::WindowButtons() ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &WindowButtons::OnOverlayShown)); ubus_manager_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &WindowButtons::OnOverlayHidden)); Settings::Instance().form_factor.changed.connect(sigc::mem_fun(this, &WindowButtons::OnDashSettingsUpdated)); + WindowManager::Default().initiate_spread.connect(sigc::mem_fun(this, &WindowButtons::OnSpreadInitiate)); + WindowManager::Default().terminate_spread.connect(sigc::mem_fun(this, &WindowButtons::OnSpreadTerminate)); } nux::Area* WindowButtons::FindAreaUnderMouse(const nux::Point& mouse, nux::NuxEventType event_type) @@ -362,7 +364,12 @@ void WindowButtons::OnCloseClicked(nux::Button *button) if (win_button->overlay_mode()) { - ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); + auto& wm = WindowManager::Default(); + + if (wm.IsScaleActive()) + wm.TerminateScale(); + else + ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); } else { @@ -488,9 +495,6 @@ void WindowButtons::OnOverlayShown(GVariant* data) void WindowButtons::OnOverlayHidden(GVariant* data) { - internal::WindowButton* maximize_button = nullptr; - internal::WindowButton* restore_button = nullptr; - glib::String overlay_identity; gboolean can_maximise = FALSE; gint32 overlay_monitor = 0; @@ -509,10 +513,37 @@ void WindowButtons::OnOverlayHidden(GVariant* data) active_overlay_ = ""; - WindowManager& wm = WindowManager::Default(); + if (!WindowManager::Default().IsScaleActive()) + ResetNormalButtonState(); +} + +void WindowButtons::OnSpreadInitiate() +{ for (auto area : GetChildren()) { auto button = static_cast<internal::WindowButton*>(area); + button->enabled = (button->GetType() == panel::WindowButtonType::CLOSE); + button->overlay_mode = true; + } +} + +void WindowButtons::OnSpreadTerminate() +{ + if (!active_overlay_.empty()) + return; + + ResetNormalButtonState(); +} + +void WindowButtons::ResetNormalButtonState() +{ + WindowManager& wm = WindowManager::Default(); + internal::WindowButton* maximize_button = nullptr; + internal::WindowButton* restore_button = nullptr; + + for (auto* area : GetChildren()) + { + auto button = static_cast<internal::WindowButton*>(area); if (controlled_window()) { diff --git a/unity-shared/WindowButtons.h b/unity-shared/WindowButtons.h index bead1078b..98ccf3d2e 100644 --- a/unity-shared/WindowButtons.h +++ b/unity-shared/WindowButtons.h @@ -65,8 +65,11 @@ private: void OnMaximizeClicked(nux::Button *button); void OnOverlayShown(GVariant* data); void OnOverlayHidden(GVariant* data); + void OnSpreadInitiate(); + void OnSpreadTerminate(); void OnDashSettingsUpdated(FormFactor form_factor); void OnControlledWindowChanged(Window xid); + void ResetNormalButtonState(); bool OpacitySetter(double& target, double new_value); std::string active_overlay_; |
