How to detect mouse scroll events with the emulated mouse (connecting to a pc by VNC)?

Viewed 14

Does anyone have any idea why the scroll is not tracked when I remotely connect to the computer via VNC? The scroll action itself is tracked, but the delta is always 0 (event->delta_y). I want to be able to detect in which direction I scroll (Up or Down) while working with my application remotely - using VNC. I was trying to go around this problem by using x11. This system tracks mouse scroll events correctly, but I must create a loop to track the event, not what I want. Also I was trying to get ( event->direction ), but it always returns SMOOTH_SCROLL, but should return the particular direction. The code I have now:

bool OcctGtkViewer::onMouseScroll(GdkEventScroll *theEvent)
{
  bool isPressed = false;
  int init_x, init_y, fin_x, fin_y;
  Display *xdisplay = XOpenDisplay(0);
  XEvent xevent;
  ::Window xroot = gdk_x11_window_get_xid(gtk_widget_get_window((GtkWidget   *)myGLArea->gobj()));
  int scr = DefaultScreen(xdisplay);

  const Graphic3d_Vec2d aNewPos2d =   myView->Window()->ConvertPointToBacking(Graphic3d_Vec2d(theEvent->x, theEvent->y));

  XGrabPointer(xdisplay, xroot, 1, ButtonPressMask | ButtonReleaseMask,     GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
  while (1)
  {
     XNextEvent(xdisplay, &xevent);

     if (xevent.type == ButtonPress)
     {
       switch (xevent.xbutton.button)
      {
        case Button4:
        if (true)
        {
          const Aspect_ScrollDelta aScroll(Graphic3d_Vec2i(aNewPos2d +  Graphic3d_Vec2d(0.5)), 1);

          if (UpdateMouseScroll(aScroll))
          {
            myGLArea->queue_draw();
          }

      break;
    }
    case Button5:
      if (true)
      {
        const Aspect_ScrollDelta aScroll(Graphic3d_Vec2i(aNewPos2d + Graphic3d_Vec2d(0.5)), -1);

        if (UpdateMouseScroll(aScroll))
        {
          myGLArea->queue_draw();
        }

        break;
      }
    default:
      break;
    }
  }

  break;
}

XFlush(xdisplay);
XCloseDisplay(xdisplay);

return true;
}
0 Answers
Related