diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-09-06 19:37:50 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-09-06 19:37:50 +0200 |
| commit | 35ab8dbc68d5f4d6a0cdf145486d740bbd901357 (patch) | |
| tree | 7f4fe287b56ec29dec2c9bf2720049b805611390 | |
| parent | 701a4206b2932b00ee79e8d61f3157139ef32c4b (diff) | |
| parent | b22ddf542ece6ee86d9b29b69cb53b234d74db11 (diff) | |
Merging with lp:~3v1n0/unity/systemd-unit-fixes
(bzr r3788.10.6)
65 files changed, 886 insertions, 332 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c14aa4674..90c5998b4 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,7 +203,7 @@ endif() # # Enable or disable boot logging -# +# option (BOOT_LOGGER "Enable startup performance logging" OFF) if (BOOT_LOGGER) SET (BOOT_LOGGER_FLAG "-DENABLE_LOGGER") @@ -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 @@ -361,46 +361,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,19 +390,3 @@ if (DOXYGEN_FOUND STREQUAL "YES") ADDITIONAL_MAKE_CLEAN_FILES api-doc) endif (DOXYGEN_FOUND STREQUAL "YES") - -# -# 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/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 4c59ece30..5f87fed8f 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) @@ -130,7 +132,9 @@ GnomeManager::Impl::Impl(GnomeManager* manager, bool test_mode) { 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 +170,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) { @@ -374,7 +379,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 +398,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 +418,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 +440,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 +459,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/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/unity7.conf.in b/data/unity7.conf.in index cd3a8816f..1c1958243 100644 --- a/unity7.conf.in +++ b/data/unity7.conf.in @@ -4,7 +4,10 @@ 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 exec @CMAKE_INSTALL_LIBDIR@/unity/unity-compiz-profile-select +pre-start script + @UNITY_LIBDIR@/upstart-prestart-check + @UNITY_LIBDIR@/compiz-profile-selector +end script respawn exec compiz diff --git a/unity7.override b/data/unity7.override index 2905494b6..2905494b6 100644 --- a/unity7.override +++ b/data/unity7.override diff --git a/unity7.service.in b/data/unity7.service.in index cec854387..36dc2aa6a 100644 --- a/unity7.service.in +++ b/data/unity7.service.in @@ -6,6 +6,10 @@ 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 -ExecStart.Pre=@CMAKE_INSTALL_LIBDIR@/unity/unity-compiz-profile-select Restart=on-failure + +[Install] +RequiredBy=ubuntu-session.target diff --git a/debian/changelog b/debian/changelog index 389971565..c366a2dc3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,63 @@ +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) ] diff --git a/debian/control b/debian/control index 6b99e10ee..4185f499c 100644 --- a/debian/control +++ b/debian/control @@ -37,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), diff --git a/debian/unity.install b/debian/unity.install index d963f41d8..208f0b6ec 100644 --- a/debian/unity.install +++ b/debian/unity.install @@ -2,9 +2,10 @@ etc/pam.d usr/bin usr/lib/*/compiz/libunity*.so usr/lib/*/unity/unity-active-plugins-safety-check -usr/lib/*/unity/unity-compiz-profile-select +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/lib/systemd/user/unity7.service 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/launcher/EdgeBarrierController.cpp b/launcher/EdgeBarrierController.cpp index cd71ccd6f..42d509eb3 100644 --- a/launcher/EdgeBarrierController.cpp +++ b/launcher/EdgeBarrierController.cpp @@ -39,8 +39,6 @@ namespace int const X_BREAK_BUFFER = 20; } -DECLARE_LOGGER(logger, "unity.edge_barrier_controller"); - EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) : edge_overcome_pressure_(0) , parent_(parent) 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 3dcf05cb7..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,6 +217,8 @@ 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() diff --git a/lockscreen/LockScreenController.cpp b/lockscreen/LockScreenController.cpp index 801bcf536..6d6f6c0c0 100644 --- a/lockscreen/LockScreenController.cpp +++ b/lockscreen/LockScreenController.cpp @@ -42,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 { @@ -132,7 +133,7 @@ Controller::Controller(DBusManager::Ptr const& dbus_manager, shields_.clear(); upstart_wrapper_->Emit("desktop-unlock"); - systemd_wrapper_->Stop("unity-screen-locked.target"); + systemd_wrapper_->Stop(SYSTEMD_LOCK_TARGET); accelerator_controller_.reset(); menu_manager_.reset(); } @@ -466,7 +467,7 @@ void Controller::LockScreen() { menu_manager_ = std::make_shared<menu::Manager>(std::make_shared<indicator::LockScreenDBusIndicators>(), key_grabber_); upstart_wrapper_->Emit("desktop-lock"); - systemd_wrapper_->Stop("unity-screen-locked.target"); + 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/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/PanelMenuView.cpp b/panel/PanelMenuView.cpp index 8860a085e..2bcdd494c 100644 --- a/panel/PanelMenuView.cpp +++ b/panel/PanelMenuView.cpp @@ -723,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 diff --git a/panel/PanelView.cpp b/panel/PanelView.cpp index 973bde072..cd08c46cd 100644 --- a/panel/PanelView.cpp +++ b/panel/PanelView.cpp @@ -43,7 +43,7 @@ namespace { const RawPixel TRIANGLE_THRESHOLD = 5_em; const double SCRUB_VELOCITY_THRESHOLD = 0.05; -const int refine_gradient_midpoint = 959; +const RawPixel REFINE_GRADIENT_MIDPOINT = 959; } @@ -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_); @@ -755,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/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 48cd2edd4..ca920df0c 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -570,8 +570,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); @@ -579,7 +579,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()) { @@ -610,7 +610,7 @@ void UnityScreen::OnInitiateSpread() void UnityScreen::OnTerminateSpread() { - spread_filter_.reset(); + spread_widgets_.reset(); for (auto const& swin : sScreen->getWindows()) UnityWindow::get(swin->window)->OnTerminateSpread(); @@ -1745,7 +1745,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) @@ -1857,8 +1857,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) { @@ -1941,8 +1946,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) { @@ -2018,12 +2028,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 = ""; } } @@ -2072,7 +2082,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 && @@ -3463,6 +3473,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); } @@ -4777,7 +4788,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 262bd4c23..43df66e72 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -70,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" @@ -342,7 +342,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_; /* Subscription for gestures that manipulate Unity launcher */ std::unique_ptr<nux::GesturesSubscription> gestures_sub_launcher_; diff --git a/resources/dash_bottom_right_corner_rotated.png b/resources/dash_bottom_right_corner_rotated.png Binary files differdeleted file mode 100644 index ec458a101..000000000 --- a/resources/dash_bottom_right_corner_rotated.png +++ /dev/null diff --git a/resources/dash_bottom_right_corner_rotated_mask.png b/resources/dash_bottom_right_corner_rotated_mask.png Binary files differdeleted file mode 100644 index a0b8fe006..000000000 --- a/resources/dash_bottom_right_corner_rotated_mask.png +++ /dev/null diff --git a/resources/dash_bottom_tile.png b/resources/dash_bottom_tile.png Binary files differdeleted file mode 100644 index 963a034df..000000000 --- a/resources/dash_bottom_tile.png +++ /dev/null diff --git a/resources/dash_top_border_tile.png b/resources/dash_top_border_tile.png Binary files differdeleted file mode 100644 index a90e10432..000000000 --- a/resources/dash_top_border_tile.png +++ /dev/null diff --git a/resources/dash_top_border_tile_mask.png b/resources/dash_top_border_tile_mask.png Binary files differdeleted file mode 100644 index bc030c827..000000000 --- a/resources/dash_top_border_tile_mask.png +++ /dev/null diff --git a/resources/dash_top_left_corner.png b/resources/dash_top_left_corner.png Binary files differdeleted file mode 100644 index c3b8de33d..000000000 --- a/resources/dash_top_left_corner.png +++ /dev/null diff --git a/resources/dash_top_left_corner_mask.png b/resources/dash_top_left_corner_mask.png Binary files differdeleted file mode 100644 index 7f9e7e0c3..000000000 --- a/resources/dash_top_left_corner_mask.png +++ /dev/null diff --git a/resources/dash_top_right_corner_rotated.png b/resources/dash_top_right_corner_rotated.png Binary files differdeleted file mode 100644 index 7d2a1337e..000000000 --- a/resources/dash_top_right_corner_rotated.png +++ /dev/null diff --git a/resources/dash_top_right_corner_rotated_mask.png b/resources/dash_top_right_corner_rotated_mask.png Binary files differdeleted file mode 100644 index b17cf351e..000000000 --- a/resources/dash_top_right_corner_rotated_mask.png +++ /dev/null diff --git a/resources/overlay_top_left_tile.png b/resources/overlay_top_left_tile.png Binary files differnew file mode 100644 index 000000000..19157c277 --- /dev/null +++ b/resources/overlay_top_left_tile.png diff --git a/services/CMakeLists.txt b/services/CMakeLists.txt index 49b3d2f26..de866c108 100644 --- a/services/CMakeLists.txt +++ b/services/CMakeLists.txt @@ -51,7 +51,7 @@ 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) 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.service.in b/services/unity-panel-service-lockscreen.service.in index 970b3b5d6..d2398e03a 100644 --- a/services/unity-panel-service-lockscreen.service.in +++ b/services/unity-panel-service-lockscreen.service.in @@ -3,5 +3,6 @@ Description=Backing Service for the Unity Panel in Lockscreen mode PartOf=unity-screen-locked.target [Service] -ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service --lockscreen-mode +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.service.in b/services/unity-panel-service.service.in index 858076e9b..f15ec7c99 100644 --- a/services/unity-panel-service.service.in +++ b/services/unity-panel-service.service.in @@ -5,5 +5,6 @@ PartOf=graphical-session.target BindsTo=indicators-pre.target [Service] -ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-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 index 3eb0f25e6..fb0a1f6e1 100644 --- a/services/unity-screen-locked.target +++ b/services/unity-screen-locked.target @@ -1,4 +1,5 @@ [Unit] Description=A target that, when running, represents the screen being locked -Wants=ubuntu-panel-service-lock.service +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/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp index 7faea517c..6a335bf8c 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" @@ -286,6 +287,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_; diff --git a/tests/test_systemd_wrapper.cpp b/tests/test_systemd_wrapper.cpp index f5feff1bd..30d5f9f76 100644 --- a/tests/test_systemd_wrapper.cpp +++ b/tests/test_systemd_wrapper.cpp @@ -60,7 +60,6 @@ struct TestSystemdWrapper : public Test systemd_server_->AddObjects(SYSTEMD, "/org/freedesktop/systemd1"); Utils::WaitUntilMSec([this] { return systemd_server_->IsConnected(); }); - Utils::WaitUntilMSec([this] { return systemd_wrapper_.IsConnected(); }); } unity::glib::DBusServer::Ptr systemd_server_; diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index cd2eb0c91..a9a5bc283 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,7 +1,7 @@ # # 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 @@ -27,7 +27,10 @@ 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 ${CMAKE_INSTALL_LIBDIR}/unity/) +install(TARGETS unity-active-plugins-safety-check DESTINATION ${UNITY_INSTALL_LIBDIR}) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/unity-compiz-profile-select.in ${CMAKE_CURRENT_BINARY_DIR}/unity-compiz-profile-select @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-compiz-profile-select DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/) +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-compiz-profile-select.in b/tools/unity-compiz-profile-select.in deleted file mode 100755 index e3ab7e59c..000000000 --- a/tools/unity-compiz-profile-select.in +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# 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" -systemctl set-environment --user COMPIZ_CONFIG_PROFILE="$compiz_profile" - -export COMPIZ_CONFIG_PROFILE="$compiz_profile" -exec @CMAKE_INSTALL_LIBDIR@/unity/unity-active-plugins-safety-check diff --git a/tools/unity.cmake b/tools/unity.cmake index 7be8f7d14..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")) @@ -74,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)''' @@ -108,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) @@ -128,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): @@ -144,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: @@ -199,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/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 14a72486f..b0ac7b12c 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -58,6 +58,7 @@ set (UNITY_SHARED_SOURCES SearchBar.cpp SearchBarSpinner.cpp SpreadFilter.cpp + SpreadWidgets.cpp StaticCairoText.cpp SystemdWrapper.cpp TextureCache.cpp 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 index 8541a6a4b..465c5afad 100644 --- a/unity-shared/InputMonitor.cpp +++ b/unity-shared/InputMonitor.cpp @@ -257,6 +257,10 @@ struct Monitor::Impl 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_) @@ -266,12 +270,14 @@ struct Monitor::Impl }, 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"; } } diff --git a/unity-shared/InputMonitor.h b/unity-shared/InputMonitor.h index 3a8fb37f3..23ff8ceff 100644 --- a/unity-shared/InputMonitor.h +++ b/unity-shared/InputMonitor.h @@ -46,7 +46,7 @@ public: static Monitor& Get(); Monitor(); - virtual ~Monitor(); + ~Monitor(); bool RegisterClient(Events, EventCallback const&); bool UnregisterClient(EventCallback const&); 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 e439ca332..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() 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/SystemdWrapper.cpp b/unity-shared/SystemdWrapper.cpp index 6df7c9b3f..f3f294f0b 100644 --- a/unity-shared/SystemdWrapper.cpp +++ b/unity-shared/SystemdWrapper.cpp @@ -1,4 +1,4 @@ -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 3 -*- +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* * Copyright © 2016 Canonical Ltd * @@ -35,39 +35,37 @@ public: void Start(std::string const& name); void Stop(std::string const& name); - bool IsConnected(); + void CallMethod(std::string const& method, std::string const& unit); private: + bool test_mode_; glib::DBusProxy::Ptr systemd_proxy_; }; SystemdWrapper::Impl::Impl(bool test) -{ - std::string busname = "org.freedesktop.systemd1"; - if (test) { - busname = "com.canonical.Unity.Test.Systemd"; - } + : test_mode_(test) +{} - systemd_proxy_ = std::make_shared<unity::glib::DBusProxy>(busname, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager"); +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) { - if (IsConnected()) { - systemd_proxy_->Call("StartUnit", g_variant_new("(ss)", name.c_str(), "replace")); - } + CallMethod("StartUnit", name); } void SystemdWrapper::Impl::Stop(std::string const& name) { - if (IsConnected()) { - systemd_proxy_->Call("StopUnit", g_variant_new("(ss)", name.c_str(), "replace")); - } -} - -bool SystemdWrapper::Impl::IsConnected() -{ - return systemd_proxy_->IsConnected(); + CallMethod("StopUnit", name); } // @@ -95,9 +93,4 @@ void SystemdWrapper::Stop(std::string const& name) pimpl_->Stop(name); } -bool SystemdWrapper::IsConnected() -{ - return pimpl_->IsConnected(); -} - } diff --git a/unity-shared/SystemdWrapper.h b/unity-shared/SystemdWrapper.h index ddfb4a25e..0bd4ba0e7 100644 --- a/unity-shared/SystemdWrapper.h +++ b/unity-shared/SystemdWrapper.h @@ -35,7 +35,6 @@ public: void Start(std::string const& name); void Stop(std::string const& name); - bool IsConnected(); protected: struct TestMode {}; 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(); |
