/** * Create the capture */ static void *xshm_create(obs_data_t settings, obs_source_t source) { UNUSED_PARAMETER(source); struct xshm_data *data = bzalloc(sizeof(struct xshm_data)); data->dpy = XOpenDisplay(NULL); if (!data->dpy) { blog(LOG_ERROR, "xshm-input: Unable to open X display !"); goto fail; } if (!XShmQueryExtension(data->dpy)) { blog(LOG_ERROR, "xshm-input: XShm extension not found !"); goto fail; } data->use_xinerama = xinerama_is_active(data->dpy) ? true : false; obs_enter_graphics(); data->cursor = xcursor_init(data->dpy); obs_leave_graphics(); xshm_update(data, settings); return data; fail: xshm_destroy(data); return NULL; }
XCompcapMain::XCompcapMain(obs_data_t *settings, obs_source_t *source) { p = new XCompcapMain_private; p->source = source; obs_enter_graphics(); p->cursor = xcursor_init(xdisp); obs_leave_graphics(); updateSettings(settings); }
/** * Start the capture */ static void xshm_capture_start(struct xshm_data *data) { const char *server = (data->advanced && *data->server) ? data->server : NULL; data->dpy = XOpenDisplay(server); if (!data->dpy) { blog(LOG_ERROR, "Unable to open X display !"); goto fail; } if (!XShmQueryExtension(data->dpy)) { blog(LOG_ERROR, "XShm extension not found !"); goto fail; } data->use_xinerama = xinerama_is_active(data->dpy) ? true : false; if (xshm_update_geometry(data) < 0) { blog(LOG_ERROR, "failed to update geometry !"); goto fail; } data->xshm = xshm_attach(data->dpy, data->screen, data->width, data->height); if (!data->xshm) { blog(LOG_ERROR, "failed to attach shm !"); goto fail; } obs_enter_graphics(); data->cursor = xcursor_init(data->dpy); xcursor_offset(data->cursor, data->x_org, data->y_org); xshm_resize_texture(data); obs_leave_graphics(); return; fail: xshm_capture_stop(data); }