forked from external/yambar
Apply "clang-format" preferences globally
This commit is contained in:
parent
d841aeeecd
commit
b85ba99980
64 changed files with 1868 additions and 2678 deletions
82
xcb.c
82
xcb.c
|
@ -1,16 +1,16 @@
|
|||
#include "xcb.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/randr.h>
|
||||
#include <xcb/render.h>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
#if defined(HAVE_XCB_ERRORS)
|
||||
#include <xcb/xcb_errors.h>
|
||||
#include <xcb/xcb_errors.h>
|
||||
#endif
|
||||
|
||||
#define LOG_MODULE "xcb"
|
||||
|
@ -36,8 +36,7 @@ xcb_atom_t _NET_WM_NAME;
|
|||
static xcb_errors_context_t *err_context;
|
||||
#endif
|
||||
|
||||
static void __attribute__((destructor))
|
||||
fini(void)
|
||||
static void __attribute__((destructor)) fini(void)
|
||||
{
|
||||
#if defined(HAVE_XCB_ERRORS)
|
||||
xcb_errors_context_free(err_context);
|
||||
|
@ -63,19 +62,17 @@ xcb_init(void)
|
|||
|
||||
/* Vendor release number */
|
||||
unsigned release = setup->release_number;
|
||||
unsigned major = release / 10000000; release %= 10000000;
|
||||
unsigned minor = release / 100000; release %= 100000;
|
||||
unsigned major = release / 10000000;
|
||||
release %= 10000000;
|
||||
unsigned minor = release / 100000;
|
||||
release %= 100000;
|
||||
unsigned patch = release / 1000;
|
||||
#endif
|
||||
|
||||
LOG_DBG("%.*s %u.%u.%u (protocol: %u.%u)",
|
||||
xcb_setup_vendor_length(setup), xcb_setup_vendor(setup),
|
||||
major, minor, patch,
|
||||
setup->protocol_major_version,
|
||||
setup->protocol_minor_version);
|
||||
LOG_DBG("%.*s %u.%u.%u (protocol: %u.%u)", xcb_setup_vendor_length(setup), xcb_setup_vendor(setup), major, minor,
|
||||
patch, setup->protocol_major_version, setup->protocol_minor_version);
|
||||
|
||||
const xcb_query_extension_reply_t *randr =
|
||||
xcb_get_extension_data(conn, &xcb_randr_id);
|
||||
const xcb_query_extension_reply_t *randr = xcb_get_extension_data(conn, &xcb_randr_id);
|
||||
|
||||
if (randr == NULL || !randr->present) {
|
||||
LOG_ERR("RANDR extension not present");
|
||||
|
@ -83,8 +80,7 @@ xcb_init(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
const xcb_query_extension_reply_t *render =
|
||||
xcb_get_extension_data(conn, &xcb_render_id);
|
||||
const xcb_query_extension_reply_t *render = xcb_get_extension_data(conn, &xcb_render_id);
|
||||
|
||||
if (render == NULL || !render->present) {
|
||||
LOG_ERR("RENDER extension not present");
|
||||
|
@ -92,18 +88,15 @@ xcb_init(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
xcb_randr_query_version_cookie_t randr_cookie =
|
||||
xcb_randr_query_version(conn, XCB_RANDR_MAJOR_VERSION,
|
||||
XCB_RANDR_MINOR_VERSION);
|
||||
xcb_render_query_version_cookie_t render_cookie =
|
||||
xcb_render_query_version(conn, XCB_RENDER_MAJOR_VERSION,
|
||||
XCB_RENDER_MINOR_VERSION);
|
||||
xcb_randr_query_version_cookie_t randr_cookie
|
||||
= xcb_randr_query_version(conn, XCB_RANDR_MAJOR_VERSION, XCB_RANDR_MINOR_VERSION);
|
||||
xcb_render_query_version_cookie_t render_cookie
|
||||
= xcb_render_query_version(conn, XCB_RENDER_MAJOR_VERSION, XCB_RENDER_MINOR_VERSION);
|
||||
|
||||
xcb_flush(conn);
|
||||
|
||||
xcb_generic_error_t *e;
|
||||
xcb_randr_query_version_reply_t *randr_version =
|
||||
xcb_randr_query_version_reply(conn, randr_cookie, &e);
|
||||
xcb_randr_query_version_reply_t *randr_version = xcb_randr_query_version_reply(conn, randr_cookie, &e);
|
||||
if (e != NULL) {
|
||||
LOG_ERR("failed to query RANDR version: %s", xcb_error(e));
|
||||
free(e);
|
||||
|
@ -111,8 +104,7 @@ xcb_init(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
xcb_render_query_version_reply_t *render_version =
|
||||
xcb_render_query_version_reply(conn, render_cookie, &e);
|
||||
xcb_render_query_version_reply_t *render_version = xcb_render_query_version_reply(conn, render_cookie, &e);
|
||||
if (e != NULL) {
|
||||
LOG_ERR("failed to query RENDER version: %s", xcb_error(e));
|
||||
free(e);
|
||||
|
@ -120,10 +112,8 @@ xcb_init(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
LOG_DBG("RANDR: %u.%u",
|
||||
randr_version->major_version, randr_version->minor_version);
|
||||
LOG_DBG("RENDER: %u.%u",
|
||||
render_version->major_version, render_version->minor_version);
|
||||
LOG_DBG("RANDR: %u.%u", randr_version->major_version, randr_version->minor_version);
|
||||
LOG_DBG("RENDER: %u.%u", render_version->major_version, render_version->minor_version);
|
||||
|
||||
free(randr_version);
|
||||
free(render_version);
|
||||
|
@ -131,7 +121,7 @@ xcb_init(void)
|
|||
/* Cache atoms */
|
||||
UTF8_STRING = get_atom(conn, "UTF8_STRING");
|
||||
_NET_WM_PID = get_atom(conn, "_NET_WM_PID");
|
||||
_NET_WM_WINDOW_TYPE = get_atom(conn, "_NET_WM_WINDOW_TYPE");
|
||||
_NET_WM_WINDOW_TYPE = get_atom(conn, "_NET_WM_WINDOW_TYPE");
|
||||
_NET_WM_WINDOW_TYPE_DOCK = get_atom(conn, "_NET_WM_WINDOW_TYPE_DOCK");
|
||||
_NET_WM_STATE = get_atom(conn, "_NET_WM_STATE");
|
||||
_NET_WM_STATE_ABOVE = get_atom(conn, "_NET_WM_STATE_ABOVE");
|
||||
|
@ -153,10 +143,7 @@ xcb_atom_t
|
|||
get_atom(xcb_connection_t *conn, const char *name)
|
||||
{
|
||||
xcb_generic_error_t *e;
|
||||
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(
|
||||
conn,
|
||||
xcb_intern_atom(conn, 0, strlen(name), name),
|
||||
&e);
|
||||
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(conn, xcb_intern_atom(conn, 0, strlen(name), name), &e);
|
||||
|
||||
if (e != NULL) {
|
||||
LOG_ERR("%s: failed to get atom for %s", name, xcb_error(e));
|
||||
|
@ -182,8 +169,7 @@ char *
|
|||
get_atom_name(xcb_connection_t *conn, xcb_atom_t atom)
|
||||
{
|
||||
xcb_generic_error_t *e;
|
||||
xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(
|
||||
conn, xcb_get_atom_name(conn, atom), &e);
|
||||
xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(conn, xcb_get_atom_name(conn, atom), &e);
|
||||
|
||||
if (e != NULL) {
|
||||
LOG_ERR("failed to get atom name: %s", xcb_error(e));
|
||||
|
@ -192,8 +178,7 @@ get_atom_name(xcb_connection_t *conn, xcb_atom_t atom)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char *name = strndup(
|
||||
xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply));
|
||||
char *name = strndup(xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply));
|
||||
|
||||
LOG_DBG("atom name: %s", name);
|
||||
|
||||
|
@ -207,22 +192,17 @@ xcb_error(const xcb_generic_error_t *error)
|
|||
static char msg[1024];
|
||||
|
||||
#if defined(HAVE_XCB_ERRORS)
|
||||
const char *major = xcb_errors_get_name_for_major_code(
|
||||
err_context, error->major_code);
|
||||
const char *minor = xcb_errors_get_name_for_minor_code(
|
||||
err_context, error->major_code, error->minor_code);
|
||||
const char *major = xcb_errors_get_name_for_major_code(err_context, error->major_code);
|
||||
const char *minor = xcb_errors_get_name_for_minor_code(err_context, error->major_code, error->minor_code);
|
||||
|
||||
const char *extension;
|
||||
const char *name = xcb_errors_get_name_for_error(
|
||||
err_context, error->error_code, &extension);
|
||||
const char *name = xcb_errors_get_name_for_error(err_context, error->error_code, &extension);
|
||||
|
||||
snprintf(msg, sizeof(msg),
|
||||
"major=%s, minor=%s), code=%s, extension=%s, sequence=%u",
|
||||
major, minor, name, extension, error->sequence);
|
||||
#else
|
||||
snprintf(msg, sizeof(msg), "op %hhu:%hu, code %hhu, sequence %hu",
|
||||
error->major_code, error->minor_code, error->error_code,
|
||||
snprintf(msg, sizeof(msg), "major=%s, minor=%s), code=%s, extension=%s, sequence=%u", major, minor, name, extension,
|
||||
error->sequence);
|
||||
#else
|
||||
snprintf(msg, sizeof(msg), "op %hhu:%hu, code %hhu, sequence %hu", error->major_code, error->minor_code,
|
||||
error->error_code, error->sequence);
|
||||
#endif
|
||||
|
||||
return msg;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue