Add libi3/load_font, use it everywhere
…except for i3bar, which needs slightly more information about the font
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
#include <stdbool.h>
|
||||
#include "queue.h"
|
||||
#include "i3.h"
|
||||
#include "libi3.h"
|
||||
|
||||
typedef struct Config Config;
|
||||
typedef struct Barconfig Barconfig;
|
||||
|
@ -33,7 +33,6 @@
|
||||
*/
|
||||
|
||||
/* Forward definitions */
|
||||
typedef struct Font i3Font;
|
||||
typedef struct Binding Binding;
|
||||
typedef struct Rect Rect;
|
||||
typedef struct xoutput Output;
|
||||
@ -224,20 +223,6 @@ struct Autostart {
|
||||
TAILQ_ENTRY(Autostart) autostarts_always;
|
||||
};
|
||||
|
||||
/**
|
||||
* Data structure for cached font information:
|
||||
* - font id in X11 (load it once)
|
||||
* - font height (multiple calls needed to get it)
|
||||
*
|
||||
*/
|
||||
struct Font {
|
||||
/** The height of the font, built from font_ascent + font_descent */
|
||||
int height;
|
||||
/** The xcb-id for the font */
|
||||
xcb_font_t id;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* An Output is a physical output on your graphics driver. Outputs which
|
||||
* are currently in use have (output->active == true). Each output has a
|
||||
|
@ -5,11 +5,34 @@
|
||||
#ifndef _LIBI3_H
|
||||
#define _LIBI3_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xproto.h>
|
||||
#include <xcb/xcb_keysyms.h>
|
||||
|
||||
typedef struct Font i3Font;
|
||||
|
||||
/**
|
||||
* Data structure for cached font information:
|
||||
* - font id in X11 (load it once)
|
||||
* - font height (multiple calls needed to get it)
|
||||
*
|
||||
*/
|
||||
struct Font {
|
||||
/** The height of the font, built from font_ascent + font_descent */
|
||||
int height;
|
||||
/** The xcb-id for the font */
|
||||
xcb_font_t id;
|
||||
};
|
||||
|
||||
/* Since this file also gets included by utilities which don’t use the i3 log
|
||||
* infrastructure, we define a fallback. */
|
||||
#if !defined(ELOG)
|
||||
#define ELOG(fmt, ...) fprintf(stderr, "ERROR: " fmt, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Try to get the socket path from X11 and return NULL if it doesn’t work.
|
||||
*
|
||||
@ -143,4 +166,11 @@ uint32_t get_mod_mask_for(uint32_t keysym,
|
||||
xcb_key_symbols_t *symbols,
|
||||
xcb_get_modifier_mapping_reply_t *modmap_reply);
|
||||
|
||||
/**
|
||||
* Loads a font for usage, also getting its height. If fallback is true,
|
||||
* the fonts 'fixed' or '-misc-*' will be loaded instead of exiting.
|
||||
*
|
||||
*/
|
||||
i3Font load_font(const char *pattern, bool fallback);
|
||||
|
||||
#endif
|
||||
|
@ -52,14 +52,6 @@
|
||||
|
||||
extern unsigned int xcb_numlock_mask;
|
||||
|
||||
/**
|
||||
* Loads a font for usage, also getting its height. If fallback is true,
|
||||
* i3 loads 'fixed' or '-misc-*' if the font cannot be found instead of
|
||||
* exiting.
|
||||
*
|
||||
*/
|
||||
i3Font load_font(const char *pattern, bool fallback);
|
||||
|
||||
/**
|
||||
* Convenience wrapper around xcb_create_window which takes care of depth,
|
||||
* generating an ID and checking for errors.
|
||||
|
Reference in New Issue
Block a user