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 8e12cd943949ab8378b3e3421ccad55bcf03a316
parent f013665af293c88769d6e6d40d2c732eb17cc68f
Author: deurzen <m.deurzen@tum.de>
Date:   Mon, 27 Sep 2021 01:31:39 +0200

adds basic pt,cx encapsulation and operations

Diffstat:
Msrc/core/context.hh | 115++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/core/model.cc | 4++--
Msrc/core/partition.hh | 30+++++++++++++++++++++++++++++-
Msrc/core/workspace.hh | 24++++++++++++++++++++++++
4 files changed, 169 insertions(+), 4 deletions(-)

diff --git a/src/core/context.hh b/src/core/context.hh @@ -2,15 +2,24 @@ #define __CONTEXT_H_GUARD__ #include "../winsys/common.hh" +#include "cycle.hh" #include <string> +#include <unordered_set> + +typedef class Client* Client_ptr; +typedef class Workspace* Workspace_ptr; +typedef class Partition* Partition_ptr; typedef class Context final { public: Context(Index index, std::string name) : m_index(index), - m_name(name) + m_name(name), + mp_partition(nullptr), + mp_active(nullptr), + m_workspaces({}, true) {} Index @@ -19,10 +28,114 @@ public: return m_index; } + std::string const& + name() const + { + return m_name; + } + + bool + is_partitioned() const + { + return mp_partition != nullptr; + } + + void + set_partition(Partition_ptr partition) + { + mp_partition = partition; + } + + void + register_workspace(Workspace_ptr workspace) + { + m_workspaces.insert_at_back(workspace); + } + + void + activate_workspace(Index index) + { + m_workspaces.activate_at_index(index); + mp_active = *m_workspaces.active_element(); + } + + void + activate_workspace(Workspace_ptr workspace) + { + m_workspaces.activate_element(workspace); + mp_active = workspace; + } + + Cycle<Workspace_ptr> const& + workspaces() const + { + return m_workspaces; + } + + void + register_sticky_client(Client_ptr client) + { + m_sticky_clients.insert(client); + } + + void + unregister_sticky_client(Client_ptr client) + { + m_sticky_clients.erase(client); + } + + std::unordered_set<Client_ptr> const& + sticky_clients() const + { + return m_sticky_clients; + } + + std::deque<Workspace_ptr>::iterator + begin() + { + return m_workspaces.begin(); + } + + std::deque<Workspace_ptr>::const_iterator + begin() const + { + return m_workspaces.begin(); + } + + std::deque<Workspace_ptr>::const_iterator + cbegin() const + { + return m_workspaces.cbegin(); + } + + std::deque<Workspace_ptr>::iterator + end() + { + return m_workspaces.end(); + } + + std::deque<Workspace_ptr>::const_iterator + end() const + { + return m_workspaces.end(); + } + + std::deque<Workspace_ptr>::const_iterator + cend() const + { + return m_workspaces.cend(); + } + private: Index m_index; std::string m_name; + Partition_ptr mp_partition; + + Workspace_ptr mp_active; + Cycle<Workspace_ptr> m_workspaces; + std::unordered_set<Client_ptr> m_sticky_clients; + }* Context_ptr; #endif//__CONTEXT_H_GUARD__ diff --git a/src/core/model.cc b/src/core/model.cc @@ -1363,11 +1363,11 @@ Model::activate_workspace(Workspace_ptr next_workspace) Workspace_ptr prev_workspace = mp_workspace; mp_prev_workspace = prev_workspace; - for (Client_ptr client : next_workspace->clients()) + for (Client_ptr client : *next_workspace) if (!client->mapped) map_client(client); - for (Client_ptr client : mp_workspace->clients()) + for (Client_ptr client : *mp_workspace) if (client->mapped && !client->sticky) unmap_client(client); diff --git a/src/core/partition.hh b/src/core/partition.hh @@ -36,8 +36,12 @@ public: set_context(Context_ptr context) { Util::assert(context != nullptr, - "partition must contain valid context"); + "partition must contain a valid context"); + if (mp_context) + mp_context->set_partition(nullptr); + + context->set_partition(this); mp_context = context; } @@ -47,6 +51,30 @@ public: return mp_context; } + winsys::Region + full_region() const + { + return m_screen.full_region(); + } + + winsys::Region + placeable_region() const + { + return m_screen.placeable_region(); + } + + bool + contains(winsys::Pos pos) const + { + return m_screen.contains(pos); + } + + bool + contains(winsys::Region region) const + { + return m_screen.contains(region); + } + private: winsys::Screen m_screen; Index m_index; diff --git a/src/core/workspace.hh b/src/core/workspace.hh @@ -208,12 +208,36 @@ public: return m_clients.begin(); } + std::deque<Client_ptr>::const_iterator + begin() const + { + return m_clients.begin(); + } + + std::deque<Client_ptr>::const_iterator + cbegin() const + { + return m_clients.cbegin(); + } + std::deque<Client_ptr>::iterator end() { return m_clients.end(); } + std::deque<Client_ptr>::const_iterator + end() const + { + return m_clients.end(); + } + + std::deque<Client_ptr>::const_iterator + cend() const + { + return m_clients.cend(); + } + private: std::size_t m_index; std::string m_name;