2016-11-02 15:22:45 -04:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-10 21:07:28 -05:00
|
|
|
#include "settings.hpp"
|
2016-11-02 15:22:45 -04:00
|
|
|
|
2016-11-30 06:46:26 -05:00
|
|
|
#if not WITH_XRANDR
|
2016-11-20 17:04:31 -05:00
|
|
|
#error "X RandR extension is disabled..."
|
2016-11-02 15:22:45 -04:00
|
|
|
#endif
|
|
|
|
|
2016-11-26 09:42:48 -05:00
|
|
|
#include <xcb/randr.h>
|
2020-05-01 11:43:14 -04:00
|
|
|
|
2016-11-20 17:04:31 -05:00
|
|
|
#include <xpp/proto/randr.hpp>
|
|
|
|
|
2016-11-02 15:22:45 -04:00
|
|
|
#include "common.hpp"
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-11-02 15:22:45 -04:00
|
|
|
|
2016-11-20 17:04:31 -05:00
|
|
|
class connection;
|
2016-11-26 03:38:55 -05:00
|
|
|
struct position;
|
2016-11-20 17:04:31 -05:00
|
|
|
|
|
|
|
namespace evt {
|
|
|
|
using randr_notify = xpp::randr::event::notify<connection&>;
|
|
|
|
using randr_screen_change_notify = xpp::randr::event::screen_change_notify<connection&>;
|
2020-05-01 11:43:14 -04:00
|
|
|
} // namespace evt
|
2016-11-20 17:04:31 -05:00
|
|
|
|
2016-11-02 15:22:45 -04:00
|
|
|
struct backlight_values {
|
2017-01-19 05:11:28 -05:00
|
|
|
unsigned int atom{0};
|
2017-01-10 22:16:33 -05:00
|
|
|
double min{0.0};
|
|
|
|
double max{0.0};
|
|
|
|
double val{0.0};
|
2016-11-02 15:22:45 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct randr_output {
|
|
|
|
string name;
|
2017-01-19 05:11:28 -05:00
|
|
|
unsigned short int w{0U};
|
|
|
|
unsigned short int h{0U};
|
|
|
|
short int x{0};
|
|
|
|
short int y{0};
|
2016-11-12 14:31:39 -05:00
|
|
|
xcb_randr_output_t output;
|
2016-11-02 15:22:45 -04:00
|
|
|
backlight_values backlight;
|
2019-01-20 14:20:30 -05:00
|
|
|
bool primary{false};
|
2016-11-12 14:31:39 -05:00
|
|
|
|
2018-12-02 19:21:20 -05:00
|
|
|
bool match(const string& o, bool exact = true) const;
|
2016-11-26 03:38:55 -05:00
|
|
|
bool match(const position& p) const;
|
2019-06-24 18:23:44 -04:00
|
|
|
|
2020-05-01 11:43:14 -04:00
|
|
|
bool contains(const position& p) const;
|
2019-06-24 18:23:44 -04:00
|
|
|
bool contains(const randr_output& output) const;
|
2019-06-30 09:34:18 -04:00
|
|
|
|
|
|
|
bool equals(const randr_output& output) const;
|
2016-11-02 15:22:45 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
using monitor_t = shared_ptr<randr_output>;
|
|
|
|
|
|
|
|
namespace randr_util {
|
2016-12-21 08:55:19 -05:00
|
|
|
void query_extension(connection& conn);
|
|
|
|
|
2017-01-12 21:52:56 -05:00
|
|
|
bool check_monitor_support();
|
|
|
|
|
2020-05-01 11:43:14 -04:00
|
|
|
monitor_t make_monitor(xcb_randr_output_t randr, string name, unsigned short int w, unsigned short int h, short int x,
|
|
|
|
short int y, bool primary);
|
|
|
|
vector<monitor_t> get_monitors(
|
|
|
|
connection& conn, xcb_window_t root, bool connected_only = false, bool purge_clones = true);
|
2018-12-02 19:21:20 -05:00
|
|
|
monitor_t match_monitor(vector<monitor_t> monitors, const string& name, bool exact_match);
|
2016-11-02 15:22:45 -04:00
|
|
|
|
|
|
|
void get_backlight_range(connection& conn, const monitor_t& mon, backlight_values& dst);
|
|
|
|
void get_backlight_value(connection& conn, const monitor_t& mon, backlight_values& dst);
|
2020-05-01 11:43:14 -04:00
|
|
|
} // namespace randr_util
|
2016-11-02 15:22:45 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|