コード例 #1
0
ファイル: screen.c プロジェクト: nkruglikov/remoteink
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;
}
コード例 #2
0
ファイル: wincursor.c プロジェクト: jon-turney/XtoW
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);
}