1
Description: fix more screen locking issues
2
Origin: upstream, http://bazaar.launchpad.net/~3v1n0/unity/lockscreen-shield-regrab/revision/3845
3
Origin: upstream, http://bazaar.launchpad.net/~3v1n0/unity/lockscreen-shield-regrab/revision/3846
4
Origin: upstream, http://bazaar.launchpad.net/~3v1n0/unity/lockscreen-shield-regrab/revision/3847
5
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1349128
7
Index: unity-7.2.2+14.04.20140714/lockscreen/LockScreenController.cpp
8
===================================================================
9
--- unity-7.2.2+14.04.20140714.orig/lockscreen/LockScreenController.cpp 2014-07-14 10:30:31.000000000 -0400
10
+++ unity-7.2.2+14.04.20140714/lockscreen/LockScreenController.cpp 2014-07-30 15:13:14.677682810 -0400
12
bool AcceptKeyNavFocus() override { return true; }
13
bool InspectKeyEvent(unsigned int, unsigned int, const char*) override { return true; };
17
DECLARE_LOGGER(logger, "unity.lockscreen");
20
Controller::Controller(DBusManager::Ptr const& dbus_manager,
21
session::Manager::Ptr const& session_manager,
22
Index: unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.cpp
23
===================================================================
24
--- unity-7.2.2+14.04.20140714.orig/lockscreen/LockScreenShield.cpp 2014-07-14 10:30:31.000000000 -0400
25
+++ unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.cpp 2014-07-30 15:13:17.505682826 -0400
28
#include "LockScreenShield.h"
30
+#include <NuxCore/Logger.h>
31
#include <Nux/VLayout.h>
32
#include <Nux/HLayout.h>
33
#include <Nux/PaintLayer.h>
40
+DECLARE_LOGGER(logger, "unity.lockscreen.shield");
43
Shield::Shield(session::Manager::Ptr const& session_manager, indicator::Indicators::Ptr const& indicators, Accelerators::Ptr const& accelerators, int monitor_num, bool is_primary)
44
: AbstractShield(session_manager, indicators, accelerators, monitor_num, is_primary)
48
primary.changed.connect([this] (bool is_primary) {
55
+ regrab_conn_->disconnect();
56
is_primary ? ShowPrimaryView() : ShowSecondaryView();
57
if (panel_view_) panel_view_->SetInputEventSensitivity(is_primary);
63
-void Shield::ShowPrimaryView()
64
+void Shield::GrabScreen(bool cancel_on_failure)
68
+ auto& wc = nux::GetWindowCompositor();
70
+ if (wc.GrabPointerAdd(this) && wc.GrabKeyboardAdd(this))
72
+ regrab_conn_->disconnect();
73
+ regrab_timeout_.reset();
77
+ auto const& retry_cb = sigc::bind(sigc::mem_fun(this, &Shield::GrabScreen), false);
78
+ regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect(retry_cb);
80
+ if (cancel_on_failure)
82
+ regrab_timeout_.reset(new glib::Timeout(50, [this] {
83
+ LOG_ERROR(logger) << "Impossible to get the grab to lock the screen";
84
+ session_manager_->unlock_requested.emit();
91
+void Shield::ShowPrimaryView()
96
SetLayout(primary_layout_.GetPointer());
101
nux::Layout* main_layout = new nux::VLayout();
102
primary_layout_ = main_layout;
103
SetLayout(primary_layout_.GetPointer());
108
- auto& wc = nux::GetWindowCompositor();
110
- if (!wc.GrabPointerAdd(this) || !wc.GrabKeyboardAdd(this))
112
- regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect([this] {
118
- regrab_conn_->disconnect();
125
Index: unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.h
126
===================================================================
127
--- unity-7.2.2+14.04.20140714.orig/lockscreen/LockScreenShield.h 2014-07-14 10:30:31.000000000 -0400
128
+++ unity-7.2.2+14.04.20140714/lockscreen/LockScreenShield.h 2014-07-30 15:13:14.677682810 -0400
130
#define UNITY_LOCKSCREEN_SHIELD_H
132
#include <UnityCore/ConnectionManager.h>
133
+#include <UnityCore/GLibSource.h>
134
#include "LockScreenAbstractShield.h"
140
void UpdateBackgroundTexture();
141
+ void GrabScreen(bool cancel_on_failure);
142
void ShowPrimaryView();
143
void ShowSecondaryView();
144
Panel* CreatePanel();
146
nux::ObjectPtr<nux::Layout> cof_layout_;
147
connection::Wrapper panel_active_conn_;
148
connection::Wrapper regrab_conn_;
149
+ glib::Source::UniquePtr regrab_timeout_;
150
UserPromptView* prompt_view_;
153
Index: unity-7.2.2+14.04.20140714/unity-shared/PluginAdapter.cpp
154
===================================================================
155
--- unity-7.2.2+14.04.20140714.orig/unity-shared/PluginAdapter.cpp 2014-07-14 10:30:31.000000000 -0400
156
+++ unity-7.2.2+14.04.20140714/unity-shared/PluginAdapter.cpp 2014-07-30 15:13:11.953682795 -0400
157
@@ -1254,6 +1254,7 @@
158
if (ret == GrabSuccess)
160
XUngrabKeyboard(dpy, CurrentTime);
163
if (CompWindow* w = m_Screen->findWindow(m_Screen->activeWindow()))
164
w->moveInputFocusTo();