fix(monitor): Remove realloc from get_monitors
Premature optimization that tried to cache monitors but the cache did not take into account the parameter values. The call `get_monitors(..., ..., false, true);` would get all connected and unconncected monitors a subsequent call `get_monitors(..., ..., true, false);` would get back the same list of monitors even though it requested only connected monitors. Additionally `get_monitors` is never called periodically so the optimization really didn't help much.
This commit is contained in:
parent
61dfe739d5
commit
b5e7078d93
@ -51,7 +51,7 @@ namespace randr_util {
|
||||
|
||||
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 realloc = false);
|
||||
vector<monitor_t> get_monitors(connection& conn, xcb_window_t root, bool connected_only = false);
|
||||
monitor_t match_monitor(vector<monitor_t> monitors, const string& name, bool exact_match);
|
||||
|
||||
void get_backlight_range(connection& conn, const monitor_t& mon, backlight_values& dst);
|
||||
|
@ -101,7 +101,7 @@ void screen::handle(const evt::randr_screen_change_notify& evt) {
|
||||
if (screen->width_in_pixels != m_size.w || screen->height_in_pixels != m_size.h) {
|
||||
changed = true;
|
||||
} else {
|
||||
auto monitors = randr_util::get_monitors(m_connection, m_root, true, true);
|
||||
auto monitors = randr_util::get_monitors(m_connection, m_root, true);
|
||||
for (size_t n = 0; n < monitors.size(); n++) {
|
||||
if (n < m_monitors.size() && monitors[n]->output != m_monitors[n]->output) {
|
||||
changed = true;
|
||||
|
@ -80,14 +80,8 @@ namespace randr_util {
|
||||
/**
|
||||
* Create a list of all available randr outputs
|
||||
*/
|
||||
vector<monitor_t> get_monitors(connection& conn, xcb_window_t root, bool connected_only, bool realloc) {
|
||||
static vector<monitor_t> monitors;
|
||||
|
||||
if (realloc) {
|
||||
monitors.clear();
|
||||
} else if (!monitors.empty()) {
|
||||
return monitors;
|
||||
}
|
||||
vector<monitor_t> get_monitors(connection& conn, xcb_window_t root, bool connected_only) {
|
||||
vector<monitor_t> monitors;
|
||||
|
||||
#if WITH_XRANDR_MONITORS
|
||||
if (check_monitor_support()) {
|
||||
|
Loading…
Reference in New Issue
Block a user