client.hh (3812B)
1 #ifndef __CLIENT_H_GUARD__ 2 #define __CLIENT_H_GUARD__ 3 4 #include "../winsys/common.hh" 5 #include "../winsys/decoration.hh" 6 #include "../winsys/geometry.hh" 7 #include "../winsys/hints.hh" 8 #include "../winsys/window.hh" 9 10 #include <chrono> 11 #include <optional> 12 #include <string> 13 #include <vector> 14 15 typedef class Partition* Partition_ptr; 16 typedef class Context* Context_ptr; 17 typedef class Workspace* Workspace_ptr; 18 19 typedef struct Client* Client_ptr; 20 typedef struct Client final 21 { 22 enum class OutsideState 23 { 24 Focused, 25 FocusedDisowned, 26 FocusedSticky, 27 Unfocused, 28 UnfocusedDisowned, 29 UnfocusedSticky, 30 Urgent 31 }; 32 33 static constexpr winsys::Dim MIN_CLIENT_DIM = winsys::Dim { 25, 10 }; 34 static constexpr winsys::Dim PREFERRED_CLIENT_DIM = winsys::Dim { 480, 260 }; 35 36 static bool 37 is_free(Client_ptr client) 38 { 39 return (client->floating && (!client->fullscreen || client->contained)) 40 || !client->managed 41 || client->disowned; 42 } 43 44 Client( 45 winsys::Window window, 46 winsys::Window frame, 47 std::string name, 48 std::string class_, 49 std::string instance, 50 Partition_ptr partition, 51 Context_ptr context, 52 Workspace_ptr workspace, 53 std::optional<winsys::Pid> pid, 54 std::optional<winsys::Pid> ppid 55 ); 56 57 ~Client(); 58 59 Client(const Client&) = default; 60 Client& operator=(const Client&) = default; 61 62 OutsideState get_outside_state() const; 63 64 void touch(); 65 void focus(); 66 void unfocus(); 67 68 void stick(); 69 void unstick(); 70 71 void disown(); 72 void reclaim(); 73 74 void set_urgent(); 75 void unset_urgent(); 76 77 void expect_unmap(); 78 bool consume_unmap_if_expecting(); 79 80 void set_tile_region(winsys::Region&); 81 void set_free_region(winsys::Region&); 82 83 void set_tile_decoration(winsys::Decoration const&); 84 void set_free_decoration(winsys::Decoration const&); 85 86 winsys::Window window; 87 winsys::Window frame; 88 std::string name; 89 std::string class_; 90 std::string instance; 91 Partition_ptr partition; 92 Context_ptr context; 93 Workspace_ptr workspace; 94 winsys::Region free_region; 95 winsys::Region tile_region; 96 winsys::Region active_region; 97 winsys::Region previous_region; 98 winsys::Region inner_region; 99 winsys::Decoration tile_decoration; 100 winsys::Decoration free_decoration; 101 winsys::Decoration active_decoration; 102 std::optional<winsys::SizeHints> size_hints; 103 std::optional<winsys::Pos> warp_pos; 104 std::optional<winsys::Window> leader; 105 Client_ptr parent; 106 std::vector<Client_ptr> children; 107 Client_ptr producer; 108 std::vector<Client_ptr> consumers; 109 bool focused; 110 bool mapped; 111 bool managed; 112 bool urgent; 113 bool floating; 114 bool fullscreen; 115 bool contained; 116 bool invincible; 117 bool sticky; 118 bool iconifyable; 119 bool iconified; 120 bool disowned; 121 bool producing; 122 bool attaching; 123 std::optional<winsys::Pid> pid; 124 std::optional<winsys::Pid> ppid; 125 std::chrono::time_point<std::chrono::steady_clock> last_touched; 126 std::chrono::time_point<std::chrono::steady_clock> last_focused; 127 std::chrono::time_point<std::chrono::steady_clock> managed_since; 128 std::size_t expected_unmap_count; 129 130 private: 131 OutsideState m_outside_state; 132 133 void set_inner_region(winsys::Region&); 134 void set_active_region(winsys::Region&); 135 136 }* Client_ptr; 137 138 inline bool 139 operator==(const Client& lhs, const Client& rhs) 140 { 141 return lhs.window == rhs.window; 142 } 143 144 namespace std 145 { 146 template <> 147 struct hash<Client> 148 { 149 std::size_t 150 operator()(const Client& client) const 151 { 152 return std::hash<winsys::Window>{}(client.window); 153 } 154 }; 155 } 156 157 #endif//__CLIENT_H_GUARD__