/** * 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); }
/** * Start the capture */ static void xshm_capture_start(struct xshm_data *data) { const char *server = (data->advanced && *data->server) ? data->server : NULL; data->xcb = xcb_connect(server, NULL); if (!data->xcb || xcb_connection_has_error(data->xcb)) { blog(LOG_ERROR, "Unable to open X display !"); goto fail; } if (!xshm_check_extensions(data->xcb)) goto fail; data->use_xinerama = xinerama_is_active(data->xcb) ? true : false; if (xshm_update_geometry(data) < 0) { blog(LOG_ERROR, "failed to update geometry !"); goto fail; } data->xshm = xshm_xcb_attach(data->xcb, data->width, data->height); if (!data->xshm) { blog(LOG_ERROR, "failed to attach shm !"); goto fail; } data->cursor = xcb_xcursor_init(data->xcb); xcb_xcursor_offset(data->cursor, data->x_org, data->y_org); obs_enter_graphics(); xshm_resize_texture(data); obs_leave_graphics(); return; fail: xshm_capture_stop(data); }
/** * Update the capture with changed settings */ static void xshm_update(void *vptr, obs_data_t settings) { XSHM_DATA(vptr); data->show_cursor = obs_data_get_bool(settings, "show_cursor"); if (data->xshm) xshm_detach(data->xshm); if (xshm_update_geometry(data, settings) < 0) { blog(LOG_ERROR, "xshm-input: failed to update geometry !"); return; } xshm_resize_texture(data); xcursor_offset(data->cursor, data->x_org, data->y_org); data->xshm = xshm_attach(data->dpy, data->screen, data->width, data->height); if (!data->xshm) { blog(LOG_ERROR, "xshm-input: failed to attach shm !"); return; } }