示例#1
0
void
UpdateCursor(void)
{
  xcb_xfixes_get_cursor_image_cookie_t cookie = xcb_xfixes_get_cursor_image(xcwm_context_get_connection(context));
  xcb_xfixes_get_cursor_image_reply_t* reply = xcb_xfixes_get_cursor_image_reply(xcwm_context_get_connection(context), cookie, NULL);

  // DEBUG("Got cursor image, serial %d\n", reply->cursor_serial);

  WMUTIL_CURSOR cursor;
  memset(&cursor, 0, sizeof(cursor));
  cursor.width = reply->width;
  cursor.height = reply->height;
  cursor.xhot = reply->xhot;
  cursor.yhot = reply->yhot;
  cursor.argb = xcb_xfixes_get_cursor_image_cursor_image(reply);

  hCursor = winXCursorToHCURSOR(&cursor);

  // XXX: We should only change the cursor if the cursor is within one of our windows...
  // it's hard to notice this as a problem, as windows don't normally try to change the cursor except in response to something being clicked...
  HCURSOR hPreviousCursor = SetCursor(hCursor);

  // DEBUG("cursor 0x%08x, previous cursor 0x%08x\n", hCursor, hPreviousCursor);

  DestroyCursor(hPreviousCursor);

  free(reply);
}
示例#2
0
ExcCode screen_cursor_blend(int x, int y, Imlib_Image image) {
	xcb_xfixes_get_cursor_image_cookie_t cookie =
			xcb_xfixes_get_cursor_image(display);
	xcb_xfixes_get_cursor_image_reply_t *reply =
			xcb_xfixes_get_cursor_image_reply(display, cookie, NULL);
	if (reply == NULL)
		return 0;
	unsigned *cursor_data = xcb_xfixes_get_cursor_image_cursor_image(reply);
	if (cursor_data == NULL)
		return 0;
	Imlib_Image cursor = imlib_create_image_using_data(
			reply->width, reply->height,
			cursor_data);
	if (cursor == NULL)
		PANIC(ERR_IMAGE);
	imlib_context_set_image(cursor);
	imlib_image_set_has_alpha(1);
	
	imlib_context_set_image(image);
	imlib_blend_image_onto_image(cursor, 0, 0, 0, reply->width, reply->height,
			reply->x - reply->xhot - x, reply->y - reply->yhot - y,
			reply->width, reply->height);
	
	imlib_context_set_image(cursor);
	imlib_free_image_and_decache();
	free(reply);
	return 0;
}
示例#3
0
/**
 * Prepare the capture data
 */
static void xshm_video_tick(void *vptr, float seconds)
{
	UNUSED_PARAMETER(seconds);
	XSHM_DATA(vptr);

	if (!data->texture)
		return;
	if (!obs_source_showing(data->source))
		return;

	xcb_shm_get_image_cookie_t           img_c;
	xcb_shm_get_image_reply_t            *img_r;
	xcb_xfixes_get_cursor_image_cookie_t cur_c;
	xcb_xfixes_get_cursor_image_reply_t  *cur_r;

	img_c = xcb_shm_get_image_unchecked(data->xcb, data->xcb_screen->root,
			data->x_org, data->y_org, data->width, data->height,
			~0, XCB_IMAGE_FORMAT_Z_PIXMAP, data->xshm->seg, 0);
	cur_c = xcb_xfixes_get_cursor_image_unchecked(data->xcb);

	img_r = xcb_shm_get_image_reply(data->xcb, img_c, NULL);
	cur_r = xcb_xfixes_get_cursor_image_reply(data->xcb, cur_c, NULL);

	if (!img_r)
		goto exit;

	obs_enter_graphics();

	gs_texture_set_image(data->texture, (void *) data->xshm->data,
		data->width * 4, false);
	xcb_xcursor_update(data->cursor, cur_r);

	obs_leave_graphics();

exit:
	free(img_r);
	free(cur_r);
}