diff options
| author | Eleni Maria Stea <elenimaria.stea@canonical.com> | 2017-04-05 10:28:47 +0300 |
|---|---|---|
| committer | Eleni Maria Stea <elenimaria.stea@canonical.com> | 2017-04-05 10:28:47 +0300 |
| commit | fcb883d86aa33c453fa1a9b49b75b8313223d6e6 (patch) | |
| tree | f4d51e165635a8af1aac229a1c16d22ecb367c62 | |
| parent | b7c9ac619b20a7643dc44dc1f71be9d4981e8388 (diff) | |
| parent | 7a43ed4dae7aa26df2e555e7c706b99efeecf153 (diff) | |
merged to trunk
(bzr r4213.3.13)
| -rw-r--r-- | UnityCore/GLibDBusProxy.cpp | 20 | ||||
| -rw-r--r-- | UnityCore/GLibDBusProxy.h | 4 | ||||
| -rw-r--r-- | UnityCore/GnomeSessionManager.cpp | 59 | ||||
| -rw-r--r-- | UnityCore/GnomeSessionManager.h | 1 | ||||
| -rw-r--r-- | UnityCore/GnomeSessionManagerImpl.h | 2 | ||||
| -rw-r--r-- | UnityCore/SessionManager.h | 1 | ||||
| -rw-r--r-- | data/com.canonical.Unity.gschema.xml | 2 | ||||
| -rw-r--r-- | data/unity7.service.in | 3 | ||||
| -rw-r--r-- | debian/changelog | 40 | ||||
| -rw-r--r-- | lockscreen/BackgroundSettings.cpp | 17 | ||||
| -rw-r--r-- | lockscreen/LockScreenBaseShield.cpp | 1 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 83 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 6 | ||||
| -rw-r--r-- | shutdown/StandaloneSession.cpp | 1 | ||||
| -rw-r--r-- | tests/test_mock_session_manager.h | 1 | ||||
| -rw-r--r-- | unity-shared/BackgroundEffectHelper.cpp | 3 | ||||
| -rw-r--r-- | unity-shared/InputMonitor.cpp | 11 | ||||
| -rw-r--r-- | unity-shared/MenuManager.cpp | 11 | ||||
| -rw-r--r-- | unity-shared/SystemdWrapper.cpp | 1 | ||||
| -rw-r--r-- | unity-shared/UnitySettings.cpp | 4 |
20 files changed, 203 insertions, 68 deletions
diff --git a/UnityCore/GLibDBusProxy.cpp b/UnityCore/GLibDBusProxy.cpp index 7e89f6ddf..4d2b12594 100644 --- a/UnityCore/GLibDBusProxy.cpp +++ b/UnityCore/GLibDBusProxy.cpp @@ -609,7 +609,7 @@ glib::Variant DBusProxy::GetProperty(std::string const& name) const return nullptr; } -void DBusProxy::GetProperty(std::string const& name, ReplyCallback const& callback) +void DBusProxy::GetProperty(std::string const& name, ReplyCallback const& callback, GCancellable *cancellable) { if (!callback) return; @@ -620,7 +620,8 @@ void DBusProxy::GetProperty(std::string const& name, ReplyCallback const& callba pimpl->name_.c_str(), pimpl->object_path_.c_str(), "org.freedesktop.DBus.Properties", "Get", g_variant_new ("(ss)", pimpl->interface_name_.c_str(), name.c_str()), - G_VARIANT_TYPE("(v)"), G_DBUS_CALL_FLAGS_NONE, -1, pimpl->cancellable_, + G_VARIANT_TYPE("(v)"), G_DBUS_CALL_FLAGS_NONE, -1, + cancellable ? cancellable : pimpl->cancellable_, [] (GObject *source, GAsyncResult *res, gpointer user_data) { glib::Error err; std::unique_ptr<ReplyCallback> callback(static_cast<ReplyCallback*>(user_data)); @@ -641,15 +642,16 @@ void DBusProxy::GetProperty(std::string const& name, ReplyCallback const& callba else { // This will get the property as soon as we have a connection + glib::Object<GCancellable> canc(cancellable, AddRef()); auto conn = std::make_shared<sigc::connection>(); - *conn = connected.connect([this, conn, name, callback] { - GetProperty(name, callback); + *conn = connected.connect([this, conn, name, callback, canc] { + GetProperty(name, callback, canc); conn->disconnect(); }); } } -void DBusProxy::SetProperty(std::string const& name, GVariant* value) +void DBusProxy::SetProperty(std::string const& name, GVariant* value, GCancellable *cancellable) { if (IsConnected()) { @@ -657,7 +659,8 @@ void DBusProxy::SetProperty(std::string const& name, GVariant* value) pimpl->name_.c_str(), pimpl->object_path_.c_str(), "org.freedesktop.DBus.Properties", "Set", g_variant_new ("(ssv)", pimpl->interface_name_.c_str(), name.c_str(), value), - nullptr, G_DBUS_CALL_FLAGS_NONE, -1, pimpl->cancellable_, + nullptr, G_DBUS_CALL_FLAGS_NONE, -1, + cancellable ? cancellable : pimpl->cancellable_, [] (GObject *source, GAsyncResult *res, gpointer user_data) { glib::Error err; Variant result(g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), res, &err), StealRef()); @@ -670,9 +673,10 @@ void DBusProxy::SetProperty(std::string const& name, GVariant* value) else { // This will set the property as soon as we have a connection + glib::Object<GCancellable> canc(cancellable, AddRef()); auto conn = std::make_shared<sigc::connection>(); - *conn = connected.connect([this, conn, name, value] { - SetProperty(name, value); + *conn = connected.connect([this, conn, name, value, canc] { + SetProperty(name, value, canc); conn->disconnect(); }); } diff --git a/UnityCore/GLibDBusProxy.h b/UnityCore/GLibDBusProxy.h index 1ead7a32c..f0eb777f3 100644 --- a/UnityCore/GLibDBusProxy.h +++ b/UnityCore/GLibDBusProxy.h @@ -74,8 +74,8 @@ public: bool IsConnected() const; Variant GetProperty(std::string const& property_name) const; - void GetProperty(std::string const& property_name, ReplyCallback const&); - void SetProperty(std::string const& property_name, GVariant* value); + void GetProperty(std::string const& property_name, ReplyCallback const&, GCancellable *cancellable = nullptr); + void SetProperty(std::string const& property_name, GVariant* value, GCancellable *cancellable = nullptr); void Connect(std::string const& signal_name, ReplyCallback const& callback); void DisconnectSignal(std::string const& signal_name = ""); diff --git a/UnityCore/GnomeSessionManager.cpp b/UnityCore/GnomeSessionManager.cpp index 9fb1eb98c..13a650baa 100644 --- a/UnityCore/GnomeSessionManager.cpp +++ b/UnityCore/GnomeSessionManager.cpp @@ -130,7 +130,7 @@ GnomeManager::Impl::Impl(GnomeManager* manager, bool test_mode) glib::Variant tmp(g_variant_get_child_value(variant, 1), glib::StealRef()); SetupLogin1Proxy(tmp.GetObjectPath()); - }); + }, cancellable_); } } @@ -424,7 +424,7 @@ void GnomeManager::Impl::CallGnomeSessionMethod(std::string const& method, GVari if (cb) cb(ret, e); - }); + }, cancellable_); } void GnomeManager::Impl::CallUPowerMethod(std::string const& method, glib::DBusProxy::ReplyCallback const& cb) @@ -443,7 +443,7 @@ void GnomeManager::Impl::CallUPowerMethod(std::string const& method, glib::DBusP { cb(ret); } - }); + }, cancellable_); } void GnomeManager::Impl::CallLogindMethod(std::string const& method, GVariant* parameters, glib::DBusProxy::CallFinishedCallback const& cb) @@ -465,7 +465,7 @@ void GnomeManager::Impl::CallLogindMethod(std::string const& method, GVariant* p { cb(ret, e); } - }); + }, cancellable_); } void GnomeManager::Impl::CallConsoleKitMethod(std::string const& method, GVariant* parameters) @@ -482,7 +482,7 @@ void GnomeManager::Impl::CallConsoleKitMethod(std::string const& method, GVarian { LOG_ERROR(logger) << "Fallback call failed: " << e.Message(); } - }); + }, cancellable_); } void GnomeManager::Impl::CallDisplayManagerSeatMethod(std::string const& method, GVariant* parameters) @@ -499,7 +499,7 @@ void GnomeManager::Impl::CallDisplayManagerSeatMethod(std::string const& method, { LOG_ERROR(logger) << "DisplayManager Seat call failed: " << e.Message(); } - }); + }, cancellable_); } void GnomeManager::Impl::LockScreen(bool prompt) @@ -552,7 +552,7 @@ bool GnomeManager::Impl::HasInhibitors() glib::Variant inhibitors(g_dbus_connection_call_sync(bus, test_mode_ ? testing::DBUS_NAME.c_str() : "org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager", "IsInhibited", g_variant_new("(u)", Inhibited::LOGOUT), nullptr, - G_DBUS_CALL_FLAGS_NONE, 500, nullptr, &error)); + G_DBUS_CALL_FLAGS_NONE, 500, cancellable_, &error)); if (error) { @@ -575,13 +575,53 @@ bool GnomeManager::Impl::IsUserInGroup(std::string const& user_name, std::string auto group = getgrnam(group_name.c_str()); if (group && group->gr_mem) + { for (int i = 0; group->gr_mem[i]; ++i) + { if (g_strcmp0(group->gr_mem[i], user_name.c_str()) == 0) return true; + } + } return false; } +bool GnomeManager::Impl::AutomaticLogin() +{ + glib::Error error; + glib::Object<GDBusConnection> bus(g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error)); + + if (error) + { + LOG_ERROR(logger) << "Impossible to get the system bus to know if auto-login is enabled: " << error; + return false; + } + + glib::Variant user_path(g_dbus_connection_call_sync(bus, "org.freedesktop.Accounts", + "/org/freedesktop/Accounts", "org.freedesktop.Accounts", + "FindUserByName", g_variant_new("(s)",g_get_user_name()), nullptr, + G_DBUS_CALL_FLAGS_NONE, 500, cancellable_, &error)); + + if (error) + { + LOG_ERROR(logger) << "Impossible to get the user path: " << error; + return false; + } + + glib::Variant autologin(g_dbus_connection_call_sync(bus, "org.freedesktop.Accounts", + user_path.GetObjectPath().c_str(), "org.freedesktop.DBus.Properties", + "Get", g_variant_new("(ss)", "org.freedesktop.Accounts.User", "AutomaticLogin"), nullptr, + G_DBUS_CALL_FLAGS_NONE, 500, cancellable_, &error)); + + if (error) + { + LOG_ERROR(logger) << "Impossible to get the AutomaticLogin property: " << error; + return false; + } + + return autologin.GetBool(); +} + // Public implementation GnomeManager::GnomeManager() @@ -620,6 +660,11 @@ void GnomeManager::UserIconFile(std::function<void(std::string const&)> const& c impl_->UserIconFile(callback); } +bool GnomeManager::AutomaticLogin() const +{ + return impl_->AutomaticLogin(); +} + void GnomeManager::ScreenSaverActivate() { screensaver_requested.emit(true); diff --git a/UnityCore/GnomeSessionManager.h b/UnityCore/GnomeSessionManager.h index c0894b087..79646c70f 100644 --- a/UnityCore/GnomeSessionManager.h +++ b/UnityCore/GnomeSessionManager.h @@ -37,6 +37,7 @@ public: std::string UserName() const; std::string HostName() const; void UserIconFile(std::function<void(std::string const&)> const&) const; + bool AutomaticLogin() const; void ScreenSaverActivate(); void ScreenSaverDeactivate(); diff --git a/UnityCore/GnomeSessionManagerImpl.h b/UnityCore/GnomeSessionManagerImpl.h index f3904e7eb..9eee96757 100644 --- a/UnityCore/GnomeSessionManagerImpl.h +++ b/UnityCore/GnomeSessionManagerImpl.h @@ -69,6 +69,7 @@ struct GnomeManager::Impl void UpdateHaveOtherOpenSessions(); bool IsUserInGroup(std::string const& user_name, std::string const& group_name); + bool AutomaticLogin(); GnomeManager* manager_; bool test_mode_; @@ -84,6 +85,7 @@ struct GnomeManager::Impl glib::DBusProxy::Ptr dm_proxy_; glib::DBusProxy::Ptr dm_seat_proxy_; + glib::Cancellable cancellable_; int open_sessions_; }; diff --git a/UnityCore/SessionManager.h b/UnityCore/SessionManager.h index 7a816f7c4..89d50c1c4 100644 --- a/UnityCore/SessionManager.h +++ b/UnityCore/SessionManager.h @@ -46,6 +46,7 @@ public: virtual std::string UserName() const = 0; virtual std::string HostName() const = 0; virtual void UserIconFile(std::function<void(std::string const&)> const&) const = 0; + virtual bool AutomaticLogin() const = 0; virtual void ScreenSaverActivate() = 0; virtual void ScreenSaverDeactivate() = 0; diff --git a/data/com.canonical.Unity.gschema.xml b/data/com.canonical.Unity.gschema.xml index 35326a5fb..334a6dd92 100644 --- a/data/com.canonical.Unity.gschema.xml +++ b/data/com.canonical.Unity.gschema.xml @@ -193,7 +193,7 @@ <description>The scopes listed in the scope bar will be ordered according to this list.</description> </key> <key type="as" name="favorite-scopes"> - <default>[ 'scope://clickscope', 'scope://musicaggregator', 'scope://videoaggregator' ]</default> + <default>[ 'scope://musicaggregator', 'scope://videoaggregator' ]</default> <summary>List of scope queries specifying what should be displayed in the dash.</summary> <description>List of favorite scopes displayed in the dash.</description> </key> diff --git a/data/unity7.service.in b/data/unity7.service.in index 36dc2aa6a..7745d6bb2 100644 --- a/data/unity7.service.in +++ b/data/unity7.service.in @@ -1,7 +1,6 @@ [Unit] Description=Unity Shell v7 -Requires=unity-settings-daemon.service unity-panel-service.service bamfdaemon.service -Wants=unity-gtk-module.service +Wants=unity-settings-daemon.service unity-gtk-module.service unity-panel-service.service bamfdaemon.service After=unity-settings-daemon.service PartOf=graphical-session.target diff --git a/debian/changelog b/debian/changelog index 3648f4e00..f24e559cc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,43 @@ +unity (7.5.0+17.04.20170301-0ubuntu1) zesty; urgency=medium + + * UnityWindow: safely check validity of UnityWindow from scaled one + (LP: #1659847) + * InputMonitor: don't try to deference an invalid Nux display (LP: + #1632656) + * unity7.service: set ups and BAMF as wanted, not required + + -- Marco Trevisan (Treviño) <mail@3v1n0.net> Wed, 01 Mar 2017 13:07:08 +0000 + +unity (7.5.0+17.04.20170222-0ubuntu1) zesty; urgency=medium + + * BackgroundSettings: use gnome-bg to generate textures with proper + scaling (LP: #1666359) + + -- Marco Trevisan (Treviño) <mail@3v1n0.net> Wed, 22 Feb 2017 01:52:54 +0000 + +unity (7.5.0+17.04.20170125-0ubuntu1) zesty; urgency=medium + + [ Marco Trevisan (Treviño) ] + * GnomeSessionManager: add gcancellable to instance and use it for + calls with temporary proxies + + [ Michał Sawicz ] + * Drop click scope from the default list of favourites + + -- Marco Trevisan (Treviño) <mail@3v1n0.net> Wed, 25 Jan 2017 16:55:08 +0000 + +unity (7.5.0+17.04.20170109-0ubuntu1) zesty; urgency=medium + + [ Andrea Azzarone ] + * Round gtk scaling factor to closest integer. (LP: #1649736) + * Keep the screen locked if rebooting with autologin. (LP: #1600389) + + [ Eleni Maria Stea ] + * shouldn't create blur rectangles when there's no blur, skips the + blur rects processing in low gfx. + + -- Marco Trevisan (Treviño) <mail@3v1n0.net> Mon, 09 Jan 2017 15:10:02 +0000 + unity (7.5.0+17.04.20161130-0ubuntu1) zesty; urgency=medium [ Kai-Heng Feng ] diff --git a/lockscreen/BackgroundSettings.cpp b/lockscreen/BackgroundSettings.cpp index 7ffcee98d..d5ec73cea 100644 --- a/lockscreen/BackgroundSettings.cpp +++ b/lockscreen/BackgroundSettings.cpp @@ -53,23 +53,28 @@ BaseTexturePtr BackgroundSettings::GetBackgroundTexture(int monitor) auto& settings = Settings::Instance(); nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, geo.width, geo.height); - cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale, scale); cairo_t* c = cairo_graphics.GetInternalContext(); + glib::Object<GnomeBG> gnome_bg; double s_width = geo.width / scale; double s_height = geo.height / scale; cairo_surface_t* bg_surface = nullptr; if (settings.use_user_background()) { - bg_surface = gnome_bg_create_surface(gnome_bg_, gdk_get_default_root_window(), s_width, s_height, FALSE); + gnome_bg = gnome_bg_; } else if (!settings.background().empty()) { - glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_scale(settings.background().c_str(), s_width, s_height, FALSE, NULL)); + gnome_bg = gnome_bg_new(); + gnome_bg_set_filename(gnome_bg, settings.background().c_str()); + gnome_bg_set_placement(gnome_bg, G_DESKTOP_BACKGROUND_STYLE_ZOOM); + } - if (pixbuf) - bg_surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 0, NULL); + if (gnome_bg) + { + auto *root_window = gdk_get_default_root_window(); + bg_surface = gnome_bg_create_surface(gnome_bg, root_window, geo.width, geo.height, FALSE); } if (bg_surface) @@ -85,6 +90,8 @@ BaseTexturePtr BackgroundSettings::GetBackgroundTexture(int monitor) cairo_paint(c); } + cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale, scale); + if (!settings.logo().empty()) { int grid_x_offset = GetGridOffset(s_width); diff --git a/lockscreen/LockScreenBaseShield.cpp b/lockscreen/LockScreenBaseShield.cpp index cfd56814c..f4c591fb8 100644 --- a/lockscreen/LockScreenBaseShield.cpp +++ b/lockscreen/LockScreenBaseShield.cpp @@ -145,6 +145,7 @@ void BaseShield::UpdateBackgroundTexture() { auto background_texture = bg_settings_->GetBackgroundTexture(monitor); background_layer_.reset(new nux::TextureLayer(background_texture->GetDeviceTexture(), nux::TexCoordXForm(), nux::color::White, true)); + background_layer_->SetGeometry(monitor_geo); SetBackgroundLayer(background_layer_.get()); } } diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index b8a1c4877..41aed941d 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -197,6 +197,7 @@ UnityScreen::UnityScreen(CompScreen* screen) , menus_(std::make_shared<menu::Manager>(std::make_shared<indicator::DBusIndicators>(), std::make_shared<key::GnomeGrabber>())) , deco_manager_(std::make_shared<decoration::Manager>(menus_)) , debugger_(this) + , session_(std::make_shared<session::GnomeManager>()) , needsRelayout(false) , super_keypressed_(false) , newFocusedWindow(nullptr) @@ -519,7 +520,10 @@ UnityScreen::~UnityScreen() unity_a11y_finalize(); QuicklistManager::Destroy(); decoration::DataPool::Reset(); - SaveLockStamp(false); + + if (!session_->AutomaticLogin()) + SaveLockStamp(false); + reset_glib_logging(); screen->addSupportedAtomsSetEnabled(this, false); @@ -587,12 +591,14 @@ void UnityScreen::OnInitiateSpread() for (auto const& swin : sScreen->getWindows()) { - if (filtered_windows.find(swin->window->id()) != filtered_windows.end()) + if (!swin->window || filtered_windows.find(swin->window->id()) != filtered_windows.end()) continue; - auto* uwin = UnityWindow::get(swin->window); - uwin->OnTerminateSpread(); - fake_decorated_windows_.erase(uwin); + if (UnityWindow* uwin = UnityWindow::get(swin->window)) + { + uwin->OnTerminateSpread(); + fake_decorated_windows_.erase(uwin); + } } for (auto xid : filtered_windows) @@ -606,6 +612,9 @@ void UnityScreen::OnInitiateSpread() for (auto const& swin : sScreen->getWindows()) { + if (!swin->window) + continue; + auto* uwin = UnityWindow::get(swin->window); fake_decorated_windows_.insert(uwin); uwin->OnInitiateSpread(); @@ -617,7 +626,13 @@ void UnityScreen::OnTerminateSpread() spread_widgets_.reset(); for (auto const& swin : sScreen->getWindows()) - UnityWindow::get(swin->window)->OnTerminateSpread(); + { + if (!swin->window) + continue; + + if (UnityWindow* uwin = UnityWindow::get(swin->window)) + uwin->OnTerminateSpread(); + } fake_decorated_windows_.clear(); } @@ -867,7 +882,7 @@ void UnityScreen::DamageBlurUpdateRegion(nux::Geometry const& blur_update) cScreen->damageRegion(CompRegionFromNuxGeo(blur_update)); } -void UnityScreen::paintDisplay() +void UnityScreen::paintOutput() { CompOutput *output = last_output_; @@ -1508,7 +1523,7 @@ bool UnityScreen::glPaintOutput(const GLScreenPaintAttrib& attrib, doShellRepaint = false; if (doShellRepaint) - paintDisplay(); + paintOutput(); return ret; } @@ -3108,18 +3123,18 @@ bool UnityWindow::glDraw(const GLMatrix& matrix, if (uScreen->doShellRepaint && window == uScreen->onboard_) { - uScreen->paintDisplay(); + uScreen->paintOutput(); } else if (uScreen->doShellRepaint && window == uScreen->firstWindowAboveShell && !uScreen->forcePaintOnTop() && !uScreen->fullscreenRegion.contains(window->geometry())) { - uScreen->paintDisplay(); + uScreen->paintOutput(); } else if (locked && CanBypassLockScreen()) { - uScreen->paintDisplay(); + uScreen->paintOutput(); } enum class DrawPanelShadow @@ -3851,7 +3866,7 @@ bool UnityScreen::layoutSlotsAndAssignWindows() for (ScaleWindow *sw : scaled_windows) { - if (sw->window->outputDevice() == static_cast<int>(output.id())) + if (sw->window && sw->window->outputDevice() == static_cast<int>(output.id())) { UnityWindow::get(sw->window)->deco_win_->scaled = true; layout_windows.emplace_back(std::make_shared<LayoutWindow>(sw->window->id())); @@ -4001,17 +4016,32 @@ void UnityScreen::OnScreenUnlocked() UpdateGesturesSupport(); } -void UnityScreen::SaveLockStamp(bool save) +std::string UnityScreen::GetLockStampFile() const { - auto const& cache_dir = DesktopUtilities::GetUserRuntimeDirectory(); + std::string cache_dir; + + if (session_->AutomaticLogin()) + cache_dir = DesktopUtilities::GetUserCacheDirectory(); + else + cache_dir = DesktopUtilities::GetUserRuntimeDirectory(); if (cache_dir.empty()) + return std::string(); + + return cache_dir+local::LOCKED_STAMP; +} + +void UnityScreen::SaveLockStamp(bool save) +{ + std::string file_path = GetLockStampFile(); + + if (file_path.empty()) return; if (save) { glib::Error error; - g_file_set_contents((cache_dir+local::LOCKED_STAMP).c_str(), "", 0, &error); + g_file_set_contents(file_path.c_str(), "", 0, &error); if (error) { @@ -4020,7 +4050,7 @@ void UnityScreen::SaveLockStamp(bool save) } else { - if (g_unlink((cache_dir+local::LOCKED_STAMP).c_str()) < 0) + if (g_unlink(file_path.c_str()) < 0) { LOG_ERROR(logger) << "Impossible to delete the unity locked stamp file"; } @@ -4096,24 +4126,23 @@ void UnityScreen::InitUnityComponents() ShowFirstRunHints(); // Setup Session Controller - auto session = std::make_shared<session::GnomeManager>(); - session->lock_requested.connect(sigc::mem_fun(this, &UnityScreen::OnLockScreenRequested)); - session->prompt_lock_requested.connect(sigc::mem_fun(this, &UnityScreen::OnLockScreenRequested)); - session->locked.connect(sigc::mem_fun(this, &UnityScreen::OnScreenLocked)); - session->unlocked.connect(sigc::mem_fun(this, &UnityScreen::OnScreenUnlocked)); - session_dbus_manager_ = std::make_shared<session::DBusManager>(session); - session_controller_ = std::make_shared<session::Controller>(session); + session_->lock_requested.connect(sigc::mem_fun(this, &UnityScreen::OnLockScreenRequested)); + session_->prompt_lock_requested.connect(sigc::mem_fun(this, &UnityScreen::OnLockScreenRequested)); + session_->locked.connect(sigc::mem_fun(this, &UnityScreen::OnScreenLocked)); + session_->unlocked.connect(sigc::mem_fun(this, &UnityScreen::OnScreenUnlocked)); + session_dbus_manager_ = std::make_shared<session::DBusManager>(session_); + session_controller_ = std::make_shared<session::Controller>(session_); LOG_INFO(logger) << "InitUnityComponents-Session " << timer.ElapsedSeconds() << "s"; Introspectable::AddChild(session_controller_.get()); // Setup Lockscreen Controller - screensaver_dbus_manager_ = std::make_shared<lockscreen::DBusManager>(session); - lockscreen_controller_ = std::make_shared<lockscreen::Controller>(screensaver_dbus_manager_, session, menus_->KeyGrabber()); + screensaver_dbus_manager_ = std::make_shared<lockscreen::DBusManager>(session_); + lockscreen_controller_ = std::make_shared<lockscreen::Controller>(screensaver_dbus_manager_, session_, menus_->KeyGrabber()); UpdateActivateIndicatorsKey(); LOG_INFO(logger) << "InitUnityComponents-Lockscreen " << timer.ElapsedSeconds() << "s"; - if (g_file_test((DesktopUtilities::GetUserRuntimeDirectory()+local::LOCKED_STAMP).c_str(), G_FILE_TEST_EXISTS)) - session->PromptLockScreen(); + if (g_file_test(GetLockStampFile().c_str(), G_FILE_TEST_EXISTS)) + session_->PromptLockScreen(); auto on_launcher_size_changed = [this] (nux::Area* area, int w, int h) { /* The launcher geometry includes 1px used to draw the right/top margin diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 43df66e72..a630a99c0 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -76,6 +76,7 @@ #include "UnityShowdesktopHandler.h" #include "ThumbnailGenerator.h" #include "MenuManager.h" +#include "UnityCore/SessionManager.h" #include "compizminimizedwindowhandler.h" #include "BGHash.h" @@ -180,7 +181,7 @@ private: void nuxEpilogue(); /* nux draw wrapper */ - void paintDisplay(); + void paintOutput(); void paintPanelShadow(CompRegion const& clip); void setPanelShadowMatrix(const GLMatrix& matrix); void updateBlurDamage(); @@ -231,6 +232,7 @@ private: void OnScreenLocked(); void OnScreenUnlocked(); void SaveLockStamp(bool); + std::string GetLockStampFile() const; bool DoesPointIntersectUnityGeos(nux::Point const& pt); @@ -344,6 +346,8 @@ private: std::unique_ptr<BGHash> bghash_; spread::Widgets::Ptr spread_widgets_; + session::Manager::Ptr session_; + /* Subscription for gestures that manipulate Unity launcher */ std::unique_ptr<nux::GesturesSubscription> gestures_sub_launcher_; diff --git a/shutdown/StandaloneSession.cpp b/shutdown/StandaloneSession.cpp index ade557cee..522ffad7e 100644 --- a/shutdown/StandaloneSession.cpp +++ b/shutdown/StandaloneSession.cpp @@ -40,6 +40,7 @@ public: std::string UserName() const { return "marco"; } std::string HostName() const { return "tricky"; } void UserIconFile(std::function<void(std::string const&)> const&) const { std::cout << "UserIconFile" << std::endl; } + bool AutomaticLogin() const { return false; } void ScreenSaverActivate() { std::cout << "ScreenSaverActivate" << std::endl; } void ScreenSaverDeactivate() { std::cout << "ScreenSaverDeactivate" << std::endl; } diff --git a/tests/test_mock_session_manager.h b/tests/test_mock_session_manager.h index 97f5e26ee..decfbc7bd 100644 --- a/tests/test_mock_session_manager.h +++ b/tests/test_mock_session_manager.h @@ -34,6 +34,7 @@ struct MockManager : Manager MOCK_CONST_METHOD0(UserName, std::string()); MOCK_CONST_METHOD0(HostName, std::string()); MOCK_CONST_METHOD1(UserIconFile, void(ReplyCallback const&)); + MOCK_CONST_METHOD0(AutomaticLogin, bool()); MOCK_METHOD0(ScreenSaverActivate, void()); MOCK_METHOD0(ScreenSaverDeactivate, void()); diff --git a/unity-shared/BackgroundEffectHelper.cpp b/unity-shared/BackgroundEffectHelper.cpp index 82d66a744..507c3eacc 100644 --- a/unity-shared/BackgroundEffectHelper.cpp +++ b/unity-shared/BackgroundEffectHelper.cpp @@ -143,6 +143,9 @@ bool BackgroundEffectHelper::UpdateOwnerGeometry() void BackgroundEffectHelper::UpdateBlurGeometries() { + if (blur_type == BLUR_NONE) + return; + int radius = GetBlurRadius(); blur_geometries_.clear(); blur_geometries_.reserve(registered_list_.size()); diff --git a/unity-shared/InputMonitor.cpp b/unity-shared/InputMonitor.cpp index 465c5afad..c7b70538a 100644 --- a/unity-shared/InputMonitor.cpp +++ b/unity-shared/InputMonitor.cpp @@ -225,7 +225,8 @@ struct Monitor::Impl void UpdateEventMonitor() { - auto* dpy = nux::GetGraphicsDisplay()->GetX11Display(); + auto* nux_dpy = nux::GetGraphicsDisplay(); + auto* dpy = nux_dpy ? nux_dpy->GetX11Display() : gdk_x11_get_default_xdisplay(); Window root = DefaultRootWindow(dpy); unsigned char master_dev_bits[XIMaskLen(XI_LASTEVENT)] = { 0 }; @@ -263,9 +264,9 @@ struct Monitor::Impl if (!pointer_callbacks_.empty() || !key_callbacks_.empty() || !barrier_callbacks_.empty()) { - if (!event_filter_set_) + if (!event_filter_set_ && nux_dpy) { - nux::GetGraphicsDisplay()->AddEventFilter({[] (XEvent event, void* data) { + nux_dpy->AddEventFilter({[] (XEvent event, void* data) { return static_cast<Impl*>(data)->HandleEvent(event); }, this}); @@ -275,7 +276,9 @@ struct Monitor::Impl } else if (event_filter_set_) { - nux::GetGraphicsDisplay()->RemoveEventFilter(this); + if (nux_dpy) + nux_dpy->RemoveEventFilter(this); + event_filter_set_ = false; LOG_DEBUG(logger) << "Event filter disabled"; } diff --git a/unity-shared/MenuManager.cpp b/unity-shared/MenuManager.cpp index 77828700d..36d9d538b 100644 --- a/unity-shared/MenuManager.cpp +++ b/unity-shared/MenuManager.cpp @@ -325,17 +325,12 @@ struct Manager::Impl : sigc::trackable bool RegisterTracker(std::string const& menubar, PositionTracker const& cb) { - auto it = position_trackers_.find(menubar); - - if (it != end(position_trackers_)) - return false; - - position_trackers_.insert({menubar, cb}); + bool added = position_trackers_.insert({menubar, cb}).second; - if (active_menubar_ == menubar) + if (added && active_menubar_ == menubar) UpdateActiveTracker(); - return true; + return added; } bool UnregisterTracker(std::string const& menubar, PositionTracker const& cb) diff --git a/unity-shared/SystemdWrapper.cpp b/unity-shared/SystemdWrapper.cpp index f3f294f0b..5917ddc24 100644 --- a/unity-shared/SystemdWrapper.cpp +++ b/unity-shared/SystemdWrapper.cpp @@ -39,7 +39,6 @@ public: private: bool test_mode_; - glib::DBusProxy::Ptr systemd_proxy_; }; SystemdWrapper::Impl::Impl(bool test) diff --git a/unity-shared/UnitySettings.cpp b/unity-shared/UnitySettings.cpp index 07d9fcf4e..eff28667d 100644 --- a/unity-shared/UnitySettings.cpp +++ b/unity-shared/UnitySettings.cpp @@ -362,7 +362,7 @@ public: const auto dpi = std::max(dpi_x, dpi_y); if (dpi > DPI_SCALING_LIMIT) - scale = static_cast<int>(std::lround(scale * dpi / DPI_SCALING_LIMIT)); + scale = static_cast<int>(scale * std::lround(dpi / DPI_SCALING_LIMIT)); } return scale; @@ -439,7 +439,7 @@ public: { changing_gnome_settings_ = true; changing_gnome_settings_timeout_.reset(); - unsigned integer_scaling = std::max<unsigned>(1, scale); + unsigned integer_scaling = std::max<unsigned>(1, std::lround(scale)); double point_scaling = scale / static_cast<double>(integer_scaling); double text_scale_factor = parent_->font_scaling() * point_scaling; glib::Variant default_cursor_size(g_settings_get_default_value(gnome_ui_settings_, GNOME_CURSOR_SIZE.c_str()), glib::StealRef()); |
