当前位置: 首页>>代码示例>>C++>>正文


C++ ConnectionNumber函数代码示例

本文整理汇总了C++中ConnectionNumber函数的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionNumber函数的具体用法?C++ ConnectionNumber怎么用?C++ ConnectionNumber使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ConnectionNumber函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: R_gtk_setEventHandler

void
R_gtk_setEventHandler()
{
#ifndef WIN32
  static InputHandler *h = NULL;
  if(!h)
    {
      if (!GDK_DISPLAY())
        error("GDK display not found - please make sure X11 is running");
      h = addInputHandler(R_InputHandlers, ConnectionNumber(GDK_DISPLAY()),
                          R_gtk_eventHandler, -1);
    }
#else
  /* Create a dummy window for receiving messages */
  LPCTSTR class = "cairoDevice";
  HINSTANCE instance = GetModuleHandle(NULL);
  WNDCLASS wndclass = { 0, DefWindowProc, 0, 0, instance, NULL, 0, 0, NULL,
                        class };
  RegisterClass(&wndclass);
  HWND win = CreateWindow(class, NULL, 0, 1, 1, 1, 1, HWND_MESSAGE,
                          NULL, instance, NULL);

  SetTimer(win, CD_TIMER_ID, CD_TIMER_DELAY, (TIMERPROC)R_gtk_timer_proc);
#endif
}
开发者ID:yixuan,项目名称:Layer,代码行数:25,代码来源:EventLoop.c

示例2: X11_PendingInput

/**
 * XPending() actually performs a blocking read 
 *  if no events available. From Fakk2, by way of
 *  Heretic2, by way of SDL, original idea GGI project.
 * The benefit of this approach over the quite
 *  badly behaved XAutoRepeatOn/Off is that you get
 *  focus handling for free, which is a major win
 *  with debug and windowed mode. It rests on the
 *  assumption that the X server will use the
 *  same timestamp on press/release event pairs 
 *  for key repeats. 
 */
static qboolean X11_PendingInput(void) {

  assert(dpy != NULL);

  // Flush the display connection
  //  and look to see if events are queued
  XFlush( dpy );
  if ( XEventsQueued( dpy, QueuedAlready) ) {
    return qtrue;
  }

  // More drastic measures are required -- see if X is ready to talk
  {
    static struct timeval zero_time;
    int x11_fd;
    fd_set fdset;

    x11_fd = ConnectionNumber( dpy );
    FD_ZERO(&fdset);
    FD_SET(x11_fd, &fdset);
    if ( select(x11_fd+1, &fdset, NULL, NULL, &zero_time) == 1 ) {
      return(XPending(dpy));
    }
  }
  
  // Oh well, nothing is ready ..
  return qfalse;
}
开发者ID:5Quintessential,项目名称:jedioutcast,代码行数:40,代码来源:linux_glimp.c

示例3: _clutter_x11_event_source_new

GSource *
_clutter_x11_event_source_new (ClutterBackendX11 *backend_x11)
{
  ClutterEventSource *event_source;
  int connection_number;
  GSource *source;
  gchar *name;

  connection_number = ConnectionNumber (backend_x11->xdpy);
  CLUTTER_NOTE (EVENT, "Connection number: %d", connection_number);

  source = g_source_new (&event_funcs, sizeof (ClutterEventSource));
  event_source = (ClutterEventSource *) source;

  name = g_strdup_printf ("Clutter X11 Event (connection: %d)",
                          connection_number);
  g_source_set_name (source, name);
  g_free (name);

  event_source->backend = backend_x11;
  event_source->event_poll_fd.fd = connection_number;
  event_source->event_poll_fd.events = G_IO_IN;

  g_source_add_poll (source, &event_source->event_poll_fd);
  g_source_set_can_recurse (source, TRUE);

  return source;
}
开发者ID:Distrotech,项目名称:clutter,代码行数:28,代码来源:clutter-event-x11.c

示例4: main

int main(int argc, char **argv)
{

  if(argc == 2)
    text = argv[1];
  else {
    printf("give an argument.\n");
    exit(1);
  }

  LOG_MESSAGE("starting xnotify\n");

  initX();

  signal(SIGHUP, sighup_handler);
  signal(SIGINT, sigint_handler);
  
  display_window();

  init_and_start_ev_loop(ConnectionNumber(X.display));

  cleanup();

  return 0;
}
开发者ID:masutu,项目名称:xnotify,代码行数:25,代码来源:xnotify.c

示例5: spnav_fd

static int spnav_fd(void)
{
    if(dpy) {
        return ConnectionNumber(dpy);
    }
    return -1;
}
开发者ID:harfangeek,项目名称:MeshEditor,代码行数:7,代码来源:freeglut_spaceball.c

示例6: XOpenDisplay

// Ping X in @pingInterval miliseconds.
XServerPinger::XServerPinger(int pingInterval)
{
    Display *dpy;
    sigset_t sigs;

    // Open a separate connection to X.
    dpy = XOpenDisplay(NULL);
    xcb = XGetXCBConnection(dpy);
    connect(new QSocketNotifier(ConnectionNumber(dpy), QSocketNotifier::Read),
            SIGNAL(activated(int)), SLOT(xInput(int)));

    // XGetInputFocus() is our ping request.
    request = xcb_get_input_focus(xcb);
    xcb_flush(xcb);

    timer = new QTimer();
    connect(timer, SIGNAL(timeout()), SLOT(tick()));
    timer->start(pingInterval);

    // die() if we get SIGINT or SIGTERM.
    sigemptyset(&sigs);
    sigaddset(&sigs, SIGINT);
    sigaddset(&sigs, SIGTERM);
    connect(new QSocketNotifier(signalfd(-1, &sigs, 0),
                                QSocketNotifier::Read),
            SIGNAL(activated(int)), SLOT(die(int)));
    sigprocmask(SIG_BLOCK, &sigs, NULL);
}
开发者ID:siraj,项目名称:mcompositor,代码行数:29,代码来源:xserverpinger.cpp

示例7: RunCommand

/** Execute an external program. */
void RunCommand(const char *command) {

   const char *displayString;
   char *str;

   if(JUNLIKELY(!command)) {
      return;
   }

   displayString = DisplayString(display);

   if(!fork()) {
      close(ConnectionNumber(display));
      if(displayString && displayString[0]) {
         str = malloc(strlen(displayString) + 9);
         sprintf(str, "DISPLAY=%s", displayString);
         putenv(str);
      }
      setsid();
      execl(SHELL_NAME, SHELL_NAME, "-c", command, NULL);
      Warning(_("exec failed: (%s) %s"), SHELL_NAME, command);
      exit(EXIT_SUCCESS);
   }

}
开发者ID:bbidulock,项目名称:jwmtools,代码行数:26,代码来源:command.c

示例8: glwtEventHandle

int glwtEventHandle(int wait)
{
    int handled = 0;
    do
    {
        XFlush(glwt.x11.display);

        handled = xlib_handle_event();
        if(handled < 0)
            return -1;

        if(wait && handled == 0)
        {
            int fd;
            fd_set fds;

            fd = ConnectionNumber(glwt.x11.display);

            FD_ZERO(&fds);
            FD_SET(fd, &fds);

            int val = select(fd + 1, &fds, NULL, NULL, NULL);
            if(val == -1)
            {
                glwtErrorPrintf("select failed: %s", strerror(errno));
                return -1;
            } else if(val == 0)
                return 0;
        }
    } while(handled == 0 && wait);

    return 0;
}
开发者ID:jannek,项目名称:glwt,代码行数:33,代码来源:events.c

示例9: ftk_source_x11_create

FtkSource* ftk_source_x11_create(FtkDisplay* display, FtkOnEvent on_event, void* ctx)
{
	FtkSource* thiz = NULL;
	
	return_val_if_fail(display != NULL && on_event != NULL, NULL);

	thiz = (FtkSource*)FTK_ZALLOC(sizeof(FtkSource) + sizeof(PrivInfo));

	if(thiz != NULL)
	{
		DECL_PRIV(thiz, priv);
		thiz->get_fd   = ftk_source_x11_get_fd;
		thiz->check	   = ftk_source_x11_check;
		thiz->dispatch = ftk_source_x11_dispatch;
		thiz->destroy  = ftk_source_x11_destroy;

		thiz->ref = 1;
		priv->ctx = ctx;
		priv->on_event = on_event;
		priv->display = display;
		priv->fd  = ConnectionNumber(ftk_display_x11_get_xdisplay(display));
		priv->win = (Window)ftk_display_x11_get_xwindow(display);

		XSetErrorHandler(on_x11_error);
	}

	return thiz;
}
开发者ID:htbegin,项目名称:pyftk,代码行数:28,代码来源:ftk_source_x11.c

示例10: getEvent

static void getEvent(XEvent * ev) {
    int fd;
    fd_set readfds;
    struct timeval tv;
    
    /* Is there a message waiting? */
    if (QLength(dpy) > 0) {
        XNextEvent(dpy, ev);
        return;
    }
    
    /* Beg... */
    XFlush(dpy);
    
    /* Wait one second to see if a message arrives. */
    fd = ConnectionNumber(dpy);
    FD_ZERO(&readfds);
    FD_SET(fd, &readfds);
    tv.tv_sec = 1;
    tv.tv_usec = 0;
    if (select(fd + 1, &readfds, 0, 0, &tv) == 1) {
        XNextEvent(dpy, ev);
        return;
    }
    
    /* No message, so we have a null event. */
    ev->type = NullEvent;
}
开发者ID:007durgesh219,项目名称:jessies,代码行数:28,代码来源:menu.c

示例11: main

int main(){
        Display *display_name;
        int depth,screen,connection;


        /*Opening display and setting defaults*/
        display_name = XOpenDisplay(NULL);
        screen = DefaultScreen(display_name);
        depth = DefaultDepth(display_name,screen);
        connection = ConnectionNumber(display_name);


        /*Displaying the info gathered*/
        printf("The display is::%s\n",XDisplayName((char*)display_name));
        printf("Width::%d\tHeight::%d\n",
                                DisplayWidth(display_name,screen),
                                DisplayHeight(display_name,screen));
        printf("Connection number is %d\n",connection);


        if(depth == 1)
                printf("You live in prehistoric times\n");
        else
                printf("You've got a coloured monitor with depth of %d\n",
                        depth);


        /*Closing the display*/
        XCloseDisplay(display_name);
}
开发者ID:AMANINOUN,项目名称:nsy103,代码行数:30,代码来源:connect.c

示例12: _cogl_xlib_renderer_connect

gboolean
_cogl_xlib_renderer_connect (CoglRenderer *renderer, GError **error)
{
  CoglXlibRenderer *xlib_renderer =
    _cogl_xlib_renderer_get_data (renderer);
  CoglX11Renderer *x11_renderer =
    (CoglX11Renderer *) xlib_renderer;
  int damage_error;

  if (!assert_xlib_display (renderer, error))
    return FALSE;

  if (getenv ("COGL_X11_SYNC"))
    XSynchronize (xlib_renderer->xdpy, TRUE);

  /* Check whether damage events are supported on this display */
  if (!XDamageQueryExtension (xlib_renderer->xdpy,
                              &x11_renderer->damage_base,
                              &damage_error))
    x11_renderer->damage_base = -1;

  xlib_renderer->trap_state = NULL;

  xlib_renderer->poll_fd.fd = ConnectionNumber (xlib_renderer->xdpy);
  xlib_renderer->poll_fd.events = COGL_POLL_FD_EVENT_IN;

  register_xlib_renderer (renderer);

  return TRUE;
}
开发者ID:collects,项目名称:cogl,代码行数:30,代码来源:cogl-xlib-renderer.c

示例13: shell

/*ARGSUSED*/
extern void
shell(ScreenInfo * screen, int button, int x, int y) {
    char * command = NULL;
    char * sh;

    /* Get the command we're to execute. Give up if there isn't one. */
    if (button == Button1)
        command = btn1_command;
    if (button == Button2)
        command = btn2_command;
    if (command == NULL)
        return;

    sh = getenv("SHELL");
    if (sh == 0)
        sh = "/bin/sh";

    switch (fork()) {
    case 0:		/* Child. */
        close(ConnectionNumber(dpy));
        if (screen && screen->display_spec != 0)
            putenv(screen->display_spec);
        execl(sh, sh, "-c", command, NULL);
        fprintf(stderr, "%s: can't exec \"%s -c %s\"\n", argv0, sh,
                command);
        execlp("xterm", "xterm", NULL);
        exit(EXIT_FAILURE);
    case -1:	/* Error. */
        fprintf(stderr, "%s: couldn't fork\n", argv0);
        break;
    }
}
开发者ID:jamesfcarter,项目名称:lwm,代码行数:33,代码来源:lwm.c

示例14: X11_Open

/*
 * Open up the mouse device.
 * Returns the fd if successful, or negative if unsuccessful.
 */
static int X11_Open(MOUSEDEVICE *pmd)
{
    if (x11_setup_display() < 0)
	return -1;
    /* return the x11 file descriptor for select */
    return ConnectionNumber(x11_dpy);  
}
开发者ID:allanshin,项目名称:DirectFB_Microwindows,代码行数:11,代码来源:mou_x11.c

示例15: spawn

// spawn() heavily inspired by dwm.c
int spawn(int argc, char** argv) {
    if (argc < 2) {
        return HERBST_NEED_MORE_ARGS;
    }
    if (fork() == 0) {
        // only look in child
        if (g_display) {
            close(ConnectionNumber(g_display));
        }
        // shift all args in argv by 1 to the front
        // so that we have space for a NULL entry at the end for execvp
        char** execargs = argv_duplicate(argc, argv);
        free(execargs[0]);
        int i;
        for (i = 0; i < argc-1; i++) {
            execargs[i] = execargs[i+1];
        }
        execargs[i] = NULL;
        // do actual exec
        setsid();
        execvp(execargs[0], execargs);
        fprintf(stderr, "herbstluftwm: execvp \"%s\"", argv[1]);
        perror(" failed");
        exit(0);
    }
    return 0;
}
开发者ID:xiaq,项目名称:hlwm,代码行数:28,代码来源:main.c


注:本文中的ConnectionNumber函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。