home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume3 / awm2 / part10 / Raise.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-02-21  |  3.6 KB  |  115 lines

  1.  
  2.  
  3.  
  4. #ifndef lint
  5. static char *rcsid_Raise_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/Raise.c,v 1.2 89/02/07 21:23:28 jkh Exp $";
  6. #endif  lint
  7.  
  8. #include "X11/copyright.h"
  9. /*
  10.  *
  11.  * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  12.  *
  13.  * Copyright 1987 by Jordan Hubbard.
  14.  *
  15.  *
  16.  *                         All Rights Reserved
  17.  *
  18.  * Permission to use, copy, modify, and distribute this software and its
  19.  * documentation for any purpose and without fee is hereby granted,
  20.  * provided that the above copyright notice appear in all copies and that
  21.  * both that copyright notice and this permission notice appear in
  22.  * supporting documentation, and that the name of Ardent Computer
  23.  * Corporation or Jordan Hubbard not be used in advertising or publicity
  24.  * pertaining to distribution of the software without specific, written
  25.  * prior permission.
  26.  *
  27.  */
  28.  
  29. /*
  30.  * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  31.  *
  32.  *                         All Rights Reserved
  33.  *
  34.  * Permission to use, copy, modify, and distribute this software and its
  35.  * documentation for any purpose and without fee is hereby granted,
  36.  * provided that the above copyright notice appear in all copies and that
  37.  * both that copyright notice and this permission notice appear in
  38.  * supporting documentation, and that the name of Digital Equipment
  39.  * Corporation not be used in advertising or publicity pertaining to
  40.  * distribution of the software without specific, written prior permission.
  41.  *
  42.  *
  43.  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  44.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  45.  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  46.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  47.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  48.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  49.  * SOFTWARE.
  50.  */
  51.  
  52.  
  53. /*
  54.  * MODIFICATION HISTORY
  55.  *
  56.  * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  57.  * 001 -- R. Kittell, DEC Storage A/D May 19, 1986
  58.  *  Optionally warp mouse to upper right corner of window after raise.
  59.  * 002 -- Loretta Guarino Reid, DEC Ultrix Engineering Group
  60.  *  Western Software Lab. Convert to X11.
  61.  * 003 -- Jordan Hubbard, Ardent Computer
  62.  *  Changed for awm.
  63.  */
  64.  
  65. #include "awm.h"
  66.  
  67. /*ARGSUSED*/
  68. Boolean Raise(window, mask, button, x, y)
  69. Window window;                          /* Event window. */
  70. int mask;                               /* Button/key mask. */
  71. int button;                               /* Button event detail. */
  72. int x, y;                               /* Event mouse position. */
  73.  
  74. {
  75.      XWindowAttributes winfo;            /* Window details for warp */
  76.      AwmInfoPtr awi;
  77.      int status, vpoint;
  78.      
  79.      Entry("Raise")
  80.      
  81.      /*
  82.       * If the window is not the root window, raise the window and return.
  83.       */
  84.  
  85.      awi = GetAwmInfo(window);
  86.      if (!awi)
  87.       Leave(FALSE)
  88.      if (window != RootWindow(dpy, scr)) {
  89.       window = awi->frame ? awi->frame : awi->client;
  90.       XRaiseWindow(dpy, window);
  91.       if (awi->frame)
  92.            vpoint = 10 + titleHeight + 2;
  93.       else
  94.            vpoint = 10;
  95.       /*
  96.        * Optionally warp the mouse to the upper left corner of the window.
  97.        */
  98.       if (WarpOnRaise) {
  99.            status = XGetWindowAttributes (dpy, window, &winfo);
  100.            if (status == FAILURE)
  101.             Leave(FALSE)
  102.            
  103.            status = XWarpPointer (dpy, None, window, 
  104.                       0, 0, 0, 0,
  105.                       winfo.width >= 7 ? winfo.width - 7 :
  106.                       winfo.width / 2,
  107.                       winfo.height >= vpoint ? vpoint :
  108.                       winfo.height / 2);
  109.            if (status == FAILURE)
  110.             Leave(FALSE)
  111.       }
  112.      }
  113.      Leave(FALSE)
  114. }
  115.