sway-patched-tray-menu/include/sway/criteria.h

68 lines
1.7 KiB
C
Raw Normal View History

2018-01-20 22:21:45 +01:00
#ifndef _SWAY_CRITERIA_H
#define _SWAY_CRITERIA_H
#include <pcre.h>
#include "config.h"
2018-01-20 22:21:45 +01:00
#include "list.h"
#include "tree/view.h"
2018-01-20 22:21:45 +01:00
enum criteria_type {
2018-08-12 01:38:19 +02:00
CT_COMMAND = 1 << 0,
CT_ASSIGN_OUTPUT = 1 << 1,
CT_ASSIGN_WORKSPACE = 1 << 2,
CT_ASSIGN_WORKSPACE_NUMBER = 1 << 3,
CT_NO_FOCUS = 1 << 4,
};
struct criteria {
enum criteria_type type;
char *raw; // entire criteria string (for logging)
2018-01-20 22:21:45 +01:00
char *cmdlist;
char *target; // workspace or output name for `assign` criteria
pcre *title;
2018-05-27 06:14:46 +02:00
pcre *shell;
pcre *app_id;
pcre *con_mark;
uint32_t con_id; // internal ID
2018-11-18 00:33:06 +01:00
#if HAVE_XWAYLAND
pcre *class;
uint32_t id; // X11 window ID
pcre *instance;
pcre *window_role;
enum atom_name window_type;
#endif
bool floating;
bool tiling;
char urgent; // 'l' for latest or 'o' for oldest
char *workspace;
2018-01-20 22:21:45 +01:00
};
bool criteria_is_empty(struct criteria *criteria);
2018-01-20 22:21:45 +01:00
void criteria_destroy(struct criteria *criteria);
2018-01-20 22:21:45 +01: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-20 22:21:45 +01: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-20 22:21:45 +01:00
/**
* Compile a list of views matching the given criteria.
*/
list_t *criteria_get_views(struct criteria *criteria);
2018-01-20 22:21:45 +01:00
#endif