kranewm

An ICCCM & EWMH compliant X11 reparenting, dynamic window manager, written in C++
git clone git clone git://git.deurzen.net/kranewm.git
Log | Files | Refs | LICENSE

commit c6f2664843a68bde1367e5b6a3b45aafaf32cd21
parent 367169e60ef2d3d558547ace61a35fb93370732b
Author: deurzen <m.deurzen@tum.de>
Date:   Mon,  2 Aug 2021 12:05:14 +0200

adds memoization to consume_client ignore check

Diffstat:
Msrc/core/model.cc | 26++++++++++++++++++++++++--
Msrc/core/model.hh | 1+
2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/core/model.cc b/src/core/model.cc @@ -12,6 +12,7 @@ #include <sstream> #include <sys/wait.h> #include <unistd.h> +#include <unordered_set> #include <vector> #ifdef DEBUG @@ -2884,6 +2885,9 @@ Model::set_iconify_client(Toggle toggle, Client_ptr client) void Model::consume_client(Client_ptr producer, Client_ptr client) { + static std::unordered_set<std::string> ignored_producers_memoized; + static std::unordered_set<std::string> ignored_consumers_memoized; + Workspace_ptr pworkspace = get_workspace(producer->workspace); Workspace_ptr cworkspace = get_workspace(client->workspace); @@ -2894,13 +2898,31 @@ Model::consume_client(Client_ptr producer, Client_ptr client) return; } + std::string producer_handle = producer->name + + ":" + producer->class_ + + ":" + producer->instance; + + std::string consumer_handle = client->name + + ":" + client->class_ + + ":" + client->instance; + + if (Util::contains(ignored_producers_memoized, producer_handle)) + return; + + if (Util::contains(ignored_consumers_memoized, consumer_handle)) + return; + for (SearchSelector_ptr selector : m_ignored_producers) - if (client_matches_search(producer, *selector)) + if (client_matches_search(producer, *selector)) { + ignored_producers_memoized.insert(producer_handle); return; + } for (SearchSelector_ptr selector : m_ignored_consumers) - if (client_matches_search(client, *selector)) + if (client_matches_search(client, *selector)) { + ignored_consumers_memoized.insert(consumer_handle); return; + } if (m_move_buffer.client() == producer) stop_moving(); diff --git a/src/core/model.hh b/src/core/model.hh @@ -16,6 +16,7 @@ #include "workspace.hh" #include <cstddef> +#include <unordered_map> #include <vector> class Model;