*** xv.c.orig	Sat Apr 25 20:01:14 1998
--- xv.c	Sat Apr 25 20:07:30 1998
***************
*** 1990,1999 ****
  #else /* it is VMS */
        sprintf(filename, "[]xvXXXXXX");
  #endif
!       mktemp(filename);
  
        clearerr(stdin);
-       fp = fopen(filename,"w");
        if (!fp) FatalError("openPic(): can't write temporary file");
      
        while ( (i=getchar()) != EOF) putc(i,fp);
--- 1990,1998 ----
  #else /* it is VMS */
        sprintf(filename, "[]xvXXXXXX");
  #endif
!       fp = fdopen(mkstemp(filename), "w");
  
        clearerr(stdin);
        if (!fp) FatalError("openPic(): can't write temporary file");
      
        while ( (i=getchar()) != EOF) putc(i,fp);
***************
*** 2755,2761 ****
    
  #ifndef VMS
    sprintf(uncompname, "%s/xvuXXXXXX", tmpdir);
!   mktemp(uncompname);
    sprintf(buf,"%s -c %s >%s", UNCOMPRESS, fname, uncompname);
  #else /* it IS VMS */
    strcpy(uncompname, "[]xvuXXXXXX");
--- 2754,2760 ----
    
  #ifndef VMS
    sprintf(uncompname, "%s/xvuXXXXXX", tmpdir);
!   close(mkstemp(uncompname));
    sprintf(buf,"%s -c %s >%s", UNCOMPRESS, fname, uncompname);
  #else /* it IS VMS */
    strcpy(uncompname, "[]xvuXXXXXX");
***************
*** 2930,2937 ****
    if (!cmd || (strlen(cmd) < (size_t) 2)) return 1;
  
    sprintf(tmpname,"%s/xvXXXXXX", tmpdir);
!   mktemp(tmpname);
!   if (tmpname[0] == '\0') {   /* mktemp() blew up */
      sprintf(str,"Unable to create temporary filename.");
      ErrPopUp(str, "\nHow unlikely!");
      return 1;
--- 2929,2936 ----
    if (!cmd || (strlen(cmd) < (size_t) 2)) return 1;
  
    sprintf(tmpname,"%s/xvXXXXXX", tmpdir);
!   close(mkstemp(tmpname));
!   if (tmpname[0] == '\0') {   /* mkstemp() blew up */
      sprintf(str,"Unable to create temporary filename.");
      ErrPopUp(str, "\nHow unlikely!");
      return 1;
***************
*** 3228,3236 ****
    hints.flags = 0;
    if ((i&XValue || i&YValue)) hints.flags = USPosition;
  
!   if (i&XValue && i&XNegative) x = vrWIDE - eWIDE - abs(x);
!   if (i&YValue && i&YNegative) y = vrHIGH - eHIGH - abs(y);
! 
    if (x+eWIDE > vrWIDE) x = vrWIDE - eWIDE;   /* keep on screen */
    if (y+eHIGH > vrHIGH) y = vrHIGH - eHIGH;
  
--- 3227,3243 ----
    hints.flags = 0;
    if ((i&XValue || i&YValue)) hints.flags = USPosition;
  
!   hints.win_gravity = NorthWestGravity;
!   if (i&XValue && i&XNegative) {
!     hints.win_gravity = NorthEastGravity;
!     x = vrWIDE - (eWIDE + 2 * bwidth) - abs(x);
!   }
!   if (i&YValue && i&YNegative) {
!     hints.win_gravity = (hints.win_gravity == NorthWestGravity) ?
! 	SouthWestGravity : SouthEastGravity;
!     y = vrHIGH - (eHIGH + 2 * bwidth) - abs(y);
!   }
!  
    if (x+eWIDE > vrWIDE) x = vrWIDE - eWIDE;   /* keep on screen */
    if (y+eHIGH > vrHIGH) y = vrHIGH - eHIGH;
  
***************
*** 3249,3255 ****
    hints.x = x;                  hints.y = y;
    hints.width = eWIDE;          hints.height = eHIGH;
    hints.max_width  = maxWIDE;   hints.max_height = maxHIGH;
!   hints.flags |= USSize | PMaxSize;
      
    xswa.bit_gravity = StaticGravity;
    xswa.background_pixel = bg;
--- 3256,3262 ----
    hints.x = x;                  hints.y = y;
    hints.width = eWIDE;          hints.height = eHIGH;
    hints.max_width  = maxWIDE;   hints.max_height = maxHIGH;
!   hints.flags |= USSize | PMaxSize | PWinGravity;
      
    xswa.bit_gravity = StaticGravity;
    xswa.background_pixel = bg;
***************
*** 3298,3307 ****
      }
    }
  
- 
-   XSetStandardProperties(theDisp,mainW,"","",None,NULL,0,&hints);
-   setWinIconNames(name);
- 
    xwmh.input = True;
    xwmh.flags = InputHint;
  
--- 3305,3310 ----
***************
*** 3326,3337 ****
        }
      }
    }
-   XSetWMHints(theDisp, mainW, &xwmh);
  
    classh.res_name = "xv";
    classh.res_class = "XVroot";
-   XSetClassHint(theDisp, mainW, &classh);
  
  
    if (nodecor) {   /* turn of image window decorations (in MWM) */ 
      Atom mwm_wm_hints;
--- 3329,3340 ----
        }
      }
    }
  
    classh.res_name = "xv";
    classh.res_class = "XVroot";
  
+   XmbSetWMProperties(theDisp, mainW, NULL, NULL, NULL, 0, &hints, &xwmh, &classh);
+   setWinIconNames(name);
  
    if (nodecor) {   /* turn of image window decorations (in MWM) */ 
      Atom mwm_wm_hints;
