This commit is contained in:
Ongy 2018-05-27 16:05:27 +00:00 committed by GitHub
commit aded0015df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
91 changed files with 593 additions and 462 deletions

View file

@ -1,16 +1,52 @@
#ifndef _SWAY_LOG_H
#define _SWAY_LOG_H
#include <stdbool.h>
#include <wlr/util/log.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
typedef enum {
L_SILENT = 0,
L_ERROR = 1,
L_INFO = 2,
L_DEBUG = 3,
L_LAST,
} log_importance_t;
#ifdef __GNUC__
#define ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end)))
#else
#define ATTRIB_PRINTF(start, end)
#endif
void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
#define sway_abort(FMT, ...) \
_sway_abort("[%s:%d] " FMT, wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
_sway_abort("[%s:%d] " FMT, sway_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3);
#define sway_assert(COND, FMT, ...) \
_sway_assert(COND, "[%s:%d] %s:" FMT, wlr_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
_sway_assert(COND, "[%s:%d] %s:" FMT, sway_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
void error_handler(int sig);
typedef void (*log_callback_t)(log_importance_t importance, const char *fmt, va_list args);
// Will log all messages less than or equal to `verbosity`
// If `callback` is NULL, sway will use its default logger.
void sway_log_init(log_importance_t verbosity, log_callback_t callback);
void _sway_log(log_importance_t verbosity, const char *format, ...) ATTRIB_PRINTF(2, 3);
void _sway_vlog(log_importance_t verbosity, const char *format, va_list args) ATTRIB_PRINTF(2, 0);
const char *sway_strip_path(const char *filepath);
#define sway_log(verb, fmt, ...) \
_sway_log(verb, "[%s:%d] " fmt, sway_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
#define sway_vlog(verb, fmt, args) \
_sway_vlog(verb, "[%s:%d] " fmt, sway_strip_path(__FILE__), __LINE__, args)
#define sway_log_errno(verb, fmt, ...) \
sway_log(verb, fmt ": %s", ##__VA_ARGS__, strerror(errno))
#endif

View file

@ -5,6 +5,28 @@
#define SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP 32
/**
* Get modifier mask from modifier name.
*
* Returns the modifer mask or 0 if the name isn't found.
*/
uint32_t get_modifier_mask_by_name(const char *name);
/**
* Get modifier name from modifier mask.
*
* Returns the modifier name or NULL if it isn't found.
*/
const char *get_modifier_name_by_mask(uint32_t modifier);
/**
* Get an array of modifier names from modifier_masks
*
* Populates the names array and return the number of names added.
*/
int get_modifier_names(const char **names, uint32_t modifier_masks);
struct sway_keyboard {
struct sway_seat_device *seat_device;

View file

@ -16,27 +16,6 @@ int wrap(int i, int max);
*/
int numlen(int n);
/**
* Get modifier mask from modifier name.
*
* Returns the modifer mask or 0 if the name isn't found.
*/
uint32_t get_modifier_mask_by_name(const char *name);
/**
* Get modifier name from modifier mask.
*
* Returns the modifier name or NULL if it isn't found.
*/
const char *get_modifier_name_by_mask(uint32_t modifier);
/**
* Get an array of modifier names from modifier_masks
*
* Populates the names array and return the number of names added.
*/
int get_modifier_names(const char **names, uint32_t modifier_masks);
/**
* Get the pid of a parent process given the pid of a child process.
*