summaryrefslogtreecommitdiffstats
path: root/redhat/tdebase/kdebase-3.5.13-allow_minimal_window_interaction_inside_lock_process.patch
blob: 1c022587d1297fc041256bf588cd70e4dbf04ae1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
commit 057932620ba8355a6506b9d437518e253ba14ed9
Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>
Date:   1327619240 -0600

    Clean up lock screen internals
    This cleanup is part of an effort to resolve Bug 810, but a new Qt3 version is required to fully resolve it

diff --git a/kdesktop/lock/autologout.cc b/kdesktop/lock/autologout.cc
index 22b449c..bef39dd 100644
--- a/kdesktop/lock/autologout.cc
+++ b/kdesktop/lock/autologout.cc
@@ -82,6 +82,8 @@ AutoLogout::AutoLogout(LockProcess *parent) : TQDialog(parent, "password dialog"
     mCountdownTimerId = startTimer(1000/25);
 
     connect(tqApp, TQT_SIGNAL(activity()), TQT_SLOT(slotActivity()));
+
+    setFixedSize( sizeHint() );
 }
 
 AutoLogout::~AutoLogout()
diff --git a/kdesktop/lock/infodlg.cc b/kdesktop/lock/infodlg.cc
index f5f35b9..3fbc276 100644
--- a/kdesktop/lock/infodlg.cc
+++ b/kdesktop/lock/infodlg.cc
@@ -99,6 +99,7 @@ InfoDlg::InfoDlg(LockProcess *parent)
     frameLayout->addLayout( layStatus, 1, 1 );
 
     installEventFilter(this);
+    setFixedSize( sizeHint() );
 }
 
 InfoDlg::~InfoDlg()
diff --git a/kdesktop/lock/lockdlg.cc b/kdesktop/lock/lockdlg.cc
index 0863a22..f3eeee0 100644
--- a/kdesktop/lock/lockdlg.cc
+++ b/kdesktop/lock/lockdlg.cc
@@ -215,6 +215,7 @@ void PasswordDlg::init(GreeterPluginHandle *plugin)
         mNewSessButton->hide();
 
     installEventFilter(this);
+    setFixedSize( sizeHint() );
 
     mFailedTimerId = 0;
     mTimeoutTimerId = startTimer(PASSDLG_HIDE_TIMEOUT);
@@ -598,6 +599,7 @@ void PasswordDlg::show()
 {
     TQDialog::show();
     TQApplication::flushX();
+    setFixedSize( sizeHint() );
 }
 
 void PasswordDlg::slotStartNewSession()
@@ -818,6 +820,8 @@ void PasswordDlg::slotSwitchUser()
     connect( btn, TQT_SIGNAL(clicked()), &dialog, TQT_SLOT(reject()) );
     vbox2->addWidget( btn );
 
+    dialog.setFixedSize( dialog.sizeHint() );
+
     int ret = static_cast< LockProcess* >(parent())->execDialog( &dialog );
     if (ret != TQDialog::Rejected) {
         TQDialog::reject();
diff --git a/kdesktop/lock/lockprocess.cc b/kdesktop/lock/lockprocess.cc
index 5acc96e..9648bbc 100644
--- a/kdesktop/lock/lockprocess.cc
+++ b/kdesktop/lock/lockprocess.cc
@@ -4,7 +4,7 @@
 //
 // Copyright (c) 1999 Martin R. Jones <mjones@kde.org>
 // Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org>
-// Copyright (c) 2010-2011 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+// Copyright (c) 2010-2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
 //
 
 //kdesktop keeps running and checks user inactivity
@@ -111,6 +111,10 @@ Status DPMSInfo ( Display *, CARD16 *, BOOL * );
 #define LOCK_GRACE_DEFAULT          5000
 #define AUTOLOGOUT_DEFAULT          600
 
+// FIXME
+// This should be defined if Qt 3.4.0 or higher is in use
+// #define KEEP_MOUSE_UNGRABBED 1
+
 // These lines are taken on 10/2009 from X.org (X11/XF86keysym.h), defining some special multimedia keys
 #define XF86XK_AudioMute 0x1008FF12
 #define XF86XK_AudioRaiseVolume 0x1008FF13
@@ -183,6 +187,10 @@ LockProcess::LockProcess(bool child, bool useBlankOnly)
       mBackingStartupDelayTimer(0),
       m_startupStatusDialog(NULL)
 {
+#ifdef KEEP_MOUSE_UNGRABBED
+    setNFlags(WX11DisableMove|WX11DisableClose|WX11DisableShade|WX11DisableMinimize|WX11DisableMaximize);
+#endif
+
     setupSignals();
     setupPipe();
 
@@ -267,7 +275,11 @@ LockProcess::LockProcess(bool child, bool useBlankOnly)
 #endif
 
 #if (QT_VERSION-0 >= 0x030200) // XRANDR support
-  connect( kapp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( desktopResized()));
+    connect( kapp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( desktopResized()));
+#endif
+
+#ifdef KEEP_MOUSE_UNGRABBED
+    setEnabled(false);
 #endif
 
     greetPlugin.library = 0;
@@ -874,7 +886,6 @@ void LockProcess::createSaverWindow()
     // this is a security risk and has been deactivated--welcome to the 21st century folks!
     // setBackgroundMode(TQWidget::NoBackground);
 
-    setCursor( tqblankCursor );
     setGeometry(0, 0, mRootWidth, mRootHeight);
 
     kdDebug(1204) << "Saver window Id: " << winId() << endl;
@@ -884,7 +895,6 @@ void LockProcess::desktopResized()
 {
     mBusy = true;
     suspend();
-    setCursor( tqblankCursor );
 
     // Get root window size
     XWindowAttributes rootAttr;
@@ -1087,6 +1097,7 @@ bool LockProcess::grabInput()
         }
     }
 
+#ifndef KEEP_MOUSE_UNGRABBED
     if (!grabMouse())
     {
         usleep(100000);
@@ -1096,6 +1107,7 @@ bool LockProcess::grabInput()
             return false;
         }
     }
+#endif
 
     lockXF86();
 
@@ -1150,7 +1162,6 @@ bool LockProcess::startSaver()
 	createSaverWindow();
 	move(0, 0);
 	show();
-	setCursor( tqblankCursor );
 
 	raise();
 	XSync(qt_xdisplay(), False);
@@ -1313,6 +1324,8 @@ void LockProcess::repaintRootWindowIfNeeded()
 
 bool LockProcess::startHack()
 {
+    setCursor( tqblankCursor );
+
     if ((mEnsureVRootWindowSecurityTimer) && (!mEnsureVRootWindowSecurityTimer->isActive())) mEnsureVRootWindowSecurityTimer->start(250, FALSE);
 
     if (currentDialog || (!mDialogs.isEmpty()))
@@ -1429,6 +1442,7 @@ void LockProcess::stopHack()
             mHackProc.kill(SIGKILL);
         }
     }
+    setCursor( tqarrowCursor );
 }
 
 //---------------------------------------------------------------------------
@@ -1730,7 +1744,6 @@ void LockProcess::doFunctionKeyBroadcast() {
             mDialogControlLock = false;
         }
     }
-    setCursor( tqblankCursor );
 
     DCOPRef ref( "*", "MainApplication-Interface");
     ref.send("sendFakeKey", DCOPArg(mkeyCode , "unsigned int"));
diff --git a/kdesktop/lock/main.cc b/kdesktop/lock/main.cc
index c0b8e24..0cbef60 100644
--- a/kdesktop/lock/main.cc
+++ b/kdesktop/lock/main.cc
@@ -45,8 +45,9 @@ bool trinity_desktop_lock_forced = FALSE;
 
 bool MyApp::x11EventFilter( XEvent *ev )
 {
-    if (ev->type == XKeyPress || ev->type == ButtonPress)
+    if (ev->type == XKeyPress || ev->type == ButtonPress) {
         emit activity();
+    }
     else if (ev->type == MotionNotify) {
         time_t tick = time( 0 );
         if (tick != lastTick) {
diff --git a/kdesktop/lock/querydlg.cc b/kdesktop/lock/querydlg.cc
index e672d54..5f50cbe 100644
--- a/kdesktop/lock/querydlg.cc
+++ b/kdesktop/lock/querydlg.cc
@@ -118,6 +118,7 @@ QueryDlg::QueryDlg(LockProcess *parent)
     connect(ok, TQT_SIGNAL(clicked()), TQT_SLOT(slotOK()));
 
     installEventFilter(this);
+    setFixedSize( sizeHint() );
 }
 
 QueryDlg::~QueryDlg()
diff --git a/kdesktop/lock/sakdlg.cc b/kdesktop/lock/sakdlg.cc
index 17f54a1..d96e0af 100644
--- a/kdesktop/lock/sakdlg.cc
+++ b/kdesktop/lock/sakdlg.cc
@@ -102,6 +102,7 @@ SAKDlg::SAKDlg(LockProcess *parent)
     mStatusLabel->setText("<b>" + i18n("Press Ctrl+Alt+Del to begin.") + "</b><p>" + i18n("This process helps keep your password secure.") + "<br>" + i18n("It prevents unauthorized users from emulating the login screen."));
 
     installEventFilter(this);
+    setFixedSize( sizeHint() );
 
     mSAKProcess = new KProcess;
     *mSAKProcess << "kdmtsak";
diff --git a/kdesktop/lock/securedlg.cc b/kdesktop/lock/securedlg.cc
index 532b904..37524f7 100644
--- a/kdesktop/lock/securedlg.cc
+++ b/kdesktop/lock/securedlg.cc
@@ -144,6 +144,7 @@ SecureDlg::SecureDlg(LockProcess *parent)
     mSwitchButton->setFixedWidth(btnSize);
 
     installEventFilter(this);
+    setFixedSize( sizeHint() );
 }
 
 SecureDlg::~SecureDlg()
commit 678bea5ba74b3b39981e482e188c61fdd37786f0
Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>
Date:   1328606373 -0600

    Allow minimal managed window interaction inside the lock process
    This closes Bug 810

diff --git a/kdesktop/lock/lockprocess.cc b/kdesktop/lock/lockprocess.cc
index 9648bbc..2e9c9d3 100644
--- a/kdesktop/lock/lockprocess.cc
+++ b/kdesktop/lock/lockprocess.cc
@@ -111,8 +111,8 @@ Status DPMSInfo ( Display *, CARD16 *, BOOL * );
 #define LOCK_GRACE_DEFAULT          5000
 #define AUTOLOGOUT_DEFAULT          600
 
-// FIXME
-// This should be defined if Qt 3.4.0 or higher is in use
+// Setting this define is INSECURE
+// Use it for debugging purposes ONLY
 // #define KEEP_MOUSE_UNGRABBED 1
 
 // These lines are taken on 10/2009 from X.org (X11/XF86keysym.h), defining some special multimedia keys
@@ -185,7 +185,12 @@ LockProcess::LockProcess(bool child, bool useBlankOnly)
       mHackStartupEnabled(true),
       m_rootPixmap(NULL),
       mBackingStartupDelayTimer(0),
-      m_startupStatusDialog(NULL)
+      m_startupStatusDialog(NULL),
+      m_mouseDown(0),
+      m_mousePrevX(0),
+      m_mousePrevY(0),
+      m_dialogPrevX(0),
+      m_dialogPrevY(0)
 {
 #ifdef KEEP_MOUSE_UNGRABBED
     setNFlags(WX11DisableMove|WX11DisableClose|WX11DisableShade|WX11DisableMinimize|WX11DisableMaximize);
@@ -208,6 +213,8 @@ LockProcess::LockProcess(bool child, bool useBlankOnly)
     mEnsureVRootWindowSecurityTimer = new TQTimer( this );
     connect( mEnsureVRootWindowSecurityTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(repaintRootWindowIfNeeded()) );
 
+    connect(tqApp, TQT_SIGNAL(mouseInteraction(XEvent *)), TQT_SLOT(slotMouseActivity(XEvent *)));
+
     mHackDelayStartupTimeout = trinity_desktop_lock_delay_screensaver_start?KDesktopSettings::timeout()*1000:10*1000;
     mHackStartupEnabled = trinity_desktop_lock_delay_screensaver_start?KDesktopSettings::screenSaverEnabled():true;
 
@@ -2200,4 +2207,64 @@ void LockProcess::sendVkbdFocusInOut( WId window, Time t )
     }
 }
 
+void LockProcess::slotMouseActivity(XEvent *event)
+{
+	bool inFrame = 0;
+	bool inDialog = 0;
+	XButtonEvent *be = (XButtonEvent *) event;
+	XMotionEvent *me = (XMotionEvent *) event;
+	if (event->type == ButtonPress) {
+		// Get geometry including window frame/titlebar
+		TQRect fgeom = mDialogs.first()->frameGeometry();
+		TQRect wgeom = mDialogs.first()->geometry();
+
+		if (((be->x_root > fgeom.x()) && (be->y_root > fgeom.y())) && ((be->x_root < (fgeom.x()+fgeom.width())) && (be->y_root < (fgeom.y()+fgeom.height())))) {
+			inFrame = 1;
+		}
+		if (((be->x_root > wgeom.x()) && (be->y_root > wgeom.y())) && ((be->x_root < (wgeom.x()+wgeom.width())) && (be->y_root < (wgeom.y()+wgeom.height())))) {
+			inDialog = 1;
+		}
+
+		// Clicked inside dialog; set focus
+		if (inFrame == TRUE) {
+			WId window = mDialogs.first()->winId();
+			XSetInputFocus(qt_xdisplay(), window, RevertToParent, CurrentTime);
+			fakeFocusIn(window);
+			// Why this needs to be repeated I have no idea...
+			XSetInputFocus(qt_xdisplay(), window, RevertToParent, CurrentTime);
+			fakeFocusIn(window);
+		}
+
+		// Clicked inside window handle (or border); drag window
+		if ((inFrame == TRUE) && (inDialog == FALSE)) {
+			TQPoint oldPoint = mDialogs.first()->pos();
+			m_mouseDown = 1;
+			m_dialogPrevX = oldPoint.x();
+			m_dialogPrevY = oldPoint.y();
+			m_mousePrevX = be->x_root;
+			m_mousePrevY = be->y_root;
+			XChangeActivePointerGrab( qt_xdisplay(), GRABEVENTS, TQCursor(tqsizeAllCursor).handle(), CurrentTime);
+		}
+	}
+
+	// Drag the window...
+	if (event->type == MotionNotify) {
+		if (m_mouseDown == TRUE) {
+			int deltaX = me->x_root - m_mousePrevX;
+			int deltaY = me->y_root - m_mousePrevY;
+			m_dialogPrevX = m_dialogPrevX + deltaX;
+			m_dialogPrevY = m_dialogPrevY + deltaY;
+			mDialogs.first()->move(m_dialogPrevX, m_dialogPrevY);
+
+			m_mousePrevX = me->x_root;
+			m_mousePrevY = me->y_root;
+		}
+	}
+
+	if (event->type == ButtonRelease) {
+		m_mouseDown = 0;
+		XChangeActivePointerGrab( qt_xdisplay(), GRABEVENTS, TQCursor(tqarrowCursor).handle(), CurrentTime);
+	}
+}
+
 #include "lockprocess.moc"
diff --git a/kdesktop/lock/lockprocess.h b/kdesktop/lock/lockprocess.h
index 3a7e3db..18320a8 100644
--- a/kdesktop/lock/lockprocess.h
+++ b/kdesktop/lock/lockprocess.h
@@ -94,6 +94,7 @@ private slots:
     bool closeCurrentWindow();
     void repaintRootWindowIfNeeded();
     void startSecureDialog();
+    void slotMouseActivity(XEvent *event);
 
 private:
     void configure();
@@ -197,6 +198,12 @@ private:
     KSMModalDialog* m_startupStatusDialog;
 
     TQDateTime mlockDateTime;
+
+    bool m_mouseDown;
+    int m_mousePrevX;
+    int m_mousePrevY;
+    int m_dialogPrevX;
+    int m_dialogPrevY;
 };
 
 #endif
diff --git a/kdesktop/lock/main.h b/kdesktop/lock/main.h
index c8e0e05..23797e4 100644
--- a/kdesktop/lock/main.h
+++ b/kdesktop/lock/main.h
@@ -32,6 +32,7 @@ protected:
     bool x11EventFilter( XEvent * );
 signals:
     void activity();
+    void mouseInteraction(XEvent *event);
 private:
     time_t lastTick;
 };