[comp.sources.x] v09i063: xnlock - X version of "nlock", Patch1, Part01/01

argv@sun.com (Dan Heller) (10/01/90)

Submitted-by: Dan Heller <argv@sun.com>
Posting-number: Volume 9, Issue 63
Archive-name: xnlock/patch1
Patch-To: xnlock: Volume 6, Issue 88

Terribly sorry for taking so long to get this out....
This is the first patch to xnlock.  Changes include:

    o  full pathname for "fortune" program.
    o  removed annoying "test" where little man walks from button click
    o  cursor is now invisible

I'd still like to remove the need for XGrabServer().  If someone has
suggestions, I'd love to hear them.

Prereq: 0
*** patchlevel.h.orig	Wed Apr 25 15:49:07 1990
--- patchlevel.h	Wed Apr 25 15:48:59 1990
***************
*** 1 ****
! #define PATCHLEVEL 0
--- 1 ----
! #define PATCHLEVEL 1
*** xnlock.c.orig	Mon Apr 23 12:02:47 1990
--- xnlock.c	Sun Sep 30 10:33:34 1990
***************
*** 15,21 ****
  #include <ctype.h>
  #include <pwd.h>
  /* The program should be something that outputs a small amount of text */
! #define DEFAULT_PROGRAM "fortune -s"
  #define font_height(font)	  	(font->ascent + font->descent)
  #define FONT_NAME	"-*-new century schoolbook-*-*-*-18-*"
  #define when 		break;case
--- 15,23 ----
  #include <ctype.h>
  #include <pwd.h>
  /* The program should be something that outputs a small amount of text */
! #ifndef DEFAULT_PROGRAM
! #define DEFAULT_PROGRAM "/usr/games/fortune -s"
! #endif
  #define font_height(font)	  	(font->ascent + font->descent)
  #define FONT_NAME	"-*-new century schoolbook-*-*-*-18-*"
  #define when 		break;case
***************
*** 39,45 ****
  unsigned long	interval, look();
  Pixmap		left0, left1, right0, right1, left_front,
  		right_front, front, down;
- int test;
  
  #define FROM_ARGV    1
  #define FROM_PROGRAM 2
--- 41,46 ----
***************
*** 121,128 ****
  
      XtToolkitInitialize();
      app = XtCreateApplicationContext();
!     dpy = XtOpenDisplay(app, NULL,
! 	"xnlock", "XNlock", options, XtNumber(options), &argc, argv);
  
      Width = DisplayWidth(dpy, DefaultScreen(dpy)) + 2;
      Height = DisplayHeight(dpy, DefaultScreen(dpy)) + 2;
--- 122,132 ----
  
      XtToolkitInitialize();
      app = XtCreateApplicationContext();
!     if (!(dpy = XtOpenDisplay(app, NULL,
! 	"xnlock", "XNlock", options, XtNumber(options), &argc, argv))) {
! 	fprintf(stderr, "%s: can't open display.\n", argv[0]);
! 	exit(1);
!     }
  
      Width = DisplayWidth(dpy, DefaultScreen(dpy)) + 2;
      Height = DisplayHeight(dpy, DefaultScreen(dpy)) + 2;
***************
*** 181,186 ****
--- 185,206 ----
      }
  
      XtRealizeWidget(override);
+ 
+ 
+     /* make cursor (virtually) invisible */
+     {
+ 	Pixmap pixmap = XCreatePixmap(dpy, XtWindow(widget), 1, 1, 1);
+ 	Colormap cmap;
+ 	XColor color; /* foreground and background */
+ 	Cursor cursor;
+ 	color.pixel = Black;
+ 	XtVaGetValues(widget, XtNcolormap, &cmap, NULL);
+ 	XQueryColor(dpy, cmap, &color);
+ 	cursor = XCreatePixmapCursor(dpy, pixmap, None, &color, &color, 0, 0);
+ 	XFreePixmap(dpy, pixmap);
+ 	XDefineCursor(dpy, XtWindow(widget), cursor);
+     }
+ 
      XGrabServer(dpy);
      ScreenSaver(1);
      XtAppMainLoop(app);
***************
*** 347,356 ****
      KeySym keysym;
      Modifiers foo;
  
-     if (event->type == ButtonPress) {
- 	x = event->x, y = event->y, test = 2;
- 	return;
-     }
      if (state == IS_MOVING) {
  	/* guy is running around--change to post prompt box. */
  	XtRemoveTimeOut(timeout_id);
--- 367,372 ----
***************
*** 645,651 ****
  {
      int width = 0, height, Z, total = 0;
      static int X, Y, talking;
!     static struct { int x, y, width, height } s_rect;
      register char *p, *p2;
      char buf[BUFSIZ], *strcpy(), *index(), args[MAXLINES][256];
  
--- 661,667 ----
  {
      int width = 0, height, Z, total = 0;
      static int X, Y, talking;
!     static struct { int x, y, width, height; } s_rect;
      register char *p, *p2;
      char buf[BUFSIZ], *strcpy(), *index(), args[MAXLINES][256];
  
dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.