From 4d2d8087bd51d756038a16fb5de282d9a5f5ec38 Mon Sep 17 00:00:00 2001 From: Eleni Maria Stea Date: Wed, 6 Nov 2013 13:21:43 +0200 Subject: added virtual destructors in classes that have virtual methods to prevent future memory leaks (bzr r3587.4.1) --- plugins/unityshell/src/AggregateMonitor.h | 2 +- plugins/unityshell/src/ElapsedTimeMonitor.h | 1 + plugins/unityshell/src/Monitor.h | 2 ++ plugins/unityshell/src/UnityGestureTarget.h | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/AggregateMonitor.h b/plugins/unityshell/src/AggregateMonitor.h index 251f8158d..eb03caa3b 100644 --- a/plugins/unityshell/src/AggregateMonitor.h +++ b/plugins/unityshell/src/AggregateMonitor.h @@ -33,7 +33,7 @@ class AggregateMonitor : public Monitor { public: AggregateMonitor(); - ~AggregateMonitor(); + virtual ~AggregateMonitor(); std::string GetName() const; protected: diff --git a/plugins/unityshell/src/ElapsedTimeMonitor.h b/plugins/unityshell/src/ElapsedTimeMonitor.h index 55f6d9d83..52f501b0e 100644 --- a/plugins/unityshell/src/ElapsedTimeMonitor.h +++ b/plugins/unityshell/src/ElapsedTimeMonitor.h @@ -31,6 +31,7 @@ namespace performance { class ElapsedTimeMonitor : public Monitor { public: + virtual ~ElapsedTimeMonitor() {} std::string GetName() const; protected: diff --git a/plugins/unityshell/src/Monitor.h b/plugins/unityshell/src/Monitor.h index ee6dfa6b9..11a28c456 100644 --- a/plugins/unityshell/src/Monitor.h +++ b/plugins/unityshell/src/Monitor.h @@ -29,6 +29,8 @@ namespace performance { class Monitor { public: + virtual ~Monitor() {} + void Start(); GVariant* Stop(); virtual std::string GetName() const = 0; diff --git a/plugins/unityshell/src/UnityGestureTarget.h b/plugins/unityshell/src/UnityGestureTarget.h index f47996e63..574ba0148 100644 --- a/plugins/unityshell/src/UnityGestureTarget.h +++ b/plugins/unityshell/src/UnityGestureTarget.h @@ -34,6 +34,7 @@ class UnityGestureTarget : public nux::GestureTarget { public: UnityGestureTarget(); + virtual ~UnityGestureTarget() {} virtual nux::GestureDeliveryRequest GestureEvent(const nux::GestureEvent &event); -- cgit v1.2.3 From 2d911d11d30790592924a77b55fcaa52fb5794b6 Mon Sep 17 00:00:00 2001 From: Eleni Maria Stea Date: Fri, 8 Nov 2013 17:03:48 +0200 Subject: temporal remove of v. destr (bzr r3587.4.2) --- plugins/unityshell/src/AggregateMonitor.h | 2 +- plugins/unityshell/src/ElapsedTimeMonitor.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/AggregateMonitor.h b/plugins/unityshell/src/AggregateMonitor.h index eb03caa3b..251f8158d 100644 --- a/plugins/unityshell/src/AggregateMonitor.h +++ b/plugins/unityshell/src/AggregateMonitor.h @@ -33,7 +33,7 @@ class AggregateMonitor : public Monitor { public: AggregateMonitor(); - virtual ~AggregateMonitor(); + ~AggregateMonitor(); std::string GetName() const; protected: diff --git a/plugins/unityshell/src/ElapsedTimeMonitor.h b/plugins/unityshell/src/ElapsedTimeMonitor.h index 52f501b0e..55f6d9d83 100644 --- a/plugins/unityshell/src/ElapsedTimeMonitor.h +++ b/plugins/unityshell/src/ElapsedTimeMonitor.h @@ -31,7 +31,6 @@ namespace performance { class ElapsedTimeMonitor : public Monitor { public: - virtual ~ElapsedTimeMonitor() {} std::string GetName() const; protected: -- cgit v1.2.3 From 1868be7a56c2c73ab87bbb4a13a8dfd863a57d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 14 Nov 2013 04:00:29 +0100 Subject: Unity: always prefer passing [this] to lambdas than [&] (bzr r3592.2.1) --- plugins/unityshell/src/WindowMinimizeSpeedController.cpp | 8 ++++---- plugins/unityshell/src/unityshell.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/WindowMinimizeSpeedController.cpp b/plugins/unityshell/src/WindowMinimizeSpeedController.cpp index a605b93f2..29df106fa 100644 --- a/plugins/unityshell/src/WindowMinimizeSpeedController.cpp +++ b/plugins/unityshell/src/WindowMinimizeSpeedController.cpp @@ -42,22 +42,22 @@ WindowMinimizeSpeedController::WindowMinimizeSpeedController() , _duration(200) // going to be overridden anyway, but at least it is initialised { _minimize_count_changed.Connect(_settings, "changed::minimize-count", - [&] (GSettings*, gchar* name) { + [this] (GSettings*, gchar* name) { _minimize_count = g_settings_get_int(_settings, name); SetDuration(); }); _minimize_speed_threshold_changed.Connect(_settings, "changed::minimize-speed-threshold", - [&] (GSettings*, gchar* name) { + [this] (GSettings*, gchar* name) { _minimize_speed_threshold = g_settings_get_int(_settings, name); SetDuration(); }); _minimize_fast_duration_changed.Connect(_settings, "changed::minimize-fast-duration", - [&] (GSettings*, gchar* name) { + [this] (GSettings*, gchar* name) { _minimize_fast_duration = g_settings_get_int(_settings, name); SetDuration(); }); _minimize_slow_duration_changed.Connect(_settings, "changed::minimize-slow-duration", - [&] (GSettings*, gchar* name) { + [this] (GSettings*, gchar* name) { _minimize_slow_duration = g_settings_get_int(_settings, name); SetDuration(); }); diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 54547125a..3012cdf4a 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -397,7 +397,7 @@ UnityScreen::UnityScreen(CompScreen* screen) BackgroundEffectHelper::updates_enabled = true; - ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, [&](GVariant * data) + ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, [this](GVariant * data) { unity::glib::String overlay_identity; gboolean can_maximise = FALSE; @@ -2942,7 +2942,7 @@ void UnityWindow::windowNotify(CompWindowNotify n) if (window->type() == CompWindowTypeDesktopMask) { if (!focus_desktop_timeout_) { - focus_desktop_timeout_.reset(new glib::Timeout(1000, [&] { + focus_desktop_timeout_.reset(new glib::Timeout(1000, [this] { for (CompWindow *w : screen->clientList()) { if (!(w->type() & NO_FOCUS_MASK) && w->focus ()) @@ -3322,7 +3322,7 @@ void UnityScreen::ScheduleRelayout(guint timeout) { if (!sources_.GetSource(local::RELAYOUT_TIMEOUT)) { - sources_.AddTimeout(timeout, [&] { + sources_.AddTimeout(timeout, [this] { NeedsRelayout(); Relayout(); -- cgit v1.2.3 From ff9cbb9596f4f63a6cea19e7e7b149bb2fc55c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 14 Nov 2013 16:06:27 +0100 Subject: UnityScreen: remove the useless and expensive gl{Push,Pop}Attrib calls For some reasons this code was copied by the opengl plugin as a workaround to fix the state of our screen after that nux has drawn. Actually this is not needed, the only thing we really need to do is to fix the current Viewport, because nux seems to leave it in a bad state which would lead to flickering menus, fullscreen windows, tooltip and missing windows thumbnails in switcher. Thanks to Sam Spilsbury for his precious support. (bzr r3592.1.1) --- plugins/unityshell/src/unityshell.cpp | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 54547125a..eddec6e74 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -570,16 +570,6 @@ void UnityScreen::nuxPrologue() * bit, but we do that here in order to workaround a bug (?) in the NVIDIA * drivers (lp:703140). */ glDisable(GL_LIGHTING); - - /* reset matrices */ - glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT | - GL_TEXTURE_BIT | GL_COLOR_BUFFER_BIT | GL_SCISSOR_BIT); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); #endif glGetError(); @@ -588,30 +578,18 @@ void UnityScreen::nuxPrologue() void UnityScreen::nuxEpilogue() { #ifndef USE_GLES - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glDepthRange(0, 1); - glViewport(-1, -1, 2, 2); - glRasterPos2f(0, 0); - - gScreen->resetRasterPos(); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - glPopAttrib(); + /* In some unknown place inside nux drawing we change the viewport without + * setting it back to the default one, so we need to restore it before allowing + * compiz to take the scene */ + auto* o = _last_output; + glViewport(o->x(), screen->height() - o->y2(), o->width(), o->height()); glDepthRange(0, 1); #else glDepthRangef(0, 1); - gScreen->resetRasterPos(); #endif + gScreen->resetRasterPos(); glDisable(GL_SCISSOR_TEST); } -- cgit v1.2.3 From c3e0cbb86dd4c594c317fd2cb20e2909775513ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 14 Nov 2013 16:06:44 +0100 Subject: UnityScreen: indentation fix (bzr r3592.1.2) --- plugins/unityshell/src/unityshell.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index eddec6e74..e6c3bd57b 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -549,16 +549,16 @@ void UnityScreen::EnsureSuperKeybindings() void UnityScreen::CreateSuperNewAction(char shortcut, impl::ActionModifiers flag) { - CompActionPtr action(new CompAction()); - const std::string key(optionGetShowLauncher().keyToString()); + CompActionPtr action(new CompAction()); + const std::string key(optionGetShowLauncher().keyToString()); - CompAction::KeyBinding binding; - binding.fromString(impl::CreateActionString(key, shortcut, flag)); + CompAction::KeyBinding binding; + binding.fromString(impl::CreateActionString(key, shortcut, flag)); - action->setKey(binding); + action->setKey(binding); - screen->addAction(action.get()); - _shortcut_actions.push_back(action); + screen->addAction(action.get()); + _shortcut_actions.push_back(action); } void UnityScreen::nuxPrologue() -- cgit v1.2.3 From 4b8083b12cdfc680c4465476090bbabe7607b729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 14 Nov 2013 16:51:03 +0100 Subject: UnityShell: initialize panel geometries vector outside the loop (bzr r3592.1.3) --- plugins/unityshell/src/unityshell.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index e6c3bd57b..aab320ac7 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -995,7 +995,7 @@ bool UnityScreen::DoesPointIntersectUnityGeos(nux::Point const& pt) } } - for (nux::Geometry &panel_geo : panel_controller_->GetGeometries ()) + for (nux::Geometry const& panel_geo : panel_controller_->GetGeometries ()) { if (panel_geo.IsInside(pt)) { @@ -1549,17 +1549,18 @@ void UnityScreen::compizDamageNux(CompRegion const& damage) } /* Grab changed nux regions and add damage rects for them */ -void UnityScreen::determineNuxDamage(CompRegion &nux_damage) +void UnityScreen::determineNuxDamage(CompRegion& nux_damage) { /* Fetch all the dirty geometry from nux and aggregate it */ - std::vector dirty = wt->GetPresentationListGeometries(); + auto const& dirty = wt->GetPresentationListGeometries(); + auto const& panels_geometries = panel_controller_->GetGeometries(); for (auto const& dirty_geo : dirty) { nux_damage += CompRegionFromNuxGeo(dirty_geo); /* Special case, we need to redraw the panel shadow on panel updates */ - for (auto const& panel_geo : panel_controller_->GetGeometries()) + for (auto const& panel_geo : panels_geometries) { if (!dirty_geo.IsIntersecting(panel_geo)) continue; -- cgit v1.2.3 From 2beb9acbf61af0ab83c36722fb489d1875606f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 14 Nov 2013 16:56:08 +0100 Subject: UnityShell: remove the useless call to GetPresentationListGeometries in glPaintTransformedOutput (bzr r3592.1.4) --- plugins/unityshell/src/unityshell.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'plugins/unityshell') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index aab320ac7..a0d754d12 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -1351,10 +1351,6 @@ void UnityScreen::glPaintTransformedOutput(const GLScreenPaintAttrib& attrib, ignore_redraw_request_ = true; compizDamageNux(CompRegionRef(output->region())); ignore_redraw_request_ = false; - - /* Fetch all the presentation list geometries - this will have the side - * effect of clearing any built-up damage state */ - std::vector dirty = wt->GetPresentationListGeometries(); } gScreen->glPaintTransformedOutput(attrib, transform, region, output, mask); -- cgit v1.2.3