1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2025-03-17 17:24:25 -04:00

cache: hide details of struct atom_entry

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-02-16 01:00:50 +00:00
parent 9175489f65
commit 2b52edd9e3
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4
2 changed files with 11 additions and 11 deletions

View file

@ -8,6 +8,11 @@
#include "log.h"
#include "utils.h"
struct atom_entry {
struct cache_handle entry;
xcb_atom_t atom;
};
static inline int atom_getter(struct cache *cache attr_unused, const char *atom_name,
struct cache_handle **value, void *user_data) {
xcb_connection_t *c = user_data;
@ -45,6 +50,10 @@ xcb_atom_t get_atom(struct atom *a, const char *key, xcb_connection_t *c) {
return cache_entry(entry, struct atom_entry, entry)->atom;
}
xcb_atom_t get_atom_cached(struct atom *a, const char *key) {
return cache_entry(cache_get(&a->c, key), struct atom_entry, entry)->atom;
}
/**
* Create a new atom structure and fetch all predefined atoms
*/

View file

@ -1,10 +1,7 @@
#pragma once
#include <stdlib.h>
#include <xcb/xcb.h>
#include "cache.h"
#include "log.h"
#include "meta.h"
// clang-format off
@ -54,24 +51,18 @@
#define ATOM_DEF(x) xcb_atom_t a##x
struct atom_entry;
struct atom {
struct cache c;
LIST_APPLY(ATOM_DEF, SEP_COLON, ATOM_LIST1);
LIST_APPLY(ATOM_DEF, SEP_COLON, ATOM_LIST2);
};
struct atom_entry {
struct cache_handle entry;
xcb_atom_t atom;
};
/// Create a new atom object with a xcb connection. `struct atom` does not hold
/// a reference to the connection.
struct atom *init_atoms(xcb_connection_t *c);
xcb_atom_t get_atom(struct atom *a, const char *key, xcb_connection_t *c);
static inline xcb_atom_t get_atom_cached(struct atom *a, const char *key) {
return cache_entry(cache_get(&a->c, key), struct atom_entry, entry)->atom;
}
xcb_atom_t get_atom_cached(struct atom *a, const char *key);
void destroy_atoms(struct atom *a);