~unity-team/unity/trusty-1332509

« back to all changes in this revision

Viewing changes to debian/patches/lp1349128.patch

  • Committer: Marco Trevisan (Treviño)
  • Date: 2014-08-06 16:02:48 UTC
  • mto: This revision was merged to the branch mainline in revision 3802.
  • Revision ID: mail@3v1n0.net-20140806160248-vft3fe2zzvk0sojr
debian/patches: removing security patch, now included in branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
6
 
 
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
11
 
@@ -45,9 +45,9 @@
12
 
   bool AcceptKeyNavFocus() override { return true; }
13
 
   bool InspectKeyEvent(unsigned int, unsigned int, const char*) override { return true; };
14
 
 };
15
 
-}
16
 
 
17
 
 DECLARE_LOGGER(logger, "unity.lockscreen");
18
 
+}
19
 
 
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
26
 
@@ -19,6 +19,7 @@
27
 
 
28
 
 #include "LockScreenShield.h"
29
 
 
30
 
+#include <NuxCore/Logger.h>
31
 
 #include <Nux/VLayout.h>
32
 
 #include <Nux/HLayout.h>
33
 
 #include <Nux/PaintLayer.h>
34
 
@@ -35,6 +36,10 @@
35
 
 {
36
 
 namespace lockscreen
37
 
 {
38
 
+namespace
39
 
+{
40
 
+DECLARE_LOGGER(logger, "unity.lockscreen.shield");
41
 
+}
42
 
 
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)
45
 
@@ -56,12 +61,7 @@
46
 
   });
47
 
 
48
 
   primary.changed.connect([this] (bool is_primary) {
49
 
-    if (!is_primary)
50
 
-    {
51
 
-      UnGrabPointer();
52
 
-      UnGrabKeyboard();
53
 
-    }
54
 
-
55
 
+    regrab_conn_->disconnect();
56
 
     is_primary ? ShowPrimaryView() : ShowSecondaryView();
57
 
     if (panel_view_) panel_view_->SetInputEventSensitivity(is_primary);
58
 
     QueueRelayout();
59
 
@@ -86,17 +86,41 @@
60
 
   }
61
 
 }
62
 
 
63
 
-void Shield::ShowPrimaryView()
64
 
+void Shield::GrabScreen(bool cancel_on_failure)
65
 
 {
66
 
-  GrabPointer();
67
 
-  GrabKeyboard();
68
 
+  auto& wc = nux::GetWindowCompositor();
69
 
+
70
 
+  if (wc.GrabPointerAdd(this) && wc.GrabKeyboardAdd(this))
71
 
+  {
72
 
+    regrab_conn_->disconnect();
73
 
+    regrab_timeout_.reset();
74
 
+  }
75
 
+  else
76
 
+  {
77
 
+    auto const& retry_cb = sigc::bind(sigc::mem_fun(this, &Shield::GrabScreen), false);
78
 
+    regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect(retry_cb);
79
 
 
80
 
+    if (cancel_on_failure)
81
 
+    {
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();
85
 
+        return false;
86
 
+      }));
87
 
+    }
88
 
+  }
89
 
+}
90
 
+
91
 
+void Shield::ShowPrimaryView()
92
 
+{
93
 
   if (primary_layout_)
94
 
   {
95
 
+    GrabScreen(false);
96
 
     SetLayout(primary_layout_.GetPointer());
97
 
     return;
98
 
   }
99
 
 
100
 
+  GrabScreen(true);
101
 
   nux::Layout* main_layout = new nux::VLayout();
102
 
   primary_layout_ = main_layout;
103
 
   SetLayout(primary_layout_.GetPointer());
104
 
@@ -149,19 +173,7 @@
105
 
       }
106
 
       else
107
 
       {
108
 
-        auto& wc = nux::GetWindowCompositor();
109
 
-
110
 
-        if (!wc.GrabPointerAdd(this) || !wc.GrabKeyboardAdd(this))
111
 
-        {
112
 
-          regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect([this] {
113
 
-            if (primary())
114
 
-            {
115
 
-              GrabPointer();
116
 
-              GrabKeyboard();
117
 
-            }
118
 
-            regrab_conn_->disconnect();
119
 
-          });
120
 
-        }
121
 
+        GrabScreen(false);
122
 
       }
123
 
     }
124
 
   });
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
129
 
@@ -21,6 +21,7 @@
130
 
 #define UNITY_LOCKSCREEN_SHIELD_H
131
 
 
132
 
 #include <UnityCore/ConnectionManager.h>
133
 
+#include <UnityCore/GLibSource.h>
134
 
 #include "LockScreenAbstractShield.h"
135
 
 
136
 
 namespace unity
137
 
@@ -48,6 +49,7 @@
138
 
 
139
 
 private:
140
 
   void UpdateBackgroundTexture();
141
 
+  void GrabScreen(bool cancel_on_failure);
142
 
   void ShowPrimaryView();
143
 
   void ShowSecondaryView();
144
 
   Panel* CreatePanel();
145
 
@@ -59,6 +61,7 @@
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_;
151
 
   Panel* panel_view_;
152
 
 };
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)
159
 
   {
160
 
     XUngrabKeyboard(dpy, CurrentTime);
161
 
+    XFlush(dpy);
162
 
 
163
 
     if (CompWindow* w = m_Screen->findWindow(m_Screen->activeWindow()))
164
 
       w->moveInputFocusTo();