Esempio n. 1
0
int
xf86RemoveGeneralHandler(pointer handler)
{
    IHPtr ih;
    int fd;

    if (!handler)
	return -1;

    ih = handler;
    fd = ih->fd;

    if (ih->fd >= 0)
	RemoveGeneralSocket(ih->fd);
    removeInputHandler(ih);

    return fd;
}
Esempio n. 2
0
int
xf86RemoveInputHandler(pointer handler)
{
    IHPtr ih;
    int fd;

    if (!handler)
	return -1;

    ih = handler;
    fd = ih->fd;

    if (ih->fd >= 0)
	RemoveEnabledDevice(ih->fd);
    removeInputHandler(ih);

    return fd;
}
Esempio n. 3
0
void nvimcom_Stop()
{
#ifndef WIN32
    if(ih){
        removeInputHandler(&R_InputHandlers, ih);
        close(ifd);
        close(ofd);
    }
#endif

    if(nvimcom_initialized){
        Rf_removeTaskCallbackByName("NVimComHandler");
#ifdef WIN32
        closesocket(sfd);
        WSACleanup();
#else
        close(sfd);
        pthread_cancel(tid);
        pthread_join(tid, NULL);
#endif
        ListStatus *tmp = firstList;
        while(tmp){
            firstList = tmp->next;
            free(tmp->key);
            free(tmp);
            tmp = firstList;
        }
        for(int i = 0; i < 64; i++){
            free(loadedlibs[i]);
            loadedlibs[i] = NULL;
        }
        if(obbrbuf1)
            free(obbrbuf1);
        if(obbrbuf2)
            free(obbrbuf2);
        if(verbose)
            REprintf("nvimcom stopped\n");
    }
    nvimcom_initialized = 0;
}
Esempio n. 4
0
File: Rgtk.c Progetto: hjy1210/RGtk2
void
R_gtkInit(long *rargc, char **rargv, Rboolean *success)
{
  int argc;

  argc = (int) *rargc;
  
  if (!gdk_display_get_default()) {
    gtk_disable_setlocale();
    if (!gtk_init_check(&argc, &rargv)) {
      *success = FALSE;
      return;
    }
  }

#ifndef G_OS_WIN32
  {
    int fds[2];

    if (!GDK_DISPLAY()) {
      *success = FALSE;
      return;
    }


    addInputHandler(R_InputHandlers, ConnectionNumber(GDK_DISPLAY()),
                    R_gtk_eventHandler, -1);

    /* Experimental timer-based piping to a file descriptor */
#ifdef G_THREADS_ENABLED
#ifndef __FreeBSD__
    if (!pipe(fds)) {
      ifd = fds[0];
      ofd = fds[1];
      eventLoopInputHandler = addInputHandler(R_InputHandlers, ifd,
                                              R_gtk_timerInputHandler, 32);
      if (!g_thread_supported ()) g_thread_init (NULL);
      eventLoopThread = g_thread_create(R_gtk_timerThreadFunc, NULL, TRUE,
                                        NULL);
      R_CStackLimit = -1;
    } else g_warning("Failed to establish pipe; "
                     "disabling timer-based event handling");
#endif
#endif
  }
#else
#if R_VERSION < R_Version(2,8,0)
  R_tcldo = R_gtk_handle_events;
#else
  
  /* Create a dummy window for receiving messages */
  LPCTSTR class = "RGtk2";
  HINSTANCE instance = GetModuleHandle(NULL);
  WNDCLASS wndclass = { 0, DefWindowProc, 0, 0, instance, NULL, 0, 0, NULL,
                        class };
  RegisterClass(&wndclass);
  win = CreateWindow(class, NULL, 0, 1, 1, 1, 1, HWND_MESSAGE,
                     NULL, instance, NULL);

  SetTimer(win, RGTK2_TIMER_ID, RGTK2_TIMER_DELAY, (TIMERPROC)R_gtk_timer_proc);
#endif // R < 2.8.0
#endif // Windows

  R_GTK_TYPE_PARAM_SEXP;
  
  g_value_register_transform_func(G_TYPE_DOUBLE, G_TYPE_STRING,
                                  transformDoubleString);
  g_value_register_transform_func(G_TYPE_INT, G_TYPE_STRING,
                                  transformIntString);
  g_value_register_transform_func(G_TYPE_BOOLEAN, G_TYPE_STRING,
                                  transformBooleanString);
  
  *success = TRUE;
}

void R_gtkCleanup() {
#ifndef G_OS_WIN32
  removeInputHandler(&R_InputHandlers, eventLoopInputHandler);
  g_main_loop_quit(eventLoopMain);
  g_thread_join(eventLoopThread);
  close(ifd);
  close(ofd);
#else
  DestroyWindow(win);
#endif
}