1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-10-27 05:23:39 -04:00
polybar/include/x11/winspec.hpp

181 lines
5.5 KiB
C++
Raw Normal View History

2016-11-20 17:04:31 -05:00
#pragma once
2016-11-26 00:13:20 -05:00
#include <xcb/xcb_aux.h>
2016-11-20 17:04:31 -05:00
#include "common.hpp"
2016-11-24 22:10:26 -05:00
#include "components/types.hpp"
2016-11-20 17:04:31 -05:00
#include "x11/connection.hpp"
POLYBAR_NS
struct cw_size {
2017-01-19 05:11:28 -05:00
explicit cw_size(unsigned short int w, unsigned short int h) : w(w), h(h) {}
2016-11-24 22:10:26 -05:00
explicit cw_size(struct size size) : w(size.w), h(size.h) {}
2017-01-19 05:11:28 -05:00
unsigned short int w{1};
unsigned short int h{1};
2016-11-20 17:04:31 -05:00
};
struct cw_pos {
2017-01-19 05:11:28 -05:00
explicit cw_pos(short int x, short int y) : x(x), y(y) {}
2016-11-24 22:10:26 -05:00
explicit cw_pos(struct position pos) : x(pos.x), y(pos.y) {}
2017-01-19 05:11:28 -05:00
short int x{0};
short int y{0};
2016-11-20 17:04:31 -05:00
};
struct cw_border {
2017-01-19 05:11:28 -05:00
explicit cw_border(unsigned short int border_width) : border_width(border_width) {}
unsigned short int border_width{0};
2016-11-20 17:04:31 -05:00
};
struct cw_class {
2017-01-19 05:11:28 -05:00
explicit cw_class(unsigned short int class_) : class_(class_) {}
unsigned short int class_{XCB_COPY_FROM_PARENT};
2016-11-20 17:04:31 -05:00
};
struct cw_parent {
2016-11-24 22:10:26 -05:00
explicit cw_parent(xcb_window_t parent) : parent(parent) {}
xcb_window_t parent{XCB_NONE};
2016-11-20 17:04:31 -05:00
};
struct cw_depth {
2017-01-19 05:11:28 -05:00
explicit cw_depth(unsigned char depth) : depth(depth) {}
unsigned char depth{XCB_COPY_FROM_PARENT};
2016-11-20 17:04:31 -05:00
};
struct cw_visual {
2016-11-24 22:10:26 -05:00
explicit cw_visual(xcb_visualid_t visualid) : visualid(visualid) {}
xcb_visualid_t visualid{XCB_COPY_FROM_PARENT};
2016-11-20 17:04:31 -05:00
};
struct cw_mask {
2017-01-19 05:11:28 -05:00
explicit cw_mask(unsigned int mask) : mask(mask) {}
const unsigned int mask{0};
2016-11-20 17:04:31 -05:00
};
struct cw_params {
2016-11-24 22:10:26 -05:00
explicit cw_params(const xcb_params_cw_t* params) : params(params) {}
const xcb_params_cw_t* params{nullptr};
};
struct cw_params_back_pixel {
2017-01-19 05:11:28 -05:00
explicit cw_params_back_pixel(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_back_pixmap {
2017-01-19 05:11:28 -05:00
explicit cw_params_back_pixmap(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_backing_pixel {
2017-01-19 05:11:28 -05:00
explicit cw_params_backing_pixel(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_backing_planes {
2017-01-19 05:11:28 -05:00
explicit cw_params_backing_planes(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_backing_store {
2017-01-19 05:11:28 -05:00
explicit cw_params_backing_store(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_bit_gravity {
2017-01-19 05:11:28 -05:00
explicit cw_params_bit_gravity(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_border_pixel {
2017-01-19 05:11:28 -05:00
explicit cw_params_border_pixel(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_border_pixmap {
2017-01-19 05:11:28 -05:00
explicit cw_params_border_pixmap(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_colormap {
2017-01-19 05:11:28 -05:00
explicit cw_params_colormap(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_cursor {
2017-01-19 05:11:28 -05:00
explicit cw_params_cursor(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_dont_propagate {
2017-01-19 05:11:28 -05:00
explicit cw_params_dont_propagate(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_event_mask {
2017-01-19 05:11:28 -05:00
explicit cw_params_event_mask(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_override_redirect {
2017-01-19 05:11:28 -05:00
explicit cw_params_override_redirect(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_save_under {
2017-01-19 05:11:28 -05:00
explicit cw_params_save_under(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-24 22:10:26 -05:00
};
struct cw_params_win_gravity {
2017-01-19 05:11:28 -05:00
explicit cw_params_win_gravity(unsigned int value) : value(value) {}
unsigned int value{0};
2016-11-20 17:04:31 -05:00
};
struct cw_flush {
2016-11-24 22:10:26 -05:00
explicit cw_flush(bool checked = false) : checked(checked) {}
bool checked{false};
2016-11-20 17:04:31 -05:00
};
/**
* Create X window
*
* Example usage:
* @code cpp
2016-11-24 22:10:26 -05:00
* auto win = winspec(m_connection)
2016-11-20 17:04:31 -05:00
* << cw_size(100, 200)
* << cw_pos(10, -20)
* << cw_border(9)
* << cw_class(XCB_WINDOW_CLASS_INPUT_ONLY)
* << cw_parent(0x000110a);
* << cw_flush(false);
* @endcode
*/
class winspec {
public:
2016-11-24 22:10:26 -05:00
explicit winspec(connection& conn);
explicit winspec(connection& conn, const xcb_window_t& window);
2016-11-20 17:04:31 -05:00
2016-11-24 22:10:26 -05:00
explicit operator xcb_window_t() const;
explicit operator xcb_rectangle_t() const;
2016-11-20 17:04:31 -05:00
2016-11-24 22:10:26 -05:00
xcb_window_t operator<<(const cw_flush& f);
2016-11-20 17:04:31 -05:00
2016-11-24 22:10:26 -05:00
winspec& operator<<(const cw_size& size);
winspec& operator<<(const cw_pos& p);
winspec& operator<<(const cw_border& b);
winspec& operator<<(const cw_class& c);
winspec& operator<<(const cw_parent& p);
winspec& operator<<(const cw_depth& d);
winspec& operator<<(const cw_visual& v);
winspec& operator<<(const cw_params_back_pixel& p);
winspec& operator<<(const cw_params_back_pixmap& p);
winspec& operator<<(const cw_params_backing_pixel& p);
winspec& operator<<(const cw_params_backing_planes& p);
winspec& operator<<(const cw_params_backing_store& p);
winspec& operator<<(const cw_params_bit_gravity& p);
winspec& operator<<(const cw_params_border_pixel& p);
winspec& operator<<(const cw_params_border_pixmap& p);
winspec& operator<<(const cw_params_colormap& p);
winspec& operator<<(const cw_params_cursor& p);
winspec& operator<<(const cw_params_dont_propagate& p);
winspec& operator<<(const cw_params_event_mask& p);
winspec& operator<<(const cw_params_override_redirect& p);
winspec& operator<<(const cw_params_save_under& p);
winspec& operator<<(const cw_params_win_gravity& p);
2016-11-20 17:04:31 -05:00
protected:
connection& m_connection;
2016-11-24 22:10:26 -05:00
xcb_window_t m_window{XCB_NONE};
2017-01-19 05:11:28 -05:00
unsigned int m_parent{XCB_NONE};
unsigned char m_depth{XCB_COPY_FROM_PARENT};
unsigned short int m_class{XCB_COPY_FROM_PARENT};
2016-11-24 22:10:26 -05:00
xcb_visualid_t m_visual{XCB_COPY_FROM_PARENT};
2017-01-19 05:11:28 -05:00
short int m_x{0};
short int m_y{0};
unsigned short int m_width{1U};
unsigned short int m_height{1U};
unsigned short int m_border{0};
unsigned int m_mask{0};
2016-11-24 22:10:26 -05:00
xcb_params_cw_t m_params{};
2016-11-20 17:04:31 -05:00
};
POLYBAR_NS_END