/*
 * DWN - Desktop Window Manager
 * retoor <retoor@molodetz.nl>
 * Window rules engine for auto-applying settings
 */

#ifndef DWN_RULES_H
#define DWN_RULES_H

#include "dwn.h"
#include <stdbool.h>

#define MAX_RULES 64
#define RULE_PATTERN_SIZE 128

typedef enum {
    RULE_MATCH_CLASS,
    RULE_MATCH_TITLE,
    RULE_MATCH_CLASS_AND_TITLE
} RuleMatchType;

typedef struct {
    RuleMatchType match_type;
    char class_pattern[RULE_PATTERN_SIZE];
    char title_pattern[RULE_PATTERN_SIZE];

    bool has_workspace;
    int workspace;

    bool has_floating;
    bool floating;

    bool has_sticky;
    bool sticky;

    bool has_fullscreen;
    bool fullscreen;

    bool has_size;
    int width;
    int height;

    bool has_position;
    int x;
    int y;

    bool has_opacity;
    float opacity;
} WindowRule;

void rules_init(void);
void rules_cleanup(void);
bool rules_load(const char *path);
void rules_add(const WindowRule *rule);
void rules_clear(void);
int rules_count(void);

bool rules_apply_to_client(Client *client);
bool rules_match_pattern(const char *str, const char *pattern);

#endif
