2015-08-26 03:53:59 +10:00
|
|
|
#ifndef _SWAY_UTIL_H
|
|
|
|
#define _SWAY_UTIL_H
|
|
|
|
|
2016-01-06 04:07:43 +11:00
|
|
|
#include <stdint.h>
|
2018-07-30 22:03:46 +10:00
|
|
|
#include <stdbool.h>
|
2019-02-11 11:56:57 +11:00
|
|
|
#include <wayland-server-protocol.h>
|
2016-01-06 04:07:43 +11:00
|
|
|
|
2015-08-25 23:17:18 +10:00
|
|
|
/**
|
2020-06-06 07:12:31 +10:00
|
|
|
* Get the current time, in milliseconds.
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint32_t get_current_time_msec(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wrap i into the range [0, max]
|
2015-08-25 23:17:18 +10:00
|
|
|
*/
|
|
|
|
int wrap(int i, int max);
|
2015-08-26 03:53:59 +10:00
|
|
|
|
2016-07-31 09:50:13 +10:00
|
|
|
/**
|
2019-12-28 15:33:55 +11:00
|
|
|
* Given a string that represents an RGB(A) color, result will be set to a
|
|
|
|
* uint32_t version of the color, as long as it is valid. If it is invalid,
|
|
|
|
* then false will be returned and result will be untouched.
|
2016-07-31 09:50:13 +10:00
|
|
|
*/
|
2019-12-28 15:33:55 +11:00
|
|
|
bool parse_color(const char *color, uint32_t *result);
|
2016-07-31 09:50:13 +10:00
|
|
|
|
2019-12-28 15:56:11 +11:00
|
|
|
void color_to_rgba(float dest[static 4], uint32_t color);
|
|
|
|
|
2018-07-24 05:04:46 +10:00
|
|
|
/**
|
|
|
|
* Given a string that represents a boolean, return the boolean value. This
|
|
|
|
* function also takes in the current boolean value to support toggling. If
|
|
|
|
* toggling is not desired, pass in true for current so that toggling values
|
|
|
|
* get parsed as not true.
|
|
|
|
*/
|
2018-07-24 06:22:09 +10:00
|
|
|
bool parse_boolean(const char *boolean, bool current);
|
2018-07-24 05:04:46 +10:00
|
|
|
|
2018-11-18 06:31:33 +11:00
|
|
|
/**
|
|
|
|
* Given a string that represents a floating point value, return a float.
|
|
|
|
* Returns NAN on error.
|
|
|
|
*/
|
|
|
|
float parse_float(const char *value);
|
|
|
|
|
2019-02-11 11:56:57 +11:00
|
|
|
const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel);
|
|
|
|
|
2019-10-29 16:54:16 +11:00
|
|
|
bool sway_set_cloexec(int fd, bool cloexec);
|
2019-04-14 14:27:47 +10:00
|
|
|
|
2015-08-26 03:53:59 +10:00
|
|
|
#endif
|