[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2856.0. "VMS5.3-1 X server problem ?" by SX4GTO::TZAY (Grace Tzay, 415/691-4792, UCS-4 ) Fri Jun 01 1990 20:46

My application uses XLIB calls X$CREATE_PIX_FROM_BITMAP_DATA and
X$CREATE_PIXMAP_CURSOR to define specific cursor patterns. It then
calls X$DEFINE_CURSOR on mouse button press events to change the cursor
pattern. This method seems to work fine up through VMS V5.3. I have several
users who have upgraded to VMS V5.3-1 and have noticed the following problem:

When the mouse buttton is pressed, the location of the cursor seems to move
(i.e. the hot spot is no longer where it used to be with the previous
cursor pattern).

There were some changes to the $QIO interface for VMS V5.3-1--however, my
application only uses the XLIB interface. Is it possible that the X-library
didn't change to account for the new QIO fix ??

Has anybody else seen or heard of this problem and can you offer me any
suggestions or fixes ??

-------------- here is the program ----------------------
/*
This program represents an approximation of the mouse pointer handling
portion of COINS. It open a small window and draws a tiny box in it. Move
the mouse until the tip of the pointer is in the tiny box. Press any mouse 
button. The finger nail of the pointing hand should now be in the box. 
Releasing the mouse button should result in the tip of the arrow being in the
box. Run this program both on VMS V5.3 and V5.3-1 and observe the differences.
To exit the program, simply press any key on the keyboard
*/
#include <decw$include/Xlib.h>
#include <decw$include/Xutil.h>
#define wX 300
#define wY 300
#define wW 60
#define wH 40
#define wB 0

#define cWidth 16
#define cHeight 16
#define cDepth 1

#define arrow 0
#define pHand 1

Display *dpy;
Screen *screen;
Window window;
GC gc;

char cData[2][32] = {
 {0x03, 0x00, 0x05, 0x00, 0x09, 0x00, 0x11, 0x00, 0x21, 0x00, 0x41, 0x00,
  0x81, 0x00, 0x01, 0x01, 0x01, 0x02, 0xc1, 0x07, 0x49, 0x00, 0x95, 0x00,
  0x93, 0x00, 0x21, 0x01, 0x20, 0x01, 0xc0, 0x01},
 {0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x48, 0x00, 0x24, 0x00, 0x32, 0x00,
  0xf2, 0x7f, 0x0a, 0x80, 0xf6, 0x7f, 0x12, 0x04, 0xf2, 0x07, 0x12, 0x02,
  0xf2, 0x03, 0x16, 0x01, 0xfc, 0x01, 0x00, 0x00}
 };
char cMaskData[2][32] = {
 {0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, 0x3f, 0x00, 0x7f, 0x00,
  0xff, 0x00, 0xff, 0x01, 0xff, 0x03, 0xff, 0x07, 0x7f, 0x00, 0xf7, 0x00,
  0xf3, 0x00, 0xe1, 0x01, 0xe0, 0x01, 0xc0, 0x01},
 {0x00, 0x00, 0x70, 0x00, 0xf8, 0x00, 0xfc, 0x00, 0x7e, 0x00, 0xff, 0x7f,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0x0f, 0xff, 0x07, 
  0xff, 0x07, 0xff, 0x03, 0xfe, 0x03, 0xfc, 0x03}
 };
int cursors[2];
int cXHotSpot[2] = {1, 15};
int cYHotSpot[2] = {0,  8};

XEvent theEvent;

static int InitGrafix( );
static void TrackCursor( );
static int XtoMeta( );

/********************** The main program *******************************/

static int main()
{          
    if (InitGrafix() == 0) {
      TrackCursor();
      XDrawRectangle(dpy, window, gc, 20, 20, 4, 4);
      do {
          XNextEvent(dpy, &theEvent);
      } while (!XtoMeta(theEvent));
      XCloseDisplay(dpy);
    }
}                                        

/********************** InitGrafix *************************************/
static int InitGrafix( )
{
XSetWindowAttributes xswa;
XGCValues xgcv;

  dpy = XOpenDisplay(0);        
  if (!dpy){
      return -1;
  }
    screen = XDefaultScreenOfDisplay(dpy);
  xswa.background_pixel = WhitePixelOfScreen(screen);
  xswa.event_mask = KeyPressMask | ButtonPressMask | ButtonReleaseMask ;
  window = XCreateWindow(dpy, XRootWindowOfScreen(screen), wX, wY, wW, wH,
                         wB, XDefaultDepthOfScreen(screen), InputOutput,
                         XDefaultVisualOfScreen(screen), 
                         CWEventMask|CWBackPixel, &xswa);
  xgcv.foreground = XBlackPixelOfScreen(screen);
  xgcv.background = XWhitePixelOfScreen(screen);
  xgcv.plane_mask = xgcv.foreground ^ xgcv.background;
  gc = XCreateGC(dpy, window, GCForeground | GCBackground | GCPlaneMask,
                 &xgcv);   
  XMapWindow(dpy,window);
  XFlush(dpy);
  XSetInputFocus(dpy, window, RevertToPointerRoot, CurrentTime);

  return 0;
} 

/********************** TrackCursor *************************************/
static void TrackCursor( )
{
int pixmap, cursorPixmap, cursorMaskPixmap;
int status;
XColor foreColor, backColor, exactColor;
int theCursor;

  pixmap = XCreatePixmap(dpy, window, cWidth, cHeight, cDepth);
  status = XAllocNamedColor(dpy, XDefaultColormapOfScreen(screen),
              "Black", &foreColor, &exactColor);
  status = XAllocNamedColor(dpy, XDefaultColormapOfScreen(screen),
              "White", &backColor, &exactColor);
  for (theCursor = 0; theCursor < 2; theCursor++) {
    cursorPixmap = XCreatePixmapFromBitmapData(dpy, pixmap, cData[theCursor], 
                     cWidth, cHeight, XWhitePixelOfScreen(screen),
                     XBlackPixelOfScreen(screen), cDepth);
    cursorMaskPixmap = XCreatePixmapFromBitmapData(dpy, pixmap, 
                        cMaskData[theCursor], cWidth, cHeight,
                        XWhitePixelOfScreen(screen), 
                        XBlackPixelOfScreen(screen), cDepth);
    cursors[theCursor] = XCreatePixmapCursor(dpy, cursorPixmap,
                           cursorMaskPixmap, &foreColor, &backColor,
                           cXHotSpot[theCursor], cYHotSpot[theCursor]);
  }
  XDefineCursor(dpy, window, cursors[arrow]);
}

/********************** XtoMeta *************************************/
static int XtoMeta(x)
XEvent x;
{
Bool translates;

  translates = False;
  switch (x.type) {
    case KeyPress: translates = True;
                   break;
    case ButtonPress: XDefineCursor(dpy, window, cursors[pHand]);
                      break;
    case ButtonRelease: XDefineCursor(dpy, window, cursors[arrow]);
                        break;
    }
  return translates;
}

T.RTitleUserPersonal
Name
DateLines
2856.1CVG::PETTENGILLmulpFri Jun 01 1990 21:511
I hope this is QAR'd....