summaryrefslogtreecommitdiff
diff options
-rw-r--r--CMakeLists.txt103
-rw-r--r--UnityCore/CMakeLists.txt3
-rw-r--r--UnityCore/DBusIndicators.cpp2
-rw-r--r--UnityCore/GnomeSessionManager.cpp99
-rw-r--r--UnityCore/GnomeSessionManagerImpl.h2
-rw-r--r--UnityCore/Variant.cpp30
-rw-r--r--UnityCore/Variant.h1
-rw-r--r--config.h.cmake5
-rw-r--r--dash/FilterExpanderLabel.cpp8
-rw-r--r--dash/FilterExpanderLabel.h1
-rw-r--r--data/CMakeLists.txt44
-rw-r--r--data/com.canonical.Unity.gschema.xml (renamed from com.canonical.Unity.gschema.xml)0
-rw-r--r--data/unity7.conf.in13
-rw-r--r--data/unity7.override1
-rw-r--r--data/unity7.service.in15
-rw-r--r--debian/changelog193
-rw-r--r--debian/control28
-rw-r--r--debian/libunity-core-6.0-9.install5
-rw-r--r--debian/unity-services.install5
-rw-r--r--debian/unity-services.links14
-rw-r--r--debian/unity.install5
-rw-r--r--debian/unity.links1
-rw-r--r--debian/unity7.conf27
-rw-r--r--decorations/CMakeLists.txt1
-rw-r--r--decorations/DecoratedWindow.cpp145
-rw-r--r--decorations/DecoratedWindow.h2
-rw-r--r--decorations/DecorationsForceQuitDialog.cpp20
-rw-r--r--decorations/DecorationsManager.cpp2
-rw-r--r--decorations/DecorationsMenuLayout.cpp68
-rw-r--r--decorations/DecorationsMenuLayout.h5
-rw-r--r--decorations/DecorationsPriv.h12
-rw-r--r--decorations/DecorationsShape.cpp107
-rw-r--r--decorations/DecorationsShape.h54
-rw-r--r--decorations/DecorationsWindowButton.cpp47
-rw-r--r--decorations/DecorationsWindowButton.h3
-rw-r--r--launcher/DeviceNotificationDisplay.h2
-rw-r--r--launcher/DeviceNotificationDisplayImp.cpp30
-rw-r--r--launcher/DeviceNotificationDisplayImp.h2
-rw-r--r--launcher/EdgeBarrierController.cpp141
-rw-r--r--launcher/EdgeBarrierControllerPrivate.h7
-rw-r--r--launcher/FileManagerLauncherIcon.cpp36
-rw-r--r--launcher/FileManagerLauncherIcon.h8
-rw-r--r--launcher/LauncherOptions.cpp44
-rw-r--r--launcher/StorageLauncherIcon.cpp19
-rw-r--r--launcher/SwitcherController.cpp5
-rw-r--r--launcher/SwitcherView.cpp11
-rw-r--r--launcher/TrashLauncherIcon.cpp34
-rw-r--r--launcher/VolumeLauncherIcon.cpp2
-rw-r--r--lockscreen/KylinLockScreenShield.cpp20
-rw-r--r--lockscreen/KylinLockScreenShield.h3
-rw-r--r--lockscreen/LockScreenAcceleratorController.cpp14
-rw-r--r--lockscreen/LockScreenBaseShield.cpp20
-rw-r--r--lockscreen/LockScreenBaseShield.h10
-rw-r--r--lockscreen/LockScreenController.cpp86
-rw-r--r--lockscreen/LockScreenController.h8
-rw-r--r--lockscreen/LockScreenPanel.cpp81
-rw-r--r--lockscreen/LockScreenPanel.h14
-rw-r--r--lockscreen/LockScreenShield.cpp25
-rw-r--r--lockscreen/LockScreenShield.h7
-rw-r--r--lockscreen/LockScreenShieldFactory.cpp4
-rw-r--r--lockscreen/LockScreenShieldFactory.h6
-rw-r--r--lockscreen/UserAuthenticatorPam.cpp5
-rw-r--r--panel/PanelIndicatorEntryView.cpp10
-rw-r--r--panel/PanelMenuView.cpp10
-rw-r--r--panel/PanelMenuView.h2
-rw-r--r--panel/PanelView.cpp127
-rw-r--r--panel/PanelView.h15
-rw-r--r--plugins/unityshell/src/unityshell.cpp77
-rw-r--r--plugins/unityshell/src/unityshell.h8
-rw-r--r--plugins/unityshell/unityshell.xml.in2
-rw-r--r--resources/dash_bottom_right_corner_rotated.pngbin1457 -> 0 bytes
-rw-r--r--resources/dash_bottom_right_corner_rotated_mask.pngbin1038 -> 0 bytes
-rw-r--r--resources/dash_bottom_tile.pngbin1008 -> 0 bytes
-rw-r--r--resources/dash_top_border_tile.pngbin1036 -> 0 bytes
-rw-r--r--resources/dash_top_border_tile_mask.pngbin936 -> 0 bytes
-rw-r--r--resources/dash_top_left_corner.pngbin1459 -> 0 bytes
-rw-r--r--resources/dash_top_left_corner_mask.pngbin1060 -> 0 bytes
-rw-r--r--resources/dash_top_right_corner_rotated.pngbin1871 -> 0 bytes
-rw-r--r--resources/dash_top_right_corner_rotated_mask.pngbin1045 -> 0 bytes
-rw-r--r--resources/overlay_top_left_tile.pngbin0 -> 468 bytes
-rw-r--r--services/CMakeLists.txt35
-rw-r--r--services/panel-service.c88
-rw-r--r--services/unity-panel-service-lockscreen.conf.in4
-rw-r--r--services/unity-panel-service-lockscreen.override1
-rw-r--r--services/unity-panel-service-lockscreen.service.in8
-rw-r--r--services/unity-panel-service.conf.in4
-rw-r--r--services/unity-panel-service.override1
-rw-r--r--services/unity-panel-service.service.in10
-rw-r--r--services/unity-screen-locked.target5
-rw-r--r--shutdown/SessionView.cpp8
-rw-r--r--tests/CMakeLists.txt42
-rw-r--r--tests/autopilot/unity/tests/test_dash.py8
-rw-r--r--tests/test-gestures/CMakeLists.txt4
-rw-r--r--tests/test-gestures/test_gesture_broker.cpp6
-rw-r--r--tests/test_action_handle.cpp24
-rw-r--r--tests/test_animation_utils.cpp8
-rw-r--r--tests/test_application_launcher_icon.cpp8
-rw-r--r--tests/test_bamf_application.cpp6
-rw-r--r--tests/test_categories.cpp6
-rw-r--r--tests/test_connection_manager.cpp20
-rw-r--r--tests/test_dashview.cpp2
-rw-r--r--tests/test_dashview_impl.cpp6
-rw-r--r--tests/test_dbus_indicators.cpp8
-rw-r--r--tests/test_decorations_input_mixer.cpp14
-rw-r--r--tests/test_decorations_widgets.cpp10
-rw-r--r--tests/test_delta_tracker.cpp12
-rw-r--r--tests/test_desktop_launcher_icon.cpp2
-rw-r--r--tests/test_device_launcher_section.cpp2
-rw-r--r--tests/test_edge_barrier_controller.cpp2
-rw-r--r--tests/test_favorite_store_gsettings.cpp10
-rw-r--r--tests/test_favorite_store_private.cpp8
-rw-r--r--tests/test_file_manager_launcher_icon.cpp202
-rw-r--r--tests/test_filter_widgets.cpp2
-rw-r--r--tests/test_glib_dbus_object.cpp4
-rw-r--r--tests/test_glib_dbus_server.cpp26
-rw-r--r--tests/test_glib_object.cpp20
-rw-r--r--tests/test_glib_signals.cpp6
-rw-r--r--tests/test_glib_source.cpp90
-rw-r--r--tests/test_glib_variant.cpp18
-rw-r--r--tests/test_gnome_session_manager.cpp11
-rw-r--r--tests/test_grabhandle.cpp4
-rw-r--r--tests/test_gsettings_scopes.cpp64
-rw-r--r--tests/test_hud_button.cpp4
-rw-r--r--tests/test_hud_private.cpp12
-rw-r--r--tests/test_hud_view.cpp2
-rw-r--r--tests/test_indicator.cpp12
-rw-r--r--tests/test_indicator_appmenu.cpp6
-rw-r--r--tests/test_indicator_entry.cpp6
-rw-r--r--tests/test_indicators.cpp22
-rw-r--r--tests/test_introspection_data.cpp80
-rw-r--r--tests/test_keyboard_util.cpp8
-rw-r--r--tests/test_launcher_controller.cpp23
-rw-r--r--tests/test_launcher_model.cpp12
-rw-r--r--tests/test_layout_system.cpp18
-rw-r--r--tests/test_lockscreen_controller.cpp23
-rw-r--r--tests/test_mock_devices.h2
-rw-r--r--tests/test_panel_controller.cpp8
-rw-r--r--tests/test_panel_indicator_entry_dropdown_view.cpp20
-rw-r--r--tests/test_panel_view.cpp2
-rw-r--r--tests/test_pointer_barrier.cpp4
-rw-r--r--tests/test_previews.cpp4
-rw-r--r--tests/test_previews_application.cpp2
-rw-r--r--tests/test_previews_generic.cpp2
-rw-r--r--tests/test_previews_movie.cpp2
-rw-r--r--tests/test_previews_music.cpp2
-rw-r--r--tests/test_previews_social.cpp2
-rw-r--r--tests/test_quicklist_view.cpp2
-rw-r--r--tests/test_results.cpp20
-rw-r--r--tests/test_scope.cpp12
-rw-r--r--tests/test_scope_view.cpp24
-rw-r--r--tests/test_session_view.cpp8
-rw-r--r--tests/test_shortcut_model.cpp8
-rw-r--r--tests/test_shortcut_view.cpp6
-rw-r--r--tests/test_switcher_controller_slow.cpp10
-rw-r--r--tests/test_systemd_wrapper.cpp110
-rw-r--r--tests/test_texture_cache.cpp4
-rw-r--r--tests/test_trash_launcher_icon.cpp12
-rw-r--r--tests/test_ubus.cpp12
-rw-r--r--tests/test_unity_window_style.cpp6
-rw-r--r--tests/test_unity_window_view.cpp6
-rw-r--r--tests/test_volume_launcher_icon.cpp12
-rw-r--r--tests/test_xdnd_start_stop_notifier_imp.cpp22
-rw-r--r--tools/CMakeLists.txt30
-rwxr-xr-xtools/compiz-profile-selector.in19
-rw-r--r--tools/systemd-prestart-check29
-rwxr-xr-xtools/unity.cmake86
-rw-r--r--tools/unity_active_plugins_safety_check.cpp83
-rw-r--r--tools/upstart-prestart-check17
-rw-r--r--unity-shared/CMakeLists.txt3
-rw-r--r--unity-shared/CompizUtils.cpp7
-rw-r--r--unity-shared/CompizUtils.h3
-rwxr-xr-xunity-shared/DashStyle.cpp90
-rwxr-xr-xunity-shared/DashStyle.h26
-rw-r--r--unity-shared/DecorationStyle.cpp7
-rw-r--r--unity-shared/GnomeFileManager.cpp6
-rw-r--r--unity-shared/InputMonitor.cpp420
-rw-r--r--unity-shared/InputMonitor.h67
-rw-r--r--unity-shared/MenuManager.cpp163
-rw-r--r--unity-shared/MenuManager.h4
-rw-r--r--unity-shared/OverlayRenderer.cpp155
-rw-r--r--unity-shared/PluginAdapter.cpp4
-rw-r--r--unity-shared/SigcSlotHash.h70
-rw-r--r--unity-shared/SpreadWidgets.cpp195
-rw-r--r--unity-shared/SpreadWidgets.h48
-rw-r--r--unity-shared/StandaloneWindowManager.cpp3
-rw-r--r--unity-shared/StandaloneWindowManager.h1
-rw-r--r--unity-shared/SystemdWrapper.cpp96
-rw-r--r--unity-shared/SystemdWrapper.h54
-rw-r--r--unity-shared/TextInput.cpp19
-rw-r--r--unity-shared/TextInput.h1
-rw-r--r--unity-shared/UScreen.cpp10
-rw-r--r--unity-shared/UScreen.h2
-rw-r--r--unity-shared/UnitySettings.cpp54
-rw-r--r--unity-shared/UnityWindowView.cpp7
-rw-r--r--unity-shared/UpstartWrapper.cpp17
-rw-r--r--unity-shared/WindowButtons.cpp15
-rw-r--r--unity-shared/WindowManager.h1
-rw-r--r--unity-shared/XWindowManager.cpp6
-rw-r--r--unity-shared/XWindowManager.h1
199 files changed, 3759 insertions, 1397 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e97af92b..03bbea326 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -158,14 +158,15 @@ add_dependencies (release distcheck)
#
set (VERSION "${UNITY_VERSION}")
set (PREFIXPATH "${CMAKE_INSTALL_PREFIX}")
-set (UNITYLIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}")
-set (UNITYDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}")
-set (PKGDATADIR "${UNITYDATADIR}/icons")
+set (UNITY_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}")
+set (UNITY_DATADIR "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}")
+set (UNITY_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}")
+set (PKGDATADIR "${UNITY_DATADIR}/icons")
set (SOURCEDATADIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
set (BUILDDIR "${CMAKE_BINARY_DIR}")
set (TESTDATADIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/data")
set (LOCALE_DIR "${CMAKE_INSTALL_FULL_LOCALEDIR}")
-# specify the domain directly rather than refering to a variable
+# specify the domain directly rather than refering to a variable
# like ${PROJECT_NAME} to no confuse dh_translations
set (GETTEXT_PACKAGE "unity")
@@ -182,7 +183,6 @@ configure_file (${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
#
# i18n
#
-
find_package (Gettext REQUIRED)
set (COMPIZ_I18N_DIR ${CMAKE_SOURCE_DIR}/po)
@@ -203,13 +203,13 @@ endif()
#
# Enable or disable boot logging
-#
+#
option (BOOT_LOGGER "Enable startup performance logging" OFF)
if (BOOT_LOGGER)
SET (BOOT_LOGGER_FLAG "-DENABLE_LOGGER")
endif (BOOT_LOGGER)
-SET (MAINTAINER_CXXFLAGS "-Werror -Wall -Wcast-align -Wempty-body -Wformat-security -Winit-self -Warray-bounds")
+SET (MAINTAINER_CXXFLAGS "-Werror -Wall -Wcast-align -Wempty-body -Wformat-security -Winit-self -Warray-bounds -Wno-error=deprecated-declarations")
option (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS "Disable errors when local typedefs are unused" ON)
if (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)
@@ -248,7 +248,7 @@ set(UNITY_PLUGIN_SHARED_DEPS
libnotify
libstartup-notification-1.0
nux-4.0>=4.0.5
- sigc++-2.0
+ sigc++-2.0>=2.4.0
unity-misc>=0.4.0
xpathselect=1.4
zeitgeist-2.0
@@ -259,7 +259,7 @@ set(UNITY_PLUGIN_DEPS ${UNITY_PLUGIN_SHARED_DEPS})
if(ENABLE_X_SUPPORT)
set(UNITY_PLUGIN_DEPS
${UNITY_PLUGIN_DEPS}
- compiz>=0.9.9
+ compiz>=0.9.11
libgeis
x11
xfixes
@@ -304,56 +304,7 @@ add_subdirectory(guides)
add_subdirectory(gnome)
if (ENABLE_UNIT_TESTS)
- # Check for google test and build it locally
- set (
- GMOCK_ROOT_DIR
- "/usr/src/gmock"
- CACHE
- PATH
- "Path to Google mock srcs"
- )
-
- set (
- GMOCK_INCLUDE_DIR
- "/usr/include/gmock/include"
- CACHE
- PATH
- "Path to Google mock include"
- )
-
- set(
- GTEST_ROOT_DIR
- "${GMOCK_ROOT_DIR}/gtest" # Default value, adjustable by user with e.g., ccmake
- CACHE
- PATH
- "Path to Google test srcs"
- )
-
- set(
- GTEST_INCLUDE_DIR
- "${GMOCK_ROOT_DIR}/gtest/include"
- CACHE
- PATH
- "Path to Google tests include"
- )
-
- if (GTEST_INCLUDE_DIR AND GMOCK_INCLUDE_DIR)
- include_directories (
- ${GMOCK_INCLUDE_DIR}
- ${GTEST_INCLUDE_DIR}
- )
- add_subdirectory(
- ${GMOCK_ROOT_DIR}
- "${CMAKE_CURRENT_BINARY_DIR}/gmock"
- )
- elseif (GTEST_INCLUDE_DIR AND NOT GMOCK_INCLUDE_DIR)
- include_directories (
- ${GTEST_INCLUDE_DIR}
- )
- endif(GTEST_INCLUDE_DIR AND GMOCK_INCLUDE_DIR)
-
add_subdirectory(tests)
-
else (ENABLE_UNIT_TESTS)
set (MISSING_TESTS_MSG "-- Tests disabled, compile with -DENABLE_UNIT_TESTS=ON")
add_custom_target (check COMMAND echo ${MISSING_TESTS_MSG})
@@ -361,46 +312,11 @@ else (ENABLE_UNIT_TESTS)
add_custom_target (gcheck COMMAND echo ${MISSING_TESTS_MSG})
endif (ENABLE_UNIT_TESTS)
-#
-# GSettings Schema
-#
-SET (UNITY_SCHEMAS "com.canonical.Unity.gschema.xml")
-SET (UNITY_TEST_SCHEMAS "external.gschema.xml")
-
-# Have an option to not install the schema into where GLib is
-option (GSETTINGS_LOCALINSTALL "Install GSettings Schemas locally instead of to the GLib prefix" OFF)
-if (GSETTINGS_LOCALINSTALL)
- SET (GSETTINGS_DIR "${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas/")
-else (GSETTINGS_LOCALINSTALL)
- execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} glib-2.0 --variable prefix OUTPUT_VARIABLE _glib_prefix OUTPUT_STRIP_TRAILING_WHITESPACE)
- SET (GSETTINGS_DIR "${_glib_prefix}/share/glib-2.0/schemas/")
-endif (GSETTINGS_LOCALINSTALL)
-
-# Run the validator and error if it fails
-execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_comple_schemas OUTPUT_STRIP_TRAILING_WHITESPACE)
-execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${CMAKE_CURRENT_SOURCE_DIR}/${UNITY_SCHEMAS} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-if (_schemas_invalid)
- message (SEND_ERROR "Schema validation error: ${_schemas_invalid}")
-endif (_schemas_invalid)
-
-# Actually install and recomple schemas
-message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}")
-install (FILES ${UNITY_SCHEMAS} DESTINATION ${GSETTINGS_DIR} OPTIONAL)
-install (CODE "message (STATUS \"Compiling GSettings schemas\")")
-install (CODE "execute_process (COMMAND ${_glib_comple_schemas} ${GSETTINGS_DIR})")
-
# Resources
install (FILES resources/dash-widgets.json DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/themes)
file (GLOB _datafiles "${CMAKE_CURRENT_SOURCE_DIR}/resources/*")
install (FILES ${_datafiles} DESTINATION ${PKGDATADIR})
-
-# For testing
-configure_file (${CMAKE_SOURCE_DIR}/${UNITY_SCHEMAS} ${CMAKE_BINARY_DIR}/settings/${UNITY_SCHEMAS})
-configure_file (${CMAKE_SOURCE_DIR}/tests/data/${UNITY_TEST_SCHEMAS} ${CMAKE_BINARY_DIR}/settings/${UNITY_TEST_SCHEMAS})
-execute_process (COMMAND ${_glib_comple_schemas} ${CMAKE_BINARY_DIR}/settings)
-
#
# docs
#
@@ -425,3 +341,4 @@ if (DOXYGEN_FOUND STREQUAL "YES")
ADDITIONAL_MAKE_CLEAN_FILES api-doc)
endif (DOXYGEN_FOUND STREQUAL "YES")
+
diff --git a/UnityCore/CMakeLists.txt b/UnityCore/CMakeLists.txt
index 0693f7e67..9aad8c6b9 100644
--- a/UnityCore/CMakeLists.txt
+++ b/UnityCore/CMakeLists.txt
@@ -145,7 +145,8 @@ target_link_libraries (${CORE_LIB_NAME} ${LIBS})
set_target_properties(${CORE_LIB_NAME} PROPERTIES
VERSION ${CORE_LIB_LT_CURRENT}.${CORE_LIB_LT_REV}.${CORE_LIB_LT_AGE}
SOVERSION ${CORE_LIB_LT_CURRENT}
- INSTALL_RPATH "${PRIVATE_CORE_DEPS_LIBRARY_DIRS}")
+ INSTALL_RPATH "${PRIVATE_CORE_DEPS_LIBRARY_DIRS}"
+ BUILD_WITH_INSTALL_RPATH TRUE)
add_pch(pch/unitycore_pch.hh ${CORE_LIB_NAME})
install (TARGETS ${CORE_LIB_NAME}
diff --git a/UnityCore/DBusIndicators.cpp b/UnityCore/DBusIndicators.cpp
index 6021418f2..b9c17e105 100644
--- a/UnityCore/DBusIndicators.cpp
+++ b/UnityCore/DBusIndicators.cpp
@@ -123,7 +123,7 @@ void DBusIndicators::Impl::CheckLocalService()
// This is obviously hackish, but this part of the code is mostly hackish...
// Let's attempt to run it from where we expect it to be
- std::string cmd = UNITYLIBDIR"/" + std::string("unity-panel-service");
+ std::string cmd = UNITY_LIBDIR"/" + std::string("unity-panel-service");
LOG_WARN(logger) << "Couldn't load panel from installed services, "
<< "so trying to load panel from known location: " << cmd;
diff --git a/UnityCore/GnomeSessionManager.cpp b/UnityCore/GnomeSessionManager.cpp
index 5fd29409e..b739b3663 100644
--- a/UnityCore/GnomeSessionManager.cpp
+++ b/UnityCore/GnomeSessionManager.cpp
@@ -77,6 +77,8 @@ const std::string SUPPRESS_DIALOGS_KEY = "suppress-logout-restart-shutdown";
const std::string GNOME_LOCKDOWN_OPTIONS = "org.gnome.desktop.lockdown";
const std::string DISABLE_LOCKSCREEN_KEY = "disable-lock-screen";
+
+GDBusProxyFlags DEFAULT_CALL_FLAGS = static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS|G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION);
}
GnomeManager::Impl::Impl(GnomeManager* manager, bool test_mode)
@@ -99,38 +101,45 @@ GnomeManager::Impl::Impl(GnomeManager* manager, bool test_mode)
});
{
- const char* session_id = test_mode_ ? "id0" : g_getenv("XDG_SESSION_ID");
+ std::string session_id = test_mode_ ? "id0" : glib::gchar_to_string(g_getenv("XDG_SESSION_ID"));
- login_proxy_ = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.login1",
- "/org/freedesktop/login1/session/" + glib::gchar_to_string(session_id),
- "org.freedesktop.login1.Session",
- test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES);
+ if (!session_id.empty())
+ {
+ CallLogindMethod("GetSession", g_variant_new("(s)", session_id.c_str()), [this, session_id] (GVariant* variant, glib::Error const& err) {
+ std::string session_path;
- login_proxy_->Connect("Lock", [this](GVariant*){
- manager_->PromptLockScreen();
- });
+ if (!err && variant)
+ session_path = glib::Variant(variant).GetObjectPath();
- login_proxy_->Connect("Unlock", [this](GVariant*){
- manager_->unlock_requested.emit();
- });
+ if (session_path.empty())
+ session_path = "/org/freedesktop/login1/session/" + session_id;
- login_proxy_->ConnectProperty("Active", [this] (GVariant* variant) {
- bool active = glib::Variant(variant).GetBool();
- manager_->is_session_active.changed.emit(active);
- if (active)
- manager_->screensaver_requested.emit(false);
- });
+ SetupLogin1Proxy(session_path);
+ });
+ }
+ else
+ {
+ auto proxy = std::make_shared<glib::DBusProxy>("org.freedesktop.login1",
+ "/org/freedesktop/login1/user/self",
+ "org.freedesktop.login1.User",
+ G_BUS_TYPE_SYSTEM);
- manager_->is_session_active.SetGetterFunction([this] {
- return login_proxy_->GetProperty("Active").GetBool();
- });
+ proxy->GetProperty("Display", [this, proxy] (GVariant *variant) {
+ if (!variant || g_variant_n_children(variant) < 2)
+ return;
+
+ glib::Variant tmp(g_variant_get_child_value(variant, 1), glib::StealRef());
+ SetupLogin1Proxy(tmp.GetObjectPath());
+ });
+ }
}
{
presence_proxy_ = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.gnome.SessionManager",
"/org/gnome/SessionManager/Presence",
- "org.gnome.SessionManager.Presence");
+ "org.gnome.SessionManager.Presence",
+ G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES);
presence_proxy_->Connect("StatusChanged", [this](GVariant* variant) {
enum class PresenceStatus : unsigned
@@ -166,7 +175,8 @@ GnomeManager::Impl::Impl(GnomeManager* manager, bool test_mode)
dm_seat_proxy_ = std::make_shared<glib::DBusProxy>("org.freedesktop.Accounts",
("/org/freedesktop/Accounts/User" + std::to_string(getuid())).c_str(),
"org.freedesktop.Accounts.User",
- G_BUS_TYPE_SYSTEM);
+ G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS);
}
CallLogindMethod("CanHibernate", nullptr, [this] (GVariant* variant, glib::Error const& err) {
@@ -216,6 +226,34 @@ GnomeManager::Impl::~Impl()
ClosedDialog();
}
+void GnomeManager::Impl::SetupLogin1Proxy(std::string const& session_path)
+{
+ login_proxy_ = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.login1",
+ session_path,
+ "org.freedesktop.login1.Session",
+ test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES);
+
+ login_proxy_->Connect("Lock", [this](GVariant*){
+ manager_->PromptLockScreen();
+ });
+
+ login_proxy_->Connect("Unlock", [this](GVariant*){
+ manager_->unlock_requested.emit();
+ });
+
+ login_proxy_->ConnectProperty("Active", [this] (GVariant* variant) {
+ bool active = glib::Variant(variant).GetBool();
+ manager_->is_session_active.changed.emit(active);
+ if (active)
+ manager_->screensaver_requested.emit(false);
+ });
+
+ manager_->is_session_active.SetGetterFunction([this] {
+ return login_proxy_->GetProperty("Active").GetBool();
+ });
+}
+
bool GnomeManager::Impl::InteractiveMode()
{
bool schema_found = false;
@@ -374,7 +412,8 @@ void GnomeManager::Impl::CallGnomeSessionMethod(std::string const& method, GVari
glib::DBusProxy::CallFinishedCallback const& cb)
{
auto proxy = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.gnome.SessionManager",
- "/org/gnome/SessionManager", "org.gnome.SessionManager");
+ "/org/gnome/SessionManager", "org.gnome.SessionManager",
+ G_BUS_TYPE_SESSION, DEFAULT_CALL_FLAGS);
// By passing the proxy to the lambda we ensure that it will be smartly handled
proxy->CallBegin(method, parameters, [proxy, cb] (GVariant* ret, glib::Error const& e) {
@@ -392,7 +431,8 @@ void GnomeManager::Impl::CallUPowerMethod(std::string const& method, glib::DBusP
{
auto proxy = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.UPower",
"/org/freedesktop/UPower", "org.freedesktop.UPower",
- test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM);
+ test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,
+ DEFAULT_CALL_FLAGS);
proxy->CallBegin(method, nullptr, [proxy, cb] (GVariant *ret, glib::Error const& e) {
if (e)
@@ -411,7 +451,8 @@ void GnomeManager::Impl::CallLogindMethod(std::string const& method, GVariant* p
auto proxy = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
- test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM);
+ test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,
+ DEFAULT_CALL_FLAGS);
// By passing the proxy to the lambda we ensure that it will be smartly handled
proxy->CallBegin(method, parameters, [proxy, cb, method] (GVariant* ret, glib::Error const& e) {
@@ -432,7 +473,8 @@ void GnomeManager::Impl::CallConsoleKitMethod(std::string const& method, GVarian
auto proxy = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.ConsoleKit",
"/org/freedesktop/ConsoleKit/Manager",
"org.freedesktop.ConsoleKit.Manager",
- test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM);
+ test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,
+ DEFAULT_CALL_FLAGS);
// By passing the proxy to the lambda we ensure that it will be smartly handled
proxy->CallBegin(method, parameters, [this, proxy] (GVariant*, glib::Error const& e) {
@@ -450,7 +492,8 @@ void GnomeManager::Impl::CallDisplayManagerSeatMethod(std::string const& method,
auto proxy = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.DisplayManager",
glib::gchar_to_string(xdg_seat_path),
"org.freedesktop.DisplayManager.Seat",
- test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM);
+ test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,
+ DEFAULT_CALL_FLAGS);
proxy->CallBegin(method, parameters, [this, proxy] (GVariant*, glib::Error const& e) {
if (e)
{
diff --git a/UnityCore/GnomeSessionManagerImpl.h b/UnityCore/GnomeSessionManagerImpl.h
index c388be94c..2cef5ad41 100644
--- a/UnityCore/GnomeSessionManagerImpl.h
+++ b/UnityCore/GnomeSessionManagerImpl.h
@@ -46,6 +46,8 @@ struct GnomeManager::Impl
Impl(GnomeManager* parent, bool test_mode = false);
~Impl();
+ void SetupLogin1Proxy(std::string const& session_path);
+
void ConfirmLogout();
void ConfirmReboot();
void ConfirmShutdown();
diff --git a/UnityCore/Variant.cpp b/UnityCore/Variant.cpp
index 2095ff370..57cdb0fc8 100644
--- a/UnityCore/Variant.cpp
+++ b/UnityCore/Variant.cpp
@@ -179,6 +179,36 @@ std::string Variant::GetString() const
return result ? result : "";
}
+std::string Variant::GetObjectPath() const
+{
+ const gchar *result = nullptr;
+
+ if (!variant_)
+ return "";
+
+ if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_OBJECT_PATH))
+ {
+ // g_variant_get_string doesn't duplicate the string
+ result = g_variant_get_string(variant_, nullptr);
+ }
+ else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(o)")))
+ {
+ // As we're using the '&' prefix we don't need to free the string!
+ g_variant_get(variant_, "(&o)", &result);
+ }
+ else
+ {
+ auto const& variant = get_variant(variant_);
+ if (variant)
+ return variant.GetObjectPath();
+
+ LOG_ERROR(logger) << "You're trying to extract a 'o' from a variant which is of type '"
+ << g_variant_type_peek_string(g_variant_get_type(variant_)) << "'";
+ }
+
+ return result ? result : "";
+}
+
template <typename TYPE, typename GTYPE>
TYPE get_numeric_value(GVariant *variant_, const char *type_str, const char *fallback_type_str)
{
diff --git a/UnityCore/Variant.h b/UnityCore/Variant.h
index fca2b8e63..e313e8f18 100644
--- a/UnityCore/Variant.h
+++ b/UnityCore/Variant.h
@@ -68,6 +68,7 @@ public:
~Variant();
std::string GetString() const;
+ std::string GetObjectPath() const;
unsigned char GetByte() const;
int16_t GetInt16() const;
uint16_t GetUInt16() const;
diff --git a/config.h.cmake b/config.h.cmake
index 11dfa0e5f..3caa2ecde 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -2,8 +2,9 @@
#define CONFIG_H
#cmakedefine PREFIXPATH "@PREFIXPATH@"
-#cmakedefine UNITYDATADIR "@UNITYDATADIR@"
-#cmakedefine UNITYLIBDIR "@UNITYLIBDIR@"
+#cmakedefine UNITY_DATADIR "@UNITY_DATADIR@"
+#cmakedefine UNITY_LIBDIR "@UNITY_LIBDIR@"
+#cmakedefine UNITY_INSTALL_LIBDIR "@UNITY_INSTALL_LIBDIR@"
#cmakedefine PKGDATADIR "@PKGDATADIR@"
#cmakedefine LOCALE_DIR "@LOCALE_DIR@"
#cmakedefine VERSION "@VERSION@"
diff --git a/dash/FilterExpanderLabel.cpp b/dash/FilterExpanderLabel.cpp
index b6dd20b86..0137297e5 100644
--- a/dash/FilterExpanderLabel.cpp
+++ b/dash/FilterExpanderLabel.cpp
@@ -273,6 +273,14 @@ void FilterExpanderLabel::DrawContent(nux::GraphicsEngine& graphics_engine, bool
graphics_engine.PopClippingRectangle();
}
+nux::Area* FilterExpanderLabel::FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type)
+{
+ if (event_type == nux::EVENT_MOUSE_WHEEL)
+ return nullptr;
+ else
+ return nux::View::FindAreaUnderMouse(mouse_position, event_type);
+}
+
//
// Key navigation
//
diff --git a/dash/FilterExpanderLabel.h b/dash/FilterExpanderLabel.h
index 52f672788..3afbaf817 100644
--- a/dash/FilterExpanderLabel.h
+++ b/dash/FilterExpanderLabel.h
@@ -69,6 +69,7 @@ public:
nux::Property<bool> expanded;
protected:
+ nux::Area* FindAreaUnderMouse(const nux::Point&, nux::NuxEventType) override;
virtual bool AcceptKeyNavFocus();
virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index 321867659..adc5f9c61 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -1 +1,43 @@
-add_subdirectory(pam) \ No newline at end of file
+add_subdirectory(pam)
+
+# GSettings Schema
+SET (UNITY_SCHEMAS "com.canonical.Unity.gschema.xml")
+SET (UNITY_TEST_SCHEMAS "external.gschema.xml")
+
+# Have an option to not install the schema into where GLib is
+option (GSETTINGS_LOCALINSTALL "Install GSettings Schemas locally instead of to the GLib prefix" OFF)
+if (GSETTINGS_LOCALINSTALL)
+ SET (GSETTINGS_DIR "${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas/")
+else (GSETTINGS_LOCALINSTALL)
+ execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} glib-2.0 --variable prefix OUTPUT_VARIABLE _glib_prefix OUTPUT_STRIP_TRAILING_WHITESPACE)
+ SET (GSETTINGS_DIR "${_glib_prefix}/share/glib-2.0/schemas/")
+endif (GSETTINGS_LOCALINSTALL)
+
+# Run the validator and error if it fails
+execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_comple_schemas OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${CMAKE_CURRENT_SOURCE_DIR}/${UNITY_SCHEMAS} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if (_schemas_invalid)
+ message (SEND_ERROR "Schema validation error: ${_schemas_invalid}")
+endif (_schemas_invalid)
+
+# Actually install and recomple schemas
+message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}")
+install (FILES ${UNITY_SCHEMAS} DESTINATION ${GSETTINGS_DIR} OPTIONAL)
+install (CODE "message (STATUS \"Compiling GSettings schemas\")")
+install (CODE "execute_process (COMMAND ${_glib_comple_schemas} ${GSETTINGS_DIR})")
+
+# Settings for testing
+configure_file (${CMAKE_SOURCE_DIR}/data/${UNITY_SCHEMAS} ${CMAKE_BINARY_DIR}/settings/${UNITY_SCHEMAS})
+configure_file (${CMAKE_SOURCE_DIR}/tests/data/${UNITY_TEST_SCHEMAS} ${CMAKE_BINARY_DIR}/settings/${UNITY_TEST_SCHEMAS})
+execute_process (COMMAND ${_glib_comple_schemas} ${CMAKE_BINARY_DIR}/settings)
+
+# Upstart
+configure_file(unity7.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
+
+# Systemd
+configure_file(unity7.service.in ${CMAKE_CURRENT_BINARY_DIR}/unity7.service @ONLY)
+pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity7.service DESTINATION ${SYSTEMD_USER_DIR})
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/unity7.override DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/systemd-session/upstart)
diff --git a/com.canonical.Unity.gschema.xml b/data/com.canonical.Unity.gschema.xml
index bfeeb7dad..bfeeb7dad 100644
--- a/com.canonical.Unity.gschema.xml
+++ b/data/com.canonical.Unity.gschema.xml
diff --git a/data/unity7.conf.in b/data/unity7.conf.in
new file mode 100644
index 000000000..1c1958243
--- /dev/null
+++ b/data/unity7.conf.in
@@ -0,0 +1,13 @@
+description "Unity Shell v7"
+author "Ted Gould <ted@ubuntu.com>, Marco Trevisan <marco@ubuntu.com>"
+
+start on xsession SESSION=ubuntu and started unity-settings-daemon
+stop on desktop-end
+
+pre-start script
+ @UNITY_LIBDIR@/upstart-prestart-check
+ @UNITY_LIBDIR@/compiz-profile-selector
+end script
+
+respawn
+exec compiz
diff --git a/data/unity7.override b/data/unity7.override
new file mode 100644
index 000000000..2905494b6
--- /dev/null
+++ b/data/unity7.override
@@ -0,0 +1 @@
+manual
diff --git a/data/unity7.service.in b/data/unity7.service.in
new file mode 100644
index 000000000..36dc2aa6a
--- /dev/null
+++ b/data/unity7.service.in
@@ -0,0 +1,15 @@
+[Unit]
+Description=Unity Shell v7
+Requires=unity-settings-daemon.service unity-panel-service.service bamfdaemon.service
+Wants=unity-gtk-module.service
+After=unity-settings-daemon.service
+PartOf=graphical-session.target
+
+[Service]
+ExecStartPre=@UNITY_LIBDIR@/systemd-prestart-check
+ExecStartPre=@UNITY_LIBDIR@/compiz-profile-selector
+ExecStart=/usr/bin/compiz
+Restart=on-failure
+
+[Install]
+RequiredBy=ubuntu-session.target
diff --git a/debian/changelog b/debian/changelog
index 48826a862..3648f4e00 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,196 @@
+unity (7.5.0+17.04.20161130-0ubuntu1) zesty; urgency=medium
+
+ [ Kai-Heng Feng ]
+ * UnitySettings: If scale-factor is not set, find and set right scale
+ for HiDPI displays.
+
+ [ Marco Trevisan (Treviño) ]
+ * CMakeLists.txt: add support to compile with GTest 1.8 (LP: #1644062)
+ * UnityScreen: toggle gestures recognition on lock (LP: #1645507)
+
+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Wed, 30 Nov 2016 11:06:58 +0000
+
+unity (7.5.0+17.04.20161111.1-0ubuntu1) zesty; urgency=medium
+
+ * LockScreenController: use InputMonitor to get all the events and
+ hide the Blank Window (LP: #1321075)
+ * LockScreenController: use input monitor to get the events to switch
+ monitor (LP: #1316862)
+ * LauncherOptions: use track_obj to manage option changes (LP:
+ #1622995)
+
+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Fri, 11 Nov 2016 16:01:53 +0000
+
+unity (7.5.0+17.04.20161107.2-0ubuntu1) zesty; urgency=medium
+
+ [ Andrea Azzarone ]
+ * Properly handle the file manager copy dialog in
+ FileManagerLauncherIcon and in StorageLauncherIcon. (LP: #1575452,
+ #1609845)
+ * Correctly position the force quit dialog when scaling is different
+ than 1.0 (LP: #1637991)
+ * GnomeSession: Retrieve the session id using dbus if $XDG_SESSION_ID
+ is not set
+
+ [ Marco Trevisan (Treviño) ]
+ * LockScreenController: ignore icon_paths_changed signal in
+ menumanager for Lockscreen (LP: #1635625)
+
+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Mon, 07 Nov 2016 23:31:33 +0000
+
+unity (7.5.0+17.04.20161107-0ubuntu1) zesty; urgency=medium
+
+ * No-change rebuild against latest nux
+
+ -- Jeremy Bicha <jbicha@ubuntu.com> Mon, 07 Nov 2016 02:22:22 +0000
+
+unity (7.5.0+17.04.20161027-0ubuntu1) zesty; urgency=medium
+
+ [ Marco Trevisan (Treviño) ]
+ * TestXdndStartStopNotifierImp: enable some unstable tests by adding
+ XTest support
+
+ [ Martin Pitt ]
+ * Add indicator-printers Wants to unity-panel-service.service
+ * Disable fatal deprecation warnings to build with zesty's GTK 3.22
+ without breaking backportability.
+
+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 27 Oct 2016 08:41:53 +0000
+
+unity (7.5.0+16.10.20160906.1-0ubuntu1) yakkety; urgency=medium
+
+ [ Marco Trevisan (Treviño), Ted Gould ]
+ * Unity: add systemd units for the shell and related services, mark
+ unity7 a requirement for ubuntu-session
+
+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Tue, 06 Sep 2016 14:19:15 +0000
+
+unity (7.5.0+16.10.20160901.2-0ubuntu1) yakkety; urgency=medium
+
+ [ Andrea Azzarone ]
+ * Disable menu discovery animation if MenusDiscoveryDuration is 0.
+ (LP: #942962)
+ * Redraw fake decorations on window resize. (LP: #940470)
+
+ [ Marco Trevisan (Treviño) ]
+ * InputMonitor: add an unity class that monitors XInput2 events and
+ converts them to XEvent
+ * EdgeBarrierController: use InputMonitor to get the barrier events
+ instead of relying on its implementation
+ * DecorationsMenuLayout: use input monitor for menu scrubbing (LP:
+ #1614597)
+ * PanelView: use InputMonitor to track menu events
+ * LockScreenPanel: use InputMonitor events instead of mouse polling
+ for menu scrubbing
+ * MenuManager: add support for mouse trackers with triangle algorithm
+ support (LP: #1618405)
+ * PanelView: scale gradient refinement properly
+ * PanelService: don't allow to deactivate menus if they've been opened
+ too shortly
+ * WindowButton: properly partially unmaximize a window when
+ middle/left clicking in the restore button (LP: #1616136)
+ * CMake: move data and setting files in proper folder, define shared
+ libdir variables
+
+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Thu, 01 Sep 2016 23:59:15 +0000
+
+unity (7.5.0+16.10.20160819-0ubuntu1) yakkety; urgency=medium
+
+ [ Andrea Azzarone ]
+ * Use compiz::Window::serverNext instead of compiz::Window::next in
+ IsWindowObscured as the latter can be outdated just after
+ scale/spread terminates. (LP: #1614116)
+
+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Fri, 19 Aug 2016 13:15:09 +0000
+
+unity (7.5.0+16.10.20160817.1-0ubuntu1) yakkety; urgency=medium
+
+ [ Andrea Azzarone ]
+ * Make sure the switcher detail view is properly scaled. Also scale
+ the xy_offset to make sure the switcher and launcher do not overlap.
+ (LP: #1605256)
+ * Close session dialog on first ESC. (LP: #1521116)
+ * Filter out scrolling envents for FilterExpanderLabel. (LP: #1604632)
+
+ [ Marco Trevisan (Treviño) ]
+ * OverlayRenderer: properly decorate launcher/panel when the launcher
+ is at the bottom (LP: #1611694)
+ * UserAuthenticatorPam: ensure pam_handle_ is null initialized and
+ don't proceed if not set (LP: #1611668)
+ * OverlayRenderer: don't use rotated textures, just rotate them at
+ rendering time
+ * DecorationStyle: set css name for Gtk 3.20
+ * SpreadWidgets: add container for spread filter and new spread
+ decorations (LP: #1283314)
+
+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Wed, 17 Aug 2016 14:03:22 +0000
+
+unity (7.5.0+16.10.20160806-0ubuntu1) yakkety; urgency=medium
+
+ [ Marco Trevisan (Treviño) ]
+ * DecoratedWindow: avoid deferencing an invalid shadow texture ptr,
+ and split functions (LP: #1608464)
+ * UnityWindowView: don't try to deference close_button_ if its' null
+ * DecorationsForceQuitDialog: make CSS selectors work with gtk 3.20
+
+ [ Andrea Azzarone, Marco Trevisan (Treviño) ]
+ * DecoratedWindow: display unmaximize button if the window is
+ vertically or horizontally maximized (LP: #1608480)
+
+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Sat, 06 Aug 2016 16:25:58 +0000
+
+unity (7.5.0+16.10.20160727-0ubuntu1) yakkety; urgency=medium
+
+ [ Andrea Azzarone ]
+ * [LockSceen] Remove numlock warning. (LP: #1526322)
+ * Make sure initiate and terminate callbacks are not empty before
+ calling them. (LP: #1605012)
+ * Properly destroy close_button_ to properly disconnect lambda. (LP:
+ #1605010)
+ * Use the standard notification-device-eject in the "device eject"
+ notification. This allows us to scale it properly on high-dpi
+ setups. (LP: #1605231)
+ * Add tools to enforce unityshell plugin for the current profile and
+ add "move" and "resize" plugins as requirements. (LP: #1506023,
+ #1605007)
+ * When locked discard damages from windows below lockscreen. (LP:
+ #1605180)
+
+ [ Eleni Maria Stea ]
+ * DecoratedWindow: Added shadows for shaped windows
+
+ [ Marco Trevisan (Treviño) ]
+ * LockScreenAcceleratorController: ensure callbacks are valid before
+ calling them (LP: #1605012)
+ * DecoratedWindow: Cleanup shadows for shaped windows, reduce
+ recomputation
+
+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Wed, 27 Jul 2016 10:25:54 +0000
+
+unity (7.5.0+16.10.20160715-0ubuntu1) yakkety; urgency=medium
+
+ [ Eleni Maria Stea ]
+ * Reverts fix for multimonitor because of problems in nvidia cards
+ (see bug: #1602901) (LP: #1602901)
+
+ -- iain@orangesquash.org.uk <iain@orangesquash.org.uk> Fri, 15 Jul 2016 15:13:28 +0000
+
+unity (7.5.0+16.10.20160714-0ubuntu1) yakkety; urgency=medium
+
+ [ Andrea Azzarone ]
+ * FileManagerLauncherIcon: Don't trust the Quirk::VISIBLE in the ctor.
+ (LP: #1599133)
+ * [TrashLauncherIcon] Create GFileMonitor in an idle to avoid blocking
+ calls. (LP: #1602720)
+
+ [ Marco Trevisan (Treviño) ]
+ * Unity script: use result from unity_support_test to check the right
+ COMPIZ_CONFIG_PROFILE to use (LP: #1602377)
+ * SwitcherView: always disable animations when in lowgfx mode (LP:
+ #1602784)
+
+ -- Marco Trevisan (Treviño) <mail@3v1n0.net> Thu, 14 Jul 2016 10:06:29 +0000
+
unity (7.5.0+16.10.20160705.4-0ubuntu1) yakkety; urgency=medium
[ Andrea Azzarone ]
diff --git a/debian/control b/debian/control
index ffea1b014..210814e77 100644
--- a/debian/control
+++ b/debian/control
@@ -18,6 +18,7 @@ Build-Depends: cmake,
libbamf3-dev (>= 0.5.3~bzr0),
libboost-dev,
libcairo2-dev,
+ libcompizconfig0-dev,
libdbus-1-dev,
libdbusmenu-glib-dev (>= 0.3.91),
libdee-dev (>= 1.2.6),
@@ -36,7 +37,7 @@ Build-Depends: cmake,
libnux-4.0-dev (>= 4.0.6),
libpam0g-dev,
libpango1.0-dev,
- libsigc++-2.0-dev,
+ libsigc++-2.0-dev (>= 2.4.0),
libstartup-notification0-dev,
libunique-dev,
libunity-dev (>= 7.1.0),
@@ -46,12 +47,14 @@ Build-Depends: cmake,
libxfixes-dev (>= 1:5.0.1),
libxi-dev (>= 2:1.7.1.901),
libxpathselect-dev (>=1.4),
+ libxtst-dev,
libzeitgeist-2.0-dev,
pkg-config,
python (>= 2.7),
python3 (>= 3.4),
python-setuptools,
quilt,
+ systemd,
xserver-xorg-video-dummy,
xsltproc,
Standards-Version: 3.9.5
@@ -80,21 +83,10 @@ Depends: ${shlibs:Depends},
libxfixes3 (>= 1:5.0.1-1),
libxi6 (>= 2:1.7.1.901),
unity-scope-home,
-Provides: indicator-renderer
Recommends: unity-control-center,
${unity-default-masterscopes}
nautilus,
gnome-disk-utility,
- indicator-appmenu (>= 15.02.0),
- indicator-application,
- indicator-sound,
- indicator-bluetooth,
- indicator-datetime,
- indicator-keyboard,
- indicator-messages,
- indicator-printers,
- indicator-power,
- indicator-session,
hud,
session-shortcuts,
Breaks: unity-lens-applications (<< 5.12.0-0ubuntu2),
@@ -113,6 +105,18 @@ Package: unity-services
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends},
+ indicator-common,
+Provides: indicator-renderer
+Recommends: indicator-appmenu (>= 15.02.0),
+ indicator-application,
+ indicator-sound,
+ indicator-bluetooth,
+ indicator-datetime,
+ indicator-keyboard,
+ indicator-messages,
+ indicator-printers,
+ indicator-power,
+ indicator-session,
Description: Services for the Unity interface
Unity is a desktop experience that sings. Designed by Canonical and the Ayatana
community, Unity is all about the combination of familiarity and the future. We
diff --git a/debian/libunity-core-6.0-9.install b/debian/libunity-core-6.0-9.install
index be488a661..4ece61576 100644
--- a/debian/libunity-core-6.0-9.install
+++ b/debian/libunity-core-6.0-9.install
@@ -2,8 +2,9 @@ usr/lib/*/libunity-core*.so.*
usr/lib/*/unity/*.py
usr/share/ccsm
usr/share/gnome-control-center/
-usr/share/unity
+usr/share/unity/icons
+usr/share/unity/themes
debian/unity-crashdb.conf etc/apport/crashdb.conf.d/
debian/source_unity.py usr/share/apport/package-hooks
-debian/unity7.conf usr/share/upstart/sessions
tools/convert-files/* usr/lib/compiz/migration/
+usr/share/upstart/sessions/unity7.conf
diff --git a/debian/unity-services.install b/debian/unity-services.install
index 4f0e67ca8..7255aeace 100644
--- a/debian/unity-services.install
+++ b/debian/unity-services.install
@@ -1,3 +1,6 @@
usr/lib/*/unity/*service
-usr/share/upstart
+usr/share/upstart/sessions/unity-panel*
+usr/share/upstart/systemd-session/upstart/unity-panel*
+usr/lib/systemd/user/unity-panel*
+usr/lib/systemd/user/unity-screen-locked.target
usr/share/man/*/unity-panel-service.1
diff --git a/debian/unity-services.links b/debian/unity-services.links
new file mode 100644
index 000000000..f84ecaafd
--- /dev/null
+++ b/debian/unity-services.links
@@ -0,0 +1,14 @@
+/usr/lib/systemd/user/indicator-application.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-application.service
+/usr/lib/systemd/user/indicator-bluetooth.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-bluetooth.service
+/usr/lib/systemd/user/indicator-datetime.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-datetime.service
+/usr/lib/systemd/user/indicator-keyboard.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-keyboard.service
+/usr/lib/systemd/user/indicator-messages.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-messages.service
+/usr/lib/systemd/user/indicator-power.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-power.service
+/usr/lib/systemd/user/indicator-session.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-session.service
+/usr/lib/systemd/user/indicator-sound.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-sound.service
+/usr/lib/systemd/user/indicator-printers.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-printers.service
+/usr/lib/systemd/user/indicator-datetime.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-datetime.service
+/usr/lib/systemd/user/indicator-keyboard.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-keyboard.service
+/usr/lib/systemd/user/indicator-power.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-power.service
+/usr/lib/systemd/user/indicator-session.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-session.service
+/usr/lib/systemd/user/indicator-sound.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-sound.service
diff --git a/debian/unity.install b/debian/unity.install
index 22e55b097..208f0b6ec 100644
--- a/debian/unity.install
+++ b/debian/unity.install
@@ -1,6 +1,11 @@
etc/pam.d
usr/bin
usr/lib/*/compiz/libunity*.so
+usr/lib/*/unity/unity-active-plugins-safety-check
+usr/lib/*/unity/compiz-profile-selector
+usr/lib/*/unity/*-prestart-check
+usr/lib/systemd/user/unity7.service
usr/share/man/*/unity.1
usr/share/compiz
usr/share/locale
+usr/share/upstart/systemd-session/upstart/unity7.override
diff --git a/debian/unity.links b/debian/unity.links
new file mode 100644
index 000000000..7aa586e8f
--- /dev/null
+++ b/debian/unity.links
@@ -0,0 +1 @@
+/usr/lib/systemd/user/unity7.service /usr/lib/systemd/user/ubuntu-session.target.requires/unity7.service
diff --git a/debian/unity7.conf b/debian/unity7.conf
deleted file mode 100644
index b7df8bb36..000000000
--- a/debian/unity7.conf
+++ /dev/null
@@ -1,27 +0,0 @@
-description "Unity Shell v7"
-author "Ted Gould <ted@ubuntu.com>, Marco Trevisan <marco@ubuntu.com>"
-
-start on xsession SESSION=ubuntu and started unity-settings-daemon
-stop on desktop-end
-
-pre-start script
- # If gnome-session is going to start compiz,
- # we don't want to be the ones doing it.
-
- if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
- echo "GNOME Session is starting Compiz"
- stop ; exit 0
- fi
-
- compiz_profile="ubuntu"
-
- if ! /usr/lib/nux/unity_support_test -p; then
- compiz_profile="ubuntu-lowgfx"
- fi
-
- echo "Using compiz profile '$compiz_profile'"
- initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
-end script
-
-respawn
-exec compiz
diff --git a/decorations/CMakeLists.txt b/decorations/CMakeLists.txt
index d7fb53c4a..fe71565bb 100644
--- a/decorations/CMakeLists.txt
+++ b/decorations/CMakeLists.txt
@@ -35,6 +35,7 @@ set (DECORATION_SOURCES
DecorationsMenuDropdown.cpp
DecorationsForceQuitDialog.cpp
DecorationsDataPool.cpp
+ DecorationsShape.cpp
)
add_library (decorations-lib STATIC ${DECORATION_SOURCES})
diff --git a/decorations/DecoratedWindow.cpp b/decorations/DecoratedWindow.cpp
index 93b50d27e..fe294dc83 100644
--- a/decorations/DecoratedWindow.cpp
+++ b/decorations/DecoratedWindow.cpp
@@ -37,7 +37,7 @@ namespace decoration
{
namespace
{
-const std::string MENUS_PANEL_NAME = "WindowLIM";
+const int SHADOW_BLUR_MARGIN_FACTOR = 2;
}
Window::Impl::Impl(Window* parent, CompWindow* win)
@@ -54,7 +54,6 @@ Window::Impl::Impl(Window* parent, CompWindow* win)
, deco_elements_(cu::DecorationElement::NONE)
, last_mwm_decor_(win_->mwmDecor())
, last_actions_(win_->actions())
- , panel_id_(MENUS_PANEL_NAME + std::to_string(win_->id()))
, cv_(Settings::Instance().em())
{
active.changed.connect([this] (bool active) {
@@ -147,6 +146,23 @@ void Window::Impl::Undecorate()
bg_textures_.clear();
}
+void Window::Impl::UpdateWindowState(unsigned old_state)
+{
+ Update();
+
+ if (state_change_button_)
+ {
+ if (win_->state() & (CompWindowStateMaximizedVertMask|CompWindowStateMaximizedHorzMask))
+ {
+ state_change_button_->type = WindowButtonType::UNMAXIMIZE;
+ }
+ else
+ {
+ state_change_button_->type = WindowButtonType::MAXIMIZE;
+ }
+ }
+}
+
void Window::Impl::UnsetExtents()
{
if (win_->hasUnmapReference())
@@ -409,7 +425,13 @@ void Window::Impl::SetupWindowControls()
top_layout_->Append(std::make_shared<WindowButton>(win_, WindowButtonType::MINIMIZE));
if (win_->actions() & (CompWindowActionMaximizeHorzMask|CompWindowActionMaximizeVertMask))
- top_layout_->Append(std::make_shared<WindowButton>(win_, WindowButtonType::MAXIMIZE));
+ {
+ auto type = (win_->state() & (CompWindowStateMaximizedVertMask|CompWindowStateMaximizedHorzMask)) ?
+ WindowButtonType::UNMAXIMIZE : WindowButtonType::MAXIMIZE;
+ auto state_change_button = std::make_shared<WindowButton>(win_, type);
+ top_layout_->Append(state_change_button);
+ state_change_button_ = state_change_button;
+ }
auto title = std::make_shared<Title>();
title->text = last_title_.empty() ? WindowManager::Default().GetWindowName(win_->id()) : last_title_;
@@ -492,6 +514,12 @@ bool Window::Impl::ShadowDecorated() const
return deco_elements_ & cu::DecorationElement::SHADOW;
}
+bool Window::Impl::ShapedShadowDecorated() const
+{
+ return deco_elements_ & cu::DecorationElement::SHADOW &&
+ deco_elements_ & cu::DecorationElement::SHAPED;
+}
+
bool Window::Impl::FullyDecorated() const
{
return deco_elements_ & cu::DecorationElement::BORDER;
@@ -504,6 +532,14 @@ bool Window::Impl::ShouldBeDecorated() const
GLTexture* Window::Impl::ShadowTexture() const
{
+ if (shaped_shadow_pixmap_)
+ return shaped_shadow_pixmap_->texture();
+
+ return SharedShadowTexture();
+}
+
+GLTexture* Window::Impl::SharedShadowTexture() const
+{
auto const& mi = manager_->impl_;
if (active() || parent_->scaled())
return mi->active_shadow_pixmap_->texture();
@@ -569,10 +605,22 @@ void Window::Impl::ComputeShadowQuads()
if (!last_shadow_rect_.isEmpty())
last_shadow_rect_.setGeometry(0, 0, 0, 0);
- return;
+ shaped_shadow_pixmap_.reset();
+ }
+ else if (deco_elements_ & cu::DecorationElement::SHAPED)
+ {
+ ComputeShapedShadowQuad();
+ }
+ else
+ {
+ shaped_shadow_pixmap_.reset();
+ ComputeGenericShadowQuads();
}
+}
- const auto* texture = ShadowTexture();
+void Window::Impl::ComputeGenericShadowQuads()
+{
+ const auto* texture = SharedShadowTexture();
if (!texture || !texture->width() || !texture->height())
return;
@@ -676,6 +724,68 @@ void Window::Impl::ComputeShadowQuads()
}
}
+cu::PixmapTexture::Ptr Window::Impl::BuildShapedShadowTexture(nux::Size const& size, unsigned radius, nux::Color const& color, Shape const& shape) {
+ nux::CairoGraphics img(CAIRO_FORMAT_ARGB32, size.width, size.height);
+ auto* img_ctx = img.GetInternalContext();
+
+ for (auto const& rect : shape.GetRectangles())
+ {
+ cairo_rectangle(img_ctx, rect.x + radius * SHADOW_BLUR_MARGIN_FACTOR - shape.XOffset(), rect.y + radius * SHADOW_BLUR_MARGIN_FACTOR - shape.YOffset(), rect.width, rect.height);
+ cairo_set_source_rgba(img_ctx, color.red, color.green, color.blue, color.alpha);
+ cairo_fill(img_ctx);
+ }
+
+ img.BlurSurface(radius);
+
+ cu::CairoContext shadow_ctx(size.width, size.height);
+ cairo_set_source_surface(shadow_ctx, img.GetSurface(), 0, 0);
+ cairo_paint(shadow_ctx);
+
+ return shadow_ctx;
+}
+
+void Window::Impl::ComputeShapedShadowQuad()
+{
+ nux::Color color = active() ? manager_->active_shadow_color() : manager_->inactive_shadow_color();
+ unsigned int radius = active() ? manager_->active_shadow_radius() : manager_->inactive_shadow_radius();
+
+ Shape shape(win_->id());
+ auto const& border = win_->borderRect();
+ auto const& shadow_offset = manager_->shadow_offset();
+
+ // Ideally it would be shape.getWidth + radius * 2 but Cairographics::BlurSurface
+ // isn't bounded by the radius and we need to compensate by using a larger texture.
+ int width = shape.Width() + radius * 2 * SHADOW_BLUR_MARGIN_FACTOR;
+ int height = shape.Height() + radius * 2 * SHADOW_BLUR_MARGIN_FACTOR;
+
+ if (width != last_shadow_rect_.width() || height != last_shadow_rect_.height())
+ shaped_shadow_pixmap_ = BuildShapedShadowTexture({width, height}, radius, color, shape);
+
+ const auto* texture = shaped_shadow_pixmap_->texture();
+
+ if (!texture || !texture->width() || !texture->height())
+ return;
+
+ int x = border.x() + shadow_offset.x - radius * 2 + shape.XOffset();
+ int y = border.y() + shadow_offset.y - radius * 2 + shape.YOffset();
+
+ auto* quad = &shadow_quads_[Quads::Pos(0)];
+ quad->box.setGeometry(x, y, width, height);
+ quad->matrix = texture->matrix();
+ quad->matrix.x0 = -COMP_TEX_COORD_X(quad->matrix, quad->box.x1());
+ quad->matrix.y0 = -COMP_TEX_COORD_Y(quad->matrix, quad->box.y1());
+
+ CompRect shaped_shadow_rect(x, y, width, height);
+ if (shaped_shadow_rect != last_shadow_rect_)
+ {
+ auto const& win_region = win_->region();
+ quad->region = CompRegion(quad->box) - win_region;
+
+ last_shadow_rect_ = shaped_shadow_rect;
+ win_->updateWindowOutputExtents();
+ }
+}
+
void Window::Impl::Paint(GLMatrix const& transformation,
GLWindowPaintAttrib const& attrib,
CompRegion const& region, unsigned mask)
@@ -714,14 +824,18 @@ void Window::Impl::Draw(GLMatrix const& transformation,
glwin_->vertexBuffer()->begin();
- for (unsigned i = 0; i < shadow_quads_.size(); ++i)
+ unsigned int num_quads = ShapedShadowDecorated() ? 1 : shadow_quads_.size();
+ for (unsigned int i = 0; i < num_quads; ++i)
{
auto& quad = shadow_quads_[Quads::Pos(i)];
glwin_->glAddGeometry(quad.matrices, quad.region, clip_region);
}
if (glwin_->vertexBuffer()->end())
- glwin_->glDrawTexture(ShadowTexture(), transformation, attrib, mask);
+ {
+ if (GLTexture* texture = ShadowTexture())
+ glwin_->glDrawTexture(texture, transformation, attrib, mask);
+ }
for (auto const& dtex : bg_textures_)
{
@@ -746,6 +860,9 @@ void Window::Impl::Damage()
void Window::Impl::RedrawDecorations()
{
+ if (!win_->isMapped())
+ return;
+
dirty_geo_ = true;
cwin_->damageOutputExtents();
}
@@ -813,18 +930,13 @@ void Window::Impl::UpdateAppMenuVisibility()
sliding_layout->mouse_owner = grab_edge_->mouse_owner();
}
-inline std::string const& Window::Impl::GetMenusPanelID() const
-{
- return panel_id_;
-}
-
void Window::Impl::UnsetAppMenu()
{
if (!menus_)
return;
auto const& indicators = manager_->impl_->menu_manager_->Indicators();
- indicators->SyncGeometries(GetMenusPanelID(), indicator::EntryLocationMap());
+ indicators->SyncGeometries(menus_->MenubarId(), indicator::EntryLocationMap());
sliding_layout_->SetInputItem(nullptr);
grab_mouse_changed_->disconnect();
}
@@ -837,7 +949,7 @@ void Window::Impl::SyncMenusGeometries() const
auto const& indicators = manager_->impl_->menu_manager_->Indicators();
indicator::EntryLocationMap map;
menus_->ChildrenGeometries(map);
- indicators->SyncGeometries(GetMenusPanelID(), map);
+ indicators->SyncGeometries(menus_->MenubarId(), map);
}
bool Window::Impl::ActivateMenu(std::string const& entry_id)
@@ -907,6 +1019,11 @@ void Window::Update()
impl_->Update();
}
+void Window::UpdateWindowState(unsigned old_state)
+{
+ impl_->UpdateWindowState(old_state);
+}
+
void Window::UpdateFrameRegion(CompRegion& r)
{
if (impl_->frame_region_.isEmpty())
diff --git a/decorations/DecoratedWindow.h b/decorations/DecoratedWindow.h
index 893a6e0f3..3edfb2777 100644
--- a/decorations/DecoratedWindow.h
+++ b/decorations/DecoratedWindow.h
@@ -21,6 +21,7 @@
#define UNITY_DECORATED_WINDOW
#include "Introspectable.h"
+#include <NuxCore/Property.h>
#include <memory>
class CompRegion;
@@ -52,6 +53,7 @@ public:
void UpdateDecorationPositionDelayed();
void UpdateFrameRegion(CompRegion&);
void UpdateOutputExtents(compiz::window::extents::Extents&);
+ void UpdateWindowState(unsigned old_state);
void Paint(GLMatrix const&, GLWindowPaintAttrib const&, CompRegion const&, unsigned mask);
void Draw(GLMatrix const&, GLWindowPaintAttrib const&, CompRegion const&, unsigned mask);
diff --git a/decorations/DecorationsForceQuitDialog.cpp b/decorations/DecorationsForceQuitDialog.cpp
index 791dad491..509b4824e 100644
--- a/decorations/DecorationsForceQuitDialog.cpp
+++ b/decorations/DecorationsForceQuitDialog.cpp
@@ -279,7 +279,7 @@ GtkWidget* sheet_style_dialog_new(ForceQuitDialog* main_dialog, Window parent_xi
int decoration_radius = std::max({radius.top, radius.left, radius.right, radius.bottom});
gtk_css_provider_load_from_data(style, (R"(
- SheetStyleDialog {
+ SheetStyleDialog, sheet-style-dialog {
background-color: #f7f6f5;
color: #4a4a4a;
border-radius: )"+std::to_string(decoration_radius)+R"(px;
@@ -291,7 +291,7 @@ GtkWidget* sheet_style_dialog_new(ForceQuitDialog* main_dialog, Window parent_xi
std::to_string(int(color.alpha))+'.'+std::to_string(int(color.alpha*10000.0))+')'+R"(;
}
- SheetStyleDialog:backdrop {
+ SheetStyleDialog:backdrop, sheet-style-dialog:backdrop {
background-color: shade(#f7f6f5, 1.2);
color: shade(#4a4a4a, 1.5);
border-radius: )"+std::to_string(decoration_radius)+R"(px;
@@ -327,10 +327,7 @@ GtkWidget* sheet_style_dialog_new(ForceQuitDialog* main_dialog, Window parent_xi
auto* title = gtk_label_new(_("This window is not responding"));
glib::Object<GtkCssProvider> title_style(gtk_css_provider_new());
- gtk_css_provider_load_from_data(title_style, (R"(
- GtkLabel {
- font-size: 17px;
- })"), -1, nullptr);
+ gtk_css_provider_load_from_data(title_style, (R"(* { font-size: 17px; })"), -1, nullptr);
style_ctx = gtk_widget_get_style_context(title);
gtk_style_context_add_provider(style_ctx, glib::object_cast<GtkStyleProvider>(title_style), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_style_context_add_class(style_ctx, "unity-force-quit");
@@ -377,6 +374,10 @@ static void sheet_style_dialog_class_init(SheetStyleDialogClass* klass)
gtk_render_background(gtk_widget_get_style_context(self), cr, 0, 0, a.width, a.height);
return GTK_WIDGET_CLASS(sheet_style_dialog_parent_class)->draw(self, cr);
};
+
+#if GTK_CHECK_VERSION(3, 20, 0)
+ gtk_widget_class_set_css_name(GTK_WIDGET_CLASS(klass), "sheet-style-dialog");
+#endif
}
// Close button
@@ -384,7 +385,6 @@ GtkWidget* close_button_new()
{
auto* self = GTK_WIDGET(g_object_new(close_button_get_type(), nullptr));
gtk_button_set_relief(GTK_BUTTON(self), GTK_RELIEF_NONE);
- gtk_button_set_focus_on_click(GTK_BUTTON(self), FALSE);
gtk_widget_set_can_focus(self, FALSE);
gtk_widget_set_halign(self, GTK_ALIGN_START);
@@ -478,9 +478,11 @@ struct ForceQuitDialog::Impl : sigc::trackable
void UpdateDialogPosition()
{
+ gint scale = gtk_widget_get_scale_factor(dialog_);
+ scale = std::max<gint>(1, scale);
auto const& win_geo = win_->inputRect();
- nux::Size walloc(gtk_widget_get_allocated_width(dialog_), gtk_widget_get_allocated_height(dialog_));
- gtk_window_move(GTK_WINDOW(dialog_), win_geo.centerX() - walloc.width/2, win_geo.centerY() - walloc.height/2);
+ nux::Size walloc(gtk_widget_get_allocated_width(dialog_) * scale, gtk_widget_get_allocated_height(dialog_) * scale);
+ gtk_window_move(GTK_WINDOW(dialog_), (win_geo.centerX() - walloc.width/2) / scale, (win_geo.centerY() - walloc.height/2) / scale);
}
ForceQuitDialog* parent_;
diff --git a/decorations/DecorationsManager.cpp b/decorations/DecorationsManager.cpp
index 4be19cb33..37933a95b 100644
--- a/decorations/DecorationsManager.cpp
+++ b/decorations/DecorationsManager.cpp
@@ -20,9 +20,9 @@
#include "DecorationsPriv.h"
#include <core/atoms.h>
-#include <NuxGraphics/CairoGraphics.h>
#include <UnityCore/DBusIndicators.h>
#include <X11/Xatom.h>
+
#include "WindowManager.h"
namespace unity
diff --git a/decorations/DecorationsMenuLayout.cpp b/decorations/DecorationsMenuLayout.cpp
index 252fd7d0d..e31a766df 100644
--- a/decorations/DecorationsMenuLayout.cpp
+++ b/decorations/DecorationsMenuLayout.cpp
@@ -25,6 +25,10 @@ namespace unity
{
namespace decoration
{
+namespace
+{
+const std::string MENUS_PANEL_NAME = "WindowLIM";
+}
using namespace indicator;
@@ -33,8 +37,8 @@ MenuLayout::MenuLayout(menu::Manager::Ptr const& menu, CompWindow* win)
, show_now(false)
, menu_manager_(menu)
, win_(win)
- , last_pointer_(-1, -1)
, dropdown_(std::make_shared<MenuDropdown>(menu_manager_->Indicators(), win))
+ , menubar_id_(MENUS_PANEL_NAME + std::to_string(win_->id()))
{
visible = false;
}
@@ -91,6 +95,11 @@ void MenuLayout::Setup()
Relayout();
}
+std::string const& MenuLayout::MenubarId() const
+{
+ return menubar_id_;
+}
+
bool MenuLayout::ActivateMenu(std::string const& entry_id)
{
MenuEntry::Ptr target;
@@ -117,14 +126,27 @@ bool MenuLayout::ActivateMenu(std::string const& entry_id)
if (!activated)
activated = dropdown_->ActivateChild(target);
- if (activated)
+ return activated;
+}
+
+bool MenuLayout::ActivateMenu(CompPoint const& pos)
+{
+ if (!Geometry().contains(pos))
+ return false;
+
+ for (auto const& item : items_)
{
- // Since this generally happens on keyboard activation we need to avoid that
- // the mouse position would interfere with this
- last_pointer_.set(pointerX, pointerY);
+ if (!item->visible() || !item->sensitive())
+ continue;
+
+ if (item->Geometry().contains(pos))
+ {
+ std::static_pointer_cast<MenuEntry>(item)->ShowMenu(1);
+ return true;
+ }
}
- return activated;
+ return false;
}
void MenuLayout::OnEntryMouseOwnershipChanged(bool owner)
@@ -154,39 +176,15 @@ void MenuLayout::OnEntryActiveChanged(bool actived)
{
active = actived;
- if (active && !pointer_tracker_ && items_.size() > 1)
+ if (active && items_.size() > 1)
{
- pointer_tracker_.reset(new glib::Timeout(16));
- pointer_tracker_->Run([this] {
- Window win;
- int i, x, y;
- unsigned int ui;
-
- XQueryPointer(screen->dpy(), screen->root(), &win, &win, &x, &y, &i, &i, &ui);
-
- if (last_pointer_.x() != x || last_pointer_.y() != y)
- {
- last_pointer_.set(x, y);
-
- for (auto const& item : items_)
- {
- if (!item->visible() || !item->sensitive())
- continue;
-
- if (item->Geometry().contains(last_pointer_))
- {
- std::static_pointer_cast<MenuEntry>(item)->ShowMenu(1);
- break;
- }
- }
- }
-
- return true;
- });
+ menu_manager_->RegisterTracker(menubar_id_, (sigc::track_obj([this] (int x, int y, double speed) {
+ ActivateMenu(CompPoint(x, y));
+ }, *this)));
}
else if (!active)
{
- pointer_tracker_.reset();
+ menu_manager_->UnregisterTracker(menubar_id_);
}
}
diff --git a/decorations/DecorationsMenuLayout.h b/decorations/DecorationsMenuLayout.h
index 9fc787186..df80c3e4c 100644
--- a/decorations/DecorationsMenuLayout.h
+++ b/decorations/DecorationsMenuLayout.h
@@ -42,7 +42,9 @@ public:
void Setup();
bool ActivateMenu(std::string const& entry_id);
+ bool ActivateMenu(CompPoint const&);
void ChildrenGeometries(indicator::EntryLocationMap&) const;
+ std::string const& MenubarId() const;
protected:
void DoRelayout() override;
@@ -55,10 +57,9 @@ private:
menu::Manager::Ptr menu_manager_;
CompWindow* win_;
- CompPoint last_pointer_;
- glib::Source::UniquePtr pointer_tracker_;
glib::Source::UniquePtr show_now_timeout_;
std::shared_ptr<MenuDropdown> dropdown_;
+ std::string menubar_id_;
};
} // decoration namespace
diff --git a/decorations/DecorationsPriv.h b/decorations/DecorationsPriv.h
index c39e9c5dd..c8c5a39ec 100644
--- a/decorations/DecorationsPriv.h
+++ b/decorations/DecorationsPriv.h
@@ -23,6 +23,7 @@
#include <unordered_map>
#include <NuxCore/NuxCore.h>
#include <NuxCore/Rect.h>
+#include <NuxGraphics/CairoGraphics.h>
#include <UnityCore/ConnectionManager.h>
#include <UnityCore/Indicators.h>
#include <core/core.h>
@@ -30,6 +31,7 @@
#include <composite/composite.h>
#include <X11/extensions/shape.h>
+#include "DecorationsShape.h"
#include "DecorationsDataPool.h"
#include "DecorationsManager.h"
#include "DecorationsInputMixer.h"
@@ -47,6 +49,7 @@ class Title;
class MenuLayout;
class SlidingLayout;
class ForceQuitDialog;
+class WindowButton;
namespace cu = compiz_utils;
@@ -88,6 +91,7 @@ struct Window::Impl
bool IsMaximized() const;
bool FullyDecorated() const;
bool ShadowDecorated() const;
+ bool ShapedShadowDecorated() const;
void RedrawDecorations();
void Damage();
void SetupAppMenu();
@@ -100,6 +104,7 @@ private:
void SetupExtents();
void ComputeBorderExtent(CompWindowExtents &border);
void UpdateElements(cu::WindowFilter wf = cu::WindowFilter::NONE);
+ void UpdateWindowState(unsigned old_state);
void UpdateClientDecorationsState();
void UpdateMonitor();
void UpdateFrame();
@@ -117,14 +122,18 @@ private:
void SyncMenusGeometries() const;
bool ShouldBeDecorated() const;
GLTexture* ShadowTexture() const;
+ GLTexture* SharedShadowTexture() const;
unsigned ShadowRadius() const;
std::string const& GetMenusPanelID() const;
void ComputeShadowQuads();
+ void ComputeGenericShadowQuads();
+ void ComputeShapedShadowQuad();
void UpdateDecorationTextures();
void UpdateWindowEdgesGeo();
void UpdateForceQuitDialogPosition();
void RenderDecorationTexture(Side, nux::Geometry const&);
+ cu::PixmapTexture::Ptr BuildShapedShadowTexture(nux::Size const&, unsigned radius, nux::Color const&, Shape const&);
void Paint(GLMatrix const&, GLWindowPaintAttrib const&, CompRegion const&, unsigned mask);
void Draw(GLMatrix const&, GLWindowPaintAttrib const&, CompRegion const&, unsigned mask);
@@ -153,11 +162,12 @@ private:
connection::Wrapper dpi_changed_;
connection::Wrapper grab_mouse_changed_;
std::string last_title_;
- std::string panel_id_;
std::vector<cu::SimpleTextureQuad> bg_textures_;
+ cu::PixmapTexture::Ptr shaped_shadow_pixmap_;
std::shared_ptr<ForceQuitDialog> force_quit_;
InputMixer::Ptr input_mixer_;
Layout::Ptr top_layout_;
+ uweak_ptr<WindowButton> state_change_button_;
uweak_ptr<MenuLayout> menus_;
uweak_ptr<Title> title_;
uweak_ptr<SlidingLayout> sliding_layout_;
diff --git a/decorations/DecorationsShape.cpp b/decorations/DecorationsShape.cpp
new file mode 100644
index 000000000..bd827d78e
--- /dev/null
+++ b/decorations/DecorationsShape.cpp
@@ -0,0 +1,107 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Eleni Maria Stea <elenimaria.stea@canonical.com>
+ */
+
+#include "DecorationsShape.h"
+
+#include <core/core.h>
+#include <NuxCore/Logger.h>
+#include <X11/extensions/shape.h>
+
+namespace unity
+{
+namespace decoration
+{
+namespace
+{
+DECLARE_LOGGER(logger, "unity.decoration.shape");
+}
+
+Shape::Shape(Window xid)
+{
+ Bool buse, cuse;
+ int bx, by, cx, cy;
+ unsigned int bw, bh, cw, ch;
+ Display *dpy = screen->dpy();
+
+ XShapeQueryExtents(dpy, xid, &buse, &bx, &by, &bw, &bh, &cuse, &cx, &cy, &cw, &ch);
+
+ int kind;
+
+ if (buse)
+ {
+ width_ = bw;
+ height_ = bh;
+ xoffs_ = bx;
+ yoffs_ = by;
+ kind = ShapeBounding;
+ }
+ else if (cuse)
+ {
+ width_ = cw;
+ height_ = ch;
+ xoffs_ = cx;
+ yoffs_ = cy;
+ kind = ShapeClip;
+ }
+ else
+ {
+ LOG_ERROR(logger) << "XShapeQueryExtend returned no extents";
+ return;
+ }
+
+ int rect_count, rect_order;
+ std::unique_ptr<XRectangle[], int(*)(void*)> rectangles(XShapeGetRectangles(dpy, xid, kind, &rect_count, &rect_order), XFree);
+
+ if (!rectangles)
+ {
+ LOG_ERROR(logger) << "Failed to get shape rectangles";
+ return;
+ }
+
+ for (int i = 0; i < rect_count; ++i)
+ rectangles_.push_back(rectangles[i]);
+}
+
+std::vector<XRectangle> const& Shape::GetRectangles() const
+{
+ return rectangles_;
+}
+
+int Shape::Width() const
+{
+ return width_;
+}
+
+int Shape::Height() const
+{
+ return height_;
+}
+
+int Shape::XOffset() const
+{
+ return xoffs_;
+}
+
+int Shape::YOffset() const
+{
+ return yoffs_;
+}
+
+} // decoration namespace
+} // unity namespace
diff --git a/decorations/DecorationsShape.h b/decorations/DecorationsShape.h
new file mode 100644
index 000000000..a040bc8a9
--- /dev/null
+++ b/decorations/DecorationsShape.h
@@ -0,0 +1,54 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Eleni Maria Stea <elenimaria.stea@canonical.com>
+ */
+
+#ifndef DECORATIONS_SHAPE_H_
+#define DECORATIONS_SHAPE_H_
+
+#include <X11/Xlib.h>
+#include <vector>
+
+namespace unity
+{
+namespace decoration
+{
+class Shape
+{
+public:
+ Shape(Window);
+
+ int Width() const;
+ int Height() const;
+ int XOffset() const;
+ int YOffset() const;
+
+ std::vector<XRectangle> const& GetRectangles() const;
+
+private:
+ int width_;
+ int height_;
+ int xoffs_;
+ int yoffs_;
+
+ std::vector<XRectangle> rectangles_;
+};
+
+} // decoration namespace
+} // unity namespace
+
+#endif //DECORATIONS_SHAPE_H_
diff --git a/decorations/DecorationsWindowButton.cpp b/decorations/DecorationsWindowButton.cpp
index 39671c569..131c74bdd 100644
--- a/decorations/DecorationsWindowButton.cpp
+++ b/decorations/DecorationsWindowButton.cpp
@@ -29,8 +29,8 @@ namespace unity
namespace decoration
{
-WindowButton::WindowButton(CompWindow* win, WindowButtonType type)
- : type_(type)
+WindowButton::WindowButton(CompWindow* win, WindowButtonType wbt)
+ : type(wbt)
, pressed_(false)
, was_pressed_(false)
, win_(win)
@@ -39,12 +39,13 @@ WindowButton::WindowButton(CompWindow* win, WindowButtonType type)
mouse_owner.changed.connect(cb);
focused.changed.connect(cb);
scale.changed.connect(cb);
+ type.changed.connect(cb);
UpdateTexture();
}
void WindowButton::UpdateTexture()
{
- SetTexture(DataPool::Get()->ButtonTexture(scale(), type_, GetCurrentState()));
+ SetTexture(DataPool::Get()->ButtonTexture(scale(), type(), GetCurrentState()));
}
WidgetState WindowButton::GetCurrentState() const
@@ -98,7 +99,7 @@ void WindowButton::ButtonUpEvent(CompPoint const& p, unsigned button, Time times
pressed_ = false;
UpdateTexture();
- switch (type_)
+ switch (type())
{
case WindowButtonType::CLOSE:
if (win_->actions() & CompWindowActionCloseMask)
@@ -112,32 +113,50 @@ void WindowButton::ButtonUpEvent(CompPoint const& p, unsigned button, Time times
switch (button)
{
case Button1:
- if ((win_->state() & CompWindowStateMaximizedVertMask) ||
- (win_->state() & CompWindowStateMaximizedHorzMask))
- win_->maximize(0);
- else if (win_->actions() & (CompWindowActionMaximizeHorzMask|CompWindowActionMaximizeVertMask))
+ if (win_->actions() & (CompWindowActionMaximizeHorzMask|CompWindowActionMaximizeVertMask))
win_->maximize(MAXIMIZE_STATE);
break;
case Button2:
if (win_->actions() & CompWindowActionMaximizeVertMask)
{
if (!(win_->state() & CompWindowStateMaximizedVertMask))
- win_->maximize(CompWindowStateMaximizedVertMask);
+ win_->maximize(win_->state() | CompWindowStateMaximizedVertMask);
+ }
+ break;
+ case Button3:
+ if (win_->actions() & CompWindowActionMaximizeHorzMask)
+ {
+ if (!(win_->state() & CompWindowStateMaximizedHorzMask))
+ win_->maximize(win_->state() | CompWindowStateMaximizedHorzMask);
+ }
+ break;
+ }
+ break;
+ case WindowButtonType::UNMAXIMIZE:
+ switch (button)
+ {
+ case Button1:
+ win_->maximize(0);
+ break;
+ case Button2:
+ if (win_->actions() & CompWindowActionMaximizeVertMask)
+ {
+ if (!(win_->state() & CompWindowStateMaximizedVertMask))
+ win_->maximize(win_->state() | CompWindowStateMaximizedVertMask);
else
- win_->maximize(0);
+ win_->maximize(win_->state() & ~CompWindowStateMaximizedVertMask);
}
break;
case Button3:
if (win_->actions() & CompWindowActionMaximizeHorzMask)
{
if (!(win_->state() & CompWindowStateMaximizedHorzMask))
- win_->maximize(CompWindowStateMaximizedHorzMask);
+ win_->maximize(win_->state() | CompWindowStateMaximizedHorzMask);
else
- win_->maximize(0);
+ win_->maximize(win_->state() & ~CompWindowStateMaximizedHorzMask);
}
break;
}
- break;
default:
break;
}
@@ -168,7 +187,7 @@ void WindowButton::MotionEvent(CompPoint const& p, Time)
std::string WindowButton::GetName() const
{
- switch (type_)
+ switch (type())
{
case WindowButtonType::CLOSE:
return "CloseWindowButton";
diff --git a/decorations/DecorationsWindowButton.h b/decorations/DecorationsWindowButton.h
index f9fd62362..85efc2636 100644
--- a/decorations/DecorationsWindowButton.h
+++ b/decorations/DecorationsWindowButton.h
@@ -33,6 +33,8 @@ class WindowButton : public TexturedItem
public:
WindowButton(CompWindow*, WindowButtonType type);
+ nux::Property<WindowButtonType> type;
+
WidgetState GetCurrentState() const;
protected:
@@ -46,7 +48,6 @@ protected:
private:
void UpdateTexture();
- WindowButtonType type_;
bool pressed_;
bool was_pressed_;
CompWindow* win_;
diff --git a/launcher/DeviceNotificationDisplay.h b/launcher/DeviceNotificationDisplay.h
index 2c12a899a..84af00d42 100644
--- a/launcher/DeviceNotificationDisplay.h
+++ b/launcher/DeviceNotificationDisplay.h
@@ -36,7 +36,7 @@ public:
virtual ~DeviceNotificationDisplay() {}
- virtual void Display(std::string const& icon_name, std::string const& volume_name) = 0;
+ virtual void Display(std::string const& volume_name) = 0;
};
}
diff --git a/launcher/DeviceNotificationDisplayImp.cpp b/launcher/DeviceNotificationDisplayImp.cpp
index 6bc647950..684a05790 100644
--- a/launcher/DeviceNotificationDisplayImp.cpp
+++ b/launcher/DeviceNotificationDisplayImp.cpp
@@ -20,49 +20,27 @@
#include "config.h"
#include <glib/gi18n-lib.h>
#include <libnotify/notify.h>
-#include <sigc++/sigc++.h>
#include <UnityCore/GLibWrapper.h>
#include "DeviceNotificationDisplayImp.h"
-#include "unity-shared/IconLoader.h"
namespace unity
{
namespace launcher
{
-namespace
-{
-const unsigned icon_size = 48;
-}
-
//
// Start private implementation
//
class DeviceNotificationDisplayImp::Impl
{
public:
- void Show(std::string const& icon_name, std::string const& volume_name)
- {
- IconLoader::GetDefault().LoadFromGIconString(icon_name, -1, icon_size,
- sigc::bind(sigc::mem_fun(this, &Impl::ShowNotificationWhenIconIsReady), volume_name));
- }
-
- void ShowNotificationWhenIconIsReady(std::string const& icon_name,
- int max_width,
- int max_height,
- glib::Object<GdkPixbuf> const& pixbuf,
- std::string const& volume_name)
+ void Show(std::string const& volume_name)
{
glib::Object<NotifyNotification> notification(notify_notification_new(volume_name.c_str(),
_("The drive has been successfully ejected"),
- nullptr));
-
+ "notification-device-eject"));
notify_notification_set_hint(notification, "x-canonical-private-synchronous", g_variant_new_boolean(TRUE));
-
- if (pixbuf)
- notify_notification_set_image_from_pixbuf(notification, pixbuf);
-
notify_notification_show(notification, nullptr);
}
};
@@ -78,9 +56,9 @@ DeviceNotificationDisplayImp::DeviceNotificationDisplayImp()
DeviceNotificationDisplayImp::~DeviceNotificationDisplayImp()
{}
-void DeviceNotificationDisplayImp::Display(std::string const& icon_name, std::string const& volume_name)
+void DeviceNotificationDisplayImp::Display(std::string const& volume_name)
{
- pimpl->Show(icon_name, volume_name);
+ pimpl->Show(volume_name);
}
}
diff --git a/launcher/DeviceNotificationDisplayImp.h b/launcher/DeviceNotificationDisplayImp.h
index 910951b15..17323a54a 100644
--- a/launcher/DeviceNotificationDisplayImp.h
+++ b/launcher/DeviceNotificationDisplayImp.h
@@ -33,7 +33,7 @@ public:
DeviceNotificationDisplayImp();
virtual ~DeviceNotificationDisplayImp();
- virtual void Display(std::string const& icon_name, std::string const& volume_name);
+ virtual void Display(std::string const& volume_name);
private:
class Impl;
diff --git a/launcher/EdgeBarrierController.cpp b/launcher/EdgeBarrierController.cpp
index a0354f585..42d509eb3 100644
--- a/launcher/EdgeBarrierController.cpp
+++ b/launcher/EdgeBarrierController.cpp
@@ -25,6 +25,7 @@
#include <NuxCore/Logger.h>
#include "unity-shared/UnitySettings.h"
#include "unity-shared/UScreen.h"
+#include "unity-shared/InputMonitor.h"
#include "UnityCore/GLibSource.h"
namespace unity
@@ -36,50 +37,10 @@ namespace
{
int const Y_BREAK_BUFFER = 20;
int const X_BREAK_BUFFER = 20;
- int const MAJOR = 2;
- int const MINOR = 3;
-}
-
-DECLARE_LOGGER(logger, "unity.edge_barrier_controller");
-
-int GetXI2OpCode()
-{
- Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
-
- int opcode, event_base, error_base;
- if (!XQueryExtension(dpy, "XFIXES",
- &opcode,
- &event_base,
- &error_base))
- {
- LOG_ERROR(logger) << "Missing XFixes";
- return -1;
- }
-
- if (!XQueryExtension (dpy, "XInputExtension",
- &opcode,
- &event_base,
- &error_base))
- {
- LOG_ERROR(logger) << "Missing XInput";
- return -1;
- }
-
- int maj = MAJOR;
- int min = MINOR;
-
- if (XIQueryVersion(dpy, &maj, &min) == BadRequest)
- {
- LOG_ERROR(logger) << "Need XInput version 2.3";
- return -1;
- }
-
- return opcode;
}
EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent)
- : xi2_opcode_(-1)
- , edge_overcome_pressure_(0)
+ : edge_overcome_pressure_(0)
, parent_(parent)
{
UScreen *uscreen = UScreen::GetDefault();
@@ -119,8 +80,6 @@ EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent)
options->option_changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnOptionsChanged));
SetupBarriers(UScreen::GetDefault()->GetMonitors());
});
-
- xi2_opcode_ = GetXI2OpCode();
}
EdgeBarrierController::Impl::~Impl()
@@ -202,36 +161,30 @@ void EdgeBarrierController::Impl::ResizeBarrierList(std::vector<nux::Geometry> c
}
}
-void SetupXI2Events()
-{
- Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
-
- unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
- XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
-
- XISetMask(mask.mask, XI_BarrierHit);
- XISetMask(mask.mask, XI_BarrierLeave);
- XISelectEvents (dpy, DefaultRootWindow(dpy), &mask, 1);
-}
-
void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const& layout)
{
if (parent_->force_disable())
return;
- bool edge_resist = parent_->sticky_edges();
+ size_t monitors_size = layout.size();
auto launcher_position = Settings::Instance().launcher_position();
+ bool edge_resist = parent_->sticky_edges();
+ bool needs_barrier = edge_resist && monitors_size > 1;
+ bool needs_vertical_barrier = needs_barrier;
+
+ if (parent_->options()->hide_mode() != launcher::LauncherHideMode::LAUNCHER_HIDE_NEVER)
+ needs_vertical_barrier = true;
- for (unsigned i = 0; i < layout.size(); i++)
+ for (unsigned i = 0; i < layout.size(); ++i)
{
- auto vertical_barrier = vertical_barriers_[i];
- auto horizontal_barrier = horizontal_barriers_[i];
- auto monitor = layout[i];
+ auto const& vertical_barrier = vertical_barriers_[i];
+ auto const& horizontal_barrier = horizontal_barriers_[i];
+ auto const& monitor = layout[i];
vertical_barrier->DestroyBarrier();
horizontal_barrier->DestroyBarrier();
- if (edge_resist)
+ if (needs_barrier)
{
horizontal_barrier->x1 = monitor.x;
horizontal_barrier->x2 = monitor.x + monitor.width;
@@ -246,7 +199,7 @@ void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const
horizontal_barrier->ConstructBarrier();
}
- if (!edge_resist && parent_->options()->hide_mode() == launcher::LauncherHideMode::LAUNCHER_HIDE_NEVER)
+ if (!needs_vertical_barrier)
continue;
if (launcher_position == LauncherPosition::LEFT)
@@ -273,8 +226,10 @@ void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const
vertical_barrier->ConstructBarrier();
}
- SetupXI2Events();
- AddEventFilter();
+ if (needs_barrier || needs_vertical_barrier)
+ input::Monitor::Get().RegisterClient(input::Events::BARRIER, sigc::mem_fun(this, &Impl::HandleEvent));
+ else
+ input::Monitor::Get().UnregisterClient(sigc::mem_fun(this, &Impl::HandleEvent));
float decay_responsiveness_mult = ((parent_->options()->edge_responsiveness() - 1) * .3f) + 1;
decaymulator_.rate_of_decay = parent_->options()->edge_decay_rate() * decay_responsiveness_mult;
@@ -283,65 +238,25 @@ void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const
edge_overcome_pressure_ = parent_->options()->edge_overcome_pressure() * overcome_responsiveness_mult;
}
-void EdgeBarrierController::Impl::AddEventFilter()
-{
- // Remove an old one, if it exists
- nux::GetGraphicsDisplay()->RemoveEventFilter(this);
-
- nux::GraphicsDisplay::EventFilterArg event_filter;
- event_filter.filter = &HandleEventCB;
- event_filter.data = this;
-
- nux::GetGraphicsDisplay()->AddEventFilter(event_filter);
-}
-
-bool EdgeBarrierController::Impl::HandleEvent(XEvent xevent)
-{
- Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
- XGenericEventCookie *cookie = &xevent.xcookie;
- bool ret = false;
-
- switch (cookie->evtype)
- {
- case (XI_BarrierHit):
- {
- if (XGetEventData(dpy, cookie))
- {
- XIBarrierEvent* barrier_event = (XIBarrierEvent*)cookie->data;
- PointerBarrierWrapper::Ptr wrapper = FindBarrierEventOwner(barrier_event);
-
- if (wrapper)
- ret = wrapper->HandleBarrierEvent(barrier_event);
- }
-
- XFreeEventData(dpy, cookie);
- break;
- }
- default:
- break;
- }
-
- return ret;
-}
-
-bool EdgeBarrierController::Impl::HandleEventCB(XEvent xevent, void* data)
+void EdgeBarrierController::Impl::HandleEvent(XEvent const& xevent)
{
- auto edge_barrier_controller = static_cast<EdgeBarrierController::Impl*>(data);
- int const xi2_opcode = edge_barrier_controller->xi2_opcode_;
+ if (xevent.xcookie.evtype != XI_BarrierHit)
+ return;
- if (xevent.type != GenericEvent || xevent.xcookie.extension != xi2_opcode)
- return false;
+ auto* barrier_event = reinterpret_cast<XIBarrierEvent*>(xevent.xcookie.data);
+ PointerBarrierWrapper::Ptr const& wrapper = FindBarrierEventOwner(barrier_event);
- return edge_barrier_controller->HandleEvent(xevent);
+ if (wrapper)
+ wrapper->HandleBarrierEvent(barrier_event);
}
PointerBarrierWrapper::Ptr EdgeBarrierController::Impl::FindBarrierEventOwner(XIBarrierEvent* barrier_event)
{
- for (auto barrier : vertical_barriers_)
+ for (auto const& barrier : vertical_barriers_)
if (barrier->OwnsBarrierEvent(barrier_event->barrier))
return barrier;
- for (auto barrier : horizontal_barriers_)
+ for (auto const& barrier : horizontal_barriers_)
if (barrier->OwnsBarrierEvent(barrier_event->barrier))
return barrier;
diff --git a/launcher/EdgeBarrierControllerPrivate.h b/launcher/EdgeBarrierControllerPrivate.h
index df852bcd0..1de19822c 100644
--- a/launcher/EdgeBarrierControllerPrivate.h
+++ b/launcher/EdgeBarrierControllerPrivate.h
@@ -53,12 +53,8 @@ struct EdgeBarrierController::Impl : public sigc::trackable
bool EventIsInsideYBreakZone(BarrierEvent::Ptr const& event);
bool EventIsInsideXBreakZone(BarrierEvent::Ptr const& event);
- void AddEventFilter();
-
PointerBarrierWrapper::Ptr FindBarrierEventOwner(XIBarrierEvent* barrier_event);
-
- static bool HandleEventCB(XEvent event, void* data);
- bool HandleEvent(XEvent event);
+ void HandleEvent(XEvent const&);
std::vector<PointerBarrierWrapper::Ptr> vertical_barriers_;
std::vector<PointerBarrierWrapper::Ptr> horizontal_barriers_;
@@ -68,7 +64,6 @@ struct EdgeBarrierController::Impl : public sigc::trackable
Decaymulator decaymulator_;
glib::Source::UniquePtr release_timeout_;
- int xi2_opcode_;
float edge_overcome_pressure_;
EdgeBarrierController* parent_;
};
diff --git a/launcher/FileManagerLauncherIcon.cpp b/launcher/FileManagerLauncherIcon.cpp
index e4cf98d55..0926997fe 100644
--- a/launcher/FileManagerLauncherIcon.cpp
+++ b/launcher/FileManagerLauncherIcon.cpp
@@ -46,6 +46,14 @@ FileManagerLauncherIcon::FileManagerLauncherIcon(ApplicationPtr const& app, Devi
// We disconnect from ApplicationLauncherIcon app signals, as we manage them manually
signals_conn_.Clear();
+ SetQuirk(Quirk::VISIBLE, false);
+ SkipQuirkAnimation(Quirk::VISIBLE);
+
+ signals_conn_.Add(app_->window_opened.connect([this](ApplicationWindowPtr const& win) {
+ signals_conn_.Add(win->monitor.changed.connect([this] (int) { UpdateStorageWindows(); }));
+ UpdateStorageWindows();
+ }));
+
signals_conn_.Add(app_->desktop_file.changed.connect([this](std::string const& desktop_file) {
LOG_DEBUG(logger) << tooltip_text() << " desktop_file now " << desktop_file;
UpdateDesktopFile();
@@ -74,7 +82,6 @@ FileManagerLauncherIcon::FileManagerLauncherIcon(ApplicationPtr const& app, Devi
_source_manager.Remove(ICON_REMOVE_TIMEOUT);
}));
-
UpdateStorageWindows();
}
@@ -120,7 +127,7 @@ WindowList FileManagerLauncherIcon::GetStorageWindows() const
for (auto const& app_win : ApplicationLauncherIcon::GetManagedWindows())
{
- if (IsLocationManaged(file_manager_->LocationForWindow(app_win)))
+ if (WindowManager::Default().IsWindowMapped(app_win->window_id()) && IsLocationManaged(file_manager_->LocationForWindow(app_win)))
fm_windows.push_back(app_win);
}
@@ -132,5 +139,30 @@ bool FileManagerLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data)
return StorageLauncherIcon::OnShouldHighlightOnDrag(dnd_data);
}
+bool FileManagerLauncherIcon::IsUserVisible() const
+{
+ return ApplicationLauncherIcon::IsUserVisible();
+}
+
+WindowList FileManagerLauncherIcon::WindowsOnViewport()
+{
+ WindowFilterMask filter = 0;
+ filter |= WindowFilter::MAPPED;
+ filter |= WindowFilter::ON_CURRENT_DESKTOP;
+ filter |= WindowFilter::ON_ALL_MONITORS;
+
+ return WindowedLauncherIcon::GetWindows(filter);
+}
+
+WindowList FileManagerLauncherIcon::WindowsForMonitor(int monitor)
+{
+ WindowFilterMask filter = 0;
+ filter |= WindowFilter::MAPPED;
+ filter |= WindowFilter::ON_CURRENT_DESKTOP;
+
+ return WindowedLauncherIcon::GetWindows(filter, monitor);
+}
+
+
} // namespace launcher
} // namespace unity
diff --git a/launcher/FileManagerLauncherIcon.h b/launcher/FileManagerLauncherIcon.h
index 1996747a3..3b7d5d466 100644
--- a/launcher/FileManagerLauncherIcon.h
+++ b/launcher/FileManagerLauncherIcon.h
@@ -32,8 +32,16 @@ namespace launcher
class FileManagerLauncherIcon : public ApplicationLauncherIcon, public StorageLauncherIcon
{
public:
+ typedef nux::ObjectPtr<FileManagerLauncherIcon> Ptr;
+
FileManagerLauncherIcon(ApplicationPtr const&, DeviceLauncherSection::Ptr const&, FileManager::Ptr const& = nullptr);
+ bool IsUserVisible() const override;
+
+protected:
+ WindowList WindowsOnViewport() override;
+ WindowList WindowsForMonitor(int monitor) override;
+
private:
WindowList GetManagedWindows() const override;
WindowList GetStorageWindows() const override;
diff --git a/launcher/LauncherOptions.cpp b/launcher/LauncherOptions.cpp
index 6a06cf759..3d87ac3fb 100644
--- a/launcher/LauncherOptions.cpp
+++ b/launcher/LauncherOptions.cpp
@@ -49,31 +49,31 @@ Options::Options()
, scroll_inactive_icons(false)
, minimize_window_on_click(false)
{
- auto changed_lambda = [this] {
+ auto changed_cb = sigc::track_obj(sigc::hide([this] {
changed_idle_.reset(new glib::Idle(glib::Source::Priority::HIGH));
changed_idle_->Run([this] { option_changed.emit(); return false; });
- };
+ }), *this);
- auto_hide_animation.changed.connect(sigc::hide(changed_lambda));
- background_alpha.changed.connect(sigc::hide(changed_lambda));
- background_color.changed.connect(sigc::hide(changed_lambda));
- backlight_mode.changed.connect(sigc::hide(changed_lambda));
- edge_decay_rate.changed.connect(sigc::hide(changed_lambda));
- edge_overcome_pressure.changed.connect(sigc::hide(changed_lambda));
- edge_responsiveness.changed.connect(sigc::hide(changed_lambda));
- edge_reveal_pressure.changed.connect(sigc::hide(changed_lambda));
- edge_stop_velocity.changed.connect(sigc::hide(changed_lambda));
- edge_passed_disabled_ms.changed.connect(sigc::hide(changed_lambda));
- hide_mode.changed.connect(sigc::hide(changed_lambda));
- icon_size.changed.connect(sigc::hide(changed_lambda));
- launch_animation.changed.connect(sigc::hide(changed_lambda));
- reveal_trigger.changed.connect(sigc::hide(changed_lambda));
- tile_size.changed.connect(sigc::hide(changed_lambda));
- super_tap_duration.changed.connect(sigc::hide(changed_lambda));
- urgent_animation.changed.connect(sigc::hide(changed_lambda));
- edge_resist.changed.connect(sigc::hide(changed_lambda));
- scroll_inactive_icons.changed.connect(sigc::hide(changed_lambda));
- minimize_window_on_click.changed.connect(sigc::hide(changed_lambda));
+ auto_hide_animation.changed.connect(changed_cb);
+ background_alpha.changed.connect(changed_cb);
+ background_color.changed.connect(changed_cb);
+ backlight_mode.changed.connect(changed_cb);
+ edge_decay_rate.changed.connect(changed_cb);
+ edge_overcome_pressure.changed.connect(changed_cb);
+ edge_responsiveness.changed.connect(changed_cb);
+ edge_reveal_pressure.changed.connect(changed_cb);
+ edge_stop_velocity.changed.connect(changed_cb);
+ edge_passed_disabled_ms.changed.connect(changed_cb);
+ hide_mode.changed.connect(changed_cb);
+ icon_size.changed.connect(changed_cb);
+ launch_animation.changed.connect(changed_cb);
+ reveal_trigger.changed.connect(changed_cb);
+ tile_size.changed.connect(changed_cb);
+ super_tap_duration.changed.connect(changed_cb);
+ urgent_animation.changed.connect(changed_cb);
+ edge_resist.changed.connect(changed_cb);
+ scroll_inactive_icons.changed.connect(changed_cb);
+ minimize_window_on_click.changed.connect(changed_cb);
}
}
diff --git a/launcher/StorageLauncherIcon.cpp b/launcher/StorageLauncherIcon.cpp
index fcc367b72..fcd50c54d 100644
--- a/launcher/StorageLauncherIcon.cpp
+++ b/launcher/StorageLauncherIcon.cpp
@@ -36,7 +36,7 @@ void StorageLauncherIcon::UpdateStorageWindows()
bool active = false;
bool urgent = false;
bool check_visibility = (GetIconType() == IconType::APPLICATION);
- bool visible = IsSticky();
+ bool visible = false;
managed_windows_ = GetStorageWindows();
windows_connections_.Clear();
@@ -54,13 +54,8 @@ void StorageLauncherIcon::UpdateStorageWindows()
if (!urgent && win->urgent())
urgent = true;
- if (check_visibility)
- {
- windows_connections_.Add(win->visible.changed.connect([this] (bool) { OnWindowStateChanged(); }));
-
- if (!visible && win->visible())
- visible = true;
- }
+ if (check_visibility && !visible)
+ visible = true;
}
SetQuirk(Quirk::RUNNING, !managed_windows_.empty());
@@ -68,7 +63,7 @@ void StorageLauncherIcon::UpdateStorageWindows()
SetQuirk(Quirk::URGENT, urgent);
if (check_visibility)
- SetQuirk(Quirk::VISIBLE, visible);
+ SetQuirk(Quirk::VISIBLE, visible || IsSticky());
EnsureWindowsLocation();
}
@@ -83,7 +78,7 @@ void StorageLauncherIcon::OnWindowStateChanged()
bool active = false;
bool urgent = false;
bool check_visibility = (GetIconType() == IconType::APPLICATION);
- bool visible = IsSticky();
+ bool visible = false;
for (auto const& win : managed_windows_)
{
@@ -93,7 +88,7 @@ void StorageLauncherIcon::OnWindowStateChanged()
if (!urgent && win->urgent())
urgent = true;
- if (check_visibility && !visible && win->visible())
+ if (check_visibility && !visible)
visible = true;
}
@@ -101,7 +96,7 @@ void StorageLauncherIcon::OnWindowStateChanged()
SetQuirk(Quirk::URGENT, urgent);
if (check_visibility)
- SetQuirk(Quirk::VISIBLE, visible);
+ SetQuirk(Quirk::VISIBLE, visible || IsSticky());
}
bool StorageLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data)
diff --git a/launcher/SwitcherController.cpp b/launcher/SwitcherController.cpp
index dc31784a6..8f400c32c 100644
--- a/launcher/SwitcherController.cpp
+++ b/launcher/SwitcherController.cpp
@@ -45,7 +45,7 @@ const std::string SHOW_TIMEOUT = "show-timeout";
const std::string DETAIL_TIMEOUT = "detail-timeout";
const std::string VIEW_CONSTRUCT_IDLE = "view-construct-idle";
const unsigned FADE_DURATION = 80;
-const int XY_OFFSET = 100;
+const RawPixel XY_OFFSET = 100_em;
}
namespace switcher
@@ -441,7 +441,8 @@ nux::Geometry GetSwitcherViewsGeometry()
int monitor = uscreen->GetMonitorWithMouse();
auto monitor_geo = uscreen->GetMonitorGeometry(monitor);
- monitor_geo.Expand(-XY_OFFSET, -XY_OFFSET);
+ auto em = Settings::Instance().em(monitor);
+ monitor_geo.Expand(-XY_OFFSET.CP(em), -XY_OFFSET.CP(em));
return monitor_geo;
}
diff --git a/launcher/SwitcherView.cpp b/launcher/SwitcherView.cpp
index d3aecf533..6264700bb 100644
--- a/launcher/SwitcherView.cpp
+++ b/launcher/SwitcherView.cpp
@@ -49,6 +49,9 @@ namespace
RawPixel const EXTRA_ICON_SPACE = 10_em;
RawPixel const TEXT_SIZE = 15_em;
+ RawPixel const LAYOUT_SPACING = 8_em;
+ RawPixel const LAYOUT_MAX_ROW_HEIGHT = 400_em;
+
unsigned int const ANIMATION_LENGTH = 250;
unsigned int const MAX_DIRECTIONS_CHANGED = 3;
unsigned int const SCROLL_WHEEL_EVENTS_DISTANCE = 75;
@@ -88,6 +91,9 @@ SwitcherView::SwitcherView(ui::AbstractIconRenderer::Ptr const& renderer)
text_view_->SetFontWeight(PANGO_WEIGHT_BOLD);
text_view_->SetScale(scale);
+ layout_system_.spacing = LAYOUT_SPACING.CP(scale);
+ layout_system_.max_row_height = LAYOUT_MAX_ROW_HEIGHT.CP(scale);
+
icon_size.changed.connect(sigc::mem_fun(this, &SwitcherView::OnIconSizeChanged));
tile_size.changed.connect(sigc::mem_fun(this, &SwitcherView::OnTileSizeChanged));
scale.changed.connect(sigc::mem_fun(this, &SwitcherView::OnScaleChanged));
@@ -211,10 +217,13 @@ void SwitcherView::OnScaleChanged(double scale)
text_size = TEXT_SIZE.CP(scale);
vertical_size = tile_size + VERTICAL_PADDING.CP(scale) * 2;
icon_renderer_->scale = scale;
+ layout_system_.spacing = LAYOUT_SPACING.CP(scale);
+ layout_system_.max_row_height = LAYOUT_MAX_ROW_HEIGHT.CP(scale);
}
void SwitcherView::StartAnimation()
{
+ animation_.SetDuration(Settings::Instance().low_gfx() ? 0 : animation_length);
animation::Start(animation_, animation::Direction::FORWARD);
}
@@ -249,7 +258,6 @@ void SwitcherView::OnDetailSelectionChanged(bool detail)
render_targets_.clear();
}
- animation_.SetDuration(Settings::Instance().low_gfx() ? 0 : animation_length);
SaveLast();
}
@@ -260,7 +268,6 @@ void SwitcherView::OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection
delta_tracker_.ResetState();
- animation_.SetDuration(animation_length);
SaveLast();
}
diff --git a/launcher/TrashLauncherIcon.cpp b/launcher/TrashLauncherIcon.cpp
index b8239aabd..9c6502ec9 100644
--- a/launcher/TrashLauncherIcon.cpp
+++ b/launcher/TrashLauncherIcon.cpp
@@ -55,23 +55,27 @@ TrashLauncherIcon::TrashLauncherIcon(FileManager::Ptr const& fm)
SkipQuirkAnimation(Quirk::VISIBLE);
SetShortcut('t');
- glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str()));
+ _source_manager.AddIdle([this]{
+ glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str()));
- glib::Error err;
- trash_monitor_ = g_file_monitor_directory(location, G_FILE_MONITOR_NONE, cancellable_, &err);
- g_file_monitor_set_rate_limit(trash_monitor_, 1000);
+ glib::Error err;
+ trash_monitor_ = g_file_monitor_directory(location, G_FILE_MONITOR_NONE, cancellable_, &err);
+ g_file_monitor_set_rate_limit(trash_monitor_, 1000);
- if (err)
- {
- LOG_ERROR(logger) << "Could not create file monitor for trash uri: " << err;
- }
- else
- {
- glib_signals_.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(trash_monitor_, "changed",
- [this] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent) {
- UpdateTrashIcon();
- });
- }
+ if (err)
+ {
+ LOG_ERROR(logger) << "Could not create file monitor for trash uri: " << err;
+ }
+ else
+ {
+ glib_signals_.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(trash_monitor_, "changed",
+ [this] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent) {
+ UpdateTrashIcon();
+ });
+ }
+
+ return false;
+ });
UpdateTrashIcon();
UpdateStorageWindows();
diff --git a/launcher/VolumeLauncherIcon.cpp b/launcher/VolumeLauncherIcon.cpp
index 0bb771f05..6cbbc5c45 100644
--- a/launcher/VolumeLauncherIcon.cpp
+++ b/launcher/VolumeLauncherIcon.cpp
@@ -108,7 +108,7 @@ public:
auto conn = std::make_shared<sigc::connection>();
*conn = volume_->ejected.connect([this, conn] {
- notification_->Display(volume_->GetIconName(), volume_->GetName());
+ notification_->Display(volume_->GetName());
conn->disconnect();
});
connections_.Add(*conn);
diff --git a/lockscreen/KylinLockScreenShield.cpp b/lockscreen/KylinLockScreenShield.cpp
index 5f2211827..8074f46cc 100644
--- a/lockscreen/KylinLockScreenShield.cpp
+++ b/lockscreen/KylinLockScreenShield.cpp
@@ -37,7 +37,7 @@ KylinShield::KylinShield(session::Manager::Ptr const& session_manager,
Accelerators::Ptr const& accelerators,
nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
int monitor_num, bool is_primary)
- : BaseShield(session_manager, nullptr, accelerators, prompt_view, monitor_num, is_primary)
+ : BaseShield(session_manager, accelerators, prompt_view, monitor_num, is_primary)
{
is_primary ? ShowPrimaryView() : ShowSecondaryView();
EnableInputWindow(true);
@@ -77,23 +77,5 @@ void KylinShield::ShowPrimaryView()
main_layout->AddSpace(0, 10);
}
-nux::Area* KylinShield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsigned long modifiers)
-{
- if (primary)
- {
- grab_key.emit(modifiers, keysym);
-
- if (prompt_view_)
- {
- auto* focus_view = prompt_view_->focus_view();
-
- if (focus_view && focus_view->GetInputEventSensitivity())
- return focus_view;
- }
- }
-
- return nullptr;
-}
-
}
}
diff --git a/lockscreen/KylinLockScreenShield.h b/lockscreen/KylinLockScreenShield.h
index 93294521a..fb33706b0 100644
--- a/lockscreen/KylinLockScreenShield.h
+++ b/lockscreen/KylinLockScreenShield.h
@@ -41,9 +41,6 @@ public:
nux::ObjectPtr<AbstractUserPromptView> const&,
int monitor, bool is_primary);
-protected:
- nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override;
-
private:
void ShowPrimaryView() override;
};
diff --git a/lockscreen/LockScreenAcceleratorController.cpp b/lockscreen/LockScreenAcceleratorController.cpp
index 80436881d..49dbd3bf1 100644
--- a/lockscreen/LockScreenAcceleratorController.cpp
+++ b/lockscreen/LockScreenAcceleratorController.cpp
@@ -194,10 +194,20 @@ void AcceleratorController::OnActionActivated(CompAction& action)
CompOption::Vector options;
if (action.state() & CompAction::StateInitKey)
- action.initiate()(&action, 0, options);
+ {
+ auto const& initiate_cb = action.initiate();
+
+ if (!initiate_cb.empty())
+ initiate_cb(&action, 0, options);
+ }
if (action.state() & CompAction::StateTermKey)
- action.terminate()(&action, CompAction::StateTermTapped, options);
+ {
+ auto const& terminate_cb = action.terminate();
+
+ if (!terminate_cb.empty())
+ terminate_cb(&action, CompAction::StateTermTapped, options);
+ }
}
Accelerators::Ptr const& AcceleratorController::GetAccelerators() const
diff --git a/lockscreen/LockScreenBaseShield.cpp b/lockscreen/LockScreenBaseShield.cpp
index 0d65550c3..cfd56814c 100644
--- a/lockscreen/LockScreenBaseShield.cpp
+++ b/lockscreen/LockScreenBaseShield.cpp
@@ -38,7 +38,6 @@ const unsigned MAX_GRAB_WAIT = 100;
}
BaseShield::BaseShield(session::Manager::Ptr const& session,
- indicator::Indicators::Ptr const& indicators,
Accelerators::Ptr const& accelerators,
nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
int monitor_num, bool is_primary)
@@ -47,7 +46,6 @@ BaseShield::BaseShield(session::Manager::Ptr const& session,
, monitor(monitor_num)
, scale(1.0)
, session_manager_(session)
- , indicators_(indicators)
, accelerators_(accelerators)
, prompt_view_(prompt_view)
, bg_settings_(std::make_shared<BackgroundSettings>())
@@ -83,11 +81,6 @@ BaseShield::BaseShield(session::Manager::Ptr const& session,
background_layer_.reset();
UpdateBackgroundTexture();
});
-
- mouse_move.connect([this] (int x, int y, int, int, unsigned long, unsigned long) {
- auto const& abs_geo = GetAbsoluteGeometry();
- grab_motion.emit(abs_geo.x + x, abs_geo.y + y);
- });
}
bool BaseShield::HasGrab() const
@@ -96,6 +89,19 @@ bool BaseShield::HasGrab() const
return (wc.GetPointerGrabArea() == this && wc.GetKeyboardGrabArea() == this);
}
+nux::Area* BaseShield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsigned long modifiers)
+{
+ if (primary && prompt_view_)
+ {
+ auto* focus_view = prompt_view_->focus_view();
+
+ if (focus_view && focus_view->GetInputEventSensitivity())
+ return focus_view;
+ }
+
+ return nullptr;
+}
+
nux::Area* BaseShield::FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type)
{
nux::Area* area = BaseWindow::FindAreaUnderMouse(mouse, event_type);
diff --git a/lockscreen/LockScreenBaseShield.h b/lockscreen/LockScreenBaseShield.h
index 06f47b21b..9cd1e164e 100644
--- a/lockscreen/LockScreenBaseShield.h
+++ b/lockscreen/LockScreenBaseShield.h
@@ -21,8 +21,8 @@
#define UNITY_LOCKSCREEN_BASE_SHIELD_H
#include <NuxCore/Property.h>
+#include "UnityCore/ConnectionManager.h"
#include "UnityCore/SessionManager.h"
-#include "UnityCore/Indicators.h"
#include "UnityCore/GLibSource.h"
#include "unity-shared/MockableBaseWindow.h"
@@ -39,8 +39,8 @@ class CofView;
class BaseShield : public MockableBaseWindow
{
public:
- BaseShield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&,
- Accelerators::Ptr const&, nux::ObjectPtr<AbstractUserPromptView> const&,
+ BaseShield(session::Manager::Ptr const&, Accelerators::Ptr const&,
+ nux::ObjectPtr<AbstractUserPromptView> const&,
int monitor_num, bool is_primary);
nux::Property<bool> primary;
@@ -54,14 +54,13 @@ public:
sigc::signal<void> grabbed;
sigc::signal<void> grab_failed;
- sigc::signal<void, int, int> grab_motion;
- sigc::signal<void, unsigned long, unsigned long> grab_key;
protected:
virtual bool AcceptKeyNavFocus() { return false; }
virtual void ShowPrimaryView() = 0;
virtual void ShowSecondaryView();
+ nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override;
nux::Area* FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type) override;
void GrabScreen(bool cancel_on_failure);
@@ -69,7 +68,6 @@ protected:
void UpdateScale();
session::Manager::Ptr session_manager_;
- indicator::Indicators::Ptr indicators_;
Accelerators::Ptr accelerators_;
nux::ObjectPtr<AbstractUserPromptView> prompt_view_;
std::shared_ptr<BackgroundSettings> bg_settings_;
diff --git a/lockscreen/LockScreenController.cpp b/lockscreen/LockScreenController.cpp
index 0818f21a9..2ede0f7a7 100644
--- a/lockscreen/LockScreenController.cpp
+++ b/lockscreen/LockScreenController.cpp
@@ -28,6 +28,7 @@
#include "LockScreenShield.h"
#include "LockScreenSettings.h"
#include "unity-shared/AnimationUtils.h"
+#include "unity-shared/InputMonitor.h"
#include "unity-shared/UnitySettings.h"
#include "unity-shared/UScreen.h"
#include "unity-shared/WindowManager.h"
@@ -41,6 +42,7 @@ namespace
const unsigned int IDLE_FADE_DURATION = 10000;
const unsigned int LOCK_FADE_DURATION = 400;
const unsigned int POST_LOCK_SCREENSAVER_WAIT = 2;
+const std::string SYSTEMD_LOCK_TARGET = "unity-screen-locked.target";
class BlankWindow : public nux::BaseWindow
{
@@ -56,6 +58,7 @@ DECLARE_LOGGER(logger, "unity.lockscreen");
Controller::Controller(DBusManager::Ptr const& dbus_manager,
session::Manager::Ptr const& session_manager,
key::Grabber::Ptr const& key_grabber,
+ SystemdWrapper::Ptr const& systemd_wrapper,
UpstartWrapper::Ptr const& upstart_wrapper,
ShieldFactoryInterface::Ptr const& shield_factory,
bool test_mode)
@@ -63,6 +66,7 @@ Controller::Controller(DBusManager::Ptr const& dbus_manager,
, dbus_manager_(dbus_manager)
, session_manager_(session_manager)
, key_grabber_(key_grabber)
+ , systemd_wrapper_(systemd_wrapper)
, upstart_wrapper_(upstart_wrapper)
, shield_factory_(shield_factory)
, suspend_inhibitor_manager_(std::make_shared<SuspendInhibitorManager>())
@@ -117,6 +121,8 @@ Controller::Controller(DBusManager::Ptr const& dbus_manager,
if (animation::GetDirection(fade_animator_) == animation::Direction::BACKWARD)
{
+ auto events_cb = sigc::track_obj(sigc::mem_fun(this, &Controller::OnLockScreenInputEvent), *primary_shield_);
+ input::Monitor::Get().UnregisterClient(events_cb);
primary_shield_connections_.Clear();
uscreen_connection_->block();
hidden_window_connection_->block();
@@ -129,8 +135,9 @@ Controller::Controller(DBusManager::Ptr const& dbus_manager,
shields_.clear();
upstart_wrapper_->Emit("desktop-unlock");
+ systemd_wrapper_->Stop(SYSTEMD_LOCK_TARGET);
accelerator_controller_.reset();
- indicators_.reset();
+ menu_manager_.reset();
}
else if (!prompt_activation_)
{
@@ -195,6 +202,20 @@ void Controller::OnPrimaryShieldMotion(int x, int y)
break;
}
}
+}
+
+void Controller::OnLockScreenInputEvent(XEvent const& event)
+{
+ switch (event.type)
+ {
+ case MotionNotify:
+ case ButtonPress:
+ if (primary_shield_->IsIndicatorOpen())
+ break;
+ case ButtonRelease:
+ OnPrimaryShieldMotion(event.xmotion.x_root, event.xmotion.y_root);
+ break;
+ }
ResetPostLockScreenSaver();
}
@@ -206,11 +227,8 @@ void Controller::SetupPrimaryShieldConnections()
primary_shield_connections_.Clear();
- auto move_cb = sigc::mem_fun(this, &Controller::OnPrimaryShieldMotion);
- primary_shield_connections_.Add(primary_shield_->grab_motion.connect(move_cb));
-
- auto key_cb = sigc::hide(sigc::hide(sigc::mem_fun(this, &Controller::ResetPostLockScreenSaver)));
- primary_shield_connections_.Add(primary_shield_->grab_key.connect(key_cb));
+ auto events_cb = sigc::track_obj(sigc::mem_fun(this, &Controller::OnLockScreenInputEvent), *primary_shield_);
+ input::Monitor::Get().RegisterClient(input::Events::INPUT, events_cb);
if (!session_manager_->is_locked())
{
@@ -252,7 +270,7 @@ void Controller::EnsureShields(std::vector<nux::Geometry> const& monitors)
if (i >= shields_size)
{
- shield = shield_factory_->CreateShield(session_manager_, indicators_, accelerator_controller_->GetAccelerators(), prompt_view, i, i == primary);
+ shield = shield_factory_->CreateShield(session_manager_, menu_manager_, accelerator_controller_->GetAccelerators(), prompt_view, i, i == primary);
is_new = true;
}
@@ -314,10 +332,19 @@ void Controller::HideBlankWindow()
blank_window_->ShowWindow(false);
animation::SetValue(blank_window_animator_, animation::Direction::BACKWARD);
+ if (prompt_activation_)
+ BlankWindowGrabEnable(false);
+
blank_window_.Release();
lockscreen_delay_timeout_.reset();
}
+void Controller::OnBlankWindowInputEvent(XEvent const&)
+{
+ if (!lockscreen_timeout_)
+ HideBlankWindow();
+}
+
void Controller::BlankWindowGrabEnable(bool grab)
{
if (!blank_window_)
@@ -325,41 +352,29 @@ void Controller::BlankWindowGrabEnable(bool grab)
if (grab)
{
- for (auto const& shield : shields_)
+ if (!primary_shield_.IsValid())
{
- shield->UnGrabPointer();
- shield->UnGrabKeyboard();
+ blank_window_->EnableInputWindow(true);
+ blank_window_->GrabPointer();
+ blank_window_->GrabKeyboard();
}
- blank_window_->EnableInputWindow(true);
- blank_window_->GrabPointer();
- blank_window_->GrabKeyboard();
+ input::Monitor::Get().RegisterClient(input::Events::INPUT, sigc::mem_fun(this, &Controller::OnBlankWindowInputEvent));
nux::GetWindowCompositor().SetAlwaysOnFrontWindow(blank_window_.GetPointer());
-
- blank_window_->mouse_move.connect([this](int, int, int dx, int dy, unsigned long, unsigned long) {
- if ((dx || dy) && !lockscreen_timeout_) HideBlankWindow();
- });
- blank_window_->key_down.connect([this] (unsigned long et, unsigned long k, unsigned long s, const char* c, unsigned short kc) {
- if (prompt_view_.GetPointer() && prompt_view_->focus_view())
- prompt_view_->focus_view()->key_down.emit(et, k, s, c, kc);
- if (!lockscreen_timeout_) HideBlankWindow();
- });
- blank_window_->mouse_down.connect([this] (int, int, unsigned long, unsigned long) {
- if (!lockscreen_timeout_) HideBlankWindow();
- });
}
else
{
- blank_window_->UnGrabPointer();
- blank_window_->UnGrabKeyboard();
+ input::Monitor::Get().UnregisterClient(sigc::mem_fun(this, &Controller::OnBlankWindowInputEvent));
- for (auto const& shield : shields_)
+ if (primary_shield_.IsValid())
{
- if (!shield->primary())
- continue;
-
- shield->GrabPointer();
- shield->GrabKeyboard();
+ primary_shield_->GrabPointer();
+ primary_shield_->GrabKeyboard();
+ }
+ else
+ {
+ blank_window_->UnGrabPointer();
+ blank_window_->UnGrabKeyboard();
}
}
}
@@ -382,6 +397,7 @@ void Controller::OnLockRequested(bool prompt)
if (prompt)
{
EnsureBlankWindow();
+ BlankWindowGrabEnable(true);
blank_window_->SetOpacity(1.0);
}
@@ -462,8 +478,10 @@ void Controller::OnScreenSaverActivationRequest(bool activate)
void Controller::LockScreen()
{
- indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>();
+ menu_manager_ = std::make_shared<menu::Manager>(std::make_shared<indicator::LockScreenDBusIndicators>(), key_grabber_);
+ menu_manager_->Indicators()->icon_paths_changed.clear(); // Ignore custom icon themes for lockscreen, see bug #1635625
upstart_wrapper_->Emit("desktop-lock");
+ systemd_wrapper_->Start(SYSTEMD_LOCK_TARGET);
accelerator_controller_ = std::make_shared<AcceleratorController>(key_grabber_);
auto activate_key = WindowManager::Default().activate_indicators_key();
diff --git a/lockscreen/LockScreenController.h b/lockscreen/LockScreenController.h
index c5f47ef13..f1b50426e 100644
--- a/lockscreen/LockScreenController.h
+++ b/lockscreen/LockScreenController.h
@@ -30,7 +30,7 @@
#include "SuspendInhibitorManager.h"
#include "ScreenSaverDBusManager.h"
#include "unity-shared/BackgroundEffectHelper.h"
-#include "unity-shared/KeyGrabber.h"
+#include "unity-shared/SystemdWrapper.h"
#include "unity-shared/UpstartWrapper.h"
namespace unity
@@ -46,6 +46,7 @@ public:
typedef std::shared_ptr<Controller> Ptr;
Controller(DBusManager::Ptr const&, session::Manager::Ptr const&, key::Grabber::Ptr const&,
+ SystemdWrapper::Ptr const& systemd_wrapper = std::make_shared<SystemdWrapper>(),
UpstartWrapper::Ptr const& upstart_wrapper = std::make_shared<UpstartWrapper>(),
ShieldFactoryInterface::Ptr const& shield_factory = std::make_shared<ShieldFactory>(),
bool test_mode = false);
@@ -77,6 +78,8 @@ private:
void OnPresenceStatusChanged(bool idle);
void OnScreenSaverActivationRequest(bool activate);
void OnPrimaryShieldMotion(int x, int y);
+ void OnLockScreenInputEvent(XEvent const&);
+ void OnBlankWindowInputEvent(XEvent const&);
std::vector<nux::ObjectPtr<BaseShield>> shields_;
nux::ObjectWeakPtr<BaseShield> primary_shield_;
@@ -85,9 +88,10 @@ private:
DBusManager::Ptr dbus_manager_;
session::Manager::Ptr session_manager_;
+ menu::Manager::Ptr menu_manager_;
key::Grabber::Ptr key_grabber_;
- indicator::Indicators::Ptr indicators_;
AcceleratorController::Ptr accelerator_controller_;
+ SystemdWrapper::Ptr systemd_wrapper_;
UpstartWrapper::Ptr upstart_wrapper_;
ShieldFactoryInterface::Ptr shield_factory_;
SuspendInhibitorManager::Ptr suspend_inhibitor_manager_;
diff --git a/lockscreen/LockScreenPanel.cpp b/lockscreen/LockScreenPanel.cpp
index d2fbc8d39..168a46c6e 100644
--- a/lockscreen/LockScreenPanel.cpp
+++ b/lockscreen/LockScreenPanel.cpp
@@ -24,7 +24,7 @@
#include "LockScreenSettings.h"
#include "panel/PanelIndicatorsView.h"
-#include "unity-shared/CairoTexture.h"
+#include "unity-shared/InputMonitor.h"
#include "unity-shared/StaticCairoText.h"
#include "unity-shared/PanelStyle.h"
#include "unity-shared/RawPixel.h"
@@ -38,24 +38,24 @@ namespace lockscreen
namespace
{
const RawPixel PADDING = 5_em;
+const nux::Color BG_COLOR(0.1, 0.1, 0.1, 0.4);
}
using namespace indicator;
using namespace panel;
-Panel::Panel(int monitor_, Indicators::Ptr const& indicators, session::Manager::Ptr const& session_manager)
+Panel::Panel(int monitor_, menu::Manager::Ptr const& menu_manager, session::Manager::Ptr const& session_manager)
: nux::View(NUX_TRACKER_LOCATION)
, active(false)
, monitor(monitor_)
- , indicators_(indicators)
+ , menu_manager_(menu_manager)
, needs_geo_sync_(true)
{
double scale = unity::Settings::Instance().em(monitor)->DPIScale();
auto* layout = new nux::HLayout();
layout->SetLeftAndRightPadding(PADDING.CP(scale), 0);
SetLayout(layout);
-
- BuildTexture();
+ UpdateSize();
// Add setting
auto *hostname = new StaticCairoText(session_manager->HostName());
@@ -72,34 +72,33 @@ Panel::Panel(int monitor_, Indicators::Ptr const& indicators, session::Manager::
indicators_view_->on_indicator_updated.connect(sigc::mem_fun(this, &Panel::OnIndicatorViewUpdated));
layout->AddView(indicators_view_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
- for (auto const& indicator : indicators_->GetIndicators())
+ auto indicators = menu_manager_->Indicators();
+ menu_manager_->RegisterTracker(GetPanelName(), (sigc::track_obj([this] (int x, int y, double speed) {
+ indicators_view_->ActivateEntryAt(x, y);
+ }, *this)));
+
+ for (auto const& indicator : indicators->GetIndicators())
AddIndicator(indicator);
- indicators_->on_object_added.connect(sigc::mem_fun(this, &Panel::AddIndicator));
- indicators_->on_object_removed.connect(sigc::mem_fun(this, &Panel::RemoveIndicator));
- indicators_->on_entry_show_menu.connect(sigc::mem_fun(this, &Panel::OnEntryShowMenu));
- indicators_->on_entry_activated.connect(sigc::mem_fun(this, &Panel::OnEntryActivated));
- indicators_->on_entry_activate_request.connect(sigc::mem_fun(this, &Panel::OnEntryActivateRequest));
+ indicators->on_object_added.connect(sigc::mem_fun(this, &Panel::AddIndicator));
+ indicators->on_object_removed.connect(sigc::mem_fun(this, &Panel::RemoveIndicator));
+ indicators->on_entry_show_menu.connect(sigc::mem_fun(this, &Panel::OnEntryShowMenu));
+ indicators->on_entry_activated.connect(sigc::mem_fun(this, &Panel::OnEntryActivated));
+ indicators->on_entry_activate_request.connect(sigc::mem_fun(this, &Panel::OnEntryActivateRequest));
monitor.changed.connect([this, hostname] (int monitor) {
double scale = unity::Settings::Instance().em(monitor)->DPIScale();
hostname->SetScale(scale);
static_cast<nux::HLayout*>(GetLayout())->SetLeftAndRightPadding(PADDING.CP(scale), 0);
indicators_view_->SetMonitor(monitor);
- BuildTexture();
+ UpdateSize();
QueueRelayout();
});
}
-void Panel::BuildTexture()
+void Panel::UpdateSize()
{
int height = panel::Style::Instance().PanelHeight(monitor);
- nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, 1, height);
- auto* cr = context.GetInternalContext();
- cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
- cairo_paint_with_alpha(cr, 0.4);
- bg_texture_ = texture_ptr_from_cairo_graphics(context);
-
view_layout_->SetMinimumHeight(height);
view_layout_->SetMaximumHeight(height);
}
@@ -165,12 +164,7 @@ void Panel::OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, in
if (!GetInputEventSensitivity())
return;
- if (!active)
- {
- // This is ugly... But Nux fault!
- WindowManager::Default().UnGrabMousePointer(CurrentTime, button, x, y);
- active = true;
- }
+ active = true;
}
void Panel::OnEntryActivateRequest(std::string const& entry_id)
@@ -184,36 +178,16 @@ void Panel::OnEntryActivated(std::string const& panel, std::string const& entry_
if (!GetInputEventSensitivity() || (!panel.empty() && panel != GetPanelName()))
return;
- bool active = !entry_id.empty();
+ bool valid_entry = !entry_id.empty();
- if (active && !WindowManager::Default().IsScreenGrabbed())
+ if (valid_entry && !WindowManager::Default().IsScreenGrabbed())
{
// The menu didn't grab the keyboard, let's take it back.
nux::GetWindowCompositor().GrabKeyboardAdd(static_cast<nux::BaseWindow*>(GetTopLevelViewWindow()));
}
- if (active && !track_menu_pointer_timeout_)
- {
- track_menu_pointer_timeout_.reset(new glib::Timeout(16));
- track_menu_pointer_timeout_->Run([this] {
- nux::Point const& mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
- if (tracked_pointer_pos_ != mouse)
- {
- if (GetAbsoluteGeometry().IsPointInside(mouse.x, mouse.y))
- indicators_view_->ActivateEntryAt(mouse.x, mouse.y);
-
- tracked_pointer_pos_ = mouse;
- }
-
- return true;
- });
- }
- else if (!active)
- {
- track_menu_pointer_timeout_.reset();
- tracked_pointer_pos_ = {-1, -1};
- this->active = false;
- }
+ if (!valid_entry)
+ active = valid_entry;
}
void Panel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
@@ -227,12 +201,7 @@ void Panel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
graphics_engine.PushClippingRectangle(geo);
nux::GetPainter().PaintBackground(graphics_engine, geo);
- nux::TexCoordXForm texxform;
- texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP);
- graphics_engine.QRP_1Tex(geo.x, geo.y, geo.width, geo.height,
- bg_texture_->GetDeviceTexture(), texxform,
- nux::color::White);
-
+ graphics_engine.QRP_Color(geo.x, geo.y, geo.width, geo.height, BG_COLOR);
view_layout_->ProcessDraw(graphics_engine, force_draw);
graphics_engine.PopClippingRectangle();
@@ -242,7 +211,7 @@ void Panel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
{
EntryLocationMap locations;
indicators_view_->GetGeometryForSync(locations);
- indicators_->SyncGeometries(GetPanelName(), locations);
+ menu_manager_->Indicators()->SyncGeometries(GetPanelName(), locations);
needs_geo_sync_ = false;
}
}
diff --git a/lockscreen/LockScreenPanel.h b/lockscreen/LockScreenPanel.h
index 664eccf50..cab2ae3ae 100644
--- a/lockscreen/LockScreenPanel.h
+++ b/lockscreen/LockScreenPanel.h
@@ -22,9 +22,9 @@
#include <Nux/Nux.h>
#include <Nux/View.h>
-#include "UnityCore/Indicators.h"
#include "UnityCore/GLibSource.h"
#include "UnityCore/SessionManager.h"
+#include "unity-shared/MenuManager.h"
namespace unity
{
@@ -39,7 +39,7 @@ namespace lockscreen
class Panel : public nux::View
{
public:
- Panel(int monitor, indicator::Indicators::Ptr const&, session::Manager::Ptr const&);
+ Panel(int monitor, menu::Manager::Ptr const&, session::Manager::Ptr const&);
nux::Property<bool> active;
nux::Property<int> monitor;
@@ -55,20 +55,16 @@ private:
void AddIndicator(indicator::Indicator::Ptr const&);
void RemoveIndicator(indicator::Indicator::Ptr const&);
void OnIndicatorViewUpdated();
- void OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const& geo);
+ void OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const&);
void OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, int y, unsigned button);
void OnEntryActivateRequest(std::string const& entry_id);
- void BuildTexture();
+ void UpdateSize();
std::string GetPanelName() const;
- indicator::Indicators::Ptr indicators_;
+ menu::Manager::Ptr menu_manager_;
panel::PanelIndicatorsView* indicators_view_;
- nux::ObjectPtr<nux::BaseTexture> bg_texture_;
-
bool needs_geo_sync_;
- nux::Point tracked_pointer_pos_;
- glib::Source::UniquePtr track_menu_pointer_timeout_;
};
} // lockscreen namespace
diff --git a/lockscreen/LockScreenShield.cpp b/lockscreen/LockScreenShield.cpp
index 264cf7132..77d8fc574 100644
--- a/lockscreen/LockScreenShield.cpp
+++ b/lockscreen/LockScreenShield.cpp
@@ -32,11 +32,12 @@ namespace lockscreen
{
Shield::Shield(session::Manager::Ptr const& session_manager,
- indicator::Indicators::Ptr const& indicators,
+ menu::Manager::Ptr const& menu_manager,
Accelerators::Ptr const& accelerators,
nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
int monitor_num, bool is_primary)
- : BaseShield(session_manager, indicators, accelerators, prompt_view, monitor_num, is_primary)
+ : BaseShield(session_manager, accelerators, prompt_view, monitor_num, is_primary)
+ , menu_manager_(menu_manager)
, panel_view_(nullptr)
{
is_primary ? ShowPrimaryView() : ShowSecondaryView();
@@ -91,11 +92,11 @@ void Shield::ShowPrimaryView()
Panel* Shield::CreatePanel()
{
- if (!indicators_ || !session_manager_)
+ if (!menu_manager_ || !session_manager_)
return nullptr;
- panel_view_ = new Panel(monitor, indicators_, session_manager_);
- panel_active_conn_ = panel_view_->active.changed.connect([this] (bool active) {
+ panel_view_ = new Panel(monitor, menu_manager_, session_manager_);
+ panel_view_->active.changed.connect(sigc::track_obj([this] (bool active) {
if (primary())
{
if (active)
@@ -109,7 +110,7 @@ Panel* Shield::CreatePanel()
GrabScreen(false);
}
}
- });
+ }, *this));
return panel_view_;
}
@@ -118,8 +119,6 @@ nux::Area* Shield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsign
{
if (primary)
{
- grab_key.emit(modifiers, keysym);
-
if (accelerators_)
{
if (etype == nux::EVENT_KEY_DOWN)
@@ -133,17 +132,9 @@ nux::Area* Shield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsign
return panel_view_;
}
}
-
- if (prompt_view_)
- {
- auto* focus_view = prompt_view_->focus_view();
-
- if (focus_view && focus_view->GetInputEventSensitivity())
- return focus_view;
- }
}
- return nullptr;
+ return BaseShield::FindKeyFocusArea(etype, keysym, modifiers);
}
bool Shield::IsIndicatorOpen() const
diff --git a/lockscreen/LockScreenShield.h b/lockscreen/LockScreenShield.h
index 053e0102f..3df1ba837 100644
--- a/lockscreen/LockScreenShield.h
+++ b/lockscreen/LockScreenShield.h
@@ -20,8 +20,9 @@
#ifndef UNITY_LOCKSCREEN_SHIELD_H
#define UNITY_LOCKSCREEN_SHIELD_H
-#include <UnityCore/ConnectionManager.h>
#include "LockScreenBaseShield.h"
+#include "unity-shared/MenuManager.h"
+
namespace unity
{
@@ -35,7 +36,7 @@ class Shield : public BaseShield
{
public:
Shield(session::Manager::Ptr const&,
- indicator::Indicators::Ptr const&,
+ menu::Manager::Ptr const&,
Accelerators::Ptr const&,
nux::ObjectPtr<AbstractUserPromptView> const&,
int monitor, bool is_primary);
@@ -50,7 +51,7 @@ private:
void ShowPrimaryView() override;
Panel* CreatePanel();
- connection::Wrapper panel_active_conn_;
+ menu::Manager::Ptr menu_manager_;
Panel* panel_view_;
};
diff --git a/lockscreen/LockScreenShieldFactory.cpp b/lockscreen/LockScreenShieldFactory.cpp
index 4f8d51ade..45f4cccc0 100644
--- a/lockscreen/LockScreenShieldFactory.cpp
+++ b/lockscreen/LockScreenShieldFactory.cpp
@@ -28,7 +28,7 @@ namespace lockscreen
{
nux::ObjectPtr<BaseShield> ShieldFactory::CreateShield(session::Manager::Ptr const& session_manager,
- indicator::Indicators::Ptr const& indicators,
+ menu::Manager::Ptr const& menu_manager,
Accelerators::Ptr const& accelerators,
nux::ObjectPtr<AbstractUserPromptView> const& prompt_view,
int monitor, bool is_primary)
@@ -38,7 +38,7 @@ nux::ObjectPtr<BaseShield> ShieldFactory::CreateShield(session::Manager::Ptr con
if (Settings::Instance().desktop_type() == DesktopType::UBUNTUKYLIN)
shield = new KylinShield(session_manager, accelerators, prompt_view, monitor, is_primary);
else
- shield = new Shield(session_manager, indicators, accelerators, prompt_view, monitor, is_primary);
+ shield = new Shield(session_manager, menu_manager, accelerators, prompt_view, monitor, is_primary);
return shield;
}
diff --git a/lockscreen/LockScreenShieldFactory.h b/lockscreen/LockScreenShieldFactory.h
index 6910e097c..de3c52968 100644
--- a/lockscreen/LockScreenShieldFactory.h
+++ b/lockscreen/LockScreenShieldFactory.h
@@ -22,7 +22,7 @@
#include <NuxCore/NuxCore.h>
#include "UnityCore/SessionManager.h"
-#include "UnityCore/Indicators.h"
+#include "unity-shared/MenuManager.h"
#include "LockScreenAccelerators.h"
namespace unity
@@ -41,7 +41,7 @@ struct ShieldFactoryInterface
virtual ~ShieldFactoryInterface() = default;
virtual nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,
- indicator::Indicators::Ptr const&,
+ menu::Manager::Ptr const&,
Accelerators::Ptr const&,
nux::ObjectPtr<AbstractUserPromptView> const&,
int monitor, bool is_primary) = 0;
@@ -50,7 +50,7 @@ struct ShieldFactoryInterface
struct ShieldFactory : ShieldFactoryInterface
{
nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,
- indicator::Indicators::Ptr const&,
+ menu::Manager::Ptr const&,
Accelerators::Ptr const&,
nux::ObjectPtr<AbstractUserPromptView> const&,
int monitor, bool is_primary) override;
diff --git a/lockscreen/UserAuthenticatorPam.cpp b/lockscreen/UserAuthenticatorPam.cpp
index 1f4da84c5..0b2c9f2b2 100644
--- a/lockscreen/UserAuthenticatorPam.cpp
+++ b/lockscreen/UserAuthenticatorPam.cpp
@@ -39,8 +39,9 @@ bool UserAuthenticatorPam::AuthenticateStart(std::string const& username,
first_prompt_ = true;
username_ = username;
authenticate_cb_ = authenticate_cb;
+ pam_handle_ = nullptr;
- if (!InitPam())
+ if (!InitPam() || !pam_handle_)
return false;
glib::Object<GTask> task(g_task_new(nullptr, cancellable_, [] (GObject*, GAsyncResult*, gpointer data) {
@@ -66,7 +67,7 @@ bool UserAuthenticatorPam::AuthenticateStart(std::string const& username,
if (unity::Settings::Instance().pam_check_account_type())
self->status_ = status2;
- pam_setcred (self->pam_handle_, PAM_REINITIALIZE_CRED);
+ pam_setcred(self->pam_handle_, PAM_REINITIALIZE_CRED);
}
});
diff --git a/panel/PanelIndicatorEntryView.cpp b/panel/PanelIndicatorEntryView.cpp
index 67a80956b..da5635c99 100644
--- a/panel/PanelIndicatorEntryView.cpp
+++ b/panel/PanelIndicatorEntryView.cpp
@@ -33,6 +33,8 @@
#include "unity-shared/RawPixel.h"
#include "unity-shared/WindowManager.h"
#include "unity-shared/ThemeSettings.h"
+#include "unity-shared/UBusWrapper.h"
+#include "unity-shared/UBusMessages.h"
#include "unity-shared/UnitySettings.h"
namespace unity
@@ -117,6 +119,9 @@ void PanelIndicatorEntryView::OnMouseDown(int x, int y, long button_flags, long
}
else
{
+ if (overlay_showing_)
+ UBusManager::SendMessage(UBUS_OVERLAY_CLOSE_REQUEST);
+
WindowManager& wm = WindowManager::Default();
if (wm.IsExpoActive())
@@ -140,6 +145,11 @@ void PanelIndicatorEntryView::OnMouseDown(int x, int y, long button_flags, long
wm.TerminateScale();
}
+ // This is ugly... But Nux fault!
+ auto const& abs_geo = GetAbsoluteGeometry();
+ guint64 timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
+ WindowManager::Default().UnGrabMousePointer(timestamp, button, abs_geo.x, abs_geo.y);
+
Activate(button);
}
}
diff --git a/panel/PanelMenuView.cpp b/panel/PanelMenuView.cpp
index f2aa86053..2bcdd494c 100644
--- a/panel/PanelMenuView.cpp
+++ b/panel/PanelMenuView.cpp
@@ -102,7 +102,6 @@ PanelMenuView::PanelMenuView(menu::Manager::Ptr const& menus)
, ignore_menu_visibility_(false)
, integrated_menus_(menu_manager_->integrated_menus())
, always_show_menus_(menu_manager_->always_show_menus())
- , ignore_leave_events_(false)
, desktop_name_(get_current_desktop())
{
if (ApplicationWindowPtr const& win = ApplicationManager::Default().GetActiveWindow())
@@ -724,7 +723,7 @@ void PanelMenuView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw
if (new_application_ && !is_inside_)
{
- if (opacity() != 1.0f)
+ if (opacity() != 1.0f && menu_manager_->discovery() > 0)
StartFadeIn(menu_manager_->discovery_fadein());
}
else
@@ -1814,14 +1813,9 @@ void PanelMenuView::OnPanelViewMouseEnter(int x, int y, unsigned long mouse_butt
}
}
-void PanelMenuView::IgnoreLeaveEvents(bool ignore)
-{
- ignore_leave_events_ = ignore;
-}
-
void PanelMenuView::OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state)
{
- if (always_show_menus_ || ignore_leave_events_)
+ if (always_show_menus_)
return;
if (is_inside_)
diff --git a/panel/PanelMenuView.h b/panel/PanelMenuView.h
index 93310d10a..7d3effb84 100644
--- a/panel/PanelMenuView.h
+++ b/panel/PanelMenuView.h
@@ -56,7 +56,6 @@ public:
bool HasKeyActivableMenus() const;
void NotifyAllMenusClosed();
- void IgnoreLeaveEvents(bool);
virtual void AddIndicator(indicator::Indicator::Ptr const& indicator);
@@ -192,7 +191,6 @@ private:
bool ignore_menu_visibility_;
bool integrated_menus_;
bool always_show_menus_;
- bool ignore_leave_events_;
nux::Geometry monitor_geo_;
const std::string desktop_name_;
diff --git a/panel/PanelView.cpp b/panel/PanelView.cpp
index 01c21b403..cd08c46cd 100644
--- a/panel/PanelView.cpp
+++ b/panel/PanelView.cpp
@@ -42,7 +42,8 @@ namespace panel
namespace
{
const RawPixel TRIANGLE_THRESHOLD = 5_em;
-const int refine_gradient_midpoint = 959;
+const double SCRUB_VELOCITY_THRESHOLD = 0.05;
+const RawPixel REFINE_GRADIENT_MIDPOINT = 959;
}
@@ -113,10 +114,9 @@ PanelView::PanelView(MockableBaseWindow* parent, menu::Manager::Ptr const& menus
remote_->on_object_added.connect(sigc::mem_fun(this, &PanelView::OnObjectAdded));
remote_->on_object_removed.connect(sigc::mem_fun(this, &PanelView::OnObjectRemoved));
- remote_->on_entry_activated.connect(sigc::mem_fun(this, &PanelView::OnEntryActivated));
- remote_->on_entry_show_menu.connect(sigc::mem_fun(this, &PanelView::OnEntryShowMenu));
menus->key_activate_entry.connect(sigc::mem_fun(this, &PanelView::ActivateEntry));
menus->open_first.connect(sigc::mem_fun(this, &PanelView::ActivateFirstSensitive));
+ menus->RegisterTracker(GetPanelName(), sigc::mem_fun(this, &PanelView::OnMenuPointerMoved));
ubus_manager_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &PanelView::OnOverlayHidden));
ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &PanelView::OnOverlayShown));
@@ -374,7 +374,7 @@ PanelView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
nux::TexCoordXForm refine_texxform;
- int refine_x_pos = geo.x + (stored_dash_width_ - refine_gradient_midpoint);
+ int refine_x_pos = geo.x + (stored_dash_width_ - REFINE_GRADIENT_MIDPOINT.CP(Settings::Instance().em(monitor_)));
if (Settings::Instance().launcher_position() == LauncherPosition::LEFT)
refine_x_pos += unity::Settings::Instance().LauncherSize(monitor_);
@@ -473,7 +473,7 @@ PanelView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
nux::Geometry refine_geo = geo;
- int refine_x_pos = geo.x + (stored_dash_width_ - refine_gradient_midpoint);
+ int refine_x_pos = geo.x + (stored_dash_width_ - REFINE_GRADIENT_MIDPOINT.CP(Settings::Instance().em(monitor_)));
if (Settings::Instance().launcher_position() == LauncherPosition::LEFT)
refine_x_pos += unity::Settings::Instance().LauncherSize(monitor_);
@@ -627,7 +627,7 @@ void PanelView::OnIndicatorViewUpdated()
QueueDraw();
}
-void PanelView::OnMenuPointerMoved(int x, int y)
+void PanelView::OnMenuPointerMoved(int x, int y, double speed)
{
nux::Geometry const& geo = GetAbsoluteGeometry();
@@ -648,116 +648,6 @@ void PanelView::OnMenuPointerMoved(int x, int y)
}
}
-static bool PointInTriangle(nux::Point const& p, nux::Point const& t0, nux::Point const& t1, nux::Point const& t2)
-{
- int s = t0.y * t2.x - t0.x * t2.y + (t2.y - t0.y) * p.x + (t0.x - t2.x) * p.y;
- int t = t0.x * t1.y - t0.y * t1.x + (t0.y - t1.y) * p.x + (t1.x - t0.x) * p.y;
-
- if ((s < 0) != (t < 0))
- return false;
-
- int A = -t1.y * t2.x + t0.y * (t2.x - t1.x) + t0.x * (t1.y - t2.y) + t1.x * t2.y;
- if (A < 0)
- {
- s = -s;
- t = -t;
- A = -A;
- }
-
- return s > 0 && t > 0 && (s + t) < A;
-}
-
-static double GetMouseVelocity(nux::Point const& p0, nux::Point const& p1, util::Timer &timer)
-{
- int dx, dy;
- double speed;
- auto millis = timer.ElapsedMicroSeconds();
-
- if (millis == 0)
- return 1;
-
- dx = p0.x - p1.x;
- dy = p0.y - p1.y;
-
- speed = sqrt(dx * dx + dy * dy) / millis * 1000;
-
- return speed;
-}
-
-bool PanelView::TrackMenuPointer()
-{
- nux::Point const& mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
- double speed = GetMouseVelocity(mouse, tracked_pointer_pos_, mouse_tracker_timer_);
-
- mouse_tracker_timer_.Reset();
- tracked_pointer_pos_ = mouse;
-
- double scale = Settings::Instance().em(monitor_)->DPIScale();
- if (speed > 0 && PointInTriangle(mouse,
- nux::Point(triangle_top_corner_.x, std::max(triangle_top_corner_.y - TRIANGLE_THRESHOLD.CP(scale), 0)),
- nux::Point(menu_geo_.x, menu_geo_.y),
- nux::Point(menu_geo_.x + menu_geo_.width, menu_geo_.y)))
- {
- return true;
- }
-
- if (mouse != triangle_top_corner_)
- {
- triangle_top_corner_ = mouse;
- OnMenuPointerMoved(mouse.x, mouse.y);
- }
-
- return true;
-}
-
-void PanelView::OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const& menu_geo)
-{
- if (!panel.empty() && panel != GetPanelName())
- return;
-
- menu_geo_ = menu_geo;
-
- bool active = !entry_id.empty();
- if (active && !track_menu_pointer_timeout_)
- {
- //
- // Track menus being scrubbed at 60Hz (about every 16 millisec)
- // It might sound ugly, but it's far nicer (and more responsive) than the
- // code it replaces which used to capture motion events in another process
- // (unity-panel-service) and send them to us over dbus.
- // NOTE: The reason why we have to use a timer instead of tracking motion
- // events is because the motion events will never be delivered to this
- // process. All the motion events will go to unity-panel-service while
- // scrubbing because the active panel menu has (needs) the pointer grab.
- //
- mouse_tracker_timer_.Reset();
- triangle_top_corner_ = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
- track_menu_pointer_timeout_.reset(new glib::Timeout(16));
- track_menu_pointer_timeout_->Run(sigc::mem_fun(this, &PanelView::TrackMenuPointer));
- }
- else if (!active)
- {
- track_menu_pointer_timeout_.reset();
- menu_view_->NotifyAllMenusClosed();
- tracked_pointer_pos_ = {-1, -1};
- }
-
- if (overlay_is_open_)
- ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST);
-}
-
-void PanelView::OnEntryShowMenu(std::string const& entry_id, unsigned xid,
- int x, int y, unsigned button)
-{
- if (!track_menu_pointer_timeout_)
- {
- // This is ugly... But Nux fault!
- menu_view_->IgnoreLeaveEvents(true);
- WindowManager::Default().UnGrabMousePointer(CurrentTime, button, x, y);
- menu_view_->IgnoreLeaveEvents(false);
- }
-}
-
bool PanelView::ActivateFirstSensitive()
{
if (!IsActive())
@@ -768,7 +658,6 @@ bool PanelView::ActivateFirstSensitive()
{
// Since this only happens on keyboard events, we need to prevent that the
// pointer tracker would select another entry.
- tracked_pointer_pos_ = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
return true;
}
@@ -785,7 +674,6 @@ bool PanelView::ActivateEntry(std::string const& entry_id)
{
// Since this only happens on keyboard events, we need to prevent that the
// pointer tracker would select another entry.
- tracked_pointer_pos_ = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
return true;
}
@@ -867,6 +755,9 @@ void PanelView::SetMonitor(int monitor)
menu_view_->SetMonitor(monitor);
indicators_->SetMonitor(monitor);
Resize();
+
+ if (WindowManager::Default().IsScaleActive())
+ EnableOverlayMode(true);
}
void PanelView::Resize()
diff --git a/panel/PanelView.h b/panel/PanelView.h
index c25d251e5..48a6a4bed 100644
--- a/panel/PanelView.h
+++ b/panel/PanelView.h
@@ -35,7 +35,6 @@
#include "unity-shared/Introspectable.h"
#include "unity-shared/MenuManager.h"
#include "unity-shared/MockableBaseWindow.h"
-#include "unity-shared/Timer.h"
#include "PanelMenuView.h"
#include "PanelTray.h"
#include "PanelIndicatorsView.h"
@@ -88,9 +87,6 @@ protected:
void OnObjectAdded(indicator::Indicator::Ptr const& proxy);
void OnObjectRemoved(indicator::Indicator::Ptr const& proxy);
void OnIndicatorViewUpdated();
- void OnMenuPointerMoved(int x, int y);
- void OnEntryActivated(std::string const& panel, std::string const& entry_id, nux::Rect const& geo);
- void OnEntryShowMenu(std::string const& entry_id, unsigned xid, int x, int y, unsigned button);
private:
std::string GetPanelName() const;
@@ -100,6 +96,8 @@ private:
void OnSpreadInitiate();
void OnSpreadTerminate();
void OnLowGfxChanged();
+ void OnMenuPointerMoved(int x, int y, double speed);
+ void OnActiveEntryEvent(XEvent const&);
void EnableOverlayMode(bool);
void LoadTextures();
@@ -109,7 +107,6 @@ private:
bool IsTransparent();
void UpdateBackground();
void ForceUpdateBackground();
- bool TrackMenuPointer();
void SyncGeometries();
void AddPanelView(PanelIndicatorsView* child, unsigned int stretchFactor);
@@ -133,10 +130,6 @@ private:
BaseTexturePtr bg_refine_single_column_tex_;
std::unique_ptr<nux::AbstractPaintLayer> bg_refine_single_column_layer_;
- std::string active_overlay_;
- nux::Point tracked_pointer_pos_, triangle_top_corner_;
- util::Timer mouse_tracker_timer_;
-
bool is_dirty_;
bool opacity_maximized_toggle_;
bool needs_geo_sync_;
@@ -144,15 +137,13 @@ private:
float opacity_;
int monitor_;
int stored_dash_width_;
-
- nux::Geometry menu_geo_;
+ std::string active_overlay_;
connection::Manager on_indicator_updated_connections_;
connection::Manager maximized_opacity_toggle_connections_;
BackgroundEffectHelper bg_effect_helper_;
nux::ObjectPtr<nux::IOpenGLBaseTexture> bg_blur_texture_;
UBusManager ubus_manager_;
- glib::Source::UniquePtr track_menu_pointer_timeout_;
};
} // namespace panel
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp
index 54da52e11..70ffab1e9 100644
--- a/plugins/unityshell/src/unityshell.cpp
+++ b/plugins/unityshell/src/unityshell.cpp
@@ -572,8 +572,8 @@ void UnityScreen::InitAltTabNextWindow()
void UnityScreen::OnInitiateSpread()
{
scale_just_activated_ = super_keypressed_;
- spread_filter_ = std::make_shared<spread::Filter>();
- spread_filter_->text.changed.connect([this] (std::string const& filter) {
+ spread_widgets_ = std::make_shared<spread::Widgets>();
+ spread_widgets_->GetFilter()->text.changed.connect([this] (std::string const& filter) {
if (filter.empty())
{
sScreen->relayoutSlots(CompMatch::emptyMatch);
@@ -581,7 +581,7 @@ void UnityScreen::OnInitiateSpread()
else
{
CompMatch windows_match;
- auto const& filtered_windows = spread_filter_->FilteredWindows();
+ auto const& filtered_windows = spread_widgets_->GetFilter()->FilteredWindows();
for (auto const& swin : sScreen->getWindows())
{
@@ -612,7 +612,7 @@ void UnityScreen::OnInitiateSpread()
void UnityScreen::OnTerminateSpread()
{
- spread_filter_.reset();
+ spread_widgets_.reset();
for (auto const& swin : sScreen->getWindows())
UnityWindow::get(swin->window)->OnTerminateSpread();
@@ -865,7 +865,7 @@ void UnityScreen::DamageBlurUpdateRegion(nux::Geometry const& blur_update)
cScreen->damageRegion(CompRegionFromNuxGeo(blur_update));
}
-void UnityScreen::paintOutput()
+void UnityScreen::paintDisplay()
{
CompOutput *output = last_output_;
@@ -886,7 +886,7 @@ void UnityScreen::paintOutput()
current_draw_binding = old_read_binding;
#endif
- BackgroundEffectHelper::monitor_rect_.Set(0, 0, output->width(), output->height());
+ BackgroundEffectHelper::monitor_rect_.Set(0, 0, screen->width(), screen->height());
// If we have dirty helpers re-copy the backbuffer into a texture
if (dirty_helpers_on_this_frame_)
@@ -911,10 +911,10 @@ void UnityScreen::paintOutput()
for (CompRect const& rect : blur_region.rects())
{
- int x = nux::Clamp<int>(rect.x(), 0, output->width());
- int y = nux::Clamp<int>(output->height() - rect.y2(), 0, output->height());
- int width = std::min<int>(output->width() - rect.x(), rect.width());
- int height = std::min<int>(output->height() - y, rect.height());
+ int x = nux::Clamp<int>(rect.x(), 0, screen->width());
+ int y = nux::Clamp<int>(screen->height() - rect.y2(), 0, screen->height());
+ int width = std::min<int>(screen->width() - rect.x(), rect.width());
+ int height = std::min<int>(screen->height() - y, rect.height());
CHECKGL(glCopyTexSubImage2D(surface_target, 0, x, y, x, y, width, height));
}
@@ -1506,7 +1506,7 @@ bool UnityScreen::glPaintOutput(const GLScreenPaintAttrib& attrib,
doShellRepaint = false;
if (doShellRepaint)
- paintOutput();
+ paintDisplay();
return ret;
}
@@ -1747,7 +1747,7 @@ void UnityScreen::compizDamageNux(CompRegion const& damage)
auto const& geo = NuxGeometryFromCompRect(r);
wt->PresentWindowsIntersectingGeometryOnThisFrame(geo);
}
-
+
auto const& launchers = launcher_controller_->launchers();
for (auto const& launcher : launchers)
@@ -1859,8 +1859,13 @@ void UnityScreen::handleEvent(XEvent* event)
}
if (wm.IsScaleActive())
{
- if (spread_filter_ && spread_filter_->Visible())
- skip_other_plugins = spread_filter_->GetAbsoluteGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root);
+ if (spread_widgets_)
+ {
+ auto const& spread_filter = spread_widgets_->GetFilter();
+
+ if (spread_filter && spread_filter->Visible())
+ skip_other_plugins = spread_filter->GetAbsoluteGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root);
+ }
if (!skip_other_plugins)
{
@@ -1943,8 +1948,13 @@ void UnityScreen::handleEvent(XEvent* event)
}
else if (wm.IsScaleActive())
{
- if (spread_filter_ && spread_filter_->Visible())
- skip_other_plugins = spread_filter_->GetAbsoluteGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root);
+ if (spread_widgets_)
+ {
+ auto const& spread_filter = spread_widgets_->GetFilter();
+
+ if (spread_filter && spread_filter->Visible())
+ skip_other_plugins = spread_filter->GetAbsoluteGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root);
+ }
if (!skip_other_plugins)
{
@@ -2020,12 +2030,12 @@ void UnityScreen::handleEvent(XEvent* event)
}
}
- if (spread_filter_ && spread_filter_->Visible())
+ if (spread_widgets_ && spread_widgets_->GetFilter()->Visible())
{
if (key_sym == XK_Escape)
{
skip_other_plugins = true;
- spread_filter_->text = "";
+ spread_widgets_->GetFilter()->text = "";
}
}
@@ -2074,7 +2084,7 @@ void UnityScreen::handleEvent(XEvent* event)
skip_other_plugins = true;
}
- if (spread_filter_ && spread_filter_->Visible())
+ if (spread_widgets_ && spread_widgets_->GetFilter() && spread_widgets_->GetFilter()->Visible())
skip_other_plugins = false;
if (!skip_other_plugins &&
@@ -3015,9 +3025,9 @@ bool UnityWindow::glPaint(const GLWindowPaintAttrib& attrib,
wAttrib.opacity = 0.0;
int old_index = gWindow->glPaintGetCurrentIndex();
gWindow->glPaintSetCurrentIndex(MAXSHORT);
+ deco_win_->Paint(matrix, wAttrib, region, mask);
bool ret = gWindow->glPaint(wAttrib, matrix, region, mask);
gWindow->glPaintSetCurrentIndex(old_index);
- deco_win_->Paint(matrix, wAttrib, region, mask);
return ret;
}
}
@@ -3096,18 +3106,18 @@ bool UnityWindow::glDraw(const GLMatrix& matrix,
if (uScreen->doShellRepaint && window == uScreen->onboard_)
{
- uScreen->paintOutput();
+ uScreen->paintDisplay();
}
else if (uScreen->doShellRepaint &&
window == uScreen->firstWindowAboveShell &&
!uScreen->forcePaintOnTop() &&
!uScreen->fullscreenRegion.contains(window->geometry()))
{
- uScreen->paintOutput();
+ uScreen->paintDisplay();
}
else if (locked && CanBypassLockScreen())
{
- uScreen->paintOutput();
+ uScreen->paintDisplay();
}
enum class DrawPanelShadow
@@ -3191,6 +3201,9 @@ bool UnityWindow::glDraw(const GLMatrix& matrix,
bool UnityWindow::damageRect(bool initial, CompRect const& rect)
{
+ if (uScreen->lockscreen_controller_->IsLocked() && !CanBypassLockScreen())
+ return true;
+
if (initial)
deco_win_->Update();
@@ -3359,6 +3372,7 @@ void UnityWindow::windowNotify(CompWindowNotify n)
PluginAdapter::Default().UpdateShowDesktopState();
break;
case CompWindowNotifyBeforeDestroy:
+ deco_win_->Undecorate();
being_destroyed.emit();
break;
case CompWindowNotifyMinimize:
@@ -3419,7 +3433,7 @@ void UnityWindow::stateChangeNotify(unsigned int lastState)
uScreen->fullscreen_windows_.remove(window);
}
- deco_win_->Update();
+ deco_win_->UpdateWindowState(lastState);
PluginAdapter::Default().NotifyStateChange(window, window->state(), lastState);
window->stateChangeNotify(lastState);
}
@@ -3461,6 +3475,7 @@ void UnityWindow::moveNotify(int x, int y, bool immediate)
void UnityWindow::resizeNotify(int x, int y, int w, int h)
{
deco_win_->UpdateDecorationPositionDelayed();
+ CleanupCachedTextures();
PluginAdapter::Default().NotifyResized(window, x, y, w, h);
window->resizeNotify(x, y, w, h);
}
@@ -3970,6 +3985,8 @@ void UnityScreen::OnScreenLocked()
// We disable the edge barriers, to avoid blocking the mouse pointer during lockscreen
edge_barriers_->force_disable = true;
+
+ UpdateGesturesSupport();
}
void UnityScreen::OnScreenUnlocked()
@@ -3986,6 +4003,8 @@ void UnityScreen::OnScreenUnlocked()
screen->addAction(&action);
edge_barriers_->force_disable = false;
+
+ UpdateGesturesSupport();
}
std::string UnityScreen::GetLockStampFile() const
@@ -4210,9 +4229,11 @@ lockscreen::Controller::Ptr UnityScreen::lockscreen_controller()
void UnityScreen::UpdateGesturesSupport()
{
- Settings::Instance().gestures_launcher_drag() ? gestures_sub_launcher_->Activate() : gestures_sub_launcher_->Deactivate();
- Settings::Instance().gestures_dash_tap() ? gestures_sub_dash_->Activate() : gestures_sub_dash_->Deactivate();
- Settings::Instance().gestures_windows_drag_pinch() ? gestures_sub_windows_->Activate() : gestures_sub_windows_->Deactivate();
+ auto& s = Settings::Instance();
+ bool locked = lockscreen_controller_ && lockscreen_controller_->IsLocked();
+ (!locked && s.gestures_launcher_drag()) ? gestures_sub_launcher_->Activate() : gestures_sub_launcher_->Deactivate();
+ (!locked && s.gestures_dash_tap()) ? gestures_sub_dash_->Activate() : gestures_sub_dash_->Deactivate();
+ (!locked && s.gestures_windows_drag_pinch()) ? gestures_sub_windows_->Activate() : gestures_sub_windows_->Deactivate();
}
void UnityScreen::InitGesturesSupport()
@@ -4791,7 +4812,7 @@ void ScreenIntrospection::AddProperties(debug::IntrospectionData& introspection)
Introspectable::IntrospectableList ScreenIntrospection::GetIntrospectableChildren()
{
- IntrospectableList children({uScreen->spread_filter_.get()});
+ IntrospectableList children({uScreen->spread_widgets_ ? uScreen->spread_widgets_->GetFilter().get() : nullptr});
for (auto const& win : screen_->windows())
children.push_back(UnityWindow::get(win));
diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h
index a838e8731..a1b9704c7 100644
--- a/plugins/unityshell/src/unityshell.h
+++ b/plugins/unityshell/src/unityshell.h
@@ -56,6 +56,7 @@
#include "DashStyle.h"
#include "EdgeBarrierController.h"
#include "FavoriteStoreGSettings.h"
+#include "InputMonitor.h"
#include "ShortcutController.h"
#include "LauncherController.h"
#include "LockScreenController.h"
@@ -69,7 +70,7 @@
#include "SwitcherController.h"
#include "SessionController.h"
#include "SessionDBusManager.h"
-#include "SpreadFilter.h"
+#include "SpreadWidgets.h"
#include "UBusWrapper.h"
#include "UnityshellPrivate.h"
#include "UnityShowdesktopHandler.h"
@@ -180,7 +181,7 @@ private:
void nuxEpilogue();
/* nux draw wrapper */
- void paintOutput();
+ void paintDisplay();
void paintPanelShadow(CompRegion const& clip);
void setPanelShadowMatrix(const GLMatrix& matrix);
void updateBlurDamage();
@@ -319,6 +320,7 @@ private:
internal::FavoriteStoreGSettings favorite_store_;
ThumbnailGenerator thumbnail_generator_;
lockscreen::Settings lockscreen_settings_;
+ input::Monitor input_monitor_;
/* The window thread should be the last thing removed, as c++ does it in reverse order */
std::unique_ptr<nux::WindowThread> wt;
@@ -342,7 +344,7 @@ private:
ui::EdgeBarrierController::Ptr edge_barriers_;
debug::DebugDBusInterface debugger_;
std::unique_ptr<BGHash> bghash_;
- spread::Filter::Ptr spread_filter_;
+ spread::Widgets::Ptr spread_widgets_;
session::Manager::Ptr session_;
diff --git a/plugins/unityshell/unityshell.xml.in b/plugins/unityshell/unityshell.xml.in
index ee1469345..1820f27d2 100644
--- a/plugins/unityshell/unityshell.xml.in
+++ b/plugins/unityshell/unityshell.xml.in
@@ -39,6 +39,8 @@
<plugin>compiztoolbox</plugin>
<plugin>scale</plugin>
<plugin>expo</plugin>
+ <plugin>move</plugin>
+ <plugin>resize</plugin>
</requirement>
<conflict>
<plugin>decor</plugin>
diff --git a/resources/dash_bottom_right_corner_rotated.png b/resources/dash_bottom_right_corner_rotated.png
deleted file mode 100644
index ec458a101..000000000
--- a/resources/dash_bottom_right_corner_rotated.png
+++ /dev/null
Binary files differ
diff --git a/resources/dash_bottom_right_corner_rotated_mask.png b/resources/dash_bottom_right_corner_rotated_mask.png
deleted file mode 100644
index a0b8fe006..000000000
--- a/resources/dash_bottom_right_corner_rotated_mask.png
+++ /dev/null
Binary files differ
diff --git a/resources/dash_bottom_tile.png b/resources/dash_bottom_tile.png
deleted file mode 100644
index 963a034df..000000000
--- a/resources/dash_bottom_tile.png
+++ /dev/null
Binary files differ
diff --git a/resources/dash_top_border_tile.png b/resources/dash_top_border_tile.png
deleted file mode 100644
index a90e10432..000000000
--- a/resources/dash_top_border_tile.png
+++ /dev/null
Binary files differ
diff --git a/resources/dash_top_border_tile_mask.png b/resources/dash_top_border_tile_mask.png
deleted file mode 100644
index bc030c827..000000000
--- a/resources/dash_top_border_tile_mask.png
+++ /dev/null
Binary files differ
diff --git a/resources/dash_top_left_corner.png b/resources/dash_top_left_corner.png
deleted file mode 100644
index c3b8de33d..000000000
--- a/resources/dash_top_left_corner.png
+++ /dev/null
Binary files differ
diff --git a/resources/dash_top_left_corner_mask.png b/resources/dash_top_left_corner_mask.png
deleted file mode 100644
index 7f9e7e0c3..000000000
--- a/resources/dash_top_left_corner_mask.png
+++ /dev/null
Binary files differ
diff --git a/resources/dash_top_right_corner_rotated.png b/resources/dash_top_right_corner_rotated.png
deleted file mode 100644
index 7d2a1337e..000000000
--- a/resources/dash_top_right_corner_rotated.png
+++ /dev/null
Binary files differ
diff --git a/resources/dash_top_right_corner_rotated_mask.png b/resources/dash_top_right_corner_rotated_mask.png
deleted file mode 100644
index b17cf351e..000000000
--- a/resources/dash_top_right_corner_rotated_mask.png
+++ /dev/null
Binary files differ
diff --git a/resources/overlay_top_left_tile.png b/resources/overlay_top_left_tile.png
new file mode 100644
index 000000000..19157c277
--- /dev/null
+++ b/resources/overlay_top_left_tile.png
Binary files differ
diff --git a/services/CMakeLists.txt b/services/CMakeLists.txt
index 13a61716b..9a9f9e01f 100644
--- a/services/CMakeLists.txt
+++ b/services/CMakeLists.txt
@@ -35,7 +35,7 @@ set(PANEL_SOURCES
set(CFLAGS
${SERVICE_DEPS_CFLAGS}
${SERVICE_DEPS_CFLAGS_OTHER}
- "-Werror -Wall"
+ "-Werror -Wall -Wno-error=deprecated-declarations"
)
string (REPLACE ";" " " CFLAGS "${CFLAGS}")
@@ -51,10 +51,41 @@ link_directories(${LIB_PATHS})
add_executable(unity-panel-service ${PANEL_SOURCES})
target_link_libraries(unity-panel-service ${LIBS})
-install(TARGETS unity-panel-service DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/)
+install(TARGETS unity-panel-service DESTINATION ${UNITY_INSTALL_LIBDIR})
configure_file(unity-panel-service.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.conf)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
configure_file(unity-panel-service-lockscreen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
+
+##
+## Systemd Unit Files
+##
+
+# where to install
+# Uncomment when we drop Vivid
+# pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)
+set (SYSTEMD_USER_DIR "/usr/lib/systemd/user")
+message (STATUS "${SYSTEMD_USER_DIR} is the systemd user unit file install dir")
+
+configure_file (unity-panel-service.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service")
+configure_file (unity-panel-service-lockscreen.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service")
+
+install( FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service"
+ "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service"
+ "${CMAKE_CURRENT_SOURCE_DIR}/unity-screen-locked.target"
+ DESTINATION "${SYSTEMD_USER_DIR}")
+
+##
+## Upstart systemd override Job File
+##
+
+set (UPSTART_SYSTEMD_OVERRIDE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/upstart/systemd-session/upstart")
+message (STATUS "${UPSTART_SYSTEMD_OVERRIDE_DIR} is the Upstart override Job File for systemd dir")
+
+install (FILES
+ unity-panel-service.override
+ unity-panel-service-lockscreen.override
+ DESTINATION "${UPSTART_SYSTEMD_OVERRIDE_DIR}")
diff --git a/services/panel-service.c b/services/panel-service.c
index b9b86cd7f..4451fffa5 100644
--- a/services/panel-service.c
+++ b/services/panel-service.c
@@ -80,6 +80,7 @@ struct _PanelServicePrivate
gint last_right;
gint last_bottom;
guint32 last_menu_button;
+ guint64 last_open_time;
GSettings *gsettings;
KeyBinding menu_toggle;
@@ -92,6 +93,7 @@ struct _PanelServicePrivate
/* Globals */
static gboolean suppress_signals = FALSE;
+static void (*default_menu_shell_deactivate) (GtkMenuShell *menu_shell);
enum
{
@@ -138,6 +140,7 @@ static void sort_indicators (PanelService *);
static void notify_object (IndicatorObject *object);
static void update_keybinding (GSettings *, const gchar *, gpointer);
static void emit_upstart_event (const gchar *);
+static void menu_shell_deactivate_override (GtkMenuShell *menu_shell);
static gchar * get_indicator_entry_id_by_entry (IndicatorObjectEntry *entry);
static IndicatorObjectEntry * get_indicator_entry_by_id (PanelService *self, const gchar *entry_id);
static GdkFilterReturn event_filter (GdkXEvent *, GdkEvent *, PanelService *);
@@ -161,7 +164,7 @@ panel_service_class_dispose (GObject *self)
if (GTK_IS_WIDGET (priv->last_menu) &&
gtk_widget_get_realized (GTK_WIDGET (priv->last_menu)))
{
- gtk_menu_popdown (GTK_MENU (priv->last_menu));
+ panel_service_close_active_entry (PANEL_SERVICE (self));
g_signal_handlers_disconnect_by_data (priv->last_menu, self);
priv->last_menu = NULL;
}
@@ -435,6 +438,25 @@ get_indicator_entry_by_id (PanelService *self, const gchar *entry_id)
return entry;
}
+static const gchar *
+get_indicator_entry_id_by_menu (PanelService *self, GtkMenu *menu)
+{
+ GHashTableIter iter;
+ IndicatorObjectEntry* entry;
+ gchar *id;
+
+ g_hash_table_iter_init (&iter, self->priv->id2entry_hash);
+ while (g_hash_table_iter_next (&iter, (gpointer*) &id, (gpointer*) &entry))
+ {
+ if (entry && entry->menu == menu)
+ {
+ return id;
+ }
+ }
+
+ return NULL;
+}
+
static void
ensure_entry_menu_is_closed (PanelService *self,
const gchar *panel_id,
@@ -446,7 +468,9 @@ ensure_entry_menu_is_closed (PanelService *self,
if (GTK_IS_MENU (priv->last_menu) && priv->last_menu == entry->menu)
{
if (!priv->last_panel || !panel_id || g_strcmp0 (priv->last_panel, panel_id) == 0)
- gtk_menu_popdown (entry->menu);
+ {
+ panel_service_close_active_entry (self);
+ }
}
}
@@ -590,17 +614,15 @@ event_filter (GdkXEvent *ev, GdkEvent *gev, PanelService *self)
event_matches_keybinding (event->mods.base, keysym, &priv->show_dash) ||
event_matches_keybinding (event->mods.base, keysym, &priv->show_hud))
{
- if (GTK_IS_MENU (priv->last_menu))
- gtk_menu_popdown (GTK_MENU (priv->last_menu));
-
+ panel_service_close_active_entry (self);
ret = GDK_FILTER_REMOVE;
}
else if (event->mods.base != GDK_CONTROL_MASK)
{
if (!IsModifierKey (keysym) && (event->mods.base != 0 || is_allowed_keysym (keysym)))
{
- if (GTK_IS_MENU (priv->last_menu) && !is_control_keysym (keysym))
- gtk_menu_popdown (GTK_MENU (priv->last_menu));
+ if (!is_control_keysym (keysym))
+ panel_service_close_active_entry (self);
reinject_key_event_to_root_window (event);
ret = GDK_FILTER_REMOVE;
@@ -1370,9 +1392,7 @@ on_indicator_menu_show (IndicatorObject *object,
if (!entry)
{
- if (GTK_IS_MENU (self->priv->last_menu))
- gtk_menu_popdown (GTK_MENU (self->priv->last_menu));
-
+ panel_service_close_active_entry (self);
return;
}
@@ -1840,8 +1860,16 @@ static void
on_active_menu_hidden (GtkMenu *menu, PanelService *self)
{
PanelServicePrivate *priv = self->priv;
+ GtkMenuShellClass *menu_shell_class = GTK_MENU_SHELL_GET_CLASS (priv->last_menu);
+
g_signal_handlers_disconnect_by_data (priv->last_menu, self);
+ if (menu_shell_class && default_menu_shell_deactivate &&
+ menu_shell_class->deactivate != default_menu_shell_deactivate)
+ {
+ menu_shell_class->deactivate = default_menu_shell_deactivate;
+ }
+
priv->last_x = 0;
priv->last_y = 0;
priv->last_menu_button = 0;
@@ -1853,6 +1881,7 @@ on_active_menu_hidden (GtkMenu *menu, PanelService *self)
priv->last_right = 0;
priv->last_top = 0;
priv->last_bottom = 0;
+ priv->last_open_time = 0;
priv->use_event = FALSE;
priv->pressed_entry = NULL;
@@ -2270,6 +2299,34 @@ menuitem_activated (GtkWidget *menuitem, IndicatorObjectEntry *entry)
}
static void
+menu_shell_deactivate_override (GtkMenuShell *menu_shell)
+{
+ PanelService *self = panel_service_get_default ();
+ const gchar *entry_id;
+
+ if (gtk_get_current_event () && GTK_MENU (menu_shell) == self->priv->last_menu)
+ {
+ guint64 ms_open = (g_get_monotonic_time () - self->priv->last_open_time) / 1000;
+
+ if (ms_open < 50)
+ {
+ /* If the menu shell deactivation was requested by an event, we ensure this
+ * didn't happen too early to activation, or there could be a race causing
+ * no menu to appear. Also since the item is now marked as inactive, we should
+ * manually highlight it. */
+ entry_id = get_indicator_entry_id_by_menu (self, self->priv->last_menu);
+
+ if (entry_id)
+ g_signal_emit (self, _service_signals[ENTRY_ACTIVATE_REQUEST], 0, entry_id);
+
+ return;
+ }
+ }
+
+ default_menu_shell_deactivate (menu_shell);
+}
+
+static void
panel_service_show_entry_common (PanelService *self,
IndicatorObject *object,
IndicatorObjectEntry *entry,
@@ -2281,6 +2338,7 @@ panel_service_show_entry_common (PanelService *self,
{
PanelServicePrivate *priv;
GtkWidget *last_menu;
+ GtkMenuShellClass *menu_shell_class;
g_return_if_fail (PANEL_IS_SERVICE (self));
g_return_if_fail (INDICATOR_IS_OBJECT (object));
@@ -2350,6 +2408,14 @@ panel_service_show_entry_common (PanelService *self,
g_signal_connect_after (priv->last_menu, "move-current",
G_CALLBACK (on_active_menu_move_current), self);
+ /* Override the menu deactivation in order to prevent it to close too early */
+ menu_shell_class = GTK_MENU_SHELL_GET_CLASS (priv->last_menu);
+ if (menu_shell_class && menu_shell_class->deactivate != menu_shell_deactivate_override)
+ {
+ default_menu_shell_deactivate = menu_shell_class->deactivate;
+ menu_shell_class->deactivate = menu_shell_deactivate_override;
+ }
+
gtk_menu_shell_set_take_focus (GTK_MENU_SHELL (priv->last_menu), TRUE);
gtk_menu_popup (priv->last_menu, NULL, NULL, positon_menu, self, button, CurrentTime);
gboolean visible = gtk_widget_is_visible (GTK_WIDGET (priv->last_menu));
@@ -2382,6 +2448,7 @@ panel_service_show_entry_common (PanelService *self,
priv->last_right = left + width -1;
priv->last_top = top;
priv->last_bottom = top + height -1;
+ priv->last_open_time = g_get_monotonic_time ();
}
else
{
@@ -2626,6 +2693,7 @@ panel_service_close_active_entry (PanelService *self)
if (GTK_IS_MENU (self->priv->last_menu))
{
+ self->priv->last_open_time = 0;
gtk_menu_popdown (GTK_MENU (self->priv->last_menu));
}
}
diff --git a/services/unity-panel-service-lockscreen.conf.in b/services/unity-panel-service-lockscreen.conf.in
index b9255d825..1b954a189 100644
--- a/services/unity-panel-service-lockscreen.conf.in
+++ b/services/unity-panel-service-lockscreen.conf.in
@@ -4,5 +4,7 @@ author "Andrea Azzarone <andrea.azzarone@canonical.com>"
start on desktop-lock
stop on desktop-unlock
+pre-start exec @UNITY_LIBDIR@/upstart-prestart-check
+
respawn
-exec ${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service --lockscreen-mode
+exec @UNITY_LIBDIR@/unity-panel-service --lockscreen-mode
diff --git a/services/unity-panel-service-lockscreen.override b/services/unity-panel-service-lockscreen.override
new file mode 100644
index 000000000..2905494b6
--- /dev/null
+++ b/services/unity-panel-service-lockscreen.override
@@ -0,0 +1 @@
+manual
diff --git a/services/unity-panel-service-lockscreen.service.in b/services/unity-panel-service-lockscreen.service.in
new file mode 100644
index 000000000..d2398e03a
--- /dev/null
+++ b/services/unity-panel-service-lockscreen.service.in
@@ -0,0 +1,8 @@
+[Unit]
+Description=Backing Service for the Unity Panel in Lockscreen mode
+PartOf=unity-screen-locked.target
+
+[Service]
+ExecStartPre=@UNITY_LIBDIR@/systemd-prestart-check
+ExecStart=@UNITY_LIBDIR@/unity-panel-service --lockscreen-mode
+Restart=on-failure
diff --git a/services/unity-panel-service.conf.in b/services/unity-panel-service.conf.in
index 62712f833..b803f6a7a 100644
--- a/services/unity-panel-service.conf.in
+++ b/services/unity-panel-service.conf.in
@@ -11,8 +11,10 @@ author "Ted Gould <ted@ubuntu.com>"
start on desktop-start DESKTOP_SESSION=ubuntu
stop on desktop-end
+pre-start exec @UNITY_LIBDIR@/upstart-prestart-check
+
emits indicator-services-start
emits indicator-services-end
respawn
-exec ${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service
+exec @UNITY_LIBDIR@/unity-panel-service
diff --git a/services/unity-panel-service.override b/services/unity-panel-service.override
new file mode 100644
index 000000000..2905494b6
--- /dev/null
+++ b/services/unity-panel-service.override
@@ -0,0 +1 @@
+manual
diff --git a/services/unity-panel-service.service.in b/services/unity-panel-service.service.in
new file mode 100644
index 000000000..f15ec7c99
--- /dev/null
+++ b/services/unity-panel-service.service.in
@@ -0,0 +1,10 @@
+[Unit]
+Description=Backing Service for the Unity Panel
+After=unity7.service
+PartOf=graphical-session.target
+BindsTo=indicators-pre.target
+
+[Service]
+ExecStartPre=@UNITY_LIBDIR@/systemd-prestart-check
+ExecStart=@UNITY_LIBDIR@/unity-panel-service
+Restart=on-failure
diff --git a/services/unity-screen-locked.target b/services/unity-screen-locked.target
new file mode 100644
index 000000000..fb0a1f6e1
--- /dev/null
+++ b/services/unity-screen-locked.target
@@ -0,0 +1,5 @@
+[Unit]
+Description=A target that, when running, represents the screen being locked
+Requires=unity7.service
+Wants=unity-panel-service-lockscreen.service
+PartOf=graphical-session.target
diff --git a/shutdown/SessionView.cpp b/shutdown/SessionView.cpp
index 70534f0e7..422e3c934 100644
--- a/shutdown/SessionView.cpp
+++ b/shutdown/SessionView.cpp
@@ -356,14 +356,6 @@ nux::Area* View::FindKeyFocusArea(unsigned etype, unsigned long key_code, unsign
}
}
}
- else if (key_code == NUX_VK_ESCAPE)
- {
- nux::InputArea* focused = nux::GetWindowCompositor().GetKeyFocusArea();
-
- // Let's reset the focused area if we're in keyboard-navigation mode.
- if (focused && focused->IsChildOf(buttons_layout_) && !focused->IsMouseInside())
- return this;
- }
return UnityWindowView::FindKeyFocusArea(etype, key_code, modifiers);
}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 17ea9b758..15284cde8 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -6,9 +6,40 @@ set(UNITY_SRC ../plugins/unityshell/src)
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/data DESTINATION ${CMAKE_BINARY_DIR}/tests)
#
+# Google Tests
+#
+
+# Check for google test and build it locally
+set (GTEST_PREFIX "/usr/src/googletest")
+
+if (EXISTS "${GTEST_PREFIX}")
+ # As of version 1.8.0
+ set (GMOCK_SOURCE_DIR "${GTEST_PREFIX}/googlemock" CACHE PATH "gmock source directory")
+ set (GMOCK_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/include" CACHE PATH "gmock source include directory")
+ set (GTEST_INCLUDE_DIR "${GTEST_PREFIX}/googletest/include" CACHE PATH "gtest source include directory")
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
+else()
+ set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory")
+ set (GMOCK_INCLUDE_DIR "/usr/include/gmock/include" CACHE PATH "gmock source include directory")
+ set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory")
+endif()
+
+if (GTEST_INCLUDE_DIR AND GMOCK_INCLUDE_DIR)
+ include_directories (${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR})
+ add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock")
+elseif (GTEST_INCLUDE_DIR AND NOT GMOCK_INCLUDE_DIR)
+ include_directories (${GTEST_INCLUDE_DIR})
+endif(GTEST_INCLUDE_DIR AND GMOCK_INCLUDE_DIR)
+
+if (GMOCK_SOURCE_DIR)
+ set(GMOCK_LIB gmock)
+ set(GMOCK_MAIN_LIB gmock_main)
+endif (GMOCK_SOURCE_DIR)
+
+#
# Unit tests
#
-set (TEST_DEPS "${UNITY_PLUGIN_DEPS};unity>=4.99.0;libupstart;")
+set (TEST_DEPS "${UNITY_PLUGIN_DEPS};unity>=4.99.0;libupstart;xtst")
pkg_check_modules (TEST_UNIT_DEPS REQUIRED ${TEST_DEPS})
string (REPLACE ";" " " TEST_UNIT_DEPS_CFLAGS_OTHER "${TEST_UNIT_CFLAGS_OTHER}")
@@ -44,8 +75,6 @@ add_subdirectory (test-get-transients)
#
enable_testing()
-set(GMOCK_LIB gmock)
-set(GMOCK_MAIN_LIB gmock_main)
if (GMOCK_LIB AND
GMOCK_MAIN_LIB)
@@ -224,6 +253,7 @@ if (ENABLE_X_SUPPORT)
test_error_preview.cpp
test_edge_barrier_controller.cpp
test_expo_launcher_icon.cpp
+ test_file_manager_launcher_icon.cpp
test_filter_widgets.cpp
test_glib_dbus_server.cpp
test_gnome_session_manager.cpp
@@ -286,6 +316,7 @@ if (ENABLE_X_SUPPORT)
test_switcher_controller_class.cpp
test_switcher_model.cpp
test_switcher_view.cpp
+ test_systemd_wrapper.cpp
test_tabiterator.cpp
test_texture_cache.cpp
test_text_input.cpp
@@ -373,7 +404,7 @@ set (TEST_COMMAND_HEADLESS
&& ${DUMMY_XORG_TEST_RUNNER} ${GTEST_TEST_COMMAND_SLOW}
&& ${TEST_COMMAND_XLESS})
-if (GTEST_ROOT_DIR)
+if (GMOCK_SOURCE_DIR)
if (ENABLE_X_SUPPORT)
add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-gtest test-gtest-slow test-gtest-xless test-gtest-dbus test-gestures)
add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest test-gtest-slow test-gtest-xless test-gtest-dbus test-gestures)
@@ -384,9 +415,10 @@ if (GTEST_ROOT_DIR)
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})
-endif (GTEST_ROOT_DIR)
+endif (GMOCK_SOURCE_DIR)
# make target to allow devs to run "make autopilot" from build dir:
set (AUTOPILOTDIR "${CMAKE_CURRENT_SOURCE_DIR}/autopilot")
# Rules to install autopilot files and executable script:
install(CODE "execute_process(COMMAND python2.7 setup.py install --prefix ${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${AUTOPILOTDIR})")
add_custom_target (autopilot COMMAND cd ${AUTOPILOTDIR} && make check)
+
diff --git a/tests/autopilot/unity/tests/test_dash.py b/tests/autopilot/unity/tests/test_dash.py
index a2f3f6832..8f4943abc 100644
--- a/tests/autopilot/unity/tests/test_dash.py
+++ b/tests/autopilot/unity/tests/test_dash.py
@@ -1136,18 +1136,18 @@ class PreviewClickCancelTests(DashTestCase):
def setUp(self):
super(PreviewClickCancelTests, self).setUp()
- gettext.install("unity-scope-applications")
- scope = self.unity.dash.reveal_application_scope(clear_search=False)
+ gettext.install("unity-scope-files")
+ scope = self.unity.dash.reveal_file_scope(clear_search=False)
self.addCleanup(self.unity.dash.ensure_hidden)
# Only testing an application preview for this test.
- search_string = "Software Updater"
+ search_string = "Videos"
if self.unity.dash.search_string != search_string:
self.unity.dash.clear_search()
self.keyboard.type(search_string)
# wait for "Installed" category
- category = self.wait_for_category(scope, _("Installed"))
+ category = self.wait_for_category(scope, _("Folders"))
# wait for results
self.assertThat(lambda: len(category.get_results()), Eventually(GreaterThan(0), timeout=20))
diff --git a/tests/test-gestures/CMakeLists.txt b/tests/test-gestures/CMakeLists.txt
index a48f4d96a..193e0db18 100644
--- a/tests/test-gestures/CMakeLists.txt
+++ b/tests/test-gestures/CMakeLists.txt
@@ -1,4 +1,4 @@
-if (GTEST_ROOT_DIR)
+if (GMOCK_SOURCE_DIR)
set(UNITY_SRC ${CMAKE_SOURCE_DIR}/plugins/unityshell/src)
add_custom_command(OUTPUT CompoundGestureRecognizer.cpp
@@ -76,4 +76,4 @@ if (GTEST_ROOT_DIR)
add_dependencies(test-gestures gtest unity-core-${UNITY_API_VERSION})
add_custom_target (check-gestures COMMAND ./test-gestures DEPENDS test-gestures)
-endif (GTEST_ROOT_DIR)
+endif (GMOCK_SOURCE_DIR)
diff --git a/tests/test-gestures/test_gesture_broker.cpp b/tests/test-gestures/test_gesture_broker.cpp
index 392aa1560..ef262b1af 100644
--- a/tests/test-gestures/test_gesture_broker.cpp
+++ b/tests/test-gestures/test_gesture_broker.cpp
@@ -111,11 +111,11 @@ TEST_F(GestureBrokerTest, ThreeFingersTouchHitsCorrectWindow)
// Gesture shouldn't be accepted as constructions hasn't finished
ASSERT_EQ(0, g_gesture_event_accept_count[0]);
ASSERT_EQ(0, g_gesture_event_reject_count[0]);
- ASSERT_EQ(1, g_window_target_mocks.size());
+ ASSERT_EQ(1u, g_window_target_mocks.size());
WindowGestureTargetMock *target_mock = *g_window_target_mocks.begin();
ASSERT_TRUE(target_mock->window == middle_window);
// No events yet as the broker didn't accept the gesture yet
- ASSERT_EQ(0, target_mock->events_received.size());
+ ASSERT_EQ(0u, target_mock->events_received.size());
fake_event.type = nux::EVENT_GESTURE_UPDATE;
fake_event.touches.push_back(nux::TouchPoint(4, 132.0f, 142.0f));
@@ -128,5 +128,5 @@ TEST_F(GestureBrokerTest, ThreeFingersTouchHitsCorrectWindow)
// Check that this gesture target is still valid
ASSERT_EQ(1, g_window_target_mocks.count(target_mock));
// Gesture events should have been sent to the target by now
- ASSERT_EQ(2, target_mock->events_received.size());
+ ASSERT_EQ(2u, target_mock->events_received.size());
}
diff --git a/tests/test_action_handle.cpp b/tests/test_action_handle.cpp
index b8dd438de..a7f25865b 100644
--- a/tests/test_action_handle.cpp
+++ b/tests/test_action_handle.cpp
@@ -29,7 +29,7 @@ namespace
TEST(TestActionHandle, Initialization)
{
action::handle handle;
- EXPECT_EQ(handle, 0);
+ EXPECT_EQ(handle, 0u);
uint64_t val = g_random_int();
action::handle random = val;
@@ -39,7 +39,7 @@ TEST(TestActionHandle, Initialization)
TEST(TestActionHandle, Assignment)
{
action::handle handle;
- ASSERT_EQ(handle, 0);
+ ASSERT_EQ(handle, 0u);
uint64_t val = g_random_int();
handle = val;
@@ -49,21 +49,21 @@ TEST(TestActionHandle, Assignment)
TEST(TestActionHandle, CastToScalarType)
{
action::handle handle = 5;
- ASSERT_EQ(handle, 5);
+ ASSERT_EQ(handle, 5u);
int int_handle = handle;
EXPECT_EQ(int_handle, 5);
unsigned uint_handle = handle;
- EXPECT_EQ(uint_handle, 5);
+ EXPECT_EQ(uint_handle, 5u);
}
TEST(TestActionHandle, PrefixIncrementOperator)
{
action::handle handle;
- ASSERT_EQ(handle, 0);
+ ASSERT_EQ(handle, 0u);
- for (auto i = 1; i <= 10; ++i)
+ for (auto i = 1u; i <= 10u; ++i)
{
ASSERT_EQ(++handle, i);
ASSERT_EQ(handle, i);
@@ -73,9 +73,9 @@ TEST(TestActionHandle, PrefixIncrementOperator)
TEST(TestActionHandle, PostfixIncrementOperator)
{
action::handle handle;
- ASSERT_EQ(handle, 0);
+ ASSERT_EQ(handle, 0u);
- for (auto i = 1; i <= 10; ++i)
+ for (auto i = 1u; i <= 10u; ++i)
{
ASSERT_EQ(handle++, i-1);
ASSERT_EQ(handle, i);
@@ -85,9 +85,9 @@ TEST(TestActionHandle, PostfixIncrementOperator)
TEST(TestActionHandle, PrefixDecrementOperator)
{
action::handle handle(10);
- ASSERT_EQ(handle, 10);
+ ASSERT_EQ(handle, 10u);
- for (auto i = 10; i > 0; --i)
+ for (auto i = 10u; i > 0u; --i)
{
ASSERT_EQ(--handle, i-1);
ASSERT_EQ(handle, i-1);
@@ -97,9 +97,9 @@ TEST(TestActionHandle, PrefixDecrementOperator)
TEST(TestActionHandle, PostfixDecrementOperator)
{
action::handle handle(10);
- ASSERT_EQ(handle, 10);
+ ASSERT_EQ(handle, 10u);
- for (auto i = 10; i > 0; --i)
+ for (auto i = 10u; i > 0u; --i)
{
ASSERT_EQ(handle--, i);
ASSERT_EQ(handle, i-1);
diff --git a/tests/test_animation_utils.cpp b/tests/test_animation_utils.cpp
index 56f7aad03..1c810e474 100644
--- a/tests/test_animation_utils.cpp
+++ b/tests/test_animation_utils.cpp
@@ -60,8 +60,8 @@ TYPED_TEST(TestAnimationUtilsFloating, StartValueForDirection)
TYPED_TEST(TestAnimationUtilsIntegers, StartValueForDirection)
{
- EXPECT_EQ(0, StartValueForDirection<TypeParam>(Direction::FORWARD));
- EXPECT_EQ(100, StartValueForDirection<TypeParam>(Direction::BACKWARD));
+ EXPECT_EQ(static_cast<TypeParam>(0), StartValueForDirection<TypeParam>(Direction::FORWARD));
+ EXPECT_EQ(static_cast<TypeParam>(100), StartValueForDirection<TypeParam>(Direction::BACKWARD));
}
TYPED_TEST(TestAnimationUtilsFloating, FinishValueForDirection)
@@ -72,8 +72,8 @@ TYPED_TEST(TestAnimationUtilsFloating, FinishValueForDirection)
TYPED_TEST(TestAnimationUtilsIntegers, FinishValueForDirection)
{
- EXPECT_EQ(100, FinishValueForDirection<TypeParam>(Direction::FORWARD));
- EXPECT_EQ(0, FinishValueForDirection<TypeParam>(Direction::BACKWARD));
+ EXPECT_EQ(static_cast<TypeParam>(100), FinishValueForDirection<TypeParam>(Direction::FORWARD));
+ EXPECT_EQ(static_cast<TypeParam>(0), FinishValueForDirection<TypeParam>(Direction::BACKWARD));
}
TYPED_TEST(TestAnimationUtils, StartNotRunning)
diff --git a/tests/test_application_launcher_icon.cpp b/tests/test_application_launcher_icon.cpp
index 610417c91..6c1a77c7b 100644
--- a/tests/test_application_launcher_icon.cpp
+++ b/tests/test_application_launcher_icon.cpp
@@ -725,11 +725,11 @@ TEST_F(TestApplicationLauncherIcon, PerformScrollInitiallyUnfocusedWindow)
mock_icon->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, false);
EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(7, 6, 5, 4, 3, 2, 1, 8));
- ASSERT_EQ(WM->GetActiveWindow(), 8);
+ ASSERT_EQ(WM->GetActiveWindow(), 8u);
mock_icon->PerformScroll(AbstractLauncherIcon::ScrollDirection::DOWN, 200);
EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(7, 6, 5, 4, 3, 2, 8, 1));
- ASSERT_EQ(WM->GetActiveWindow(), 1);
+ ASSERT_EQ(WM->GetActiveWindow(), 1u);
}
TEST_F(TestApplicationLauncherIcon, PerformScrollSingleUnfocusedWindow)
@@ -741,12 +741,12 @@ TEST_F(TestApplicationLauncherIcon, PerformScrollSingleUnfocusedWindow)
mock_icon->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, false);
EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(1, 2));
- ASSERT_EQ(WM->GetActiveWindow(), 2);
+ ASSERT_EQ(WM->GetActiveWindow(), 2u);
mock_icon->PerformScroll(AbstractLauncherIcon::ScrollDirection::DOWN, 200);
EXPECT_THAT(WM->GetWindowsInStackingOrder(), testing::ElementsAre(2, 1));
- ASSERT_EQ(WM->GetActiveWindow(), 1);
+ ASSERT_EQ(WM->GetActiveWindow(), 1u);
}
TEST_F(TestApplicationLauncherIcon, ActiveQuirkWMCrossCheck)
diff --git a/tests/test_bamf_application.cpp b/tests/test_bamf_application.cpp
index 56b2052a6..9557af7e8 100644
--- a/tests/test_bamf_application.cpp
+++ b/tests/test_bamf_application.cpp
@@ -56,7 +56,7 @@ struct TestBamfApplication : public testing::Test
TEST_F(TestBamfApplication, GetWindows)
{
- ASSERT_EQ(application_.GetWindows().size(), 0);
+ ASSERT_EQ(application_.GetWindows().size(), 0u);
GList* children = nullptr;
for (int i = 0; i<5; ++i)
@@ -73,9 +73,9 @@ TEST_F(TestBamfApplication, GetWindows)
AddFakeWindowToWM(3, true);
AddFakeWindowToWM(4, false);
- EXPECT_EQ(application_.GetWindows().size(), 5);
+ EXPECT_EQ(application_.GetWindows().size(), 5u);
g_list_free_full(children, g_object_unref);
}
-} \ No newline at end of file
+}
diff --git a/tests/test_categories.cpp b/tests/test_categories.cpp
index a72a9a077..9ac971e3c 100644
--- a/tests/test_categories.cpp
+++ b/tests/test_categories.cpp
@@ -49,7 +49,7 @@ TEST_F(TestCategories, TestSignalProxyAdded)
Category cat(nullptr, nullptr, nullptr);
bool added = false;
- ASSERT_EQ(model.row_added.size(), 1);
+ ASSERT_EQ(model.row_added.size(), 1u);
model.category_added.connect([&added] (Category const&) { added = true; });
model.row_added.emit(cat);
EXPECT_TRUE(added);
@@ -60,7 +60,7 @@ TEST_F(TestCategories, TestSignalProxyChanged)
Category cat(nullptr, nullptr, nullptr);
bool changed = false;
- ASSERT_EQ(model.row_changed.size(), 1);
+ ASSERT_EQ(model.row_changed.size(), 1u);
model.category_changed.connect([&changed] (Category const&) { changed = true; });
model.row_changed.emit(cat);
EXPECT_TRUE(changed);
@@ -71,7 +71,7 @@ TEST_F(TestCategories, TestSignalProxyRemoved)
Category cat(nullptr, nullptr, nullptr);
bool removed = false;
- ASSERT_EQ(model.row_removed.size(), 1);
+ ASSERT_EQ(model.row_removed.size(), 1u);
model.category_removed.connect([&removed] (Category const&) { removed = true; });
model.row_removed.emit(cat);
EXPECT_TRUE(removed);
diff --git a/tests/test_connection_manager.cpp b/tests/test_connection_manager.cpp
index 5fd965cfb..58cd767c9 100644
--- a/tests/test_connection_manager.cpp
+++ b/tests/test_connection_manager.cpp
@@ -163,7 +163,7 @@ TEST(TestConnectionManager, Initialization)
{
connection::Manager manager;
EXPECT_TRUE(manager.Empty());
- EXPECT_EQ(manager.Size(), 0);
+ EXPECT_EQ(manager.Size(), 0u);
}
TEST(TestConnectionManager, AddEmpty)
@@ -176,7 +176,7 @@ TEST(TestConnectionManager, AddEmpty)
EXPECT_EQ(handle, global_handle);
EXPECT_TRUE(manager.Empty());
- EXPECT_EQ(manager.Size(), 0);
+ EXPECT_EQ(manager.Size(), 0u);
}
TEST(TestConnectionManager, AddSignal)
@@ -192,7 +192,7 @@ TEST(TestConnectionManager, AddSignal)
++global_handle;
EXPECT_EQ(handle, global_handle);
EXPECT_FALSE(manager.Empty());
- EXPECT_EQ(manager.Size(), 1);
+ EXPECT_EQ(manager.Size(), 1u);
}
TEST(TestConnectionManager, AddMultipleSignals)
@@ -200,7 +200,7 @@ TEST(TestConnectionManager, AddMultipleSignals)
connection::Manager manager;
SignalerObject signaler;
- for (int i = 1; i <= 10; ++i)
+ for (unsigned i = 1; i <= 10u; ++i)
{
auto const& conn = signaler.awesome_signal.connect([] {/* Awesome callback! */});
auto handle = manager.Add(conn);
@@ -237,7 +237,7 @@ TEST(TestConnectionManager, RemoveAndClearAvailable)
EXPECT_TRUE(manager.RemoveAndClear(&handle));
EXPECT_FALSE(conn.connected());
EXPECT_TRUE(manager.Empty());
- EXPECT_EQ(handle, 0);
+ EXPECT_EQ(handle, 0u);
}
TEST(TestConnectionManager, RemoveUnavailable)
@@ -247,7 +247,7 @@ TEST(TestConnectionManager, RemoveUnavailable)
connection::handle handle = 5;
EXPECT_FALSE(manager.RemoveAndClear(&handle));
EXPECT_TRUE(manager.Empty());
- EXPECT_EQ(handle, 5);
+ EXPECT_EQ(handle, 5u);
}
TEST(TestConnectionManager, ReplaceOnEmpty)
@@ -256,7 +256,7 @@ TEST(TestConnectionManager, ReplaceOnEmpty)
SignalerObject signaler;
auto const& conn = signaler.awesome_signal.connect([] {/* Awesome callback! */});
- EXPECT_GT(manager.Replace(0, conn), 0);
+ EXPECT_GT(manager.Replace(0, conn), 0u);
EXPECT_FALSE(manager.Empty());
}
@@ -269,8 +269,8 @@ TEST(TestConnectionManager, ReplaceUnavailable)
manager.Add(conn);
ASSERT_FALSE(manager.Empty());
- EXPECT_GT(manager.Replace(0, conn), 0);
- EXPECT_EQ(manager.Size(), 2);
+ EXPECT_GT(manager.Replace(0, conn), 0u);
+ EXPECT_EQ(manager.Size(), 2u);
}
TEST(TestConnectionManager, ReplaceAvailable)
@@ -284,7 +284,7 @@ TEST(TestConnectionManager, ReplaceAvailable)
sigc::connection second_conn = signaler.awesome_signal.connect([] {/* Awesome callback! */});
auto second_handle = manager.Replace(first_handle, second_conn);
- EXPECT_EQ(manager.Size(), 1);
+ EXPECT_EQ(manager.Size(), 1u);
EXPECT_EQ(first_handle, second_handle);
EXPECT_FALSE(first_conn.connected());
diff --git a/tests/test_dashview.cpp b/tests/test_dashview.cpp
index 684d62c11..31ceda32a 100644
--- a/tests/test_dashview.cpp
+++ b/tests/test_dashview.cpp
@@ -91,7 +91,7 @@ TEST_F(TestDashView, TestConstruct)
Scopes::Ptr scopes(new MockGSettingsScopes(scopes_default));
nux::ObjectPtr<MockDashView> view(new MockDashView(scopes, application_starter_));
- EXPECT_EQ(view->scope_views_.size(), 5) << "Error: Incorrect number of scope views (" << view->scope_views_.size() << " != 5)";
+ EXPECT_EQ(view->scope_views_.size(), 5u) << "Error: Incorrect number of scope views (" << view->scope_views_.size() << " != 5)";
}
diff --git a/tests/test_dashview_impl.cpp b/tests/test_dashview_impl.cpp
index dcf641c36..a1024b059 100644
--- a/tests/test_dashview_impl.cpp
+++ b/tests/test_dashview_impl.cpp
@@ -49,7 +49,7 @@ TEST(TestParseScopeFilter, TestSingleParameter)
ScopeFilter filter = parse_scope_uri("uri?filter_param=test");
EXPECT_THAT(filter.id, Eq("uri"));
- EXPECT_THAT(filter.filters.size(), Eq(1));
+ EXPECT_THAT(filter.filters.size(), Eq(1u));
EXPECT_THAT(filter.filters["param"], Eq("test"));
}
@@ -66,7 +66,7 @@ TEST(TestParseScopeFilter, TestEmbeddedEquals)
ScopeFilter filter = parse_scope_uri("uri?filter_param=a=b");
EXPECT_THAT(filter.id, Eq("uri"));
- EXPECT_THAT(filter.filters.size(), Eq(1));
+ EXPECT_THAT(filter.filters.size(), Eq(1u));
EXPECT_THAT(filter.filters["param"], Eq("a=b"));
}
@@ -75,7 +75,7 @@ TEST(TestParseScopeFilter, TestMultipleParameters)
ScopeFilter filter = parse_scope_uri("uri?filter_param1=first&filter_param2=second");
EXPECT_THAT(filter.id, Eq("uri"));
- EXPECT_THAT(filter.filters.size(), Eq(2));
+ EXPECT_THAT(filter.filters.size(), Eq(2u));
EXPECT_THAT(filter.filters["param1"], Eq("first"));
EXPECT_THAT(filter.filters["param2"], Eq("second"));
}
diff --git a/tests/test_dbus_indicators.cpp b/tests/test_dbus_indicators.cpp
index 8e6bbe6c2..3569a3b2d 100644
--- a/tests/test_dbus_indicators.cpp
+++ b/tests/test_dbus_indicators.cpp
@@ -76,8 +76,8 @@ TEST_F(TestDBusIndicators, TestSync)
// wait until the dbus indicator gets any indicator from the panel service
Utils::WaitUntil(sigc::mem_fun(*dbus_indicators, &DBusIndicatorsTest::HasIndicators), true, 5);
- EXPECT_EQ(dbus_indicators->GetIndicators().size(), 1);
- EXPECT_EQ(dbus_indicators->GetIndicators().front()->GetEntries().size(), 2);
+ EXPECT_EQ(dbus_indicators->GetIndicators().size(), 1u);
+ EXPECT_EQ(dbus_indicators->GetIndicators().front()->GetEntries().size(), 2u);
EXPECT_EQ(dbus_indicators->GetIndicators().front()->GetEntries().front()->id(), "test_entry_id");
EXPECT_EQ(dbus_indicators->GetIndicators().front()->GetEntries().back()->id(), "test_entry_id2");
@@ -89,8 +89,8 @@ TEST_F(TestDBusIndicators, TestSync)
// so do one interation of the main loop more
g_main_context_iteration(NULL, TRUE);
- EXPECT_EQ(dbus_indicators->GetIndicators().size(), 1);
- EXPECT_EQ(dbus_indicators->GetIndicators().front()->GetEntries().size(), 2);
+ EXPECT_EQ(dbus_indicators->GetIndicators().size(), 1u);
+ EXPECT_EQ(dbus_indicators->GetIndicators().front()->GetEntries().size(), 2u);
EXPECT_EQ(dbus_indicators->GetIndicators().front()->GetEntries().front()->id(), "test_entry_id2");
EXPECT_EQ(dbus_indicators->GetIndicators().front()->GetEntries().back()->id(), "test_entry_id");
}
diff --git a/tests/test_decorations_input_mixer.cpp b/tests/test_decorations_input_mixer.cpp
index b0e652f8c..687b019a3 100644
--- a/tests/test_decorations_input_mixer.cpp
+++ b/tests/test_decorations_input_mixer.cpp
@@ -53,13 +53,13 @@ TEST_F(TestDecorationInputMixer, PushToFrontItem)
mixer.PushToFront(item3);
auto const& items = mixer.Items();
- ASSERT_EQ(3, items.size());
+ ASSERT_EQ(3u, items.size());
EXPECT_EQ(item3, *std::next(items.begin(), 0));
EXPECT_EQ(item2, *std::next(items.begin(), 1));
EXPECT_EQ(item1, *std::next(items.begin(), 2));
mixer.PushToFront(item2);
- ASSERT_EQ(3, mixer.Items().size());
+ ASSERT_EQ(3u, mixer.Items().size());
EXPECT_EQ(item2, *std::next(items.begin(), 0));
EXPECT_EQ(item3, *std::next(items.begin(), 1));
EXPECT_EQ(item1, *std::next(items.begin(), 2));
@@ -77,13 +77,13 @@ TEST_F(TestDecorationInputMixer, PushToBackItem)
mixer.PushToBack(item3);
auto const& items = mixer.Items();
- ASSERT_EQ(3, items.size());
+ ASSERT_EQ(3u, items.size());
EXPECT_EQ(item1, *std::next(items.begin(), 0));
EXPECT_EQ(item2, *std::next(items.begin(), 1));
EXPECT_EQ(item3, *std::next(items.begin(), 2));
mixer.PushToBack(item2);
- ASSERT_EQ(3, items.size());
+ ASSERT_EQ(3u, items.size());
EXPECT_EQ(item1, *std::next(items.begin(), 0));
EXPECT_EQ(item3, *std::next(items.begin(), 1));
EXPECT_EQ(item2, *std::next(items.begin(), 2));
@@ -101,15 +101,15 @@ TEST_F(TestDecorationInputMixer, RemoveItem)
mixer.PushToFront(item3);
auto const& items = mixer.Items();
- ASSERT_EQ(3, items.size());
+ ASSERT_EQ(3u, items.size());
mixer.Remove(item2);
- ASSERT_EQ(2, items.size());
+ ASSERT_EQ(2u, items.size());
EXPECT_EQ(item3, *std::next(items.begin(), 0));
EXPECT_EQ(item1, *std::next(items.begin(), 1));
mixer.Remove(item1);
- ASSERT_EQ(1, items.size());
+ ASSERT_EQ(1u, items.size());
EXPECT_EQ(item3, *std::next(items.begin(), 0));
mixer.EnterEvent(CompPoint(item3->Geometry().x2(), item3->Geometry().y1()));
diff --git a/tests/test_decorations_widgets.cpp b/tests/test_decorations_widgets.cpp
index da954bdc5..73cf22cfd 100644
--- a/tests/test_decorations_widgets.cpp
+++ b/tests/test_decorations_widgets.cpp
@@ -321,7 +321,7 @@ TEST_F(TestDecorationLayout, AppendUnlimited)
ASSERT_EQ(layout->Geometry().y() + (layout->Geometry().height() - item_geo.height()) / 2, item_geo.y());
}
- EXPECT_EQ(100, layout->Items().size());
+ EXPECT_EQ(100u, layout->Items().size());
}
TEST_F(TestDecorationLayout, AppendParentsItem)
@@ -365,7 +365,7 @@ TEST_F(TestDecorationLayout, AppendInvisible)
ASSERT_EQ(expected_geo, layout->Geometry());
}
- EXPECT_EQ(100, layout->Items().size());
+ EXPECT_EQ(100u, layout->Items().size());
EXPECT_EQ(CompRect(), layout->Geometry());
}
@@ -388,7 +388,7 @@ TEST_F(TestDecorationLayout, AppendUnlimitedInternalPadding)
ASSERT_EQ(layout->Geometry().y() + (layout->Geometry().height() - item_geo.height()) / 2, item_geo.y());
}
- EXPECT_EQ(100, layout->Items().size());
+ EXPECT_EQ(100u, layout->Items().size());
}
TEST_F(TestDecorationLayout, AppendWithMaxWidth)
@@ -398,7 +398,7 @@ TEST_F(TestDecorationLayout, AppendWithMaxWidth)
for (int i = 0; i < 100; ++i)
layout->Append(RandomMockItem());
- ASSERT_EQ(100, layout->Items().size());
+ ASSERT_EQ(100u, layout->Items().size());
auto const& layout_geo = layout->Geometry();
int new_width = layout_geo.width()/2;
@@ -430,7 +430,7 @@ TEST_F(TestDecorationLayout, ExpandWithMaxWidth)
for (int i = 0; i < 100; ++i)
layout->Append(RandomMockItem());
- ASSERT_EQ(100, layout->Items().size());
+ ASSERT_EQ(100u, layout->Items().size());
auto const& layout_geo = layout->Geometry();
int full_width = layout_geo.width();
diff --git a/tests/test_delta_tracker.cpp b/tests/test_delta_tracker.cpp
index 23752455c..9436d20c4 100644
--- a/tests/test_delta_tracker.cpp
+++ b/tests/test_delta_tracker.cpp
@@ -38,7 +38,7 @@ public:
TEST_F(TestDeltaTracker, TestDirectionEmptyOnStart)
{
- ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 0);
+ ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 0u);
}
TEST_F(TestDeltaTracker, TestCorrectDirections)
@@ -46,7 +46,7 @@ TEST_F(TestDeltaTracker, TestCorrectDirections)
delta_tracker_.HandleNewMouseDelta(0, -1);
delta_tracker_.HandleNewMouseDelta(1, 0);
- ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 2);
+ ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 2u);
}
TEST_F(TestDeltaTracker, TestNoDuplicates)
@@ -54,7 +54,7 @@ TEST_F(TestDeltaTracker, TestNoDuplicates)
delta_tracker_.HandleNewMouseDelta(0, -1);
delta_tracker_.HandleNewMouseDelta(0, -1);
- ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 1);
+ ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 1u);
}
TEST_F(TestDeltaTracker, TestAllDirections)
@@ -64,7 +64,7 @@ TEST_F(TestDeltaTracker, TestAllDirections)
delta_tracker_.HandleNewMouseDelta(-1, 0);
delta_tracker_.HandleNewMouseDelta(1, 0);
- ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 4);
+ ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 4u);
}
TEST_F(TestDeltaTracker, TestResetStates)
@@ -74,10 +74,10 @@ TEST_F(TestDeltaTracker, TestResetStates)
delta_tracker_.HandleNewMouseDelta(-1, 0);
delta_tracker_.HandleNewMouseDelta(1, 0);
- ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 4);
+ ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 4u);
delta_tracker_.ResetState();
- ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 0);
+ ASSERT_EQ(delta_tracker_.AmountOfDirectionsChanged(), 0u);
}
}
diff --git a/tests/test_desktop_launcher_icon.cpp b/tests/test_desktop_launcher_icon.cpp
index 9320d280a..075ca90e9 100644
--- a/tests/test_desktop_launcher_icon.cpp
+++ b/tests/test_desktop_launcher_icon.cpp
@@ -40,7 +40,7 @@ TEST_F(TestDesktopLauncherIcon, Type)
TEST_F(TestDesktopLauncherIcon, Shortcut)
{
- EXPECT_EQ(icon.GetShortcut(), 'd');
+ EXPECT_EQ(icon.GetShortcut(), static_cast<guint64>('d'));
}
TEST_F(TestDesktopLauncherIcon, Position)
diff --git a/tests/test_device_launcher_section.cpp b/tests/test_device_launcher_section.cpp
index 4d6e45a8a..a28c73559 100644
--- a/tests/test_device_launcher_section.cpp
+++ b/tests/test_device_launcher_section.cpp
@@ -80,7 +80,7 @@ TEST_F(TestDeviceLauncherSection, NoDuplicates)
TEST_F(TestDeviceLauncherSection, GetIcons)
{
- EXPECT_EQ(section_.GetIcons().size(), 2);
+ EXPECT_EQ(section_.GetIcons().size(), 2u);
}
}
diff --git a/tests/test_edge_barrier_controller.cpp b/tests/test_edge_barrier_controller.cpp
index 0aa069da4..4dae2cc80 100644
--- a/tests/test_edge_barrier_controller.cpp
+++ b/tests/test_edge_barrier_controller.cpp
@@ -25,6 +25,7 @@
#include "EdgeBarrierController.h"
#include "EdgeBarrierControllerPrivate.h"
+#include "InputMonitor.h"
using namespace unity;
using namespace unity::ui;
@@ -108,6 +109,7 @@ public:
TestBarrierSubscriber horizontal_subscribers_[monitors::MAX];
TestBarrierSubscriber vertical_subscribers_[monitors::MAX];
+ input::Monitor im;
MockUScreen uscreen;
EdgeBarrierController bc;
};
diff --git a/tests/test_favorite_store_gsettings.cpp b/tests/test_favorite_store_gsettings.cpp
index a1b584238..8aa39d498 100644
--- a/tests/test_favorite_store_gsettings.cpp
+++ b/tests/test_favorite_store_gsettings.cpp
@@ -44,7 +44,7 @@ const char* base_store_favs[] = { BUILDDIR"/tests/data/applications/ubuntuone-in
"device://uuid",
NULL
};
-const int n_base_store_favs = G_N_ELEMENTS(base_store_favs) - 1; /* NULL */
+const unsigned n_base_store_favs = G_N_ELEMENTS(base_store_favs) - 1; /* NULL */
const std::string other_desktop = "application://" BUILDDIR "/tests/data/applications/bzr-handle-patch.desktop";
@@ -322,7 +322,7 @@ TEST_F(TestFavoriteStoreGSettings, TestFavoriteRemoved)
favorite_store->SaveFavorites(favs, false);
ASSERT_TRUE(signal_received);
- ASSERT_EQ(paths_removed.size(), 3);
+ ASSERT_EQ(paths_removed.size(), 3u);
EXPECT_EQ(paths_removed[0], base_store_favs[4]);
EXPECT_EQ(paths_removed[1], base_store_favs[1]);
EXPECT_EQ(paths_removed[2], base_store_favs[3]);
@@ -457,7 +457,7 @@ TEST_F(TestFavoriteStoreGSettings, TestIsFavorite)
{
EXPECT_TRUE(favorite_store->IsFavorite(FavoriteStore::URI_PREFIX_APP+base_store_favs[0]));
- for (int i = 1; i < n_base_store_favs; i++)
+ for (unsigned i = 1; i < n_base_store_favs; i++)
{
ASSERT_TRUE(favorite_store->IsFavorite(base_store_favs[i]));
}
@@ -469,9 +469,9 @@ TEST_F(TestFavoriteStoreGSettings, TestFavoritePosition)
{
EXPECT_EQ(favorite_store->FavoritePosition(FavoriteStore::URI_PREFIX_APP+base_store_favs[0]), 0);
- for (int i = 1; i < n_base_store_favs; i++)
+ for (unsigned i = 1; i < n_base_store_favs; i++)
{
- ASSERT_EQ(favorite_store->FavoritePosition(base_store_favs[i]), i);
+ ASSERT_EQ(favorite_store->FavoritePosition(base_store_favs[i]), static_cast<int>(i));
}
EXPECT_EQ(favorite_store->FavoritePosition("unity://invalid-favorite"), -1);
diff --git a/tests/test_favorite_store_private.cpp b/tests/test_favorite_store_private.cpp
index 093888150..7f8f120c8 100644
--- a/tests/test_favorite_store_private.cpp
+++ b/tests/test_favorite_store_private.cpp
@@ -80,7 +80,7 @@ TEST(TestFavoriteStorePrivate, TestGetNewbies)
result = internal::impl::GetNewbies(old, fresh);
- EXPECT_EQ(result.size(), 2);
+ EXPECT_EQ(result.size(), 2u);
EXPECT_EQ(result[0], "e");
EXPECT_EQ(result[1], "f");
@@ -95,7 +95,7 @@ TEST(TestFavoriteStorePrivate, TestGetNewbies)
result = internal::impl::GetNewbies(old, fresh);
- EXPECT_EQ(result.size(), 2);
+ EXPECT_EQ(result.size(), 2u);
EXPECT_EQ(result[0], "e");
EXPECT_EQ(result[1], "f");
}
@@ -212,7 +212,7 @@ TEST(TestFavoriteStorePrivate, TestGetRemoved)
result = internal::impl::GetRemoved(old, fresh);
- EXPECT_EQ(result.size(), 2);
+ EXPECT_EQ(result.size(), 2u);
EXPECT_EQ(result[0], "a");
EXPECT_EQ(result[1], "d");
@@ -227,7 +227,7 @@ TEST(TestFavoriteStorePrivate, TestGetRemoved)
result = internal::impl::GetRemoved(old, fresh);
- EXPECT_EQ(result.size(), 2);
+ EXPECT_EQ(result.size(), 2u);
EXPECT_EQ(result[0], "b");
EXPECT_EQ(result[1], "c");
}
diff --git a/tests/test_file_manager_launcher_icon.cpp b/tests/test_file_manager_launcher_icon.cpp
new file mode 100644
index 000000000..286dc2bc2
--- /dev/null
+++ b/tests/test_file_manager_launcher_icon.cpp
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2016 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 warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY 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
+ * version 3 along with this program. If not, see
+ * <http://www.gnu.org/licenses/>
+ *
+ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
+ */
+
+#include <gmock/gmock.h>
+using namespace testing;
+
+#include "FileManagerLauncherIcon.h"
+#include "UnityCore/DesktopUtilities.h"
+
+#include "test_mock_devices.h"
+#include "test_mock_filemanager.h"
+#include "mock-application.h"
+
+using namespace unity;
+using namespace unity::launcher;
+using namespace testmocks;
+
+namespace
+{
+
+const std::string TRASH_URI = "trash:";
+const std::string TRASH_PATH = "file://" + DesktopUtilities::GetUserTrashDirectory();
+
+struct TestFileManagerLauncherIcon : public Test
+{
+ TestFileManagerLauncherIcon()
+ : app_(std::make_shared<MockApplication::Nice>())
+ , fm_(std::make_shared<MockFileManager::Nice>())
+ , dev_ (std::make_shared<MockDeviceLauncherSection>(2))
+ , icon_(new FileManagerLauncherIcon(app_, dev_, fm_))
+ {
+ }
+
+ MockApplication::Ptr app_;
+ MockFileManager::Ptr fm_;
+ DeviceLauncherSection::Ptr dev_;
+ FileManagerLauncherIcon::Ptr icon_;
+};
+
+TEST_F(TestFileManagerLauncherIcon, IconType)
+{
+ EXPECT_EQ(icon_->GetIconType(), AbstractLauncherIcon::IconType::APPLICATION);
+}
+
+TEST_F(TestFileManagerLauncherIcon, NoWindow)
+{
+ EXPECT_FALSE(icon_->IsVisible());
+}
+
+TEST_F(TestFileManagerLauncherIcon, NoManagedWindow_TrashUri)
+{
+ EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
+ ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(TRASH_URI));
+
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ app_->windows_ = { win };
+ app_->window_opened.emit(win);
+
+ EXPECT_FALSE(icon_->IsVisible());
+ EXPECT_FALSE(icon_->IsRunning());
+}
+
+TEST_F(TestFileManagerLauncherIcon, NoManagedWindow_TrashPath)
+{
+ EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
+ ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(TRASH_PATH));
+
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ app_->windows_ = { win };
+ app_->window_opened.emit(win);
+
+ EXPECT_FALSE(icon_->IsVisible());
+ EXPECT_FALSE(icon_->IsRunning());
+}
+
+TEST_F(TestFileManagerLauncherIcon, NoManagedWindow_Device)
+{
+ auto const& device_icons = dev_->GetIcons();
+ ASSERT_EQ(2u, device_icons.size());
+
+ device_icons.at(0)->Activate(ActionArg());
+
+ EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
+ ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(device_icons.at(0)->GetVolumeUri()));
+
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ app_->windows_ = { win };
+ app_->window_opened.emit(win);
+
+ EXPECT_FALSE(icon_->IsVisible());
+ EXPECT_FALSE(icon_->IsRunning());
+}
+
+TEST_F(TestFileManagerLauncherIcon, ManagedWindows)
+{
+ EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
+ ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return("/usr/bin"));
+
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ app_->windows_ = { win };
+ app_->window_opened.emit(win);
+
+ EXPECT_TRUE(icon_->IsVisible());
+ EXPECT_TRUE(icon_->IsRunning());
+}
+
+TEST_F(TestFileManagerLauncherIcon, ManagedWindows_EmptyLocation)
+{
+ EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
+ ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(""));
+
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ app_->windows_ = { win };
+ app_->window_opened.emit(win);
+
+ EXPECT_TRUE(icon_->IsVisible());
+ EXPECT_TRUE(icon_->IsRunning());
+}
+
+TEST_F(TestFileManagerLauncherIcon, ManagedWindows_CopyDialog)
+{
+ EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1);
+ ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(""));
+
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ win->visible_ = false;
+ app_->windows_ = { win };
+ app_->window_opened.emit(win);
+
+ EXPECT_TRUE(icon_->IsVisible());
+ EXPECT_TRUE(icon_->IsRunning());
+}
+
+
+TEST_F(TestFileManagerLauncherIcon, ManagedWindows_CopyDialogAndManagedWindow)
+{
+ EXPECT_CALL(*fm_, LocationForWindow(_)).Times(3);
+ ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(""));
+
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ app_->windows_ = { win };
+ app_->window_opened.emit(win);
+
+ win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ win->visible_ = false;
+ app_->windows_.push_back(win);
+ app_->window_opened.emit(win);
+
+ EXPECT_TRUE(icon_->IsVisible());
+ EXPECT_TRUE(icon_->IsRunning());
+ EXPECT_EQ(2u, icon_->WindowsVisibleOnMonitor(0));
+}
+
+TEST_F(TestFileManagerLauncherIcon, ManagedWindows_CopyDialogAndNoManagedWindow)
+{
+ {
+ InSequence s;
+
+ EXPECT_CALL(*fm_, LocationForWindow(_))
+ .Times(1)
+ .WillOnce(Return(""));
+
+ EXPECT_CALL(*fm_, LocationForWindow(_))
+ .Times(1)
+ .WillOnce(Return(""));
+
+ EXPECT_CALL(*fm_, LocationForWindow(_))
+ .Times(1)
+ .WillOnce(Return(TRASH_PATH));
+ }
+
+ auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ app_->windows_ = { win };
+ app_->window_opened.emit(win);
+
+ win = std::make_shared<MockApplicationWindow::Nice>(g_random_int());
+ win->visible_ = false;
+ app_->windows_.push_back(win);
+ app_->window_opened.emit(win);
+
+ EXPECT_TRUE(icon_->IsVisible());
+ EXPECT_TRUE(icon_->IsRunning());
+ EXPECT_EQ(1u, icon_->WindowsVisibleOnMonitor(0));
+}
+
+}
diff --git a/tests/test_filter_widgets.cpp b/tests/test_filter_widgets.cpp
index b25a6a28f..6e8f05739 100644
--- a/tests/test_filter_widgets.cpp
+++ b/tests/test_filter_widgets.cpp
@@ -123,7 +123,7 @@ TEST_F(TestFilterMultiRangeWidget, TestConstruction)
MultiRangeFilter::Ptr filter(new MultiRangeFilter(model_, AddMultiRangeFilterOptions(model_)));
SetFilter(filter);
- ASSERT_EQ(filter_widget_->buttons_.size(), 6);
+ ASSERT_EQ(filter_widget_->buttons_.size(), 6u);
}
TEST_F(TestFilterMultiRangeWidget, TestClick)
diff --git a/tests/test_glib_dbus_object.cpp b/tests/test_glib_dbus_object.cpp
index a6fe3b5c4..30d267151 100644
--- a/tests/test_glib_dbus_object.cpp
+++ b/tests/test_glib_dbus_object.cpp
@@ -112,14 +112,14 @@ TEST(TestGLibDBusObject, InitializeWithNoObject)
TEST(TestGLibDBusObjectBuilder, GetObjectsForIntrospectionWithOneObject)
{
auto const& objs = DBusObjectBuilder::GetObjectsForIntrospection(introspection::SINGLE_OJBECT);
- ASSERT_EQ(objs.size(), 1);
+ ASSERT_EQ(objs.size(), 1u);
EXPECT_EQ(objs.front()->InterfaceName(), "com.canonical.Unity.ObjectTest");
}
TEST(TestGLibDBusObjectBuilder, GetObjectsForIntrospectionWithMultipleObjects)
{
auto const& objs = DBusObjectBuilder::GetObjectsForIntrospection(introspection::MULTIPLE_OJBECTS);
- ASSERT_EQ(objs.size(), 3);
+ ASSERT_EQ(objs.size(), 3u);
EXPECT_EQ((*std::next(objs.begin(), 0))->InterfaceName(), "com.canonical.Unity.ObjectTest1");
EXPECT_EQ((*std::next(objs.begin(), 1))->InterfaceName(), "com.canonical.Unity.ObjectTest2");
EXPECT_EQ((*std::next(objs.begin(), 2))->InterfaceName(), "com.canonical.Unity.ObjectTest3");
diff --git a/tests/test_glib_dbus_server.cpp b/tests/test_glib_dbus_server.cpp
index b2f965fd0..b72f572c3 100644
--- a/tests/test_glib_dbus_server.cpp
+++ b/tests/test_glib_dbus_server.cpp
@@ -179,7 +179,7 @@ TEST_F(TestGLibDBusServer, AddsObjectsWhenOwingName)
unsigned objects_registered = 0;
server.AddObjects(introspection::MULTIPLE_OJBECTS, TEST_OBJECT_PATH);
- ASSERT_EQ(server.GetObjects().size(), 3);
+ ASSERT_EQ(server.GetObjects().size(), 3u);
for (auto const& obj : server.GetObjects())
{
@@ -193,7 +193,7 @@ TEST_F(TestGLibDBusServer, AddsObjectsWhenOwingName)
Utils::WaitUntilMSec([this] { return server.OwnsName(); });
- EXPECT_EQ(objects_registered, 3);
+ EXPECT_EQ(objects_registered, 3u);
}
TEST_F(TestGLibDBusServer, RemovingObjectWontRegisterIt)
@@ -201,10 +201,10 @@ TEST_F(TestGLibDBusServer, RemovingObjectWontRegisterIt)
unsigned objects_registered = 0;
server.AddObjects(introspection::MULTIPLE_OJBECTS, TEST_OBJECT_PATH);
- ASSERT_EQ(server.GetObjects().size(), 3);
+ ASSERT_EQ(server.GetObjects().size(), 3u);
server.RemoveObject(server.GetObjects().front());
- ASSERT_EQ(server.GetObjects().size(), 2);
+ ASSERT_EQ(server.GetObjects().size(), 2u);
for (auto const& obj : server.GetObjects())
{
@@ -216,13 +216,13 @@ TEST_F(TestGLibDBusServer, RemovingObjectWontRegisterIt)
Utils::WaitUntilMSec([this] { return server.OwnsName(); });
- EXPECT_EQ(objects_registered, 2);
+ EXPECT_EQ(objects_registered, 2u);
}
TEST_F(TestGLibDBusServer, RemovingObjectsUnregistersThem)
{
server.AddObjects(introspection::MULTIPLE_OJBECTS, TEST_OBJECT_PATH);
- ASSERT_EQ(server.GetObjects().size(), 3);
+ ASSERT_EQ(server.GetObjects().size(), 3u);
Utils::WaitUntilMSec([this] { return server.OwnsName(); });
@@ -236,16 +236,16 @@ TEST_F(TestGLibDBusServer, RemovingObjectsUnregistersThem)
}
server.RemoveObject(server.GetObjects().front());
- ASSERT_EQ(server.GetObjects().size(), 2);
- EXPECT_EQ(objects_unregistered, 1);
+ ASSERT_EQ(server.GetObjects().size(), 2u);
+ EXPECT_EQ(objects_unregistered, 1u);
server.RemoveObject(server.GetObjects().front());
- ASSERT_EQ(server.GetObjects().size(), 1);
- EXPECT_EQ(objects_unregistered, 2);
+ ASSERT_EQ(server.GetObjects().size(), 1u);
+ EXPECT_EQ(objects_unregistered, 2u);
server.RemoveObject(server.GetObjects().front());
- ASSERT_EQ(server.GetObjects().size(), 0);
- EXPECT_EQ(objects_unregistered, 3);
+ ASSERT_EQ(server.GetObjects().size(), 0u);
+ EXPECT_EQ(objects_unregistered, 3u);
}
///
@@ -269,7 +269,7 @@ struct TestGLibDBusServerInteractions : testing::Test
ASSERT_TRUE(proxy->IsConnected());
auto const& objects = server->GetObjects();
- ASSERT_EQ(objects.size(), 1);
+ ASSERT_EQ(objects.size(), 1u);
object = objects.front();
ASSERT_NE(object, nullptr);
}
diff --git a/tests/test_glib_object.cpp b/tests/test_glib_object.cpp
index a731689b4..b8ab3913d 100644
--- a/tests/test_glib_object.cpp
+++ b/tests/test_glib_object.cpp
@@ -222,7 +222,7 @@ TEST(TestGLibObject, CastObject)
EXPECT_EQ(cast_copy, gt_obj.RawPtr());
Object<GObject> g_obj = glib::object_cast<GObject>(gt_obj);
- EXPECT_EQ(g_obj->ref_count, 2);
+ EXPECT_EQ(G_OBJECT(g_obj.RawPtr())->ref_count, 2u);
g_object_set_data(g_obj, "TestData", GINT_TO_POINTER(55));
EXPECT_EQ(GPOINTER_TO_INT(g_object_get_data(g_obj, "TestData")), 55);
@@ -285,7 +285,7 @@ TEST(TestGLibObject, ReleaseObject)
// Release() doesn't unref the object.
g_obj.Release();
EXPECT_EQ(g_obj, 0);
- EXPECT_EQ(RefCount(t_obj), 1);
+ EXPECT_EQ(RefCount(t_obj), 1u);
g_object_unref(t_obj);
}
@@ -315,8 +315,8 @@ TEST(TestGLibObject, SwapObjects)
EXPECT_EQ(g_obj1, t_obj1);
EXPECT_EQ(g_obj2, t_obj2);
- EXPECT_EQ(RefCount(g_obj1), 1);
- EXPECT_EQ(RefCount(g_obj2), 1);
+ EXPECT_EQ(RefCount(g_obj1), 1u);
+ EXPECT_EQ(RefCount(g_obj2), 1u);
}
EXPECT_TRUE(IsObjectDestroyed(t_obj1));
@@ -336,29 +336,29 @@ TEST(TestGLibObject, ListOperations)
TestObjectWrapper g_obj4;
TestObjectWrapper g_obj5;
- EXPECT_EQ(RefCount(g_obj1), 1);
+ EXPECT_EQ(RefCount(g_obj1), 1u);
obj_list.push_back(g_obj1);
obj_list.push_back(g_obj2);
obj_list.push_back(g_obj3);
obj_list.push_back(g_obj4);
obj_list.push_back(g_obj5);
- EXPECT_EQ(obj_list.size(), 5);
+ EXPECT_EQ(obj_list.size(), 5u);
- EXPECT_EQ(RefCount(g_obj1), 2);
+ EXPECT_EQ(RefCount(g_obj1), 2u);
obj_list.remove(g_obj2);
- EXPECT_EQ(obj_list.size(), 4);
+ EXPECT_EQ(obj_list.size(), 4u);
EXPECT_TRUE(std::find(obj_list.begin(), obj_list.end(), g_obj3) != obj_list.end());
EXPECT_TRUE(std::find(obj_list.begin(), obj_list.end(), g_obj3.RawPtr()) != obj_list.end());
obj_list.remove(TestObjectWrapper(t_obj1, AddRef()));
- EXPECT_EQ(obj_list.size(), 3);
+ EXPECT_EQ(obj_list.size(), 3u);
EXPECT_TRUE(std::find(obj_list.begin(), obj_list.end(), g_obj4) != obj_list.end());
obj_list.remove(g_obj5);
- EXPECT_EQ(obj_list.size(), 1);
+ EXPECT_EQ(obj_list.size(), 1u);
}
} // Namespace
diff --git a/tests/test_glib_signals.cpp b/tests/test_glib_signals.cpp
index 9b01785e8..1c0b20bf7 100644
--- a/tests/test_glib_signals.cpp
+++ b/tests/test_glib_signals.cpp
@@ -289,7 +289,7 @@ TEST_F(TestGLibSignals, TestConnectReplacePreviousConnection)
g_signal_emit_by_name(test_signals_, "signal0");
EXPECT_FALSE(signal0_received_);
- EXPECT_EQ(signal0_num_cb, 1);
+ EXPECT_EQ(signal0_num_cb, 1u);
}
TEST_F(TestGLibSignals, TestManagerConstruction)
@@ -324,7 +324,7 @@ TEST_F(TestGLibSignals, TestManagerAddition)
"signal6",
sigc::mem_fun(this, &TestGLibSignals::Signal6Callback)));
- EXPECT_EQ(manager.GetConnections().size(), 7);
+ EXPECT_EQ(manager.GetConnections().size(), 7u);
}
TEST_F(TestGLibSignals, TestManagerAdditionTemplate)
@@ -345,7 +345,7 @@ TEST_F(TestGLibSignals, TestManagerAdditionTemplate)
sigc::mem_fun(this, &TestGLibSignals::Signal5Callback));
manager.Add<gboolean, TestSignals*, const char*, int, float, double, gboolean, char>(test_signals_, "signal6", sigc::mem_fun(this, &TestGLibSignals::Signal6Callback));
- EXPECT_EQ(manager.GetConnections().size(), 7);
+ EXPECT_EQ(manager.GetConnections().size(), 7u);
}
TEST_F(TestGLibSignals, TestManagerConnection)
diff --git a/tests/test_glib_source.cpp b/tests/test_glib_source.cpp
index e920fc74e..edc87e9d2 100644
--- a/tests/test_glib_source.cpp
+++ b/tests/test_glib_source.cpp
@@ -56,7 +56,7 @@ bool OnSourceCallbackContinue()
TEST(TestGLibSource, ID)
{
Idle source;
- EXPECT_EQ(source.Id(), 0);
+ EXPECT_EQ(source.Id(), 0u);
}
TEST(TestGLibSource, Running)
@@ -91,7 +91,7 @@ TEST(TestGLibSource, Priority)
TEST(TestGLibTimeout, Construction)
{
Timeout timeout(1000, &OnSourceCallbackContinue);
- EXPECT_NE(timeout.Id(), 0);
+ EXPECT_NE(timeout.Id(), 0u);
EXPECT_TRUE(timeout.IsRunning());
EXPECT_EQ(timeout.GetPriority(), Source::Priority::DEFAULT);
}
@@ -99,7 +99,7 @@ TEST(TestGLibTimeout, Construction)
TEST(TestGLibTimeout, ConstructionEmptyCallback)
{
Timeout timeout(1000, Source::Callback());
- EXPECT_NE(timeout.Id(), 0);
+ EXPECT_NE(timeout.Id(), 0u);
EXPECT_TRUE(timeout.IsRunning());
EXPECT_EQ(timeout.GetPriority(), Source::Priority::DEFAULT);
}
@@ -107,7 +107,7 @@ TEST(TestGLibTimeout, ConstructionEmptyCallback)
TEST(TestGLibTimeout, DelayedRunConstruction)
{
Timeout timeout(1000);
- EXPECT_EQ(timeout.Id(), 0);
+ EXPECT_EQ(timeout.Id(), 0u);
EXPECT_FALSE(timeout.IsRunning());
EXPECT_EQ(timeout.GetPriority(), Source::Priority::DEFAULT);
}
@@ -124,7 +124,7 @@ TEST(TestGLibTimeout, Destroy)
}
EXPECT_TRUE(removed_called);
- EXPECT_EQ(callback_call_count, 0);
+ EXPECT_EQ(callback_call_count, 0u);
}
TEST(TestGLibTimeout, OneShotRun)
@@ -138,7 +138,7 @@ TEST(TestGLibTimeout, OneShotRun)
Utils::WaitUntilMSec([&timeout] {return timeout.IsRunning();}, false, 500);
EXPECT_TRUE(callback_called);
- EXPECT_EQ(callback_call_count, 1);
+ EXPECT_EQ(callback_call_count, 1u);
EXPECT_TRUE(removed_called);
}
@@ -157,7 +157,7 @@ TEST(TestGLibTimeout, MultipleShotsRun)
}
EXPECT_TRUE(callback_called);
- EXPECT_GT(callback_call_count, 1);
+ EXPECT_GT(callback_call_count, 1u);
EXPECT_TRUE(removed_called);
}
@@ -185,10 +185,10 @@ TEST(TestGLibTimeout, Removal)
Utils::WaitUntilMSec([&timeout] {return timeout.IsRunning();}, false, 300);
- EXPECT_NE(timeout.Id(), 0);
+ EXPECT_NE(timeout.Id(), 0u);
EXPECT_TRUE(removed_called);
EXPECT_FALSE(callback_called);
- EXPECT_EQ(callback_call_count, 0);
+ EXPECT_EQ(callback_call_count, 0u);
}
TEST(TestGLibTimeout, Running)
@@ -204,7 +204,7 @@ TEST(TestGLibTimeout, Running)
Utils::WaitUntilMSec([&timeout] {return timeout.IsRunning();}, false, 500);
EXPECT_TRUE(callback_called);
- EXPECT_EQ(callback_call_count, 1);
+ EXPECT_EQ(callback_call_count, 1u);
}
TEST(TestGLibTimeout, RemoveOnCallback)
@@ -225,7 +225,7 @@ TEST(TestGLibTimeout, RemoveOnCallback)
ASSERT_EQ(timeout.IsRunning(), false);
EXPECT_EQ(local_callback_called, true);
- EXPECT_EQ(local_callback_call_count, 1);
+ EXPECT_EQ(local_callback_call_count, 1u);
}
TEST(TestGLibTimeout, RemovePtrOnCallback)
@@ -249,7 +249,7 @@ TEST(TestGLibTimeout, RemovePtrOnCallback)
ASSERT_EQ(timeout, nullptr);
EXPECT_EQ(local_callback_called, true);
- EXPECT_EQ(local_callback_call_count, 1);
+ EXPECT_EQ(local_callback_call_count, 1u);
}
TEST(TestGLibTimeout, AutoRemoveSourceOnCallback)
@@ -270,7 +270,7 @@ TEST(TestGLibTimeout, AutoRemoveSourceOnCallback)
timeout.reset();
EXPECT_EQ(local_callback_called, true);
- EXPECT_EQ(local_callback_call_count, 1);
+ EXPECT_EQ(local_callback_call_count, 1u);
// source should be removed by now.
EXPECT_TRUE(g_main_context_find_source_by_id(NULL, id) == nullptr);
@@ -282,7 +282,7 @@ TEST(TestGLibTimeout, AutoRemoveSourceOnCallback)
TEST(TestGLibTimeoutSeconds, Construction)
{
TimeoutSeconds timeout(1, &OnSourceCallbackContinue);
- EXPECT_NE(timeout.Id(), 0);
+ EXPECT_NE(timeout.Id(), 0u);
EXPECT_TRUE(timeout.IsRunning());
EXPECT_EQ(timeout.GetPriority(), Source::Priority::DEFAULT);
}
@@ -290,7 +290,7 @@ TEST(TestGLibTimeoutSeconds, Construction)
TEST(TestGLibTimeoutSeconds, DelayedRunConstruction)
{
TimeoutSeconds timeout(1);
- EXPECT_EQ(timeout.Id(), 0);
+ EXPECT_EQ(timeout.Id(), 0u);
EXPECT_FALSE(timeout.IsRunning());
EXPECT_EQ(timeout.GetPriority(), Source::Priority::DEFAULT);
}
@@ -307,7 +307,7 @@ TEST(TestGLibTimeoutSeconds, Destroy)
}
EXPECT_TRUE(removed_called);
- EXPECT_EQ(callback_call_count, 0);
+ EXPECT_EQ(callback_call_count, 0u);
}
TEST(TestGLibTimeoutSeconds, OneShotRun)
@@ -321,7 +321,7 @@ TEST(TestGLibTimeoutSeconds, OneShotRun)
Utils::WaitUntil([&timeout] {return timeout.IsRunning();}, false, 2);
EXPECT_TRUE(callback_called);
- EXPECT_EQ(callback_call_count, 1);
+ EXPECT_EQ(callback_call_count, 1u);
EXPECT_TRUE(removed_called);
}
@@ -340,7 +340,7 @@ TEST(TestGLibTimeoutSeconds, MultipleShotsRun)
}
EXPECT_TRUE(callback_called);
- EXPECT_GT(callback_call_count, 1);
+ EXPECT_GT(callback_call_count, 1u);
EXPECT_TRUE(removed_called);
}
@@ -349,7 +349,7 @@ TEST(TestGLibTimeoutSeconds, MultipleShotsRun)
TEST(TestGLibIdle, Construction)
{
Idle idle(&OnSourceCallbackStop);
- EXPECT_NE(idle.Id(), 0);
+ EXPECT_NE(idle.Id(), 0u);
EXPECT_EQ(idle.GetPriority(), Source::Priority::DEFAULT_IDLE);
}
@@ -365,7 +365,7 @@ TEST(TestGLibIdle, Destroy)
}
EXPECT_TRUE(removed_called);
- EXPECT_EQ(callback_call_count, 0);
+ EXPECT_EQ(callback_call_count, 0u);
}
TEST(TestGLibIdle, OneShotRun)
@@ -382,7 +382,7 @@ TEST(TestGLibIdle, OneShotRun)
Utils::WaitUntilMSec([&idle] {return idle.IsRunning();}, false, 100);
EXPECT_FALSE(idle.IsRunning());
EXPECT_TRUE(callback_called);
- EXPECT_EQ(callback_call_count, 1);
+ EXPECT_EQ(callback_call_count, 1u);
EXPECT_LE(pre, post);
}
@@ -402,7 +402,7 @@ TEST(TestGLibIdle, MultipleShotsRun)
}
EXPECT_TRUE(callback_called);
- EXPECT_GT(callback_call_count, 1);
+ EXPECT_GT(callback_call_count, 1u);
DeltaTime time_delta = unity::TimeUtil::TimeDelta(&post, &pre);
EXPECT_GE(time_delta, 100);
EXPECT_LT(time_delta, 200);
@@ -420,10 +420,10 @@ TEST(TestGLibIdle, Removal)
Utils::WaitUntilMSec([&idle] {return idle.IsRunning();}, false, 300);
- EXPECT_NE(idle.Id(), 0);
+ EXPECT_NE(idle.Id(), 0u);
EXPECT_TRUE(removed_called);
EXPECT_FALSE(callback_called);
- EXPECT_EQ(callback_call_count, 0);
+ EXPECT_EQ(callback_call_count, 0u);
}
TEST(TestGLibIdle, Running)
@@ -439,7 +439,7 @@ TEST(TestGLibIdle, Running)
Utils::WaitUntilMSec([&idle] {return idle.IsRunning();}, false, 20000);
EXPECT_TRUE(callback_called);
- EXPECT_EQ(callback_call_count, 1);
+ EXPECT_EQ(callback_call_count, 1u);
}
TEST(TestGLibIdle, RemoveOnCallback)
@@ -460,7 +460,7 @@ TEST(TestGLibIdle, RemoveOnCallback)
ASSERT_EQ(idle.IsRunning(), false);
EXPECT_EQ(local_callback_called, true);
- EXPECT_EQ(local_callback_call_count, 1);
+ EXPECT_EQ(local_callback_call_count, 1u);
}
TEST(TestGLibIdle, RemovePtrOnCallback)
@@ -481,7 +481,7 @@ TEST(TestGLibIdle, RemovePtrOnCallback)
ASSERT_EQ(idle, nullptr);
EXPECT_EQ(local_callback_called, true);
- EXPECT_EQ(local_callback_call_count, 1);
+ EXPECT_EQ(local_callback_call_count, 1u);
}
// Test GLibSource Manager
@@ -509,7 +509,7 @@ TEST(TestGLibSourceManager, AddingAnonymousSources)
manager.Add(new Idle());
manager.Add(new Idle(&OnSourceCallbackContinue));
- EXPECT_EQ(manager.GetSources().size(), 4);
+ EXPECT_EQ(manager.GetSources().size(), 4u);
}
TEST(TestGLibSourceManager, AddingNamedSources)
@@ -532,7 +532,7 @@ TEST(TestGLibSourceManager, AddingNamedSources)
manager.Add(idle_2, "idle-2");
ASSERT_EQ(manager.GetSource("idle-2").get(), idle_2);
- EXPECT_EQ(manager.GetSources().size(), 4);
+ EXPECT_EQ(manager.GetSources().size(), 4u);
}
TEST(TestGLibSourceManager, AddingDuplicatedSources)
@@ -550,7 +550,7 @@ TEST(TestGLibSourceManager, AddingDuplicatedSources)
EXPECT_EQ(manager.GetSource(timeout->Id()), timeout);
EXPECT_EQ(ret, false);
- EXPECT_EQ(manager.GetSources().size(), 1);
+ EXPECT_EQ(manager.GetSources().size(), 1u);
}
TEST(TestGLibSourceManager, AddingDuplicatedNamedSources)
@@ -570,7 +570,7 @@ TEST(TestGLibSourceManager, AddingDuplicatedNamedSources)
EXPECT_EQ(ret, true);
EXPECT_FALSE(timeout_1->IsRunning());
- EXPECT_EQ(manager.GetSources().size(), 1);
+ EXPECT_EQ(manager.GetSources().size(), 1u);
}
TEST(TestGLibSourceManager, AddingTimeouts)
@@ -580,7 +580,7 @@ TEST(TestGLibSourceManager, AddingTimeouts)
auto timeout1 = manager.AddTimeout(1);
auto timeout2 = manager.AddTimeout(1, &OnSourceCallbackContinue);
- EXPECT_EQ(manager.GetSources().size(), 2);
+ EXPECT_EQ(manager.GetSources().size(), 2u);
EXPECT_FALSE(timeout1->IsRunning());
EXPECT_TRUE(timeout2->IsRunning());
}
@@ -592,7 +592,7 @@ TEST(TestGLibSourceManager, AddingIdles)
auto idle1 = manager.AddIdle();
auto idle2 = manager.AddIdle(&OnSourceCallbackContinue);
- EXPECT_EQ(manager.GetSources().size(), 2);
+ EXPECT_EQ(manager.GetSources().size(), 2u);
EXPECT_FALSE(idle1->IsRunning());
EXPECT_TRUE(idle2->IsRunning());
}
@@ -613,21 +613,21 @@ TEST(TestGLibSourceManager, RemovingSourcesById)
manager.Remove(timeout1->Id());
EXPECT_FALSE(timeout1->IsRunning());
- EXPECT_EQ(manager.GetSources().size(), 3);
+ EXPECT_EQ(manager.GetSources().size(), 3u);
manager.Remove(timeout2->Id());
EXPECT_FALSE(timeout2->IsRunning());
EXPECT_EQ(manager.GetSource(timeout2->Id()), nullptr);
- EXPECT_EQ(manager.GetSources().size(), 2);
+ EXPECT_EQ(manager.GetSources().size(), 2u);
manager.Remove(idle1->Id());
EXPECT_FALSE(idle1->IsRunning());
- EXPECT_EQ(manager.GetSources().size(), 1);
+ EXPECT_EQ(manager.GetSources().size(), 1u);
manager.Remove(idle2->Id());
EXPECT_FALSE(idle2->IsRunning());
EXPECT_EQ(manager.GetSource(idle2->Id()), nullptr);
- EXPECT_EQ(manager.GetSources().size(), 0);
+ EXPECT_EQ(manager.GetSources().size(), 0u);
}
TEST(TestGLibSourceManager, RemovingSourcesByNick)
@@ -647,22 +647,22 @@ TEST(TestGLibSourceManager, RemovingSourcesByNick)
manager.Remove("timeout-1");
EXPECT_FALSE(timeout1->IsRunning());
EXPECT_EQ(manager.GetSource("timeout-1"), nullptr);
- EXPECT_EQ(manager.GetSources().size(), 3);
+ EXPECT_EQ(manager.GetSources().size(), 3u);
manager.Remove("timeout-2");
EXPECT_FALSE(timeout2->IsRunning());
EXPECT_EQ(manager.GetSource("timeout-2"), nullptr);
- EXPECT_EQ(manager.GetSources().size(), 2);
+ EXPECT_EQ(manager.GetSources().size(), 2u);
manager.Remove("idle-1");
EXPECT_FALSE(idle1->IsRunning());
EXPECT_EQ(manager.GetSource("idle-1"), nullptr);
- EXPECT_EQ(manager.GetSources().size(), 1);
+ EXPECT_EQ(manager.GetSources().size(), 1u);
manager.Remove("idle-2");
EXPECT_FALSE(idle2->IsRunning());
EXPECT_EQ(manager.GetSource("idle-2"), nullptr);
- EXPECT_EQ(manager.GetSources().size(), 0);
+ EXPECT_EQ(manager.GetSources().size(), 0u);
}
TEST(TestGLibSourceManager, RemovesOnDisconnection)
@@ -675,16 +675,16 @@ TEST(TestGLibSourceManager, RemovesOnDisconnection)
manager.Add(timeout);
manager.Add(idle);
- ASSERT_EQ(manager.GetSources().size(), 2);
+ ASSERT_EQ(manager.GetSources().size(), 2u);
EXPECT_EQ(timeout, manager.GetSource(timeout->Id()));
EXPECT_EQ(idle, manager.GetSource(idle->Id()));
timeout->Remove();
- EXPECT_EQ(manager.GetSources().size(), 1);
+ EXPECT_EQ(manager.GetSources().size(), 1u);
EXPECT_EQ(manager.GetSource(timeout->Id()), nullptr);
idle->Remove();
- EXPECT_EQ(manager.GetSources().size(), 0);
+ EXPECT_EQ(manager.GetSources().size(), 0u);
EXPECT_EQ(manager.GetSource(idle->Id()), nullptr);
}
@@ -742,7 +742,7 @@ TEST(TestGLibSourceManager, RemoveSourceOnCallback)
ASSERT_FALSE(idle->IsRunning());
EXPECT_TRUE(local_callback_called);
- EXPECT_EQ(1, local_callback_call_count);
+ EXPECT_EQ(1u, local_callback_call_count);
}
}
diff --git a/tests/test_glib_variant.cpp b/tests/test_glib_variant.cpp
index f0bab992d..e49529d5e 100644
--- a/tests/test_glib_variant.cpp
+++ b/tests/test_glib_variant.cpp
@@ -241,9 +241,9 @@ TEST(TestGLibVariant, ConstructHintsMap)
EXPECT_EQ("charstring-value", Variant(g_variant_lookup_value(v, "charstring-key", nullptr)).GetString());
EXPECT_EQ("string-value", Variant(g_variant_lookup_value(v, "string-key", nullptr)).GetString());
EXPECT_EQ(-1, Variant(g_variant_lookup_value(v, "gint32-key", nullptr)).GetInt32());
- EXPECT_EQ(2, Variant(g_variant_lookup_value(v, "guint32-key", nullptr)).GetUInt32());
+ EXPECT_EQ(2u, Variant(g_variant_lookup_value(v, "guint32-key", nullptr)).GetUInt32());
EXPECT_EQ(-3, Variant(g_variant_lookup_value(v, "gint64-key", nullptr)).GetInt64());
- EXPECT_EQ(4, Variant(g_variant_lookup_value(v, "guint64-key", nullptr)).GetUInt64());
+ EXPECT_EQ(4u, Variant(g_variant_lookup_value(v, "guint64-key", nullptr)).GetUInt64());
EXPECT_FLOAT_EQ(1.1, Variant(g_variant_lookup_value(v, "float-key", nullptr)).GetFloat());
EXPECT_DOUBLE_EQ(2.2, Variant(g_variant_lookup_value(v, "double-key", nullptr)).GetDouble());
EXPECT_EQ(true, Variant(g_variant_lookup_value(v, "bool-key", nullptr)).GetBool());
@@ -387,9 +387,9 @@ TEST(TestGLibVariant, AssignHintsMap)
EXPECT_EQ("charstring-value", Variant(g_variant_lookup_value(v, "charstring-key", nullptr)).GetString());
EXPECT_EQ("string-value", Variant(g_variant_lookup_value(v, "string-key", nullptr)).GetString());
EXPECT_EQ(-1, Variant(g_variant_lookup_value(v, "gint32-key", nullptr)).GetInt32());
- EXPECT_EQ(2, Variant(g_variant_lookup_value(v, "guint32-key", nullptr)).GetUInt32());
+ EXPECT_EQ(2u, Variant(g_variant_lookup_value(v, "guint32-key", nullptr)).GetUInt32());
EXPECT_EQ(-3, Variant(g_variant_lookup_value(v, "gint64-key", nullptr)).GetInt64());
- EXPECT_EQ(4, Variant(g_variant_lookup_value(v, "guint64-key", nullptr)).GetUInt64());
+ EXPECT_EQ(4u, Variant(g_variant_lookup_value(v, "guint64-key", nullptr)).GetUInt64());
EXPECT_FLOAT_EQ(1.1, Variant(g_variant_lookup_value(v, "float-key", nullptr)).GetFloat());
EXPECT_DOUBLE_EQ(2.2, Variant(g_variant_lookup_value(v, "double-key", nullptr)).GetDouble());
EXPECT_EQ(true, Variant(g_variant_lookup_value(v, "bool-key", nullptr)).GetBool());
@@ -590,10 +590,10 @@ TEST(TestGLibVariant, GetUInt32)
EXPECT_EQ(v2.GetUInt32(), value);
Variant v3(g_variant_new("(ui)", value, G_MAXUINT32));
- EXPECT_EQ(v3.GetUInt32(), 0);
+ EXPECT_EQ(v3.GetUInt32(), 0u);
Variant v4;
- EXPECT_EQ(v4.GetUInt32(), 0);
+ EXPECT_EQ(v4.GetUInt32(), 0u);
value = g_random_int();
Variant v5(g_variant_new_variant(g_variant_new_uint32(value)));
@@ -632,10 +632,10 @@ TEST(TestGLibVariant, GetUInt64)
EXPECT_EQ(v2.GetUInt64(), value);
Variant v3(g_variant_new("(ti)", value, G_MAXINT64));
- EXPECT_EQ(v3.GetUInt64(), 0);
+ EXPECT_EQ(v3.GetUInt64(), 0u);
Variant v4;
- EXPECT_EQ(v4.GetUInt64(), 0);
+ EXPECT_EQ(v4.GetUInt64(), 0u);
value = g_random_int();
Variant v5(g_variant_new_variant(g_variant_new_uint64(value)));
@@ -702,7 +702,7 @@ TEST(TestGLibVariant, FromVectorEmpty)
auto const& variant = Variant::FromVector(empty);
ASSERT_TRUE(g_variant_is_container(variant));
- ASSERT_EQ(0, g_variant_n_children(variant));
+ ASSERT_EQ(0u, g_variant_n_children(variant));
EXPECT_TRUE(g_variant_is_of_type(variant, G_VARIANT_TYPE_ARRAY));
}
diff --git a/tests/test_gnome_session_manager.cpp b/tests/test_gnome_session_manager.cpp
index b78329884..a5ba3eed4 100644
--- a/tests/test_gnome_session_manager.cpp
+++ b/tests/test_gnome_session_manager.cpp
@@ -70,6 +70,9 @@ R"(<node>
const std::string LOGIND_MANAGER =
R"(<node>
<interface name="org.freedesktop.login1.Manager">
+ <method name="GetSession">
+ <arg type="s" name="result" direction="out"/>
+ </method>
<method name="CanSuspend">
<arg type="s" name="result" direction="out"/>
</method>
@@ -186,7 +189,11 @@ struct TestGnomeSessionManager : testing::Test
logind_->AddObjects(introspection::LOGIND_MANAGER, LOGIND_MANAGER_PATH);
logind_->AddObjects(introspection::LOGIND_SESSION, LOGIND_SESSION_PATH);
logind_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant*) -> GVariant* {
- if (method == "CanSuspend")
+ if (method == "GetSession")
+ {
+ return g_variant_new("(o)", "id0");
+ }
+ else if (method == "CanSuspend")
{
suspend_called = true;
return g_variant_new("(s)", can_suspend_ ? "yes" : "no");
@@ -503,7 +510,7 @@ TEST_F(TestGnomeSessionManager, Logout)
if (method == "Logout")
{
logout_called = true;
- EXPECT_EQ(Variant(par).GetUInt32(), 1);
+ EXPECT_EQ(Variant(par).GetUInt32(), 1u);
}
return nullptr;
diff --git a/tests/test_grabhandle.cpp b/tests/test_grabhandle.cpp
index 3def4b4af..966a8817e 100644
--- a/tests/test_grabhandle.cpp
+++ b/tests/test_grabhandle.cpp
@@ -168,7 +168,7 @@ TEST_F(UnityMTGrabHandleTest, TestLayoutMasks) {
EXPECT_EQ (handlesMask, MiddleHandle);
handlesMask = unity::MT::getLayoutForMask (MaximizedHorzMask | MaximizedVertMask, ResizeMask);
- EXPECT_EQ (handlesMask, 0);
+ EXPECT_EQ (handlesMask, 0u);
handlesMask = unity::MT::getLayoutForMask (MaximizedHorzMask, ResizeMask);
EXPECT_EQ (handlesMask, BottomHandle | TopHandle);
@@ -193,7 +193,7 @@ TEST_F(UnityMTGrabHandleTest, TestLayoutMasks) {
EXPECT_EQ (handlesMask, MiddleHandle);
handlesMask = unity::MT::getLayoutForMask (0, 0);
- EXPECT_EQ (handlesMask, 0);
+ EXPECT_EQ (handlesMask, 0u);
}
TEST_F(UnityMTGrabHandleTest, TestLayouts)
diff --git a/tests/test_gsettings_scopes.cpp b/tests/test_gsettings_scopes.cpp
index f71bfca54..9268045ee 100644
--- a/tests/test_gsettings_scopes.cpp
+++ b/tests/test_gsettings_scopes.cpp
@@ -72,9 +72,9 @@ public:
});
}
- int scope_added;
- int scope_removed;
- int scopes_reordered;
+ unsigned scope_added;
+ unsigned scope_removed;
+ unsigned scopes_reordered;
};
TEST_F(TestGSettingsScopes, TestAdded)
@@ -83,13 +83,13 @@ TEST_F(TestGSettingsScopes, TestAdded)
ConnectScope(&scopes);
scopes.InsertScope("testscope1.scope", 0);
- EXPECT_EQ(scopes.count, (unsigned int)1);
- EXPECT_EQ(scopes_reordered, (unsigned int)0);
+ EXPECT_EQ(scopes.count, 1u);
+ EXPECT_EQ(scopes_reordered, 0u);
// add another
scopes.InsertScope("testscope2.scope", 1);
- EXPECT_EQ(scopes.count, (unsigned int)2);
- EXPECT_EQ(scopes_reordered, (unsigned int)0);
+ EXPECT_EQ(scopes.count, 2u);
+ EXPECT_EQ(scopes_reordered, 0u);
int position = -1;
EXPECT_TRUE(scopes.GetScope("testscope1.scope", &position) && position == 0);
@@ -105,12 +105,12 @@ TEST_F(TestGSettingsScopes, TestReorderBefore)
scopes.InsertScope("testscope2.scope", 1);
scopes.InsertScope("testscope3.scope", 2);
scopes.InsertScope("testscope4.scope", 3);
- EXPECT_EQ(scopes.count, (unsigned int)4);
- EXPECT_EQ(scopes_reordered, (unsigned int)0);
+ EXPECT_EQ(scopes.count, 4u);
+ EXPECT_EQ(scopes_reordered, 0u);
// change position
scopes.InsertScope("testscope3.scope", 0);
- EXPECT_EQ(scopes_reordered, (unsigned int)1);
+ EXPECT_EQ(scopes_reordered, 1u);
int position = -1;
EXPECT_TRUE(scopes.GetScope("testscope3.scope", &position) && position == 0);
@@ -128,12 +128,12 @@ TEST_F(TestGSettingsScopes, TestReorderAfter)
scopes.InsertScope("testscope2.scope", 1);
scopes.InsertScope("testscope3.scope", 2);
scopes.InsertScope("testscope4.scope", 3);
- EXPECT_EQ(scopes.count, (unsigned int)4);
- EXPECT_EQ(scopes_reordered, (unsigned int)0);
+ EXPECT_EQ(scopes.count, 4u);
+ EXPECT_EQ(scopes_reordered, 0u);
// change position
scopes.InsertScope("testscope2.scope", 3);
- EXPECT_EQ(scopes_reordered, (unsigned int)1);
+ EXPECT_EQ(scopes_reordered, 1u);
int position = -1;
EXPECT_TRUE(scopes.GetScope("testscope1.scope", &position) && position == 0);
@@ -149,8 +149,8 @@ TEST_F(TestGSettingsScopes, TestAddNonExists)
ConnectScope(&scopes);
scopes.InsertScope("non-existing.scope", 0);
- EXPECT_EQ(scope_added, (unsigned int)0);
- EXPECT_EQ(scopes.count, (unsigned int)0);
+ EXPECT_EQ(scope_added, 0u);
+ EXPECT_EQ(scopes.count, 0u);
}
TEST_F(TestGSettingsScopes, TestAddSame)
@@ -159,15 +159,15 @@ TEST_F(TestGSettingsScopes, TestAddSame)
ConnectScope(&scopes);
scopes.InsertScope("testscope1.scope", 0);
- EXPECT_EQ(scope_added, (unsigned int)1);
- EXPECT_EQ(scopes.count, (unsigned int)1);
+ EXPECT_EQ(scope_added, 1u);
+ EXPECT_EQ(scopes.count, 1u);
// shouldnt add another
scopes.InsertScope("testscope1.scope", 1);
- EXPECT_EQ(scope_added, (unsigned int)1);
- EXPECT_EQ(scopes.count, (unsigned int)1);
- EXPECT_EQ(scopes_reordered, (unsigned int)0);
+ EXPECT_EQ(scope_added, 1u);
+ EXPECT_EQ(scopes.count, 1u);
+ EXPECT_EQ(scopes_reordered, 0u);
}
TEST_F(TestGSettingsScopes, TestAddRemove)
@@ -176,12 +176,12 @@ TEST_F(TestGSettingsScopes, TestAddRemove)
ConnectScope(&scopes);
scopes.InsertScope("testscope1.scope", 0);
- EXPECT_EQ(scope_added, (unsigned int)1);
- EXPECT_EQ(scopes.count, (unsigned int)1);
+ EXPECT_EQ(scope_added, 1u);
+ EXPECT_EQ(scopes.count, 1u);
scopes.RemoveScope("testscope1.scope");
- EXPECT_EQ(scope_removed, (unsigned int)1);
- EXPECT_EQ(scopes.count, (unsigned int)0);
+ EXPECT_EQ(scope_removed, 1u);
+ EXPECT_EQ(scopes.count, 0u);
}
TEST_F(TestGSettingsScopes, TestRemoveNonExists)
@@ -190,8 +190,8 @@ TEST_F(TestGSettingsScopes, TestRemoveNonExists)
ConnectScope(&scopes);
scopes.RemoveScope("non-existing.scope");
- EXPECT_EQ(scope_removed, (unsigned int)0);
- EXPECT_EQ(scopes.count, (unsigned int)0);
+ EXPECT_EQ(scope_removed, 0u);
+ EXPECT_EQ(scopes.count, 0u);
}
TEST_F(TestGSettingsScopes, TestLoad)
@@ -200,7 +200,7 @@ TEST_F(TestGSettingsScopes, TestLoad)
ConnectScope(&scopes);
scopes.LoadScopes();
- EXPECT_EQ(scope_added, (unsigned int)4);
+ EXPECT_EQ(scope_added, 4u);
int position = -1;
EXPECT_TRUE(scopes.GetScope("testscope1.scope", &position) && position == 0);
@@ -215,15 +215,15 @@ TEST_F(TestGSettingsScopes, TestLoadUpdateGSettings)
ConnectScope(&scopes);
scopes.LoadScopes();
- EXPECT_EQ(scope_added, (unsigned int)2);
- EXPECT_EQ(scopes.count, (unsigned int)2);
+ EXPECT_EQ(scope_added, 2u);
+ EXPECT_EQ(scopes.count, 2u);
scopes.UpdateScopes(scopes_updated);
Utils::WaitUntilMSec([this] { return scope_removed > 0; }, true, 2000);
- EXPECT_EQ(scope_added, (unsigned int)4);
- EXPECT_EQ(scope_removed, (unsigned int)1);
- EXPECT_EQ(scopes.count, (unsigned int)3);
+ EXPECT_EQ(scope_added, 4u);
+ EXPECT_EQ(scope_removed, 1u);
+ EXPECT_EQ(scopes.count, 3u);
}
diff --git a/tests/test_hud_button.cpp b/tests/test_hud_button.cpp
index 67d211f5a..f8210fe35 100644
--- a/tests/test_hud_button.cpp
+++ b/tests/test_hud_button.cpp
@@ -41,13 +41,13 @@ TEST(TestHudButton, TestLabelOpacity)
nux::Layout* layout = button->GetLayout();
ASSERT_NE(layout, nullptr);
- ASSERT_EQ(layout->GetChildren().size(), 0);
+ ASSERT_EQ(layout->GetChildren().size(), 0u);
hud::Query::Ptr query(new hud::Query("<b>Op</b> Fi<b>le</b>", "","", "", "", NULL));
button->SetQuery(query);
auto children(layout->GetChildren());
- ASSERT_EQ(children.size(), 3);
+ ASSERT_EQ(children.size(), 3u);
auto it = children.begin();
StaticCairoText* label = dynamic_cast<StaticCairoText*>(*it);
diff --git a/tests/test_hud_private.cpp b/tests/test_hud_private.cpp
index d8e657cd1..965aaaba2 100644
--- a/tests/test_hud_private.cpp
+++ b/tests/test_hud_private.cpp
@@ -32,20 +32,20 @@ TEST(TestHudPrivate, RefactorTextEmpty)
std::vector<std::pair<std::string, bool>> temp;
temp = impl::RefactorText("");
- ASSERT_EQ(temp.size(), 0);
+ ASSERT_EQ(temp.size(), 0u);
temp = impl::RefactorText("Test");
- ASSERT_EQ(temp.size(), 1);
+ ASSERT_EQ(temp.size(), 1u);
EXPECT_EQ(temp[0].first, "Test");
EXPECT_EQ(temp[0].second, false); // True means "Full opacity", false "Half opacity"
temp = impl::RefactorText("<b>Test</b>");
- ASSERT_EQ(temp.size(), 1);
+ ASSERT_EQ(temp.size(), 1u);
EXPECT_EQ(temp[0].first, "Test");
EXPECT_EQ(temp[0].second, true);
temp = impl::RefactorText("Hello > <b>Test</b> World");
- ASSERT_EQ(temp.size(), 3);
+ ASSERT_EQ(temp.size(), 3u);
EXPECT_EQ(temp[0].first, "Hello > ");
EXPECT_EQ(temp[0].second, false);
EXPECT_EQ(temp[1].first, "Test");
@@ -54,7 +54,7 @@ TEST(TestHudPrivate, RefactorTextEmpty)
EXPECT_EQ(temp[2].second, false);
temp = impl::RefactorText("Open <b>Fi</b>le <b>Wit</b>h");
- ASSERT_EQ(temp.size(), 5);
+ ASSERT_EQ(temp.size(), 5u);
EXPECT_EQ(temp[0].first, "Open ");
EXPECT_EQ(temp[0].second, false);
EXPECT_EQ(temp[1].first, "Fi");
@@ -67,7 +67,7 @@ TEST(TestHudPrivate, RefactorTextEmpty)
EXPECT_EQ(temp[4].second, false);
temp = impl::RefactorText("Open <b>File With");
- ASSERT_EQ(temp.size(), 2);
+ ASSERT_EQ(temp.size(), 2u);
EXPECT_EQ(temp[0].first, "Open ");
EXPECT_EQ(temp[0].second, false);
EXPECT_EQ(temp[1].first, "File With");
diff --git a/tests/test_hud_view.cpp b/tests/test_hud_view.cpp
index 049b5ae3d..d205f449a 100644
--- a/tests/test_hud_view.cpp
+++ b/tests/test_hud_view.cpp
@@ -50,7 +50,7 @@ TEST(TestHudView, TestSetQueries)
queries.push_back(hud::Query::Ptr(new hud::Query("4", "","", "", "", NULL)));
view->SetQueries(queries);
- ASSERT_EQ(view->buttons().size(), 4);
+ ASSERT_EQ(view->buttons().size(), 4u);
auto it = view->buttons().begin();
EXPECT_EQ((*it)->label, "4");
diff --git a/tests/test_indicator.cpp b/tests/test_indicator.cpp
index 1f6c8a90f..a8f956380 100644
--- a/tests/test_indicator.cpp
+++ b/tests/test_indicator.cpp
@@ -94,19 +94,19 @@ TEST(TestIndicator, Syncing)
}
indicator.Sync(sync_data);
- EXPECT_EQ(indicator.GetEntries().size(), 3);
+ EXPECT_EQ(indicator.GetEntries().size(), 3u);
EXPECT_EQ(indicator.GetEntry("test-entry-2"), entry2);
// Mock::VerifyAndClearExpectations(&sig_receiver);
// Sync the indicator removing an entry
sync_data.erase(std::remove(sync_data.begin(), sync_data.end(), entry2), sync_data.end());
- EXPECT_EQ(sync_data.size(), 2);
+ EXPECT_EQ(sync_data.size(), 2u);
EXPECT_CALL(sig_receiver, Updated());
EXPECT_CALL(sig_receiver, EntryAdded(_)).Times(0);
EXPECT_CALL(sig_receiver, EntryRemoved(entry2));
indicator.Sync(sync_data);
- EXPECT_EQ(indicator.GetEntries().size(), 2);
+ EXPECT_EQ(indicator.GetEntries().size(), 2u);
EXPECT_EQ(indicator.GetEntry("test-entry-2"), nullptr);
// Sync the indicator removing an entry and adding a new one
@@ -115,13 +115,13 @@ TEST(TestIndicator, Syncing)
Entry::Ptr entry4(entry);
sync_data.push_back(entry4);
sync_data.erase(std::remove(sync_data.begin(), sync_data.end(), entry3), sync_data.end());
- EXPECT_EQ(sync_data.size(), 2);
+ EXPECT_EQ(sync_data.size(), 2u);
EXPECT_CALL(sig_receiver, EntryAdded(entry4));
EXPECT_CALL(sig_receiver, EntryRemoved(entry3));
EXPECT_CALL(sig_receiver, Updated());
indicator.Sync(sync_data);
- EXPECT_EQ(indicator.GetEntries().size(), 2);
+ EXPECT_EQ(indicator.GetEntries().size(), 2u);
// Remove all the indicators
@@ -132,7 +132,7 @@ TEST(TestIndicator, Syncing)
sync_data.clear();
indicator.Sync(sync_data);
- EXPECT_EQ(indicator.GetEntries().size(), 0);
+ EXPECT_EQ(indicator.GetEntries().size(), 0u);
}
TEST(TestIndicator, Updated)
diff --git a/tests/test_indicator_appmenu.cpp b/tests/test_indicator_appmenu.cpp
index e9a9d6dd8..7bd57780e 100644
--- a/tests/test_indicator_appmenu.cpp
+++ b/tests/test_indicator_appmenu.cpp
@@ -108,7 +108,7 @@ TEST(TestAppmenuIndicator, Syncing)
// Sync the indicator removing an entry
sync_data.erase(std::remove(sync_data.begin(), sync_data.end(), entry2), sync_data.end());
- ASSERT_EQ(sync_data.size(), 2);
+ ASSERT_EQ(sync_data.size(), 2u);
EXPECT_CALL(sig_receiver, Updated());
EXPECT_CALL(sig_receiver, UpdatedWin(parent_window1));
EXPECT_CALL(sig_receiver, UpdatedWin(parent_window2)).Times(0);
@@ -116,7 +116,7 @@ TEST(TestAppmenuIndicator, Syncing)
EXPECT_CALL(sig_receiver, EntryRemoved(entry2));
indicator.Sync(sync_data);
- EXPECT_EQ(indicator.GetEntries().size(), 2);
+ EXPECT_EQ(indicator.GetEntries().size(), 2u);
EXPECT_EQ(indicator.GetEntry("test-entry-2"), nullptr);
EXPECT_EQ(indicator.GetEntriesForWindow(parent_window1), Indicator::Entries({entry1}));
@@ -124,7 +124,7 @@ TEST(TestAppmenuIndicator, Syncing)
auto entry4 = std::make_shared<Entry>("test-entry-4", "name-hint", parent_window2, "label", true, true, 0, "icon", true, true, -1);
sync_data.push_back(entry4);
sync_data.erase(std::remove(sync_data.begin(), sync_data.end(), entry3), sync_data.end());
- EXPECT_EQ(sync_data.size(), 2);
+ EXPECT_EQ(sync_data.size(), 2u);
EXPECT_CALL(sig_receiver, EntryAdded(entry4));
EXPECT_CALL(sig_receiver, EntryRemoved(entry3));
diff --git a/tests/test_indicator_entry.cpp b/tests/test_indicator_entry.cpp
index 1809f0191..857d765f7 100644
--- a/tests/test_indicator_entry.cpp
+++ b/tests/test_indicator_entry.cpp
@@ -40,7 +40,7 @@ TEST(TestIndicatorEntry, TestConstruction)
EXPECT_EQ(entry.id(), "id");
EXPECT_EQ(entry.name_hint(), "name_hint");
- EXPECT_EQ(entry.parent_window(), 12345);
+ EXPECT_EQ(entry.parent_window(), 12345u);
EXPECT_EQ(entry.label(), "label");
EXPECT_TRUE(entry.label_sensitive());
EXPECT_TRUE(entry.label_visible());
@@ -60,7 +60,7 @@ TEST(TestIndicatorEntry, TestConstructionEmpty)
EXPECT_EQ(entry.id(), "id");
EXPECT_EQ(entry.name_hint(), "name_hint");
- EXPECT_EQ(entry.parent_window(), 12345);
+ EXPECT_EQ(entry.parent_window(), 12345u);
EXPECT_TRUE(entry.label().empty());
EXPECT_FALSE(entry.label_sensitive());
EXPECT_FALSE(entry.label_visible());
@@ -85,7 +85,7 @@ TEST(TestIndicatorEntry, TestAssignment)
EXPECT_EQ(entry.id(), "other_id");
EXPECT_EQ(entry.name_hint(), "other_name_hint");
- EXPECT_EQ(entry.parent_window(), 54321);
+ EXPECT_EQ(entry.parent_window(), 54321u);
EXPECT_EQ(entry.label(), "other_label");
EXPECT_FALSE(entry.label_sensitive());
EXPECT_FALSE(entry.label_visible());
diff --git a/tests/test_indicators.cpp b/tests/test_indicators.cpp
index 11f5c4611..a2004aaec 100644
--- a/tests/test_indicators.cpp
+++ b/tests/test_indicators.cpp
@@ -76,7 +76,7 @@ struct TestIndicators : Test
// Sync the indicator, adding 3 entries
test_indicator_1->Sync(sync_data);
- EXPECT_EQ(test_indicator_1->GetEntries().size(), 3);
+ EXPECT_EQ(test_indicator_1->GetEntries().size(), 3u);
// Adding another indicator filled with entries into the TestMockIndicators
@@ -93,9 +93,9 @@ struct TestIndicators : Test
// Sync the indicator, adding 2 entries
test_indicator_2->Sync(sync_data);
- EXPECT_EQ(test_indicator_2->GetEntries().size(), 2);
+ EXPECT_EQ(test_indicator_2->GetEntries().size(), 2u);
- ASSERT_THAT(indicators.GetIndicators().size(), 2);
+ ASSERT_THAT(indicators.GetIndicators().size(), 2u);
}
MockIndicators::Nice indicators;
@@ -135,7 +135,7 @@ TEST_F(TestIndicators, IndicatorsHandling)
EXPECT_EQ(indicators.GetIndicator("indicator-test-1"), test_indicator_1);
indicators_list = indicators.GetIndicators();
- EXPECT_EQ(indicators_list.size(), 1);
+ EXPECT_EQ(indicators_list.size(), 1u);
EXPECT_NE(std::find(indicators_list.begin(), indicators_list.end(), test_indicator_1), indicators_list.end());
EXPECT_CALL(sig_receiver, OnObjectAdded(_));
@@ -145,7 +145,7 @@ TEST_F(TestIndicators, IndicatorsHandling)
EXPECT_EQ(indicators.GetIndicator("indicator-test-2"), test_indicator_2);
indicators_list = indicators.GetIndicators();
- EXPECT_EQ(indicators_list.size(), 2);
+ EXPECT_EQ(indicators_list.size(), 2u);
EXPECT_NE(std::find(indicators_list.begin(), indicators_list.end(), test_indicator_2), indicators_list.end());
EXPECT_CALL(sig_receiver, OnObjectAdded(_));
@@ -155,14 +155,14 @@ TEST_F(TestIndicators, IndicatorsHandling)
EXPECT_EQ(indicators.GetIndicator("indicator-test-3"), test_indicator_3);
indicators_list = indicators.GetIndicators();
- EXPECT_EQ(indicators_list.size(), 3);
+ EXPECT_EQ(indicators_list.size(), 3u);
EXPECT_NE(std::find(indicators_list.begin(), indicators_list.end(), test_indicator_3), indicators_list.end());
EXPECT_CALL(sig_receiver, OnObjectAdded(_)).Times(0);
EXPECT_CALL(sig_receiver, OnObjectRemoved(_)).Times(0);
ASSERT_THAT(indicators.GetIndicator("invalid-indicator-test-4"), IsNull());
- EXPECT_EQ(indicators.GetIndicators().size(), 3);
+ EXPECT_EQ(indicators.GetIndicators().size(), 3u);
// Readding an indicator already there should do nothing
EXPECT_CALL(sig_receiver, OnObjectAdded(_)).Times(0);
@@ -170,7 +170,7 @@ TEST_F(TestIndicators, IndicatorsHandling)
Indicator::Ptr test_indicator_3_duplicate(indicators.AddIndicator("indicator-test-3"));
EXPECT_EQ(indicators.GetIndicator("indicator-test-3"), test_indicator_3);
- EXPECT_EQ(indicators.GetIndicators().size(), 3);
+ EXPECT_EQ(indicators.GetIndicators().size(), 3u);
EXPECT_EQ(test_indicator_3, test_indicator_3_duplicate);
// Removing the indicators...
@@ -181,7 +181,7 @@ TEST_F(TestIndicators, IndicatorsHandling)
ASSERT_THAT(indicators.GetIndicator("indicator-test-2"), IsNull());
indicators_list = indicators.GetIndicators();
- EXPECT_EQ(indicators_list.size(), 2);
+ EXPECT_EQ(indicators_list.size(), 2u);
EXPECT_EQ(std::find(indicators_list.begin(), indicators_list.end(), test_indicator_2), indicators_list.end());
EXPECT_CALL(sig_receiver, OnObjectAdded(_)).Times(0);
@@ -191,7 +191,7 @@ TEST_F(TestIndicators, IndicatorsHandling)
ASSERT_THAT(indicators.GetIndicator("indicator-test-1"), IsNull());
indicators_list = indicators.GetIndicators();
- EXPECT_EQ(indicators_list.size(), 1);
+ EXPECT_EQ(indicators_list.size(), 1u);
EXPECT_EQ(std::find(indicators_list.begin(), indicators_list.end(), test_indicator_1), indicators_list.end());
EXPECT_CALL(sig_receiver, OnObjectAdded(_)).Times(0);
@@ -353,7 +353,7 @@ TEST_F(TestIndicators, ShowAppMenu)
ASSERT_TRUE(appmenu_indicator->IsAppmenu());
}
- ASSERT_EQ(indicators.GetIndicators().size(), 1);
+ ASSERT_EQ(indicators.GetIndicators().size(), 1u);
{
Indicator::Ptr indicator = indicators.GetIndicator("libappmenu.so");
diff --git a/tests/test_introspection_data.cpp b/tests/test_introspection_data.cpp
index fbdef29e2..2bc00a344 100644
--- a/tests/test_introspection_data.cpp
+++ b/tests/test_introspection_data.cpp
@@ -54,9 +54,9 @@ TEST(TestIntrospectionData, AddBool)
data.add("Bool", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Bool", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value, g_variant_get_boolean(get_variant_child(variant, 1)));
}
@@ -68,9 +68,9 @@ TEST(TestIntrospectionData, AddConstChar)
auto tmp = data.Get();
GVariant* variant = g_variant_lookup_value(tmp, "ConstChar", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_STREQ(value, g_variant_get_string(get_variant_child(variant, 1), nullptr));
}
@@ -81,9 +81,9 @@ TEST(TestIntrospectionData, AddString)
data.add("String", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "String", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value, g_variant_get_string(get_variant_child(variant, 1), nullptr));
}
@@ -94,9 +94,9 @@ TEST(TestIntrospectionData, AddInt16)
data.add("Int16", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Int16", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value, g_variant_get_int16(get_variant_child(variant, 1)));
}
@@ -107,9 +107,9 @@ TEST(TestIntrospectionData, AddInt32)
data.add("Int32", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Int32", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value, g_variant_get_int32(get_variant_child(variant, 1)));
}
@@ -120,9 +120,9 @@ TEST(TestIntrospectionData, AddInt64)
data.add("Int64", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Int64", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value, g_variant_get_int64(get_variant_child(variant, 1)));
}
@@ -133,9 +133,9 @@ TEST(TestIntrospectionData, AddUInt16)
data.add("Uint16", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Uint16", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value, g_variant_get_uint16(get_variant_child(variant, 1)));
}
@@ -146,9 +146,9 @@ TEST(TestIntrospectionData, AddUInt32)
data.add("Uint32", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Uint32", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value, g_variant_get_uint32(get_variant_child(variant, 1)));
}
@@ -159,9 +159,9 @@ TEST(TestIntrospectionData, AddUInt64)
data.add("Uint64", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Uint64", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value, g_variant_get_uint64(get_variant_child(variant, 1)));
}
@@ -172,9 +172,9 @@ TEST(TestIntrospectionData, AddFloat)
data.add("Float", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Float", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_FLOAT_EQ(value, g_variant_get_double(get_variant_child(variant, 1)));
}
@@ -185,9 +185,9 @@ TEST(TestIntrospectionData, AddDouble)
data.add("Double", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Double", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_DOUBLE_EQ(value, g_variant_get_double(get_variant_child(variant, 1)));
}
@@ -198,9 +198,9 @@ TEST(TestIntrospectionData, AddVariant)
data.add("Variant", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Variant", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_TRUE(g_variant_equal(value, get_variant_child(variant, 1)));
}
@@ -211,9 +211,9 @@ TEST(TestIntrospectionData, AddGlibVariant)
data.add("GLibVariant", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "GLibVariant", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(2, g_variant_n_children(variant));
+ ASSERT_EQ(2u, g_variant_n_children(variant));
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_TRUE(g_variant_equal(value, get_variant_child(variant, 1)));
}
@@ -224,9 +224,9 @@ TEST(TestIntrospectionData, AddRect)
data.add("Rect", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Rect", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(5, g_variant_n_children(variant));
+ ASSERT_EQ(5u, g_variant_n_children(variant));
- EXPECT_EQ(1, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(1u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value.x, g_variant_get_int32(get_variant_child(variant, 1)));
EXPECT_EQ(value.y, g_variant_get_int32(get_variant_child(variant, 2)));
EXPECT_EQ(value.width, g_variant_get_int32(get_variant_child(variant, 3)));
@@ -241,9 +241,9 @@ TEST(TestIntrospectionData, AddRectDefault)
GVariant* data_variant = data.Get();
GVariant* variant = g_variant_lookup_value(data_variant, "globalRect", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(5, g_variant_n_children(variant));
+ ASSERT_EQ(5u, g_variant_n_children(variant));
- EXPECT_EQ(1, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(1u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value.x, g_variant_get_int32(get_variant_child(variant, 1)));
EXPECT_EQ(value.y, g_variant_get_int32(get_variant_child(variant, 2)));
EXPECT_EQ(value.width, g_variant_get_int32(get_variant_child(variant, 3)));
@@ -251,22 +251,22 @@ TEST(TestIntrospectionData, AddRectDefault)
variant = g_variant_lookup_value(data_variant, "x", nullptr);
ASSERT_THAT(variant, NotNull());
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value.x, g_variant_get_int32(get_variant_child(variant, 1)));
variant = g_variant_lookup_value(data_variant, "y", nullptr);
ASSERT_THAT(variant, NotNull());
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value.y, g_variant_get_int32(get_variant_child(variant, 1)));
variant = g_variant_lookup_value(data_variant, "width", nullptr);
ASSERT_THAT(variant, NotNull());
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value.width, g_variant_get_int32(get_variant_child(variant, 1)));
variant = g_variant_lookup_value(data_variant, "height", nullptr);
ASSERT_THAT(variant, NotNull());
- EXPECT_EQ(0, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(0u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value.height, g_variant_get_int32(get_variant_child(variant, 1)));
}
@@ -277,9 +277,9 @@ TEST(TestIntrospectionData, AddPoint)
data.add("Point", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Point", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(3, g_variant_n_children(variant));
+ ASSERT_EQ(3u, g_variant_n_children(variant));
- EXPECT_EQ(2, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(2u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value.x, g_variant_get_int32(get_variant_child(variant, 1)));
EXPECT_EQ(value.y, g_variant_get_int32(get_variant_child(variant, 2)));
}
@@ -291,9 +291,9 @@ TEST(TestIntrospectionData, AddSize)
data.add("Size", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Size", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(3, g_variant_n_children(variant));
+ ASSERT_EQ(3u, g_variant_n_children(variant));
- EXPECT_EQ(3, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(3u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(value.width, g_variant_get_int32(get_variant_child(variant, 1)));
EXPECT_EQ(value.height, g_variant_get_int32(get_variant_child(variant, 2)));
}
@@ -305,9 +305,9 @@ TEST(TestIntrospectionData, AddColor)
data.add("Color", value);
GVariant* variant = g_variant_lookup_value(data.Get(), "Color", nullptr);
ASSERT_THAT(variant, NotNull());
- ASSERT_EQ(5, g_variant_n_children(variant));
+ ASSERT_EQ(5u, g_variant_n_children(variant));
- EXPECT_EQ(4, g_variant_get_uint32(get_variant_child(variant, 0)));
+ EXPECT_EQ(4u, g_variant_get_uint32(get_variant_child(variant, 0)));
EXPECT_EQ(static_cast<int32_t>(value.red * 255.), g_variant_get_int32(get_variant_child(variant, 1)));
EXPECT_EQ(static_cast<int32_t>(value.green * 255.), g_variant_get_int32(get_variant_child(variant, 2)));
EXPECT_EQ(static_cast<int32_t>(value.blue * 255.), g_variant_get_int32(get_variant_child(variant, 3)));
diff --git a/tests/test_keyboard_util.cpp b/tests/test_keyboard_util.cpp
index 4e315b140..f2645e580 100644
--- a/tests/test_keyboard_util.cpp
+++ b/tests/test_keyboard_util.cpp
@@ -66,6 +66,8 @@ TEST(TestKeyboardUtil, AboveKeySymbol)
ASSERT_NE(keyboard::get_key_above_key_symbol(x_display, XStringToKeysym("x")), NoSymbol);
ASSERT_NE(keyboard::get_key_above_key_symbol(x_display, XStringToKeysym("y")), NoSymbol);
ASSERT_NE(keyboard::get_key_above_key_symbol(x_display, XStringToKeysym("z")), NoSymbol);
+
+ XCloseDisplay(x_display);
}
TEST(TestKeyboardUtil, BelowKeySymbol)
@@ -97,6 +99,8 @@ TEST(TestKeyboardUtil, BelowKeySymbol)
ASSERT_NE(keyboard::get_key_below_key_symbol(x_display, XStringToKeysym("w")), NoSymbol);
ASSERT_NE(keyboard::get_key_below_key_symbol(x_display, XStringToKeysym("x")), NoSymbol);
ASSERT_NE(keyboard::get_key_below_key_symbol(x_display, XStringToKeysym("y")), NoSymbol);
+
+ XCloseDisplay(x_display);
}
TEST(TestKeyboardUtil, RightToKeySymbol)
@@ -134,6 +138,8 @@ TEST(TestKeyboardUtil, RightToKeySymbol)
ASSERT_NE(keyboard::get_key_right_to_key_symbol(x_display, XStringToKeysym("x")), NoSymbol);
ASSERT_NE(keyboard::get_key_right_to_key_symbol(x_display, XStringToKeysym("y")), NoSymbol);
ASSERT_NE(keyboard::get_key_right_to_key_symbol(x_display, XStringToKeysym("z")), NoSymbol);
+
+ XCloseDisplay(x_display);
}
TEST(TestKeyboardUtil, LeftToKeySymbol)
@@ -172,6 +178,8 @@ TEST(TestKeyboardUtil, LeftToKeySymbol)
ASSERT_NE(keyboard::get_key_left_to_key_symbol(x_display, XStringToKeysym("x")), NoSymbol);
ASSERT_NE(keyboard::get_key_left_to_key_symbol(x_display, XStringToKeysym("y")), NoSymbol);
ASSERT_NE(keyboard::get_key_left_to_key_symbol(x_display, XStringToKeysym("z")), NoSymbol);
+
+ XCloseDisplay(x_display);
}
TEST(TestKeyboardUtil, PrintableKeySymbols)
diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp
index 7faea517c..3c99ca414 100644
--- a/tests/test_launcher_controller.cpp
+++ b/tests/test_launcher_controller.cpp
@@ -25,6 +25,7 @@
#include "ExpoLauncherIcon.h"
#include "DesktopLauncherIcon.h"
#include "DesktopUtilities.h"
+#include "InputMonitor.h"
#include "MockableBaseWindow.h"
#include "MockLauncherIcon.h"
#include "BFBLauncherIcon.h"
@@ -270,6 +271,7 @@ protected:
for (auto const& icon : icons)
model->RemoveIcon(icon);
+
ASSERT_EQ(model->Size(), 0);
}
@@ -286,6 +288,7 @@ protected:
std::shared_ptr<helper::CaptureLogOutput> logger_output_;
MockUScreen uscreen;
panel::Style panel_style;
+ input::Monitor im_;
MockFavoriteStore favorite_store;
MockXdndManager::Ptr xdnd_manager_;
ui::EdgeBarrierController::Ptr edge_barriers_;
@@ -297,16 +300,16 @@ TEST_F(TestLauncherController, Construction)
{
EXPECT_NE(lc.options(), nullptr);
EXPECT_TRUE(lc.multiple_launchers());
- ASSERT_EQ(lc.launchers().size(), 1);
+ ASSERT_EQ(lc.launchers().size(), 1u);
EXPECT_EQ(lc.launcher().monitor(), 0);
ASSERT_EQ(lc.Impl()->parent_, &lc);
ASSERT_NE(lc.Impl()->model_, nullptr);
EXPECT_EQ(lc.Impl()->expo_icon_->GetIconType(), AbstractLauncherIcon::IconType::EXPO);
EXPECT_EQ(lc.Impl()->desktop_icon_->GetIconType(), AbstractLauncherIcon::IconType::DESKTOP);
EXPECT_GE(lc.Impl()->sort_priority_, AbstractLauncherIcon::DefaultPriority(AbstractLauncherIcon::IconType::APPLICATION));
- EXPECT_EQ(lc.Impl()->model_->GetSublist<BFBLauncherIcon>().size(), 1);
- EXPECT_EQ(lc.Impl()->model_->GetSublist<HudLauncherIcon>().size(), 1);
- EXPECT_EQ(lc.Impl()->model_->GetSublist<TrashLauncherIcon>().size(), 1);
+ EXPECT_EQ(lc.Impl()->model_->GetSublist<BFBLauncherIcon>().size(), 1u);
+ EXPECT_EQ(lc.Impl()->model_->GetSublist<HudLauncherIcon>().size(), 1u);
+ EXPECT_EQ(lc.Impl()->model_->GetSublist<TrashLauncherIcon>().size(), 1u);
EXPECT_FALSE(lc.Impl()->launcher_open);
EXPECT_FALSE(lc.Impl()->launcher_keynav);
EXPECT_FALSE(lc.Impl()->launcher_grabbed);
@@ -353,7 +356,7 @@ TEST_F(TestLauncherController, MultimonitorSingleLauncher)
for (unsigned i = 0; i < monitors::MAX; ++i)
{
uscreen.SetPrimary(i);
- ASSERT_EQ(lc.launchers().size(), 1);
+ ASSERT_EQ(lc.launchers().size(), 1u);
EXPECT_EQ(lc.launcher().monitor(), i);
}
}
@@ -364,7 +367,7 @@ TEST_F(TestLauncherController, MirroredMultimonitorSingleLauncherOnExternalMonit
lc.multiple_launchers = false;
uscreen.SetPrimary(1);
- ASSERT_EQ(lc.launchers().size(), 1);
+ ASSERT_EQ(lc.launchers().size(), 1u);
ASSERT_EQ(lc.launcher().monitor(), 0);
}
@@ -373,7 +376,7 @@ TEST_F(TestLauncherController, MultimonitorSwitchToMultipleLaunchers)
lc.multiple_launchers = false;
uscreen.SetupFakeMultiMonitor();
- ASSERT_EQ(lc.launchers().size(), 1);
+ ASSERT_EQ(lc.launchers().size(), 1u);
lc.multiple_launchers = true;
EXPECT_EQ(lc.launchers().size(), monitors::MAX);
@@ -388,7 +391,7 @@ TEST_F(TestLauncherController, MultimonitorSwitchToSingleLauncher)
ASSERT_EQ(lc.launchers().size(), monitors::MAX);
lc.multiple_launchers = false;
- EXPECT_EQ(lc.launchers().size(), 1);
+ EXPECT_EQ(lc.launchers().size(), 1u);
EXPECT_EQ(lc.launcher().monitor(), primary);
}
@@ -398,7 +401,7 @@ TEST_F(TestLauncherController, MultimonitorSwitchToSingleMonitor)
ASSERT_EQ(lc.launchers().size(), monitors::MAX);
uscreen.Reset();
- EXPECT_EQ(lc.launchers().size(), 1);
+ EXPECT_EQ(lc.launchers().size(), 1u);
EXPECT_EQ(lc.launcher().monitor(), 0);
}
@@ -417,7 +420,7 @@ TEST_F(TestLauncherController, MultimonitorRemoveMiddleMonitor)
TEST_F(TestLauncherController, SingleMonitorSwitchToMultimonitor)
{
- ASSERT_EQ(lc.launchers().size(), 1);
+ ASSERT_EQ(lc.launchers().size(), 1u);
uscreen.SetupFakeMultiMonitor();
diff --git a/tests/test_launcher_model.cpp b/tests/test_launcher_model.cpp
index 3f64b9fb7..ac3a3c0a6 100644
--- a/tests/test_launcher_model.cpp
+++ b/tests/test_launcher_model.cpp
@@ -52,28 +52,28 @@ public:
TEST_F(TestLauncherModel, Constructor)
{
- EXPECT_EQ(model.Size(), 0);
+ EXPECT_EQ(model.Size(), 0u);
}
TEST_F(TestLauncherModel, Add)
{
model.AddIcon(icon1);
- EXPECT_EQ(model.Size(), 1);
+ EXPECT_EQ(model.Size(), 1u);
model.AddIcon(icon1);
- EXPECT_EQ(model.Size(), 1);
+ EXPECT_EQ(model.Size(), 1u);
model.AddIcon(AbstractLauncherIcon::Ptr());
- EXPECT_EQ(model.Size(), 1);
+ EXPECT_EQ(model.Size(), 1u);
}
TEST_F(TestLauncherModel, Remove)
{
model.AddIcon(icon1);
- EXPECT_EQ(model.Size(), 1);
+ EXPECT_EQ(model.Size(), 1u);
model.RemoveIcon(icon1);
- EXPECT_EQ(model.Size(), 0);
+ EXPECT_EQ(model.Size(), 0u);
}
TEST_F(TestLauncherModel, AddSignal)
diff --git a/tests/test_layout_system.cpp b/tests/test_layout_system.cpp
index bd1f23c98..3a4e0928b 100644
--- a/tests/test_layout_system.cpp
+++ b/tests/test_layout_system.cpp
@@ -55,7 +55,7 @@ TEST_F(TestLayoutWindow, InitializationNormalWindow)
LayoutWindow lwin(xid);
EXPECT_EQ(lwin.xid, xid);
EXPECT_EQ(lwin.geo, fake_window->geo);
- EXPECT_EQ(lwin.decoration_height, 0);
+ EXPECT_EQ(lwin.decoration_height, 0u);
EXPECT_EQ(lwin.selected, false);
EXPECT_FLOAT_EQ(lwin.scale, 1.0f);
EXPECT_EQ(lwin.aspect_ratio, fake_window->geo().width / static_cast<float>(fake_window->geo().height));
@@ -70,7 +70,7 @@ TEST_F(TestLayoutWindow, InitializationMinimizedNormalWindow)
LayoutWindow lwin(xid);
EXPECT_EQ(lwin.xid, xid);
EXPECT_EQ(lwin.geo, fake_window->geo);
- EXPECT_EQ(lwin.decoration_height, 0);
+ EXPECT_EQ(lwin.decoration_height, 0u);
EXPECT_EQ(lwin.selected, false);
EXPECT_EQ(lwin.aspect_ratio, fake_window->geo().width / static_cast<float>(fake_window->geo().height));
}
@@ -84,7 +84,7 @@ TEST_F(TestLayoutWindow, InitializationMaximizedWindow)
LayoutWindow lwin(xid);
EXPECT_EQ(lwin.xid, xid);
EXPECT_EQ(lwin.geo, fake_window->geo);
- EXPECT_EQ(lwin.decoration_height, 0);
+ EXPECT_EQ(lwin.decoration_height, 0u);
EXPECT_EQ(lwin.selected, false);
EXPECT_EQ(lwin.aspect_ratio, fake_window->geo().width / static_cast<float>(fake_window->geo().height));
}
@@ -99,7 +99,7 @@ TEST_F(TestLayoutWindow, InitializationMinimizedMaximizedWindow)
LayoutWindow lwin(xid);
EXPECT_EQ(lwin.xid, xid);
EXPECT_EQ(lwin.geo, fake_window->geo);
- EXPECT_EQ(lwin.decoration_height, 0);
+ EXPECT_EQ(lwin.decoration_height, 0u);
EXPECT_EQ(lwin.selected, false);
EXPECT_EQ(lwin.aspect_ratio, fake_window->geo().width / static_cast<float>(fake_window->geo().height));
}
@@ -113,7 +113,7 @@ TEST_F(TestLayoutWindow, DecorationHeightNormalWindow)
lwin.ComputeDecorationHeight();
EXPECT_EQ(lwin.xid, xid);
EXPECT_EQ(lwin.geo, fake_window->geo);
- EXPECT_EQ(lwin.decoration_height, 0);
+ EXPECT_EQ(lwin.decoration_height, 0u);
EXPECT_EQ(lwin.selected, false);
EXPECT_FLOAT_EQ(lwin.scale, 1.0f);
EXPECT_EQ(lwin.aspect_ratio, fake_window->geo().width / static_cast<float>(fake_window->geo().height));
@@ -129,7 +129,7 @@ TEST_F(TestLayoutWindow, DecorationHeightMinimizedNormalWindow)
lwin.ComputeDecorationHeight();
EXPECT_EQ(lwin.xid, xid);
EXPECT_EQ(lwin.geo, fake_window->geo);
- EXPECT_EQ(lwin.decoration_height, 0);
+ EXPECT_EQ(lwin.decoration_height, 0u);
EXPECT_EQ(lwin.selected, false);
EXPECT_EQ(lwin.aspect_ratio, fake_window->geo().width / static_cast<float>(fake_window->geo().height));
}
@@ -163,7 +163,7 @@ TEST_F(TestLayoutWindow, DecorationHeightMinimizedMaximizedWindow)
LayoutWindow lwin(xid);
EXPECT_EQ(lwin.xid, xid);
EXPECT_EQ(lwin.geo, fake_window->geo);
- EXPECT_EQ(lwin.decoration_height, 0);
+ EXPECT_EQ(lwin.decoration_height, 0u);
EXPECT_EQ(lwin.selected, false);
EXPECT_EQ(lwin.aspect_ratio, fake_window->geo().width / static_cast<float>(fake_window->geo().height));
}
@@ -234,7 +234,7 @@ TEST_F(TestLayoutSystem, GetRowSizesEven)
ls.LayoutWindows(lwindows, max_bounds, final_bounds);
std::vector<int> const& row_sizes = ls.GetRowSizes(lwindows, max_bounds);
- EXPECT_EQ(row_sizes.size(), 2);
+ EXPECT_EQ(row_sizes.size(), 2u);
EXPECT_EQ(row_sizes[0], 2);
EXPECT_EQ(row_sizes[1], 2);
}
@@ -259,7 +259,7 @@ TEST_F(TestLayoutSystem, GetRowSizesUnEven)
ls.LayoutWindows(lwindows, max_bounds, final_bounds);
std::vector<int> const& row_sizes = ls.GetRowSizes(lwindows, max_bounds);
- EXPECT_EQ(row_sizes.size(), 2);
+ EXPECT_EQ(row_sizes.size(), 2u);
EXPECT_EQ(row_sizes[0], 2);
EXPECT_EQ(row_sizes[1], 3);
}
diff --git a/tests/test_lockscreen_controller.cpp b/tests/test_lockscreen_controller.cpp
index d1c5af5fa..9f054ed46 100644
--- a/tests/test_lockscreen_controller.cpp
+++ b/tests/test_lockscreen_controller.cpp
@@ -31,6 +31,7 @@ using namespace testing;
#include "lockscreen/LockScreenSettings.h"
#include "lockscreen/ScreenSaverDBusManager.h"
#include "unity-shared/DashStyle.h"
+#include "unity-shared/InputMonitor.h"
#include "unity-shared/PanelStyle.h"
#include "unity-shared/UScreen.h"
#include "mock_key_grabber.h"
@@ -55,7 +56,7 @@ const unsigned TICK_DURATION = 10 * 1000;
struct MockShield : BaseShield
{
MockShield()
- : BaseShield(nullptr, nullptr, nullptr, nux::ObjectPtr<AbstractUserPromptView>(), 0, false)
+ : BaseShield(nullptr, nullptr, nux::ObjectPtr<AbstractUserPromptView>(), 0, false)
{}
MOCK_CONST_METHOD0(IsIndicatorOpen, bool());
@@ -67,7 +68,7 @@ struct MockShield : BaseShield
struct ShieldFactoryMock : ShieldFactoryInterface
{
nux::ObjectPtr<BaseShield> CreateShield(session::Manager::Ptr const&,
- indicator::Indicators::Ptr const&,
+ menu::Manager::Ptr const&,
Accelerators::Ptr const&,
nux::ObjectPtr<AbstractUserPromptView> const&,
int, bool) override
@@ -83,9 +84,10 @@ struct TestLockScreenController : Test
, session_manager(std::make_shared<NiceMock<session::MockManager>>())
, key_grabber(std::make_shared<key::MockGrabber::Nice>())
, dbus_manager(std::make_shared<DBusManager>(session_manager))
+ , systemd_wrapper(std::make_shared<SystemdWrapper>())
, upstart_wrapper(std::make_shared<UpstartWrapper>())
, shield_factory(std::make_shared<ShieldFactoryMock>())
- , controller(dbus_manager, session_manager, key_grabber, upstart_wrapper, shield_factory)
+ , controller(dbus_manager, session_manager, key_grabber, systemd_wrapper, upstart_wrapper, shield_factory)
{}
struct ControllerWrap : Controller
@@ -93,9 +95,10 @@ struct TestLockScreenController : Test
ControllerWrap(DBusManager::Ptr const& dbus_manager,
session::Manager::Ptr const& session_manager,
key::Grabber::Ptr const& key_grabber,
+ SystemdWrapper::Ptr const& systemd_wrapper,
UpstartWrapper::Ptr const& upstart_wrapper,
ShieldFactoryInterface::Ptr const& shield_factory)
- : Controller(dbus_manager, session_manager, key_grabber, upstart_wrapper, shield_factory, /* test_mode */ true)
+ : Controller(dbus_manager, session_manager, key_grabber, systemd_wrapper, upstart_wrapper, shield_factory, /* test_mode */ true)
{}
using Controller::shields_;
@@ -106,12 +109,14 @@ struct TestLockScreenController : Test
nux::animation::AnimationController animation_controller;
MockUScreen uscreen;
+ unity::input::Monitor im;
unity::dash::Style dash_style;
unity::panel::Style panel_style;
unity::lockscreen::Settings lockscreen_settings;
session::MockManager::Ptr session_manager;
key::MockGrabber::Ptr key_grabber;
DBusManager::Ptr dbus_manager;
+ unity::SystemdWrapper::Ptr systemd_wrapper;
unity::UpstartWrapper::Ptr upstart_wrapper;
ShieldFactoryMock::Ptr shield_factory;
@@ -181,7 +186,7 @@ TEST_F(TestLockScreenController, SwitchToMultiMonitor)
session_manager->lock_requested.emit();
Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; });
- ASSERT_EQ(1, controller.shields_.size());
+ ASSERT_EQ(1u, controller.shields_.size());
Utils::WaitUntilMSec([this]{ return uscreen.GetMonitors().at(0) == controller.shields_.at(0)->GetGeometry(); });
EXPECT_EQ(uscreen.GetMonitors().at(0), controller.shields_.at(0)->GetGeometry());
@@ -211,7 +216,7 @@ TEST_F(TestLockScreenController, SwitchToSingleMonitor)
uscreen.Reset(/* emit_change */ true);
- ASSERT_EQ(1, controller.shields_.size());
+ ASSERT_EQ(1u, controller.shields_.size());
EXPECT_EQ(uscreen.GetMonitors().at(0), controller.shields_.at(0)->GetGeometry());
}
@@ -220,7 +225,7 @@ TEST_F(TestLockScreenController, UnlockScreenOnSingleMonitor)
session_manager->lock_requested.emit();
Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; });
- ASSERT_EQ(1, controller.shields_.size());
+ ASSERT_EQ(1u, controller.shields_.size());
session_manager->unlock_requested.emit();
tick_source.tick(ANIMATION_DURATION);
@@ -248,14 +253,14 @@ TEST_F(TestLockScreenController, ShieldHasGrabAfterBlank)
// Lock...
session_manager->lock_requested.emit();
Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; });
- ASSERT_EQ(1, controller.shields_.size());
+ ASSERT_EQ(1u, controller.shields_.size());
// ...and let the screen blank.
session_manager->presence_status_changed.emit(true);
tick_source.tick(BLANK_ANIMATION_DURATION);
ASSERT_TRUE(controller.blank_window_->GetOpacity() == 1.0);
- ASSERT_TRUE(controller.blank_window_->OwnsPointerGrab());
+ ASSERT_FALSE(controller.blank_window_->OwnsPointerGrab());
// Wake the screen
dbus_manager->simulate_activity.emit();
diff --git a/tests/test_mock_devices.h b/tests/test_mock_devices.h
index d429b569b..7dc0fcef4 100644
--- a/tests/test_mock_devices.h
+++ b/tests/test_mock_devices.h
@@ -101,7 +101,7 @@ struct MockDeviceNotificationDisplay : DeviceNotificationDisplay
typedef std::shared_ptr<MockDeviceNotificationDisplay> Ptr;
typedef testing::NiceMock<MockDeviceNotificationDisplay> Nice;
- MOCK_METHOD2(Display, void(std::string const& icon_name, std::string const& volume_name));
+ MOCK_METHOD1(Display, void(std::string const& volume_name));
};
} // anonymous namespace
diff --git a/tests/test_panel_controller.cpp b/tests/test_panel_controller.cpp
index eea0f2fe1..82da0c13e 100644
--- a/tests/test_panel_controller.cpp
+++ b/tests/test_panel_controller.cpp
@@ -19,6 +19,7 @@
#include <gmock/gmock.h>
+#include "InputMonitor.h"
#include "PanelController.h"
#include "PanelStyle.h"
#include "PanelView.h"
@@ -46,6 +47,7 @@ struct TestPanelController : public testing::Test
menu::MockManager::Ptr menus;
ui::EdgeBarrierController::Ptr edge_barriers;
launcher::Options::Ptr options;
+ input::Monitor im;
};
TEST_F(TestPanelController, Construction)
@@ -55,7 +57,7 @@ TEST_F(TestPanelController, Construction)
{
Controller pc(menus, edge_barriers);
- ASSERT_EQ(pc.panels().size(), 1);
+ ASSERT_EQ(pc.panels().size(), 1u);
EXPECT_EQ(pc.panels()[0]->GetMonitor(), 0);
panel_ptr = pc.panels()[0];
}
@@ -96,7 +98,7 @@ TEST_F(TestPanelController, MultimonitorSwitchToSingleMonitor)
ASSERT_EQ(pc.panels().size(), monitors::MAX);
uscreen.Reset();
- EXPECT_EQ(pc.panels().size(), 1);
+ EXPECT_EQ(pc.panels().size(), 1u);
EXPECT_EQ(pc.panels()[0]->GetMonitor(), 0);
}
}
@@ -125,7 +127,7 @@ TEST_F(TestPanelController, SingleMonitorSwitchToMultimonitor)
{
Controller pc(menus, edge_barriers);
- ASSERT_EQ(pc.panels().size(), 1);
+ ASSERT_EQ(pc.panels().size(), 1u);
uscreen.SetupFakeMultiMonitor();
EXPECT_EQ(pc.panels().size(), monitors::MAX);
diff --git a/tests/test_panel_indicator_entry_dropdown_view.cpp b/tests/test_panel_indicator_entry_dropdown_view.cpp
index 74e7cdb8a..d3acb6d01 100644
--- a/tests/test_panel_indicator_entry_dropdown_view.cpp
+++ b/tests/test_panel_indicator_entry_dropdown_view.cpp
@@ -97,12 +97,12 @@ TEST_F(TestPanelIndicatorEntryDropdownView, Push)
dropdown.Push(first_entry);
EXPECT_FALSE(dropdown.Empty());
- EXPECT_EQ(1, dropdown.Size());
+ EXPECT_EQ(1u, dropdown.Size());
EXPECT_TRUE(dropdown.IsVisible());
EXPECT_THAT(dropdown.Children(), Contains(first_entry));
EXPECT_EQ(first_entry, dropdown.Top());
- EXPECT_EQ(1, first_entry->GetEntry()->parents().size());
+ EXPECT_EQ(1u, first_entry->GetEntry()->parents().size());
EXPECT_THAT(first_entry->GetEntry()->parents(), Contains(dropdown.GetEntry()));
auto second_entry = BuildEntry("SecondEntry");
@@ -110,12 +110,12 @@ TEST_F(TestPanelIndicatorEntryDropdownView, Push)
dropdown.Push(second_entry);
EXPECT_FALSE(dropdown.Empty());
- EXPECT_EQ(2, dropdown.Size());
+ EXPECT_EQ(2u, dropdown.Size());
EXPECT_TRUE(dropdown.IsVisible());
EXPECT_THAT(dropdown.Children(), Contains(second_entry));
EXPECT_EQ(first_entry, dropdown.Top());
- EXPECT_EQ(1, second_entry->GetEntry()->parents().size());
+ EXPECT_EQ(1u, second_entry->GetEntry()->parents().size());
EXPECT_THAT(second_entry->GetEntry()->parents(), Contains(dropdown.GetEntry()));
}
@@ -127,12 +127,12 @@ TEST_F(TestPanelIndicatorEntryDropdownView, Insert)
dropdown.Insert(first_entry);
EXPECT_FALSE(dropdown.Empty());
- EXPECT_EQ(1, dropdown.Size());
+ EXPECT_EQ(1u, dropdown.Size());
EXPECT_TRUE(dropdown.IsVisible());
EXPECT_THAT(dropdown.Children(), Contains(first_entry));
EXPECT_EQ(first_entry, dropdown.Top());
- EXPECT_EQ(1, first_entry->GetEntry()->parents().size());
+ EXPECT_EQ(1u, first_entry->GetEntry()->parents().size());
EXPECT_THAT(first_entry->GetEntry()->parents(), Contains(dropdown.GetEntry()));
auto second_entry = BuildEntry("SecondEntry");
@@ -141,12 +141,12 @@ TEST_F(TestPanelIndicatorEntryDropdownView, Insert)
dropdown.Insert(second_entry);
EXPECT_FALSE(dropdown.Empty());
- EXPECT_EQ(2, dropdown.Size());
+ EXPECT_EQ(2u, dropdown.Size());
EXPECT_TRUE(dropdown.IsVisible());
EXPECT_THAT(dropdown.Children(), Contains(second_entry));
EXPECT_EQ(second_entry, dropdown.Top());
- EXPECT_EQ(1, second_entry->GetEntry()->parents().size());
+ EXPECT_EQ(1u, second_entry->GetEntry()->parents().size());
EXPECT_THAT(second_entry->GetEntry()->parents(), Contains(dropdown.GetEntry()));
}
@@ -161,7 +161,7 @@ TEST_F(TestPanelIndicatorEntryDropdownView, Remove)
EXPECT_CALL(sig_receiver, Refreshed(&dropdown)).Times(0);
dropdown.Remove(second_entry);
- EXPECT_EQ(1, dropdown.Size());
+ EXPECT_EQ(1u, dropdown.Size());
EXPECT_TRUE(dropdown.IsVisible());
EXPECT_THAT(dropdown.Children(), Not(Contains(second_entry)));
EXPECT_THAT(second_entry->GetEntry()->parents(), Not(Contains(dropdown.GetEntry())));
@@ -193,7 +193,7 @@ TEST_F(TestPanelIndicatorEntryDropdownView, Pop)
EXPECT_CALL(sig_receiver, Refreshed(&dropdown)).Times(0);
EXPECT_EQ(first_entry, dropdown.Pop());
- EXPECT_EQ(1, dropdown.Size());
+ EXPECT_EQ(1u, dropdown.Size());
EXPECT_TRUE(dropdown.IsVisible());
EXPECT_THAT(dropdown.Children(), Not(Contains(first_entry)));
EXPECT_THAT(first_entry->GetEntry()->parents(), Not(Contains(dropdown.GetEntry())));
diff --git a/tests/test_panel_view.cpp b/tests/test_panel_view.cpp
index 82fdf55b3..4eeb37993 100644
--- a/tests/test_panel_view.cpp
+++ b/tests/test_panel_view.cpp
@@ -25,6 +25,7 @@
#include "unity-shared/PanelStyle.h"
#include "unity-shared/UBusMessages.h"
#include "unity-shared/UBusWrapper.h"
+ #include "InputMonitor.h"
#include "mock_menu_manager.h"
#include "test_standalone_wm.h"
@@ -43,6 +44,7 @@ public:
nux::ObjectPtr<MockableBaseWindow> window_;
nux::ObjectPtr<PanelView> panel_view_;
testwrapper::StandaloneWM WM;
+ input::Monitor im;
TestPanelView()
: window_(new MockableBaseWindow())
diff --git a/tests/test_pointer_barrier.cpp b/tests/test_pointer_barrier.cpp
index fe49f34c6..ea2778b76 100644
--- a/tests/test_pointer_barrier.cpp
+++ b/tests/test_pointer_barrier.cpp
@@ -94,7 +94,7 @@ TEST(TestPointerBarrier, HandleHitNotifyEvents)
EXPECT_EQ(bev->x, ev.root_x);
EXPECT_EQ(bev->y, ev.root_y);
EXPECT_EQ(bev->velocity, 600 * pb->max_velocity_multiplier);
- EXPECT_EQ(bev->event_id, ev.eventid);
+ EXPECT_EQ(bev->event_id, static_cast<int>(ev.eventid));
}
});
@@ -120,7 +120,7 @@ TEST(TestPointerBarrier, HandleHitNotifyReleasedEvents)
EXPECT_EQ(bev->x, ev.root_x);
EXPECT_EQ(bev->y, ev.root_y);
EXPECT_GT(bev->velocity, 0);
- EXPECT_EQ(bev->event_id, ev.eventid);
+ EXPECT_EQ(bev->event_id, static_cast<int>(ev.eventid));
});
pb->released = true;
diff --git a/tests/test_previews.cpp b/tests/test_previews.cpp
index cd566f492..3c99a087e 100644
--- a/tests/test_previews.cpp
+++ b/tests/test_previews.cpp
@@ -106,7 +106,7 @@ TEST(TestPreviews, DeserializeGenericWithMeta)
auto actions = preview->GetActions();
auto info_hints = preview->GetInfoHints();
- EXPECT_EQ(actions.size(), 2);
+ EXPECT_EQ(actions.size(), 2u);
auto action1 = actions[0];
EXPECT_EQ(action1->id, "action1");
@@ -121,7 +121,7 @@ TEST(TestPreviews, DeserializeGenericWithMeta)
EXPECT_EQ(action2->icon_hint, "");
EXPECT_EQ(action2->extra_text, "Foo");
- EXPECT_EQ(info_hints.size(), 2);
+ EXPECT_EQ(info_hints.size(), 2u);
auto hint1 = info_hints[0];
EXPECT_EQ(hint1->id, "hint1");
EXPECT_EQ(hint1->display_name, "Hint 1");
diff --git a/tests/test_previews_application.cpp b/tests/test_previews_application.cpp
index d5a893d84..b0b8fe1ba 100644
--- a/tests/test_previews_application.cpp
+++ b/tests/test_previews_application.cpp
@@ -122,7 +122,7 @@ TEST_F(TestPreviewApplication, TestUIValues)
EXPECT_EQ(preview_view->copywrite_->GetText(), "Copywrite &amp; special char");
EXPECT_EQ(preview_view->app_rating_->GetRating(), 0.8f);
- EXPECT_EQ(preview_view->action_buttons_.size(), 2);
+ EXPECT_EQ(preview_view->action_buttons_.size(), 2u);
if (preview_view->action_buttons_.size() >= 2)
{
diff --git a/tests/test_previews_generic.cpp b/tests/test_previews_generic.cpp
index 06699a28c..c10c99e1a 100644
--- a/tests/test_previews_generic.cpp
+++ b/tests/test_previews_generic.cpp
@@ -105,7 +105,7 @@ TEST_F(TestPreviewGeneric, TestUIValues)
EXPECT_EQ(preview_view->subtitle_->GetText(), "Generic Subtitle &gt; special char");
EXPECT_EQ(preview_view->description_->GetText(), "Generic Desctiption &lt; special char");
- EXPECT_EQ(preview_view->action_buttons_.size(), 2);
+ EXPECT_EQ(preview_view->action_buttons_.size(), 2u);
if (preview_view->action_buttons_.size() >= 2)
{
diff --git a/tests/test_previews_movie.cpp b/tests/test_previews_movie.cpp
index 8d8221cff..ac3b7e1cb 100644
--- a/tests/test_previews_movie.cpp
+++ b/tests/test_previews_movie.cpp
@@ -116,7 +116,7 @@ TEST_F(TestPreviewMovie, TestUIValues)
EXPECT_EQ(preview_view->description_->GetText(), "Movie Desctiption &lt; special char");
EXPECT_EQ(preview_view->rating_->GetRating(), 0.8f);
- EXPECT_EQ(preview_view->action_buttons_.size(), 2);
+ EXPECT_EQ(preview_view->action_buttons_.size(), 2u);
if (preview_view->action_buttons_.size() >= 2)
{
diff --git a/tests/test_previews_music.cpp b/tests/test_previews_music.cpp
index 04df70066..4398ec292 100644
--- a/tests/test_previews_music.cpp
+++ b/tests/test_previews_music.cpp
@@ -107,7 +107,7 @@ TEST_F(TestPreviewMusic, TestUIValues)
EXPECT_EQ(preview_view->title_->GetText(), "Music Title &amp; special char");
EXPECT_EQ(preview_view->subtitle_->GetText(), "Music Subtitle &gt; special char");
- EXPECT_EQ(preview_view->action_buttons_.size(), 4);
+ EXPECT_EQ(preview_view->action_buttons_.size(), 4u);
if (preview_view->action_buttons_.size() >= 2)
{
diff --git a/tests/test_previews_social.cpp b/tests/test_previews_social.cpp
index 4c555555f..76b42e034 100644
--- a/tests/test_previews_social.cpp
+++ b/tests/test_previews_social.cpp
@@ -101,7 +101,7 @@ TEST_F(TestPreviewSocial, TestUIValues)
EXPECT_EQ(preview_view->title_->GetText(), "Social Title &amp; special char");
EXPECT_EQ(preview_view->subtitle_->GetText(), "Social Subtitle &gt; special char");
- EXPECT_EQ(preview_view->action_buttons_.size(), 2);
+ EXPECT_EQ(preview_view->action_buttons_.size(), 2u);
}
}
diff --git a/tests/test_quicklist_view.cpp b/tests/test_quicklist_view.cpp
index 908cb50bc..946ea0f25 100644
--- a/tests/test_quicklist_view.cpp
+++ b/tests/test_quicklist_view.cpp
@@ -110,7 +110,7 @@ TEST_F(TestQuicklistView, AddItems)
AddMenuItems(root);
- ASSERT_EQ(quicklist->GetChildren().size(), 4);
+ ASSERT_EQ(quicklist->GetChildren().size(), 4u);
ASSERT_EQ(quicklist->GetNumItems(), 4);
EXPECT_EQ(quicklist->GetNthType(0), unity::QuicklistMenuItemType::LABEL);
EXPECT_EQ(quicklist->GetNthType(1), unity::QuicklistMenuItemType::SEPARATOR);
diff --git a/tests/test_results.cpp b/tests/test_results.cpp
index 428c46d22..a27278614 100644
--- a/tests/test_results.cpp
+++ b/tests/test_results.cpp
@@ -41,7 +41,7 @@ TEST_F(TestResults, TestSignalProxyAdded)
Result res(nullptr, nullptr, nullptr);
bool added = false;
- ASSERT_EQ(model.row_added.size(), 1);
+ ASSERT_EQ(model.row_added.size(), 1u);
model.result_added.connect([&added] (Result const&) { added = true; });
model.row_added.emit(res);
EXPECT_TRUE(added);
@@ -52,7 +52,7 @@ TEST_F(TestResults, TestSignalProxyChanged)
Result res(nullptr, nullptr, nullptr);
bool changed = false;
- ASSERT_EQ(model.row_changed.size(), 1);
+ ASSERT_EQ(model.row_changed.size(), 1u);
model.result_changed.connect([&changed] (Result const&) { changed = true; });
model.row_changed.emit(res);
EXPECT_TRUE(changed);
@@ -63,7 +63,7 @@ TEST_F(TestResults, TestSignalProxyRemoved)
Result res(nullptr, nullptr, nullptr);
bool removed = false;
- ASSERT_EQ(model.row_removed.size(), 1);
+ ASSERT_EQ(model.row_removed.size(), 1u);
model.result_removed.connect([&removed] (Result const&) { removed = true; });
model.row_removed.emit(res);
EXPECT_TRUE(removed);
@@ -83,15 +83,15 @@ TEST_F(TestResults, TestFilterValid)
dee_filter_new_for_any_column(2, g_variant_new_uint32(1), &filter);
glib::Object<DeeModel> filter_model(dee_filter_model_new(model.model(), &filter));
-
+
unsigned int i = 0;
for (ResultIterator iter(filter_model); !iter.IsLast(); ++iter)
{
- EXPECT_EQ((*iter).category_index(), 1);
+ EXPECT_EQ((*iter).category_index(), 1u);
i++;
}
- EXPECT_EQ(i, 50);
+ EXPECT_EQ(i, 50u);
}
TEST_F(TestResults, TestRowsValid)
@@ -108,7 +108,7 @@ TEST_F(TestResults, TestRowsValid)
EXPECT_EQ(result.uri(), value);
EXPECT_EQ(result.icon_hint(), value);
EXPECT_EQ(result.category_index(), (i / 50));
- EXPECT_EQ(result.result_type(), 0);
+ EXPECT_EQ(result.result_type(), 0u);
EXPECT_EQ(result.mimetype(), value);
EXPECT_EQ(result.name(), value);
EXPECT_EQ(result.comment(), value);
@@ -287,8 +287,8 @@ TEST_F(TestResults, LocalResult_FromToVariant)
EXPECT_EQ(local_result_2.uri, "uri");
EXPECT_EQ(local_result_2.icon_hint, "icon_hint");
- EXPECT_EQ(local_result_2.category_index, 1);
- EXPECT_EQ(local_result_2.result_type, 2);
+ EXPECT_EQ(local_result_2.category_index, 1u);
+ EXPECT_EQ(local_result_2.result_type, 2u);
EXPECT_EQ(local_result_2.mimetype, "mimetype");
EXPECT_EQ(local_result_2.name, "name");
EXPECT_EQ(local_result_2.comment, "comment");
@@ -315,7 +315,7 @@ TEST_F(TestResults, LocalResult_FromToVariant)
TEST_F(TestResults, LocalResult_Variants)
{
LocalResult local_result;
- EXPECT_EQ(local_result.Variants().size(), 9);
+ EXPECT_EQ(local_result.Variants().size(), 9u);
}
}
diff --git a/tests/test_scope.cpp b/tests/test_scope.cpp
index ce2c20c46..7d014055b 100644
--- a/tests/test_scope.cpp
+++ b/tests/test_scope.cpp
@@ -258,9 +258,9 @@ TEST_F(TestScope, UpdateSearchCategoryWorkflow)
ASSERT_THAT(category_model1, NotNull());
ASSERT_THAT(category_model2, NotNull());
- EXPECT_EQ(category_model0->count(), 5) << "Category 0 result count not as expected (" << category_model0->count() << " != 5)";
- EXPECT_EQ(category_model1->count(), 4) << "Category 1 result count not as expected (" << category_model1->count() << " != 4)";
- EXPECT_EQ(category_model2->count(), 4) << "Category 2 result count not as expected (" << category_model2->count() << " != 4)";
+ EXPECT_EQ(category_model0->count(), 5u) << "Category 0 result count not as expected (" << category_model0->count() << " != 5)";
+ EXPECT_EQ(category_model1->count(), 4u) << "Category 1 result count not as expected (" << category_model1->count() << " != 4)";
+ EXPECT_EQ(category_model2->count(), 4u) << "Category 2 result count not as expected (" << category_model2->count() << " != 4)";
// 2. Update the filter.
CheckOptionFilter::Ptr type_filter = std::static_pointer_cast<CheckOptionFilter>(WaitForFilter("categories"));
@@ -287,9 +287,9 @@ TEST_F(TestScope, UpdateSearchCategoryWorkflow)
category_model1 = scope_->GetResultsForCategory(1);
category_model2 = scope_->GetResultsForCategory(2);
- EXPECT_EQ(category_model0->count(), 0) << "Category 0 result count not as expected (" << category_model0->count() << " != 0)";
- EXPECT_EQ(category_model1->count(), 4) << "Category 1 result count not as expected (" << category_model1->count() << " != 4)";
- EXPECT_EQ(category_model2->count(), 0) << "Category 2 result count not as expected (" << category_model2->count() << " != 0)";
+ EXPECT_EQ(category_model0->count(), 0u) << "Category 0 result count not as expected (" << category_model0->count() << " != 0)";
+ EXPECT_EQ(category_model1->count(), 4u) << "Category 1 result count not as expected (" << category_model1->count() << " != 4)";
+ EXPECT_EQ(category_model2->count(), 0u) << "Category 2 result count not as expected (" << category_model2->count() << " != 0)";
}
} // namespace dash
diff --git a/tests/test_scope_view.cpp b/tests/test_scope_view.cpp
index 124059584..c9090ce7e 100644
--- a/tests/test_scope_view.cpp
+++ b/tests/test_scope_view.cpp
@@ -87,14 +87,14 @@ TEST_F(TestScopeView, TestCategoryInsert)
MockCategories::Ptr categories = std::make_shared<MockCategories>(2);
scope_->categories.changed.emit(categories);
Utils::WaitUntilMSec([this] { return scope_view_->GetOrderedCategoryViews().size() == 2; });
- ASSERT_EQ(scope_view_->GetOrderedCategoryViews().size(), 2);
+ ASSERT_EQ(scope_view_->GetOrderedCategoryViews().size(), 2u);
}
TEST_F(TestScopeView, TestFilterExpansion)
{
MockCategories::Ptr categories = std::make_shared<MockCategories>(4);
scope_->categories.changed.emit(categories);
- ASSERT_EQ(scope_view_->fake_groups_.size(), 4);
+ ASSERT_EQ(scope_view_->fake_groups_.size(), 4u);
scope_view_->filters_expanded = true;
for (unsigned i = 0; i < scope_view_->fake_groups_.size(); ++i)
@@ -107,7 +107,7 @@ TEST_F(TestScopeView, TestCategoryExpansion_OneCategory_EmptySearchString)
scope_view_->search_string_ = "";
scope_->categories.changed.emit(categories);
- ASSERT_EQ(scope_view_->fake_groups_.size(), 1);
+ ASSERT_EQ(scope_view_->fake_groups_.size(), 1u);
Utils::WaitPendingEvents();
Utils::WaitUntilMSec([this] () { return scope_view_->fake_groups_[0]->GetExpanded(); });
}
@@ -118,7 +118,7 @@ TEST_F(TestScopeView, TestCategoryExpansion_OneCategory_FilledSearchString)
scope_view_->search_string_ = "Ubuntu";
scope_->categories.changed.emit(categories);
- ASSERT_EQ(scope_view_->fake_groups_.size(), 1);
+ ASSERT_EQ(scope_view_->fake_groups_.size(), 1u);
Utils::WaitPendingEvents();
Utils::WaitUntilMSec([this] () { return scope_view_->fake_groups_[0]->GetExpanded(); });
}
@@ -129,7 +129,7 @@ TEST_F(TestScopeView, TestCategoryExpansion_TwoCategory_EmptySearchString)
scope_view_->search_string_ = "";
scope_->categories.changed.emit(categories);
- ASSERT_EQ(scope_view_->fake_groups_.size(), 2);
+ ASSERT_EQ(scope_view_->fake_groups_.size(), 2u);
Utils::WaitPendingEvents();
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[0]->GetExpanded(); });
Utils::WaitUntilMSec([this] () { return scope_view_->fake_groups_[1]->GetExpanded(); });
@@ -141,7 +141,7 @@ TEST_F(TestScopeView, TestCategoryExpansion_TwoCategory_FilledSearchString)
scope_view_->search_string_ = "Ubuntu";
scope_->categories.changed.emit(categories);
- ASSERT_EQ(scope_view_->fake_groups_.size(), 2);
+ ASSERT_EQ(scope_view_->fake_groups_.size(), 2u);
Utils::WaitPendingEvents();
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[0]->GetExpanded(); });
Utils::WaitUntilMSec([this] () { return scope_view_->fake_groups_[1]->GetExpanded(); });
@@ -153,7 +153,7 @@ TEST_F(TestScopeView, TestCategoryExpansion_ThreeCategory_EmptySearchString)
scope_view_->search_string_ = "";
scope_->categories.changed.emit(categories);
- ASSERT_EQ(scope_view_->fake_groups_.size(), 3);
+ ASSERT_EQ(scope_view_->fake_groups_.size(), 3u);
Utils::WaitPendingEvents();
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[0]->GetExpanded(); });
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[1]->GetExpanded(); });
@@ -166,7 +166,7 @@ TEST_F(TestScopeView, TestCategoryExpansion_ThreeCategory_FilledSearchString)
scope_view_->search_string_ = "Ubuntu";
scope_->categories.changed.emit(categories);
- ASSERT_EQ(scope_view_->fake_groups_.size(), 3);
+ ASSERT_EQ(scope_view_->fake_groups_.size(), 3u);
Utils::WaitPendingEvents();
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[0]->GetExpanded(); });
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[1]->GetExpanded(); });
@@ -178,7 +178,7 @@ TEST_F(TestScopeView, TestCategoryExpansion_TwoCategory_OnResultAdded_EmptySearc
MockCategories::Ptr categories = std::make_shared<MockCategories>(2);
scope_->categories.changed.emit(categories);
- ASSERT_EQ(scope_view_->fake_groups_.size(), 2);
+ ASSERT_EQ(scope_view_->fake_groups_.size(), 2u);
Utils::WaitPendingEvents();
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[0]->GetExpanded(); });
Utils::WaitUntilMSec([this] () { return scope_view_->fake_groups_[1]->GetExpanded(); });
@@ -202,7 +202,7 @@ TEST_F(TestScopeView, TestCategoryExpansion_TwoCategory_OnResultAdded_FilledSear
scope_view_->search_string_ = "Ubuntu";
scope_->categories.changed.emit(categories);
- ASSERT_EQ(scope_view_->fake_groups_.size(), 2);
+ ASSERT_EQ(scope_view_->fake_groups_.size(), 2u);
Utils::WaitPendingEvents();
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[0]->GetExpanded(); });
Utils::WaitUntilMSec([this] () { return scope_view_->fake_groups_[1]->GetExpanded(); });
@@ -225,7 +225,7 @@ TEST_F(TestScopeView, TestCategoryExpansion_ThreeCategory_OnResultAdded_EmptySea
MockCategories::Ptr categories = std::make_shared<MockCategories>(3);
scope_->categories.changed.emit(categories);
- ASSERT_EQ(scope_view_->fake_groups_.size(), 3);
+ ASSERT_EQ(scope_view_->fake_groups_.size(), 3u);
Utils::WaitPendingEvents();
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[0]->GetExpanded(); });
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[1]->GetExpanded(); });
@@ -257,7 +257,7 @@ TEST_F(TestScopeView, TestCategoryExpansion_ThreeCategory_OnResultAdded_FilledSe
scope_view_->search_string_ = "Ubuntu";
scope_->categories.changed.emit(categories);
- ASSERT_EQ(scope_view_->fake_groups_.size(), 3);
+ ASSERT_EQ(scope_view_->fake_groups_.size(), 3u);
Utils::WaitPendingEvents();
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[0]->GetExpanded(); });
Utils::WaitUntilMSec([this] () { return not scope_view_->fake_groups_[1]->GetExpanded(); });
diff --git a/tests/test_session_view.cpp b/tests/test_session_view.cpp
index 4d40dd7ab..e8082b799 100644
--- a/tests/test_session_view.cpp
+++ b/tests/test_session_view.cpp
@@ -179,7 +179,7 @@ TEST_F(TestSessionView, ShutdownModeButtons)
ON_CALL(*manager, CanShutdown()).WillByDefault(testing::Return(true));
view.mode = View::Mode::SHUTDOWN;
- EXPECT_EQ(view.GetButtons().size(), 2);
+ EXPECT_EQ(view.GetButtons().size(), 2u);
EXPECT_EQ(view.GetButtonPosition(Button::Action::REBOOT), 0);
EXPECT_EQ(view.GetButtonPosition(Button::Action::SHUTDOWN), 1);
EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::SHUTDOWN));
@@ -190,7 +190,7 @@ TEST_F(TestSessionView, LogoutModeButtons)
ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(true));
view.mode = View::Mode::LOGOUT;
- EXPECT_EQ(view.GetButtons().size(), 2);
+ EXPECT_EQ(view.GetButtons().size(), 2u);
EXPECT_EQ(view.GetButtonPosition(Button::Action::LOCK), 0);
EXPECT_EQ(view.GetButtonPosition(Button::Action::LOGOUT), 1);
EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::LOGOUT));
@@ -201,7 +201,7 @@ TEST_F(TestSessionView, LogoutLightModeButtons)
ON_CALL(*manager, CanLock()).WillByDefault(testing::Return(false));
view.mode = View::Mode::LOGOUT;
- EXPECT_EQ(view.GetButtons().size(), 1);
+ EXPECT_EQ(view.GetButtons().size(), 1u);
EXPECT_EQ(view.GetButtonPosition(Button::Action::LOGOUT), 0);
EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::LOGOUT));
}
@@ -314,4 +314,4 @@ TEST_F(TestSessionView, RebootButtonActivateReboots)
}
} // session
-} // unity \ No newline at end of file
+} // unity
diff --git a/tests/test_shortcut_model.cpp b/tests/test_shortcut_model.cpp
index 6cbf52e85..f3410b9fe 100644
--- a/tests/test_shortcut_model.cpp
+++ b/tests/test_shortcut_model.cpp
@@ -40,10 +40,10 @@ TEST(TestShortcutModel, TestConstruction)
Model model(hints);
EXPECT_EQ(model.categories_per_column(), 3);
- EXPECT_EQ(model.categories().size(), 3);
- EXPECT_EQ(model.hints().at("Launcher").size(), 2);
- EXPECT_EQ(model.hints().at("Dash").size(), 1);
- EXPECT_EQ(model.hints().at("Menu Bar").size(), 1);
+ EXPECT_EQ(model.categories().size(), 3u);
+ EXPECT_EQ(model.hints().at("Launcher").size(), 2u);
+ EXPECT_EQ(model.hints().at("Dash").size(), 1u);
+ EXPECT_EQ(model.hints().at("Menu Bar").size(), 1u);
EXPECT_EQ(model.hints().find("Unity"), model.hints().end());
}
diff --git a/tests/test_shortcut_view.cpp b/tests/test_shortcut_view.cpp
index e4cee114f..1fcb782be 100644
--- a/tests/test_shortcut_view.cpp
+++ b/tests/test_shortcut_view.cpp
@@ -85,7 +85,7 @@ TEST_F(TestShortcutView, SettingModelAddsColumns)
model->categories_per_column = 1;
view.SetModel(model);
- EXPECT_EQ(view.columns_layout_->GetChildren().size(), 2);
+ EXPECT_EQ(view.columns_layout_->GetChildren().size(), 2u);
}
TEST_F(TestShortcutView, SettingModelRebuildsColumns)
@@ -93,12 +93,12 @@ TEST_F(TestShortcutView, SettingModelRebuildsColumns)
auto model1 = GetMockModel({"Cat1", "Cat2"}, 1);
model1->categories_per_column = 1;
view.SetModel(model1);
- ASSERT_EQ(view.columns_layout_->GetChildren().size(), 2);
+ ASSERT_EQ(view.columns_layout_->GetChildren().size(), 2u);
auto model2 = GetMockModel({"Cat1"}, 1);
model2->categories_per_column = 1;
view.SetModel(model2);
- EXPECT_EQ(view.columns_layout_->GetChildren().size(), 1);
+ EXPECT_EQ(view.columns_layout_->GetChildren().size(), 1u);
}
TEST_F(TestShortcutView, ChangingModelParametersRebuildsColumns)
diff --git a/tests/test_switcher_controller_slow.cpp b/tests/test_switcher_controller_slow.cpp
index 58deb59c9..47c5de900 100644
--- a/tests/test_switcher_controller_slow.cpp
+++ b/tests/test_switcher_controller_slow.cpp
@@ -39,7 +39,7 @@ TEST_F(TestSwitcherController, InitialDetailTimeout)
controller_->Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, icons_);
Selection selection = controller_->GetCurrentSelection();
EXPECT_EQ(selection.application_->tooltip_text(), "Second");
- EXPECT_EQ(selection.window_, 0);
+ EXPECT_EQ(selection.window_, 0u);
Utils::WaitForTimeoutMSec(initial_details_timeout * 1.1);
selection = controller_->GetCurrentSelection();
@@ -65,22 +65,22 @@ TEST_F(TestSwitcherController, DetailTimeoutRemoval)
controller_->Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, icons_);
Selection selection = controller_->GetCurrentSelection();
EXPECT_EQ(selection.application_->tooltip_text(), "Second");
- EXPECT_EQ(selection.window_, 0);
+ EXPECT_EQ(selection.window_, 0u);
controller_->Next();
selection = controller_->GetCurrentSelection();
ASSERT_EQ(selection.application_->tooltip_text(), "Third");
- EXPECT_EQ(selection.window_, 0);
+ EXPECT_EQ(selection.window_, 0u);
controller_->Next();
selection = controller_->GetCurrentSelection();
ASSERT_EQ(selection.application_->tooltip_text(), "Show Desktop");
- EXPECT_EQ(selection.window_, 0);
+ EXPECT_EQ(selection.window_, 0u);
controller_->Next();
selection = controller_->GetCurrentSelection();
ASSERT_EQ(selection.application_->tooltip_text(), "First");
- EXPECT_EQ(selection.window_, 0);
+ EXPECT_EQ(selection.window_, 0u);
Utils::WaitForTimeoutMSec(details_timeout * 1.1);
selection = controller_->GetCurrentSelection();
diff --git a/tests/test_systemd_wrapper.cpp b/tests/test_systemd_wrapper.cpp
new file mode 100644
index 000000000..30d5f9f76
--- /dev/null
+++ b/tests/test_systemd_wrapper.cpp
@@ -0,0 +1,110 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+* Copyright (c) 2016 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 <http://www.gnu.org/licenses/>.
+*
+* Authored by: Ted Gould <ted@canonical.com>
+*/
+
+#include <gtest/gtest.h>
+using namespace testing;
+
+#include "unity-shared/SystemdWrapper.h"
+
+#include <UnityCore/GLibDBusServer.h>
+#include <UnityCore/Variant.h>
+
+#include "test_utils.h"
+
+namespace
+{
+
+const std::string SYSTEMD =
+R"(<node>
+ <interface name="org.freedesktop.systemd1.Manager">
+ <method name="StartUnit">
+ <arg name="name" type="s" direction="in" />
+ <arg name="mode" type="s" direction="in" />
+ <arg name="job" type="o" direction="out" />
+ </method>
+ <method name="StopUnit">
+ <arg name="name" type="s" direction="in" />
+ <arg name="mode" type="s" direction="in" />
+ <arg name="job" type="o" direction="out" />
+ </method>
+ </interface>
+</node>)";
+
+struct MockSystemdWrapper : unity::SystemdWrapper {
+ MockSystemdWrapper()
+ : SystemdWrapper(SystemdWrapper::TestMode())
+ {}
+};
+
+struct TestSystemdWrapper : public Test
+{
+ TestSystemdWrapper()
+ {
+ systemd_server_ = std::make_shared<unity::glib::DBusServer>("com.canonical.Unity.Test.Systemd");
+ systemd_server_->AddObjects(SYSTEMD, "/org/freedesktop/systemd1");
+
+ Utils::WaitUntilMSec([this] { return systemd_server_->IsConnected(); });
+ }
+
+ unity::glib::DBusServer::Ptr systemd_server_;
+ MockSystemdWrapper systemd_wrapper_;
+};
+
+
+TEST_F(TestSystemdWrapper, Start)
+{
+ bool start_sent = false;
+
+ systemd_server_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant* par) -> GVariant* {
+ if (method == "StartUnit")
+ {
+ start_sent = true;
+
+ std::string event_name = glib::Variant(g_variant_get_child_value(par, 0)).GetString();
+ EXPECT_EQ("unity-screen-locked", event_name);
+ }
+
+ return nullptr;
+ });
+
+ systemd_wrapper_.Start("unity-screen-locked");
+ Utils::WaitUntil(start_sent);
+}
+
+TEST_F(TestSystemdWrapper, Stop)
+{
+ bool stop_sent = false;
+
+ systemd_server_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant* par) -> GVariant* {
+ if (method == "StopUnit")
+ {
+ stop_sent = true;
+
+ std::string event_name = glib::Variant(g_variant_get_child_value(par, 0)).GetString();
+ EXPECT_EQ("unity-screen-locked", event_name);
+ }
+
+ return nullptr;
+ });
+
+ systemd_wrapper_.Stop("unity-screen-locked");
+ Utils::WaitUntil(stop_sent);
+}
+
+}
diff --git a/tests/test_texture_cache.cpp b/tests/test_texture_cache.cpp
index 99093931e..49e665f7a 100644
--- a/tests/test_texture_cache.cpp
+++ b/tests/test_texture_cache.cpp
@@ -126,11 +126,11 @@ TEST(TestTextureCache, Invalidate)
TextureCache& cache = TextureCache::GetDefault();
nux::ObjectPtr<nux::BaseTexture> t1 = cache.FindTexture("foo", 5, 7, callback);
cache.Invalidate("foo", 5, 7);
- ASSERT_EQ(0, cache.Size());
+ ASSERT_EQ(0u, cache.Size());
nux::ObjectPtr<nux::BaseTexture> t2 = cache.FindTexture("foo", 5, 7, callback);
EXPECT_NE(t1, t2);
- EXPECT_EQ(1, cache.Size());
+ EXPECT_EQ(1u, cache.Size());
EXPECT_EQ(2, counter.count);
}
diff --git a/tests/test_trash_launcher_icon.cpp b/tests/test_trash_launcher_icon.cpp
index d8a5b6162..58690c53f 100644
--- a/tests/test_trash_launcher_icon.cpp
+++ b/tests/test_trash_launcher_icon.cpp
@@ -65,13 +65,13 @@ TEST_F(TestTrashLauncherIcon, Activate)
TEST_F(TestTrashLauncherIcon, Quicklist)
{
auto const& menus = icon.Menus();
- EXPECT_EQ(menus.size(), 1);
+ EXPECT_EQ(menus.size(), 1u);
}
TEST_F(TestTrashLauncherIcon, QuicklistEmptyTrash)
{
auto const& menus = icon.Menus();
- ASSERT_EQ(menus.size(), 1);
+ ASSERT_EQ(menus.size(), 1u);
auto const& empty_trash_menu = menus.front();
@@ -145,12 +145,12 @@ TEST_F(TestTrashLauncherIcon, WindowsOnMonitorChanges)
ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(WindowList({win})));
fm_->locations_changed.emit();
- EXPECT_EQ(icon.WindowsVisibleOnMonitor(0), 1);
- EXPECT_EQ(icon.WindowsVisibleOnMonitor(1), 0);
+ EXPECT_EQ(icon.WindowsVisibleOnMonitor(0), 1u);
+ EXPECT_EQ(icon.WindowsVisibleOnMonitor(1), 0u);
win->SetMonitor(1);
- EXPECT_EQ(icon.WindowsVisibleOnMonitor(0), 0);
- EXPECT_EQ(icon.WindowsVisibleOnMonitor(1), 1);
+ EXPECT_EQ(icon.WindowsVisibleOnMonitor(0), 0u);
+ EXPECT_EQ(icon.WindowsVisibleOnMonitor(1), 1u);
}
TEST_F(TestTrashLauncherIcon, FilemanagerSignalDisconnection)
diff --git a/tests/test_ubus.cpp b/tests/test_ubus.cpp
index 1ca4b89a4..a3148ea86 100644
--- a/tests/test_ubus.cpp
+++ b/tests/test_ubus.cpp
@@ -114,7 +114,7 @@ TEST_F(TestUBusServer, SingleDispatch)
ProcessMessages();
EXPECT_TRUE(callback_called);
- EXPECT_EQ(callback_call_count, 1);
+ EXPECT_EQ(callback_call_count, 1u);
}
TEST_F(TestUBusServer, SingleDispatchWithData)
@@ -125,7 +125,7 @@ TEST_F(TestUBusServer, SingleDispatchWithData)
ProcessMessages();
EXPECT_TRUE(callback_called);
- EXPECT_EQ(callback_call_count, 1);
+ EXPECT_EQ(callback_call_count, 1u);
EXPECT_EQ(last_msg_variant.GetString(), "UserData");
}
@@ -137,7 +137,7 @@ TEST_F(TestUBusServer, SingleDispatchUnicode)
ProcessMessages();
EXPECT_TRUE(callback_called);
- EXPECT_EQ(callback_call_count, 1);
+ EXPECT_EQ(callback_call_count, 1u);
}
TEST_F(TestUBusServer, SendUnregisteredMessage)
@@ -166,7 +166,7 @@ TEST_F(TestUBusServer, MultipleDispatches)
ProcessMessages();
EXPECT_TRUE(callback_called);
- EXPECT_EQ(callback_call_count, 3);
+ EXPECT_EQ(callback_call_count, 3u);
}
TEST_F(TestUBusServer, MultipleDispatchesWithData)
@@ -253,7 +253,7 @@ TEST_F(TestUBusManager, RegisterAndSend)
ProcessMessages();
EXPECT_TRUE(callback_called);
- EXPECT_EQ(callback_call_count, 1);
+ EXPECT_EQ(callback_call_count, 1u);
}
TEST_F(TestUBusManager, Unregister)
@@ -301,7 +301,7 @@ TEST_F(TestUBusManager, UnregisterInsideCallback)
ProcessMessages();
EXPECT_TRUE(callback_called);
- EXPECT_EQ(callback_call_count, 1);
+ EXPECT_EQ(callback_call_count, 1u);
}
TEST_F(TestUBusManager, DispatchWithPriority)
diff --git a/tests/test_unity_window_style.cpp b/tests/test_unity_window_style.cpp
index 39f9772fa..3356ffe40 100644
--- a/tests/test_unity_window_style.cpp
+++ b/tests/test_unity_window_style.cpp
@@ -34,10 +34,10 @@ TEST(TestUnityWindowStyle, Get)
auto style_copy = UnityWindowStyle::Get();
ASSERT_EQ(style, style_copy);
- EXPECT_EQ(style.use_count(), 2);
+ EXPECT_EQ(style.use_count(), 2u);
}
- EXPECT_EQ(style.use_count(), 1);
+ EXPECT_EQ(style.use_count(), 1u);
}
-} \ No newline at end of file
+}
diff --git a/tests/test_unity_window_view.cpp b/tests/test_unity_window_view.cpp
index 9b49c9573..e5b0b06ce 100644
--- a/tests/test_unity_window_view.cpp
+++ b/tests/test_unity_window_view.cpp
@@ -82,12 +82,18 @@ TEST_F(TestUnityWindowView, Closable)
view.closable = true;
ASSERT_NE(view.close_button_, nullptr);
+ auto weak_ptr = nux::ObjectWeakPtr<IconTexture>(view.close_button_);
+ ASSERT_TRUE(weak_ptr.IsValid());
+
EXPECT_EQ(view.close_button_->texture(), view.style()->GetTexture(view.scale, WindowTextureType::CLOSE_ICON));
EXPECT_EQ(view.close_button_->GetParentObject(), &view);
int padding = view.style()->GetCloseButtonPadding().CP(view.scale);
EXPECT_EQ(view.close_button_->GetBaseX(), padding);
EXPECT_EQ(view.close_button_->GetBaseY(), padding);
+
+ view.closable = false;
+ ASSERT_FALSE(weak_ptr.IsValid());
}
TEST_F(TestUnityWindowView, CloseButtonStates)
diff --git a/tests/test_volume_launcher_icon.cpp b/tests/test_volume_launcher_icon.cpp
index 1bd4f5a56..cee0dc9dc 100644
--- a/tests/test_volume_launcher_icon.cpp
+++ b/tests/test_volume_launcher_icon.cpp
@@ -213,12 +213,12 @@ TEST_F(TestVolumeLauncherIcon, WindowsOnMonitorChanges)
ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win})));
file_manager_->locations_changed.emit();
- EXPECT_EQ(icon_->WindowsVisibleOnMonitor(0), 1);
- EXPECT_EQ(icon_->WindowsVisibleOnMonitor(1), 0);
+ EXPECT_EQ(icon_->WindowsVisibleOnMonitor(0), 1u);
+ EXPECT_EQ(icon_->WindowsVisibleOnMonitor(1), 0u);
win->SetMonitor(1);
- EXPECT_EQ(icon_->WindowsVisibleOnMonitor(0), 0);
- EXPECT_EQ(icon_->WindowsVisibleOnMonitor(1), 1);
+ EXPECT_EQ(icon_->WindowsVisibleOnMonitor(0), 0u);
+ EXPECT_EQ(icon_->WindowsVisibleOnMonitor(1), 1u);
}
TEST_F(TestVolumeLauncherIcon, TestPosition)
@@ -481,7 +481,7 @@ TEST_F(TestVolumeLauncherIcon, TestEjectMenuItem)
auto menuitem = GetMenuItemAtIndex(5);
EXPECT_CALL(*volume_, Eject());
- EXPECT_CALL(*notifications_, Display(volume_->GetIconName(), volume_->GetName()));
+ EXPECT_CALL(*notifications_, Display(volume_->GetName()));
ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Eject");
EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));
@@ -573,7 +573,7 @@ TEST_F(TestVolumeLauncherIcon, TestEject)
.WillRepeatedly(Return(true));
EXPECT_CALL(*volume_, Eject());
- EXPECT_CALL(*notifications_, Display(volume_->GetIconName(), volume_->GetName()));
+ EXPECT_CALL(*notifications_, Display(volume_->GetName()));
icon_->EjectAndShowNotification();
}
diff --git a/tests/test_xdnd_start_stop_notifier_imp.cpp b/tests/test_xdnd_start_stop_notifier_imp.cpp
index 9811664ee..c8bf74b26 100644
--- a/tests/test_xdnd_start_stop_notifier_imp.cpp
+++ b/tests/test_xdnd_start_stop_notifier_imp.cpp
@@ -24,7 +24,7 @@ using namespace testing;
#include <Nux/Nux.h>
#include <X11/Xlib.h>
-//#include <X11/extensions/XTest.h>
+#include <X11/extensions/XTest.h>
#include "unity-shared/WindowManager.h"
#include "test_utils.h"
@@ -47,7 +47,7 @@ struct TestXdndStartStopNotifierImp : public Test {
unity::XdndStartStopNotifierImp xdnd_start_stop_notifier;
};
-TEST_F(TestXdndStartStopNotifierImp, UNSTABLE_TEST(SignalStarted))
+TEST_F(TestXdndStartStopNotifierImp, SignalStarted)
{
bool signal_received = false;
xdnd_start_stop_notifier.started.connect([&](){
@@ -55,15 +55,15 @@ TEST_F(TestXdndStartStopNotifierImp, UNSTABLE_TEST(SignalStarted))
});
XSetSelectionOwner(display_, selection_, owner_, CurrentTime);
- //XTestFakeButtonEvent(display_, 1, True, CurrentTime);
+ XTestFakeButtonEvent(display_, 1, True, CurrentTime);
auto& wm = unity::WindowManager::Default();
wm.window_mapped.emit(0);
Utils::WaitUntil(signal_received);
- //XTestFakeButtonEvent(display_, 1, False, CurrentTime);
+ XTestFakeButtonEvent(display_, 1, False, CurrentTime);
}
-TEST_F(TestXdndStartStopNotifierImp, UNSTABLE_TEST(SignalFinished))
+TEST_F(TestXdndStartStopNotifierImp, SignalFinished)
{
bool signal_received = false;
xdnd_start_stop_notifier.finished.connect([&](){
@@ -71,34 +71,34 @@ TEST_F(TestXdndStartStopNotifierImp, UNSTABLE_TEST(SignalFinished))
});
XSetSelectionOwner(display_, selection_, owner_, CurrentTime);
- //XTestFakeButtonEvent(display_, 1, True, CurrentTime);
+ XTestFakeButtonEvent(display_, 1, True, CurrentTime);
auto& wm = unity::WindowManager::Default();
wm.window_mapped.emit(0);
Utils::WaitForTimeoutMSec(500);
XSetSelectionOwner(display_, selection_, None, CurrentTime);
- //XTestFakeButtonEvent(display_, 1, False, CurrentTime);
+ XTestFakeButtonEvent(display_, 1, False, CurrentTime);
wm.window_unmapped.emit(0);
Utils::WaitUntil(signal_received);
}
-TEST_F(TestXdndStartStopNotifierImp, DISABLED_SignalFinished_QT)
+TEST_F(TestXdndStartStopNotifierImp, SignalFinished_QT)
{
bool signal_received = false;
- xdnd_start_stop_notifier.finished.connect([&](){
+ xdnd_start_stop_notifier.finished.connect([&signal_received] {
signal_received = true;
});
XSetSelectionOwner(display_, selection_, owner_, CurrentTime);
- //XTestFakeButtonEvent(display_, 1, True, CurrentTime);
+ XTestFakeButtonEvent(display_, 1, True, CurrentTime);
auto& wm = unity::WindowManager::Default();
wm.window_mapped.emit(0);
Utils::WaitForTimeoutMSec(500);
- //XTestFakeButtonEvent(display_, 1, False, CurrentTime);
+ XTestFakeButtonEvent(display_, 1, False, CurrentTime);
wm.window_unmapped.emit(0);
Utils::WaitUntil(signal_received);
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index e92776dd0..a9a5bc283 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -1,8 +1,36 @@
#
# Some unity tools
#
-install(FILES makebootchart.py PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity)
+install(FILES makebootchart.py PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION ${UNITY_INSTALL_LIBDIR})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/unity.cmake ${CMAKE_BINARY_DIR}/bin/unity)
install(FILES ${CMAKE_BINARY_DIR}/bin/unity PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+#
+# unity-active-plugins-safety-check
+#
+pkg_check_modules(UAPSC_DEPS REQUIRED libcompizconfig)
+
+set(CFLAGS
+ ${UAPSC_DEPS_CFLAGS}
+ ${UAPSC_DEPS_CFLAGS_OTHER}
+ )
+
+string (REPLACE ";" " " CFLAGS "${CFLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CFLAGS}")
+
+set(LIBS ${UAPSC_DEPS_LIBRARIES})
+
+set(LIB_PATHS ${UAPSC_DEPS_LIBRARY_DIRS})
+link_directories(${LIB_PATHS})
+
+add_executable(unity-active-plugins-safety-check unity_active_plugins_safety_check.cpp)
+target_link_libraries(unity-active-plugins-safety-check ${LIBS})
+install(TARGETS unity-active-plugins-safety-check DESTINATION ${UNITY_INSTALL_LIBDIR})
+
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/compiz-profile-selector.in ${CMAKE_CURRENT_BINARY_DIR}/compiz-profile-selector @ONLY)
+install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/compiz-profile-selector DESTINATION ${UNITY_INSTALL_LIBDIR})
+
+install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/systemd-prestart-check DESTINATION ${UNITY_INSTALL_LIBDIR})
+install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/upstart-prestart-check DESTINATION ${UNITY_INSTALL_LIBDIR})
diff --git a/tools/compiz-profile-selector.in b/tools/compiz-profile-selector.in
new file mode 100755
index 000000000..8041f109b
--- /dev/null
+++ b/tools/compiz-profile-selector.in
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -e
+compiz_profile="ubuntu"
+
+if ! /usr/lib/nux/unity_support_test -p; then
+ compiz_profile="ubuntu-lowgfx"
+fi
+
+echo "Using compiz profile '$compiz_profile'"
+
+if [ -n "$UPSTART_SESSION" ]; then
+ initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
+fi
+
+dbus-update-activation-environment --verbose --systemd COMPIZ_CONFIG_PROFILE="$compiz_profile"
+
+export COMPIZ_CONFIG_PROFILE="$compiz_profile"
+exec @UNITY_LIBDIR@/unity-active-plugins-safety-check
diff --git a/tools/systemd-prestart-check b/tools/systemd-prestart-check
new file mode 100644
index 000000000..191ff4f10
--- /dev/null
+++ b/tools/systemd-prestart-check
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+this_unit=$(sed -n "s,.*:name=systemd:.*/\([^/]\+\.service\)/\?.*,\1,p" /proc/self/cgroup)
+
+if [ -n "$this_unit" ] && [[ $this_unit == "unity"* ]]; then
+ this_job=$(systemctl --user list-jobs $this_unit | sed -n "s,\([0-9]\+\)\s\+${this_unit//./\\.}.*,\1,p")
+fi
+
+# If gnome-session is going to start compiz,
+# we don't want to be the ones doing it.
+if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session; then
+ echo "GNOME Session is starting Compiz"
+ [ -n "$this_job" ] && systemctl --user cancel $this_job
+ exit 1
+fi
+
+if [ -z "$UPSTART_SESSION" ]; then
+ exit 0
+fi
+
+upstart_status=$(initctl status unity7) || true
+
+if (echo "$upstart_status" | grep -q "start/running"); then
+ echo "Unity is managed by Upstart"
+ [ -n "$this_job" ] && systemctl --user cancel $this_job
+ exit 1
+fi
+
+exit 0
diff --git a/tools/unity.cmake b/tools/unity.cmake
index e018ab1bd..72f646a40 100755
--- a/tools/unity.cmake
+++ b/tools/unity.cmake
@@ -27,6 +27,7 @@ import signal
import subprocess
import sys
import time
+import xdg.BaseDirectory
DEFAULT_COMMAND = "compiz --replace"
home_dir = os.path.expanduser("~%s" % os.getenv("SUDO_USER"))
@@ -59,6 +60,12 @@ def set_unity_env ():
os.environ['COMPIZ_CONFIG_PROFILE'] = 'ubuntu'
+ try:
+ if subprocess.call('/usr/lib/nux/unity_support_test -f'.split()) > 0:
+ os.environ['COMPIZ_CONFIG_PROFILE'] = 'ubuntu-lowgfx'
+ except:
+ pass
+
if not 'DISPLAY' in os.environ:
# take an optimistic chance and warn about it :)
print("WARNING: no DISPLAY variable set, setting it to :0")
@@ -68,8 +75,49 @@ def reset_launcher_icons ():
'''Reset the default launcher icon and restart it.'''
subprocess.Popen(["gsettings", "reset" ,"com.canonical.Unity.Launcher" , "favorites"])
+def call_silently(cmd):
+ return subprocess.call(cmd.split(), stdout=open(os.devnull, 'w'), stderr=subprocess.STDOUT) == 0
+
+def session_manager_command(service, what):
+ if is_systemd_session() and not is_running_in_upstart(service):
+ return "systemctl --user {} {}.service".format(what, service)
+ elif is_upstart_session():
+ return "{} {}".format(what, service)
+
def is_upstart_session():
- return 'UPSTART_SESSION' in os.environ.keys() and len(os.environ['UPSTART_SESSION'])
+ return 'UPSTART_SESSION' in os.environ.keys() and len(os.environ['UPSTART_SESSION'])
+
+def is_running_in_upstart(service):
+ return is_upstart_session() and b'start/running' in subprocess.check_output("status {}".format(service).split())
+
+def is_unity_running_in_upstart():
+ return is_running_in_upstart("unity7")
+
+def is_systemd_session():
+ try:
+ return os.path.exists(os.path.join(xdg.BaseDirectory.get_runtime_dir(), "systemd"))
+ except:
+ return False
+
+def is_unity_running_in_systemd():
+ return is_systemd_session() and not is_unity_running_in_upstart() and \
+ call_silently(session_manager_command("unity7", "is-active"))
+
+def is_unity_running_in_session_manager():
+ return is_unity_running_in_systemd() or is_unity_running_in_upstart()
+
+def start_with_session_manager():
+ return subprocess.Popen(session_manager_command("unity7", "start").split())
+
+def restart_with_session_manager():
+ if is_unity_running_in_session_manager():
+ return subprocess.Popen(session_manager_command("unity7", "restart").split())
+ return start_with_session_manager()
+
+def stop_with_session_manager():
+ if is_unity_running_in_session_manager():
+ return call_silently(session_manager_command("unity7", "stop"))
+ return False
def process_and_start_unity (compiz_args):
'''launch unity under compiz (replace the current shell in any case)'''
@@ -102,9 +150,14 @@ def process_and_start_unity (compiz_args):
if options.log:
cli.extend(['2>&1', '|', 'tee', options.log])
- if is_upstart_session():
- if b'start/running' in subprocess.check_output("status unity7".split()):
- subprocess.call("stop unity7".split())
+ run_command = " ".join(cli)
+
+ if run_command == DEFAULT_COMMAND and not options.ignore_session_manager and \
+ (is_upstart_session() or is_systemd_session()):
+ return restart_with_session_manager()
+
+ if is_unity_running_in_upstart():
+ stop_with_session_manager()
# kill a previous compiz if was there (this is a hack as compiz can
# sometimes get stuck and not exit on --replace)
@@ -122,15 +175,10 @@ def process_and_start_unity (compiz_args):
except IOError:
continue
- run_command = " ".join(cli)
-
- if is_upstart_session() and run_command == DEFAULT_COMMAND and not options.ignore_upstart:
- return subprocess.Popen("start unity7".split())
- else:
- # shell = True as it's the simpest way to | tee.
- # In this case, we need a string and not a list
- # FIXME: still some bug with 2>&1 not showing everything before wait()
- return subprocess.Popen(" ".join(cli), env=dict(os.environ), shell=True)
+ # shell = True as it's the simpest way to | tee.
+ # In this case, we need a string and not a list
+ # FIXME: still some bug with 2>&1 not showing everything before wait()
+ return subprocess.Popen(run_command, env=dict(os.environ), shell=True)
def run_unity (compiz_args):
@@ -138,9 +186,9 @@ def run_unity (compiz_args):
try:
options.debug_mode = 2 if options.advanced_debug else 1 if options.debug else 0
- if is_upstart_session(): subprocess.call(["stop", "unity-panel-service"])
+ session_manager_command("unity-panel-service", "stop")
unity_instance = process_and_start_unity (compiz_args)
- if is_upstart_session(): subprocess.call(["start", "unity-panel-service"])
+ session_manager_command("unity-panel-service", "start")
unity_instance.wait()
except KeyboardInterrupt as e:
try:
@@ -193,8 +241,12 @@ if __name__ == '__main__':
help="Store log under filename.")
parser.add_option("--replace", action="store_true",
help="Run unity /!\ This is for compatibility with other desktop interfaces and acts the same as running unity without --replace")
- parser.add_option("--ignore-upstart", action="store_true",
- help="Run unity without upstart support")
+ if is_systemd_session() and not is_unity_running_in_upstart():
+ parser.add_option("--ignore-systemd", action="store_true", dest="ignore_session_manager",
+ help="Run unity without systemd support")
+ elif is_upstart_session():
+ parser.add_option("--ignore-upstart", action="store_true", dest="ignore_session_manager",
+ help="Run unity without upstart support")
parser.add_option("--reset", action="store_true",
help="(deprecated: provided for backwards compatibility)")
parser.add_option("--reset-icons", action="store_true",
diff --git a/tools/unity_active_plugins_safety_check.cpp b/tools/unity_active_plugins_safety_check.cpp
new file mode 100644
index 000000000..cd9e00165
--- /dev/null
+++ b/tools/unity_active_plugins_safety_check.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
+ */
+
+#include <ccs.h>
+#include <gio/gio.h>
+
+#include <iostream>
+#include <string>
+
+extern const CCSInterfaceTable ccsDefaultInterfaceTable;
+
+void PluginSetActiveWithDeps(CCSContext* context, std::string const& plugin_name)
+{
+ if (plugin_name.empty())
+ return;
+
+ auto plugin = ccsFindPlugin(context, plugin_name.c_str());
+
+ if (!plugin)
+ return;
+
+ auto reqs = ccsPluginGetRequiresPlugins(plugin);
+ for (auto req = reqs; req; req = req->next)
+ {
+ if (req->data && req->data->value)
+ {
+ std::string name = req->data->value;
+ PluginSetActiveWithDeps(context, name.c_str());
+ }
+ }
+
+ if (!ccsPluginIsActive(context, plugin_name.c_str())) {
+ std::cout << "Setting plugin '" << plugin_name << "' to active" << std::endl;
+ ccsPluginSetActive(plugin, true);
+ }
+
+ auto conflicts = ccsPluginGetConflictPlugins(plugin);
+ for (auto con = conflicts; con; con = con->next)
+ {
+ if (con->data && con->data->value)
+ {
+ std::string name = con->data->value;
+ auto plugin = ccsFindPlugin(context, name.c_str());
+
+ if (ccsPluginIsActive(context, name.c_str()))
+ {
+ std::cout << "Setting plugin '" << name << "' to non-active" << std::endl;
+ ccsPluginSetActive(plugin, false);
+ }
+ }
+ }
+}
+
+int main()
+{
+ auto context = ccsContextNew (0, &ccsDefaultInterfaceTable);
+
+ if (!context)
+ return -1;
+
+ PluginSetActiveWithDeps(context, "unityshell");
+
+ ccsWriteChangedSettings(context);
+ g_settings_sync();
+ ccsFreeContext(context);
+
+ return 0;
+}
diff --git a/tools/upstart-prestart-check b/tools/upstart-prestart-check
new file mode 100644
index 000000000..e846c4769
--- /dev/null
+++ b/tools/upstart-prestart-check
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# If gnome-session is going to start compiz,
+# we don't want to be the ones doing it.
+if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
+ echo "GNOME Session is starting Compiz"
+ stop
+ exit 1
+fi
+
+if (systemctl --user is-active unity7 &> /dev/null); then
+ echo "Unity instance is managed by Systemd, ignoring request..."
+ stop
+ exit 1
+fi
+
+exit 0
diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt
index 7ad243f57..b0ac7b12c 100644
--- a/unity-shared/CMakeLists.txt
+++ b/unity-shared/CMakeLists.txt
@@ -58,7 +58,9 @@ set (UNITY_SHARED_SOURCES
SearchBar.cpp
SearchBarSpinner.cpp
SpreadFilter.cpp
+ SpreadWidgets.cpp
StaticCairoText.cpp
+ SystemdWrapper.cpp
TextureCache.cpp
TextInput.cpp
TextureThumbnailProvider.cpp
@@ -81,6 +83,7 @@ if(ENABLE_X_SUPPORT)
set (UNITY_SHARED_SOURCES
XKeyboardUtil.cpp
XWindowManager.cpp
+ InputMonitor.cpp
${UNITY_SHARED_SOURCES}
)
else()
diff --git a/unity-shared/CompizUtils.cpp b/unity-shared/CompizUtils.cpp
index acd1e15a3..643dfd18d 100644
--- a/unity-shared/CompizUtils.cpp
+++ b/unity-shared/CompizUtils.cpp
@@ -211,11 +211,10 @@ unsigned WindowDecorationElements(CompWindow* win, WindowFilter wf)
}
}
- if (region.boundingRect() != win->geometry()) // Shaped windows
- return elements;
+ elements |= DecorationElement::SHADOW;
- if (rectangular)
- elements |= DecorationElement::SHADOW;
+ if (!rectangular)
+ elements |= DecorationElement::SHAPED;
if (!win->overrideRedirect() &&
(win->type() & DECORABLE_WINDOW_TYPES) &&
diff --git a/unity-shared/CompizUtils.h b/unity-shared/CompizUtils.h
index ef4b03c88..0c733eb0e 100644
--- a/unity-shared/CompizUtils.h
+++ b/unity-shared/CompizUtils.h
@@ -133,7 +133,8 @@ enum
NONE = 0,
EDGE = (1 << 0),
SHADOW = (1 << 1),
- BORDER = (1 << 2),
+ SHAPED = (1 << 2),
+ BORDER = (1 << 3),
FULL = EDGE|SHADOW|BORDER
};
}
diff --git a/unity-shared/DashStyle.cpp b/unity-shared/DashStyle.cpp
index 22ee245d9..66ed48c5b 100755
--- a/unity-shared/DashStyle.cpp
+++ b/unity-shared/DashStyle.cpp
@@ -44,7 +44,7 @@
#include "UnitySettings.h"
#include "config.h"
-#define DASH_WIDGETS_FILE UNITYDATADIR"/themes/dash-widgets.json"
+#define DASH_WIDGETS_FILE UNITY_DATADIR"/themes/dash-widgets.json"
namespace unity
{
@@ -303,7 +303,7 @@ void Style::Impl::LoadStyleFile()
// is initialised.
SetDefaultValues();
- if (!parser.Open(theme::Settings::Get()->ThemedFilePath("dash-widgets", {UNITYDATADIR"/themes"}, {"json"})))
+ if (!parser.Open(theme::Settings::Get()->ThemedFilePath("dash-widgets", {UNITY_DATADIR"/themes"}, {"json"})))
{
LOG_ERROR(logger) << "Impossible to find a dash-widgets.json in theme paths";
return;
@@ -2121,24 +2121,14 @@ bool Style::SeparatorHoriz(cairo_t* cr)
return true;
}
-BaseTexturePtr Style::GetDashHorizontalTile(double scale, Position dash_position) const
+BaseTexturePtr Style::GetDashHorizontalTile(double scale) const
{
- std::string horizontal_tile;
- if (dash_position == Position::BOTTOM)
- horizontal_tile = "dash_top_border_tile";
- else
- horizontal_tile = "dash_bottom_border_tile";
- return pimpl->LoadScaledTexture(horizontal_tile, scale);
+ return pimpl->LoadScaledTexture("dash_bottom_border_tile", scale);
}
-BaseTexturePtr Style::GetDashHorizontalTileMask(double scale, Position dash_position) const
+BaseTexturePtr Style::GetDashHorizontalTileMask(double scale) const
{
- std::string horizontal_tile_mask;
- if (dash_position == Position::BOTTOM)
- horizontal_tile_mask = "dash_top_border_tile_mask";
- else
- horizontal_tile_mask = "dash_bottom_border_tile_mask";
- return pimpl->LoadScaledTexture(horizontal_tile_mask, scale);
+ return pimpl->LoadScaledTexture("dash_bottom_border_tile_mask", scale);
}
BaseTexturePtr Style::GetDashRightTile(double scale) const
@@ -2151,79 +2141,49 @@ BaseTexturePtr Style::GetDashRightTileMask(double scale) const
return pimpl->LoadScaledTexture("dash_right_border_tile_mask", scale);
}
+BaseTexturePtr Style::GetDashTopLeftTile(double scale) const
+{
+ return pimpl->LoadScaledTexture("overlay_top_left_tile", scale);
+}
+
BaseTexturePtr Style::GetDashLeftTile(double scale) const
{
return pimpl->LoadScaledTexture("dash_left_tile", scale);
}
-BaseTexturePtr Style::GetDashTopOrBottomTile(double scale, Position dash_position) const
+BaseTexturePtr Style::GetDashTopTile(double scale) const
{
- std::string top_bottom_tile;
- if (dash_position == Position::BOTTOM)
- top_bottom_tile = "dash_bottom_tile";
- else
- top_bottom_tile = "dash_top_tile";
- return pimpl->LoadScaledTexture(top_bottom_tile, scale);
+ return pimpl->LoadScaledTexture("dash_top_tile", scale);
}
-BaseTexturePtr Style::GetDashCorner(double scale, Position dash_position) const
+BaseTexturePtr Style::GetDashCorner(double scale) const
{
- std::string corner;
- if (dash_position == Position::BOTTOM)
- corner = "dash_top_right_corner_rotated";
- else
- corner = "dash_bottom_right_corner";
- return pimpl->LoadScaledTexture(corner, scale);
+ return pimpl->LoadScaledTexture("dash_bottom_right_corner", scale);
}
-BaseTexturePtr Style::GetDashCornerMask(double scale, Position dash_position) const
+BaseTexturePtr Style::GetDashCornerMask(double scale) const
{
- std::string corner_mask;
- if (dash_position == Position::BOTTOM)
- corner_mask = "dash_top_right_corner_rotated_mask";
- else
- corner_mask = "dash_bottom_right_corner_mask";
- return pimpl->LoadScaledTexture(corner_mask, scale);
+ return pimpl->LoadScaledTexture("dash_bottom_right_corner_mask", scale);
}
-BaseTexturePtr Style::GetDashLeftCorner(double scale, Position dash_position) const
+BaseTexturePtr Style::GetDashLeftCorner(double scale) const
{
- std::string left_corner;
- if (dash_position == Position::BOTTOM)
- left_corner = "dash_top_left_corner";
- else
- left_corner = "dash_bottom_left_corner";
- return pimpl->LoadScaledTexture(left_corner, scale);
+ return pimpl->LoadScaledTexture("dash_bottom_left_corner", scale);
}
-BaseTexturePtr Style::GetDashLeftCornerMask(double scale, Position dash_position) const
+BaseTexturePtr Style::GetDashLeftCornerMask(double scale) const
{
- std::string left_corner_mask;
- if (dash_position == Position::BOTTOM)
- left_corner_mask = "dash_top_left_corner_mask";
- else
- left_corner_mask = "dash_bottom_left_corner_mask";
- return pimpl->LoadScaledTexture(left_corner_mask, scale);
+ return pimpl->LoadScaledTexture("dash_bottom_left_corner_mask", scale);
}
-BaseTexturePtr Style::GetDashRightCorner(double scale, Position dash_position) const
+BaseTexturePtr Style::GetDashRightCorner(double scale) const
{
- std::string right_corner;
- if (dash_position == Position::BOTTOM)
- right_corner = "dash_bottom_right_corner_rotated";
- else
- right_corner = "dash_top_right_corner";
- return pimpl->LoadScaledTexture(right_corner, scale);
+ return pimpl->LoadScaledTexture("dash_top_right_corner", scale);
}
-BaseTexturePtr Style::GetDashRightCornerMask(double scale, Position dash_position) const
+BaseTexturePtr Style::GetDashRightCornerMask(double scale) const
{
- std::string right_corner_mask;
- if (dash_position == Position::BOTTOM)
- right_corner_mask = "dash_bottom_right_corner_rotated_mask";
- else
- right_corner_mask = "dash_top_right_corner_mask";
- return pimpl->LoadScaledTexture(right_corner_mask, scale);
+ return pimpl->LoadScaledTexture("dash_top_right_corner_mask", scale);
}
BaseTexturePtr Style::GetSearchMagnifyIcon(double scale) const
diff --git a/unity-shared/DashStyle.h b/unity-shared/DashStyle.h
index 4d228a513..f080297a9 100755
--- a/unity-shared/DashStyle.h
+++ b/unity-shared/DashStyle.h
@@ -85,11 +85,6 @@ enum class Arrow {
NONE
};
-enum class Position {
- LEFT,
- BOTTOM
-};
-
class Style : public StyleInterface
{
public:
@@ -175,19 +170,20 @@ public:
BaseTexturePtr const& GetCategoryBackground() const;
BaseTexturePtr const& GetCategoryBackgroundNoFilters() const;
- BaseTexturePtr GetDashHorizontalTile(double scale, Position) const;
- BaseTexturePtr GetDashHorizontalTileMask(double scale, Position) const;
+ BaseTexturePtr GetDashHorizontalTile(double scale) const;
+ BaseTexturePtr GetDashHorizontalTileMask(double scale) const;
BaseTexturePtr GetDashRightTile(double scale) const;
BaseTexturePtr GetDashRightTileMask(double scale) const;
+ BaseTexturePtr GetDashTopLeftTile(double scale) const;
BaseTexturePtr GetDashLeftTile(double scale) const;
- BaseTexturePtr GetDashTopOrBottomTile(double scale, Position) const;
-
- BaseTexturePtr GetDashCorner(double scale, Position) const;
- BaseTexturePtr GetDashCornerMask(double scale, Position) const;
- BaseTexturePtr GetDashLeftCorner(double scale, Position) const;
- BaseTexturePtr GetDashLeftCornerMask(double scale, Position) const;
- BaseTexturePtr GetDashRightCorner(double scale, Position) const;
- BaseTexturePtr GetDashRightCornerMask(double scale, Position) const;
+ BaseTexturePtr GetDashTopTile(double scale) const;
+
+ BaseTexturePtr GetDashCorner(double scale) const;
+ BaseTexturePtr GetDashCornerMask(double scale) const;
+ BaseTexturePtr GetDashLeftCorner(double scale) const;
+ BaseTexturePtr GetDashLeftCornerMask(double scale) const;
+ BaseTexturePtr GetDashRightCorner(double scale) const;
+ BaseTexturePtr GetDashRightCornerMask(double scale) const;
RawPixel GetDashHorizontalBorderHeight() const;
RawPixel GetDashVerticalBorderWidth() const;
diff --git a/unity-shared/DecorationStyle.cpp b/unity-shared/DecorationStyle.cpp
index ddd658483..7cfe5e067 100644
--- a/unity-shared/DecorationStyle.cpp
+++ b/unity-shared/DecorationStyle.cpp
@@ -124,6 +124,10 @@ static void unity_decoration_class_init(UnityDecorationClass* klass)
param = g_param_spec_boxed("glow-color", "Selected Window Glow Color", "", GDK_TYPE_RGBA, G_PARAM_READABLE);
gtk_widget_class_install_style_property(GTK_WIDGET_CLASS(klass), param);
+
+#if GTK_CHECK_VERSION(3, 20, 0)
+ gtk_widget_class_set_css_name(GTK_WIDGET_CLASS(klass), "UnityDecoration");
+#endif
}
Border BorderFromGtkBorder(GtkBorder* b, Border const& fallback = Border())
@@ -369,6 +373,7 @@ struct Style::Impl
void AddContextClasses(Side s, WidgetState ws, GtkStyleContext* ctx = nullptr)
{
ctx = ctx ? ctx : ctx_;
+ gtk_style_context_add_class(ctx, "unity-decoration");
gtk_style_context_add_class(ctx, "background");
gtk_style_context_add_class(ctx, "gnome-panel-menu-bar");
if (s == Side::TOP) { gtk_style_context_add_class(ctx, "header-bar"); }
@@ -804,4 +809,4 @@ nux::Size Style::MenuItemNaturalSize(std::string const& text)
}
} // decoration namespace
-} // unity namespace \ No newline at end of file
+} // unity namespace
diff --git a/unity-shared/GnomeFileManager.cpp b/unity-shared/GnomeFileManager.cpp
index 4ec6e51f2..df3534720 100644
--- a/unity-shared/GnomeFileManager.cpp
+++ b/unity-shared/GnomeFileManager.cpp
@@ -45,7 +45,7 @@ struct GnomeFileManager::Impl
{
Impl(GnomeFileManager* parent)
: parent_(parent)
- , filemanager_proxy_("org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1")
+ , filemanager_proxy_("org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1", G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS)
{
auto callback = sigc::mem_fun(this, &Impl::OnOpenLocationsXidsUpdated);
filemanager_proxy_.GetProperty("XUbuntuOpenLocationsXids", callback);
@@ -54,8 +54,10 @@ struct GnomeFileManager::Impl
glib::DBusProxy::Ptr NautilusOperationsProxy() const
{
+ auto flags = static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS);
return std::make_shared<glib::DBusProxy>(NAUTILUS_NAME, NAUTILUS_PATH,
- "org.gnome.Nautilus.FileOperations");
+ "org.gnome.Nautilus.FileOperations",
+ G_BUS_TYPE_SESSION, flags);
}
void OnOpenLocationsXidsUpdated(GVariant* value)
diff --git a/unity-shared/InputMonitor.cpp b/unity-shared/InputMonitor.cpp
new file mode 100644
index 000000000..465c5afad
--- /dev/null
+++ b/unity-shared/InputMonitor.cpp
@@ -0,0 +1,420 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2014 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
+ */
+
+#include "InputMonitor.h"
+#include "SigcSlotHash.h"
+
+#include <Nux/Nux.h>
+#include <NuxCore/Logger.h>
+#include <X11/extensions/XInput2.h>
+#include <UnityCore/GLibSource.h>
+#include <unordered_set>
+#include <gdk/gdkx.h>
+#include <glib.h>
+
+namespace unity
+{
+namespace input
+{
+namespace
+{
+DECLARE_LOGGER(logger, "unity.input.monitor");
+
+Monitor* instance_ = nullptr;
+
+const unsigned XINPUT_MAJOR_VERSION = 2;
+const unsigned XINPUT_MINOR_VERSION = 3;
+
+bool operator&(Events l, Events r)
+{
+ typedef std::underlying_type<Events>::type ut;
+ return static_cast<ut>(static_cast<ut>(l) & static_cast<ut>(r));
+}
+
+Events& operator|=(Events& l, Events r)
+{
+ typedef std::underlying_type<Events>::type ut;
+ return l = static_cast<Events>(static_cast<ut>(l) | static_cast<ut>(r));
+}
+
+template <typename EVENT>
+void initialize_event_common(EVENT* ev, XIDeviceEvent* xiev)
+{
+ ev->serial = xiev->serial;
+ ev->send_event = xiev->send_event;
+ ev->display = xiev->display;
+ ev->window = xiev->event;
+ ev->root = xiev->root;
+ ev->subwindow = xiev->child;
+ ev->time = xiev->time;
+ ev->x = std::round(xiev->event_x);
+ ev->y = std::round(xiev->event_y);
+ ev->x_root = std::round(xiev->root_x);
+ ev->y_root = std::round(xiev->root_y);
+ ev->state = xiev->mods.effective;
+ ev->same_screen = True;
+}
+
+template <typename EVENT_TYPE, typename NATIVE_TYPE>
+void initialize_event(XEvent* ev, NATIVE_TYPE* xiev);
+
+template <>
+void initialize_event<XButtonEvent>(XEvent* ev, XIDeviceEvent* xiev)
+{
+ XButtonEvent* bev = &ev->xbutton;
+ ev->type = (xiev->evtype == XI_ButtonPress) ? ButtonPress : ButtonRelease;
+ initialize_event_common(bev, xiev);
+ bev->button = xiev->detail;
+}
+
+template <>
+void initialize_event<XKeyEvent>(XEvent* ev, XIDeviceEvent* xiev)
+{
+ XKeyEvent* kev = &ev->xkey;
+ ev->type = (xiev->evtype == XI_KeyPress) ? KeyPress : KeyRelease;
+ initialize_event_common(kev, xiev);
+ kev->keycode = xiev->detail;
+}
+
+template <>
+void initialize_event<XMotionEvent>(XEvent* ev, XIDeviceEvent* xiev)
+{
+ XMotionEvent* mev = &ev->xmotion;
+ ev->type = MotionNotify;
+ initialize_event_common(mev, xiev);
+ mev->is_hint = NotifyNormal;
+
+ for (int i = 0; i < xiev->buttons.mask_len * 8; ++i)
+ {
+ if (XIMaskIsSet(xiev->buttons.mask, i))
+ {
+ mev->is_hint = NotifyHint;
+ break;
+ }
+ }
+}
+
+template <>
+void initialize_event<XGenericEventCookie>(XEvent* ev, XIBarrierEvent* xiev)
+{
+ XGenericEventCookie* cev = &ev->xcookie;
+ cev->type = GenericEvent;
+ cev->serial = xiev->serial;
+ cev->send_event = xiev->send_event;
+ cev->display = xiev->display;
+ cev->evtype = xiev->evtype;
+ cev->data = xiev;
+}
+}
+
+struct Monitor::Impl
+{
+#if __GNUC__ < 6
+ using EventCallbackSet = std::unordered_set<EventCallback>;
+#else
+ using EventCallbackSet = std::unordered_set<EventCallback, std::hash<sigc::slot_base>>;
+#endif
+
+ Impl()
+ : xi_opcode_(0)
+ , event_filter_set_(false)
+ , invoking_callbacks_(false)
+ {
+ Display *dpy = gdk_x11_get_default_xdisplay();
+ int event_base, error_base;
+
+ if (XQueryExtension(dpy, "XInputExtension", &xi_opcode_, &event_base, &error_base))
+ {
+ int maj = XINPUT_MAJOR_VERSION;
+ int min = XINPUT_MINOR_VERSION;
+
+ if (XIQueryVersion(dpy, &maj, &min) == BadRequest)
+ {
+ LOG_ERROR(logger) << "Need XInput version "<< maj << "." << min << ", "
+ << "impossible, to setup an InputMonitor";
+ }
+ }
+ else
+ {
+ LOG_ERROR(logger) << "Missing XInput, impossible to setup an InputMonitor";
+ }
+ }
+
+ ~Impl()
+ {
+ if (event_filter_set_)
+ {
+ pointer_callbacks_.clear();
+ key_callbacks_.clear();
+ barrier_callbacks_.clear();
+ UpdateEventMonitor();
+ }
+ }
+
+ bool RegisterClient(Events type, EventCallback const& cb)
+ {
+ bool added = false;
+
+ if (type & Events::POINTER)
+ added = pointer_callbacks_.insert(cb).second || added;
+
+ if (type & Events::KEYS)
+ added = key_callbacks_.insert(cb).second || added;
+
+ if (type & Events::BARRIER)
+ added = barrier_callbacks_.insert(cb).second || added;
+
+ if (added)
+ UpdateEventMonitor();
+
+ return added;
+ }
+
+ bool UnregisterClient(EventCallback const& cb)
+ {
+ if (invoking_callbacks_)
+ {
+ // Delay the event removal if we're currently invoking a callback
+ // not to break the callbacks loop
+ removal_queue_.insert(cb);
+ return false;
+ }
+
+ bool removed = false;
+ removed = pointer_callbacks_.erase(cb) > 0 || removed;
+ removed = key_callbacks_.erase(cb) > 0 || removed;
+ removed = barrier_callbacks_.erase(cb) > 0 || removed;
+
+ if (removed)
+ UpdateEventMonitor();
+
+ return removed;
+ }
+
+ Events RegisteredEvents(EventCallback const& cb) const
+ {
+ Events events = Events::NONE;
+
+ if (pointer_callbacks_.find(cb) != end(pointer_callbacks_))
+ events |= Events::POINTER;
+
+ if (key_callbacks_.find(cb) != end(key_callbacks_))
+ events |= Events::KEYS;
+
+ if (barrier_callbacks_.find(cb) != end(barrier_callbacks_))
+ events |= Events::BARRIER;
+
+ return events;
+ }
+
+ void UpdateEventMonitor()
+ {
+ auto* dpy = nux::GetGraphicsDisplay()->GetX11Display();
+ Window root = DefaultRootWindow(dpy);
+
+ unsigned char master_dev_bits[XIMaskLen(XI_LASTEVENT)] = { 0 };
+ XIEventMask master_dev = { XIAllMasterDevices, sizeof(master_dev_bits), master_dev_bits };
+
+ if (!barrier_callbacks_.empty())
+ {
+ XISetMask(master_dev.mask, XI_BarrierHit);
+ XISetMask(master_dev.mask, XI_BarrierLeave);
+ }
+
+ unsigned char all_devs_bits[XIMaskLen(XI_LASTEVENT)] = { 0 };
+ XIEventMask all_devs = { XIAllDevices, sizeof(all_devs_bits), all_devs_bits };
+
+ if (!pointer_callbacks_.empty())
+ {
+ XISetMask(all_devs.mask, XI_Motion);
+ XISetMask(all_devs.mask, XI_ButtonPress);
+ XISetMask(all_devs.mask, XI_ButtonRelease);
+ }
+
+ if (!key_callbacks_.empty())
+ {
+ XISetMask(all_devs.mask, XI_KeyPress);
+ XISetMask(all_devs.mask, XI_KeyRelease);
+ }
+
+ XIEventMask selected[] = {master_dev, all_devs};
+ XISelectEvents(dpy, root, selected, G_N_ELEMENTS(selected));
+ XSync(dpy, False);
+
+ LOG_DEBUG(logger) << "Pointer clients: " << pointer_callbacks_.size() << ", "
+ << "Key clients: " << key_callbacks_.size() << ", "
+ << "Barrier clients: " << barrier_callbacks_.size();
+
+ if (!pointer_callbacks_.empty() || !key_callbacks_.empty() || !barrier_callbacks_.empty())
+ {
+ if (!event_filter_set_)
+ {
+ nux::GetGraphicsDisplay()->AddEventFilter({[] (XEvent event, void* data) {
+ return static_cast<Impl*>(data)->HandleEvent(event);
+ }, this});
+
+ event_filter_set_ = true;
+ LOG_DEBUG(logger) << "Event filter enabled";
+ }
+ }
+ else if (event_filter_set_)
+ {
+ nux::GetGraphicsDisplay()->RemoveEventFilter(this);
+ event_filter_set_ = false;
+ LOG_DEBUG(logger) << "Event filter disabled";
+ }
+ }
+
+ bool HandleEvent(XEvent& event)
+ {
+ bool handled = false;
+
+ if (event.type != GenericEvent || event.xcookie.extension != xi_opcode_)
+ return handled;
+
+ switch (event.xcookie.evtype)
+ {
+ case XI_ButtonPress:
+ case XI_ButtonRelease:
+ handled = InvokeCallbacks<XButtonEvent>(pointer_callbacks_, event);
+ break;
+ case XI_Motion:
+ handled = InvokeCallbacks<XMotionEvent>(pointer_callbacks_, event);
+ break;
+ case XI_KeyPress:
+ case XI_KeyRelease:
+ handled = InvokeCallbacks<XKeyEvent>(key_callbacks_, event);
+ break;
+ case XI_BarrierHit:
+ case XI_BarrierLeave:
+ handled = InvokeCallbacks<XGenericEventCookie, XIBarrierEvent>(barrier_callbacks_, event);
+ break;
+ }
+
+ return handled;
+ }
+
+ template <typename EVENT_TYPE, typename NATIVE_TYPE = XIDeviceEvent>
+ bool InvokeCallbacks(EventCallbackSet& callbacks, XEvent& xiev)
+ {
+ XGenericEventCookie *cookie = &xiev.xcookie;
+
+ if (!XGetEventData(xiev.xany.display, cookie))
+ return false;
+
+ XEvent event;
+ initialize_event<EVENT_TYPE>(&event, reinterpret_cast<NATIVE_TYPE*>(cookie->data));
+ invoking_callbacks_ = true;
+
+ for (auto it = callbacks.begin(); it != callbacks.end();)
+ {
+ if (it->empty())
+ {
+ it = callbacks.erase(it);
+ continue;
+ }
+
+ (*it)(event);
+ ++it;
+ }
+
+ XFreeEventData(xiev.xany.display, cookie);
+ invoking_callbacks_ = false;
+
+ // A callback might unregister itself on the event callback, causing the
+ // above callbacks loop to crash, so in this case we save the event in the
+ // removal queue and eventually we unregistered these callbacks.
+ bool update_event_monitor = false;
+ for (auto it = removal_queue_.begin(); it != removal_queue_.end(); it = removal_queue_.erase(it))
+ {
+ auto const& cb = *it;
+ pointer_callbacks_.erase(cb);
+ key_callbacks_.erase(cb);
+ barrier_callbacks_.erase(cb);
+ update_event_monitor = true;
+ }
+
+ if (callbacks.empty() || update_event_monitor)
+ {
+ idle_removal_.reset(new glib::Idle([this] {
+ UpdateEventMonitor();
+ return false;
+ }));
+
+ return false;
+ }
+
+ return true;
+ }
+
+ int xi_opcode_;
+ bool event_filter_set_;
+ bool invoking_callbacks_;
+ glib::Source::UniquePtr idle_removal_;
+ EventCallbackSet pointer_callbacks_;
+ EventCallbackSet key_callbacks_;
+ EventCallbackSet barrier_callbacks_;
+ EventCallbackSet removal_queue_;
+};
+
+Monitor::Monitor()
+{
+ if (instance_)
+ {
+ LOG_WARN(logger) << "More than one input::Monitor created.";
+ return;
+ }
+
+ instance_ = this;
+ impl_.reset(new Impl());
+}
+
+Monitor::~Monitor()
+{
+ if (this == instance_)
+ instance_ = nullptr;
+}
+
+Monitor& Monitor::Get()
+{
+ if (!instance_)
+ {
+ LOG_ERROR(logger) << "No input::Monitor created yet.";
+ }
+
+ return *instance_;
+}
+
+bool Monitor::RegisterClient(Events events, EventCallback const& cb)
+{
+ return impl_->RegisterClient(events, cb);
+}
+
+bool Monitor::UnregisterClient(EventCallback const& cb)
+{
+ return impl_->UnregisterClient(cb);
+}
+
+Events Monitor::RegisteredEvents(EventCallback const& cb) const
+{
+ return impl_->RegisteredEvents(cb);
+}
+
+} // input namespace
+} // unity namespace
diff --git a/unity-shared/InputMonitor.h b/unity-shared/InputMonitor.h
new file mode 100644
index 000000000..23ff8ceff
--- /dev/null
+++ b/unity-shared/InputMonitor.h
@@ -0,0 +1,67 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2014 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
+ */
+
+#ifndef __UNITY_INPUT_MONITOR__
+#define __UNITY_INPUT_MONITOR__
+
+#include <X11/Xlib.h>
+#include <sigc++/slot.h>
+#include <memory>
+
+namespace unity
+{
+namespace input
+{
+enum class Events : unsigned
+{
+ NONE = 0,
+ POINTER = (1 << 0),
+ KEYS = (1 << 1),
+ BARRIER = (1 << 2),
+ INPUT = POINTER | KEYS,
+ ALL = POINTER | KEYS | BARRIER
+};
+
+class Monitor : public sigc::trackable
+{
+public:
+ typedef sigc::slot<void, XEvent const&> EventCallback;
+
+ static Monitor& Get();
+
+ Monitor();
+ ~Monitor();
+
+ bool RegisterClient(Events, EventCallback const&);
+ bool UnregisterClient(EventCallback const&);
+
+ Events RegisteredEvents(EventCallback const&) const;
+
+private:
+ Monitor(Monitor const&) = delete;
+ Monitor& operator=(Monitor const&) = delete;
+
+ struct Impl;
+ std::unique_ptr<Impl> impl_;
+};
+
+} // input namespace
+} // unity namespace
+
+#endif // __UNITY_INPUT_MONITOR__
diff --git a/unity-shared/MenuManager.cpp b/unity-shared/MenuManager.cpp
index f00887ce8..77828700d 100644
--- a/unity-shared/MenuManager.cpp
+++ b/unity-shared/MenuManager.cpp
@@ -21,11 +21,17 @@
#include <gtk/gtk.h>
#include <NuxCore/Logger.h>
#include <UnityCore/GLibSignal.h>
+#include <UnityCore/GLibSource.h>
#include <UnityCore/GLibWrapper.h>
#include <UnityCore/DBusIndicators.h>
#include <unordered_map>
#include "MenuManager.h"
+#include "InputMonitor.h"
+#include "RawPixel.h"
+#include "SigcSlotHash.h"
+#include "UnitySettings.h"
+#include "UScreen.h"
#include "WindowManager.h"
namespace unity
@@ -40,6 +46,10 @@ const std::string SETTINGS_NAME = "com.canonical.Unity";
const std::string LIM_KEY = "integrated-menus";
const std::string SHOW_MENUS_NOW_DELAY = "show-menus-now-delay";
const std::string ALWAYS_SHOW_MENUS_KEY = "always-show-menus";
+
+const RawPixel TRIANGLE_THRESHOLD = 5_em;
+const double SCRUB_VELOCITY_THRESHOLD = 0.05;
+const unsigned MENU_OPEN_MOUSE_WAIT = 150;
}
using namespace indicator;
@@ -51,6 +61,7 @@ struct Manager::Impl : sigc::trackable
, indicators_(indicators)
, key_grabber_(grabber)
, show_now_window_(0)
+ , last_pointer_time_(0)
, settings_(g_settings_new(SETTINGS_NAME.c_str()))
{
for (auto const& indicator : indicators_->GetIndicators())
@@ -182,9 +193,15 @@ struct Manager::Impl : sigc::trackable
parent_->key_activate_entry.emit(entry_id);
}
- void EntryActivated(std::string const&, std::string const&, nux::Rect const& geo)
+ void EntryActivated(std::string const& menubar, std::string const&, nux::Rect const& geo)
{
parent_->menu_open = !geo.IsNull();
+
+ if (active_menubar_ != menubar)
+ {
+ active_menubar_ = menubar;
+ UpdateActiveTracker();
+ }
}
void SetShowNowForWindow(Window xid, bool show)
@@ -231,15 +248,148 @@ struct Manager::Impl : sigc::trackable
gtk_icon_theme_set_search_path(gtk_icon_theme_get_default(), gicon_paths.data(), gicon_paths.size());
}
+ bool PointInTriangle(nux::Point const& p, nux::Point const& t0, nux::Point const& t1, nux::Point const& t2)
+ {
+ int s = t0.y * t2.x - t0.x * t2.y + (t2.y - t0.y) * p.x + (t0.x - t2.x) * p.y;
+ int t = t0.x * t1.y - t0.y * t1.x + (t0.y - t1.y) * p.x + (t1.x - t0.x) * p.y;
+
+ if ((s < 0) != (t < 0))
+ return false;
+
+ int A = -t1.y * t2.x + t0.y * (t2.x - t1.x) + t0.x * (t1.y - t2.y) + t1.x * t2.y;
+ if (A < 0)
+ {
+ s = -s;
+ t = -t;
+ A = -A;
+ }
+
+ return s > 0 && t > 0 && (s + t) < A;
+ }
+
+ double GetMouseVelocity(nux::Point const& p0, nux::Point const& p1, Time time_delta)
+ {
+ int dx, dy;
+ double speed;
+
+ if (time_delta == 0)
+ return 1;
+
+ dx = p0.x - p1.x;
+ dy = p0.y - p1.y;
+
+ speed = sqrt(dx * dx + dy * dy) / time_delta;
+
+ return speed;
+ }
+
+ void OnActiveEntryEvent(XEvent const& e)
+ {
+ if (e.type != MotionNotify)
+ return;
+
+ auto const& active_entry = indicators_->GetActiveEntry();
+
+ if (!active_entry)
+ return;
+
+ nux::Point mouse(e.xmotion.x_root, e.xmotion.y_root);
+ auto monitor = UScreen::GetDefault()->GetMonitorAtPosition(mouse.x, mouse.y);
+ double scale = Settings::Instance().em(monitor)->DPIScale();
+ double speed = GetMouseVelocity(mouse, tracked_pointer_pos_, e.xmotion.time - last_pointer_time_);
+ auto menu_geo = active_entry->geometry();
+
+ tracked_pointer_pos_ = mouse;
+ last_pointer_time_ = e.xmotion.time;
+
+ if (speed > SCRUB_VELOCITY_THRESHOLD &&
+ PointInTriangle(mouse, {mouse.x, std::max(mouse.y - TRIANGLE_THRESHOLD.CP(scale), 0)},
+ menu_geo.GetPosition(), {menu_geo.x + menu_geo.width, menu_geo.y}))
+ {
+ pointer_movement_timeout_ = std::make_shared<glib::Timeout>(MENU_OPEN_MOUSE_WAIT, [this, mouse, speed] {
+ if (active_tracker_)
+ active_tracker_(mouse.x, mouse.y, speed);
+
+ return false;
+ });
+
+ return;
+ }
+
+ if (active_tracker_)
+ {
+ pointer_movement_timeout_.reset();
+ active_tracker_(mouse.x, mouse.y, speed);
+ }
+ }
+
+ bool RegisterTracker(std::string const& menubar, PositionTracker const& cb)
+ {
+ auto it = position_trackers_.find(menubar);
+
+ if (it != end(position_trackers_))
+ return false;
+
+ position_trackers_.insert({menubar, cb});
+
+ if (active_menubar_ == menubar)
+ UpdateActiveTracker();
+
+ return true;
+ }
+
+ bool UnregisterTracker(std::string const& menubar, PositionTracker const& cb)
+ {
+ auto it = position_trackers_.find(menubar);
+
+ if (it == end(position_trackers_))
+ return false;
+
+ if (!cb || (cb && it->second == cb))
+ {
+ position_trackers_.erase(it);
+ UpdateActiveTracker();
+ return true;
+ }
+
+ return false;
+ }
+
+ void UpdateActiveTracker()
+ {
+ auto it = position_trackers_.find(active_menubar_);
+ active_tracker_ = (it != end(position_trackers_)) ? it->second : PositionTracker();
+ pointer_movement_timeout_.reset();
+
+ if (active_tracker_)
+ {
+ if (input::Monitor::Get().RegisterClient(input::Events::POINTER, sigc::mem_fun(this, &Impl::OnActiveEntryEvent)))
+ last_pointer_time_ = 0;
+ }
+ else
+ {
+ input::Monitor::Get().UnregisterClient(sigc::mem_fun(this, &Impl::OnActiveEntryEvent));
+
+ if (it != end(position_trackers_))
+ position_trackers_.erase(it);
+ }
+ }
+
Manager* parent_;
Indicators::Ptr indicators_;
AppmenuIndicator::Ptr appmenu_;
key::Grabber::Ptr key_grabber_;
Window show_now_window_;
+ std::string active_menubar_;
+ PositionTracker active_tracker_;
+ nux::Point tracked_pointer_pos_;
+ Time last_pointer_time_;
+ glib::Source::Ptr pointer_movement_timeout_;
connection::Manager appmenu_connections_;
connection::Wrapper active_win_conn_;
glib::Object<GSettings> settings_;
glib::SignalManager signals_;
+ std::unordered_map<std::string, PositionTracker> position_trackers_;
std::unordered_map<indicator::Entry::Ptr, uint32_t> entry_actions_;
};
@@ -278,5 +428,16 @@ key::Grabber::Ptr const& Manager::KeyGrabber() const
return impl_->key_grabber_;
}
+bool Manager::RegisterTracker(std::string const& menubar, PositionTracker const& cb)
+{
+ return impl_->RegisterTracker(menubar, cb);
+}
+
+bool Manager::UnregisterTracker(std::string const& menubar, PositionTracker const& cb)
+{
+ return impl_->UnregisterTracker(menubar, cb);
+}
+
+
} // menu namespace
} // unity namespace
diff --git a/unity-shared/MenuManager.h b/unity-shared/MenuManager.h
index 20432db73..ad0f177e2 100644
--- a/unity-shared/MenuManager.h
+++ b/unity-shared/MenuManager.h
@@ -67,6 +67,10 @@ public:
key::Grabber::Ptr const& KeyGrabber() const;
+ typedef sigc::slot<void, int /*x*/, int /*y*/, double /*speed*/> PositionTracker;
+ bool RegisterTracker(std::string const& menubar, PositionTracker const&);
+ bool UnregisterTracker(std::string const& menubar, PositionTracker const& = PositionTracker());
+
sigc::signal<void> appmenu_added;
sigc::signal<void> appmenu_removed;
sigc::signal<bool>::accumulated<any_true> open_first;
diff --git a/unity-shared/OverlayRenderer.cpp b/unity-shared/OverlayRenderer.cpp
index 135eaf79c..475ad5e9c 100644
--- a/unity-shared/OverlayRenderer.cpp
+++ b/unity-shared/OverlayRenderer.cpp
@@ -50,6 +50,12 @@ const RawPixel VERTICAL_PADDING = 20_em;
// Now that we mask the corners of the dash,
// draw longer lines to fill the minimal gaps
const RawPixel CORNER_OVERLAP = 3_em;
+
+enum class OverlayPosition
+{
+ LEFT,
+ BOTTOM
+};
}
// Impl class
@@ -82,7 +88,9 @@ public:
nux::ObjectPtr<nux::BaseTexture> right_texture_;
nux::ObjectPtr<nux::BaseTexture> right_texture_mask_;
nux::ObjectPtr<nux::BaseTexture> left_texture_;
- nux::ObjectPtr<nux::BaseTexture> top_bottom_texture_;
+ nux::ObjectPtr<nux::BaseTexture> top_left_texture_;
+ nux::ObjectPtr<nux::BaseTexture> top_texture_;
+ nux::ObjectPtr<nux::BaseTexture> bottom_texture_;
nux::ObjectPtr<nux::BaseTexture> corner_;
nux::ObjectPtr<nux::BaseTexture> corner_mask_;
@@ -120,7 +128,6 @@ OverlayRendererImpl::OverlayRendererImpl(OverlayRenderer *parent_)
parent->scale.changed.connect(sigc::hide(sigc::mem_fun(this, &OverlayRendererImpl::LoadScaledTextures)));
parent->owner_type.changed.connect(sigc::hide(sigc::mem_fun(this, &OverlayRendererImpl::LoadScaledTextures)));
Settings::Instance().low_gfx.changed.connect(sigc::hide(sigc::mem_fun(this, &OverlayRendererImpl::UpdateTextures)));
- Settings::Instance().launcher_position.changed.connect(sigc::hide(sigc::mem_fun(this, &OverlayRendererImpl::LoadScaledTextures)));
dash::Style::Instance().textures_changed.connect(sigc::mem_fun(this, &OverlayRendererImpl::UpdateTextures));
dash::Style::Instance().textures_changed.connect(sigc::mem_fun(this, &OverlayRendererImpl::LoadScaledTextures));
@@ -132,24 +139,21 @@ void OverlayRendererImpl::LoadScaledTextures()
{
double scale = parent->scale;
auto& style = dash::Style::Instance();
- auto dash_position = dash::Position::LEFT;
- if (Settings::Instance().launcher_position() == LauncherPosition::BOTTOM && parent->owner_type() == OverlayOwner::Dash)
- dash_position = dash::Position::BOTTOM;
-
- horizontal_texture_ = style.GetDashHorizontalTile(scale, dash_position);
- horizontal_texture_mask_ = style.GetDashHorizontalTileMask(scale, dash_position);
+ horizontal_texture_ = style.GetDashHorizontalTile(scale);
+ horizontal_texture_mask_ = style.GetDashHorizontalTileMask(scale);
right_texture_ = style.GetDashRightTile(scale);
right_texture_mask_ = style.GetDashRightTileMask(scale);
+ top_left_texture_ = style.GetDashTopLeftTile(scale);
left_texture_ = style.GetDashLeftTile(scale);
- top_bottom_texture_ = style.GetDashTopOrBottomTile(scale, dash_position);
-
- corner_ = style.GetDashCorner(scale, dash_position);
- corner_mask_ = style.GetDashCornerMask(scale, dash_position);
- left_corner_ = style.GetDashLeftCorner(scale, dash_position);
- left_corner_mask_ = style.GetDashLeftCornerMask(scale, dash_position);
- right_corner_ = style.GetDashRightCorner(scale, dash_position);
- right_corner_mask_ = style.GetDashRightCornerMask(scale, dash_position);
+ top_texture_ = style.GetDashTopTile(scale);
+
+ corner_ = style.GetDashCorner(scale);
+ corner_mask_ = style.GetDashCornerMask(scale);
+ left_corner_ = style.GetDashLeftCorner(scale);
+ left_corner_mask_ = style.GetDashLeftCornerMask(scale);
+ right_corner_ = style.GetDashRightCorner(scale);
+ right_corner_mask_ = style.GetDashRightCornerMask(scale);
}
void OverlayRendererImpl::OnBgColorChanged(nux::Color const& new_color)
@@ -610,19 +614,19 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
if (settings.form_factor() != FormFactor::NETBOOK || force_edges)
{
- int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse();
- nux::Geometry const& monitor_geo = unity::UScreen::GetDefault()->GetMonitorGeometry(monitor);
+ int monitor = UScreen::GetDefault()->GetMonitorAtPosition(absolute_geo.x, absolute_geo.y);
+ auto const& monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor);
int launcher_size = Settings::Instance().LauncherSize(monitor);
int panel_height = panel::Style::Instance().PanelHeight(monitor);
- auto dash_position = dash::Position::LEFT;
+ auto dash_position = OverlayPosition::LEFT;
int border_y = content_geo.y;
int border_height = larger_absolute_geo.height;
if (parent->owner_type() == OverlayOwner::Dash && settings.launcher_position() == LauncherPosition::BOTTOM)
{
border_y = panel_height;
border_height = monitor_geo.height - launcher_size;
- dash_position = dash::Position::BOTTOM;
+ dash_position = OverlayPosition::BOTTOM;
}
nux::Geometry geo_border(content_geo.x, border_y, larger_absolute_geo.width - content_geo.x, border_height);
@@ -646,7 +650,13 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
auto const& left_tile = left_texture_;
auto const& right_corner = right_corner_;
auto const& right_corner_mask = right_corner_mask_;
- auto const& top_tile = top_bottom_texture_;
+ auto const& horizontal_tile = top_texture_;
+
+ if (dash_position == OverlayPosition::BOTTOM)
+ {
+ // Let's flip all the textures vertically
+ texxform.flip_v_coord = true;
+ }
int left_corner_offset = LEFT_CORNER_OFFSET.CP(scale);
int top_corner_offset = TOP_CORNER_OFFSET.CP(scale);
@@ -662,7 +672,7 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
int corner_y = geo.y + (geo.height - corner_size.height);
- if (dash_position == dash::Position::BOTTOM)
+ if (dash_position == OverlayPosition::BOTTOM)
corner_y = geo.y - corner_size.height + top_corner_offset;
// Selectively erase blur region in the curbe
@@ -700,19 +710,18 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
{
// Horizontal repeated texture
int real_width = geo.width - (left_corner_size.width - left_corner_offset) - corner_size.width;
- int offset = real_width % horizontal->GetWidth();
int horizontal_y = geo.y + (geo.height - horizontal->GetHeight());
- if (dash_position == dash::Position::BOTTOM)
+ if (dash_position == OverlayPosition::BOTTOM)
horizontal_y = geo.y - horizontal->GetHeight() + top_corner_offset;
texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
// Selectively erase blur region in the curbe
- gfx_context.QRP_ColorModTexAlpha(left_corner_size.width - left_corner_offset - offset,
+ gfx_context.QRP_ColorModTexAlpha(left_corner_size.width - left_corner_offset,
horizontal_y,
- real_width + offset,
+ real_width,
horizontal->GetHeight(),
horizontal_mask->GetDeviceTexture(),
texxform,
@@ -721,9 +730,9 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
// Write correct alpha
gfx_context.GetRenderStates().SetBlend(false);
gfx_context.GetRenderStates().SetColorMask(false, false, false, true);
- RenderInverseMask(gfx_context, left_corner_size.width - left_corner_offset - offset,
+ RenderInverseMask(gfx_context, left_corner_size.width - left_corner_offset,
horizontal_y,
- real_width + offset,
+ real_width,
horizontal->GetHeight(),
horizontal_mask->GetDeviceTexture(),
texxform,
@@ -733,9 +742,9 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
gfx_context.GetRenderStates().SetColorMask(true, true, true, true);
- gfx_context.QRP_1Tex(left_corner_size.width - left_corner_offset - offset,
+ gfx_context.QRP_1Tex(left_corner_size.width - left_corner_offset,
horizontal_y,
- real_width + offset,
+ real_width,
horizontal->GetHeight(),
horizontal->GetDeviceTexture(),
texxform,
@@ -747,10 +756,10 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
int left_corner_y = geo.y + (geo.height - left_corner_size.height);
- if (dash_position == dash::Position::BOTTOM)
+ if (dash_position == OverlayPosition::BOTTOM)
left_corner_y = geo.y - left_corner_size.height + top_corner_offset;
- if (dash_position == dash::Position::LEFT)
+ if (dash_position == OverlayPosition::LEFT)
{
// Selectively erase blur region in the curbe
gfx_context.QRP_ColorModTexAlpha(geo.x - left_corner_offset,
@@ -792,14 +801,14 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
int offset = real_height % left_tile->GetHeight();
int left_texture_y = geo.y + geo.height;
- if (dash_position == dash::Position::BOTTOM)
+ if (dash_position == OverlayPosition::BOTTOM)
{
- left_texture_y = panel_height;
- real_height = monitor_geo.height - launcher_size - content_geo.height - left_corner->GetHeight() - panel_height + top_corner_offset;
+ left_texture_y = panel_height + top_left_texture_->GetHeight();
+ real_height = monitor_geo.height - launcher_size - content_geo.height - left_corner->GetHeight() - panel_height + top_corner_offset - top_left_texture_->GetHeight();
}
else if (settings.launcher_position() == LauncherPosition::BOTTOM)
{
- real_height -= launcher_size;
+ real_height -= launcher_size + top_left_texture_->GetWidth();
}
texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
@@ -819,7 +828,7 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
int right_edge_y = geo.y + right_corner_size.height - top_corner_offset;
- if (dash_position == dash::Position::BOTTOM)
+ if (dash_position == OverlayPosition::BOTTOM)
right_edge_y = geo.y + top_corner_offset;
// Selectively erase blur region in the curbe
@@ -860,7 +869,7 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
int right_corner_y = geo.y - top_corner_offset;
- if (dash_position == dash::Position::BOTTOM)
+ if (dash_position == OverlayPosition::BOTTOM)
right_corner_y = geo.y + content_geo.height - right_corner_size.height + top_corner_offset;
// Selectively erase blur region in the curbe
@@ -900,17 +909,79 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
int y = geo.y - top_corner_offset;
- if (dash_position == dash::Position::BOTTOM)
- y = geo.y + content_geo.height - top_tile->GetHeight() + top_corner_offset;
+ if (dash_position == OverlayPosition::BOTTOM)
+ y = geo.y + content_geo.height - horizontal_tile->GetHeight() + top_corner_offset;
gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
gfx_context.QRP_1Tex(geo.x + geo.width,
y,
geometry.width - (geo.x + geo.width),
- top_tile->GetHeight(),
- top_tile->GetDeviceTexture(),
+ horizontal_tile->GetHeight(),
+ horizontal_tile->GetDeviceTexture(),
texxform,
nux::color::White);
+
+ if (dash_position == OverlayPosition::BOTTOM)
+ {
+ // Top Left edge
+ nux::TexCoordXForm top_texxform;
+ top_texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+ top_texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
+
+ gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
+ gfx_context.QRP_1Tex(0,
+ panel_height,
+ top_left_texture_->GetWidth(),
+ top_left_texture_->GetHeight(),
+ top_left_texture_->GetDeviceTexture(),
+ top_texxform,
+ nux::color::White);
+ // Top edge
+ top_texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+ top_texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
+ gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
+ gfx_context.QRP_1Tex(top_left_texture_->GetWidth(),
+ panel_height - top_corner_offset,
+ monitor_geo.width - top_left_texture_->GetWidth(),
+ horizontal_tile->GetHeight(),
+ horizontal_tile->GetDeviceTexture(),
+ top_texxform,
+ nux::color::White);
+ }
+ else if (settings.launcher_position() == LauncherPosition::BOTTOM)
+ {
+ int above_launcher_y = monitor_geo.height - panel_height - launcher_size;
+ bool was_flipped = texxform.flip_v_coord;
+
+ // Bottom Left edge
+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+ texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
+ texxform.flip_v_coord = true;
+
+ gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
+ gfx_context.QRP_1Tex(0,
+ above_launcher_y - top_left_texture_->GetWidth(),
+ top_left_texture_->GetWidth(),
+ top_left_texture_->GetHeight(),
+ top_left_texture_->GetDeviceTexture(),
+ texxform,
+ nux::color::White);
+
+ // Bottom edge
+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+ texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
+
+ gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
+ gfx_context.QRP_1Tex(top_left_texture_->GetHeight(),
+ above_launcher_y + top_corner_offset - horizontal_tile->GetHeight(),
+ monitor_geo.width - top_left_texture_->GetHeight(),
+ horizontal_tile->GetHeight(),
+ horizontal_tile->GetDeviceTexture(),
+ texxform,
+ nux::color::White);
+
+ texxform.flip_v_coord = was_flipped;
+ }
}
}
diff --git a/unity-shared/PluginAdapter.cpp b/unity-shared/PluginAdapter.cpp
index 1684dbbbe..324bf54b1 100644
--- a/unity-shared/PluginAdapter.cpp
+++ b/unity-shared/PluginAdapter.cpp
@@ -608,7 +608,7 @@ bool PluginAdapter::IsWindowObscured(Window window_id) const
CompPoint window_vp = window->defaultViewport();
// Check if any windows above this one are blocking it
- for (CompWindow* sibling = window->next; sibling != NULL; sibling = sibling->next)
+ for (CompWindow* sibling = window->serverNext; sibling != NULL; sibling = sibling->serverNext)
{
if (sibling->defaultViewport() == window_vp
&& !sibling->minimized()
@@ -630,7 +630,7 @@ bool PluginAdapter::IsWindowMapped(Window window_id) const
CompWindow* window = m_Screen->findWindow(window_id);
if (window)
return window->mapNum () > 0;
- return true;
+ return false;
}
bool PluginAdapter::IsWindowVisible(Window window_id) const
diff --git a/unity-shared/SigcSlotHash.h b/unity-shared/SigcSlotHash.h
new file mode 100644
index 000000000..c7058c3b8
--- /dev/null
+++ b/unity-shared/SigcSlotHash.h
@@ -0,0 +1,70 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
+ */
+
+#ifndef __UNITY_SIGC_SLOT_HASHER__
+#define __UNITY_SIGC_SLOT_HASHER__
+
+#include <sigc++/slot.h>
+
+namespace sigc
+{
+inline bool operator==(slot_base const& lhs, slot_base const& rhs)
+{
+ if (!lhs.rep_ || !rhs.rep_)
+ return (lhs.rep_ == rhs.rep_);
+
+ return (lhs.rep_->call_ == rhs.rep_->call_);
+}
+
+inline bool operator!=(slot_base const& lhs, slot_base const& rhs)
+{
+ return !(lhs == rhs);
+}
+} // sigc namespace
+
+namespace std
+{
+
+template<>
+struct hash<sigc::slot_base>
+{
+ size_t operator()(sigc::slot_base const& cb) const
+ {
+ if (cb.rep_)
+ return hash<size_t>()(reinterpret_cast<size_t>(cb.rep_->call_));
+
+ return hash<size_t>()(reinterpret_cast<size_t>(cb.rep_));
+ }
+};
+
+#if __GNUC__ < 6
+template<class T>
+struct hash
+{
+ size_t operator()(T const& cb) const
+ {
+ static_assert(std::is_base_of<sigc::slot_base, T>::value, "Type is not derived from sigc::slot_base");
+ return hash<sigc::slot_base>()(cb);
+ }
+};
+#endif
+
+} // std namespace
+
+#endif // __UNITY_SIGC_SLOT_HASHER__
diff --git a/unity-shared/SpreadWidgets.cpp b/unity-shared/SpreadWidgets.cpp
new file mode 100644
index 000000000..ba6a2b9f1
--- /dev/null
+++ b/unity-shared/SpreadWidgets.cpp
@@ -0,0 +1,195 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
+*
+* Authored by: Marco Trevisan <marco@ubuntu.com>
+*/
+
+#include "SpreadWidgets.h"
+
+#include "DashStyle.h"
+#include "PanelStyle.h"
+#include "RawPixel.h"
+#include "SearchBar.h"
+#include "UnitySettings.h"
+#include "UScreen.h"
+
+namespace unity
+{
+namespace spread
+{
+namespace
+{
+const RawPixel LEFT_CORNER_OFFSET = 10_em;
+}
+
+class Decorations : public nux::BaseWindow
+{
+public:
+ nux::Property<int> monitor;
+
+ Decorations(int monitor_)
+ : monitor(monitor_)
+ {
+ monitor.changed.connect(sigc::mem_fun(this, &Decorations::Update));
+ SetBackgroundColor(nux::color::Transparent);
+
+ Update(monitor);
+ PushToFront();
+ ShowWindow(true);
+ }
+
+ ~Decorations()
+ {
+ ShowWindow(false);
+ object_destroyed.emit(this);
+ }
+
+ void Update(int monitor)
+ {
+ auto& settings = Settings::Instance();
+ auto abs_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor);
+ int panel_height = panel::Style::Instance().PanelHeight(monitor);
+ int launcher_size = settings.LauncherSize(monitor);
+ scale_ = settings.em(monitor)->DPIScale();
+
+ if (settings.launcher_position() == LauncherPosition::LEFT)
+ {
+ abs_geo.x += launcher_size;
+ abs_geo.width -= launcher_size;
+ }
+ else
+ {
+ abs_geo.height -= launcher_size;
+ }
+
+ abs_geo.y += panel_height;
+ abs_geo.height -= panel_height;
+ SetGeometry(abs_geo);
+
+ auto& dash_style = dash::Style::Instance();
+ corner_tex_ = dash_style.GetDashTopLeftTile(scale_);
+ left_edge_tex_ = dash_style.GetDashLeftTile(scale_);
+ horizontal_tex_ = dash_style.GetDashTopTile(scale_);
+ }
+
+ void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) override
+ {
+ auto const& geo = GetGeometry();
+ auto launcher_position = Settings::Instance().launcher_position();
+ int x_offset = 0;
+
+ nux::TexCoordXForm texxform;
+
+ if (launcher_position == LauncherPosition::LEFT)
+ {
+ // Corner
+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+ texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
+
+ gfx_context.QRP_1Tex(0,
+ 0,
+ corner_tex_->GetWidth(),
+ corner_tex_->GetHeight(),
+ corner_tex_->GetDeviceTexture(),
+ texxform,
+ nux::color::White);
+
+ x_offset = corner_tex_->GetWidth();
+ }
+
+ // Top Edge
+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+ texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
+
+ gfx_context.QRP_1Tex(x_offset,
+ -LEFT_CORNER_OFFSET.CP(scale_),
+ geo.width - x_offset,
+ horizontal_tex_->GetHeight(),
+ horizontal_tex_->GetDeviceTexture(),
+ texxform,
+ nux::color::White);
+
+ if (launcher_position == LauncherPosition::LEFT)
+ {
+ // Left edge
+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+ texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
+
+ gfx_context.QRP_1Tex(-LEFT_CORNER_OFFSET.CP(scale_),
+ corner_tex_->GetHeight(),
+ left_edge_tex_->GetWidth(),
+ geo.height,
+ left_edge_tex_->GetDeviceTexture(),
+ texxform,
+ nux::color::White);
+ }
+ else if (launcher_position == LauncherPosition::BOTTOM)
+ {
+ texxform.flip_v_coord = true;
+
+ // Bottom Edge
+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
+ texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
+
+ gfx_context.QRP_1Tex(0,
+ geo.height - horizontal_tex_->GetHeight() + LEFT_CORNER_OFFSET.CP(scale_),
+ geo.width,
+ horizontal_tex_->GetHeight(),
+ horizontal_tex_->GetDeviceTexture(),
+ texxform,
+ nux::color::White);
+ }
+ }
+
+ double scale_;
+ dash::BaseTexturePtr corner_tex_;
+ dash::BaseTexturePtr left_edge_tex_;
+ dash::BaseTexturePtr horizontal_tex_;
+};
+
+
+Widgets::Widgets()
+ : filter_(std::make_shared<Filter>())
+{
+ auto const& uscreen = UScreen::GetDefault();
+ auto num_monitors = uscreen->GetPluggedMonitorsNumber();
+
+ for (auto i = 0; i < num_monitors; ++i)
+ decos_.push_back(std::make_shared<Decorations>(i));
+
+ uscreen->changed.connect(sigc::track_obj([this] (int, std::vector<nux::Geometry> const& monitors) {
+ auto num_monitors = monitors.size();
+ decos_.reserve(num_monitors);
+
+ while (decos_.size() < num_monitors)
+ decos_.emplace_back(std::make_shared<Decorations>(decos_.size()-1));
+
+ decos_.resize(num_monitors);
+ for (auto i = 0u; i < num_monitors; ++i)
+ {
+ decos_[i]->monitor = i;
+ decos_[i]->monitor.changed.emit(i);
+ }
+ }, *this));
+}
+
+Filter::Ptr Widgets::GetFilter() const
+{
+ return filter_;
+}
+
+} // namespace spread
+} // namespace unity
diff --git a/unity-shared/SpreadWidgets.h b/unity-shared/SpreadWidgets.h
new file mode 100644
index 000000000..44433e424
--- /dev/null
+++ b/unity-shared/SpreadWidgets.h
@@ -0,0 +1,48 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
+*
+* Authored by: Marco Trevisan <marco@ubuntu.com>
+*/
+
+#ifndef UNITYSHELL_SPREAD_WIDGETS_H
+#define UNITYSHELL_SPREAD_WIDGETS_H
+
+#include "SpreadFilter.h"
+
+namespace unity
+{
+namespace spread
+{
+class Decorations;
+
+class Widgets : public sigc::trackable
+{
+public:
+ typedef std::shared_ptr<Widgets> Ptr;
+
+ Widgets();
+
+ Filter::Ptr GetFilter() const;
+
+private:
+ Filter::Ptr filter_;
+ std::vector<std::shared_ptr<Decorations>> decos_;
+};
+
+} // namespace spread
+} // namespace unity
+
+#endif
diff --git a/unity-shared/StandaloneWindowManager.cpp b/unity-shared/StandaloneWindowManager.cpp
index 44aa839d6..43eef13c7 100644
--- a/unity-shared/StandaloneWindowManager.cpp
+++ b/unity-shared/StandaloneWindowManager.cpp
@@ -624,6 +624,9 @@ std::string StandaloneWindowManager::GetStringProperty(Window, Atom) const
return std::string();
}
+void StandaloneWindowManager::SetCardinalProperty(Window, Atom, std::vector<long> const&)
+{}
+
std::vector<long> StandaloneWindowManager::GetCardinalProperty(Window, Atom) const
{
return std::vector<long>();
diff --git a/unity-shared/StandaloneWindowManager.h b/unity-shared/StandaloneWindowManager.h
index 8b2775233..60bb78824 100644
--- a/unity-shared/StandaloneWindowManager.h
+++ b/unity-shared/StandaloneWindowManager.h
@@ -165,6 +165,7 @@ public:
virtual std::string GetWindowName(Window window_id) const;
virtual bool IsOnscreenKeyboard(Window window_id) const;
virtual std::string GetStringProperty(Window window_id, Atom) const;
+ virtual void SetCardinalProperty(Window window_id, Atom, std::vector<long> const&);
virtual std::vector<long> GetCardinalProperty(Window window_id, Atom) const;
// Mock functions
diff --git a/unity-shared/SystemdWrapper.cpp b/unity-shared/SystemdWrapper.cpp
new file mode 100644
index 000000000..f3f294f0b
--- /dev/null
+++ b/unity-shared/SystemdWrapper.cpp
@@ -0,0 +1,96 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+* Copyright © 2016 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 <http://www.gnu.org/licenses/>.
+*
+* Authored by: Ted Gould <ted@canonical.com>
+*/
+
+#include "SystemdWrapper.h"
+
+#include <UnityCore/GLibDBusProxy.h>
+
+namespace unity
+{
+
+//
+// Start private implementation
+//
+
+class SystemdWrapper::Impl
+{
+public:
+ Impl(bool test);
+
+ void Start(std::string const& name);
+ void Stop(std::string const& name);
+ void CallMethod(std::string const& method, std::string const& unit);
+
+private:
+ bool test_mode_;
+ glib::DBusProxy::Ptr systemd_proxy_;
+};
+
+SystemdWrapper::Impl::Impl(bool test)
+ : test_mode_(test)
+{}
+
+void SystemdWrapper::Impl::CallMethod(std::string const& method, std::string const& unit)
+{
+ auto const& busname = test_mode_ ? "com.canonical.Unity.Test.Systemd" : "org.freedesktop.systemd1";
+ auto flags = static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS);
+ auto proxy = std::make_shared<glib::DBusProxy>(busname, "/org/freedesktop/systemd1",
+ "org.freedesktop.systemd1.Manager",
+ G_BUS_TYPE_SESSION, flags);
+
+ proxy->CallBegin(method, g_variant_new("(ss)", unit.c_str(), "replace"), [proxy] (GVariant*, glib::Error const& e) {});
+}
+
+void SystemdWrapper::Impl::Start(std::string const& name)
+{
+ CallMethod("StartUnit", name);
+}
+
+void SystemdWrapper::Impl::Stop(std::string const& name)
+{
+ CallMethod("StopUnit", name);
+}
+
+//
+// End private implementation
+//
+
+SystemdWrapper::SystemdWrapper()
+ : pimpl_(new Impl(false))
+{}
+
+SystemdWrapper::SystemdWrapper(SystemdWrapper::TestMode const& tm)
+ : pimpl_(new Impl(true))
+{}
+
+SystemdWrapper::~SystemdWrapper()
+{}
+
+void SystemdWrapper::Start(std::string const& name)
+{
+ pimpl_->Start(name);
+}
+
+void SystemdWrapper::Stop(std::string const& name)
+{
+ pimpl_->Stop(name);
+}
+
+}
diff --git a/unity-shared/SystemdWrapper.h b/unity-shared/SystemdWrapper.h
new file mode 100644
index 000000000..0bd4ba0e7
--- /dev/null
+++ b/unity-shared/SystemdWrapper.h
@@ -0,0 +1,54 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+* Copyright © 2016 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 <http://www.gnu.org/licenses/>.
+*
+* Authored by: Ted Gould <ted@canonical.com>
+*/
+
+#ifndef UNITY_SYSTEMD_WRAPPER
+#define UNITY_SYSTEMD_WRAPPER
+
+#include <memory>
+
+namespace unity
+{
+
+class SystemdWrapper
+{
+public:
+ typedef std::shared_ptr<SystemdWrapper> Ptr;
+
+ SystemdWrapper();
+ ~SystemdWrapper();
+
+ void Start(std::string const& name);
+ void Stop(std::string const& name);
+
+protected:
+ struct TestMode {};
+ SystemdWrapper(TestMode const&);
+
+private:
+ // Noncopyable
+ SystemdWrapper(SystemdWrapper const&) = delete;
+ SystemdWrapper& operator=(SystemdWrapper const&) = delete;
+
+ class Impl;
+ std::unique_ptr<Impl> pimpl_;
+};
+
+}
+
+#endif
diff --git a/unity-shared/TextInput.cpp b/unity-shared/TextInput.cpp
index 881691e0b..a9ecaa706 100644
--- a/unity-shared/TextInput.cpp
+++ b/unity-shared/TextInput.cpp
@@ -104,7 +104,6 @@ TextInput::TextInput(NUX_FILE_LINE_DECL)
, scale(1.0)
, bg_layer_(new nux::ColorLayer(nux::Color(0xff595853), true))
, caps_lock_on(false)
- , num_lock_on(false)
, last_width_(-1)
, last_height_(-1)
{
@@ -146,9 +145,8 @@ TextInput::TextInput(NUX_FILE_LINE_DECL)
// Caps lock warning
warning_ = new IconTexture(LoadWarningIcon(DEFAULT_ICON_SIZE.CP(scale)));
- warning_->SetVisible(caps_lock_on() || num_lock_on());
+ warning_->SetVisible(caps_lock_on());
layout_->AddView(warning_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
- num_lock_on.changed.connect(sigc::mem_fun(this, &TextInput::OnLockStateChanged));
caps_lock_on.changed.connect(sigc::mem_fun(this, &TextInput::OnLockStateChanged));
show_lock_warnings.changed.connect(sigc::hide(sigc::mem_fun(this, &TextInput::CheckLocks)));
@@ -249,7 +247,6 @@ void TextInput::CheckLocks()
{
GdkKeymap* keymap = gdk_keymap_get_default();
caps_lock_on = gdk_keymap_get_caps_lock_state(keymap) ? true : false;
- num_lock_on = gdk_keymap_get_num_lock_state(keymap) ? true : false;
}
void TextInput::OnLockStateChanged(bool)
@@ -260,8 +257,8 @@ void TextInput::OnLockStateChanged(bool)
return;
}
- warning_->SetVisible(caps_lock_on() || num_lock_on());
- warning_->SetOpacity((num_lock_on() && !caps_lock_on()) ? 0.3 : 1.0);
+ warning_->SetVisible(caps_lock_on());
+ warning_->SetOpacity(1.0);
warning_tooltip_.Release();
QueueRelayout();
QueueDraw();
@@ -345,18 +342,10 @@ void TextInput::LoadWarningTooltip()
pango_layout_set_height(layout, -1); //avoid wrap lines
- if (caps_lock_on() && num_lock_on())
- {
- pango_layout_set_text(layout, _("Caps lock and Num lock are on"), -1);
- }
- else if (caps_lock_on())
+ if (caps_lock_on())
{
pango_layout_set_text(layout, _("Caps lock is on"), -1);
}
- else if (num_lock_on())
- {
- pango_layout_set_text(layout, _("Num lock is on"), -1);
- }
nux::Size extents;
pango_layout_get_pixel_size(layout, &extents.width, &extents.height);
diff --git a/unity-shared/TextInput.h b/unity-shared/TextInput.h
index 1df5f1862..3967fe2e6 100644
--- a/unity-shared/TextInput.h
+++ b/unity-shared/TextInput.h
@@ -124,7 +124,6 @@ private:
SearchBarSpinner* spinner_;
nux::Property<bool> caps_lock_on;
- nux::Property<bool> num_lock_on;
int last_width_;
int last_height_;
diff --git a/unity-shared/UScreen.cpp b/unity-shared/UScreen.cpp
index 6165ddf8b..c3f47b3f1 100644
--- a/unity-shared/UScreen.cpp
+++ b/unity-shared/UScreen.cpp
@@ -88,6 +88,11 @@ nux::Geometry const& UScreen::GetMonitorGeometry(int monitor) const
return monitors_[monitor];
}
+nux::Size const& UScreen::GetMonitorPhysicalSize(int monitor) const
+{
+ return physical_monitors_[monitor];
+}
+
std::vector<nux::Geometry> const& UScreen::GetMonitors() const
{
return monitors_;
@@ -154,6 +159,7 @@ void UScreen::Refresh()
nux::Geometry last_geo;
monitors_.clear();
+ physical_monitors_.clear();
primary_ = gdk_screen_get_primary_monitor(screen_);
int monitors = gdk_screen_get_n_monitors(screen_);
@@ -164,6 +170,9 @@ void UScreen::Refresh()
float scale = gdk_screen_get_monitor_scale_factor(screen_, i);
nux::Geometry geo(rect.x, rect.y, rect.width, rect.height);
+
+ nux::Size physical_size(gdk_screen_get_monitor_width_mm(screen_, i),
+ gdk_screen_get_monitor_height_mm(screen_, i));
if (scale != 1.0)
geo = geo * scale;
@@ -174,6 +183,7 @@ void UScreen::Refresh()
last_geo = geo;
monitors_.push_back(geo);
+ physical_monitors_.push_back(physical_size);
LOG_DEBUG(logger) << "Monitor " << i << " has geometry " << geo.x << "x"
<< geo.y << "x" << geo.width << "x" << geo.height;
diff --git a/unity-shared/UScreen.h b/unity-shared/UScreen.h
index 52f1899e0..527ea90a1 100644
--- a/unity-shared/UScreen.h
+++ b/unity-shared/UScreen.h
@@ -45,6 +45,7 @@ public:
int GetMonitorWithMouse() const;
int GetMonitorAtPosition(int x, int y) const;
nux::Geometry const& GetMonitorGeometry(int monitor) const;
+ nux::Size const& GetMonitorPhysicalSize(int monitor) const;
std::vector<nux::Geometry> const& GetMonitors() const;
nux::Geometry GetScreenGeometry() const;
@@ -63,6 +64,7 @@ private:
protected:
static UScreen* default_screen_;
std::vector<nux::Geometry> monitors_;
+ std::vector<nux::Size> physical_monitors_;
int primary_;
private:
diff --git a/unity-shared/UnitySettings.cpp b/unity-shared/UnitySettings.cpp
index 6bc7cc3e1..2811f2e04 100644
--- a/unity-shared/UnitySettings.cpp
+++ b/unity-shared/UnitySettings.cpp
@@ -76,6 +76,8 @@ const int DEFAULT_LAUNCHER_SIZE = 64;
const int MINIMUM_DESKTOP_HEIGHT = 800;
const int GNOME_SETTINGS_CHANGED_WAIT_SECONDS = 1;
const double DEFAULT_DPI = 96.0f;
+const double DPI_SCALING_LIMIT = 140.0f;
+const int DPI_SCALING_STEP = 8;
}
//
@@ -322,6 +324,34 @@ public:
return em_converters_[monitor];
}
+ int FindOptimalScale(const UScreen* uscreen, const int monitor)
+ {
+ auto const& geo = uscreen->GetMonitorGeometry(monitor);
+ auto const& size = uscreen->GetMonitorPhysicalSize(monitor);
+ auto scale = DPI_SCALING_STEP;
+
+ if ((size.width == 160 && size.height == 90) ||
+ (size.width == 160 && size.height == 100) ||
+ (size.width == 16 && size.height == 9) ||
+ (size.width == 16 && size.height == 10))
+ {
+ return scale;
+ }
+
+ if (size.width > 0 && size.height > 0)
+ {
+ const double dpi_x = static_cast<double>(geo.width) / (size.width / 25.4);
+ const double dpi_y = static_cast<double>(geo.height) / (size.height / 25.4);
+
+ const auto dpi = std::max(dpi_x, dpi_y);
+
+ if (dpi > DPI_SCALING_LIMIT)
+ scale = static_cast<int>(std::lround(scale * dpi / DPI_SCALING_LIMIT));
+ }
+
+ return scale;
+ }
+
void UpdateDPI()
{
auto* uscreen = UScreen::GetDefault();
@@ -332,6 +362,10 @@ public:
glib::Variant dict;
g_settings_get(ubuntu_ui_settings_, SCALE_FACTOR.c_str(), "@a{si}", &dict);
+ bool dict_changed = false;
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("a{si}"));
+
glib::String app_target_monitor(g_settings_get_string(ui_settings_, APP_SCALE_MONITOR.c_str()));
double app_target_scale = 0;
@@ -345,8 +379,18 @@ public:
double ui_scale = 1.0f;
int value;
- if (g_variant_lookup(dict, monitor_name.c_str(), "i", &value) && value > 0)
- ui_scale = static_cast<double>(value)/8.0f;
+ if (g_variant_lookup(dict, monitor_name.c_str(), "i", &value))
+ {
+ if (value > 0)
+ ui_scale = static_cast<double>(value)/DPI_SCALING_STEP;
+ }
+ else
+ {
+ value = FindOptimalScale(uscreen, monitor);
+ ui_scale = static_cast<double>(value)/DPI_SCALING_STEP;
+ dict_changed = true;
+ }
+ g_variant_builder_add(&builder, "{si}", monitor_name.c_str(), value);
if (app_target_monitor.Str() == monitor_name)
app_target_scale = ui_scale;
@@ -360,6 +404,12 @@ public:
any_changed = true;
}
+ glib::Variant new_dict(g_variant_builder_end(&builder));
+ if (dict_changed)
+ {
+ g_settings_set_value(ubuntu_ui_settings_, SCALE_FACTOR.c_str(), new_dict);
+ }
+
if (app_target_scale == 0)
app_target_scale = (g_settings_get_boolean(ui_settings_, APP_USE_MAX_SCALE.c_str())) ? max_scale : min_scale;
diff --git a/unity-shared/UnityWindowView.cpp b/unity-shared/UnityWindowView.cpp
index caea09709..507548cbb 100644
--- a/unity-shared/UnityWindowView.cpp
+++ b/unity-shared/UnityWindowView.cpp
@@ -145,7 +145,12 @@ void UnityWindowView::OnClosableChanged(bool closable)
{
if (!closable)
{
- close_button_ = nullptr;
+ if (close_button_)
+ {
+ close_button_->UnParentObject();
+ close_button_ = nullptr;
+ }
+
return;
}
diff --git a/unity-shared/UpstartWrapper.cpp b/unity-shared/UpstartWrapper.cpp
index ea2cd4650..284668b41 100644
--- a/unity-shared/UpstartWrapper.cpp
+++ b/unity-shared/UpstartWrapper.cpp
@@ -37,18 +37,23 @@ public:
void Emit(std::string const& name);
private:
- glib::DBusProxy::Ptr upstart_proxy_;
+ bool test_mode_;
};
UpstartWrapper::Impl::Impl(bool test_mode)
-{
- upstart_proxy_ = std::make_shared<unity::glib::DBusProxy>(test_mode ? "com.canonical.Unity.Test.Upstart" : DBUS_SERVICE_UPSTART,
- DBUS_PATH_UPSTART, DBUS_INTERFACE_UPSTART);
-}
+ : test_mode_(test_mode)
+{}
void UpstartWrapper::Impl::Emit(std::string const& name)
{
- upstart_proxy_->Call("EmitEvent", g_variant_new("(sasb)", name.c_str(), nullptr, 0));
+ auto flags = static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS);
+
+ auto proxy = std::make_shared<unity::glib::DBusProxy>(test_mode_ ? "com.canonical.Unity.Test.Upstart" : DBUS_SERVICE_UPSTART,
+ DBUS_PATH_UPSTART, DBUS_INTERFACE_UPSTART,
+ G_BUS_TYPE_SESSION, flags);
+
+ proxy->CallBegin("EmitEvent", g_variant_new("(sasb)", name.c_str(), nullptr, 0), [proxy] (GVariant*, glib::Error const&) {});
}
//
diff --git a/unity-shared/WindowButtons.cpp b/unity-shared/WindowButtons.cpp
index af2bf512e..bd88aaf1d 100644
--- a/unity-shared/WindowButtons.cpp
+++ b/unity-shared/WindowButtons.cpp
@@ -420,10 +420,23 @@ void WindowButtons::OnRestoreClicked(nux::Button *button)
{
WindowManager& wm = WindowManager::Default();
Window to_restore = controlled_window();
+ int button = nux::GetGraphicsDisplay()->GetCurrentEvent().GetEventButton();
wm.Raise(to_restore);
wm.Activate(to_restore);
- wm.Restore(to_restore);
+
+ if (button == nux::NUX_MOUSE_BUTTON1)
+ {
+ wm.Restore(to_restore);
+ }
+ else if (button == nux::NUX_MOUSE_BUTTON2)
+ {
+ wm.VerticallyMaximize(to_restore);
+ }
+ else if (button == nux::NUX_MOUSE_BUTTON3)
+ {
+ wm.HorizontallyMaximize(to_restore);
+ }
}
restore_clicked.emit();
diff --git a/unity-shared/WindowManager.h b/unity-shared/WindowManager.h
index 3502941d0..cb38aea77 100644
--- a/unity-shared/WindowManager.h
+++ b/unity-shared/WindowManager.h
@@ -170,6 +170,7 @@ public:
virtual bool IsOnscreenKeyboard(Window window_id) const = 0;
virtual std::string GetStringProperty(Window, Atom) const = 0;
+ virtual void SetCardinalProperty(Window, Atom, std::vector<long> const&) = 0;
virtual std::vector<long> GetCardinalProperty(Window, Atom) const = 0;
virtual Cursor GetCachedCursor(unsigned int cursor_name) const = 0;
diff --git a/unity-shared/XWindowManager.cpp b/unity-shared/XWindowManager.cpp
index 71b20ffd6..d6222f8b8 100644
--- a/unity-shared/XWindowManager.cpp
+++ b/unity-shared/XWindowManager.cpp
@@ -123,6 +123,12 @@ std::string XWindowManager::GetStringProperty(Window window_id, Atom atom) const
return std::string(val, n_items);
}
+void XWindowManager::SetCardinalProperty(Window window_id, Atom atom, std::vector<long> const& values)
+{
+ XChangeProperty(screen->dpy(), window_id, atom, XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) values.data(), values.size());
+}
+
std::vector<long> XWindowManager::GetCardinalProperty(Window window_id, Atom atom) const
{
Atom type;
diff --git a/unity-shared/XWindowManager.h b/unity-shared/XWindowManager.h
index 211d92029..f6c4bbd04 100644
--- a/unity-shared/XWindowManager.h
+++ b/unity-shared/XWindowManager.h
@@ -36,6 +36,7 @@ public:
std::string GetWindowName(Window window_id) const;
bool IsOnscreenKeyboard(Window window_id) const;
std::string GetStringProperty(Window window_id, Atom atom) const;
+ void SetCardinalProperty(Window, Atom, std::vector<long> const&);
std::vector<long> GetCardinalProperty(Window, Atom) const;
};