Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Problem using XLookupString

$
0
0
I am having trouble with the following function, giving the error

Code:

xbuplot.c: In function ‘void xbuevent_(float*, float*, int*, char*)’:
xbuplot.c:694:65: error: cannot convert ‘XEvent* {aka _XEvent*}’ to ‘XKeyEvent*’ for argument ‘1’ to ‘int XLookupString(XKeyEvent*, char*, int, KeySym*, XComposeStatus*)’
make: *** [../pltlib/xbuplot.o] Error 1

Code:

void xbuevent_ (
  float* x_mm,
  float* y_mm,  /*  position of cursor in mm  */
  int* button,  /*  button that was pressed  */
  char* key  /*  key that was pressed  */
) {

  XEvent event;
 
  // CHRISD:
  //XEvent *event;
  //XKeyEvent *keyevent;
 
  KeySym keysym;
  XComposeStatus compose;
  char buffer = 0;
  int buflen = 1;
  int got_event = 0;

  *button = *key = 0;    /* initialize button and key to zero */

  /* loop until we get a key or button press that we want */
  while (!got_event)
  {
    /* get next button or key press event */
    XMaskEvent (display, ButtonPressMask | KeyPressMask, &event);
    switch (event.type)
    {
      case ButtonPress:
        *button = event.xbutton.button;
        *x_mm = (double) event.xbutton.x / (double) win_width * win_width_mm;
        *y_mm = (double) (win_height - event.xbutton.y) / (double) win_height
        * win_height_mm;
        got_event++;
        break;
      case KeyPress:
        //XLookupString (&event, &buffer, buflen, &keysym, &compose);
        XLookupString (&event, buffer, buflen, &keysym, &compose);
        switch (keysym)
        {
          case XK_Shift_L:    /* ignore a key press from a key modifier */
          case XK_Shift_R:
          case XK_Control_L:
          case XK_Control_R:
          case XK_Caps_Lock:
          case XK_Shift_Lock:
          case XK_Meta_L:
          case XK_Meta_R:
          case XK_Alt_L:
          case XK_Alt_R:
          case XK_Super_L:
          case XK_Super_R:
          case XK_Hyper_L:
          case XK_Hyper_R:
            break;
          default:
            *key = buffer;
            *x_mm = (double) event.xkey.x / (double) win_width * win_width_mm;
            *y_mm = (double) (win_height - event.xkey.y) / (double) win_height
            * win_height_mm;
            got_event++;
            break;
        }
    }
  }
}


Viewing all articles
Browse latest Browse all 16232

Trending Articles