/* Function: al_run_detached_thread */ void al_run_detached_thread(void *(*proc)(void *arg), void *arg) { ALLEGRO_THREAD *outer = create_thread(); outer->thread_state = THREAD_STATE_DETACHED; outer->arg = arg; outer->proc = proc; _al_thread_create(&outer->thread, detached_thread_func_trampoline, outer); _al_thread_detach(&outer->thread); }
/* Function: al_create_thread */ ALLEGRO_THREAD *al_create_thread( void *(*proc)(ALLEGRO_THREAD *thread, void *arg), void *arg) { ALLEGRO_THREAD *outer = create_thread(); outer->thread_state = THREAD_STATE_CREATED; _al_mutex_init(&outer->mutex); _al_cond_init(&outer->cond); outer->arg = arg; outer->proc = proc; _al_thread_create(&outer->thread, thread_func_trampoline, outer); /* XXX _al_thread_create should return an error code */ return outer; }
static ALLEGRO_SYSTEM *xglx_initialize(int flags) { Display *x11display; Display *gfxdisplay; ALLEGRO_SYSTEM_XGLX *s; (void)flags; #ifdef DEBUG_X11 _Xdebug = 1; #endif XInitThreads(); /* Get an X11 display handle. */ x11display = XOpenDisplay(0); if (x11display) { /* Never ask. */ gfxdisplay = XOpenDisplay(0); if (!gfxdisplay) { ALLEGRO_ERROR("XOpenDisplay failed second time.\n"); XCloseDisplay(x11display); return NULL; } } else { ALLEGRO_INFO("XOpenDisplay failed; assuming headless mode.\n"); gfxdisplay = NULL; } _al_unix_init_time(); s = al_calloc(1, sizeof *s); _al_mutex_init_recursive(&s->lock); _al_cond_init(&s->resized); s->inhibit_screensaver = false; _al_vector_init(&s->system.displays, sizeof (ALLEGRO_DISPLAY_XGLX *)); s->system.vt = xglx_vt; s->gfxdisplay = gfxdisplay; s->x11display = x11display; if (s->x11display) { ALLEGRO_INFO("XGLX driver connected to X11 (%s %d).\n", ServerVendor(s->x11display), VendorRelease(s->x11display)); ALLEGRO_INFO("X11 protocol version %d.%d.\n", ProtocolVersion(s->x11display), ProtocolRevision(s->x11display)); /* We need to put *some* atom into the ClientMessage we send for * faking mouse movements with al_set_mouse_xy - so let's ask X11 * for one here. */ s->AllegroAtom = XInternAtom(x11display, "AllegroAtom", False); /* Message type for XEmbed protocol. */ s->XEmbedAtom = XInternAtom(x11display, "_XEMBED", False); _al_thread_create(&s->xevents_thread, _al_xwin_background_thread, s); s->have_xevents_thread = true; ALLEGRO_INFO("events thread spawned.\n"); } return &s->system; }
/* Create a new system object for the dummy X11 driver. */ static ALLEGRO_SYSTEM *xglx_initialize(int flags) { Display *x11display; Display *gfxdisplay; ALLEGRO_SYSTEM_XGLX *s; (void)flags; #ifdef DEBUG_X11 _Xdebug = 1; #endif XInitThreads(); /* Get an X11 display handle. */ x11display = XOpenDisplay(0); if (!x11display) { ALLEGRO_ERROR("XOpenDisplay failed.\n"); return NULL; } /* Never ask. */ gfxdisplay = XOpenDisplay(0); if (!gfxdisplay) { ALLEGRO_ERROR("XOpenDisplay failed.\n"); XCloseDisplay(x11display); return NULL; } _al_unix_init_time(); s = _AL_MALLOC(sizeof *s); memset(s, 0, sizeof *s); /* We need to put *some* atom into the ClientMessage we send for * faking mouse movements with al_set_mouse_xy - so lets ask X11 * for one here. */ s->AllegroAtom = XInternAtom(x11display, "AllegroAtom", False); _al_mutex_init_recursive(&s->lock); _al_cond_init(&s->resized); s->inhibit_screensaver = false; _al_vector_init(&s->system.displays, sizeof (ALLEGRO_DISPLAY_XGLX *)); s->gfxdisplay = gfxdisplay; s->x11display = x11display; s->system.vt = xglx_vt; ALLEGRO_INFO("XGLX driver connected to X11 (%s %d).\n", ServerVendor(s->x11display), VendorRelease(s->x11display)); ALLEGRO_INFO("X11 protocol version %d.%d.\n", ProtocolVersion(s->x11display), ProtocolRevision(s->x11display)); #ifdef ALLEGRO_XWINDOWS_WITH_XINERAMA _al_xsys_xinerama_init(s); #endif _al_xglx_store_video_mode(s); _al_thread_create(&s->thread, xglx_background_thread, s); ALLEGRO_INFO("events thread spawned.\n"); return &s->system; }