aboutsummaryrefslogtreecommitdiff
path: root/src/WinClient.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/WinClient.hh')
-rw-r--r--src/WinClient.hh190
1 files changed, 190 insertions, 0 deletions
diff --git a/src/WinClient.hh b/src/WinClient.hh
new file mode 100644
index 0000000..c93a76d
--- /dev/null
+++ b/src/WinClient.hh
@@ -0,0 +1,190 @@
1// WinClient.hh for Fluxbox - an X11 Window manager
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen(at)users.sourceforge.net)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id: WinClient.hh,v 1.15 2003/09/29 14:58:15 rathnor Exp $
23
24#ifndef WINCLIENT_HH
25#define WINCLIENT_HH
26
27#include "Window.hh"
28#include "Subject.hh"
29#include "FbWindow.hh"
30
31#include <X11/Xutil.h>
32#include <string>
33
34class BScreen;
35class Strut;
36
37/// Holds client window info
38class WinClient:public FbTk::FbWindow {
39public:
40 typedef std::list<WinClient *> TransientList;
41
42 WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin = 0);
43
44 ~WinClient();
45 void updateRect(int x, int y, unsigned int width, unsigned int height);
46 bool sendFocus(); // returns whether we sent a message or not
47 // i.e. whether we assume the focus will get taken
48 void sendClose(bool forceful = false);
49 // not aware of anything that makes this false at present
50 inline bool isClosable() const { return true; }
51 void reparent(Window win, int x, int y);
52 bool getAttrib(XWindowAttributes &attr) const;
53 bool getWMName(XTextProperty &textprop) const;
54 bool getWMIconName(XTextProperty &textprop) const;
55 /// @return name member of class structure
56 const std::string &getWMClassName() const;
57 /// @return class member of class structure
58 const std::string &getWMClassClass() const;
59 /// updates from wm class hints
60 void updateWMClassHint();
61 void updateWMProtocols();
62
63 inline const std::string &getTitle() const { return m_title; }
64 void updateTitle();
65 void updateIconTitle();
66 BScreen &screen() { return m_screen; }
67 const BScreen &screen() const { return m_screen; }
68 /// notifies when this client dies
69 FbTk::Subject &dieSig() { return m_diesig; }
70
71 /// updates transient window information
72 void updateTransientInfo();
73 WinClient *transientFor() { return transient_for; }
74 const WinClient *transientFor() const { return transient_for; }
75 TransientList &transientList() { return transients; }
76 const TransientList &transientList() const { return transients; }
77 bool isTransient() const { return transient_for != 0; }
78
79 bool isModal() const { return m_modal > 0; }
80 void addModal(); // some transient of ours (or us) is modal
81 void removeModal(); // some transient (or us) is no longer modal
82
83 bool operator == (const FluxboxWindow &win) const {
84 return (m_win == &win);
85 }
86
87 void setStrut(Strut *strut);
88 void clearStrut();
89
90 bool focus(); // calls Window->setCurrentClient to give focus to this client
91
92 const std::string &title() const { return m_title; }
93 const std::string &iconTitle() const { return m_icon_title; }
94 const FluxboxWindow *fbwindow() const { return m_win; }
95 FluxboxWindow *fbwindow() { return m_win; }
96
97 static const int PropBlackboxHintsElements = 5;
98 static const int PropMwmHintsElements = 3;
99
100 void updateBlackboxHints();
101 void updateMWMHints();
102 void updateWMHints();
103 void updateWMNormalHints();
104
105 /**
106 * Changes width and height to the nearest (lower) value
107 * that conforms to it's size hints.
108 *
109 * display_* give the values that would be displayed
110 * to the user when resizing.
111 * We use pointers for display_* since they are optional.
112 */
113 void applySizeHints(int &width, int &height, int *display_width = 0, int *display_height = 0);
114
115 // grouping is tracked by remembering the window to the left in the group
116 Window getGroupLeftWindow() const;
117 void setGroupLeftWindow(Window win);
118 bool hasGroupLeftWindow() const;
119
120 // does this client have a pending unmap or destroy event?
121 bool validateClient() const;
122
123 inline int gravity() const { return m_win_gravity; }
124
125 /**
126 !! TODO !!
127 remove or move these to private
128 */
129
130 WinClient *transient_for; // which window are we a transient for?
131 std::list<WinClient *> transients; // which windows are our transients?
132 Window window_group;
133
134
135 int x, y, old_bw;
136 unsigned int
137 min_width, min_height, max_width, max_height, width_inc, height_inc,
138 min_aspect_x, min_aspect_y, max_aspect_x, max_aspect_y,
139 base_width, base_height;
140 unsigned long initial_state, normal_hint_flags, wm_hint_flags;
141
142 // this structure only contains 3 elements... the Motif 2.0 structure contains
143 // 5... we only need the first 3... so that is all we will define
144 typedef struct MwmHints {
145 unsigned long flags; // Motif wm flags
146 unsigned long functions; // Motif wm functions
147 unsigned long decorations; // Motif wm decorations
148 } MwmHints;
149
150 FluxboxWindow *m_win;
151 class WinClientSubj: public FbTk::Subject {
152 public:
153 explicit WinClientSubj(WinClient &client):m_winclient(client) { }
154 WinClient &winClient() { return m_winclient; }
155 private:
156 WinClient &m_winclient;
157 };
158
159 inline int getFocusMode() const { return m_focus_mode; }
160 inline const FluxboxWindow::BlackboxHints *getBlackboxHint() const {
161 return m_blackbox_hint; }
162 void saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_attribs);
163 inline const MwmHints *getMwmHint() const { return m_mwm_hint; }
164
165 enum { F_NOINPUT = 0, F_PASSIVE, F_LOCALLYACTIVE, F_GLOBALLYACTIVE };
166
167private:
168 // number of transients which we are modal for
169 // or indicates that we are modal if don't have any transients
170 int m_modal;
171 bool send_focus_message, send_close_message;
172
173 int m_win_gravity;
174
175 std::string m_title, m_icon_title;
176 std::string m_class_name, m_instance_name;
177
178 FluxboxWindow::BlackboxHints *m_blackbox_hint;
179 MwmHints *m_mwm_hint;
180
181 int m_focus_mode;
182
183 WinClientSubj m_diesig;
184 BScreen &m_screen;
185
186 Strut *m_strut;
187
188};
189
190#endif // WINCLIENT_HH