1 #ifndef __CLIENTLIST_H_
2 #define __CLIENTLIST_H_
3 
4 #include <X11/X.h>
5 #include <X11/Xlib.h>
6 
7 #include "attribute_.h"
8 #include "child.h"
9 #include "commandio.h"
10 #include "object.h"
11 #include "rectangle.h"
12 #include "regexstr.h"
13 #include "theme.h"
14 #include "types.h"
15 #include "x11-types.h"
16 
17 class Decoration;
18 class DecTriple;
19 class Ewmh;
20 class FrameLeaf;
21 class Slice;
22 class HSTag;
23 class Monitor;
24 class Settings;
25 class ClientManager;
26 
27 class Client : public Object {
28 public:
29     Client(Window w, bool visible_already, ClientManager& cm);
30     ~Client() override;
31 
32     Window      window_;
33     std::unique_ptr<Decoration> dec; // pimpl
34     Rectangle   last_size_;      // last size excluding the window border
35     Rectangle   float_size_ = {0, 0, 100, 100};     // floating size without the window border
36     HSTag*      tag_ = {};
37     Slice* slice = {};
38     bool        ewmhfullscreen_ = false; // ewmh fullscreen state
39     bool        neverfocus_ = false; // do not give the focus via XSetInputFocus
40     Attribute_<bool> visible_;
41     bool        dragged_ = false;  // if this client is dragged currently
42     int         ignore_unmaps_ = 0;  // Ignore one unmap for each reparenting
43                                 // action, because reparenting creates an unmap
44                                 // notify event
45     // for size hints
46     float mina_ = 0;
47     float maxa_ = 0;
48     int basew_ = 0;
49     int baseh_ = 0;
50     int incw_ = 0;
51     int inch_ = 0;
52     int maxw_ = 0;
53     int maxh_ = 0;
54     int minw_ = 0;
55     int minh_ = 0;
56 
57     // for other modules
58     Signal_<HSTag*> needsRelayout;
59 
60     // attributes:
61     Attribute_<bool> urgent_;
62     Attribute_<bool> floating_;
63     Attribute_<bool> fullscreen_;
64     Attribute_<bool> minimized_;
65     Attribute_<std::string> title_;  // or also called window title; this is never NULL
66     DynAttribute_<std::string> tag_str_;
67     DynChild_<FrameLeaf> parent_frame_;
68     Attribute_<std::string> window_id_str;
69     Attribute_<RegexStr> keyMask_; // regex for key bindings that are active on this window
70     Attribute_<RegexStr> keysInactive_; // regex for key bindings that are inactive on this window
71     Attribute_<int>  pid_;
72     Attribute_<int>  pgid_;
73     Attribute_<bool> pseudotile_; // only move client but don't resize (if possible)
74     Attribute_<bool> ewmhrequests_; // accept ewmh-requests for this client
75     Attribute_<bool> ewmhnotify_; // send ewmh-notifications for this client
76     Attribute_<bool> sizehints_floating_;  // respect size hints regarding this client in floating mode
77     Attribute_<bool> sizehints_tiling_;  // respect size hints regarding this client in tiling mode
78     DynAttribute_<std::string> window_class_;
79     DynAttribute_<std::string> window_instance_;
80 
81 public:
82     void init_from_X();
83 
84     void make_full_client();
85     void listen_for_events();
86 
87 
88     // setter and getter for attributes
tag()89     HSTag* tag() { return tag_; }
90     void setTag(HSTag* tag);
91 
x11Window()92     Window x11Window() const { return window_; }
93     Window decorationWindow();
94     friend void mouse_function_resize(XMotionEvent* me);
95 
96     // other member functions
97     void window_focus();
98     void window_unfocus();
99     static void window_unfocus_last();
100 
101     void fuzzy_fix_initial_position();
102 
103     Rectangle outer_floating_rect();
104 
105     void setup_border(bool focused);
106     void resize_tiling(Rectangle rect, bool isFocused, bool minimalDecoration);
107     void resize_floating(Monitor* m, bool isFocused);
108     void resize_fullscreen(Rectangle m, bool isFocused);
109     bool is_client_floated();
110     void set_urgent(bool state);
111     void update_wm_hints();
112     void update_title();
113     void raise();
114 
115     void send_configure();
116     bool applysizehints(int *w, int *h);
117     void updatesizehints();
118 
119     void set_visible(bool visible);
120 
121     void set_urgent_force(bool state);
122     void requestClose(); //! ask the client to close
123 
124     void clear_properties();
125     bool ignore_unmapnotify();
126 
127     void updateEwmhState();
128 private:
129     std::string getWindowClass();
130     std::string getWindowInstance();
131     std::string triggerRelayoutMonitor();
132     FrameLeaf* parentFrame();
133     void requestRedraw();
134     friend Decoration;
135     ClientManager& manager;
136     Theme& theme;
137     Settings& settings;
138     Ewmh& ewmh;
139     std::string tagName();
140     const DecTriple& getDecTriple();
141     Theme::Type mostRecentThemeType;
142 };
143 
144 
145 
146 void reset_client_colors();
147 
148 Client* get_client_from_window(Window window);
149 Client* get_current_client();
150 Client* get_client(const char* str);
151 Window get_window(const std::string& str);
152 
153 int close_command(Input input, Output output);
154 
155 // sets a client property, depending on argv[0]
156 int client_set_property_command(int argc, char** argv);
157 bool is_window_class_ignored(char* window_class);
158 bool is_window_ignored(Window win);
159 
160 #endif
161