From 767f29c04216d5a8c0390d5d6e071f42652131c6 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sat, 22 Dec 2012 14:39:22 +0800 Subject: Fix damage calculuation algorithm, draw blurs into our own private fbo and adapt for new core api (bzr r2985.3.6) --- unity-shared/BackgroundEffectHelper.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/BackgroundEffectHelper.cpp b/unity-shared/BackgroundEffectHelper.cpp index 33b1ee03a..cdcd037ed 100644 --- a/unity-shared/BackgroundEffectHelper.cpp +++ b/unity-shared/BackgroundEffectHelper.cpp @@ -92,9 +92,7 @@ bool BackgroundEffectHelper::HasEnabledHelpers() for (BackgroundEffectHelper * bg_effect_helper : registered_list_) { if (bg_effect_helper->enabled) - { return true; - } } return false; -- cgit v1.2.3 From 8a530a5fff48aaa957d331e1618227d261935173 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Thu, 28 Mar 2013 14:12:43 +0800 Subject: Just read off the backbuffer. Its faster and easier (bzr r3139.1.16) --- unity-shared/BackgroundEffectHelper.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'unity-shared') diff --git a/unity-shared/BackgroundEffectHelper.cpp b/unity-shared/BackgroundEffectHelper.cpp index c65f6a3d0..6a1ea94d2 100644 --- a/unity-shared/BackgroundEffectHelper.cpp +++ b/unity-shared/BackgroundEffectHelper.cpp @@ -92,7 +92,9 @@ bool BackgroundEffectHelper::HasEnabledHelpers() for (BackgroundEffectHelper * bg_effect_helper : registered_list_) { if (bg_effect_helper->enabled) + { return true; + } } return false; -- cgit v1.2.3 From 4d15a06e5fd94a2009954e3159cdcaff855e6b0b Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sat, 30 Mar 2013 00:33:33 +0800 Subject: Only redraw the window buttons when necessary, not on every frame (bzr r3139.1.21) --- unity-shared/OverlayWindowButtons.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'unity-shared') diff --git a/unity-shared/OverlayWindowButtons.cpp b/unity-shared/OverlayWindowButtons.cpp index bdf609639..f0b6c472f 100644 --- a/unity-shared/OverlayWindowButtons.cpp +++ b/unity-shared/OverlayWindowButtons.cpp @@ -38,6 +38,10 @@ OverlayWindowButtons::OverlayWindowButtons() { UpdateGeometry(); SetBackgroundColor(nux::color::Transparent); + + window_buttons_->queue_draw.connect([&] (nux::Layout* /*layout*/) { + QueueDraw(); + }); } void OverlayWindowButtons::UpdateGeometry() -- cgit v1.2.3 From 9da7364c14aa4b848a5e69dbdc1fbb6784e13f18 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Thu, 16 May 2013 21:58:34 +0800 Subject: Use gtk_icon_info_free instead of g_object_unref GtkIconInfo is not a GObject, and callers are meant to free it with gtk_icon_info_unref according to the documentation for it: GtkIconInfo * gtk_icon_theme_lookup_icon (GtkIconTheme *icon_theme, const gchar *icon_name, gint size, GtkIconLookupFlags flags); Looks up a named icon and returns a structure containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using gtk_icon_info_load_icon(). (gtk_icon_theme_load_icon() combines these two steps if all you need is the pixbuf.) ... Returns : a GtkIconInfo structure containing information about the icon, or NULL if the icon wasn't found. Free with gtk_icon_info_free() (LP: #1180790) Fixes LP: #1180790 (bzr r3324.6.1) --- unity-shared/IconLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'unity-shared') diff --git a/unity-shared/IconLoader.cpp b/unity-shared/IconLoader.cpp index 271a0f4ee..4d2fa2e06 100644 --- a/unity-shared/IconLoader.cpp +++ b/unity-shared/IconLoader.cpp @@ -125,7 +125,7 @@ private: ~IconLoaderTask() { if (icon_info) - ::g_object_unref(G_OBJECT(icon_info)); + ::gtk_icon_info_free(icon_info); if (helper_handle != 0) impl->DisconnectHandle(helper_handle); } -- cgit v1.2.3 From e865a463d71e1ef678c914f64fa47e2cb0471d8e Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Fri, 17 May 2013 14:15:41 +0800 Subject: Use an ifdef to pick the free method. Unreferencing a GtkIconInfo is broken in gtk versions < 3.8, but using gtk_icon_info_free is deprecated in >= 3.8 . So provide a new function gtk::UnreferenceIconInfo with an ifdef to pick the right method and do that. GtkUtilDeathTest::NoDeathOnUnreference added to verify that. (bzr r3324.6.2) --- unity-shared/IconLoader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/IconLoader.cpp b/unity-shared/IconLoader.cpp index 4d2fa2e06..bbde9c942 100644 --- a/unity-shared/IconLoader.cpp +++ b/unity-shared/IconLoader.cpp @@ -34,6 +34,7 @@ #include #include "unity-shared/Timer.h" +#include "unity-shared/GtkUtil.h" namespace unity { @@ -124,8 +125,7 @@ private: ~IconLoaderTask() { - if (icon_info) - ::gtk_icon_info_free(icon_info); + gtk::UnreferenceIconInfo(icon_info); if (helper_handle != 0) impl->DisconnectHandle(helper_handle); } -- cgit v1.2.3 From 2e788dda27508eb481dfa618c2b381b2e3b5e41b Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Fri, 17 May 2013 14:47:29 +0800 Subject: Added GtkUtil.h (bzr r3324.6.3) --- unity-shared/GtkUtil.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 unity-shared/GtkUtil.h (limited to 'unity-shared') diff --git a/unity-shared/GtkUtil.h b/unity-shared/GtkUtil.h new file mode 100644 index 000000000..cd8d30bcd --- /dev/null +++ b/unity-shared/GtkUtil.h @@ -0,0 +1,43 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* +* Copyright (C) 2013 Canonical Ltd +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 3 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Authored by: Sam Spilsbury +*/ + +#ifndef GTK_UTIL_H +#define GTK_UTIL_H + +#include +#include +#include + +namespace unity +{ +namespace gtk +{ +inline void UnreferenceIconInfo(GtkIconInfo *info) +{ +#ifdef HAVE_GTK_3_8 + g_object_clear(info); +#else + if (info) + gtk_icon_info_free(info); +#endif +} +} +} + +#endif -- cgit v1.2.3 From 16a22d38bb55bbc3cff0045f3a5a829b1a44787c Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Tue, 21 May 2013 00:02:01 +0800 Subject: Revert 3273 (bzr r3248.3.26) --- unity-shared/GtkUtil.h | 43 ------------------------------------------- unity-shared/IconLoader.cpp | 4 ++-- 2 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 unity-shared/GtkUtil.h (limited to 'unity-shared') diff --git a/unity-shared/GtkUtil.h b/unity-shared/GtkUtil.h deleted file mode 100644 index cd8d30bcd..000000000 --- a/unity-shared/GtkUtil.h +++ /dev/null @@ -1,43 +0,0 @@ -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- -/* -* Copyright (C) 2013 Canonical Ltd -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 3 as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* Authored by: Sam Spilsbury -*/ - -#ifndef GTK_UTIL_H -#define GTK_UTIL_H - -#include -#include -#include - -namespace unity -{ -namespace gtk -{ -inline void UnreferenceIconInfo(GtkIconInfo *info) -{ -#ifdef HAVE_GTK_3_8 - g_object_clear(info); -#else - if (info) - gtk_icon_info_free(info); -#endif -} -} -} - -#endif diff --git a/unity-shared/IconLoader.cpp b/unity-shared/IconLoader.cpp index bbde9c942..4d2fa2e06 100644 --- a/unity-shared/IconLoader.cpp +++ b/unity-shared/IconLoader.cpp @@ -34,7 +34,6 @@ #include #include "unity-shared/Timer.h" -#include "unity-shared/GtkUtil.h" namespace unity { @@ -125,7 +124,8 @@ private: ~IconLoaderTask() { - gtk::UnreferenceIconInfo(icon_info); + if (icon_info) + ::gtk_icon_info_free(icon_info); if (helper_handle != 0) impl->DisconnectHandle(helper_handle); } -- cgit v1.2.3 From 7fd44d8fd609bc6eb5e550e1f376f366a00d22d2 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sat, 15 Jun 2013 11:59:49 +0800 Subject: Cleanup, remove duplicate calls to QueueDraw (bzr r3347.3.5) --- unity-shared/OverlayWindowButtons.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/OverlayWindowButtons.cpp b/unity-shared/OverlayWindowButtons.cpp index ab6e51081..5b89b781c 100644 --- a/unity-shared/OverlayWindowButtons.cpp +++ b/unity-shared/OverlayWindowButtons.cpp @@ -43,10 +43,6 @@ OverlayWindowButtons::OverlayWindowButtons() AddChild(window_buttons_.GetPointer()); UpdateGeometry(); SetBackgroundColor(nux::color::Transparent); - - window_buttons_->queue_draw.connect([&] (nux::Layout* /*layout*/) { - QueueDraw(); - }); } void OverlayWindowButtons::UpdateGeometry() -- cgit v1.2.3 From 5fa0bbeaa5a5273d27970dceec339c763301b2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 17 Sep 2013 17:41:46 +0200 Subject: DebugDBusInterface: get proper node id and add first stub matching functions (bzr r3506.5.2) --- unity-shared/DebugDBusInterface.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/DebugDBusInterface.cpp b/unity-shared/DebugDBusInterface.cpp index c373dbc08..b146b7830 100644 --- a/unity-shared/DebugDBusInterface.cpp +++ b/unity-shared/DebugDBusInterface.cpp @@ -34,8 +34,8 @@ namespace unity namespace debug { DECLARE_LOGGER(logger, "unity.debug.interface"); -// namespace -// { +namespace +{ namespace local { std::ofstream output_file; @@ -53,7 +53,7 @@ namespace local int32_t GetId() const { - return GPOINTER_TO_INT(node_); + return node_->GetIntrospectionId(); } std::string GetName() const @@ -71,34 +71,32 @@ namespace local return parent_; } - virtual bool MatchBooleanProperty(const std::string& name, bool value) const + bool MatchBooleanProperty(std::string const& name, bool value) const { - return false; + return MatchProperty(name, value ? "TRUE" : "FALSE"); } - virtual bool MatchIntegerProperty(const std::string& name, int32_t value) const + bool MatchIntegerProperty(std::string const& name, int32_t value) const { - return false; + return MatchProperty(name, std::to_string(value)); } - virtual bool MatchStringProperty(const std::string& name, const std::string& value) const + bool MatchStringProperty(std::string const& name, std::string const& value) const { - return false; + return MatchStringProperty(name, value); } - - bool MatchProperty(const std::string& name, const std::string& value) const + bool MatchProperty(std::string const& name, std::string const& value) const { bool matches = false; - - GVariantBuilder child_builder; + GVariantBuilder child_builder; g_variant_builder_init(&child_builder, G_VARIANT_TYPE("a{sv}")); g_variant_builder_add(&child_builder, "{sv}", "id", g_variant_new_uint64(node_->GetIntrospectionId())); node_->AddProperties(&child_builder); GVariant* prop_dict = g_variant_builder_end(&child_builder); - GVariant* prop_value = g_variant_lookup_value(prop_dict, name.c_str(), NULL); + GVariant* prop_value = g_variant_lookup_value(prop_dict, name.c_str(), nullptr); - if (prop_value != NULL) + if (prop_value) { GVariantClass prop_val_type = g_variant_classify(prop_value); // it'd be nice to be able to do all this with one method. However, the booleans need @@ -200,6 +198,7 @@ namespace local { std::vector children; auto const& this_ptr = std::const_pointer_cast(shared_from_this()); + for(auto const& child: node_->GetIntrospectableChildren()) children.push_back(std::make_shared(child, this_ptr)); @@ -253,7 +252,7 @@ namespace local dlclose(xpathselect_driver_); } -// } +} } bool TryLoadXPathImplementation(); -- cgit v1.2.3 From fb0474736bb7e56de3e0d86669865e4ea6c65881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 17 Sep 2013 17:53:23 +0200 Subject: DebugDBusInterface: use glib::Variant and add property getter method (bzr r3506.5.3) --- unity-shared/DebugDBusInterface.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/DebugDBusInterface.cpp b/unity-shared/DebugDBusInterface.cpp index b146b7830..99e7af457 100644 --- a/unity-shared/DebugDBusInterface.cpp +++ b/unity-shared/DebugDBusInterface.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -89,12 +90,7 @@ namespace local bool MatchProperty(std::string const& name, std::string const& value) const { bool matches = false; - GVariantBuilder child_builder; - g_variant_builder_init(&child_builder, G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(&child_builder, "{sv}", "id", g_variant_new_uint64(node_->GetIntrospectionId())); - node_->AddProperties(&child_builder); - GVariant* prop_dict = g_variant_builder_end(&child_builder); - GVariant* prop_value = g_variant_lookup_value(prop_dict, name.c_str(), nullptr); + auto const& prop_value = GetPropertyValue(name); if (prop_value) { @@ -189,11 +185,21 @@ namespace local LOG_WARNING(logger) << "Unable to match against property of unknown type."; }; } - g_variant_unref(prop_value); - g_variant_unref(prop_dict); + return matches; } + glib::Variant GetPropertyValue(std::string const& name) const + { + GVariantBuilder child_builder; + g_variant_builder_init(&child_builder, G_VARIANT_TYPE("a{sv}")); + // This is probably not needed anymore... + g_variant_builder_add(&child_builder, "{sv}", "id", g_variant_new_uint64(node_->GetIntrospectionId())); + node_->AddProperties(&child_builder); + glib::Variant prop_dict(g_variant_builder_end(&child_builder)); + return glib::Variant(g_variant_lookup_value(prop_dict, name.c_str(), nullptr)); + } + std::vector Children() const { std::vector children; @@ -259,10 +265,8 @@ bool TryLoadXPathImplementation(); GVariant* GetState(std::string const& query); void StartLogToFile(std::string const& file_path); void ResetLogging(); -void SetLogSeverity(std::string const& log_component, - std::string const& severity); -void LogMessage(std::string const& severity, - std::string const& message); +void SetLogSeverity(std::string const& log_component, std::string const& severity); +void LogMessage(std::string const& severity, std::string const& message); namespace dbus { @@ -371,7 +375,7 @@ GVariant* DebugDBusInterface::HandleDBusMethodCall(std::string const& method, GV GVariant* GetState(std::string const& query) { - GVariantBuilder builder; + GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sv)")); auto root_node = std::make_shared(_parent_introspectable); -- cgit v1.2.3 From 0f785bd09f4eded83c0dca221b7a1258661289e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 17 Sep 2013 18:17:39 +0200 Subject: DebugDBusInterface: implemented correctly MatchStringProperty, MatchBooleanProperty and MatchIntegerProperty (bzr r3506.5.4) --- unity-shared/DebugDBusInterface.cpp | 130 ++++++++++++------------------------ 1 file changed, 41 insertions(+), 89 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/DebugDBusInterface.cpp b/unity-shared/DebugDBusInterface.cpp index 99e7af457..e6a975825 100644 --- a/unity-shared/DebugDBusInterface.cpp +++ b/unity-shared/DebugDBusInterface.cpp @@ -72,121 +72,73 @@ namespace local return parent_; } - bool MatchBooleanProperty(std::string const& name, bool value) const + bool MatchStringProperty(std::string const& name, std::string const& value) const { - return MatchProperty(name, value ? "TRUE" : "FALSE"); - } + auto const& prop_value = GetPropertyValue(name); - bool MatchIntegerProperty(std::string const& name, int32_t value) const - { - return MatchProperty(name, std::to_string(value)); + if (prop_value) + { + if (!g_variant_is_of_type(prop_value, G_VARIANT_TYPE_STRING)) + { + LOG_WARNING(logger) << "Unable to match '"<< name << "', it's not a string property."; + return false; + } + + return (prop_value.GetString() == value); + } + + return false; } - bool MatchStringProperty(std::string const& name, std::string const& value) const + bool MatchBooleanProperty(std::string const& name, bool value) const { - return MatchStringProperty(name, value); + auto const& prop_value = GetPropertyValue(name); + + if (prop_value) + { + if (!g_variant_is_of_type(prop_value, G_VARIANT_TYPE_BOOLEAN)) + { + LOG_WARNING(logger) << "Unable to match '"<< name << "', it's not a boolean property."; + return false; + } + + return (prop_value.GetBool() == value); + } + + return false; } - bool MatchProperty(std::string const& name, std::string const& value) const + bool MatchIntegerProperty(std::string const& name, int32_t value) const { - bool matches = false; auto const& prop_value = GetPropertyValue(name); if (prop_value) { GVariantClass prop_val_type = g_variant_classify(prop_value); - // it'd be nice to be able to do all this with one method. However, the booleans need - // special treatment, and I can't figure out how to group all the integer types together - // without resorting to template functions.... and we all know what happens when you - // start doing that... + // it'd be nice to be able to do all this with one method. + // I can't figure out how to group all the integer types together switch (prop_val_type) { - case G_VARIANT_CLASS_STRING: - { - const gchar* prop_val = g_variant_get_string(prop_value, NULL); - if (g_strcmp0(prop_val, value.c_str()) == 0) - { - matches = true; - } - } - break; - case G_VARIANT_CLASS_BOOLEAN: - { - std::string value = boost::to_upper_copy(value); - bool p = value == "TRUE" || value == "ON" || value == "YES" || value == "1"; - matches = (g_variant_get_boolean(prop_value) == p); - } - break; case G_VARIANT_CLASS_BYTE: - { - // It would be nice if I could do all the integer types together, but I couldn't see how... - std::stringstream stream(value); - int val; // changing this to guchar causes problems. - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_byte(prop_value); - } - break; + return value == g_variant_get_byte(prop_value); case G_VARIANT_CLASS_INT16: - { - std::stringstream stream(value); - gint16 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_int16(prop_value); - } - break; + return value == g_variant_get_int16(prop_value); case G_VARIANT_CLASS_UINT16: - { - std::stringstream stream(value); - guint16 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_uint16(prop_value); - } - break; + return static_cast(value) == g_variant_get_uint16(prop_value); case G_VARIANT_CLASS_INT32: - { - std::stringstream stream(value); - gint32 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_int32(prop_value); - } - break; + return value == prop_value.GetInt32(); case G_VARIANT_CLASS_UINT32: - { - std::stringstream stream(value); - guint32 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_uint32(prop_value); - } - break; + return static_cast(value) == prop_value.GetUInt32(); case G_VARIANT_CLASS_INT64: - { - std::stringstream stream(value); - gint64 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_int64(prop_value); - } - break; + return value == prop_value.GetInt64(); case G_VARIANT_CLASS_UINT64: - { - std::stringstream stream(value); - guint64 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_uint64(prop_value); - } - break; + return static_cast(value) == prop_value.GetUInt64(); default: - LOG_WARNING(logger) << "Unable to match against property of unknown type."; + LOG_WARNING(logger) << "Unable to match '"<< name << "' against property of unknown integer type."; }; } - return matches; + return false; } glib::Variant GetPropertyValue(std::string const& name) const -- cgit v1.2.3 From bc762eb29d22b22769ec1dadb53d9ce8592b233a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 17 Sep 2013 18:47:01 +0200 Subject: DebugDBusInterface: update copyright (bzr r3506.5.5) --- unity-shared/DebugDBusInterface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'unity-shared') diff --git a/unity-shared/DebugDBusInterface.cpp b/unity-shared/DebugDBusInterface.cpp index e6a975825..5651cb65b 100644 --- a/unity-shared/DebugDBusInterface.cpp +++ b/unity-shared/DebugDBusInterface.cpp @@ -1,6 +1,6 @@ // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* - * Copyright (C) 2010 Canonical Ltd + * Copyright (C) 2010-2013 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -15,6 +15,8 @@ * along with this program. If not, see . * * Authored by: Alex Launi + * Thomi Richards + * Marco Trevisan */ #include -- cgit v1.2.3 From e58f8249acea557c814a7eb42559056e544f3bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 17 Sep 2013 18:56:38 +0200 Subject: DebugDBusInterface: make IntrospectableAdapter::Ptr definition const by default this will make us avoid to const_cast later... (bzr r3506.5.6) --- unity-shared/DebugDBusInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/DebugDBusInterface.cpp b/unity-shared/DebugDBusInterface.cpp index 5651cb65b..ffb770e25 100644 --- a/unity-shared/DebugDBusInterface.cpp +++ b/unity-shared/DebugDBusInterface.cpp @@ -47,7 +47,7 @@ namespace local class IntrospectableAdapter : public std::enable_shared_from_this, public xpathselect::Node { public: - typedef std::shared_ptr Ptr; + typedef std::shared_ptr Ptr; IntrospectableAdapter(Introspectable* node, IntrospectableAdapter::Ptr const& parent = nullptr) : node_(node) , parent_(parent) @@ -157,7 +157,7 @@ namespace local std::vector Children() const { std::vector children; - auto const& this_ptr = std::const_pointer_cast(shared_from_this()); + auto const& this_ptr = shared_from_this(); for(auto const& child: node_->GetIntrospectableChildren()) children.push_back(std::make_shared(child, this_ptr)); -- cgit v1.2.3 From 8161f39f6009af3b25927e5ee4b0c5999616249b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 18 Sep 2013 14:07:54 +0200 Subject: DebugDBusInterface: add const strings for defining proto version and library loading (bzr r3506.5.7) --- unity-shared/DebugDBusInterface.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/DebugDBusInterface.cpp b/unity-shared/DebugDBusInterface.cpp index ffb770e25..68054bc60 100644 --- a/unity-shared/DebugDBusInterface.cpp +++ b/unity-shared/DebugDBusInterface.cpp @@ -41,6 +41,9 @@ namespace { namespace local { + const std::string PROTOCOL_VERSION = "1.4"; + const std::string XPATH_SELECT_LIB = "libxpathselect.so.1.4"; + std::ofstream output_file; void* xpathselect_driver_ = nullptr; @@ -179,7 +182,7 @@ namespace local xpathselect::NodeVector select_nodes(IntrospectableAdapter::Ptr const& root, std::string const& query) { if (!xpathselect_driver_) - xpathselect_driver_ = dlopen("libxpathselect.so.1.4", RTLD_LAZY); + xpathselect_driver_ = dlopen(XPATH_SELECT_LIB.c_str(), RTLD_LAZY); if (xpathselect_driver_) { @@ -294,7 +297,7 @@ GVariant* DebugDBusInterface::HandleDBusMethodCall(std::string const& method, GV } else if (method == "GetVersion") { - return g_variant_new("(s)", "1.3"); + return g_variant_new("(s)", local::PROTOCOL_VERSION.c_str()); } else if (method == "StartLogToFile") { -- cgit v1.2.3 From 4e19578ffd1b64089fd3d94188efd8cfa08ab1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 18 Sep 2013 14:08:43 +0200 Subject: DebugDBusInterface: if the "id" is required, there's no need to introspect. Just return it (bzr r3506.5.8) --- unity-shared/DebugDBusInterface.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/DebugDBusInterface.cpp b/unity-shared/DebugDBusInterface.cpp index 68054bc60..e6a90d645 100644 --- a/unity-shared/DebugDBusInterface.cpp +++ b/unity-shared/DebugDBusInterface.cpp @@ -148,13 +148,14 @@ namespace local glib::Variant GetPropertyValue(std::string const& name) const { - GVariantBuilder child_builder; - g_variant_builder_init(&child_builder, G_VARIANT_TYPE("a{sv}")); - // This is probably not needed anymore... - g_variant_builder_add(&child_builder, "{sv}", "id", g_variant_new_uint64(node_->GetIntrospectionId())); - node_->AddProperties(&child_builder); - glib::Variant prop_dict(g_variant_builder_end(&child_builder)); - return glib::Variant(g_variant_lookup_value(prop_dict, name.c_str(), nullptr)); + if (name == "id") + return g_variant_new_int32(GetId()); + + GVariantBuilder properties_builder; + g_variant_builder_init(&properties_builder, G_VARIANT_TYPE("a{sv}")); + node_->AddProperties(&properties_builder); + glib::Variant props_dict(g_variant_builder_end(&properties_builder)); + return g_variant_lookup_value(props_dict, name.c_str(), nullptr); } std::vector Children() const -- cgit v1.2.3 From fcd28b197759c7fbeed1a71ff5161e24722c7f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 18 Sep 2013 14:14:26 +0200 Subject: Introspectable: some code cleanup on Introspect method (bzr r3506.5.9) --- unity-shared/Introspectable.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/Introspectable.cpp b/unity-shared/Introspectable.cpp index 9e3d8b920..f08b3d5e9 100644 --- a/unity-shared/Introspectable.cpp +++ b/unity-shared/Introspectable.cpp @@ -46,9 +46,9 @@ Introspectable::IntrospectableList Introspectable::GetIntrospectableChildren() GVariant* Introspectable::Introspect() { - GVariantBuilder builder; - GVariantBuilder child_builder; - gint n_children = 0; + GVariantBuilder builder; + GVariantBuilder child_builder; + bool has_valid_children = false; g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}")); g_variant_builder_add(&builder, "{sv}", "id", g_variant_new_uint64(_id)); @@ -57,20 +57,22 @@ Introspectable::Introspect() g_variant_builder_init(&child_builder, G_VARIANT_TYPE("as")); - auto children = GetIntrospectableChildren(); - for (auto it = children.begin(); it != children.end(); it++) + for (auto const& child : GetIntrospectableChildren()) { - if ((*it)->GetName() != "") + auto const& child_name = child->GetName(); + + if (!child_name.empty()) { - g_variant_builder_add(&child_builder, "s", (*it)->GetName().c_str()); - n_children++; + g_variant_builder_add(&child_builder, "s", child_name.c_str()); + has_valid_children = true; } } GVariant* child_results = g_variant_builder_end(&child_builder); - if (n_children > 0) + if (has_valid_children) g_variant_builder_add(&builder, "{sv}", GetChildsName().c_str(), child_results); + return g_variant_builder_end(&builder); } -- cgit v1.2.3 From 4ab3aa187443543adfb80d7e287bb2e46ea0719e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 18 Sep 2013 16:41:08 +0200 Subject: Unity: use the new BuildWrapper features in AddProperties methods (bzr r3506.5.11) --- unity-shared/SearchBar.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'unity-shared') diff --git a/unity-shared/SearchBar.cpp b/unity-shared/SearchBar.cpp index 11974736b..3f300e91c 100644 --- a/unity-shared/SearchBar.cpp +++ b/unity-shared/SearchBar.cpp @@ -617,6 +617,7 @@ void SearchBar::AddProperties(GVariantBuilder* builder) .add("filter-label-y", show_filters_->GetAbsoluteY()) .add("filter-label-width", show_filters_->GetAbsoluteWidth()) .add("filter-label-height", show_filters_->GetAbsoluteHeight()) + .add("filter-label-geo", show_filters_->GetAbsoluteGeometry()) .add("im_active", pango_entry_->im_active()); } -- cgit v1.2.3 From 4590d83f4fbf89b74d0427855abc254690e6ed0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 19 Sep 2013 01:45:24 +0200 Subject: Introspectable: use variant::BuilderWrapper for adding the ID value to items (bzr r3506.5.19) --- unity-shared/Introspectable.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/Introspectable.cpp b/unity-shared/Introspectable.cpp index f08b3d5e9..1f6eb7459 100644 --- a/unity-shared/Introspectable.cpp +++ b/unity-shared/Introspectable.cpp @@ -17,6 +17,7 @@ * Authored by: Alex Launi */ +#include #include "Introspectable.h" namespace unity @@ -51,8 +52,7 @@ Introspectable::Introspect() bool has_valid_children = false; g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(&builder, "{sv}", "id", g_variant_new_uint64(_id)); - + variant::BuilderWrapper(&builder).add("id", _id); AddProperties(&builder); g_variant_builder_init(&child_builder, G_VARIANT_TYPE("as")); @@ -68,10 +68,10 @@ Introspectable::Introspect() } } - GVariant* child_results = g_variant_builder_end(&child_builder); + glib::Variant child_results(g_variant_builder_end(&child_builder)); if (has_valid_children) - g_variant_builder_add(&builder, "{sv}", GetChildsName().c_str(), child_results); + g_variant_builder_add(&builder, "{sv}", GetChildsName().c_str(), static_cast(child_results)); return g_variant_builder_end(&builder); } -- cgit v1.2.3 From 1966a04309bac3bb3c174b57202c0a5bb8b96563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 19 Sep 2013 02:47:33 +0200 Subject: Introspectable: use BuilderWrapper also for Children (bzr r3506.5.23) --- unity-shared/Introspectable.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/Introspectable.cpp b/unity-shared/Introspectable.cpp index 1f6eb7459..9b1c2d63b 100644 --- a/unity-shared/Introspectable.cpp +++ b/unity-shared/Introspectable.cpp @@ -52,7 +52,8 @@ Introspectable::Introspect() bool has_valid_children = false; g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}")); - variant::BuilderWrapper(&builder).add("id", _id); + variant::BuilderWrapper build_wrapper(&builder); + build_wrapper.add("id", _id); AddProperties(&builder); g_variant_builder_init(&child_builder, G_VARIANT_TYPE("as")); @@ -71,7 +72,7 @@ Introspectable::Introspect() glib::Variant child_results(g_variant_builder_end(&child_builder)); if (has_valid_children) - g_variant_builder_add(&builder, "{sv}", GetChildsName().c_str(), static_cast(child_results)); + build_wrapper.add(GetChildsName(), static_cast(child_results)); return g_variant_builder_end(&builder); } -- cgit v1.2.3 From 7b7ed6c86bc37e88c4b6c69db69df4da1e53d61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 19 Sep 2013 03:02:33 +0200 Subject: BuilderWrapper: add overriding with glib::Variant (bzr r3506.5.24) --- unity-shared/Introspectable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'unity-shared') diff --git a/unity-shared/Introspectable.cpp b/unity-shared/Introspectable.cpp index 9b1c2d63b..56ad40465 100644 --- a/unity-shared/Introspectable.cpp +++ b/unity-shared/Introspectable.cpp @@ -72,7 +72,7 @@ Introspectable::Introspect() glib::Variant child_results(g_variant_builder_end(&child_builder)); if (has_valid_children) - build_wrapper.add(GetChildsName(), static_cast(child_results)); + build_wrapper.add(GetChildsName(), child_results); return g_variant_builder_end(&builder); } -- cgit v1.2.3 From 43afab0923de597f6ca1d77f0f26ed5073e4b639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 19 Sep 2013 15:39:49 +0200 Subject: DebugDBusInterface: use new GVariant constructors and getters where possible (bzr r3506.5.31) --- unity-shared/DebugDBusInterface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/DebugDBusInterface.cpp b/unity-shared/DebugDBusInterface.cpp index e6a90d645..b92a3bd36 100644 --- a/unity-shared/DebugDBusInterface.cpp +++ b/unity-shared/DebugDBusInterface.cpp @@ -125,11 +125,11 @@ namespace local switch (prop_val_type) { case G_VARIANT_CLASS_BYTE: - return value == g_variant_get_byte(prop_value); + return static_cast(value) == prop_value.GetByte(); case G_VARIANT_CLASS_INT16: - return value == g_variant_get_int16(prop_value); + return value == prop_value.GetInt16(); case G_VARIANT_CLASS_UINT16: - return static_cast(value) == g_variant_get_uint16(prop_value); + return static_cast(value) == prop_value.GetUInt16(); case G_VARIANT_CLASS_INT32: return value == prop_value.GetInt32(); case G_VARIANT_CLASS_UINT32: @@ -149,7 +149,7 @@ namespace local glib::Variant GetPropertyValue(std::string const& name) const { if (name == "id") - return g_variant_new_int32(GetId()); + return glib::Variant(GetId()); GVariantBuilder properties_builder; g_variant_builder_init(&properties_builder, G_VARIANT_TYPE("a{sv}")); -- cgit v1.2.3 From d172d70310509f5cd40642bbbea03cce5807297c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 19 Sep 2013 15:43:14 +0200 Subject: Introspectable: some cleanup (bzr r3506.5.32) --- unity-shared/Introspectable.cpp | 47 ++++++++++++++++++----------------------- unity-shared/Introspectable.h | 12 ++++------- 2 files changed, 25 insertions(+), 34 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/Introspectable.cpp b/unity-shared/Introspectable.cpp index 56ad40465..ed932587f 100644 --- a/unity-shared/Introspectable.cpp +++ b/unity-shared/Introspectable.cpp @@ -25,23 +25,25 @@ namespace unity namespace debug { +const std::string CHILDREN_NAME = "Children"; + Introspectable::Introspectable() { - static guint64 unique_id=0; - _id = unique_id++; + static int32_t unique_id_ = 0; + id_ = unique_id_++; } Introspectable::~Introspectable() { - for (auto parent : _parents) - parent->_children.remove(this); - for (auto child : _children) - child->_parents.remove(this); + for (auto parent : parents_) + parent->children_.remove(this); + for (auto child : children_) + child->parents_.remove(this); } Introspectable::IntrospectableList Introspectable::GetIntrospectableChildren() { - return _children; + return children_; } GVariant* @@ -53,7 +55,7 @@ Introspectable::Introspect() g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}")); variant::BuilderWrapper build_wrapper(&builder); - build_wrapper.add("id", _id); + build_wrapper.add("id", id_); AddProperties(&builder); g_variant_builder_init(&child_builder, G_VARIANT_TYPE("as")); @@ -72,7 +74,7 @@ Introspectable::Introspect() glib::Variant child_results(g_variant_builder_end(&child_builder)); if (has_valid_children) - build_wrapper.add(GetChildsName(), child_results); + build_wrapper.add(CHILDREN_NAME, child_results); return g_variant_builder_end(&builder); } @@ -80,35 +82,28 @@ Introspectable::Introspect() void Introspectable::AddChild(Introspectable* child) { - _children.push_back(child); - child->_parents.push_back(this); + children_.push_back(child); + child->parents_.push_back(this); } void Introspectable::RemoveChild(Introspectable* child) { - _children.remove(child); - child->_parents.remove(this); -} - -std::string -Introspectable::GetChildsName() const -{ - return "Children"; + children_.remove(child); + child->parents_.remove(this); } -guint64 Introspectable::GetIntrospectionId() const +int32_t Introspectable::GetIntrospectionId() const { - return _id; + return id_; } void Introspectable::RemoveAllChildren() { - for (auto child : _children) - { - child->_parents.remove(this); - } - _children.clear(); + for (auto child : children_) + child->parents_.remove(this); + + children_.clear(); } } diff --git a/unity-shared/Introspectable.h b/unity-shared/Introspectable.h index 245ec7b84..ab4302696 100644 --- a/unity-shared/Introspectable.h +++ b/unity-shared/Introspectable.h @@ -41,13 +41,9 @@ public: void RemoveChild(Introspectable* child); virtual void AddProperties(GVariantBuilder* builder) = 0; virtual IntrospectableList GetIntrospectableChildren(); - guint64 GetIntrospectionId() const; + int32_t GetIntrospectionId() const; protected: - /// Please don't override this unless you really need to. The only valid reason - /// is if you have a property that simply *must* be called 'Children'. - virtual std::string GetChildsName() const; - void RemoveAllChildren(); /* @@ -61,9 +57,9 @@ protected: */ private: - std::list _children; - std::list _parents; - guint64 _id; + std::list children_; + std::list parents_; + int32_t _id; }; } } -- cgit v1.2.3 From 5b38b5f6cc3a96ca62cb345e14aaff05a39e8171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 19 Sep 2013 22:20:58 +0200 Subject: Introspectable: fix compilation issue (bzr r3506.5.33) --- unity-shared/Introspectable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'unity-shared') diff --git a/unity-shared/Introspectable.h b/unity-shared/Introspectable.h index ab4302696..af7c0dd84 100644 --- a/unity-shared/Introspectable.h +++ b/unity-shared/Introspectable.h @@ -59,7 +59,7 @@ protected: private: std::list children_; std::list parents_; - int32_t _id; + int32_t id_; }; } } -- cgit v1.2.3 From f8752d5339a798f0fdfed01f10a96eac1eea31d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 30 Oct 2013 14:29:38 -0700 Subject: Unity: use IsIntersecting when possible (bzr r3347.3.13) --- unity-shared/PlacesOverlayVScrollBar.cpp | 3 +-- unity-shared/PluginAdapter.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/PlacesOverlayVScrollBar.cpp b/unity-shared/PlacesOverlayVScrollBar.cpp index fc5d2daac..e16f4b848 100644 --- a/unity-shared/PlacesOverlayVScrollBar.cpp +++ b/unity-shared/PlacesOverlayVScrollBar.cpp @@ -209,9 +209,8 @@ void PlacesOverlayVScrollBar::CheckIfThumbIsInsideSlider() { nux::Geometry const& slider_geo = _slider->GetAbsoluteGeometry(); nux::Geometry const& thumb_geo = overlay_window_->GetThumbGeometry(); - nux::Geometry const& intersection = (thumb_geo.Intersect(slider_geo)); - if (!intersection.IsNull()) + if (thumb_geo.IsIntersecting(slider_geo)) { ResetConnector(); overlay_window_->ThumbInsideSlider(); diff --git a/unity-shared/PluginAdapter.cpp b/unity-shared/PluginAdapter.cpp index b233f3067..34bead63d 100644 --- a/unity-shared/PluginAdapter.cpp +++ b/unity-shared/PluginAdapter.cpp @@ -573,7 +573,7 @@ bool PluginAdapter::IsWindowObscured(Window window_id) const && sibling->isMapped() && sibling->isViewable() && (sibling->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE - && !GetWindowGeometry(sibling->id()).Intersect(win_geo).IsNull()) + && GetWindowGeometry(sibling->id()).IsIntersecting(win_geo)) { return true; } -- cgit v1.2.3 From 7a83bc70d95f33df9c79c6b97bd4e9eca5aa3e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 31 Oct 2013 13:56:07 -0700 Subject: BackgroundEffectHelper: use IsIntersecting (bzr r3347.3.16) --- unity-shared/BackgroundEffectHelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'unity-shared') diff --git a/unity-shared/BackgroundEffectHelper.cpp b/unity-shared/BackgroundEffectHelper.cpp index d48aad978..0d86d3aba 100644 --- a/unity-shared/BackgroundEffectHelper.cpp +++ b/unity-shared/BackgroundEffectHelper.cpp @@ -74,7 +74,7 @@ void BackgroundEffectHelper::ProcessDamage(nux::Geometry const& geo) if (bg_effect_helper->cache_dirty || !bg_effect_helper->owner || !bg_effect_helper->enabled) continue; - if (!geo.Intersect(bg_effect_helper->blur_geometry_).IsNull()) + if (geo.IsIntersecting(bg_effect_helper->blur_geometry_)) { bg_effect_helper->DirtyCache(); } -- cgit v1.2.3