1440N/A--- a/greeter/Login.h-orig Thu Sep 17 19:24:37 2009
1440N/A+++ b/greeter/Login.h Mon Feb 24 00:45:55 2014
1440N/A@@ -100,6 +100,7 @@
1440N/A # define XtNgreetFace "greetFace"
1440N/A # define XtNfailFace "failFace"
1440N/A # define XtNfailTimeout "failTimeout"
1440N/A+# define XtNgrabDelay "grabDelay"
1440N/A # define XtNsessionArgument "sessionArgument"
1440N/A # define XtNsecureSession "secureSession"
1440N/A # define XtNallowAccess "allowAccess"
1440N/A@@ -140,6 +141,7 @@
1440N/A # define XtCPasswdPrompt "PasswdPrompt"
1440N/A # define XtCFail "Fail"
1440N/A # define XtCFailTimeout "FailTimeout"
1440N/A+# define XtCGrabDelay "GrabDelay"
1440N/A # define XtCSessionArgument "SessionArgument"
1440N/A # define XtCSecureSession "SecureSession"
1440N/A # define XtCAllowAccess "AllowAccess"
1440N/A--- a/greeter/LoginP.h-orig Thu Sep 17 19:24:37 2009
1440N/A+++ b/greeter/LoginP.h Mon Feb 24 00:46:53 2014
1440N/A@@ -130,6 +130,7 @@
1440N/A char *sessionArg; /* argument passed to session */
1440N/A LoginFunc notify_done; /* proc to call when done */
1440N/A int failTimeout; /* seconds til drop fail msg */
1440N/A+ int grabDelay; /* time to retry to set the input focus to the login widget */
1440N/A XtIntervalId interval_id; /* drop fail message note */
1440N/A Boolean secure_session; /* session is secured */
1440N/A Boolean allow_access; /* disable access control on login */
1440N/A--- a/greeter/Login.c-orig Wed Feb 26 01:36:09 2014
1440N/A+++ b/greeter/Login.c Wed Feb 26 01:21:35 2014
1440N/A@@ -217,6 +217,8 @@
1440N/A (XtPointer) "Password Change Required" },
1440N/A {XtNfailTimeout, XtCFailTimeout, XtRInt, sizeof (int),
1440N/A offset(failTimeout), XtRImmediate, (XtPointer) 10},
1440N/A+ {XtNgrabDelay, XtCGrabDelay, XtRInt, sizeof (int),
1440N/A+ offset(grabDelay), XtRImmediate, (XtPointer) 10},
1440N/A {XtNnotifyDone, XtCCallback, XtRFunction, sizeof (XtPointer),
1440N/A offset(notify_done), XtRFunction, (XtPointer) 0},
1440N/A {XtNsessionArgument, XtCSessionArgument, XtRString, sizeof (char *),
1440N/A@@ -665,6 +667,37 @@
1440N/A ErrorMessage(ctx, w->login.passwdChangeMsg, False);
1440N/A }
1440N/A
1440N/A+const char *
1440N/A+xerrMessage(int e)
1440N/A+{
1440N/A+ const char *s;
1440N/A+
1440N/A+ switch (e) {
1440N/A+
1440N/A+ case BadMatch:
1440N/A+ s = "window is not visible";
1440N/A+ break;
1440N/A+
1440N/A+ case BadWindow:
1440N/A+ s = "window is no longer valid";
1440N/A+ break;
1440N/A+
1440N/A+ default:
1440N/A+ s = "generic failure";
1440N/A+ break;
1440N/A+ }
1440N/A+ return s;
1440N/A+}
1440N/A+
1440N/A+static volatile int xerr;
1440N/A+
1440N/A+static int
1440N/A+xErrorHandler(Display *d, XErrorEvent *xeep)
1440N/A+{
1440N/A+ xerr = xeep->error_code;
1440N/A+ return xerr;
1440N/A+}
1440N/A+
1440N/A static void
1440N/A draw_it (LoginWidget w)
1440N/A {
1440N/A@@ -770,8 +803,40 @@
1440N/A }
1440N/A RedrawFail (w);
1440N/A XorCursor (w);
1440N/A- XSetInputFocus (XtDisplay (w), XtWindow (w),
1440N/A- RevertToPointerRoot, CurrentTime);
1440N/A+
1440N/A+ if (XGrabKeyboard (XtDisplay (w), XtWindow (w), False, GrabModeAsync,
1440N/A+ GrabModeAsync, CurrentTime) != GrabSuccess)
1440N/A+ {
1440N/A+ typedef int (*x_e_h)(Display *, XErrorEvent *);
1440N/A+ x_e_h originalHandler = XSetErrorHandler(xErrorHandler);
1440N/A+ int waitsecs = w->login.grabDelay;
1440N/A+ for (;;) {
1440N/A+ xerr = Success;
1440N/A+ XSetInputFocus (XtDisplay (w), XtWindow (w),
1440N/A+ RevertToPointerRoot, CurrentTime);
1440N/A+ XSync(XtDisplay (w), False);
1440N/A+
1440N/A+ if (xerr != BadMatch) {
1440N/A+ break;
1440N/A+ }
1440N/A+
1440N/A+ if (waitsecs == 0) { /* timed out */
1440N/A+ break;
1440N/A+ }
1440N/A+
1440N/A+ if (waitsecs > 0) {
1440N/A+ sleep(1);
1440N/A+ --waitsecs;
1440N/A+ }
1440N/A+ }
1440N/A+ (void) XSetErrorHandler(originalHandler);
1440N/A+
1440N/A+ if (xerr != Success) {
1440N/A+ fprintf(stderr, "%s: failed to set focus; %s\n",
1440N/A+ "greeter", xerrMessage(xerr));
1440N/A+ }
1440N/A+ }
1440N/A+
1440N/A }
1440N/A
1440N/A /* Returns 0 on success, -1 on failure */
1440N/A--- a/config/Xresources.cpp-orig Thu Sep 17 19:24:37 2009
1440N/A+++ b/config/Xresources.cpp Mon Feb 24 01:06:12 2014
1440N/A@@ -5,6 +5,7 @@
1440N/A !
1440N/A
1440N/A Xcursor.theme: whiteglass
1440N/A+xlogin*grabDelay: 5
1440N/A
1440N/A #define BS \ /* cpp can be trickier than m4 */
1440N/A #define NLBS \n\ /* don't remove these comments */