Source

Mirror / include / setup.h

Full commit
#ifndef SETUP_H
#define SETUP_H
#include <vector>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <cstring>
#include <string>
#include <tuple>

#include <xcb/xcb.h>
#include <xcb/xcb_ewmh.h>
#include <xcb/randr.h>
#include <xcb/xcb_cursor.h>
 
#include "ewmh.h"
#include "cursor.h"

class Monitor;
class StatusBar;
class Window;

class SetupError: public std::exception
{
    public:
        SetupError(const std::string m="Window Manager Error");
        ~SetupError() noexcept;
        const char* what();
    private:
        std::string msg;

};

typedef std::tuple<std::string, std::string, std::string, bool, bool> Rule;

class Setup
{
    public:
        Setup(std::vector<std::string> tags, std::vector<Rule> windowRules);
        ~Setup();
        Window& findWindow(xcb_window_t window);
        void addWindow(xcb_window_t window);
        void addWindow(Window window);
        void removeWindow(xcb_window_t window);
        void removeWindow(Window window);
        void layoutWindows();
        Monitor& getCurrentMonitor();
        void launchApp(std::string command);

        xcb_connection_t *conn;
        xcb_ewmh_connection_t *ewmh;
        xcb_window_t root;
        xcb_screen_t *screen;
        xcb_cursor_context_t *cursorContext;
        std::vector<Monitor> monitors;

        int statusBarHeight = 20;
    
    private:
        bool getXrandrMonitors();
        void getMonitors();

        std::vector<std::string> tags;
        std::vector<Rule> windowRules;
};

#endif //SETUP_H