[Xcb] [PATCH 1/2] Add missing defines for X11 opcodes

Klemens Baum klemensbaum at gmail.com
Fri Dec 25 10:23:51 PST 2015


This patch adds the XCB_ERROR, XCB_REPLY and XCB_GE_EVENT symbolic constants.
These are intended to be used for disambiguating xcb_generic_event_t.
---
 src/xcb.h    | 50 ++++++++++++++++++++++++++++----------------------
 src/xcb_in.c | 22 +++++++++-------------
 2 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/src/xcb.h b/src/xcb.h
index 86eb1bc..b8e51bb 100644
--- a/src/xcb.h
+++ b/src/xcb.h
@@ -106,16 +106,26 @@ typedef struct xcb_connection_t xcb_connection_t;  /**< Opaque structure contain
 
 /* Other types */
 
+#define XCB_ERROR 0
+
 /**
- * @brief Generic iterator.
+ * @brief Generic error.
  *
- * A generic iterator structure.
+ * A generic error structure.
  */
 typedef struct {
-    void *data;   /**< Data of the current iterator */
-    int rem;    /**< remaining elements */
-    int index;  /**< index of the current iterator */
-} xcb_generic_iterator_t;
+    uint8_t   response_type;  /**< Type of the response */
+    uint8_t   error_code;     /**< Error code */
+    uint16_t sequence;       /**< Sequence number */
+    uint32_t resource_id;     /** < Resource ID for requests with side effects only */
+    uint16_t minor_code;      /** < Minor opcode of the failed request */
+    uint8_t major_code;       /** < Major opcode of the failed request */
+    uint8_t pad0;
+    uint32_t pad[5];         /**< Padding */
+    uint32_t full_sequence;  /**< full sequence */
+} xcb_generic_error_t;
+
+#define XCB_REPLY 1
 
 /**
  * @brief Generic reply.
@@ -142,6 +152,8 @@ typedef struct {
     uint32_t full_sequence;  /**< full sequence */
 } xcb_generic_event_t;
 
+#define XCB_GE_EVENT 35
+
 /**
  * @brief GE event
  *
@@ -163,30 +175,24 @@ typedef struct {
 } xcb_ge_event_t;
 
 /**
- * @brief Generic error.
+ * @brief Generic cookie.
  *
- * A generic error structure.
+ * A generic cookie structure.
  */
 typedef struct {
-    uint8_t   response_type;  /**< Type of the response */
-    uint8_t   error_code;     /**< Error code */
-    uint16_t sequence;       /**< Sequence number */
-    uint32_t resource_id;     /** < Resource ID for requests with side effects only */
-    uint16_t minor_code;      /** < Minor opcode of the failed request */
-    uint8_t major_code;       /** < Major opcode of the failed request */
-    uint8_t pad0;
-    uint32_t pad[5];         /**< Padding */
-    uint32_t full_sequence;  /**< full sequence */
-} xcb_generic_error_t;
+    unsigned int sequence;  /**< Sequence number */
+} xcb_void_cookie_t;
 
 /**
- * @brief Generic cookie.
+ * @brief Generic iterator.
  *
- * A generic cookie structure.
+ * A generic iterator structure.
  */
 typedef struct {
-    unsigned int sequence;  /**< Sequence number */
-} xcb_void_cookie_t;
+    void *data;   /**< Data of the current iterator */
+    int rem;    /**< remaining elements */
+    int index;  /**< index of the current iterator */
+} xcb_generic_iterator_t;
 
 
 /* Include the generated xproto header. */
diff --git a/src/xcb_in.c b/src/xcb_in.c
index bab4bc7..6a015e6 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -6,17 +6,17 @@
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * and/or sell copies of the Software, and to permit persons to whom the
  * Software is furnished to do so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
+ *
  * Except as contained in this notice, the names of the authors or their
  * institutions shall not be used in advertising or otherwise to promote the
  * sale, use or other dealings in this Software without prior written
@@ -52,10 +52,6 @@
 #include "xcbext.h"
 #include "xcbint.h"
 
-#define XCB_ERROR 0
-#define XCB_REPLY 1
-#define XCB_XGE_EVENT 35
-
 struct event_list {
     xcb_generic_event_t *event;
     struct event_list *next;
@@ -65,7 +61,7 @@ struct xcb_special_event {
 
     struct xcb_special_event *next;
 
-    /* Match XGE events for the specific extension and event ID (the
+    /* Match GE events for the specific extension and event ID (the
      * first 32 bit word after evtype)
      */
     uint8_t     extension;
@@ -144,8 +140,8 @@ static int event_special(xcb_connection_t *c,
     struct xcb_special_event *special_event;
     struct xcb_ge_special_event_t *ges = (void *) event->event;
 
-    /* Special events are always XGE events */
-    if ((ges->response_type & 0x7f) != XCB_XGE_EVENT)
+    /* Special events are always GE events */
+    if ((ges->response_type & 0x7f) != XCB_GE_EVENT)
         return 0;
 
     for (special_event = c->in.special_events;
@@ -249,8 +245,8 @@ static int read_packet(xcb_connection_t *c)
             nfd = genrep.pad0;
     }
 
-    /* XGE events may have sizes > 32 */
-    if ((genrep.response_type & 0x7f) == XCB_XGE_EVENT)
+    /* GE events may have sizes > 32 */
+    if ((genrep.response_type & 0x7f) == XCB_GE_EVENT)
         eventlength = genrep.length * 4;
 
     bufsize = length + eventlength + nfd * sizeof(int)  +
@@ -271,7 +267,7 @@ static int read_packet(xcb_connection_t *c)
         return 0;
     }
 
-    /* pull in XGE event data if available, append after event struct */
+    /* pull in GE event data if available, append after event struct */
     if (eventlength)
     {
         if(_xcb_in_read_block(c, &((xcb_generic_event_t*)buf)[1], eventlength) <= 0)
-- 
2.4.6



More information about the Xcb mailing list