1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-03 04:33:30 -05:00
polybar/include/x11/randr.hpp
Michael Carlberg 4d7f6c14e6 fix(xrandr): Less strict monitor matching
Be less strict when matching randr outputs
against specified name. This is a workaround
to fix the output naming issue when switching
between graphic drivers.

On my system the output names include a dash
when using the nvidia drivers but the intel
driver does not.

   nvidia:
      HDMI-1
      eDP-1
   xf86-video-intel:
      HDMI1
      eDP1

When strict mode is disabled the matching
won't care about the connection state.

The user can re-enable exact matching and
connection state testing by setting the
config parameter `monitor-strict = true`
2016-11-12 20:42:56 +01:00

53 lines
1.2 KiB
C++

#pragma once
#include "config.hpp"
#ifndef ENABLE_RANDR_EXT
#error "RandR extension is disabled..."
#endif
#include "common.hpp"
#include "utils/memory.hpp"
#include "x11/connection.hpp"
LEMONBUDDY_NS
struct backlight_values {
uint32_t atom = 0;
uint32_t min = 0;
uint32_t max = 0;
uint32_t val = 0;
};
struct randr_output {
string name;
int w = 0;
int h = 0;
int x = 0;
int y = 0;
xcb_randr_output_t output;
backlight_values backlight;
/**
* Workaround for the inconsistent naming
* of outputs between my intel and nvidia
* drivers (xf86-video-intel drops the dash)
*/
bool match(const string& o, bool strict = false) const {
if (strict && name != o)
return false;
return name == o || name == string_util::replace(o, "-", "");
}
};
using monitor_t = shared_ptr<randr_output>;
namespace randr_util {
monitor_t make_monitor(xcb_randr_output_t randr, string name, int w, int h, int x, int y);
vector<monitor_t> get_monitors(connection& conn, xcb_window_t root, bool connected_only = false);
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);
}
LEMONBUDDY_NS_END