From 241d4101db14e5791a3993580d1a86f569a0684b Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Tue, 23 Oct 2012 09:52:18 +0200 Subject: Add new nux X support macros. (bzr r2865.2.1) --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d7a00627..da2b33106 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,9 +25,11 @@ option( if(UNITY_ENABLE_X_ORG_SUPPORT) add_definitions(-DUNITY_HAS_X_ORG_SUPPORT) + add_definitions(-DUSE_X11) message("Unity is configured with support for X.org") else () message("Unity is configured with without X.org") + add_definitions(-DNO_X11) endif() if (BUILD_GLES) -- cgit v1.2.3 From 8f9b81b27caa0a1686026676466d0c0f197ac138 Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Tue, 23 Oct 2012 10:32:09 +0200 Subject: Nice cmake flag to disable i18n due to qemu bug. (bzr r2865.2.2) --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index da2b33106..55d58bb74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,13 @@ option( ON ) +# This is due to bug lp:668799 - qemu-arm segfaults executing msgmerge +option( + I18N_SUPPORT + "Enable I18N, do the .po file thing." + ON +) + if(UNITY_ENABLE_X_ORG_SUPPORT) add_definitions(-DUNITY_HAS_X_ORG_SUPPORT) add_definitions(-DUSE_X11) @@ -119,12 +126,14 @@ add_custom_command (OUTPUT ${CMAKE_SOURCE_DIR}/po/unity.pot WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) +if (I18N_SUPPORT) if (${GETTEXT_FOUND} STREQUAL "TRUE") set (HAVE_GETTEXT true) file (GLOB _translations ${CMAKE_SOURCE_DIR}/po/*.po) GETTEXT_CREATE_TRANSLATIONS (${CMAKE_SOURCE_DIR}/po/${PROJECT_NAME}.pot ALL ${_translations}) endif (${GETTEXT_FOUND} STREQUAL "TRUE") +endif() # # Enable or disable boot logging -- cgit v1.2.3 From e52088b311e876012712a90fc508b0ebfca1b7d6 Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Tue, 23 Oct 2012 10:43:13 +0200 Subject: Exclude some tests when not using X. (bzr r2865.2.3) --- tests/CMakeLists.txt | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e5c69a84e..4efa4ecfd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -179,6 +179,7 @@ if (GTEST_SRC_DIR AND add_test(UnityGTestDBus test-gtest-dbus) add_dependencies(test-gtest-dbus unity-core-${UNITY_API_VERSION} test-gtest-service gtest) +if (UNITY_ENABLE_X_ORG_SUPPORT) # Tests that require X add_executable(test-gtest test_main.cpp @@ -230,12 +231,14 @@ if (GTEST_SRC_DIR AND target_link_libraries(test-gtest gtest gmock unity-shared ${LIBS} launcher-lib unity-shared-standalone shortcuts-lib previews-lib hud-lib switcher-lib dash-lib panel-lib) add_test(UnityGTest test-gtest) add_dependencies(test-gtest unity-core-${UNITY_API_VERSION} gtest gmock) - +endif (UNITY_ENABLE_X_ORG_SUPPORT) endif (GTEST_SRC_DIR AND GMOCK_LIB AND GMOCK_MAIN_LIB) -add_subdirectory (test-gestures) +if(UNITY_ENABLE_X_ORG_SUPPORT) + add_subdirectory (test-gestures) +endif() # # check target @@ -243,10 +246,12 @@ add_subdirectory (test-gestures) set (TEST_RESULT_DIR ${CMAKE_BINARY_DIR}/tests) set (TEST_RESULT_XML ${TEST_RESULT_DIR}/test-results_xml) set (TEST_RESULT_HTML ${TEST_RESULT_DIR}/test-results_html) -set (GTEST_TEST_COMMAND ./test-gtest) +if (UNITY_ENABLE_X_ORG_SUPPORT) + set (GTEST_TEST_COMMAND ./test-gtest) + set (GTEST_TEST_COMMAND_GESTURES ./test-gestures/test-gestures) +endif (UNITY_ENABLE_X_ORG_SUPPORT) set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless) set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --task ./test-gtest-service --task ./test-gtest-dbus) -set (GTEST_TEST_COMMAND_GESTURES ./test-gestures/test-gestures) set (TEST_COMMAND gtester --verbose -k --g-fatal-warnings -o=${TEST_RESULT_XML} ./test-unit @@ -263,10 +268,16 @@ set (TEST_COMMAND_HEADLESS && echo "Warning, DBus test cases are disabled!!") if (GTEST_SRC_DIR) - add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-xless test-gtest-dbus test-gestures) - add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus test-gestures) + if (UNITY_ENABLE_X_ORG_SUPPORT) + add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-xless test-gtest-dbus test-gestures) + add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus test-gestures) + add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest test-gtest-xless) + else () + add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest-xless test-gtest-dbus) + add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus) + add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest-xless) + endif () add_custom_target (check-report COMMAND ${TEST_UNIT_COMMAND} && gtester-report ${TEST_RESULT_XML} > ${TEST_RESULT_HTML}) - add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest test-gtest-xless) else (GTEST_SRC_DIR) add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit) endif (GTEST_SRC_DIR) -- cgit v1.2.3 From 1865cff4d91a43585077455ad4bba5c5a7f785f6 Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Tue, 23 Oct 2012 10:48:42 +0200 Subject: The eSHAPE_CORNER_ROUND5 has been removed, so using 4. No idea what this will actually do. (bzr r2865.2.4) --- unity-shared/UnityWindowView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unity-shared/UnityWindowView.cpp b/unity-shared/UnityWindowView.cpp index 6b6a8a920..9de1d5857 100644 --- a/unity-shared/UnityWindowView.cpp +++ b/unity-shared/UnityWindowView.cpp @@ -136,7 +136,7 @@ void UnityWindowView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_dr gPainter.PaintShapeCornerROP(GfxContext, internal_clip, nux::color::White, - nux::eSHAPE_CORNER_ROUND5, + nux::eSHAPE_CORNER_ROUND4, nux::eCornerTopLeft | nux::eCornerTopRight | nux::eCornerBottomLeft | nux::eCornerBottomRight, true, -- cgit v1.2.3 From b3f0d2e81ef48b94d612c7957dbe17bdad66d866 Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Tue, 23 Oct 2012 10:54:42 +0200 Subject: Don't need the compiz header there. (bzr r2865.2.5) --- launcher/LauncherOptions.h | 1 - 1 file changed, 1 deletion(-) diff --git a/launcher/LauncherOptions.h b/launcher/LauncherOptions.h index 0a29a5bb6..81b7aabec 100644 --- a/launcher/LauncherOptions.h +++ b/launcher/LauncherOptions.h @@ -24,7 +24,6 @@ #include #include #include -#include #include -- cgit v1.2.3 From ea720f72c5d6f35ca2e0fb8efe0c69d681bac09a Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Tue, 23 Oct 2012 11:17:21 +0200 Subject: The showdesktop tests need X. (bzr r2865.2.6) --- tests/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4efa4ecfd..d8508f0b7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -142,14 +142,12 @@ if (GTEST_SRC_DIR AND test_previews.cpp test_shortcut_model.cpp test_shortcut_private.cpp - test_showdesktop_handler.cpp test_ubus.cpp test_unityshell_private.cpp ${CMAKE_CURRENT_BINARY_DIR}/test_glib_signals_utils_marshal.cpp ${UNITY_SRC}/DebugDBusInterface.cpp ${UNITY_SRC}/XPathQueryPart.cpp ${UNITY_SRC}/UnityshellPrivate.cpp - ${UNITY_SRC}/UnityShowdesktopHandler.cpp ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.cpp ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.cpp ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.cpp @@ -214,6 +212,7 @@ if (UNITY_ENABLE_X_ORG_SUPPORT) test_shortcut_controller.cpp test_single_monitor_launcher_icon.cpp test_expo_launcher_icon.cpp + test_showdesktop_handler.cpp test_switcher_controller.cpp test_switcher_model.cpp test_texture_cache.cpp @@ -226,6 +225,7 @@ if (UNITY_ENABLE_X_ORG_SUPPORT) bamf-mock-application.c gmockmount.c gmockvolume.c + ${UNITY_SRC}/UnityShowdesktopHandler.cpp ${CMAKE_SOURCE_DIR}/plugins/unityshell/src/WindowMinimizeSpeedController.cpp ) target_link_libraries(test-gtest gtest gmock unity-shared ${LIBS} launcher-lib unity-shared-standalone shortcuts-lib previews-lib hud-lib switcher-lib dash-lib panel-lib) -- cgit v1.2.3 From 4abcf1c6a8ba87c8aa8bd31e4882580d3b16b329 Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Tue, 23 Oct 2012 11:17:35 +0200 Subject: The shortcuts currently need compiz. (bzr r2865.2.7) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 55d58bb74..70fd16edb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,7 +170,6 @@ pkg_check_modules (CACHED_UNITY_PRIVATE_DEPS REQUIRED ${UNITY_PROTOCOL_PRIVATE_D add_subdirectory(unity-shared) add_subdirectory(dash) add_subdirectory(launcher) -add_subdirectory(shortcuts) if(UNITY_ENABLE_X_ORG_SUPPORT) add_subdirectory(hud) add_subdirectory(panel) @@ -178,6 +177,7 @@ if(UNITY_ENABLE_X_ORG_SUPPORT) add_subdirectory(plugins/networkarearegion) add_subdirectory(plugins/unitydialog) add_subdirectory(plugins/unity-mt-grab-handles) + add_subdirectory(shortcuts) add_subdirectory(unity-standalone) endif() -- cgit v1.2.3 From 6766a1fd2988191974edb42b51508c34035adf04 Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Wed, 24 Oct 2012 09:54:53 +0200 Subject: Use the range based for, and remove compiz header. Move the debug files into unity-shared. (bzr r2865.2.8) --- plugins/unityshell/src/DebugDBusInterface.cpp | 394 -------------------------- plugins/unityshell/src/DebugDBusInterface.h | 67 ----- plugins/unityshell/src/XPathQueryPart.cpp | 189 ------------ plugins/unityshell/src/XPathQueryPart.h | 45 --- unity-shared/CMakeLists.txt | 2 + unity-shared/DebugDBusInterface.cpp | 393 +++++++++++++++++++++++++ unity-shared/DebugDBusInterface.h | 67 +++++ unity-shared/XPathQueryPart.cpp | 189 ++++++++++++ unity-shared/XPathQueryPart.h | 45 +++ 9 files changed, 696 insertions(+), 695 deletions(-) delete mode 100644 plugins/unityshell/src/DebugDBusInterface.cpp delete mode 100644 plugins/unityshell/src/DebugDBusInterface.h delete mode 100644 plugins/unityshell/src/XPathQueryPart.cpp delete mode 100644 plugins/unityshell/src/XPathQueryPart.h create mode 100644 unity-shared/DebugDBusInterface.cpp create mode 100644 unity-shared/DebugDBusInterface.h create mode 100644 unity-shared/XPathQueryPart.cpp create mode 100644 unity-shared/XPathQueryPart.h diff --git a/plugins/unityshell/src/DebugDBusInterface.cpp b/plugins/unityshell/src/DebugDBusInterface.cpp deleted file mode 100644 index 42e55de39..000000000 --- a/plugins/unityshell/src/DebugDBusInterface.cpp +++ /dev/null @@ -1,394 +0,0 @@ -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- -/* - * Copyright (C) 2010 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: Alex Launi - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "DebugDBusInterface.h" -#include "Introspectable.h" -#include "XPathQueryPart.h" - -namespace unity -{ -const std::string DBUS_BUS_NAME = "com.canonical.Unity"; - -namespace debug -{ -namespace -{ -nux::logging::Logger logger("unity.debug.DebugDBusInterface"); - -namespace local -{ - std::ofstream output_file; -} -} - -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); - -const char* DebugDBusInterface::DBUS_DEBUG_OBJECT_PATH = "/com/canonical/Unity/Debug"; - -const gchar DebugDBusInterface::introspection_xml[] = - " " - " " - "" - " " - " " - " " - " " - "" - " " - "" - " " - "" - " " - " " - " " - "" - " " - " " - "" - " " - " " - " " - " " - "" - " " - " " - " " - " " - "" - " " - " "; - -GDBusInterfaceVTable DebugDBusInterface::interface_vtable = -{ - DebugDBusInterface::HandleDBusMethodCall, - NULL, - NULL -}; - -static Introspectable* _parent_introspectable; - -DebugDBusInterface::DebugDBusInterface(Introspectable* parent) -{ - _parent_introspectable = parent; - _owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, - unity::DBUS_BUS_NAME.c_str(), - G_BUS_NAME_OWNER_FLAGS_NONE, - &DebugDBusInterface::OnBusAcquired, - &DebugDBusInterface::OnNameAcquired, - &DebugDBusInterface::OnNameLost, - this, - NULL); -} - -DebugDBusInterface::~DebugDBusInterface() -{ - g_bus_unown_name(_owner_id); -} - -void -DebugDBusInterface::OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer data) -{ - int i = 0; - GError* error; - - GDBusNodeInfo* introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL); - if (!introspection_data) - { - LOG_WARNING(logger) << "No dbus introspection data could be loaded. State introspection will not work"; - return; - } - - while (introspection_data->interfaces[i] != NULL) - { - error = NULL; - g_dbus_connection_register_object(connection, - DebugDBusInterface::DBUS_DEBUG_OBJECT_PATH, - introspection_data->interfaces[i], - &interface_vtable, - data, - NULL, - &error); - if (error != NULL) - { - g_warning("Could not register debug interface onto d-bus"); - g_error_free(error); - } - i++; - } - g_dbus_node_info_unref(introspection_data); -} - -void -DebugDBusInterface::OnNameAcquired(GDBusConnection* connection, const gchar* name, gpointer data) -{ -} - -void -DebugDBusInterface::OnNameLost(GDBusConnection* connection, const gchar* name, gpointer data) -{ -} - -void -DebugDBusInterface::HandleDBusMethodCall(GDBusConnection* connection, - const gchar* sender, - const gchar* object_path, - const gchar* interface_name, - const gchar* method_name, - GVariant* parameters, - GDBusMethodInvocation* invocation, - gpointer user_data) -{ - if (g_strcmp0(method_name, "GetState") == 0) - { - GVariant* ret; - const gchar* input; - g_variant_get(parameters, "(&s)", &input); - - ret = GetState(input); - // GetState returns a floating variant and - // g_dbus_method_invocation_return_value ref sinks it - g_dbus_method_invocation_return_value(invocation, ret); - } - else if (g_strcmp0(method_name, "StartLogToFile") == 0) - { - const gchar* log_path; - g_variant_get(parameters, "(&s)", &log_path); - - StartLogToFile(log_path); - g_dbus_method_invocation_return_value(invocation, NULL); - } - else if (g_strcmp0(method_name, "ResetLogging") == 0) - { - ResetLogging(); - g_dbus_method_invocation_return_value(invocation, NULL); - } - else if (g_strcmp0(method_name, "SetLogSeverity") == 0) - { - const gchar* component; - const gchar* severity; - g_variant_get(parameters, "(&s&s)", &component, &severity); - - SetLogSeverity(component, severity); - g_dbus_method_invocation_return_value(invocation, NULL); - } - else if (g_strcmp0(method_name, "LogMessage") == 0) - { - const gchar* severity; - const gchar* message; - g_variant_get(parameters, "(&s&s)", &severity, &message); - - LogMessage(severity, message); - g_dbus_method_invocation_return_value(invocation, NULL); - } - else - { - g_dbus_method_invocation_return_dbus_error(invocation, - unity::DBUS_BUS_NAME.c_str(), - "Failed to find method"); - } -} - - -GVariant* GetState(std::string const& query) -{ - // process the XPath query: - std::list parts = GetIntrospectableNodesFromQuery(query, _parent_introspectable); - GVariantBuilder builder; - g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sv)")); - if (parts.empty()) - { - LOG_WARNING(logger) << "Query '" << query << "' Did not match anything."; - } - for (Introspectable *node : parts) - { - g_variant_builder_add(&builder, "(sv)", node->GetName().c_str(), node->Introspect()); - } - - return g_variant_new("(a(sv))", &builder); -} - -void StartLogToFile(std::string const& file_path) -{ - if (local::output_file.is_open()) - local::output_file.close(); - local::output_file.open(file_path); - nux::logging::Writer::Instance().SetOutputStream(local::output_file); -} - -void ResetLogging() -{ - if (local::output_file.is_open()) - local::output_file.close(); - nux::logging::Writer::Instance().SetOutputStream(std::cout); - nux::logging::reset_logging(); -} - -void SetLogSeverity(std::string const& log_component, - std::string const& severity) -{ - nux::logging::Logger(log_component).SetLogLevel(nux::logging::get_logging_level(severity)); -} - -void LogMessage(std::string const& severity, - std::string const& message) -{ - nux::logging::Level level = nux::logging::get_logging_level(severity); - if (logger.GetEffectiveLogLevel() <= level) - { - nux::logging::LogStream(level, logger.module(), __FILE__, __LINE__).stream() - << message; - } -} - -/* - * Do a breadth-first search of the introspection tree and find all nodes that match the - * query. - */ -std::list GetIntrospectableNodesFromQuery(std::string const& query, Introspectable* tree_root) -{ - std::list start_points; - std::string sanitised_query; - // Allow user to be lazy when specifying root node. - if (query == "" || query == "/") - { - sanitised_query = "/" + tree_root->GetName(); - } - else - { - sanitised_query = query; - } - // split query into parts - std::list query_parts; - - { - std::list query_strings; - boost::algorithm::split(query_strings, sanitised_query, boost::algorithm::is_any_of("/")); - // Boost's split() implementation does not match it's documentation! According to the - // docs, it's not supposed to add empty strings, but it does, which is a PITA. This - // next line removes them: - query_strings.erase( std::remove_if( query_strings.begin(), - query_strings.end(), - boost::bind( &std::string::empty, _1 ) ), - query_strings.end()); - foreach(std::string part, query_strings) - { - query_parts.push_back(XPathQueryPart(part)); - } - } - - // absolute or relative query string? - if (sanitised_query.at(0) == '/' && sanitised_query.at(1) != '/') - { - // absolute query - start point is tree root node. - if (query_parts.front().Matches(tree_root)) - { - start_points.push_back(tree_root); - } - } - else - { - // relative - need to do a depth first tree search for all nodes that match the - // first node in the query. - - // warn about malformed queries (all queries must start with '/') - if (sanitised_query.at(0) != '/') - { - LOG_WARNING(logger) << "Malformed relative introspection query: '" << query << "'."; - } - - // non-recursive BFS traversal to find starting points: - std::queue queue; - queue.push(tree_root); - while (!queue.empty()) - { - Introspectable *node = queue.front(); - queue.pop(); - if (query_parts.front().Matches(node)) - { - // found one. We keep going deeper, as there may be another node beneath this one - // with the same node name. - start_points.push_back(node); - } - // Add all children of current node to queue. - foreach(Introspectable* child, node->GetIntrospectableChildren()) - { - queue.push(child); - } - } - } - - // now we have the tree start points, process them: - query_parts.pop_front(); - typedef std::pair::iterator> node_match_pair; - - std::queue traverse_queue; - foreach(Introspectable *node, start_points) - { - traverse_queue.push(node_match_pair(node, query_parts.begin())); - } - start_points.clear(); - - while (!traverse_queue.empty()) - { - node_match_pair p = traverse_queue.front(); - traverse_queue.pop(); - - Introspectable *node = p.first; - auto query_it = p.second; - - if (query_it == query_parts.end()) - { - // found a match: - start_points.push_back(node); - } - else - { - // push all children of current node to start of queue, advance search iterator, and loop again. - foreach (Introspectable *child, node->GetIntrospectableChildren()) - { - if (query_it->Matches(child)) - { - auto it_copy(query_it); - ++it_copy; - traverse_queue.push(node_match_pair(child, it_copy)); - } - } - } - } - return start_points; -} -} -} diff --git a/plugins/unityshell/src/DebugDBusInterface.h b/plugins/unityshell/src/DebugDBusInterface.h deleted file mode 100644 index 3c11a5a0b..000000000 --- a/plugins/unityshell/src/DebugDBusInterface.h +++ /dev/null @@ -1,67 +0,0 @@ -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- -/* - * Copyright (C) 2010 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: Alex Launi - */ - -#include - -#ifndef _DEBUG_DBUS_INTERFACE_H -#define _DEBUG_DBUS_INTERFACE_H - -class CompScreen; - -namespace unity -{ -extern const std::string DBUS_BUS_NAME; - -namespace debug -{ -class Introspectable; -std::list GetIntrospectableNodesFromQuery(std::string const& query, Introspectable *tree_root); - -class DebugDBusInterface -{ -public: - DebugDBusInterface(Introspectable* introspectable); - ~DebugDBusInterface(); - -private: - /* methods */ - static void OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer data); - static void OnNameAcquired(GDBusConnection* connection, const gchar* name, gpointer data); - static void OnNameLost(GDBusConnection* connection, const gchar* name, gpointer data); - static void HandleDBusMethodCall(GDBusConnection* connection, - const gchar* sender, - const gchar* object_path, - const gchar* interface_name, - const gchar* method_name, - GVariant* parameters, - GDBusMethodInvocation* invocation, - gpointer user_data); - static const char* DBUS_DEBUG_OBJECT_PATH; - static const gchar introspection_xml[]; - static GDBusInterfaceVTable interface_vtable; - - static GVariant* BuildFakeReturn(); - - /* members */ - guint _owner_id; -}; -} -} - -#endif /* _DEBUG_DBUS_INTERFACE_H */ diff --git a/plugins/unityshell/src/XPathQueryPart.cpp b/plugins/unityshell/src/XPathQueryPart.cpp deleted file mode 100644 index a42a65c34..000000000 --- a/plugins/unityshell/src/XPathQueryPart.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- -/* - * Copyright (C) 2010 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: Thomi Richards - */ - -#include -#include -#include -#include -#include -#include -#include "XPathQueryPart.h" -#include "Introspectable.h" - -namespace unity -{ - -namespace debug -{ -namespace -{ - nux::logging::Logger logger("unity.debug.DebugDBusInterface"); -} - -// Stores a part of an XPath query. -XPathQueryPart::XPathQueryPart(std::string const& query_part) -{ - std::vector part_pieces; - boost::algorithm::split(part_pieces, query_part, boost::algorithm::is_any_of("[]=")); - // Boost's split() implementation does not match it's documentation! According to the - // docs, it's not supposed to add empty strings, but it does, which is a PITA. This - // next line removes them: - part_pieces.erase( std::remove_if( part_pieces.begin(), - part_pieces.end(), - boost::bind( &std::string::empty, _1 ) ), - part_pieces.end()); - if (part_pieces.size() == 1) - { - node_name_ = part_pieces.at(0); - } - else if (part_pieces.size() == 3) - { - node_name_ = part_pieces.at(0); - param_name_ = part_pieces.at(1); - param_value_ = part_pieces.at(2); - } - else - { - LOG_WARNING(logger) << "Malformed query part: " << query_part; - // assume it's just a node name: - node_name_ = query_part; - } -} - -bool XPathQueryPart::Matches(Introspectable* node) const -{ - bool matches = false; - if (param_name_ == "") - { - matches = (node_name_ == "*" || node->GetName() == node_name_); - } - else - { - 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, param_name_.c_str(), NULL); - - if (prop_value != NULL) - { - 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... - 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, param_value_.c_str()) == 0) - { - matches = true; - } - } - break; - case G_VARIANT_CLASS_BOOLEAN: - { - std::string value = boost::to_upper_copy(param_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(param_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; - case G_VARIANT_CLASS_INT16: - { - std::stringstream stream(param_value_); - gint16 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_int16(prop_value); - } - break; - case G_VARIANT_CLASS_UINT16: - { - std::stringstream stream(param_value_); - guint16 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_uint16(prop_value); - } - break; - case G_VARIANT_CLASS_INT32: - { - std::stringstream stream(param_value_); - gint32 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_int32(prop_value); - } - break; - case G_VARIANT_CLASS_UINT32: - { - std::stringstream stream(param_value_); - guint32 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_uint32(prop_value); - } - break; - case G_VARIANT_CLASS_INT64: - { - std::stringstream stream(param_value_); - gint64 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_int64(prop_value); - } - break; - case G_VARIANT_CLASS_UINT64: - { - std::stringstream stream(param_value_); - guint64 val; - stream >> val; - matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && - val == g_variant_get_uint64(prop_value); - } - break; - default: - LOG_WARNING(logger) << "Unable to match against property of unknown type."; - }; - } - g_variant_unref(prop_value); - g_variant_unref(prop_dict); - } - - return matches; -} - -} -} diff --git a/plugins/unityshell/src/XPathQueryPart.h b/plugins/unityshell/src/XPathQueryPart.h deleted file mode 100644 index b5beb3f4f..000000000 --- a/plugins/unityshell/src/XPathQueryPart.h +++ /dev/null @@ -1,45 +0,0 @@ -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- -/* - * Copyright (C) 2010 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: Thomi Richards - */ - -#include - -#ifndef _XPATH_QUERY_PART -#define _XPATH_QUERY_PART - -namespace unity -{ -namespace debug -{ - class Introspectable; - // Stores a part of an XPath query. - class XPathQueryPart - { - public: - XPathQueryPart(std::string const& query_part); - bool Matches(Introspectable* node) const; - private: - std::string node_name_; - std::string param_name_; - std::string param_value_; - }; - -} -} - -#endif diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt index 28dcc84e8..576d89482 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -32,6 +32,7 @@ set (UNITY_SHARED_SOURCES CoverArt.cpp BackgroundEffectHelper.cpp DashStyle.cpp + DebugDBusInterface.cpp DefaultThumbnailProvider.cpp FontSettings.cpp IMTextEntry.cpp @@ -64,6 +65,7 @@ set (UNITY_SHARED_SOURCES UnityWindowView.cpp UserThumbnailProvider.cpp WindowManager.cpp + XPathQueryPart.cpp ) if(UNITY_ENABLE_X_ORG_SUPPORT) diff --git a/unity-shared/DebugDBusInterface.cpp b/unity-shared/DebugDBusInterface.cpp new file mode 100644 index 000000000..f086eac4a --- /dev/null +++ b/unity-shared/DebugDBusInterface.cpp @@ -0,0 +1,393 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2010 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: Alex Launi + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "DebugDBusInterface.h" +#include "Introspectable.h" +#include "XPathQueryPart.h" + +namespace unity +{ +const std::string DBUS_BUS_NAME = "com.canonical.Unity"; + +namespace debug +{ +namespace +{ +nux::logging::Logger logger("unity.debug.DebugDBusInterface"); + +namespace local +{ + std::ofstream output_file; +} +} + +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); + +const char* DebugDBusInterface::DBUS_DEBUG_OBJECT_PATH = "/com/canonical/Unity/Debug"; + +const gchar DebugDBusInterface::introspection_xml[] = + " " + " " + "" + " " + " " + " " + " " + "" + " " + "" + " " + "" + " " + " " + " " + "" + " " + " " + "" + " " + " " + " " + " " + "" + " " + " " + " " + " " + "" + " " + " "; + +GDBusInterfaceVTable DebugDBusInterface::interface_vtable = +{ + DebugDBusInterface::HandleDBusMethodCall, + NULL, + NULL +}; + +static Introspectable* _parent_introspectable; + +DebugDBusInterface::DebugDBusInterface(Introspectable* parent) +{ + _parent_introspectable = parent; + _owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, + unity::DBUS_BUS_NAME.c_str(), + G_BUS_NAME_OWNER_FLAGS_NONE, + &DebugDBusInterface::OnBusAcquired, + &DebugDBusInterface::OnNameAcquired, + &DebugDBusInterface::OnNameLost, + this, + NULL); +} + +DebugDBusInterface::~DebugDBusInterface() +{ + g_bus_unown_name(_owner_id); +} + +void +DebugDBusInterface::OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer data) +{ + int i = 0; + GError* error; + + GDBusNodeInfo* introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL); + if (!introspection_data) + { + LOG_WARNING(logger) << "No dbus introspection data could be loaded. State introspection will not work"; + return; + } + + while (introspection_data->interfaces[i] != NULL) + { + error = NULL; + g_dbus_connection_register_object(connection, + DebugDBusInterface::DBUS_DEBUG_OBJECT_PATH, + introspection_data->interfaces[i], + &interface_vtable, + data, + NULL, + &error); + if (error != NULL) + { + g_warning("Could not register debug interface onto d-bus"); + g_error_free(error); + } + i++; + } + g_dbus_node_info_unref(introspection_data); +} + +void +DebugDBusInterface::OnNameAcquired(GDBusConnection* connection, const gchar* name, gpointer data) +{ +} + +void +DebugDBusInterface::OnNameLost(GDBusConnection* connection, const gchar* name, gpointer data) +{ +} + +void +DebugDBusInterface::HandleDBusMethodCall(GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* method_name, + GVariant* parameters, + GDBusMethodInvocation* invocation, + gpointer user_data) +{ + if (g_strcmp0(method_name, "GetState") == 0) + { + GVariant* ret; + const gchar* input; + g_variant_get(parameters, "(&s)", &input); + + ret = GetState(input); + // GetState returns a floating variant and + // g_dbus_method_invocation_return_value ref sinks it + g_dbus_method_invocation_return_value(invocation, ret); + } + else if (g_strcmp0(method_name, "StartLogToFile") == 0) + { + const gchar* log_path; + g_variant_get(parameters, "(&s)", &log_path); + + StartLogToFile(log_path); + g_dbus_method_invocation_return_value(invocation, NULL); + } + else if (g_strcmp0(method_name, "ResetLogging") == 0) + { + ResetLogging(); + g_dbus_method_invocation_return_value(invocation, NULL); + } + else if (g_strcmp0(method_name, "SetLogSeverity") == 0) + { + const gchar* component; + const gchar* severity; + g_variant_get(parameters, "(&s&s)", &component, &severity); + + SetLogSeverity(component, severity); + g_dbus_method_invocation_return_value(invocation, NULL); + } + else if (g_strcmp0(method_name, "LogMessage") == 0) + { + const gchar* severity; + const gchar* message; + g_variant_get(parameters, "(&s&s)", &severity, &message); + + LogMessage(severity, message); + g_dbus_method_invocation_return_value(invocation, NULL); + } + else + { + g_dbus_method_invocation_return_dbus_error(invocation, + unity::DBUS_BUS_NAME.c_str(), + "Failed to find method"); + } +} + + +GVariant* GetState(std::string const& query) +{ + // process the XPath query: + std::list parts = GetIntrospectableNodesFromQuery(query, _parent_introspectable); + GVariantBuilder builder; + g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sv)")); + if (parts.empty()) + { + LOG_WARNING(logger) << "Query '" << query << "' Did not match anything."; + } + for (Introspectable *node : parts) + { + g_variant_builder_add(&builder, "(sv)", node->GetName().c_str(), node->Introspect()); + } + + return g_variant_new("(a(sv))", &builder); +} + +void StartLogToFile(std::string const& file_path) +{ + if (local::output_file.is_open()) + local::output_file.close(); + local::output_file.open(file_path); + nux::logging::Writer::Instance().SetOutputStream(local::output_file); +} + +void ResetLogging() +{ + if (local::output_file.is_open()) + local::output_file.close(); + nux::logging::Writer::Instance().SetOutputStream(std::cout); + nux::logging::reset_logging(); +} + +void SetLogSeverity(std::string const& log_component, + std::string const& severity) +{ + nux::logging::Logger(log_component).SetLogLevel(nux::logging::get_logging_level(severity)); +} + +void LogMessage(std::string const& severity, + std::string const& message) +{ + nux::logging::Level level = nux::logging::get_logging_level(severity); + if (logger.GetEffectiveLogLevel() <= level) + { + nux::logging::LogStream(level, logger.module(), __FILE__, __LINE__).stream() + << message; + } +} + +/* + * Do a breadth-first search of the introspection tree and find all nodes that match the + * query. + */ +std::list GetIntrospectableNodesFromQuery(std::string const& query, Introspectable* tree_root) +{ + std::list start_points; + std::string sanitised_query; + // Allow user to be lazy when specifying root node. + if (query == "" || query == "/") + { + sanitised_query = "/" + tree_root->GetName(); + } + else + { + sanitised_query = query; + } + // split query into parts + std::list query_parts; + + { + std::list query_strings; + boost::algorithm::split(query_strings, sanitised_query, boost::algorithm::is_any_of("/")); + // Boost's split() implementation does not match it's documentation! According to the + // docs, it's not supposed to add empty strings, but it does, which is a PITA. This + // next line removes them: + query_strings.erase( std::remove_if( query_strings.begin(), + query_strings.end(), + boost::bind( &std::string::empty, _1 ) ), + query_strings.end()); + for (auto part : query_strings) + { + query_parts.push_back(XPathQueryPart(part)); + } + } + + // absolute or relative query string? + if (sanitised_query.at(0) == '/' && sanitised_query.at(1) != '/') + { + // absolute query - start point is tree root node. + if (query_parts.front().Matches(tree_root)) + { + start_points.push_back(tree_root); + } + } + else + { + // relative - need to do a depth first tree search for all nodes that match the + // first node in the query. + + // warn about malformed queries (all queries must start with '/') + if (sanitised_query.at(0) != '/') + { + LOG_WARNING(logger) << "Malformed relative introspection query: '" << query << "'."; + } + + // non-recursive BFS traversal to find starting points: + std::queue queue; + queue.push(tree_root); + while (!queue.empty()) + { + Introspectable *node = queue.front(); + queue.pop(); + if (query_parts.front().Matches(node)) + { + // found one. We keep going deeper, as there may be another node beneath this one + // with the same node name. + start_points.push_back(node); + } + // Add all children of current node to queue. + for (Introspectable* child : node->GetIntrospectableChildren()) + { + queue.push(child); + } + } + } + + // now we have the tree start points, process them: + query_parts.pop_front(); + typedef std::pair::iterator> node_match_pair; + + std::queue traverse_queue; + for (Introspectable *node : start_points) + { + traverse_queue.push(node_match_pair(node, query_parts.begin())); + } + start_points.clear(); + + while (!traverse_queue.empty()) + { + node_match_pair p = traverse_queue.front(); + traverse_queue.pop(); + + Introspectable *node = p.first; + auto query_it = p.second; + + if (query_it == query_parts.end()) + { + // found a match: + start_points.push_back(node); + } + else + { + // push all children of current node to start of queue, advance search iterator, and loop again. + for (Introspectable* child : node->GetIntrospectableChildren()) + { + if (query_it->Matches(child)) + { + auto it_copy(query_it); + ++it_copy; + traverse_queue.push(node_match_pair(child, it_copy)); + } + } + } + } + return start_points; +} +} +} diff --git a/unity-shared/DebugDBusInterface.h b/unity-shared/DebugDBusInterface.h new file mode 100644 index 000000000..3c11a5a0b --- /dev/null +++ b/unity-shared/DebugDBusInterface.h @@ -0,0 +1,67 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2010 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: Alex Launi + */ + +#include + +#ifndef _DEBUG_DBUS_INTERFACE_H +#define _DEBUG_DBUS_INTERFACE_H + +class CompScreen; + +namespace unity +{ +extern const std::string DBUS_BUS_NAME; + +namespace debug +{ +class Introspectable; +std::list GetIntrospectableNodesFromQuery(std::string const& query, Introspectable *tree_root); + +class DebugDBusInterface +{ +public: + DebugDBusInterface(Introspectable* introspectable); + ~DebugDBusInterface(); + +private: + /* methods */ + static void OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer data); + static void OnNameAcquired(GDBusConnection* connection, const gchar* name, gpointer data); + static void OnNameLost(GDBusConnection* connection, const gchar* name, gpointer data); + static void HandleDBusMethodCall(GDBusConnection* connection, + const gchar* sender, + const gchar* object_path, + const gchar* interface_name, + const gchar* method_name, + GVariant* parameters, + GDBusMethodInvocation* invocation, + gpointer user_data); + static const char* DBUS_DEBUG_OBJECT_PATH; + static const gchar introspection_xml[]; + static GDBusInterfaceVTable interface_vtable; + + static GVariant* BuildFakeReturn(); + + /* members */ + guint _owner_id; +}; +} +} + +#endif /* _DEBUG_DBUS_INTERFACE_H */ diff --git a/unity-shared/XPathQueryPart.cpp b/unity-shared/XPathQueryPart.cpp new file mode 100644 index 000000000..a42a65c34 --- /dev/null +++ b/unity-shared/XPathQueryPart.cpp @@ -0,0 +1,189 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2010 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: Thomi Richards + */ + +#include +#include +#include +#include +#include +#include +#include "XPathQueryPart.h" +#include "Introspectable.h" + +namespace unity +{ + +namespace debug +{ +namespace +{ + nux::logging::Logger logger("unity.debug.DebugDBusInterface"); +} + +// Stores a part of an XPath query. +XPathQueryPart::XPathQueryPart(std::string const& query_part) +{ + std::vector part_pieces; + boost::algorithm::split(part_pieces, query_part, boost::algorithm::is_any_of("[]=")); + // Boost's split() implementation does not match it's documentation! According to the + // docs, it's not supposed to add empty strings, but it does, which is a PITA. This + // next line removes them: + part_pieces.erase( std::remove_if( part_pieces.begin(), + part_pieces.end(), + boost::bind( &std::string::empty, _1 ) ), + part_pieces.end()); + if (part_pieces.size() == 1) + { + node_name_ = part_pieces.at(0); + } + else if (part_pieces.size() == 3) + { + node_name_ = part_pieces.at(0); + param_name_ = part_pieces.at(1); + param_value_ = part_pieces.at(2); + } + else + { + LOG_WARNING(logger) << "Malformed query part: " << query_part; + // assume it's just a node name: + node_name_ = query_part; + } +} + +bool XPathQueryPart::Matches(Introspectable* node) const +{ + bool matches = false; + if (param_name_ == "") + { + matches = (node_name_ == "*" || node->GetName() == node_name_); + } + else + { + 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, param_name_.c_str(), NULL); + + if (prop_value != NULL) + { + 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... + 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, param_value_.c_str()) == 0) + { + matches = true; + } + } + break; + case G_VARIANT_CLASS_BOOLEAN: + { + std::string value = boost::to_upper_copy(param_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(param_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; + case G_VARIANT_CLASS_INT16: + { + std::stringstream stream(param_value_); + gint16 val; + stream >> val; + matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && + val == g_variant_get_int16(prop_value); + } + break; + case G_VARIANT_CLASS_UINT16: + { + std::stringstream stream(param_value_); + guint16 val; + stream >> val; + matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && + val == g_variant_get_uint16(prop_value); + } + break; + case G_VARIANT_CLASS_INT32: + { + std::stringstream stream(param_value_); + gint32 val; + stream >> val; + matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && + val == g_variant_get_int32(prop_value); + } + break; + case G_VARIANT_CLASS_UINT32: + { + std::stringstream stream(param_value_); + guint32 val; + stream >> val; + matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && + val == g_variant_get_uint32(prop_value); + } + break; + case G_VARIANT_CLASS_INT64: + { + std::stringstream stream(param_value_); + gint64 val; + stream >> val; + matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && + val == g_variant_get_int64(prop_value); + } + break; + case G_VARIANT_CLASS_UINT64: + { + std::stringstream stream(param_value_); + guint64 val; + stream >> val; + matches = (stream.rdstate() & (stream.badbit|stream.failbit)) == 0 && + val == g_variant_get_uint64(prop_value); + } + break; + default: + LOG_WARNING(logger) << "Unable to match against property of unknown type."; + }; + } + g_variant_unref(prop_value); + g_variant_unref(prop_dict); + } + + return matches; +} + +} +} diff --git a/unity-shared/XPathQueryPart.h b/unity-shared/XPathQueryPart.h new file mode 100644 index 000000000..b5beb3f4f --- /dev/null +++ b/unity-shared/XPathQueryPart.h @@ -0,0 +1,45 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2010 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: Thomi Richards + */ + +#include + +#ifndef _XPATH_QUERY_PART +#define _XPATH_QUERY_PART + +namespace unity +{ +namespace debug +{ + class Introspectable; + // Stores a part of an XPath query. + class XPathQueryPart + { + public: + XPathQueryPart(std::string const& query_part); + bool Matches(Introspectable* node) const; + private: + std::string node_name_; + std::string param_name_; + std::string param_value_; + }; + +} +} + +#endif -- cgit v1.2.3 From b17c55d85df6748ab18ce532de3d32317a79233c Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Wed, 24 Oct 2012 09:55:29 +0200 Subject: Don't use gestures if nux doesn't support them. (bzr r2865.2.9) --- launcher/Launcher.cpp | 13 +++++++------ launcher/Launcher.h | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp index cdf6a5281..e5e5675d9 100644 --- a/launcher/Launcher.cpp +++ b/launcher/Launcher.cpp @@ -235,8 +235,8 @@ void Launcher::OnDisplayChanged(Display* display) _collection_window->display = display; } -void -Launcher::OnDragStart(const nux::GestureEvent &event) +#ifdef NUX_GESTURES_SUPPORT +void Launcher::OnDragStart(const nux::GestureEvent &event) { _drag_gesture_ongoing = true; if (_hidden) @@ -250,16 +250,14 @@ Launcher::OnDragStart(const nux::GestureEvent &event) } } -void -Launcher::OnDragUpdate(const nux::GestureEvent &event) +void Launcher::OnDragUpdate(const nux::GestureEvent &event) { _drag_out_delta_x = CLAMP(_drag_out_delta_x + event.GetDelta().x, 0.0f, DRAG_OUT_PIXELS); EnsureAnimation(); } -void -Launcher::OnDragFinish(const nux::GestureEvent &event) +void Launcher::OnDragFinish(const nux::GestureEvent &event) { if (_drag_out_delta_x >= DRAG_OUT_PIXELS - 90.0f) _hide_machine.SetQuirk(LauncherHideMachine::MT_DRAG_OUT, true); @@ -269,6 +267,7 @@ Launcher::OnDragFinish(const nux::GestureEvent &event) EnsureAnimation(); _drag_gesture_ongoing = false; } +#endif void Launcher::AddProperties(GVariantBuilder* builder) { @@ -2523,6 +2522,7 @@ void Launcher::RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLaun RestoreSystemRenderTarget(); } +#ifdef NUX_GESTURES_SUPPORT nux::GestureDeliveryRequest Launcher::GestureEvent(const nux::GestureEvent &event) { switch(event.type) @@ -2540,6 +2540,7 @@ nux::GestureDeliveryRequest Launcher::GestureEvent(const nux::GestureEvent &even return nux::GestureDeliveryRequest::NONE; } +#endif void Launcher::SetOffscreenRenderTarget(nux::ObjectPtr texture) diff --git a/launcher/Launcher.h b/launcher/Launcher.h index 0e6d2ab0a..de5138292 100644 --- a/launcher/Launcher.h +++ b/launcher/Launcher.h @@ -148,7 +148,10 @@ public: void RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr const& icon, nux::ObjectPtr texture); +#ifdef NUX_GESTURES_SUPPORT virtual nux::GestureDeliveryRequest GestureEvent(const nux::GestureEvent &event); +#endif + protected: // Introspectable methods std::string GetName() const; @@ -193,9 +196,11 @@ private: void OnOptionChanged(); void UpdateOptions(Options::Ptr options); +#ifdef NUX_GESTURES_SUPPORT void OnDragStart(const nux::GestureEvent &event); void OnDragUpdate(const nux::GestureEvent &event); void OnDragFinish(const nux::GestureEvent &event); +#endif #ifdef UNITY_HAS_X_ORG_SUPPORT bool HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event); -- cgit v1.2.3 From d57069a3ad9d68304278b0d469ac1b5997d0f5d6 Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Wed, 24 Oct 2012 09:56:09 +0200 Subject: Pull out a bunch of dependencies if not using X. (bzr r2865.2.10) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70fd16edb..a175dae82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,7 +158,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MAINTAINER_CXXFLAGS}") if(UNITY_ENABLE_X_ORG_SUPPORT) set (UNITY_PLUGIN_DEPS "compiz>=0.9.8.0;nux-3.0>=3.0.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;gmodule-2.0;dbusmenu-glib-0.4;x11;libstartup-notification-1.0;gthread-2.0;indicator3-0.4>=0.4.90;atk;atk-bridge-2.0;unity-misc>=0.4.0;dbus-glib-1;gtk+-3.0>=3.1;sigc++-2.0;json-glib-1.0;libnotify;xfixes;unity-protocol-private>=5.95.1;libgeis;xrender>=0.9;zeitgeist-1.0>=0.3.18") else () - set (UNITY_PLUGIN_DEPS "nux-3.0>=3.0.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;gmodule-2.0;dbusmenu-glib-0.4;libstartup-notification-1.0;gthread-2.0;indicator3-0.4>=0.4.90;atk;atk-bridge-2.0;unity-misc>=0.4.0;dbus-glib-1;gtk+-3.0>=3.1;sigc++-2.0;json-glib-1.0;libnotify;xfixes;unity-protocol-private>=5.95.1;libgeis;xrender>=0.9;zeitgeist-1.0>=0.3.18") + set (UNITY_PLUGIN_DEPS "nux-3.0>=3.0.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;gmodule-2.0;dbusmenu-glib-0.4;libstartup-notification-1.0;gthread-2.0;indicator3-0.4>=0.4.90;atk;atk-bridge-2.0;unity-misc>=0.4.0;dbus-glib-1;gtk+-3.0>=3.1;sigc++-2.0;json-glib-1.0;libnotify;unity-protocol-private>=5.95.1;zeitgeist-1.0>=0.3.18") endif () set (UNITY_PROTOCOL_PRIVATE_DEPS "unity-protocol-private>=5.95.1") -- cgit v1.2.3 From c4f89928f1d4e914f5607754375dbb916c288b3e Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Wed, 24 Oct 2012 09:56:27 +0200 Subject: Conditionally compile some of the test files. (bzr r2865.2.11) --- tests/CMakeLists.txt | 94 ++++++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d8508f0b7..d9a79c93a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -112,49 +112,57 @@ if (GTEST_SRC_DIR AND # The actual test executable (xless) - do not put anything that requires X in here - add_executable(test-gtest-xless - test_main_xless.cpp - test_animator.cpp - test_launcher_model.cpp - test_glib_object.cpp - test_glib_object_utils.cpp - test_glib_object_utils.h - test_glib_signals.cpp - test_glib_signals_utils.cpp - test_glib_signals_utils.h - test_glib_source.cpp - test_glib_variant.cpp - test_grabhandle.cpp - test_desktop_utilities.cpp - test_hud_private.cpp - test_indicator.cpp - test_indicator_appmenu.cpp - test_indicator_entry.cpp - test_indicators.cpp - test_introspection.cpp - test_favorite_store.cpp - test_favorite_store_gsettings.cpp - test_favorite_store_private.cpp - test_home_lens.cpp - test_launcher_entry_remote.cpp - test_model_iterator.cpp - test_pointer_barrier.cpp - test_previews.cpp - test_shortcut_model.cpp - test_shortcut_private.cpp - test_ubus.cpp - test_unityshell_private.cpp - ${CMAKE_CURRENT_BINARY_DIR}/test_glib_signals_utils_marshal.cpp - ${UNITY_SRC}/DebugDBusInterface.cpp - ${UNITY_SRC}/XPathQueryPart.cpp - ${UNITY_SRC}/UnityshellPrivate.cpp - ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.cpp - ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.cpp - ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.cpp - ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-layout.cpp - ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp - ) - target_link_libraries(test-gtest-xless gtest unity-shared ${GMOCK_LIB} ${GMOCK_MAIN_LIB} ${LIBS} launcher-lib shortcuts-lib hud-lib) + set (GTEST_XLESS_SOURCES + test_main_xless.cpp + test_animator.cpp + test_launcher_model.cpp + test_glib_object.cpp + test_glib_object_utils.cpp + test_glib_object_utils.h + test_glib_signals.cpp + test_glib_signals_utils.cpp + test_glib_signals_utils.h + test_glib_source.cpp + test_glib_variant.cpp + test_grabhandle.cpp + test_desktop_utilities.cpp + test_indicator.cpp + test_indicator_appmenu.cpp + test_indicator_entry.cpp + test_indicators.cpp + test_introspection.cpp + test_favorite_store.cpp + test_favorite_store_gsettings.cpp + test_favorite_store_private.cpp + test_home_lens.cpp + test_launcher_entry_remote.cpp + test_model_iterator.cpp + test_previews.cpp + test_ubus.cpp + test_unityshell_private.cpp + ${CMAKE_CURRENT_BINARY_DIR}/test_glib_signals_utils_marshal.cpp + ${UNITY_SRC}/UnityshellPrivate.cpp + ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.cpp + ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.cpp + ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.cpp + ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-layout.cpp + ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp +) + +if(UNITY_ENABLE_X_ORG_SUPPORT) + set (GTEST_XLESS_SOURCES + test_hud_private.cpp + test_pointer_barrier.cpp + test_shortcut_model.cpp + test_shortcut_private.cpp + ${LAUNCHER_SOURCES} + ) +endif() + + add_executable(test-gtest-xless ${GTEST_XLESS_SOURCES}) + + + target_link_libraries(test-gtest-xless gtest unity-shared ${GMOCK_LIB} ${GMOCK_MAIN_LIB} ${LIBS} launcher-lib) add_test(UnityGTestXless test-gtest-xless) add_dependencies(test-gtest-xless unity-core-${UNITY_API_VERSION} gtest) -- cgit v1.2.3 From 881bfe2174363bfd14cbaa10be7c9c671434989d Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Wed, 24 Oct 2012 10:04:33 +0200 Subject: Change the macros, and cmake definitions. (bzr r2865.2.12) --- CMakeLists.txt | 20 ++++++++++---------- launcher/CMakeLists.txt | 8 ++++---- tests/CMakeLists.txt | 16 ++++++++-------- unity-shared/CMakeLists.txt | 4 ++-- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a175dae82..7e6bbfa84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set (CMAKE_CXX_FLAGS_DEBUG "-g3") set (CMAKE_CXX_FLAGS_RELEASE "") option( - UNITY_ENABLE_X_ORG_SUPPORT + ENABLE_X_SUPPORT "Enable X.org support in unity" ON ) @@ -30,20 +30,20 @@ option( ON ) -if(UNITY_ENABLE_X_ORG_SUPPORT) - add_definitions(-DUNITY_HAS_X_ORG_SUPPORT) +if (ENABLE_X_SUPPORT) add_definitions(-DUSE_X11) message("Unity is configured with support for X.org") else () message("Unity is configured with without X.org") add_definitions(-DNO_X11) -endif() +endif () if (BUILD_GLES) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNUX_OPENGLES_20 -DUSE_GLES") - set (UNITY_STANDALONE_LADD "-lunity-core-${UNITY_API_VERSION} -lm -lpthread -ldl") + add_definitions(-DNUX_OPENGLES_20) + add_definitions(-DUSE_GLES) + set (UNITY_STANDALONE_LADD "-lunity-core-${UNITY_API_VERSION} -lm -lpthread -ldl") else () - set (UNITY_STANDALONE_LADD "-lunity-core-${UNITY_API_VERSION} -lm -lpthread -ldl -lGL -lGLU") + set (UNITY_STANDALONE_LADD "-lunity-core-${UNITY_API_VERSION} -lm -lpthread -ldl -lGL -lGLU") endif () # @@ -155,7 +155,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MAINTAINER_CXXFLAGS}") # # Compiz Plugins # -if(UNITY_ENABLE_X_ORG_SUPPORT) +if (ENABLE_X_SUPPORT) set (UNITY_PLUGIN_DEPS "compiz>=0.9.8.0;nux-3.0>=3.0.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;gmodule-2.0;dbusmenu-glib-0.4;x11;libstartup-notification-1.0;gthread-2.0;indicator3-0.4>=0.4.90;atk;atk-bridge-2.0;unity-misc>=0.4.0;dbus-glib-1;gtk+-3.0>=3.1;sigc++-2.0;json-glib-1.0;libnotify;xfixes;unity-protocol-private>=5.95.1;libgeis;xrender>=0.9;zeitgeist-1.0>=0.3.18") else () set (UNITY_PLUGIN_DEPS "nux-3.0>=3.0.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;gmodule-2.0;dbusmenu-glib-0.4;libstartup-notification-1.0;gthread-2.0;indicator3-0.4>=0.4.90;atk;atk-bridge-2.0;unity-misc>=0.4.0;dbus-glib-1;gtk+-3.0>=3.1;sigc++-2.0;json-glib-1.0;libnotify;unity-protocol-private>=5.95.1;zeitgeist-1.0>=0.3.18") @@ -170,7 +170,7 @@ pkg_check_modules (CACHED_UNITY_PRIVATE_DEPS REQUIRED ${UNITY_PROTOCOL_PRIVATE_D add_subdirectory(unity-shared) add_subdirectory(dash) add_subdirectory(launcher) -if(UNITY_ENABLE_X_ORG_SUPPORT) +if (ENABLE_X_SUPPORT) add_subdirectory(hud) add_subdirectory(panel) add_subdirectory(plugins/unityshell) @@ -179,7 +179,7 @@ if(UNITY_ENABLE_X_ORG_SUPPORT) add_subdirectory(plugins/unity-mt-grab-handles) add_subdirectory(shortcuts) add_subdirectory(unity-standalone) -endif() +endif () # subdirs add_subdirectory(doc) diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index a4518bf7f..bc2817df6 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -75,13 +75,13 @@ set (LAUNCHER_SOURCES VolumeMonitorWrapper.cpp ) -if(UNITY_ENABLE_X_ORG_SUPPORT) +if (ENABLE_X_SUPPORT) set (LAUNCHER_SOURCES EdgeBarrierController.cpp PointerBarrier.cpp ${LAUNCHER_SOURCES} ) -endif() +endif () add_library (launcher-lib STATIC ${LAUNCHER_SOURCES}) add_dependencies (launcher-lib unity-core-${UNITY_API_VERSION} unity-shared) @@ -104,8 +104,8 @@ add_executable (launcher StandaloneLauncher.cpp) add_dependencies (launcher launcher-lib) target_link_libraries (launcher launcher-lib unity-shared unity-shared-standalone) -if(UNITY_ENABLE_X_ORG_SUPPORT) +if (ENABLE_X_SUPPORT) add_executable (switcher StandaloneSwitcher.cpp) add_dependencies (switcher switcher-lib launcher-lib) target_link_libraries (switcher switcher-lib launcher-lib unity-shared unity-shared-standalone) -endif() +endif () diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d9a79c93a..cc46e50be 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -149,7 +149,7 @@ if (GTEST_SRC_DIR AND ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp ) -if(UNITY_ENABLE_X_ORG_SUPPORT) +if (ENABLE_X_SUPPORT) set (GTEST_XLESS_SOURCES test_hud_private.cpp test_pointer_barrier.cpp @@ -157,7 +157,7 @@ if(UNITY_ENABLE_X_ORG_SUPPORT) test_shortcut_private.cpp ${LAUNCHER_SOURCES} ) -endif() +endif () add_executable(test-gtest-xless ${GTEST_XLESS_SOURCES}) @@ -185,7 +185,7 @@ endif() add_test(UnityGTestDBus test-gtest-dbus) add_dependencies(test-gtest-dbus unity-core-${UNITY_API_VERSION} test-gtest-service gtest) -if (UNITY_ENABLE_X_ORG_SUPPORT) +if (ENABLE_X_SUPPORT) # Tests that require X add_executable(test-gtest test_main.cpp @@ -239,12 +239,12 @@ if (UNITY_ENABLE_X_ORG_SUPPORT) target_link_libraries(test-gtest gtest gmock unity-shared ${LIBS} launcher-lib unity-shared-standalone shortcuts-lib previews-lib hud-lib switcher-lib dash-lib panel-lib) add_test(UnityGTest test-gtest) add_dependencies(test-gtest unity-core-${UNITY_API_VERSION} gtest gmock) -endif (UNITY_ENABLE_X_ORG_SUPPORT) +endif (ENABLE_X_SUPPORT) endif (GTEST_SRC_DIR AND GMOCK_LIB AND GMOCK_MAIN_LIB) -if(UNITY_ENABLE_X_ORG_SUPPORT) +if(ENABLE_X_SUPPORT) add_subdirectory (test-gestures) endif() @@ -254,10 +254,10 @@ endif() set (TEST_RESULT_DIR ${CMAKE_BINARY_DIR}/tests) set (TEST_RESULT_XML ${TEST_RESULT_DIR}/test-results_xml) set (TEST_RESULT_HTML ${TEST_RESULT_DIR}/test-results_html) -if (UNITY_ENABLE_X_ORG_SUPPORT) +if (ENABLE_X_SUPPORT) set (GTEST_TEST_COMMAND ./test-gtest) set (GTEST_TEST_COMMAND_GESTURES ./test-gestures/test-gestures) -endif (UNITY_ENABLE_X_ORG_SUPPORT) +endif (ENABLE_X_SUPPORT) set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless) set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --task ./test-gtest-service --task ./test-gtest-dbus) @@ -276,7 +276,7 @@ set (TEST_COMMAND_HEADLESS && echo "Warning, DBus test cases are disabled!!") if (GTEST_SRC_DIR) - if (UNITY_ENABLE_X_ORG_SUPPORT) + if (ENABLE_X_SUPPORT) add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-xless test-gtest-dbus test-gestures) add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus test-gestures) add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest test-gtest-xless) diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt index 576d89482..99d6bf05e 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -68,7 +68,7 @@ set (UNITY_SHARED_SOURCES XPathQueryPart.cpp ) -if(UNITY_ENABLE_X_ORG_SUPPORT) +if(ENABLE_X_SUPPORT) set (UNITY_SHARED_SOURCES XKeyboardUtil.cpp XWindowManager.cpp @@ -89,7 +89,7 @@ add_dependencies (unity-shared unity-core-${UNITY_API_VERSION}) # We also need to build compiz specific parts and standalone variants of those parts # -if(UNITY_ENABLE_X_ORG_SUPPORT) +if (ENABLE_X_SUPPORT) # compiz set (UNITY_SHARED_COMPIZ_SOURCES PluginAdapter.cpp -- cgit v1.2.3 From 6e830c475b1a4603d7498b728e1a6b8589ad10d3 Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Wed, 24 Oct 2012 10:21:17 +0200 Subject: Use a more sane X11 macro. (bzr r2865.2.13) --- dash/ResultViewGrid.cpp | 4 ++-- launcher/ApplicationLauncherIcon.cpp | 2 +- launcher/Launcher.cpp | 26 +++++++++++++------------- launcher/Launcher.h | 6 +++--- launcher/LauncherController.cpp | 8 ++++---- launcher/LauncherControllerPrivate.h | 4 ++-- launcher/TrashLauncherIcon.cpp | 2 +- tests/test_launcher_controller.cpp | 2 +- unity-shared/ResizingBaseWindow.h | 2 +- unity-shared/WindowManager.h | 2 +- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/dash/ResultViewGrid.cpp b/dash/ResultViewGrid.cpp index c888f2db8..f1ca2d0e4 100644 --- a/dash/ResultViewGrid.cpp +++ b/dash/ResultViewGrid.cpp @@ -780,7 +780,7 @@ std::tuple ResultViewGrid::GetResultPosition(const unsigned int& index */ bool ResultViewGrid::DndSourceDragBegin() { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 unsigned num_results = GetNumResults(); unsigned drag_index = GetIndexAtPosition(last_mouse_down_x_, last_mouse_down_y_); @@ -932,7 +932,7 @@ const char* ResultViewGrid::DndSourceGetDataForType(const char* type, int* size, void ResultViewGrid::DndSourceDragFinished(nux::DndAction result) { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 UnReference(); last_mouse_down_x_ = -1; last_mouse_down_y_ = -1; diff --git a/launcher/ApplicationLauncherIcon.cpp b/launcher/ApplicationLauncherIcon.cpp index b7f196e1b..d8a30aa21 100644 --- a/launcher/ApplicationLauncherIcon.cpp +++ b/launcher/ApplicationLauncherIcon.cpp @@ -1301,7 +1301,7 @@ bool ApplicationLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data) nux::DndAction ApplicationLauncherIcon::OnQueryAcceptDrop(DndData const& dnd_data) { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 return ValidateUrisForLaunch(dnd_data).empty() ? nux::DNDACTION_NONE : nux::DNDACTION_COPY; #else return nux::DNDACTION_NONE; diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp index e5e5675d9..8780fb660 100644 --- a/launcher/Launcher.cpp +++ b/launcher/Launcher.cpp @@ -106,7 +106,7 @@ Launcher::Launcher(nux::BaseWindow* parent, nux::ObjectPtr const& collection_window, NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 , display(nux::GetGraphicsDisplay()->GetX11Display()) #else , display(0) @@ -191,7 +191,7 @@ Launcher::Launcher(nux::BaseWindow* parent, wm.terminate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &Launcher::EnsureAnimation)); -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 display.changed.connect(sigc::mem_fun(this, &Launcher::OnDisplayChanged)); #endif @@ -1356,7 +1356,7 @@ int Launcher::GetMouseY() const bool Launcher::OnUpdateDragManagerTimeout() { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 if (display() == 0) return false; @@ -1398,7 +1398,7 @@ bool Launcher::OnUpdateDragManagerTimeout() void Launcher::DndTimeoutSetup() { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 if (sources_.GetSource(DND_CHECK_TIMEOUT)) return; @@ -2230,7 +2230,7 @@ void Launcher::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_ if (GetActionState() == ACTION_NONE) { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 if (nux::Abs(_dnd_delta_y) >= nux::Abs(_dnd_delta_x)) { _launcher_drag_delta += _dnd_delta_y; @@ -2305,7 +2305,7 @@ void Launcher::RecvMouseWheel(int x, int y, int wheel_delta, unsigned long butto EnsureAnimation(); } -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 bool Launcher::HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event) { @@ -2573,7 +2573,7 @@ bool Launcher::DndIsSpecialRequest(std::string const& uri) const void Launcher::OnDNDDataCollected(const std::list& mimes) { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 _dnd_data.Reset(); const std::string uri_list = "text/uri-list"; @@ -2620,7 +2620,7 @@ void Launcher::OnDNDDataCollected(const std::list& mimes) void Launcher::ProcessDndEnter() { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 SetStateMouseOverLauncher(true); _dnd_data.Reset(); @@ -2634,7 +2634,7 @@ void Launcher::ProcessDndEnter() void Launcher::DndReset() { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 _dnd_data.Reset(); bool is_overlay_open = IsOverlayOpen(); @@ -2662,7 +2662,7 @@ void Launcher::DndReset() void Launcher::DndHoveredIconReset() { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 _drag_edge_touching = false; SetActionState(ACTION_NONE); @@ -2682,7 +2682,7 @@ void Launcher::DndHoveredIconReset() void Launcher::ProcessDndLeave() { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 SetStateMouseOverLauncher(false); DndHoveredIconReset(); @@ -2691,7 +2691,7 @@ void Launcher::ProcessDndLeave() void Launcher::ProcessDndMove(int x, int y, std::list mimes) { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 if (!_data_checked) { const std::string uri_list = "text/uri-list"; @@ -2823,7 +2823,7 @@ void Launcher::ProcessDndMove(int x, int y, std::list mimes) void Launcher::ProcessDndDrop(int x, int y) { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 if (_steal_drag) { for (auto const& uri : _dnd_data.Uris()) diff --git a/launcher/Launcher.h b/launcher/Launcher.h index de5138292..853b6d013 100644 --- a/launcher/Launcher.h +++ b/launcher/Launcher.h @@ -43,7 +43,7 @@ #include "unity-shared/UBusWrapper.h" #include "SoftwareCenterLauncherIcon.h" -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 # include "PointerBarrier.h" # include "EdgeBarrierController.h" #endif @@ -57,7 +57,7 @@ extern const char window_title[]; class AbstractLauncherIcon; class Launcher : public unity::debug::Introspectable, -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 // TODO: abstract this into a more generic class. public ui::EdgeBarrierSubscriber, #endif @@ -202,7 +202,7 @@ private: void OnDragFinish(const nux::GestureEvent &event); #endif -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 bool HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event); #endif diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp index 7dcd6763e..fecfdc23f 100644 --- a/launcher/LauncherController.cpp +++ b/launcher/LauncherController.cpp @@ -115,7 +115,7 @@ Controller::Impl::Impl(Controller* parent) , gdbus_connection_(nullptr) , reg_id_(0) { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 edge_barriers_.options = parent_->options(); #endif @@ -201,7 +201,7 @@ void Controller::Impl::EnsureLaunchers(int primary, std::vector c int monitor = (num_launchers == 1) ? primary : i; -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 if (launchers[i]->monitor() != monitor) { edge_barriers_.Unsubscribe(launchers[i].GetPointer(), launchers[i]->monitor); @@ -210,7 +210,7 @@ void Controller::Impl::EnsureLaunchers(int primary, std::vector c launchers[i]->monitor(monitor); launchers[i]->Resize(); -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 edge_barriers_.Subscribe(launchers[i].GetPointer(), launchers[i]->monitor); #endif } @@ -222,7 +222,7 @@ void Controller::Impl::EnsureLaunchers(int primary, std::vector c { parent_->RemoveChild(launcher.GetPointer()); launcher->GetParent()->UnReference(); -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 edge_barriers_.Unsubscribe(launcher.GetPointer(), launcher->monitor); #endif } diff --git a/launcher/LauncherControllerPrivate.h b/launcher/LauncherControllerPrivate.h index 253bfbb16..210cedeb0 100644 --- a/launcher/LauncherControllerPrivate.h +++ b/launcher/LauncherControllerPrivate.h @@ -28,7 +28,7 @@ #include "AbstractLauncherIcon.h" #include "DeviceLauncherSection.h" #include "DevicesSettingsImp.h" -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 #include "EdgeBarrierController.h" #endif #include "LauncherController.h" @@ -129,7 +129,7 @@ public: AbstractLauncherIcon::Ptr expo_icon_; AbstractLauncherIcon::Ptr desktop_icon_; -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 ui::EdgeBarrierController edge_barriers_; #endif diff --git a/launcher/TrashLauncherIcon.cpp b/launcher/TrashLauncherIcon.cpp index ccc03385b..44f49de53 100644 --- a/launcher/TrashLauncherIcon.cpp +++ b/launcher/TrashLauncherIcon.cpp @@ -139,7 +139,7 @@ void TrashLauncherIcon::UpdateTrashIconCb(GObject* source, nux::DndAction TrashLauncherIcon::OnQueryAcceptDrop(DndData const& dnd_data) { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 return nux::DNDACTION_MOVE; #else return nux::DNDACTION_NONE; diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp index 22d197b2d..061f74a4a 100644 --- a/tests/test_launcher_controller.cpp +++ b/tests/test_launcher_controller.cpp @@ -380,7 +380,7 @@ TEST_F(TestLauncherController, SingleMonitorSwitchToMultimonitor) EXPECT_EQ(lc.launchers().size(), max_num_monitors); } -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 TEST_F(TestLauncherController, MultiMonitorEdgeBarrierSubscriptions) { diff --git a/unity-shared/ResizingBaseWindow.h b/unity-shared/ResizingBaseWindow.h index c7f50cbb2..d461fcb03 100644 --- a/unity-shared/ResizingBaseWindow.h +++ b/unity-shared/ResizingBaseWindow.h @@ -35,7 +35,7 @@ public: void UpdateInputWindowGeometry() { -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 if (m_input_window && m_input_window_enabled) m_input_window->SetGeometry(geo_func_(GetGeometry())); #endif diff --git a/unity-shared/WindowManager.h b/unity-shared/WindowManager.h index b9a7c7e42..a1f420003 100644 --- a/unity-shared/WindowManager.h +++ b/unity-shared/WindowManager.h @@ -28,7 +28,7 @@ #include #include -#ifdef UNITY_HAS_X_ORG_SUPPORT +#ifdef USE_X11 #include #else typedef unsigned long Window; -- cgit v1.2.3 From 8ce8b55774ffa4f7d12c579f024c7126db5c9532 Mon Sep 17 00:00:00 2001 From: Nick Dedekind Date: Fri, 26 Oct 2012 12:40:39 +0200 Subject: Inverted blink/pulse on application start for immediate feedback. Fixes LP: #893140 (bzr r2866.6.1) --- launcher/Launcher.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp index cdf6a5281..9186b5b09 100644 --- a/launcher/Launcher.cpp +++ b/launcher/Launcher.cpp @@ -642,15 +642,27 @@ float Launcher::IconUrgentWiggleValue(AbstractLauncherIcon::Ptr const& icon, str float Launcher::IconStartingBlinkValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const { + if (icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)) + return 1.0f; + + if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::STARTING)) + return 1.0f; + struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING); int starting_ms = unity::TimeUtil::TimeDelta(¤t, &starting_time); double starting_progress = (double) CLAMP((float) starting_ms / (float)(ANIM_DURATION_LONG * STARTING_BLINK_LAMBDA), 0.0f, 1.0f); double val = IsBackLightModeToggles() ? 3.0f : 4.0f; - return 0.5f + (float)(std::cos(M_PI * val * starting_progress)) * 0.5f; + return 1.0f-(0.5f + (float)(std::cos(M_PI * val * starting_progress)) * 0.5f); } float Launcher::IconStartingPulseValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const { + if (icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)) + return 1.0f; + + if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::STARTING)) + return 1.0f; + struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING); int starting_ms = unity::TimeUtil::TimeDelta(¤t, &starting_time); double starting_progress = (double) CLAMP((float) starting_ms / (float)(ANIM_DURATION_LONG * MAX_STARTING_BLINKS * STARTING_BLINK_LAMBDA * 2), 0.0f, 1.0f); @@ -661,7 +673,7 @@ float Launcher::IconStartingPulseValue(AbstractLauncherIcon::Ptr const& icon, st icon->ResetQuirkTime(AbstractLauncherIcon::Quirk::STARTING); } - return 0.5f + (float)(std::cos(M_PI * (float)(MAX_STARTING_BLINKS * 2) * starting_progress)) * 0.5f; + return 1.0f-(0.5f + (float)(std::cos(M_PI * (float)(MAX_STARTING_BLINKS * 2) * starting_progress)) * 0.5f); } float Launcher::IconBackgroundIntensity(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const -- cgit v1.2.3 From 33ffca7f6ab1bb4335f1307dfe7e2c678a9a4eb4 Mon Sep 17 00:00:00 2001 From: Michal Hruby Date: Fri, 26 Oct 2012 12:41:28 +0200 Subject: Refactor DBusProxy and the Search part of lenses (bzr r2866.7.1) --- UnityCore/GLibDBusProxy.cpp | 146 +++++++++++++++++++++++++++++------- UnityCore/GLibDBusProxy.h | 9 +++ UnityCore/HomeLens.cpp | 38 +++++----- UnityCore/HomeLens.h | 7 +- UnityCore/Lens.cpp | 179 +++++++++++++++++++------------------------- UnityCore/Lens.h | 9 ++- dash/DashView.cpp | 36 +++++---- dash/DashView.h | 6 +- dash/LensView.cpp | 6 +- dash/LensView.h | 2 +- tests/test_gdbus_proxy.cpp | 146 ++++++++++++++++++------------------ tests/test_home_lens.cpp | 73 ++++++------------ tests/test_lens.cpp | 6 +- 13 files changed, 355 insertions(+), 308 deletions(-) diff --git a/UnityCore/GLibDBusProxy.cpp b/UnityCore/GLibDBusProxy.cpp index 273bb42a3..5c88dee4f 100644 --- a/UnityCore/GLibDBusProxy.cpp +++ b/UnityCore/GLibDBusProxy.cpp @@ -59,10 +59,19 @@ public: void StartReconnectionTimeout(unsigned timeout); void Connect(); - void Call(string const& method_name, + void WaitForProxy(GCancellable* cancellable, + int timeout_msec, + std::function callback); + void CallNoError(string const& method_name, + GVariant* parameters, + ReplyCallback callback, + GCancellable* cancellable, + GDBusCallFlags flags, + int timeout_msec); + void Call(std::string const& method_name, GVariant* parameters, - ReplyCallback callback, - GCancellable* cancellable, + CallFinishedCallback callback, + GCancellable *cancellable, GDBusCallFlags flags, int timeout_msec); @@ -78,7 +87,7 @@ public: struct CallData { - DBusProxy::ReplyCallback callback; + DBusProxy::CallFinishedCallback callback; std::string method_name; }; @@ -97,6 +106,7 @@ public: glib::Signal g_signal_connection_; glib::Signal name_owner_signal_; glib::Source::UniquePtr reconnect_timeout_; + sigc::signal proxy_acquired; SignalHandlers handlers_; }; @@ -117,6 +127,7 @@ DBusProxy::Impl::Impl(DBusProxy* owner, , connected_(false) , reconnection_attempts_(0) { + // FIXME: get rid of this once glib doesn't deadlock in class initiation StartReconnectionTimeout(1); } @@ -206,6 +217,8 @@ void DBusProxy::Impl::OnProxyConnectCallback(GObject* source, self->connected_ = true; self->owner_->connected.emit(); } + + self->proxy_acquired.emit(); } void DBusProxy::Impl::OnProxyNameOwnerChanged(GDBusProxy* proxy, GParamSpec* param) @@ -245,33 +258,102 @@ void DBusProxy::Impl::OnProxySignal(GDBusProxy* proxy, callback(parameters); } +void DBusProxy::Impl::WaitForProxy(GCancellable* cancellable, + int timeout_msec, + std::function callback) +{ + if (!proxy_) + { + auto con = std::make_shared(); + auto canc = glib::Object(cancellable, glib::AddRef()); + + // add a timeout + auto timeout = glib::Source::Ptr(new glib::Timeout(timeout_msec < 0 ? 30000 : timeout_msec, [con, canc, callback] () + { + if (!g_cancellable_is_cancelled(canc)) + { + glib::Error err; + GError** real_err = &err; + *real_err = g_error_new_literal(G_DBUS_ERROR, G_DBUS_ERROR_TIMED_OUT, + "Timed out waiting for proxy"); + callback(err); + } + con->disconnect(); + return false; + })); + // wait for the signal + *con = proxy_acquired.connect([con, canc, timeout, callback] () + { + if (!g_cancellable_is_cancelled(canc)) callback(glib::Error()); + timeout->Remove(); + con->disconnect(); + }); + } + else + { + callback(glib::Error()); + } +} + +void DBusProxy::Impl::CallNoError(string const& method_name, + GVariant* parameters, + ReplyCallback callback, + GCancellable* cancellable, + GDBusCallFlags flags, + int timeout_msec) +{ + if (callback) + { + auto cb = [callback] (GVariant* result, Error const& err) + { + if (!err) callback(result); + }; + + Call(method_name, parameters, cb, cancellable, flags, timeout_msec); + } + else + { + Call(method_name, parameters, nullptr, cancellable, flags, timeout_msec); + } +} + void DBusProxy::Impl::Call(string const& method_name, GVariant* parameters, - ReplyCallback callback, + CallFinishedCallback callback, GCancellable* cancellable, GDBusCallFlags flags, int timeout_msec) { - if (proxy_) + if (!proxy_) { - CallData* data = new CallData(); - data->callback = callback; - data->method_name = method_name; - - g_dbus_proxy_call(proxy_, - method_name.c_str(), - parameters, - flags, - timeout_msec, - cancellable != NULL ? cancellable : cancellable_, - DBusProxy::Impl::OnCallCallback, - data); - } - else - { - LOG_WARNING(logger) << "Cannot call method " << method_name - << " proxy " << object_path_ << " does not exist"; + glib::Variant sinked_parameters(parameters); + glib::Objectcanc(cancellable, glib::AddRef()); + WaitForProxy(canc, timeout_msec, [this, method_name, sinked_parameters, callback, canc, flags, timeout_msec] (glib::Error const& err) + { + if (err) + { + callback(glib::Variant(), err); + LOG_WARNING(logger) << "Cannot call method " << method_name + << ": " << err; + } + else + Call(method_name, sinked_parameters, callback, canc, flags, timeout_msec); + }); + return; } + + CallData* data = new CallData(); + data->callback = callback; + data->method_name = method_name; + + g_dbus_proxy_call(proxy_, + method_name.c_str(), + parameters, + flags, + timeout_msec, + cancellable != NULL ? cancellable : cancellable_, + DBusProxy::Impl::OnCallCallback, + data); } void DBusProxy::Impl::OnCallCallback(GObject* source, GAsyncResult* res, gpointer call_data) @@ -284,7 +366,8 @@ void DBusProxy::Impl::OnCallCallback(GObject* source, GAsyncResult* res, gpointe { if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - // silently ignore + // silently ignore, don't even invoke callback, FIXME: really? + return; } else { @@ -293,12 +376,10 @@ void DBusProxy::Impl::OnCallCallback(GObject* source, GAsyncResult* res, gpointe << g_dbus_proxy_get_object_path(G_DBUS_PROXY(source)) << "\" failed: " << error; } - - return; } if (data->callback) - data->callback(result); + data->callback(result, error); } void DBusProxy::Impl::Connect(std::string const& signal_name, ReplyCallback callback) @@ -324,6 +405,17 @@ void DBusProxy::Call(string const& method_name, GCancellable* cancellable, GDBusCallFlags flags, int timeout_msec) +{ + pimpl->CallNoError(method_name, parameters, callback, cancellable, flags, + timeout_msec); +} + +void DBusProxy::CallBegin(std::string const& method_name, + GVariant* parameters, + CallFinishedCallback callback, + GCancellable *cancellable, + GDBusCallFlags flags, + int timeout_msec) { pimpl->Call(method_name, parameters, callback, cancellable, flags, timeout_msec); diff --git a/UnityCore/GLibDBusProxy.h b/UnityCore/GLibDBusProxy.h index 06cce6cc6..afc0c7684 100644 --- a/UnityCore/GLibDBusProxy.h +++ b/UnityCore/GLibDBusProxy.h @@ -26,6 +26,8 @@ #include #include +#include "GLibWrapper.h" + namespace unity { namespace glib @@ -38,6 +40,7 @@ class DBusProxy : public sigc::trackable, boost::noncopyable public: typedef std::shared_ptr Ptr; typedef std::function ReplyCallback; + typedef std::function CallFinishedCallback; DBusProxy(std::string const& name, std::string const& object_path, @@ -52,6 +55,12 @@ public: GCancellable *cancellable = nullptr, GDBusCallFlags flags = G_DBUS_CALL_FLAGS_NONE, int timeout_msec = -1); + void CallBegin(std::string const& method_name, + GVariant* parameters, + CallFinishedCallback callback, + GCancellable *cancellable = nullptr, + GDBusCallFlags flags = G_DBUS_CALL_FLAGS_NONE, + int timeout_msec = -1); void Connect(std::string const& signal_name, ReplyCallback callback); bool IsConnected(); diff --git a/UnityCore/HomeLens.cpp b/UnityCore/HomeLens.cpp index 5bfaf2af9..57f5d6535 100644 --- a/UnityCore/HomeLens.cpp +++ b/UnityCore/HomeLens.cpp @@ -865,19 +865,6 @@ void HomeLens::Impl::OnLensAdded (Lens::Ptr& lens) lenses_.push_back (lens); owner_->lens_added.emit(lens); - /* When we dispatch a search we inc the search count and when we finish - * one we decrease it. When we reach 0 we'll emit search_finished. */ - lens->global_search_finished.connect([this, lens] (Hints const& hints) { - running_searches_--; - - LensSearchFinished(lens); - if (running_searches_ <= 0) - { - owner_->search_finished.emit(Hints()); - LOG_INFO(logger) << "Search finished"; - } - }); - nux::ROProperty>& results_prop = lens->global_results()->model; nux::ROProperty>& categories_prop = lens->categories()->model; nux::ROProperty>& filters_prop = lens->filters()->model; @@ -1000,6 +987,8 @@ void HomeLens::Impl::LensSearchFinished(Lens::Ptr const& lens) cached_categories_order_ = order_vector; owner_->categories_reordered(); } + + owner_->lens_search_finished.emit(lens); } bool HomeLens::Impl::ResultsContainVisibleMatch(unsigned category) @@ -1171,30 +1160,41 @@ Lens::Ptr HomeLens::GetLensAtIndex(std::size_t index) const return Lens::Ptr(); } -void HomeLens::GlobalSearch(std::string const& search_string) +void HomeLens::GlobalSearch(std::string const& search_string, SearchFinishedCallback cb) { LOG_WARN(logger) << "Global search not enabled for HomeLens class." << " Ignoring query '" << search_string << "'"; } -void HomeLens::Search(std::string const& search_string) +void HomeLens::Search(std::string const& search_string, SearchFinishedCallback cb) { LOG_DEBUG(logger) << "Search '" << search_string << "'"; - /* Reset running search counter */ - pimpl->running_searches_ = 0; pimpl->last_search_string_ = search_string; pimpl->apps_lens_contains_visible_match = false; + auto running_searches = std::make_shared(); for (auto lens: pimpl->lenses_) { if (lens->search_in_global()) { + (*running_searches.get())++; + auto closure = [this, lens, running_searches, cb] (Hints const&, glib::Error const&) + { + int remaining_searches = --(*running_searches.get()); + pimpl->LensSearchFinished(lens); + + if (remaining_searches <= 0) + { + cb(Hints(), glib::Error()); + LOG_INFO(logger) << "Global search finished"; + } + }; + LOG_INFO(logger) << " - Global search on '" << lens->id() << "' for '" << search_string << "'"; lens->view_type = ViewType::HOME_VIEW; - lens->GlobalSearch(search_string); - pimpl->running_searches_++; + lens->GlobalSearch(search_string, closure); } } } diff --git a/UnityCore/HomeLens.h b/UnityCore/HomeLens.h index 0facd0fa1..48e0510d6 100644 --- a/UnityCore/HomeLens.h +++ b/UnityCore/HomeLens.h @@ -69,14 +69,17 @@ public: Lens::Ptr GetLens(std::string const& lens_id) const; Lens::Ptr GetLensAtIndex(std::size_t index) const; - void GlobalSearch(std::string const& search_string); - void Search(std::string const& search_string); + void GlobalSearch(std::string const& search_string, SearchFinishedCallback cb); + void Search(std::string const& search_string, SearchFinishedCallback cb); void Activate(std::string const& uri); void Preview(std::string const& uri); std::vector GetCategoriesOrder(); glib::Object GetFilterModelForCategory(unsigned category); + // emitted when global search for one lens finishes + sigc::signal lens_search_finished; + private: class Impl; class ModelMerger; diff --git a/UnityCore/Lens.cpp b/UnityCore/Lens.cpp index a4e0c5b0d..a7dd1cca8 100644 --- a/UnityCore/Lens.cpp +++ b/UnityCore/Lens.cpp @@ -62,15 +62,13 @@ public: void OnProxyConnectionChanged(); void OnProxyDisconnected(); - void ResultsModelUpdated(unsigned long long begin_seqnum, - unsigned long long end_seqnum); - void GlobalResultsModelUpdated(unsigned long long begin_seqnum, - unsigned long long end_seqnum); - unsigned long long ExtractModelSeqnum(GVariant *parameters); + void WaitForModelUpdate(glib::Variant const& response_variant, + Results::Ptr model, + std::function callback); + void SearchCallFinished(GVariant* response, glib::Error const& error, + Results::Ptr model, SearchFinishedCallback cb); - void OnSearchFinished(GVariant* parameters); - void OnGlobalSearchFinished(GVariant* parameters); void OnChanged(GVariant* parameters); void UpdateProperties(bool search_in_global, bool visible, @@ -83,8 +81,8 @@ public: GVariantIter* hints_iter); void OnViewTypeChanged(ViewType view_type); - void GlobalSearch(std::string const& search_string); - void Search(std::string const& search_string); + void GlobalSearch(std::string const& search_string, SearchFinishedCallback const& cb); + void Search(std::string const& search_string, SearchFinishedCallback const& cb); void Activate(std::string const& uri); void ActivationReply(GVariant* parameters); void Preview(std::string const& uri); @@ -189,12 +187,6 @@ Lens::Impl::Impl(Lens* owner, proxy_->Connect("Changed", sigc::mem_fun(this, &Lens::Impl::OnChanged)); } - /* Technically these signals will only be fired by remote models, but we - * connect them no matter the ModelType. Dee may grow support in the future. - */ - results_->end_transaction.connect(sigc::mem_fun(this, &Lens::Impl::ResultsModelUpdated)); - global_results_->end_transaction.connect(sigc::mem_fun(this, &Lens::Impl::GlobalResultsModelUpdated)); - owner_->id.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::id)); owner_->dbus_name.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::dbus_name)); owner_->dbus_path.SetGetterFunction(sigc::mem_fun(this, &Lens::Impl::dbus_path)); @@ -248,35 +240,27 @@ void Lens::Impl::OnProxyDisconnected() owner_->connected.EmitChanged(connected_); } -void Lens::Impl::ResultsModelUpdated(unsigned long long begin_seqnum, - unsigned long long end_seqnum) +void Lens::Impl::WaitForModelUpdate(glib::Variant const& response_variant, + Results::Ptr model, + std::function callback) { - if (results_variant_ && end_seqnum >= ExtractModelSeqnum (results_variant_)) + // a bit of pointer craziness because using copy constructors screws us up + auto con = std::make_shared(); + *con = model->end_transaction.connect([this, response_variant, model, callback, con] + (unsigned long long begin_seqnum, + unsigned long long end_seqnum) { - Hints hints; - - results_variant_.ASVToHints(hints); - - owner_->search_finished.emit(hints); - - results_variant_ = NULL; - } -} - -void Lens::Impl::GlobalResultsModelUpdated(unsigned long long begin_seqnum, - unsigned long long end_seqnum) -{ - if (global_results_variant_ && - end_seqnum >= ExtractModelSeqnum (global_results_variant_)) - { - Hints hints; - - global_results_variant_.ASVToHints(hints); + if (end_seqnum >= ExtractModelSeqnum(response_variant)) + { + Hints hints; + response_variant.ASVToHints(hints); + callback(hints); - owner_->global_search_finished.emit(hints); + con->disconnect(); + } + }); - global_results_variant_ = NULL; - } + // FIXME: also add a timer and fail the call after ~30 seconds? } unsigned long long Lens::Impl::ExtractModelSeqnum(GVariant *parameters) @@ -299,48 +283,6 @@ unsigned long long Lens::Impl::ExtractModelSeqnum(GVariant *parameters) return seqnum; } -void Lens::Impl::OnSearchFinished(GVariant* parameters) -{ - Hints hints; - unsigned long long reply_seqnum; - - reply_seqnum = ExtractModelSeqnum (parameters); - if (results_->seqnum < reply_seqnum) - { - // wait for the end-transaction signal - results_variant_ = parameters; - - // ResultsModelUpdated will emit OnSearchFinished - return; - } - - glib::Variant dict (parameters); - dict.ASVToHints(hints); - - owner_->search_finished.emit(hints); -} - -void Lens::Impl::OnGlobalSearchFinished(GVariant* parameters) -{ - Hints hints; - unsigned long long reply_seqnum; - - reply_seqnum = ExtractModelSeqnum (parameters); - if (global_results_->seqnum < reply_seqnum) - { - // wait for the end-transaction signal - global_results_variant_ = parameters; - - // GlobalResultsModelUpdated will emit OnGlobalSearchFinished - return; - } - - glib::Variant dict (parameters); - dict.ASVToHints(hints); - - owner_->global_search_finished.emit(hints); -} - void Lens::Impl::OnChanged(GVariant* parameters) { glib::String dbus_path; @@ -480,7 +422,35 @@ void Lens::Impl::OnViewTypeChanged(ViewType view_type) proxy_->Call("SetViewType", g_variant_new("(u)", view_type)); } -void Lens::Impl::GlobalSearch(std::string const& search_string) +void Lens::Impl::SearchCallFinished(GVariant* response, glib::Error const& error, Results::Ptr model, SearchFinishedCallback cb) +{ + if (!error) + { + auto reply_seqnum = ExtractModelSeqnum(response); + if (model->seqnum < reply_seqnum) + { + WaitForModelUpdate(response, model, [this, cb] (Hints const& hints) + { + if (cb) cb(hints, glib::Error()); + }); + } + else + { + Hints hints; + glib::Variant dict(response); + dict.ASVToHints(hints); + if (cb) cb(hints, glib::Error()); + } + } + else + { + // call failed + if (cb) cb(Hints(), error); + } +} + +void Lens::Impl::GlobalSearch(std::string const& search_string, + SearchFinishedCallback const& cb) { LOG_DEBUG(logger) << "Global Searching '" << id_ << "' for '" << search_string << "'"; @@ -491,20 +461,23 @@ void Lens::Impl::GlobalSearch(std::string const& search_string) g_cancellable_cancel (global_search_cancellable_); global_search_cancellable_ = g_cancellable_new (); - global_results_variant_ = NULL; last_global_search_string_ = search_string; - proxy_->Call("GlobalSearch", - g_variant_new("(sa{sv})", - search_string.c_str(), - &b), - sigc::mem_fun(this, &Lens::Impl::OnGlobalSearchFinished), - global_search_cancellable_); + proxy_->CallBegin("GlobalSearch", + g_variant_new("(sa{sv})", + search_string.c_str(), + &b), + [this, cb] (GVariant* response, glib::Error const& error) + { + SearchCallFinished(response, error, global_results_, cb); + }, + global_search_cancellable_); g_variant_builder_clear(&b); } -void Lens::Impl::Search(std::string const& search_string) +void Lens::Impl::Search(std::string const& search_string, + SearchFinishedCallback const& cb) { LOG_DEBUG(logger) << "Searching '" << id_ << "' for '" << search_string << "'"; @@ -520,15 +493,17 @@ void Lens::Impl::Search(std::string const& search_string) if (search_cancellable_) g_cancellable_cancel (search_cancellable_); search_cancellable_ = g_cancellable_new (); - results_variant_ = NULL; last_search_string_ = search_string; - proxy_->Call("Search", - g_variant_new("(sa{sv})", - search_string.c_str(), - &b), - sigc::mem_fun(this, &Lens::Impl::OnSearchFinished), - search_cancellable_); + proxy_->CallBegin("Search", + g_variant_new("(sa{sv})", + search_string.c_str(), + &b), + [this, cb] (GVariant* response, glib::Error const& error) + { + SearchCallFinished(response, error, results_, cb); + }, + search_cancellable_); g_variant_builder_clear(&b); } @@ -884,14 +859,14 @@ Lens::~Lens() delete pimpl; } -void Lens::GlobalSearch(std::string const& search_string) +void Lens::GlobalSearch(std::string const& search_string, SearchFinishedCallback cb) { - pimpl->GlobalSearch(search_string); + pimpl->GlobalSearch(search_string, cb); } -void Lens::Search(std::string const& search_string) +void Lens::Search(std::string const& search_string, SearchFinishedCallback cb) { - pimpl->Search(search_string); + pimpl->Search(search_string, cb); } void Lens::Activate(std::string const& uri) diff --git a/UnityCore/Lens.h b/UnityCore/Lens.h index 08a448107..c777020d8 100644 --- a/UnityCore/Lens.h +++ b/UnityCore/Lens.h @@ -57,6 +57,7 @@ class Lens : public sigc::trackable, boost::noncopyable public: typedef std::shared_ptr Ptr; typedef std::map Hints; + typedef std::function SearchFinishedCallback; Lens(std::string const& id, std::string const& dbus_name, @@ -81,8 +82,8 @@ public: virtual ~Lens(); - virtual void GlobalSearch(std::string const& search_string); - virtual void Search(std::string const& search_string); + virtual void GlobalSearch(std::string const& search_string, SearchFinishedCallback cb = nullptr); + virtual void Search(std::string const& search_string, SearchFinishedCallback cb = nullptr); virtual void Activate(std::string const& uri); virtual void Preview(std::string const& uri); virtual void ActivatePreviewAction(std::string const& action_id, @@ -125,8 +126,8 @@ public: /* Emitted when any of the models' swarm name changes, but collates the name * changes into a single signal emission (when all are changed) */ sigc::signal models_changed; - sigc::signal search_finished; - sigc::signal global_search_finished; + //sigc::signal search_finished; + //sigc::signal global_search_finished; sigc::signal activated; sigc::signal preview_ready; diff --git a/dash/DashView.cpp b/dash/DashView.cpp index 330f4cfa7..251bd66d4 100644 --- a/dash/DashView.cpp +++ b/dash/DashView.cpp @@ -108,9 +108,14 @@ DashView::DashView() Relayout(); home_lens_->AddLenses(lenses_); - home_lens_->search_finished.connect(sigc::mem_fun(this, &DashView::OnGlobalSearchFinished)); lens_bar_->Activate("home.lens"); + // we will special case when applications lens finishes global search + // because we want to be able to launch applications immediately + // without waiting for the search finished signal which will + // be delayed by all the lenses we're searching + home_lens_->lens_search_finished.connect(sigc::mem_fun(this, &DashView::OnAppsGlobalSearchFinished)); + // We are interested in the color of the desktop background. ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, sigc::mem_fun(this, &DashView::OnBGColorChanged)); @@ -894,6 +899,7 @@ void DashView::OnSearchChanged(std::string const& search_string) { search_in_progress_ = true; // it isn't guaranteed that we get a SearchFinished signal, so we need + // FIXME: it is now actually!! // to make sure this isn't set even though we aren't doing any search // 250ms for the Search method call, rest for the actual search searching_timeout_.reset(new glib::Timeout(500, [&] () { @@ -915,7 +921,8 @@ void DashView::OnLiveSearchReached(std::string const& search_string) LOG_DEBUG(logger) << "Live search reached: " << search_string; if (active_lens_view_) { - active_lens_view_->PerformSearch(search_string); + active_lens_view_->PerformSearch(search_string, + sigc::mem_fun(this, &DashView::OnSearchFinished)); } } @@ -933,7 +940,6 @@ void DashView::OnLensAdded(Lens::Ptr& lens) lens_views_[lens->id] = view; lens->activated.connect(sigc::mem_fun(this, &DashView::OnUriActivatedReply)); - lens->search_finished.connect(sigc::mem_fun(this, &DashView::OnSearchFinished)); lens->connected.changed.connect([&] (bool value) { std::string const& search_string = search_bar_->search_string; @@ -941,7 +947,8 @@ void DashView::OnLensAdded(Lens::Ptr& lens) && !search_string.empty()) { // force a (global!) search with the correct string - lens->GlobalSearch(search_bar_->search_string); + lens->GlobalSearch(search_bar_->search_string, + sigc::mem_fun(this, &DashView::OnSearchFinished)); } }); @@ -951,16 +958,6 @@ void DashView::OnLensAdded(Lens::Ptr& lens) LOG_DEBUG(logger) << "Got preview for: " << uri; preview_state_machine_.ActivatePreview(model); // this does not immediately display a preview - we now wait. }); - - // global search done is handled by the home lens, no need to connect to it - // BUT, we will special case global search finished coming from - // the applications lens, because we want to be able to launch applications - // immediately without waiting for the search finished signal which will - // be delayed by all the lenses we're searching - if (id == "applications.lens") - { - lens->global_search_finished.connect(sigc::mem_fun(this, &DashView::OnAppsGlobalSearchFinished)); - } } void DashView::OnLensBarActivated(std::string const& id) @@ -1007,12 +1004,13 @@ void DashView::OnLensBarActivated(std::string const& id) QueueDraw(); } -void DashView::OnSearchFinished(Lens::Hints const& hints) +void DashView::OnSearchFinished(Lens::Hints const& hints, glib::Error const& err) { hide_message_delay_.reset(); if (active_lens_view_ == NULL) return; + // FIXME: bind the lens_view in PerformSearch active_lens_view_->CheckNoResults(hints); std::string const& search_string = search_bar_->search_string; @@ -1025,15 +1023,15 @@ void DashView::OnSearchFinished(Lens::Hints const& hints) } } -void DashView::OnGlobalSearchFinished(Lens::Hints const& hints) +void DashView::OnGlobalSearchFinished(Lens::Hints const& hints, glib::Error const& error) { if (active_lens_view_ == home_view_) - OnSearchFinished(hints); + OnSearchFinished(hints, error); } -void DashView::OnAppsGlobalSearchFinished(Lens::Hints const& hints) +void DashView::OnAppsGlobalSearchFinished(Lens::Ptr const& lens) { - if (active_lens_view_ == home_view_) + if (active_lens_view_ == home_view_ && lens->id() == "applications.lens") { /* HACKITY HACK! We're resetting the state of search_in_progress when * doing searches in the home lens and we get results from apps lens. diff --git a/dash/DashView.h b/dash/DashView.h index 7a1dca40d..f0589b275 100644 --- a/dash/DashView.h +++ b/dash/DashView.h @@ -100,9 +100,9 @@ private: void OnLiveSearchReached(std::string const& search_string); void OnLensAdded(Lens::Ptr& lens); void OnLensBarActivated(std::string const& id); - void OnSearchFinished(Lens::Hints const& hints); - void OnGlobalSearchFinished(Lens::Hints const& hints); - void OnAppsGlobalSearchFinished(Lens::Hints const& hints); + void OnSearchFinished(Lens::Hints const& hints, glib::Error const& error); + void OnGlobalSearchFinished(Lens::Hints const& hints, glib::Error const& error); + void OnAppsGlobalSearchFinished(Lens::Ptr const& lens); void OnUriActivated(ResultView::ActivateType type, std::string const& uri, GVariant* data, std::string const& unique_id); void OnUriActivatedReply(std::string const& uri, HandledType type, Lens::Hints const&); bool DoFallbackActivation(std::string const& uri); diff --git a/dash/LensView.cpp b/dash/LensView.cpp index 444905b50..ab7f57cd6 100755 --- a/dash/LensView.cpp +++ b/dash/LensView.cpp @@ -605,10 +605,10 @@ void LensView::HideResultsMessage() } } -void LensView::PerformSearch(std::string const& search_query) +void LensView::PerformSearch(std::string const& search_query, Lens::SearchFinishedCallback cb) { search_string_ = search_query; - lens_->Search(search_query); + lens_->Search(search_query, cb); } std::string LensView::get_search_string() const @@ -664,7 +664,7 @@ void LensView::OnViewTypeChanged(ViewType view_type) if (view_type != HIDDEN && initial_activation_) { /* We reset the lens for ourselves, in case this is a restart or something */ - lens_->Search(search_string_); + lens_->Search(search_string_, [] (Lens::Hints const&, glib::Error const&) {}); initial_activation_ = false; } diff --git a/dash/LensView.h b/dash/LensView.h index 71da4c9df..707b6f6ab 100644 --- a/dash/LensView.h +++ b/dash/LensView.h @@ -70,7 +70,7 @@ public: sigc::signal uri_activated; - void PerformSearch(std::string const& search_query); + void PerformSearch(std::string const& search_query, Lens::SearchFinishedCallback cb); void CheckNoResults(Lens::Hints const& hints); void CheckCategoryExpansion(); void HideResultsMessage(); diff --git a/tests/test_gdbus_proxy.cpp b/tests/test_gdbus_proxy.cpp index de9675bf1..50347b55f 100644 --- a/tests/test_gdbus_proxy.cpp +++ b/tests/test_gdbus_proxy.cpp @@ -3,71 +3,36 @@ #include #include +#include "test_utils.h" + using namespace std; using namespace unity; namespace { -GMainLoop* loop_ = NULL; -glib::DBusProxy* proxy = NULL; - class TestGDBusProxy: public ::testing::Test { public: TestGDBusProxy() - : connected_result(false) - , got_signal_return(false) + : got_signal_return(false) , got_result_return(false) + , proxy("com.canonical.Unity.Test", + "/com/canonical/gdbus_wrapper", + "com.canonical.gdbus_wrapper") { } - bool connected_result; + bool got_signal_return; bool got_result_return; + glib::DBusProxy proxy; }; TEST_F(TestGDBusProxy, TestConstruction) { - loop_ = g_main_loop_new(NULL, FALSE); - proxy = new glib::DBusProxy("com.canonical.Unity.Test", - "/com/canonical/gdbus_wrapper", - "com.canonical.gdbus_wrapper"); - // performs a check on the proxy, if the proxy is connected, report a sucess - auto timeout_check = [] (gpointer data) -> gboolean - { - TestGDBusProxy* self = static_cast(data); - if (proxy->IsConnected()) - { - self->connected_result = true; - g_main_loop_quit(loop_); - return FALSE; - } - else - { - self->connected_result = false; - return TRUE; - } - }; - - - // if the proxy is not connected when this lambda runs, fail. - auto timeout_bailout = [] (gpointer data) -> gboolean - { - TestGDBusProxy* self = static_cast(data); - // reached timeout, failed testing - self->connected_result = false; - g_main_loop_quit(loop_); - return FALSE; - }; - - guint timeout_source = g_timeout_add(1000, timeout_check, this); // check once a second - guint bailout_source = g_timeout_add(10000, timeout_bailout, this); // bail out after ten - - g_main_loop_run(loop_); - g_source_remove(timeout_source); - g_source_remove(bailout_source); - - EXPECT_EQ(connected_result, true); + EXPECT_FALSE(proxy.IsConnected()); + Utils::WaitUntil(sigc::mem_fun(proxy, &glib::DBusProxy::IsConnected)); + EXPECT_TRUE(proxy.IsConnected()); } TEST_F(TestGDBusProxy, TestMethodReturn) @@ -75,23 +40,19 @@ TEST_F(TestGDBusProxy, TestMethodReturn) // Our service is setup so that if you call the TestMethod method, it will emit the TestSignal method // with whatever string you pass in gchar* expected_return = (gchar *)"TestStringTestString☻☻☻"; // cast to get gcc to shut up - gchar* returned_result = g_strdup("Not equal"); - gchar* returned_signal = g_strdup("Not equal"); + std::string returned_signal("Not equal"); + std::string returned_result("Not equal"); - GVariant* param_value = g_variant_new_string(expected_return); - GVariant* parameters = g_variant_new_tuple(¶m_value, 1); + GVariant* parameters = g_variant_new("(s)", expected_return); // signal callback auto signal_connection = [&](GVariant *variant) { if (variant != nullptr) { - g_free(returned_signal); - returned_signal = g_strdup(g_variant_get_string(g_variant_get_child_value(variant, 0), NULL)); + returned_signal = g_variant_get_string(g_variant_get_child_value(variant, 0), NULL); } got_signal_return = true; - if (got_signal_return && got_result_return) - g_main_loop_quit(loop_); }; // method callback @@ -99,37 +60,72 @@ TEST_F(TestGDBusProxy, TestMethodReturn) { if (variant != nullptr) { - g_free(returned_result); - returned_result = g_strdup(g_variant_get_string(g_variant_get_child_value(variant, 0), NULL)); + returned_result = g_variant_get_string(g_variant_get_child_value(variant, 0), NULL); } got_result_return = true; - if (got_signal_return && got_result_return) - g_main_loop_quit(loop_); }; - - auto timeout_bailout = [] (gpointer data) -> gboolean // bail out after 10 seconds + + Utils::WaitUntil(sigc::mem_fun(proxy, &glib::DBusProxy::IsConnected)); + EXPECT_TRUE(proxy.IsConnected()); // fail if we are not connected + proxy.Connect("TestSignal", signal_connection); + proxy.Call("TestMethod", parameters, method_connection); + + Utils::WaitUntil(got_result_return); + Utils::WaitUntil(got_signal_return); + + EXPECT_EQ(returned_result, expected_return); + EXPECT_EQ(returned_signal, expected_return); +} + +TEST_F(TestGDBusProxy, TestCancelling) +{ + std::string call_return; + // method callback + auto method_connection = [&](GVariant *variant) { - g_main_loop_quit(loop_); - return FALSE; + if (variant != nullptr) + { + call_return = g_variant_get_string(g_variant_get_child_value(variant, 0), NULL); + } + + got_result_return = true; }; - - guint bailout_source = g_timeout_add(10000, timeout_bailout, this); - EXPECT_EQ(proxy->IsConnected(), true); // fail if we are not connected - proxy->Connect("TestSignal", signal_connection); - proxy->Call("TestMethod", parameters, method_connection); + EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet + glib::Object cancellable(g_cancellable_new()); + // but this has to work eitherway + proxy.Call("TestMethod", g_variant_new("(s)", "TestStringTestString"), + method_connection, cancellable); - - // next check we get 30 entries from this specific known callback - g_main_loop_run(loop_); + // this could mostly cause the next test to fail + g_cancellable_cancel(cancellable); + EXPECT_FALSE(got_result_return); +} - EXPECT_EQ(g_strcmp0(expected_return, returned_result), 0); - EXPECT_EQ(g_strcmp0(expected_return, returned_signal), 0); +TEST_F(TestGDBusProxy, TestMethodCall) +{ + std::string call_return; + // method callback + auto method_connection = [&](GVariant *variant) + { + if (variant != nullptr) + { + call_return = g_variant_get_string(g_variant_get_child_value(variant, 0), NULL); + } - g_free(returned_result); - g_free(returned_signal); - g_source_remove(bailout_source); + got_result_return = true; + }; + + EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet + // but this has to work eitherway + proxy.Call("TestMethod", g_variant_new("(s)", "TestStringTestString"), + method_connection); + + Utils::WaitUntil(got_result_return); + + EXPECT_TRUE(proxy.IsConnected()); + EXPECT_EQ("TestStringTestString", call_return); } diff --git a/tests/test_home_lens.cpp b/tests/test_home_lens.cpp index 2cbd9d53a..f409d5325 100644 --- a/tests/test_home_lens.cpp +++ b/tests/test_home_lens.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -30,14 +31,6 @@ namespace class StaticTestLens; -typedef struct { - StaticTestLens* lens; - gchar* search_string; -} LensSearchClosure; - -static gboolean dispatch_global_search(gpointer userdata); - - /* * Mock Lens instance that does not use DBus. The default search does like this: * For input "bar" output: @@ -134,22 +127,27 @@ public: } g_free(row_buf); - - global_search_finished.emit(Hints()); } - void GlobalSearch(string const& search_string) + void GlobalSearch(string const& search_string, SearchFinishedCallback cb) { /* Dispatch search async, because that's what it'd normally do */ - LensSearchClosure* closure = g_new0(LensSearchClosure, 1); - closure->lens = this; - closure->search_string = g_strdup(search_string.c_str()); - g_idle_add(dispatch_global_search, closure); + source_manager_.Add(new glib::Idle([this, search_string, cb] () + { + DoGlobalSearch(search_string); + cb(Lens::Hints(), glib::Error()); + return false; + })); } - void Search(string const& search_string) + void Search(string const& search_string, SearchFinishedCallback cb) { - + /* Dispatch search async, because that's what it'd normally do */ + source_manager_.Add(new glib::Idle([search_string, cb] () + { + cb(Lens::Hints(), glib::Error()); + return false; + })); } void Activate(string const& uri) @@ -181,20 +179,9 @@ private: string results_base_name_; int num_results_; bool provides_personal_results_; + glib::SourceManager source_manager_; }; -static gboolean dispatch_global_search(gpointer userdata) -{ - LensSearchClosure* closure = (LensSearchClosure*) userdata; - - closure->lens->DoGlobalSearch(closure->search_string); - - g_free(closure->search_string); - g_free(closure); - - return FALSE; -} - /* * Mock Lenses class */ @@ -408,10 +395,8 @@ TEST(TestHomeLens, TestOneSearch) home_lens_.AddLenses(lenses_); - home_lens_.Search("ape"); - bool finished = false; - home_lens_.search_finished.connect([&finished] (Lens::Hints const& hints) + home_lens_.Search("ape", [&finished] (Lens::Hints const&, glib::Error const&) { finished = true; }); @@ -473,10 +458,8 @@ TEST(TestHomeLens, TestOrderingAfterSearch) order_changed = true; }); - home_lens_.Search("ape"); - bool finished = false; - home_lens_.search_finished.connect([&finished] (Lens::Hints const& hints) + home_lens_.Search("ape", [&finished] (Lens::Hints const&, glib::Error const&) { finished = true; }); @@ -523,10 +506,8 @@ TEST(TestHomeLens, TestOrderingWithExactAppsMatch) order_changed = true; }); - home_lens_.Search("ape"); - bool finished = false; - home_lens_.search_finished.connect([&finished] (Lens::Hints const& hints) + home_lens_.Search("ape", [&finished] (Lens::Hints const&, glib::Error const&) { finished = true; }); @@ -570,10 +551,8 @@ TEST(TestHomeLens, TestOrderingWithoutExactAppsMatch) order_changed = true; }); - home_lens_.Search("ape"); - bool finished = false; - home_lens_.search_finished.connect([&finished] (Lens::Hints const& hints) + home_lens_.Search("ape", [&finished] (Lens::Hints const&, glib::Error const&) { finished = true; }); @@ -623,10 +602,8 @@ TEST(TestHomeLens, TestOrderingByNumResults) order_changed = true; }); - home_lens_.Search("ape"); - bool finished = false; - home_lens_.search_finished.connect([&finished] (Lens::Hints const& hints) + home_lens_.Search("ape", [&finished] (Lens::Hints const&, glib::Error const&) { finished = true; }); @@ -691,10 +668,8 @@ TEST(TestHomeLens, TestPersonalResultsFirst) order_changed = true; }); - home_lens_.Search("ape"); - bool finished = false; - home_lens_.search_finished.connect([&finished] (Lens::Hints const& hints) + home_lens_.Search("ape", [&finished] (Lens::Hints const&, glib::Error const&) { finished = true; }); @@ -752,10 +727,8 @@ TEST(TestHomeLens, TestNonPersonalCategoriesBeforeEmpty) order_changed = true; }); - home_lens_.Search("ape"); - bool finished = false; - home_lens_.search_finished.connect([&finished] (Lens::Hints const& hints) + home_lens_.Search("ape", [&finished] (Lens::Hints const&, glib::Error const&) { finished = true; }); diff --git a/tests/test_lens.cpp b/tests/test_lens.cpp index 79decb031..629ab52f1 100644 --- a/tests/test_lens.cpp +++ b/tests/test_lens.cpp @@ -86,7 +86,7 @@ public: { Results::Ptr results = lens_->results; - lens_->Search("Test Search String"); + lens_->Search("Test Search String", nullptr); WaitForModel(results.get(), 5); Result result = results->RowAtIndex(0); @@ -145,7 +145,7 @@ TEST_F(TestLens, TestSearch) { Results::Ptr results = lens_->results; - lens_->Search("Test Search String"); + lens_->Search("Test Search String", nullptr); WaitForModel(results.get(), 5); for (unsigned int i = 0; i < 5; i++) @@ -169,7 +169,7 @@ TEST_F(TestLens, TestGlobalSearch) { Results::Ptr results = lens_->global_results; - lens_->GlobalSearch("Test Global Search String"); + lens_->GlobalSearch("Test Global Search String", nullptr); WaitForModel(results.get(), 10); for (unsigned int i = 0; i < 10; i++) -- cgit v1.2.3 From b07f90bdace5bb2518768a01fa849406e8082e21 Mon Sep 17 00:00:00 2001 From: Nick Dedekind Date: Thu, 8 Nov 2012 10:33:39 +0000 Subject: Added launcher icon blink/pulse test. (bzr r2866.6.2) --- tests/test_launcher.cpp | 112 +++++++++++++++++++----------------------------- 1 file changed, 44 insertions(+), 68 deletions(-) diff --git a/tests/test_launcher.cpp b/tests/test_launcher.cpp index 542bd2652..cb1ca1636 100644 --- a/tests/test_launcher.cpp +++ b/tests/test_launcher.cpp @@ -80,65 +80,22 @@ public: return AbstractLauncherIcon::Ptr(); } - float IconBackgroundIntensity(AbstractLauncherIcon::Ptr const& icon, timespec const& current) const - { - return Launcher::IconBackgroundIntensity(icon, current); - } - - void StartIconDrag(AbstractLauncherIcon::Ptr const& icon) - { - Launcher::StartIconDrag(icon); - } - - void ShowDragWindow() - { - Launcher::ShowDragWindow(); - } - - void EndIconDrag() - { - Launcher::EndIconDrag(); - } - - void UpdateDragWindowPosition(int x, int y) - { - Launcher::UpdateDragWindowPosition(x, y); - } - - void HideDragWindow() - { - Launcher::HideDragWindow(); - } - - void ResetMouseDragState() - { - Launcher::ResetMouseDragState(); - } - - bool DndIsSpecialRequest(std::string const& uri) const - { - return Launcher::DndIsSpecialRequest(uri); - } - - int GetDragIconPosition() const - { - return _drag_icon_position; - } - - void ProcessDndEnter() - { - Launcher::ProcessDndEnter(); - } - - void ProcessDndLeave() - { - Launcher::ProcessDndLeave(); - } - - void ProcessDndMove(int x, int y, std::list mimes) - { - Launcher::ProcessDndMove(x, y, mimes); - } + using Launcher::IconBackgroundIntensity; + using Launcher::StartIconDrag; + using Launcher::ShowDragWindow; + using Launcher::EndIconDrag; + using Launcher::UpdateDragWindowPosition; + using Launcher::HideDragWindow; + using Launcher::ResetMouseDragState; + using Launcher::DndIsSpecialRequest; + using Launcher::ProcessDndEnter; + using Launcher::ProcessDndLeave; + using Launcher::ProcessDndMove; + using Launcher::ProcessDndDrop; + using Launcher::_drag_icon_position; + + using Launcher::IconStartingBlinkValue; + using Launcher::IconStartingPulseValue; void FakeProcessDndMove(int x, int y, std::list uris) { @@ -158,11 +115,6 @@ public: _dnd_hovered_icon = MouseIconIntersection(x, y); } - - void ProcessDndDrop(int x, int y) - { - Launcher::ProcessDndDrop(x, y); - } }; TestLauncher() @@ -354,7 +306,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasChanged) // Start dragging icon2 launcher_->StartIconDrag(icon2); launcher_->ShowDragWindow(); - ASSERT_EQ(launcher_->GetDragIconPosition(), model_->IconIndex(icon2)); + ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2)); // Moving icon2 at the end auto const& center3 = icon3->GetCenter(launcher_->monitor()); @@ -364,7 +316,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasChanged) model_->saved.connect([&model_saved] { model_saved = true; }); EXPECT_CALL(*icon2, Stick(false)); - ASSERT_NE(launcher_->GetDragIconPosition(), model_->IconIndex(icon2)); + ASSERT_NE(launcher_->_drag_icon_position, model_->IconIndex(icon2)); launcher_->EndIconDrag(); // The icon order should be reset @@ -391,7 +343,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasNotChanged) // Start dragging icon2 launcher_->StartIconDrag(icon2); launcher_->ShowDragWindow(); - ASSERT_EQ(launcher_->GetDragIconPosition(), model_->IconIndex(icon2)); + ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2)); // Moving icon2 at the end auto center3 = icon3->GetCenter(launcher_->monitor()); @@ -408,7 +360,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasNotChanged) bool model_saved = false; model_->saved.connect([&model_saved] { model_saved = true; }); - ASSERT_EQ(launcher_->GetDragIconPosition(), model_->IconIndex(icon2)); + ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2)); launcher_->EndIconDrag(); // The icon order should be reset @@ -524,6 +476,30 @@ TEST_F(TestLauncher, AddRequestSignal) EXPECT_TRUE(add_request); } +TEST_F(TestLauncher, IconStartingPulseValue) +{ + struct timespec current; + clock_gettime(CLOCK_MONOTONIC, ¤t); + MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon); + + icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, true); + + // Pulse value should start at 0. + EXPECT_EQ(launcher_->IconStartingPulseValue(icon, current), 0.0); +} + + +TEST_F(TestLauncher, IconStartingBlinkValue) +{ + struct timespec current; + clock_gettime(CLOCK_MONOTONIC, ¤t); + MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon); + + icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, true); + + // Pulse value should start at 0. + EXPECT_EQ(launcher_->IconStartingBlinkValue(icon, current), 0.0); +} } } -- cgit v1.2.3 From a1a5266d053c4fb6392c009078aa8ebb05b5f078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=27sil2100=27=20Zemczak?= Date: Fri, 9 Nov 2012 11:47:15 +0100 Subject: The test_dash_hud_only_uses_icon_from_current_desktop test should be performed with show_desktop, as otherwise we are never sure what applications are visible on what workspace. (bzr r2887.2.1) --- tests/autopilot/unity/tests/test_hud.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py index 2ccb3b580..4623990be 100644 --- a/tests/autopilot/unity/tests/test_hud.py +++ b/tests/autopilot/unity/tests/test_hud.py @@ -669,6 +669,9 @@ class HudVisualTests(HudTestsBase): """ initial_workspace = self.workspace.current_workspace self.addCleanup(self.workspace.switch_to, initial_workspace) + self.window_manager.enter_show_desktop() + self.addCleanup(self.window_manager.leave_show_desktop) + self.workspace.switch_to(0) calc = self.start_app("Calculator") self.assertTrue(calc.is_active) -- cgit v1.2.3 From acb5650c8fa9cd7be7fc505e85947f14374c71e9 Mon Sep 17 00:00:00 2001 From: Michal Hruby Date: Mon, 12 Nov 2012 12:07:23 +0100 Subject: Fix issues brought up during review (bzr r2866.7.2) --- UnityCore/GLibDBusProxy.cpp | 23 +++++++++++++---------- UnityCore/GLibDBusProxy.h | 4 ++-- UnityCore/HomeLens.cpp | 4 ++-- UnityCore/HomeLens.h | 4 ++-- UnityCore/Lens.cpp | 19 +++++++++++-------- UnityCore/Lens.h | 6 ++---- dash/LensView.cpp | 2 +- dash/LensView.h | 2 +- tests/test_home_lens.cpp | 5 +++-- 9 files changed, 37 insertions(+), 32 deletions(-) diff --git a/UnityCore/GLibDBusProxy.cpp b/UnityCore/GLibDBusProxy.cpp index 5c88dee4f..cacdbb969 100644 --- a/UnityCore/GLibDBusProxy.cpp +++ b/UnityCore/GLibDBusProxy.cpp @@ -61,16 +61,16 @@ public: void WaitForProxy(GCancellable* cancellable, int timeout_msec, - std::function callback); + std::function const& callback); void CallNoError(string const& method_name, GVariant* parameters, - ReplyCallback callback, + ReplyCallback const& callback, GCancellable* cancellable, GDBusCallFlags flags, int timeout_msec); void Call(std::string const& method_name, GVariant* parameters, - CallFinishedCallback callback, + CallFinishedCallback const& callback, GCancellable *cancellable, GDBusCallFlags flags, int timeout_msec); @@ -260,7 +260,7 @@ void DBusProxy::Impl::OnProxySignal(GDBusProxy* proxy, void DBusProxy::Impl::WaitForProxy(GCancellable* cancellable, int timeout_msec, - std::function callback) + std::function const& callback) { if (!proxy_) { @@ -268,7 +268,7 @@ void DBusProxy::Impl::WaitForProxy(GCancellable* cancellable, auto canc = glib::Object(cancellable, glib::AddRef()); // add a timeout - auto timeout = glib::Source::Ptr(new glib::Timeout(timeout_msec < 0 ? 30000 : timeout_msec, [con, canc, callback] () + auto timeout = std::make_shared(timeout_msec < 0 ? 30000 : timeout_msec, [con, canc, callback] () { if (!g_cancellable_is_cancelled(canc)) { @@ -280,11 +280,12 @@ void DBusProxy::Impl::WaitForProxy(GCancellable* cancellable, } con->disconnect(); return false; - })); + }); // wait for the signal *con = proxy_acquired.connect([con, canc, timeout, callback] () { if (!g_cancellable_is_cancelled(canc)) callback(glib::Error()); + timeout->Remove(); con->disconnect(); }); @@ -297,7 +298,7 @@ void DBusProxy::Impl::WaitForProxy(GCancellable* cancellable, void DBusProxy::Impl::CallNoError(string const& method_name, GVariant* parameters, - ReplyCallback callback, + ReplyCallback const& callback, GCancellable* cancellable, GDBusCallFlags flags, int timeout_msec) @@ -319,7 +320,7 @@ void DBusProxy::Impl::CallNoError(string const& method_name, void DBusProxy::Impl::Call(string const& method_name, GVariant* parameters, - CallFinishedCallback callback, + CallFinishedCallback const& callback, GCancellable* cancellable, GDBusCallFlags flags, int timeout_msec) @@ -337,7 +338,9 @@ void DBusProxy::Impl::Call(string const& method_name, << ": " << err; } else + { Call(method_name, sinked_parameters, callback, canc, flags, timeout_msec); + } }); return; } @@ -401,7 +404,7 @@ DBusProxy::~DBusProxy() void DBusProxy::Call(string const& method_name, GVariant* parameters, - ReplyCallback callback, + ReplyCallback const& callback, GCancellable* cancellable, GDBusCallFlags flags, int timeout_msec) @@ -412,7 +415,7 @@ void DBusProxy::Call(string const& method_name, void DBusProxy::CallBegin(std::string const& method_name, GVariant* parameters, - CallFinishedCallback callback, + CallFinishedCallback const& callback, GCancellable *cancellable, GDBusCallFlags flags, int timeout_msec) diff --git a/UnityCore/GLibDBusProxy.h b/UnityCore/GLibDBusProxy.h index afc0c7684..35c2bca0c 100644 --- a/UnityCore/GLibDBusProxy.h +++ b/UnityCore/GLibDBusProxy.h @@ -51,13 +51,13 @@ public: void Call(std::string const& method_name, GVariant* parameters = nullptr, - ReplyCallback callback = nullptr, + ReplyCallback const& callback = nullptr, GCancellable *cancellable = nullptr, GDBusCallFlags flags = G_DBUS_CALL_FLAGS_NONE, int timeout_msec = -1); void CallBegin(std::string const& method_name, GVariant* parameters, - CallFinishedCallback callback, + CallFinishedCallback const& callback, GCancellable *cancellable = nullptr, GDBusCallFlags flags = G_DBUS_CALL_FLAGS_NONE, int timeout_msec = -1); diff --git a/UnityCore/HomeLens.cpp b/UnityCore/HomeLens.cpp index 57f5d6535..e04d3e95f 100644 --- a/UnityCore/HomeLens.cpp +++ b/UnityCore/HomeLens.cpp @@ -1160,13 +1160,13 @@ Lens::Ptr HomeLens::GetLensAtIndex(std::size_t index) const return Lens::Ptr(); } -void HomeLens::GlobalSearch(std::string const& search_string, SearchFinishedCallback cb) +void HomeLens::GlobalSearch(std::string const& search_string, SearchFinishedCallback const& cb) { LOG_WARN(logger) << "Global search not enabled for HomeLens class." << " Ignoring query '" << search_string << "'"; } -void HomeLens::Search(std::string const& search_string, SearchFinishedCallback cb) +void HomeLens::Search(std::string const& search_string, SearchFinishedCallback const& cb) { LOG_DEBUG(logger) << "Search '" << search_string << "'"; diff --git a/UnityCore/HomeLens.h b/UnityCore/HomeLens.h index 48e0510d6..68fa0ce06 100644 --- a/UnityCore/HomeLens.h +++ b/UnityCore/HomeLens.h @@ -69,8 +69,8 @@ public: Lens::Ptr GetLens(std::string const& lens_id) const; Lens::Ptr GetLensAtIndex(std::size_t index) const; - void GlobalSearch(std::string const& search_string, SearchFinishedCallback cb); - void Search(std::string const& search_string, SearchFinishedCallback cb); + void GlobalSearch(std::string const& search_string, SearchFinishedCallback const& cb); + void Search(std::string const& search_string, SearchFinishedCallback const& cb); void Activate(std::string const& uri); void Preview(std::string const& uri); diff --git a/UnityCore/Lens.cpp b/UnityCore/Lens.cpp index a7dd1cca8..35bce189b 100644 --- a/UnityCore/Lens.cpp +++ b/UnityCore/Lens.cpp @@ -64,10 +64,11 @@ public: unsigned long long ExtractModelSeqnum(GVariant *parameters); void WaitForModelUpdate(glib::Variant const& response_variant, - Results::Ptr model, - std::function callback); + Results::Ptr const& model, + std::function const& callback); void SearchCallFinished(GVariant* response, glib::Error const& error, - Results::Ptr model, SearchFinishedCallback cb); + Results::Ptr const& model, + SearchFinishedCallback const& cb); void OnChanged(GVariant* parameters); void UpdateProperties(bool search_in_global, @@ -241,8 +242,8 @@ void Lens::Impl::OnProxyDisconnected() } void Lens::Impl::WaitForModelUpdate(glib::Variant const& response_variant, - Results::Ptr model, - std::function callback) + Results::Ptr const& model, + std::function const& callback) { // a bit of pointer craziness because using copy constructors screws us up auto con = std::make_shared(); @@ -422,7 +423,7 @@ void Lens::Impl::OnViewTypeChanged(ViewType view_type) proxy_->Call("SetViewType", g_variant_new("(u)", view_type)); } -void Lens::Impl::SearchCallFinished(GVariant* response, glib::Error const& error, Results::Ptr model, SearchFinishedCallback cb) +void Lens::Impl::SearchCallFinished(GVariant* response, glib::Error const& error, Results::Ptr const& model, SearchFinishedCallback const& cb) { if (!error) { @@ -859,12 +860,14 @@ Lens::~Lens() delete pimpl; } -void Lens::GlobalSearch(std::string const& search_string, SearchFinishedCallback cb) +void Lens::GlobalSearch(std::string const& search_string, + SearchFinishedCallback const& cb) { pimpl->GlobalSearch(search_string, cb); } -void Lens::Search(std::string const& search_string, SearchFinishedCallback cb) +void Lens::Search(std::string const& search_string, + SearchFinishedCallback const& cb) { pimpl->Search(search_string, cb); } diff --git a/UnityCore/Lens.h b/UnityCore/Lens.h index c777020d8..cf35f752a 100644 --- a/UnityCore/Lens.h +++ b/UnityCore/Lens.h @@ -82,8 +82,8 @@ public: virtual ~Lens(); - virtual void GlobalSearch(std::string const& search_string, SearchFinishedCallback cb = nullptr); - virtual void Search(std::string const& search_string, SearchFinishedCallback cb = nullptr); + virtual void GlobalSearch(std::string const& search_string, SearchFinishedCallback const& cb = nullptr); + virtual void Search(std::string const& search_string, SearchFinishedCallback const& cb = nullptr); virtual void Activate(std::string const& uri); virtual void Preview(std::string const& uri); virtual void ActivatePreviewAction(std::string const& action_id, @@ -126,8 +126,6 @@ public: /* Emitted when any of the models' swarm name changes, but collates the name * changes into a single signal emission (when all are changed) */ sigc::signal models_changed; - //sigc::signal search_finished; - //sigc::signal global_search_finished; sigc::signal activated; sigc::signal preview_ready; diff --git a/dash/LensView.cpp b/dash/LensView.cpp index ab7f57cd6..9eaba5f74 100755 --- a/dash/LensView.cpp +++ b/dash/LensView.cpp @@ -605,7 +605,7 @@ void LensView::HideResultsMessage() } } -void LensView::PerformSearch(std::string const& search_query, Lens::SearchFinishedCallback cb) +void LensView::PerformSearch(std::string const& search_query, Lens::SearchFinishedCallback const& cb) { search_string_ = search_query; lens_->Search(search_query, cb); diff --git a/dash/LensView.h b/dash/LensView.h index 707b6f6ab..47cbbf72a 100644 --- a/dash/LensView.h +++ b/dash/LensView.h @@ -70,7 +70,7 @@ public: sigc::signal uri_activated; - void PerformSearch(std::string const& search_query, Lens::SearchFinishedCallback cb); + void PerformSearch(std::string const& search_query, Lens::SearchFinishedCallback const& cb); void CheckNoResults(Lens::Hints const& hints); void CheckCategoryExpansion(); void HideResultsMessage(); diff --git a/tests/test_home_lens.cpp b/tests/test_home_lens.cpp index f409d5325..3bbae4f31 100644 --- a/tests/test_home_lens.cpp +++ b/tests/test_home_lens.cpp @@ -129,7 +129,8 @@ public: g_free(row_buf); } - void GlobalSearch(string const& search_string, SearchFinishedCallback cb) + void GlobalSearch(string const& search_string, + SearchFinishedCallback const& cb) { /* Dispatch search async, because that's what it'd normally do */ source_manager_.Add(new glib::Idle([this, search_string, cb] () @@ -140,7 +141,7 @@ public: })); } - void Search(string const& search_string, SearchFinishedCallback cb) + void Search(string const& search_string, SearchFinishedCallback const& cb) { /* Dispatch search async, because that's what it'd normally do */ source_manager_.Add(new glib::Idle([search_string, cb] () -- cgit v1.2.3 From 3175b784f92ce29f1490f76a8537dad7302e6971 Mon Sep 17 00:00:00 2001 From: "Stephen M. Webb" Date: Mon, 12 Nov 2012 11:23:54 -0500 Subject: Fixes FTBFS due to libbamf API change (lp #1077937). Fixes LP: #1077937 (bzr r2888.2.1) --- hud/HudController.cpp | 2 +- panel/PanelMenuView.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hud/HudController.cpp b/hud/HudController.cpp index b7c11bcf0..484b1ce9f 100644 --- a/hud/HudController.cpp +++ b/hud/HudController.cpp @@ -339,7 +339,7 @@ void Controller::ShowHud() auto view = static_cast(l->data); Window xid = bamf_window_get_xid(win); - if (bamf_view_user_visible(view) && bamf_window_get_window_type(win) != BAMF_WINDOW_DOCK && + if (bamf_view_is_user_visible(view) && bamf_window_get_window_type(win) != BAMF_WINDOW_DOCK && wm.IsWindowOnCurrentDesktop(xid) && wm.IsWindowVisible(xid) && std::find(unity_xids.begin(), unity_xids.end(), xid) == unity_xids.end()) diff --git a/panel/PanelMenuView.cpp b/panel/PanelMenuView.cpp index ca0b61b55..d97d0888b 100644 --- a/panel/PanelMenuView.cpp +++ b/panel/PanelMenuView.cpp @@ -1322,7 +1322,7 @@ Window PanelMenuView::GetTopWindow() const continue; Window xid = bamf_window_get_xid(static_cast(l->data)); - bool visible = bamf_view_user_visible(static_cast(l->data)); + bool visible = bamf_view_is_user_visible(static_cast(l->data)); if (visible && IsValidWindow(xid)) { -- cgit v1.2.3 From 4f2d0ca987e80d24ac8797c7bace509b4d4b6e5b Mon Sep 17 00:00:00 2001 From: "Stephen M. Webb" Date: Mon, 12 Nov 2012 12:23:39 -0500 Subject: And another instance of bamf API change (bzr r2888.2.2) --- launcher/ApplicationLauncherIcon.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/launcher/ApplicationLauncherIcon.cpp b/launcher/ApplicationLauncherIcon.cpp index bb60f8296..131146398 100644 --- a/launcher/ApplicationLauncherIcon.cpp +++ b/launcher/ApplicationLauncherIcon.cpp @@ -70,7 +70,7 @@ ApplicationLauncherIcon::ApplicationLauncherIcon(BamfApplication* app) tooltip_text = BamfName(); icon_name = (icon ? icon.Str() : DEFAULT_ICON); - SetQuirk(Quirk::VISIBLE, bamf_view_user_visible(bamf_view)); + SetQuirk(Quirk::VISIBLE, bamf_view_is_user_visible(bamf_view)); SetQuirk(Quirk::ACTIVE, bamf_view_is_active(bamf_view)); SetQuirk(Quirk::RUNNING, bamf_view_is_running(bamf_view)); @@ -245,7 +245,7 @@ void ApplicationLauncherIcon::ActivateLauncherIcon(ActionArg arg) if (arg.source != ActionArg::SWITCHER) { auto bamf_view = glib::object_cast(_bamf_app); - user_visible = bamf_view_user_visible(bamf_view); + user_visible = bamf_view_is_user_visible(bamf_view); if (active) { @@ -392,7 +392,7 @@ std::vector ApplicationLauncherIcon::GetWindows(WindowFilterMask filter, if ((monitor >= 0 && bamf_window_get_monitor(window) == monitor) || monitor < 0) { - if ((user_visible && bamf_view_user_visible(view)) || !user_visible) + if ((user_visible && bamf_view_is_user_visible(view)) || !user_visible) { guint32 xid = bamf_window_get_xid(window); @@ -683,7 +683,7 @@ std::vector ApplicationLauncherIcon::GetFocusableWindows(ActionArg arg, Window xid = bamf_window_get_xid(static_cast(l->data)); bool urgent = bamf_view_is_urgent(view); - bool user_visible = bamf_view_user_visible(view); + bool user_visible = bamf_view_is_user_visible(view); if (any_urgent) { @@ -960,7 +960,7 @@ void ApplicationLauncherIcon::UnStick() BamfView* view = BAMF_VIEW(_bamf_app.RawPtr()); bamf_view_set_sticky(view, false); - SetQuirk(Quirk::VISIBLE, bamf_view_user_visible(view)); + SetQuirk(Quirk::VISIBLE, bamf_view_is_user_visible(view)); if (bamf_view_is_closed(view)) Remove(); -- cgit v1.2.3 From 01d77af4108751948d0b46817fd1b14d192f8496 Mon Sep 17 00:00:00 2001 From: Michal Hruby Date: Tue, 13 Nov 2012 15:11:24 +0100 Subject: Add a few more tests (bzr r2866.7.3) --- UnityCore/GLibDBusProxy.cpp | 6 ++-- tests/test_gdbus_proxy.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/UnityCore/GLibDBusProxy.cpp b/UnityCore/GLibDBusProxy.cpp index cacdbb969..bcd22bb18 100644 --- a/UnityCore/GLibDBusProxy.cpp +++ b/UnityCore/GLibDBusProxy.cpp @@ -325,10 +325,12 @@ void DBusProxy::Impl::Call(string const& method_name, GDBusCallFlags flags, int timeout_msec) { + GCancellable* target_canc = cancellable != NULL ? cancellable : cancellable_; + if (!proxy_) { glib::Variant sinked_parameters(parameters); - glib::Objectcanc(cancellable, glib::AddRef()); + glib::Objectcanc(target_canc, glib::AddRef()); WaitForProxy(canc, timeout_msec, [this, method_name, sinked_parameters, callback, canc, flags, timeout_msec] (glib::Error const& err) { if (err) @@ -354,7 +356,7 @@ void DBusProxy::Impl::Call(string const& method_name, parameters, flags, timeout_msec, - cancellable != NULL ? cancellable : cancellable_, + target_canc, DBusProxy::Impl::OnCallCallback, data); } diff --git a/tests/test_gdbus_proxy.cpp b/tests/test_gdbus_proxy.cpp index 50347b55f..3e46913c3 100644 --- a/tests/test_gdbus_proxy.cpp +++ b/tests/test_gdbus_proxy.cpp @@ -28,6 +28,21 @@ public: glib::DBusProxy proxy; }; +class TestGDBusProxyInvalidService: public ::testing::Test +{ +public: + TestGDBusProxyInvalidService() + : got_result_return(false) + , proxy("com.canonical.Unity.Test.NonExistant", + "/com/canonical/gdbus_wrapper", + "com.canonical.gdbus_wrapper") + { + } + + bool got_result_return; + glib::DBusProxy proxy; +}; + TEST_F(TestGDBusProxy, TestConstruction) { EXPECT_FALSE(proxy.IsConnected()); @@ -96,13 +111,65 @@ TEST_F(TestGDBusProxy, TestCancelling) glib::Object cancellable(g_cancellable_new()); // but this has to work eitherway proxy.Call("TestMethod", g_variant_new("(s)", "TestStringTestString"), - method_connection, cancellable); + method_connection, cancellable); // this could mostly cause the next test to fail g_cancellable_cancel(cancellable); EXPECT_FALSE(got_result_return); } +TEST_F(TestGDBusProxy, TestAcquiring) +{ + const int NUM_REQUESTS = 10; + int completed = 0; + std::string call_return; + // method callback + auto method_connection = [&](GVariant* variant, glib::Error const& err) + { + if (variant != nullptr) + { + call_return = g_variant_get_string(g_variant_get_child_value(variant, 0), NULL); + } + + if (++completed >= NUM_REQUESTS) got_result_return = true; + }; + + EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet + for (int i = 0; i < NUM_REQUESTS; i++) + { + proxy.CallBegin("TestMethod", g_variant_new("(s)", "TestStringTestString"), + method_connection, nullptr); + Utils::WaitForTimeoutMSec(150); + } + Utils::WaitUntil(got_result_return); +} + +TEST_F(TestGDBusProxyInvalidService, TestTimeouting) +{ + std::string call_return; + // method callback + auto method_connection = [&](GVariant* variant, glib::Error const& err) + { + if (variant != nullptr) + { + call_return = g_variant_get_string(g_variant_get_child_value(variant, 0), NULL); + } + + got_result_return = true; + }; + + EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet + + proxy.CallBegin("TestMethod", g_variant_new("(s)", "TestStringTestString"), + method_connection, nullptr, (GDBusCallFlags) 0, 100); + // want to test timeout, if non-blocking sleep was used, the proxy would + // be acquired (with a dbus error) + g_usleep(110000); + + Utils::WaitUntil(got_result_return); + EXPECT_EQ(call_return, ""); +} + TEST_F(TestGDBusProxy, TestMethodCall) { std::string call_return; @@ -120,7 +187,7 @@ TEST_F(TestGDBusProxy, TestMethodCall) EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet // but this has to work eitherway proxy.Call("TestMethod", g_variant_new("(s)", "TestStringTestString"), - method_connection); + method_connection); Utils::WaitUntil(got_result_return); -- cgit v1.2.3 From d67fc00e4aca3144956e1a9a21ef920a9393f084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 13 Nov 2012 21:54:13 +0100 Subject: TestLauncherController: fix some random failures (bzr r2892.2.1) --- tests/test_launcher_controller.cpp | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp index 22d197b2d..729546753 100644 --- a/tests/test_launcher_controller.cpp +++ b/tests/test_launcher_controller.cpp @@ -222,7 +222,7 @@ protected: { auto const& model = Impl()->model_; auto icon = std::find_if(model->begin(), model->end(), - [&path](AbstractLauncherIcon::Ptr const& i) { return ( i->DesktopFile() == path); }); + [&path](AbstractLauncherIcon::Ptr const& i) { return (i->DesktopFile() == path); }); if (icon != model->end()) return *icon; @@ -287,13 +287,18 @@ TEST_F(TestLauncherController, Construction) for (auto const& fav_uri : favorite_store.GetFavorites()) { auto model_icon_it = std::find_if(lc.Impl()->model_->begin(), lc.Impl()->model_->end(), - [&fav_uri](AbstractLauncherIcon::Ptr const& i) { return (i->RemoteUri() == fav_uri); }); - auto const& icon_it = *model_icon_it; + [&fav_uri](AbstractLauncherIcon::Ptr const& i) { return (i->RemoteUri() == fav_uri); }); + bool valid_iter = (model_icon_it != lc.Impl()->model_->end()); if (fav_uri == places::APPS_URI || fav_uri == places::DEVICES_URI) - ASSERT_FALSE(icon_it.IsValid()); + { + ASSERT_FALSE(valid_iter); + } else - ASSERT_TRUE(icon_it.IsValid()); + { + ASSERT_TRUE(valid_iter); + ASSERT_TRUE(model_icon_it->IsValid()); + } } } @@ -711,8 +716,10 @@ TEST_F(TestLauncherController, AddRunningApps) if (!BAMF_IS_APPLICATION(l->data)) continue; - BamfApplication* app = BAMF_APPLICATION(l->data); + if (bamf_view_is_sticky(BAMF_VIEW(l->data))) + continue; + BamfApplication* app = BAMF_APPLICATION(l->data); ASSERT_NE(g_object_get_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen")), nullptr); auto desktop = bamf_application_get_desktop_file(app); @@ -755,9 +762,9 @@ TEST_F(TestLauncherController, SetupIcons) FavoriteStore::URI_PREFIX_APP + app::SW_CENTER, places::DEVICES_URI, FavoriteStore::URI_PREFIX_APP + app::UPDATE_MANAGER }); - std::shared_ptr apps(bamf_matcher_get_applications(lc.Impl()->matcher_), g_list_free); lc.Impl()->SetupIcons(); lc.DisconnectSignals(); + std::shared_ptr apps(bamf_matcher_get_applications(lc.Impl()->matcher_), g_list_free); auto fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::UBUNTU_ONE); EXPECT_EQ(model->IconIndex(fav), icon_index); @@ -771,12 +778,14 @@ TEST_F(TestLauncherController, SetupIcons) fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::UPDATE_MANAGER); EXPECT_EQ(model->IconIndex(fav), ++icon_index); - for (GList *l = apps.get(); l; l = l->next) { if (!BAMF_IS_APPLICATION(l->data)) continue; + if (bamf_view_is_sticky(BAMF_VIEW(l->data))) + continue; + auto desktop = bamf_application_get_desktop_file(BAMF_APPLICATION(l->data)); std::string path(desktop ? desktop : ""); ++icon_index; @@ -784,9 +793,7 @@ TEST_F(TestLauncherController, SetupIcons) if (path.empty()) continue; - auto const& icon = lc.GetIconByDesktop(path); - - ASSERT_TRUE(icon.IsValid()); + auto icon = lc.GetIconByDesktop(path); ASSERT_EQ(model->IconIndex(icon), icon_index); } @@ -801,9 +808,9 @@ TEST_F(TestLauncherController, ResetIconPriorities) favorite_store.AddFavorite(places::APPS_URI, -1); favorite_store.AddFavorite(places::DEVICES_URI, -1); - std::shared_ptr apps(bamf_matcher_get_applications(lc.Impl()->matcher_), g_list_free); lc.Impl()->SetupIcons(); lc.DisconnectSignals(); + std::shared_ptr apps(bamf_matcher_get_applications(lc.Impl()->matcher_), g_list_free); favorite_store.SetFavorites({ places::DEVICES_URI, FavoriteStore::URI_PREFIX_APP + app::SW_CENTER, @@ -825,6 +832,9 @@ TEST_F(TestLauncherController, ResetIconPriorities) if (!BAMF_IS_APPLICATION(l->data)) continue; + if (bamf_view_is_sticky(BAMF_VIEW(l->data))) + continue; + auto desktop = bamf_application_get_desktop_file(BAMF_APPLICATION(l->data)); std::string path(desktop ? desktop : ""); ++icon_index; @@ -1516,7 +1526,9 @@ TEST_F(TestLauncherController, UpdateSelectionChanged) { UBusManager manager; std::string last_selection_change; - manager.RegisterInterest(UBUS_LAUNCHER_SELECTION_CHANGED, [&] (GVariant *data) { last_selection_change = g_variant_get_string(data, 0); }); + manager.RegisterInterest(UBUS_LAUNCHER_SELECTION_CHANGED, [&] (GVariant *data) { + last_selection_change = g_variant_get_string(data, 0); + }); lc.KeyNavGrab(); ProcessUBusMessages(); -- cgit v1.2.3 From ea990e04944ed9cbf1a3b7519cf9c18638953d77 Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Tue, 13 Nov 2012 15:00:30 -0800 Subject: * Nux major version is now 4.0, updating unity for the same (bzr r2892.3.1) --- CMakeLists.txt | 4 ++-- UnityCore/CMakeLists.txt | 2 +- plugins/unity-mt-grab-handles/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5afe3c9ea..0832c3b25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,9 +145,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MAINTAINER_CXXFLAGS}") # Compiz Plugins # if(UNITY_ENABLE_X_ORG_SUPPORT) - set (UNITY_PLUGIN_DEPS "compiz>=0.9.8.0;nux-3.0>=3.0.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;gmodule-2.0;dbusmenu-glib-0.4;x11;libstartup-notification-1.0;gthread-2.0;indicator3-0.4>=0.4.90;atk;atk-bridge-2.0;unity-misc>=0.4.0;dbus-glib-1;gtk+-3.0>=3.1;sigc++-2.0;json-glib-1.0;libnotify;xfixes;unity-protocol-private>=5.95.1;libgeis;xrender>=0.9;zeitgeist-1.0>=0.3.18") + set (UNITY_PLUGIN_DEPS "compiz>=0.9.8.0;nux-4.0>=4.0.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;gmodule-2.0;dbusmenu-glib-0.4;x11;libstartup-notification-1.0;gthread-2.0;indicator3-0.4>=0.4.90;atk;atk-bridge-2.0;unity-misc>=0.4.0;dbus-glib-1;gtk+-3.0>=3.1;sigc++-2.0;json-glib-1.0;libnotify;xfixes;unity-protocol-private>=5.95.1;libgeis;xrender>=0.9;zeitgeist-1.0>=0.3.18") else () - set (UNITY_PLUGIN_DEPS "nux-3.0>=3.0.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;gmodule-2.0;dbusmenu-glib-0.4;libstartup-notification-1.0;gthread-2.0;indicator3-0.4>=0.4.90;atk;atk-bridge-2.0;unity-misc>=0.4.0;dbus-glib-1;gtk+-3.0>=3.1;sigc++-2.0;json-glib-1.0;libnotify;xfixes;unity-protocol-private>=5.95.1;libgeis;xrender>=0.9;zeitgeist-1.0>=0.3.18") + set (UNITY_PLUGIN_DEPS "nux-4.0>=4.0.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;gmodule-2.0;dbusmenu-glib-0.4;libstartup-notification-1.0;gthread-2.0;indicator3-0.4>=0.4.90;atk;atk-bridge-2.0;unity-misc>=0.4.0;dbus-glib-1;gtk+-3.0>=3.1;sigc++-2.0;json-glib-1.0;libnotify;xfixes;unity-protocol-private>=5.95.1;libgeis;xrender>=0.9;zeitgeist-1.0>=0.3.18") endif () set (UNITY_PROTOCOL_PRIVATE_DEPS "unity-protocol-private>=5.95.1") diff --git a/UnityCore/CMakeLists.txt b/UnityCore/CMakeLists.txt index a036af4f0..5070b4c78 100644 --- a/UnityCore/CMakeLists.txt +++ b/UnityCore/CMakeLists.txt @@ -1,5 +1,5 @@ find_package (PkgConfig) -pkg_check_modules (CORE_DEPS REQUIRED glib-2.0 gio-2.0 dee-1.0 sigc++-2.0 nux-core-3.0 gdk-pixbuf-2.0 unity-protocol-private) +pkg_check_modules (CORE_DEPS REQUIRED glib-2.0 gio-2.0 dee-1.0 sigc++-2.0 nux-core-4.0 gdk-pixbuf-2.0 unity-protocol-private) pkg_check_modules (PRIVATE_CORE_DEPS REQUIRED unity-protocol-private) execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} unity --variable lensesdir OUTPUT_VARIABLE _lensesdir OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/plugins/unity-mt-grab-handles/CMakeLists.txt b/plugins/unity-mt-grab-handles/CMakeLists.txt index 3020cf6a3..a9c7c694b 100644 --- a/plugins/unity-mt-grab-handles/CMakeLists.txt +++ b/plugins/unity-mt-grab-handles/CMakeLists.txt @@ -2,4 +2,4 @@ find_package (Compiz REQUIRED) include (CompizPlugin) -compiz_plugin (unitymtgrabhandles PKGDEPS nux-3.0>=3.0.0 PLUGINDEPS composite opengl CFLAGSADD -std=c++0x) +compiz_plugin (unitymtgrabhandles PKGDEPS nux-4.0>=4.0.0 PLUGINDEPS composite opengl CFLAGSADD -std=c++0x) -- cgit v1.2.3 From c96a5f3be951ca439e91d4b5d9bc5219c6f0dcaf Mon Sep 17 00:00:00 2001 From: Tim Penhey Date: Wed, 14 Nov 2012 12:03:47 +1300 Subject: Fix the headless tests. (bzr r2865.2.15) --- tests/CMakeLists.txt | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9851f8132..36b8183b3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -147,22 +147,36 @@ if (GTEST_SRC_DIR AND ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.cpp ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-layout.cpp ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp -) + ) -if (ENABLE_X_SUPPORT) - set (GTEST_XLESS_SOURCES - test_hud_private.cpp - test_pointer_barrier.cpp - test_shortcut_model.cpp - test_shortcut_private.cpp - ${LAUNCHER_SOURCES} + set (GTEST_XLESS_LIBS + gtest + unity-shared + launcher-lib + ${GMOCK_LIB} + ${GMOCK_MAIN_LIB} + ${LIBS} + ) + + if (ENABLE_X_SUPPORT) + set (GTEST_XLESS_SOURCES + test_hud_private.cpp + test_pointer_barrier.cpp + test_shortcut_model.cpp + test_shortcut_private.cpp + ${LAUNCHER_SOURCES} + ) + set (GTEST_XLESS_LIBS + ${GTEST_XLESS_LIBS} + shortcuts-lib + hud-lib ) -endif () + endif () add_executable(test-gtest-xless ${GTEST_XLESS_SOURCES}) + target_link_libraries(test-gtest-xless ${GTEST_XLESS_LIBS}) - target_link_libraries(test-gtest-xless gtest unity-shared ${GMOCK_LIB} ${GMOCK_MAIN_LIB} ${LIBS} launcher-lib) add_test(UnityGTestXless test-gtest-xless) add_dependencies(test-gtest-xless unity-core-${UNITY_API_VERSION} gtest) -- cgit v1.2.3 From 30764a139464f9f114f24b7a2cf1af1a2e5d62bd Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Tue, 13 Nov 2012 15:23:41 -0800 Subject: * Update the debian folder as well (bzr r2892.3.2) --- debian/changelog | 3 +++ debian/control | 4 ++-- debian/rules | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 112343668..8de67756c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,9 @@ unity (6.10.0-0ubuntu3) UNRELEASED; urgency=low - adding libgtest-dev and google-mock build-dep now that there are in main (LP: #1076763) + [ bschaefer ] + * Ported to nux 4.0 + -- Michael Terry Tue, 06 Nov 2012 10:52:43 -0500 unity (6.10.0-0ubuntu2) quantal-proposed; urgency=low diff --git a/debian/control b/debian/control index 6f90dc184..94f496090 100644 --- a/debian/control +++ b/debian/control @@ -27,7 +27,7 @@ Build-Depends: cmake, libunity-misc-dev (>= 4.0.4), libgrail-dev (>= 1.0.20), libxcb-icccm4-dev, - libnux-3.0-dev (>= 3.8.0), + libnux-4.0-dev (>= 4.0.0), compiz-dev (>= 1:0.9.8.4), libcompizconfig0-dev (>= 1:0.9.8.0), xsltproc, @@ -147,7 +147,7 @@ Depends: ${misc:Depends}, libunity-core-6.0-5 (= ${binary:Version}), libglib2.0-dev, libsigc++-2.0-dev, - libnux-3.0-dev (>= 3.0.0), + libnux-4.0-dev (>= 4.0.0), libunity-dev (>= 4.0.0~), libdee-dev, Description: Core library for the Unity interface - development files diff --git a/debian/rules b/debian/rules index 036ef78bb..d5278d6e4 100755 --- a/debian/rules +++ b/debian/rules @@ -14,7 +14,7 @@ export CXX=g++-4.6 CFLAGS=$(shell echo $$CFLAGS | sed -e 's/\-Wall//') CORE_ABIVERSION := $(shell sed -rn 's/^\#define[[:space:]]+CORE_ABIVERSION[[:space:]]+//p' /usr/include/compiz/core/abiversion.h ) -NUX_ABIVERSION := $(shell sed -rn 's/^\#define[[:space:]]+NUX_ABIVERSION[[:space:]]+//p' /usr/include/Nux-3.0/Nux/ABI.h ) +NUX_ABIVERSION := $(shell sed -rn 's/^\#define[[:space:]]+NUX_ABIVERSION[[:space:]]+//p' /usr/include/Nux-4.0/Nux/ABI.h ) LIBUNITY_PRIVATE := $(shell pkg-config --libs-only-L unity-protocol-private | sed -e 's/-L\(.*\)/\1/' ) -- cgit v1.2.3 From 04fe1ee955413b9bab77f96333de8f3224c87ba8 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 13 Nov 2012 21:49:35 -0500 Subject: enable tests during debian build (bzr r2892.1.1) --- debian/rules | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index 036ef78bb..af348f81d 100755 --- a/debian/rules +++ b/debian/rules @@ -4,6 +4,7 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH) +DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) gles2_architectures := armel armhf DEB_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ') @@ -50,7 +51,7 @@ override_dh_shlibdeps: dh_shlibdeps -l$(LIBUNITY_PRIVATE) -O--parallel override_dh_auto_test: - echo "not working right now" + make -C obj-$(DEB_HOST_GNU_TYPE) check-headless %: dh $@ --with translations,quilt,python2,migrations --parallel -- cgit v1.2.3 From 932ea08911ae5b0fb439b4a05d8355b3e93d63ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 14 Nov 2012 15:09:01 +0100 Subject: CMakeLists: move from one-line dependency string to multiline dependencies This avoids conflicts and improves readability. (bzr r2892.4.1) --- CMakeLists.txt | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5afe3c9ea..4255ba02b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,9 +145,55 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MAINTAINER_CXXFLAGS}") # Compiz Plugins # if(UNITY_ENABLE_X_ORG_SUPPORT) - set (UNITY_PLUGIN_DEPS "compiz>=0.9.8.0;nux-3.0>=3.0.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;gmodule-2.0;dbusmenu-glib-0.4;x11;libstartup-notification-1.0;gthread-2.0;indicator3-0.4>=0.4.90;atk;atk-bridge-2.0;unity-misc>=0.4.0;dbus-glib-1;gtk+-3.0>=3.1;sigc++-2.0;json-glib-1.0;libnotify;xfixes;unity-protocol-private>=5.95.1;libgeis;xrender>=0.9;zeitgeist-1.0>=0.3.18") + set(UNITY_PLUGIN_DEPS "compiz>=0.9.8.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};nux-3.0>=3.0.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libbamf3") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dee-1.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gio-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gio-unix-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gmodule-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dbusmenu-glib-0.4") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};x11") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libstartup-notification-1.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gthread-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};indicator3-0.4>=0.4.90") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};atk") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};atk-bridge-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};unity-misc>=0.4.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dbus-glib-1") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gtk+-3.0>=3.1") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};sigc++-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};json-glib-1.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libnotify") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};xfixes") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};unity-protocol-private>=5.95.1") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libgeis") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};xrender>=0.9") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};zeitgeist-1.0>=0.3.18") else () - set (UNITY_PLUGIN_DEPS "nux-3.0>=3.0.0;libbamf3;dee-1.0;gio-2.0;gio-unix-2.0;gmodule-2.0;dbusmenu-glib-0.4;libstartup-notification-1.0;gthread-2.0;indicator3-0.4>=0.4.90;atk;atk-bridge-2.0;unity-misc>=0.4.0;dbus-glib-1;gtk+-3.0>=3.1;sigc++-2.0;json-glib-1.0;libnotify;xfixes;unity-protocol-private>=5.95.1;libgeis;xrender>=0.9;zeitgeist-1.0>=0.3.18") + set(UNITY_PLUGIN_DEPS "nux-3.0>=3.0.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libbamf3") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dee-1.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gio-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gio-unix-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gmodule-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dbusmenu-glib-0.4") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libstartup-notification-1.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gthread-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};indicator3-0.4>=0.4.90") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};atk") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};atk-bridge-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};unity-misc>=0.4.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dbus-glib-1") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gtk+-3.0>=3.1") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};sigc++-2.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};json-glib-1.0") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libnotify") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};xfixes") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};unity-protocol-private>=5.95.1") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libgeis") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};xrender>=0.9") + set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};zeitgeist-1.0>=0.3.1") endif () set (UNITY_PROTOCOL_PRIVATE_DEPS "unity-protocol-private>=5.95.1") -- cgit v1.2.3 From fbe2a4ea1978271729c08b3deb1696260ca5df76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 14 Nov 2012 15:21:20 +0100 Subject: CMakeLists.txt: just use standard set syntax to define the proper dependencies (bzr r2892.4.3) --- CMakeLists.txt | 100 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dd24dba6..fedda7a8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,55 +145,59 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MAINTAINER_CXXFLAGS}") # Compiz Plugins # if(UNITY_ENABLE_X_ORG_SUPPORT) - set(UNITY_PLUGIN_DEPS "compiz>=0.9.8.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};nux-4.0>=4.0.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libbamf3") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dee-1.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gio-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gio-unix-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gmodule-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dbusmenu-glib-0.4") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};x11") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libstartup-notification-1.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gthread-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};indicator3-0.4>=0.4.90") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};atk") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};atk-bridge-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};unity-misc>=0.4.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dbus-glib-1") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gtk+-3.0>=3.1") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};sigc++-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};json-glib-1.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libnotify") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};xfixes") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};unity-protocol-private>=5.95.1") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libgeis") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};xrender>=0.9") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};zeitgeist-1.0>=0.3.18") + set(UNITY_PLUGIN_DEPS + compiz>=0.9.8.0 + nux-4.0>=4.0.0 + libbamf3 + dee-1.0 + gio-2.0 + gio-unix-2.0 + gmodule-2.0 + dbusmenu-glib-0.4 + x11 + libstartup-notification-1.0 + gthread-2.0 + indicator3-0.4>=0.4.90 + atk + atk-bridge-2.0 + unity-misc>=0.4.0 + dbus-glib-1 + gtk+-3.0>=3.1 + sigc++-2.0 + json-glib-1.0 + libnotify + xfixes + unity-protocol-private>=5.95.1 + libgeis + xrender>=0.9 + zeitgeist-1.0>=0.3.18 + ) else () - set(UNITY_PLUGIN_DEPS "nux-4.0>=4.0.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libbamf3") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dee-1.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gio-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gio-unix-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gmodule-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dbusmenu-glib-0.4") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libstartup-notification-1.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gthread-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};indicator3-0.4>=0.4.90") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};atk") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};atk-bridge-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};unity-misc>=0.4.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};dbus-glib-1") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};gtk+-3.0>=3.1") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};sigc++-2.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};json-glib-1.0") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libnotify") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};xfixes") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};unity-protocol-private>=5.95.1") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};libgeis") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};xrender>=0.9") - set(UNITY_PLUGIN_DEPS "${UNITY_PLUGIN_DEPS};zeitgeist-1.0>=0.3.1") + set(UNITY_PLUGIN_DEPS + nux-4.0>=4.0.0 + libbamf3 + dee-1.0 + gio-2.0 + gio-unix-2.0 + gmodule-2.0 + dbusmenu-glib-0.4 + libstartup-notification-1.0 + gthread-2.0 + indicator3-0.4>=0.4.90 + atk + atk-bridge-2.0 + unity-misc>=0.4.0 + dbus-glib-1 + gtk+-3.0>=3.1 + sigc++-2.0 + json-glib-1.0 + libnotify + xfixes + unity-protocol-private>=5.95.1 + libgeis + xrender>=0.9 + zeitgeist-1.0>=0.3.1 + ) endif () set (UNITY_PROTOCOL_PRIVATE_DEPS "unity-protocol-private>=5.95.1") -- cgit v1.2.3 From 21bdada816a58de6d5dbcc7df10b3d266bd8fec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 14 Nov 2012 15:43:41 +0100 Subject: CMakeLists.txt: remove the unneeded dbus-glib-1 dependency (bzr r2892.4.5) --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6d11a61e..4e749284b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,7 +172,6 @@ if(ENABLE_X_SUPPORT) atk atk-bridge-2.0 unity-misc>=0.4.0 - dbus-glib-1 gtk+-3.0>=3.1 sigc++-2.0 json-glib-1.0 @@ -198,7 +197,6 @@ else () atk atk-bridge-2.0 unity-misc>=0.4.0 - dbus-glib-1 gtk+-3.0>=3.1 sigc++-2.0 json-glib-1.0 -- cgit v1.2.3 From 4ce0e92b9cb92b978329f3937640c737e2948189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 14 Nov 2012 15:44:48 +0100 Subject: UnityCore/CMakeLists.txt: add multi-line dependencies to CMake (bzr r2892.4.6) --- UnityCore/CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/UnityCore/CMakeLists.txt b/UnityCore/CMakeLists.txt index 5070b4c78..93a3b4ec0 100644 --- a/UnityCore/CMakeLists.txt +++ b/UnityCore/CMakeLists.txt @@ -1,5 +1,14 @@ find_package (PkgConfig) -pkg_check_modules (CORE_DEPS REQUIRED glib-2.0 gio-2.0 dee-1.0 sigc++-2.0 nux-core-4.0 gdk-pixbuf-2.0 unity-protocol-private) +set(UNITY_CORE_DEPS + glib-2.0 + gio-2.0 + dee-1.0 + sigc++-2.0 + nux-core-3.0 + gdk-pixbuf-2.0 + unity-protocol-private +) +pkg_check_modules (CORE_DEPS REQUIRED ${UNITY_CORE_DEPS}) pkg_check_modules (PRIVATE_CORE_DEPS REQUIRED unity-protocol-private) execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} unity --variable lensesdir OUTPUT_VARIABLE _lensesdir OUTPUT_STRIP_TRAILING_WHITESPACE) -- cgit v1.2.3 From a1b7cf8df347f5cfab785eeb1985622b5eceb69d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 14 Nov 2012 15:51:00 +0100 Subject: CMakeLists.txt: factorize the protocol private dependency string (bzr r2892.4.7) --- CMakeLists.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e749284b..b49d77922 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ add_custom_target (pre-distcheck && bzr tag ${UNITY_VERSION} && echo "• Running Distcheck" ) - + add_custom_target (dist COMMAND bzr export --root=${ARCHIVE_NAME} ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} @@ -155,8 +155,11 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MAINTAINER_CXXFLAGS}") # # Compiz Plugins # +set (UNITY_PROTOCOL_PRIVATE_DEPS "unity-protocol-private>=5.95.1") + if(ENABLE_X_SUPPORT) set(UNITY_PLUGIN_DEPS + ${UNITY_PROTOCOL_PRIVATE_DEPS} compiz>=0.9.8.0 nux-4.0>=4.0.0 libbamf3 @@ -177,13 +180,13 @@ if(ENABLE_X_SUPPORT) json-glib-1.0 libnotify xfixes - unity-protocol-private>=5.95.1 libgeis xrender>=0.9 zeitgeist-1.0>=0.3.18 ) else () set(UNITY_PLUGIN_DEPS + ${UNITY_PROTOCOL_PRIVATE_DEPS} nux-4.0>=4.0.0 libbamf3 dee-1.0 @@ -202,16 +205,12 @@ else () json-glib-1.0 libnotify xfixes - unity-protocol-private>=5.95.1 libgeis xrender>=0.9 zeitgeist-1.0>=0.3.1 ) endif () -set (UNITY_PROTOCOL_PRIVATE_DEPS "unity-protocol-private>=5.95.1") - - find_package (PkgConfig) pkg_check_modules (CACHED_UNITY_DEPS REQUIRED ${UNITY_PLUGIN_DEPS}) pkg_check_modules (CACHED_UNITY_PRIVATE_DEPS REQUIRED ${UNITY_PROTOCOL_PRIVATE_DEPS}) -- cgit v1.2.3 From 1acf3fc420867100ff16e262bce22ce54a1961c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 14 Nov 2012 15:54:06 +0100 Subject: UnityCore/CMakeLists.txt: ops, set back the dependency to nux-core-4.0 (bzr r2892.4.8) --- UnityCore/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnityCore/CMakeLists.txt b/UnityCore/CMakeLists.txt index 93a3b4ec0..2a7df66ac 100644 --- a/UnityCore/CMakeLists.txt +++ b/UnityCore/CMakeLists.txt @@ -4,7 +4,7 @@ set(UNITY_CORE_DEPS gio-2.0 dee-1.0 sigc++-2.0 - nux-core-3.0 + nux-core-4.0 gdk-pixbuf-2.0 unity-protocol-private ) -- cgit v1.2.3 From 86f6a234b215958b147387f5cddd133bbc408bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 14 Nov 2012 16:09:22 +0100 Subject: CMakeLists.txt: don't duplicate dependencies, just use a shared variable (bzr r2892.4.9) --- CMakeLists.txt | 76 ++++++++++++++++++++++------------------------------------ 1 file changed, 28 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b49d77922..a1c31f791 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,59 +155,39 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MAINTAINER_CXXFLAGS}") # # Compiz Plugins # -set (UNITY_PROTOCOL_PRIVATE_DEPS "unity-protocol-private>=5.95.1") +set(UNITY_PROTOCOL_PRIVATE_DEPS unity-protocol-private>=5.95.1) +set(UNITY_PLUGIN_SHARED_DEPS + ${UNITY_PROTOCOL_PRIVATE_DEPS} + nux-4.0>=4.0.0 + libbamf3 + dee-1.0 + gio-2.0 + gio-unix-2.0 + gmodule-2.0 + dbusmenu-glib-0.4 + libstartup-notification-1.0 + gthread-2.0 + indicator3-0.4>=0.4.90 + atk + atk-bridge-2.0 + unity-misc>=0.4.0 + gtk+-3.0>=3.1 + sigc++-2.0 + json-glib-1.0 + libnotify + xfixes + libgeis + xrender>=0.9 + zeitgeist-1.0>=0.3.18 +) + +set(UNITY_PLUGIN_DEPS ${UNITY_PLUGIN_SHARED_DEPS}) if(ENABLE_X_SUPPORT) set(UNITY_PLUGIN_DEPS - ${UNITY_PROTOCOL_PRIVATE_DEPS} + ${UNITY_PLUGIN_DEPS} compiz>=0.9.8.0 - nux-4.0>=4.0.0 - libbamf3 - dee-1.0 - gio-2.0 - gio-unix-2.0 - gmodule-2.0 - dbusmenu-glib-0.4 x11 - libstartup-notification-1.0 - gthread-2.0 - indicator3-0.4>=0.4.90 - atk - atk-bridge-2.0 - unity-misc>=0.4.0 - gtk+-3.0>=3.1 - sigc++-2.0 - json-glib-1.0 - libnotify - xfixes - libgeis - xrender>=0.9 - zeitgeist-1.0>=0.3.18 - ) -else () - set(UNITY_PLUGIN_DEPS - ${UNITY_PROTOCOL_PRIVATE_DEPS} - nux-4.0>=4.0.0 - libbamf3 - dee-1.0 - gio-2.0 - gio-unix-2.0 - gmodule-2.0 - dbusmenu-glib-0.4 - libstartup-notification-1.0 - gthread-2.0 - indicator3-0.4>=0.4.90 - atk - atk-bridge-2.0 - unity-misc>=0.4.0 - gtk+-3.0>=3.1 - sigc++-2.0 - json-glib-1.0 - libnotify - xfixes - libgeis - xrender>=0.9 - zeitgeist-1.0>=0.3.1 ) endif () -- cgit v1.2.3 From a36463cc1dd1497342dbadda7e547efd1020275c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 15 Nov 2012 01:01:25 +0100 Subject: CMakeLists.txt: sort dependencies in alhabetical order, move to x-only unneeded shared dependencies (bzr r2892.4.11) --- CMakeLists.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1c31f791..d2ccf1daf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,26 +158,23 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MAINTAINER_CXXFLAGS}") set(UNITY_PROTOCOL_PRIVATE_DEPS unity-protocol-private>=5.95.1) set(UNITY_PLUGIN_SHARED_DEPS ${UNITY_PROTOCOL_PRIVATE_DEPS} - nux-4.0>=4.0.0 - libbamf3 + atk + atk-bridge-2.0 + dbusmenu-glib-0.4 dee-1.0 gio-2.0 gio-unix-2.0 gmodule-2.0 - dbusmenu-glib-0.4 - libstartup-notification-1.0 gthread-2.0 - indicator3-0.4>=0.4.90 - atk - atk-bridge-2.0 - unity-misc>=0.4.0 gtk+-3.0>=3.1 - sigc++-2.0 + indicator3-0.4>=0.4.90 json-glib-1.0 + libbamf3 libnotify - xfixes - libgeis - xrender>=0.9 + libstartup-notification-1.0 + nux-4.0>=4.0.0 + sigc++-2.0 + unity-misc>=0.4.0 zeitgeist-1.0>=0.3.18 ) @@ -187,7 +184,10 @@ if(ENABLE_X_SUPPORT) set(UNITY_PLUGIN_DEPS ${UNITY_PLUGIN_DEPS} compiz>=0.9.8.0 + libgeis x11 + xfixes + xrender>=0.9 ) endif () -- cgit v1.2.3