Extension version checking cleanups.

This commit is contained in:
Kim Woelders 2014-11-09 17:52:47 +01:00
parent b38fe1e6cf
commit 7c6deaabbf
6 changed files with 24 additions and 11 deletions

View File

@ -131,6 +131,8 @@
#define XEXT_AVAILABLE(ext) (Mode.server.extensions & (1 << ext))
int ExtVersion(int ext_ix);
/*
* Types
*/

View File

@ -35,7 +35,7 @@
#if USE_COMPOSITE
#include <X11/extensions/Xcomposite.h>
/* Composite Overlay Window (client) availability */
#if (1000 * COMPOSITE_MAJOR + COMPOSITE_MINOR) >= 3
#if VERS(COMPOSITE_MAJOR, COMPOSITE_MINOR) >= VERS(0, 3)
#define USE_COMPOSITE_OVERLAY_WINDOW 1
#else
#define USE_COMPOSITE_OVERLAY_WINDOW 0

View File

@ -38,6 +38,7 @@
#include "ewins.h" /* EwinsManage() */
#include "hints.h"
#include "timers.h"
#include "util.h"
#include "windowmatch.h"
#include "xwin.h"
@ -62,7 +63,7 @@
#define USE_CLIP_RELATIVE_TO_DESK 1
/* Composite Overlay Window (client) availability */
#if (1000 * COMPOSITE_MAJOR + COMPOSITE_MINOR) >= 3
#if VERS(COMPOSITE_MAJOR, COMPOSITE_MINOR) >= VERS(0, 3)
#define USE_COMPOSITE_OVERLAY_WINDOW 1
#else
#define USE_COMPOSITE_OVERLAY_WINDOW 0

View File

@ -66,7 +66,7 @@ static const char *EventName(unsigned int type);
*/
typedef struct {
int major, minor;
int version;
int major_op, event_base, error_base;
} EServerExtData;
@ -280,7 +280,7 @@ static const EServerExt Extensions[] = {
static void
ExtQuery(const EServerExt * ext)
{
int available;
int available, major, minor;
EServerExtData *exd = ExtData + ext->ix;
available = XQueryExtension(disp, ext->name, &(exd->major_op),
@ -290,12 +290,13 @@ ExtQuery(const EServerExt * ext)
{
Mode.server.extensions |= 1 << ext->ix;
ext->query_ver(disp, &(exd->major), &(exd->minor));
ext->query_ver(disp, &major, &minor);
exd->version = VERS(major, minor);
if (EDebug(EDBUG_TYPE_VERBOSE))
Eprintf("Extension %-15s version %d.%d -"
" req/evt/err base = %3d/%3d/%3d\n", ext->name,
exd->major, exd->minor,
major, minor,
exd->major_op, exd->event_base, exd->error_base);
}
@ -303,6 +304,14 @@ ExtQuery(const EServerExt * ext)
ext->init(available);
}
int
ExtVersion(int ext_ix)
{
EServerExtData *exd = ExtData + ext_ix;
return exd->version;
}
/*
* File descriptor handling
*/
@ -357,8 +366,7 @@ EventsInit(void)
#define XEXT_MASK_CM_ALL ((1 << XEXT_COMPOSITE) | (1 << XEXT_DAMAGE) | \
(1 << XEXT_FIXES) | (1 << XEXT_RENDER))
if (((Mode.server.extensions & XEXT_MASK_CM_ALL) == XEXT_MASK_CM_ALL) &&
(ExtData[XEXT_COMPOSITE].major > 0 ||
ExtData[XEXT_COMPOSITE].minor >= 2))
(ExtData[XEXT_COMPOSITE].version >= VERS(0, 2)))
Mode.server.extensions |= 1 << XEXT_CM_ALL;
#endif

View File

@ -39,7 +39,7 @@ static int n_screens = 0;
#if USE_XRANDR
#include <X11/extensions/Xrandr.h>
#define RANDR_VERSION (RANDR_MAJOR * 100 + RANDR_MINOR)
#define RANDR_VERSION VERS(RANDR_MAJOR, RANDR_MINOR)
static void
_ScreenInitXrandr(void)
@ -49,7 +49,7 @@ _ScreenInitXrandr(void)
static void
_ScreenShowInfoXrandr(void)
{
#if RANDR_VERSION >= 102 /* >= 1.2 */
#if RANDR_VERSION >= VERS(1, 2) /* >= 1.2 */
char buf[4096];
XRRScreenResources *psr;
XRRCrtcInfo *pci;

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2013 Kim Woelders
* Copyright (C) 2004-2014 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -31,6 +31,8 @@
#include <stdlib.h>
#include <string.h>
#define VERS(maj, min) (1000 * (maj) + (min))
#define INT2PTR(i) ((void*)(long)(i))
#define PTR2INT(p) ((int)(long)(p))