diff options
| author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2011-12-08 00:19:52 -0500 |
|---|---|---|
| committer | Tarmac <> | 2011-12-08 00:19:52 -0500 |
| commit | d227f30af1f683ba1651e873d5838e671b278128 (patch) | |
| tree | da756e383233aabbb7fdbe8ccdb90a1d1320f7e5 | |
| parent | c5db72096a49f288c97f33ac89db16ab28f3ab5b (diff) | |
| parent | 9555dc02932264630049133f5e14e2875ce45273 (diff) | |
As requested on bug #807891 I've added an option to toggle the panel opacity if a window is currently maximized (and visible) in the current workspace.
Test is missing, it will be added once the autopilot will be available.. Fixes: https://bugs.launchpad.net/bugs/807891. Appoved by Tim Penhey. (bzr r1770)
| -rw-r--r-- | manual-tests/Panel.txt | 18 | ||||
| -rw-r--r-- | plugins/unityshell/src/PanelController.cpp | 20 | ||||
| -rw-r--r-- | plugins/unityshell/src/PanelController.h | 1 | ||||
| -rw-r--r-- | plugins/unityshell/src/PanelView.cpp | 54 | ||||
| -rw-r--r-- | plugins/unityshell/src/PanelView.h | 3 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 4 | ||||
| -rw-r--r-- | plugins/unityshell/unityshell.xml.in | 31 |
7 files changed, 115 insertions, 16 deletions
diff --git a/manual-tests/Panel.txt b/manual-tests/Panel.txt new file mode 100644 index 000000000..5c2567837 --- /dev/null +++ b/manual-tests/Panel.txt @@ -0,0 +1,18 @@ +Panel Opacity Toggle +-------------------- +This test shows how works the panel_opacity_maximized_toggle unity option + +#. Open CCSM +#. Go in the "Experimental" tab +#. Set the "Panel Opacity" setting to a value less than 1.0 (best is 0.0 for testing) +#. Enable the "Panel Opacity for Maximized Windows Toggle" +#. Close all your opened windows +#. The panel should be transparent according to the opacity setting +#. Now open a window and make sure it is restored +#. Open another Window and make it maximized + +Outcome + When there's at least one maximized window on the current screen, the panel + should become opaque, also if the opacity setting is set to 0.0. + Once all the maximized windows are closed, restored or not visible, + the panel should go back to its defined opacity. diff --git a/plugins/unityshell/src/PanelController.cpp b/plugins/unityshell/src/PanelController.cpp index 2c4042257..20e0204e1 100644 --- a/plugins/unityshell/src/PanelController.cpp +++ b/plugins/unityshell/src/PanelController.cpp @@ -51,6 +51,8 @@ public: // NOTE: nux::Property maybe? void SetOpacity(float opacity); + void SetOpacityMaximizedToggle(bool enabled); + float opacity() const; private: @@ -64,12 +66,14 @@ private: private: std::vector<nux::BaseWindow*> windows_; float opacity_; + bool opacity_maximized_toggle_; bool open_menu_start_received_; }; Controller::Impl::Impl() : opacity_(1.0f) + , opacity_maximized_toggle_(false) , open_menu_start_received_(false) { UScreen* screen = UScreen::GetDefault(); @@ -139,6 +143,16 @@ void Controller::Impl::SetOpacity(float opacity) } } +void Controller::Impl::SetOpacityMaximizedToggle(bool enabled) +{ + opacity_maximized_toggle_ = enabled; + + for (auto window : windows_) + { + ViewForWindow(window)->SetOpacityMaximizedToggle(opacity_maximized_toggle_); + } +} + void Controller::Impl::QueueRedraw() { for (auto window: windows_) @@ -201,6 +215,7 @@ void Controller::Impl::OnScreenChanged(int primary_monitor, PanelView* view = new PanelView(); view->SetMaximumHeight(24); view->SetOpacity(opacity_); + view->SetOpacityMaximizedToggle(opacity_maximized_toggle_); view->SetPrimary(i == primary_monitor); view->SetMonitor(i); @@ -281,6 +296,11 @@ void Controller::SetOpacity(float opacity) pimpl->SetOpacity(opacity); } +void Controller::SetOpacityMaximizedToggle(bool enabled) +{ + pimpl->SetOpacityMaximizedToggle(enabled); +} + void Controller::QueueRedraw() { pimpl->QueueRedraw(); diff --git a/plugins/unityshell/src/PanelController.h b/plugins/unityshell/src/PanelController.h index b82e48d17..b5e4d0103 100644 --- a/plugins/unityshell/src/PanelController.h +++ b/plugins/unityshell/src/PanelController.h @@ -47,6 +47,7 @@ public: // NOTE: nux::Property maybe? void SetOpacity(float opacity); + void SetOpacityMaximizedToggle(bool enabled); float opacity() const; private: diff --git a/plugins/unityshell/src/PanelView.cpp b/plugins/unityshell/src/PanelView.cpp index fd5b953ca..fa6579ae1 100644 --- a/plugins/unityshell/src/PanelView.cpp +++ b/plugins/unityshell/src/PanelView.cpp @@ -56,6 +56,7 @@ PanelView::PanelView(NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM), _is_dirty(true), _opacity(1.0f), + _opacity_maximized_toggle(false), _is_primary(false), _monitor(0), _dash_is_open(false) @@ -139,7 +140,12 @@ PanelView::~PanelView() ubus_server_unregister_interest(ubus, _handle_bg_color_update); ubus_server_unregister_interest(ubus, _handle_dash_hidden); ubus_server_unregister_interest(ubus, _handle_dash_shown); - _on_indicator_updated_connections.clear(); + + for (auto conn : _on_indicator_updated_connections) + conn.disconnect(); + + for (auto conn : _maximized_opacity_toggle_connections) + conn.disconnect(); indicator::EntryLocationMap locations; _remote->SyncGeometries(GetName() + boost::lexical_cast<std::string>(_monitor), locations); @@ -362,8 +368,10 @@ PanelView::UpdateBackground() _last_width = geo.width; _last_height = geo.height; _is_dirty = false; + + guint32 maximized_win = _menu_view->GetMaximizedWindow(); - if (_dash_is_open && (_menu_view->GetMaximizedWindow() == 0)) + if (_dash_is_open && maximized_win == 0) { if (_bg_layer) delete _bg_layer; @@ -375,7 +383,14 @@ PanelView::UpdateBackground() } else { - nux::NBitmapData* bitmap = panel::Style::Instance().GetBackground(geo.width, geo.height, _opacity); + double opacity = _opacity; + if (_opacity_maximized_toggle && maximized_win != 0 && + !WindowManager::Default()->IsWindowObscured(maximized_win)) + { + opacity = 1.0f; + } + + nux::NBitmapData* bitmap = panel::Style::Instance().GetBackground(geo.width, geo.height, opacity); nux::BaseTexture* texture2D = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture(); texture2D->Update(bitmap); delete bitmap; @@ -599,6 +614,39 @@ PanelView::SetOpacity(float opacity) ForceUpdateBackground(); } +void +PanelView::SetOpacityMaximizedToggle(bool enabled) +{ + if (_opacity_maximized_toggle != enabled) + { + if (enabled) + { + auto win_manager = WindowManager::Default(); + auto update_bg_lambda = [&](guint32) { ForceUpdateBackground(); }; + auto conn = &_maximized_opacity_toggle_connections; + + conn->push_back(win_manager->window_minimized.connect(update_bg_lambda)); + conn->push_back(win_manager->window_unminimized.connect(update_bg_lambda)); + conn->push_back(win_manager->window_maximized.connect(update_bg_lambda)); + conn->push_back(win_manager->window_restored.connect(update_bg_lambda)); + conn->push_back(win_manager->window_mapped.connect(update_bg_lambda)); + conn->push_back(win_manager->window_unmapped.connect(update_bg_lambda)); + conn->push_back(win_manager->compiz_screen_viewport_switch_ended.connect( + sigc::mem_fun(this, &PanelView::ForceUpdateBackground))); + } + else + { + for (auto conn : _maximized_opacity_toggle_connections) + conn.disconnect(); + + _maximized_opacity_toggle_connections.clear(); + } + + _opacity_maximized_toggle = enabled; + ForceUpdateBackground(); + } +} + bool PanelView::GetPrimary() { diff --git a/plugins/unityshell/src/PanelView.h b/plugins/unityshell/src/PanelView.h index cce783943..5a64da526 100644 --- a/plugins/unityshell/src/PanelView.h +++ b/plugins/unityshell/src/PanelView.h @@ -70,6 +70,7 @@ public: void EndFirstMenuShow(); void SetOpacity(float opacity); + void SetOpacityMaximizedToggle(bool enabled); void TrackMenuPointer(); @@ -110,6 +111,7 @@ private: nux::Color _bg_color; bool _is_dirty; float _opacity; + bool _opacity_maximized_toggle; bool _needs_geo_sync; bool _is_primary; int _monitor; @@ -122,6 +124,7 @@ private: nux::Point _tracked_pointer_pos; std::vector<sigc::connection> _on_indicator_updated_connections; + std::vector<sigc::connection> _maximized_opacity_toggle_connections; BackgroundEffectHelper bg_effect_helper_; nux::ObjectPtr <nux::IOpenGLBaseTexture> bg_blur_texture_; }; diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index dff0c9013..c7805c5a3 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -239,6 +239,7 @@ UnityScreen::UnityScreen(CompScreen* screen) optionSetLaunchAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); optionSetUrgentAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); optionSetPanelOpacityNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); + optionSetPanelOpacityMaximizedToggleNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); optionSetLauncherOpacityNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); optionSetIconSizeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); optionSetAutohideAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); @@ -2021,6 +2022,9 @@ void UnityScreen::optionChanged(CompOption* opt, UnityshellOptions::Options num) case UnityshellOptions::PanelOpacity: panel_controller_->SetOpacity(optionGetPanelOpacity()); break; + case UnityshellOptions::PanelOpacityMaximizedToggle: + panel_controller_->SetOpacityMaximizedToggle(optionGetPanelOpacityMaximizedToggle()); + break; case UnityshellOptions::LauncherOpacity: launcher.SetBackgroundAlpha(optionGetLauncherOpacity()); break; diff --git a/plugins/unityshell/unityshell.xml.in b/plugins/unityshell/unityshell.xml.in index 811b244cb..cc6d7757f 100644 --- a/plugins/unityshell/unityshell.xml.in +++ b/plugins/unityshell/unityshell.xml.in @@ -242,22 +242,27 @@ </desc> </option> <option type="float" name="panel_opacity"> - <_short>Panel Opacity</_short> - <_long>The opacity of the Panel background.</_long> - <default>1.0</default> - <min>0.0</min> - <max>1.0</max> - <precision>0.01</precision> + <_short>Panel Opacity</_short> + <_long>The opacity of the Panel background.</_long> + <default>1.0</default> + <min>0.0</min> + <max>1.0</max> + <precision>0.01</precision> + </option> + <option type="bool" name="panel_opacity_maximized_toggle"> + <_short>Panel Opacity for Maximized Windows Toggle.</_short> + <_long>When a window is maximized and visible in the current viewport, the panel opacity is disabled</_long> + <default>false</default> </option> <option type="float" name="launcher_opacity"> - <_short>Launcher Opacity</_short> - <_long>The opacity of the Launcher background.</_long> - <default>0.6667</default> - <min>0.0</min> - <max>1.0</max> - <precision>0.0001</precision> + <_short>Launcher Opacity</_short> + <_long>The opacity of the Launcher background.</_long> + <default>0.6667</default> + <min>0.0</min> + <max>1.0</max> + <precision>0.0001</precision> </option> - <option name="icon_size" type="int"> + <option name="icon_size" type="int"> <_short>Launcher icon size</_short> <_long>The size of the launcher icons</_long> <default>48</default> |
