2018-01-21 08:21:45 +11:00
|
|
|
#ifndef _SWAY_CRITERIA_H
|
|
|
|
#define _SWAY_CRITERIA_H
|
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
#include <pcre.h>
|
2018-01-21 08:21:45 +11:00
|
|
|
#include "list.h"
|
2018-05-13 08:16:36 +10:00
|
|
|
#include "tree/view.h"
|
2018-01-21 08:21:45 +11:00
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
enum criteria_type {
|
|
|
|
CT_COMMAND = 1 << 0,
|
|
|
|
CT_ASSIGN_OUTPUT = 1 << 1,
|
|
|
|
CT_ASSIGN_WORKSPACE = 1 << 2,
|
|
|
|
};
|
2018-05-12 22:52:54 +10:00
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
struct criteria {
|
|
|
|
enum criteria_type type;
|
|
|
|
char *raw; // entire criteria string (for logging)
|
2018-01-21 08:21:45 +11:00
|
|
|
char *cmdlist;
|
2018-05-13 08:16:36 +10:00
|
|
|
char *target; // workspace or output name for `assign` criteria
|
|
|
|
|
|
|
|
pcre *title;
|
|
|
|
pcre *app_id;
|
|
|
|
pcre *class;
|
|
|
|
pcre *instance;
|
|
|
|
pcre *con_mark;
|
|
|
|
uint32_t con_id; // internal ID
|
|
|
|
uint32_t id; // X11 window ID
|
|
|
|
pcre *window_role;
|
|
|
|
uint32_t window_type;
|
|
|
|
bool floating;
|
|
|
|
bool tiling;
|
|
|
|
char urgent; // 'l' for latest or 'o' for oldest
|
|
|
|
char *workspace;
|
2018-01-21 08:21:45 +11:00
|
|
|
};
|
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
bool criteria_is_empty(struct criteria *criteria);
|
2018-01-21 08:21:45 +11:00
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
void criteria_destroy(struct criteria *criteria);
|
2018-01-21 08:21:45 +11:00
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
/**
|
|
|
|
* Generate a criteria struct from a raw criteria string such as
|
|
|
|
* [class="foo" instance="bar"] (brackets inclusive).
|
|
|
|
*
|
|
|
|
* The error argument is expected to be an address of a null pointer. If an
|
|
|
|
* error is encountered, the function will return NULL and the pointer will be
|
|
|
|
* changed to point to the error string. This string should be freed afterwards.
|
|
|
|
*/
|
|
|
|
struct criteria *criteria_parse(char *raw, char **error);
|
2018-01-21 08:21:45 +11:00
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
/**
|
|
|
|
* Compile a list of criterias matching the given view.
|
|
|
|
*
|
|
|
|
* Criteria types can be bitwise ORed.
|
|
|
|
*/
|
|
|
|
list_t *criteria_for_view(struct sway_view *view, enum criteria_type types);
|
2018-01-21 08:21:45 +11:00
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
/**
|
|
|
|
* Compile a list of views matching the given criteria.
|
|
|
|
*/
|
|
|
|
list_t *criteria_get_views(struct criteria *criteria);
|
2018-01-21 08:21:45 +11:00
|
|
|
|
|
|
|
#endif
|