Esempio n. 1
0
File: mouse.c Progetto: CTU-OSP/mc
void
show_mouse_pointer (int x, int y)
{
#ifdef HAVE_LIBGPM
    if (use_mouse_p == MOUSE_GPM)
        Gpm_DrawPointer (x, y, gpm_consolefd);
#else
    (void) x;
    (void) y;
#endif /* HAVE_LIBGPM */
}
MEVENT* gpm_get_mouse_event( MEVENT* event )
{
    struct Gpm_Event ev;	/* Mouse event */
    struct timeval timeout;
    struct timeval *time_addr = NULL;
    
    int flag;
    fd_set select_set;

    if (!mouse_enabled) {
      return NULL;
    }

    FD_ZERO (&select_set);

    if (gpm_fd < 0) {
	mouse_enabled = 0;
	return NULL;
     } else {
	FD_SET (gpm_fd, &select_set);
     }

    time_addr = &timeout;
    timeout.tv_sec = 0;
    timeout.tv_usec = 200;

    flag = select (gpm_fd + 1, &select_set, NULL, NULL, time_addr);

    if (flag <= 0) {
	return NULL;
    }

    if (gpm_fd > 0 && FD_ISSET (gpm_fd, &select_set)) {
	    Gpm_GetEvent (&ev);
	    Gpm_FitEvent (&ev);
	    Gpm_DrawPointer (ev.x, ev.y, gpm_consolefd);
	    event->id = 0;
	    event->x = ev.x -1;
	    event->y = ev.y -1;
	    __gpm_to_curses(ev, event);
	    return event;
      }

    return NULL;
}
Esempio n. 3
0
File: mouse.c Progetto: dborca/mc
void show_mouse_pointer (int x, int y)
{
    if (use_mouse_p == MOUSE_GPM) {
	Gpm_DrawPointer (x, y, gpm_consolefd);
    }
}
Esempio n. 4
0
static int
gpmOpenConnection (void) {
  switch (gpmConnectionState) {
    case  GCS_CLOSED: {
      Gpm_Connect options = {
        .eventMask = GPM_MOVE,
        .defaultMask = ~0,
        .minMod = 0,
        .maxMod = ~0
      };

      gpm_tried = 0;
      gpm_zerobased = 1;

      if (Gpm_Open(&options, -1) == -1) {
        logMessage(GPM_LOG_LEVEL, "GPM open error: %s", strerror(errno));
        asyncSetAlarmIn(NULL, 5000, gpmResetConnection, NULL);
        gpmConnectionState = GCS_FAILED;
        return 0;
      }

      logMessage(GPM_LOG_LEVEL, "GPM opened: fd=%d con=%d", gpm_fd, gpm_consolefd);
      gpmConnectionState = GCS_OPENED;
    }

    case GCS_OPENED:
      return 1;
  }

  return 0;
}

static void
gpmCloseConnection (int alreadyClosed) {
  if (gpmConnectionState == GCS_OPENED) {
    if (!alreadyClosed) Gpm_Close();
    logMessage(GPM_LOG_LEVEL, "GPM closed");
  }
  gpmConnectionState = GCS_CLOSED;
}
#endif /* HAVE_LIBGPM */

static int
routeCursor_RealScreen (int column, int row, int screen) {
  return startRouting(column, row, screen);
}

static int
highlightRegion_RealScreen (int left, int right, int top, int bottom) {
  FILE *console = getConsole();

  if (console) {
#ifdef HAVE_LIBGPM
    if (gpmOpenConnection() && (gpm_fd >= 0)) {
      if (Gpm_DrawPointer(left, top, fileno(console)) != -1) return 1;

      if (errno != EINVAL) {
        logMessage(GPM_LOG_LEVEL, "Gpm_DrawPointer error: %s", strerror(errno));
        gpmCloseConnection(0);
        return 0;
      }
    }
#endif /* HAVE_LIBGPM */
  }

  return 0;
}