From 43cfae67edd4d8eb92364be2d9bd19f27ef4ef87 Mon Sep 17 00:00:00 2001 From: Unknown User d91-jda Date: Thu, 22 Feb 1996 22:58:29 +0000 Subject: [PATCH] Fixed a few bugs as reported by Fredrik Ljungberg . git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@278 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/xnlock/xnlock.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/appl/xnlock/xnlock.c b/appl/xnlock/xnlock.c index 0bac7cfba..fc46b5146 100644 --- a/appl/xnlock/xnlock.c +++ b/appl/xnlock/xnlock.c @@ -56,7 +56,7 @@ char STRING[] = "****************"; #define X_INCR 3 #define Y_INCR 2 #define CTRL 1 -#define NOCTRL 1 +#define NOCTRL 0 XtAppContext app; Display *dpy; @@ -466,6 +466,18 @@ post_prompt_box(Window window) time_y += 2*font_height(font); } +static void +RaiseWindow(Widget w, XEvent *ev, String *s, Cardinal *n) +{ + Widget x; + if(!XtIsRealized(w)) + return; + x = XtParent(w); + fprintf(stderr, "%s\n", XtName(x)); + XRaiseWindow(dpy, XtWindow(x)); +} + + static void ClearWindow(Widget w, XEvent *_event, String *_s, Cardinal *_n) { @@ -489,12 +501,6 @@ ClearWindow(Widget w, XEvent *_event, String *_s, Cardinal *_n) } } -static void -Visibility(Widget w, XtPointer client_data, XEvent *event, Boolean *_b) -{ - XRaiseWindow(dpy, XtWindow(w)); -} - static void countdown(XtPointer _t, XtIntervalId *_d) { @@ -636,7 +642,7 @@ GetPasswd(Widget w, XEvent *_event, String *_s, Cardinal *_n) if (keysym == XK_BackSpace || keysym == XK_Delete || keysym == XK_Left) { if (cnt) passwd[cnt--] = ' '; - } else if (keysym == XK_u && is_ctrl == 1) { + } else if (keysym == XK_u && is_ctrl == CTRL) { while (cnt) { passwd[cnt--] = ' '; XDrawImageString(dpy, XtWindow(w), gc, @@ -901,12 +907,14 @@ main (int argc, char **argv) Width = DisplayWidth(dpy, DefaultScreen(dpy)) + 2; Height = DisplayHeight(dpy, DefaultScreen(dpy)) + 2; override = XtVaAppCreateShell("xnlock", "XNlock", - overrideShellWidgetClass, dpy, XtNx, -1, XtNy, -1, NULL); + overrideShellWidgetClass, dpy, + XtNx, -1, + XtNy, -1, + NULL); + XtGetApplicationResources(override, &Resrcs, resources, XtNumber(resources), NULL, 0); - XtAddEventHandler(override, VisibilityChangeMask, FALSE, Visibility, NULL); - widget = XtVaCreateManagedWidget("_foo", widgetClass, override, XtNwidth, Width, XtNheight, Height, @@ -950,13 +958,16 @@ main (int argc, char **argv) static XtActionsRec actions[] = { { "ClearWindow", ClearWindow }, { "GetPasswd", GetPasswd }, + { "RaiseWindow", RaiseWindow }, }; XtAppAddActions(app, actions, XtNumber(actions)); XtOverrideTranslations(widget, - XtParseTranslationTable( - ": ClearWindow() \n\ - : GetPasswd() \n\ - : GetPasswd()")); + XtParseTranslationTable( + ": ClearWindow() \n" + ": GetPasswd() \n" + ": RaiseWindow() \n" + ": GetPasswd() \n" + ": GetPasswd()")); } XtRealizeWidget(override);