summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2013-09-19 18:08:20 +0200
committerMichael Stapelberg <michael@stapelberg.de>2013-09-20 06:19:58 +0200
commit7de51b81885a3b6dbb719a63f776783c0e307ab7 (patch)
tree2b6c9560b8a82861b80281c42c47245dcf2af93b
parent8f3279a2b3711b6f311c5a31d77c6a8c05c4c3ac (diff)
Check exact RENDER version that the server supports
RENDER's CreateCursor request was added in version 0.5 and CreateAnimCursor was added in version 0.8. Hence, just having the RENDER extension is not enough and we need to check the exact version that the server provides. Signed-off-by: Uli Schlachter <psychon@znc.in>
-rw-r--r--cursor/cursor.c17
-rw-r--r--cursor/cursor.h11
-rw-r--r--cursor/load_cursor.c6
3 files changed, 26 insertions, 8 deletions
diff --git a/cursor/cursor.c b/cursor/cursor.c
index fd75ba9..2f56f19 100644
--- a/cursor/cursor.c
+++ b/cursor/cursor.c
@@ -126,6 +126,7 @@ int xcb_cursor_context_new(xcb_connection_t *conn, xcb_screen_t *screen, xcb_cur
xcb_get_property_cookie_t rm_cookie;
xcb_get_property_reply_t *rm_reply;
xcb_render_query_pict_formats_cookie_t pf_cookie;
+ xcb_render_query_version_cookie_t ver_cookie;
if ((*ctx = calloc(1, sizeof(struct xcb_cursor_context_t))) == NULL)
return -errno;
@@ -133,15 +134,17 @@ int xcb_cursor_context_new(xcb_connection_t *conn, xcb_screen_t *screen, xcb_cur
c = *ctx;
c->conn = conn;
c->root = screen->root;
+ c->render_version = RV_NONE;
ext = xcb_get_extension_data(conn, &xcb_render_id);
- c->render_present = (ext && ext->present);
// XXX: Is it maybe necessary to ever use long_offset != 0?
// XXX: proper length? xlib seems to use 100 MB o_O
rm_cookie = xcb_get_property(conn, 0, c->root, XCB_ATOM_RESOURCE_MANAGER, XCB_ATOM_STRING, 0, 16 * 1024);
- if (c->render_present)
+ if (ext && ext->present) {
+ ver_cookie = xcb_render_query_version(conn, XCB_RENDER_MAJOR_VERSION, XCB_RENDER_MINOR_VERSION);
pf_cookie = xcb_render_query_pict_formats(conn);
+ }
c->cursor_font = xcb_generate_id(conn);
xcb_open_font(conn, c->cursor_font, strlen("cursor"), "cursor");
@@ -149,7 +152,15 @@ int xcb_cursor_context_new(xcb_connection_t *conn, xcb_screen_t *screen, xcb_cur
parse_resource_manager(c, rm_reply);
free(rm_reply);
- if (c->render_present) {
+ if (ext && ext->present) {
+ xcb_render_query_version_reply_t *reply = xcb_render_query_version_reply(conn, ver_cookie, NULL);
+
+ if (reply && (reply->major_version >= 1 || reply->minor_version >= 8))
+ c->render_version = RV_ANIM_CURSOR;
+ else if (reply && (reply->major_version >= 1 || reply->minor_version >= 5))
+ c->render_version = RV_CURSOR;
+ free(reply);
+
c->pf_reply = xcb_render_query_pict_formats_reply(conn, pf_cookie, NULL);
c->pict_format = xcb_render_util_find_standard_format(c->pf_reply, XCB_PICT_STANDARD_ARGB_32);
}
diff --git a/cursor/cursor.h b/cursor/cursor.h
index 09ab395..455dc34 100644
--- a/cursor/cursor.h
+++ b/cursor/cursor.h
@@ -29,7 +29,6 @@
#ifndef CURSOR_H
#define CURSOR_H
-#include <stdbool.h>
#include <xcb/render.h>
#include "xcb_cursor.h"
@@ -41,6 +40,14 @@ enum {
RM_MAX,
};
+enum render_version {
+ RV_NONE = 0,
+ /* RENDER's CreateCursor was added in RENDER 0.5 */
+ RV_CURSOR,
+ /* RENDER's CreateAnimCursor was added in RENDER 0.8 */
+ RV_ANIM_CURSOR
+};
+
struct xcb_cursor_context_t {
xcb_connection_t *conn;
xcb_window_t root;
@@ -62,7 +69,7 @@ struct xcb_cursor_context_t {
const char *home;
const char *path;
- bool render_present;
+ enum render_version render_version;
};
/*
diff --git a/cursor/load_cursor.c b/cursor/load_cursor.c
index 43cd7a5..914950a 100644
--- a/cursor/load_cursor.c
+++ b/cursor/load_cursor.c
@@ -196,7 +196,7 @@ xcb_cursor_t xcb_cursor_load_cursor(xcb_cursor_context_t *c, const char *name) {
// NB: if !render_present, fd will be -1 and thus the next if statement
// will trigger the fallback.
- if (c->render_present) {
+ if (c->render_version != RV_NONE) {
if (c->rm[RM_XCURSOR_THEME])
fd = open_cursor_file(c, c->rm[RM_XCURSOR_THEME], name, &core_char);
@@ -264,8 +264,8 @@ xcb_cursor_t xcb_cursor_load_cursor(xcb_cursor_context_t *c, const char *name) {
xcb_free_gc(c->conn, gc);
free(images);
- if (nimg == 1) {
- /* non-animated cursor */
+ if (nimg == 1 || c->render_version == RV_CURSOR) {
+ /* non-animated cursor or no support for animated cursors */
return elements[0].cursor;
} else {
cid = xcb_generate_id(c->conn);