Merge lp:~azzar1/unity/fix-double-lock into lp:unity

Proposed by Andrea Azzarone
Status: Superseded
Proposed branch: lp:~azzar1/unity/fix-double-lock
Merge into: lp:unity
Diff against target: 123 lines (+55/-28)
3 files modified
UnityCore/GnomeSessionManager.cpp (+49/-26)
UnityCore/GnomeSessionManagerImpl.h (+2/-0)
decorations/DecorationsForceQuitDialog.cpp (+4/-2)
To merge this branch: bzr merge lp:~azzar1/unity/fix-double-lock
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+309858@code.launchpad.net

This proposal has been superseded by a proposal from 2016-11-02.

Commit message

Retrieve the session id using dbus if env variable XDG_SESSION_ID is not available.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/GnomeSessionManager.cpp'
2--- UnityCore/GnomeSessionManager.cpp 2016-09-01 17:18:03 +0000
3+++ UnityCore/GnomeSessionManager.cpp 2016-11-02 15:01:14 +0000
4@@ -101,32 +101,27 @@
5 });
6
7 {
8- const char* session_id = test_mode_ ? "id0" : g_getenv("XDG_SESSION_ID");
9-
10- login_proxy_ = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.login1",
11- "/org/freedesktop/login1/session/" + glib::gchar_to_string(session_id),
12- "org.freedesktop.login1.Session",
13- test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,
14- G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES);
15-
16- login_proxy_->Connect("Lock", [this](GVariant*){
17- manager_->PromptLockScreen();
18- });
19-
20- login_proxy_->Connect("Unlock", [this](GVariant*){
21- manager_->unlock_requested.emit();
22- });
23-
24- login_proxy_->ConnectProperty("Active", [this] (GVariant* variant) {
25- bool active = glib::Variant(variant).GetBool();
26- manager_->is_session_active.changed.emit(active);
27- if (active)
28- manager_->screensaver_requested.emit(false);
29- });
30-
31- manager_->is_session_active.SetGetterFunction([this] {
32- return login_proxy_->GetProperty("Active").GetBool();
33- });
34+ std::string session_id = test_mode_ ? "id0" : glib::gchar_to_string(g_getenv("XDG_SESSION_ID"));
35+
36+ if (!session_id.empty())
37+ {
38+ SetupLogin1Proxy(session_id);
39+ }
40+ else
41+ {
42+ auto proxy = std::make_shared<glib::DBusProxy>("org.freedesktop.login1",
43+ "/org/freedesktop/login1/user/self",
44+ "org.freedesktop.login1.User",
45+ G_BUS_TYPE_SYSTEM);
46+
47+ proxy->GetProperty("Display", [this, proxy] (GVariant *variant) {
48+ if (!variant || g_variant_n_children(variant) < 1)
49+ return;
50+
51+ glib::Variant tmp(g_variant_get_child_value(variant, 0), glib::StealRef());
52+ SetupLogin1Proxy(tmp.GetString());
53+ });
54+ }
55 }
56
57 {
58@@ -221,6 +216,34 @@
59 ClosedDialog();
60 }
61
62+void GnomeManager::Impl::SetupLogin1Proxy(std::string const& session_id)
63+{
64+ login_proxy_ = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.login1",
65+ "/org/freedesktop/login1/session/" + session_id,
66+ "org.freedesktop.login1.Session",
67+ test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,
68+ G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES);
69+
70+ login_proxy_->Connect("Lock", [this](GVariant*){
71+ manager_->PromptLockScreen();
72+ });
73+
74+ login_proxy_->Connect("Unlock", [this](GVariant*){
75+ manager_->unlock_requested.emit();
76+ });
77+
78+ login_proxy_->ConnectProperty("Active", [this] (GVariant* variant) {
79+ bool active = glib::Variant(variant).GetBool();
80+ manager_->is_session_active.changed.emit(active);
81+ if (active)
82+ manager_->screensaver_requested.emit(false);
83+ });
84+
85+ manager_->is_session_active.SetGetterFunction([this] {
86+ return login_proxy_->GetProperty("Active").GetBool();
87+ });
88+}
89+
90 bool GnomeManager::Impl::InteractiveMode()
91 {
92 bool schema_found = false;
93
94=== modified file 'UnityCore/GnomeSessionManagerImpl.h'
95--- UnityCore/GnomeSessionManagerImpl.h 2015-12-03 05:57:00 +0000
96+++ UnityCore/GnomeSessionManagerImpl.h 2016-11-02 15:01:14 +0000
97@@ -46,6 +46,8 @@
98 Impl(GnomeManager* parent, bool test_mode = false);
99 ~Impl();
100
101+ void SetupLogin1Proxy(std::string const& session_id);
102+
103 void ConfirmLogout();
104 void ConfirmReboot();
105 void ConfirmShutdown();
106
107=== modified file 'decorations/DecorationsForceQuitDialog.cpp'
108--- decorations/DecorationsForceQuitDialog.cpp 2016-08-06 16:24:55 +0000
109+++ decorations/DecorationsForceQuitDialog.cpp 2016-11-02 15:01:14 +0000
110@@ -478,9 +478,11 @@
111
112 void UpdateDialogPosition()
113 {
114+ gint scale = gtk_widget_get_scale_factor(dialog_);
115+ scale = std::max<gint>(1, scale);
116 auto const& win_geo = win_->inputRect();
117- nux::Size walloc(gtk_widget_get_allocated_width(dialog_), gtk_widget_get_allocated_height(dialog_));
118- gtk_window_move(GTK_WINDOW(dialog_), win_geo.centerX() - walloc.width/2, win_geo.centerY() - walloc.height/2);
119+ nux::Size walloc(gtk_widget_get_allocated_width(dialog_) * scale, gtk_widget_get_allocated_height(dialog_) * scale);
120+ gtk_window_move(GTK_WINDOW(dialog_), (win_geo.centerX() - walloc.width/2) / scale, (win_geo.centerY() - walloc.height/2) / scale);
121 }
122
123 ForceQuitDialog* parent_;