File: client.hh

package info (click to toggle)
sapphire 0.15.8-9.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 448 kB
  • ctags: 850
  • sloc: cpp: 6,490; makefile: 102; sh: 77
file content (230 lines) | stat: -rw-r--r-- 6,216 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/*
 * Copyright (C) 1999,2000,2001 Frank Hale
 * frankhale@yahoo.com
 * http://sapphire.sourceforge.net/
 *
 * Updated: 3 Nov 2001
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */


#ifndef _CLIENT_HH_

class Client 
{
private:
	Display 	*dpy;
	
	Window  	title;
	Window		window;
	Window		parent;
	Window		transient;
	Window		right_sidebar;
	Window		resize_win;

	Pixmap 		frame_pix;	// Pixmap used for the titlebar
	Pixmap 		button_pix;	// Pixmap used for titlebar buttons
	Pixmap		right_pix;
	Pixmap		resize_pix;
	
	Widget 		shadeButton;
	Widget 		maximize;
	Widget 		minimize;
	Widget 		close;
	
	bool		moving;
	
	int		right_sidebar_width;
	
	int 		default_button_width;
	int 		default_button_height;

	int 		default_close_button_x;
	int		default_close_button_y;
	
	int 		default_shade_button_x;
	int		default_shade_button_y;
	
	int 		default_minimize_button_x;
	int		default_minimize_button_y;	

	int 		default_maximize_button_x;
	int		default_maximize_button_y;

	int 		default_titlebar_height;
	
	int 		default_client_name_x;
	int		default_client_name_y;
	
	int		close_button_pressed;
	int 		shade_button_pressed;
	int		minimize_button_pressed;
	int 		maximize_button_pressed;
	
	char		*name;

	char		client_position[40];
	int		text_width;
	
	bool		shaped;
	
	long 		state;

	// bitmap of what desktops this client is in
	int             desktop_mask;
	int             away;

	Colormap	cmap;
	XSizeHints	*size;
	int		ignore_unmap;

	int		x;
	int		y;
	int		width;
	int		height;

	bool 		override_redirect;

	int		oumx;
	int		oumy;
	int		oumwidth;
	int		oumheight;

	int		old_width;
	int		old_height;

	bool 		button1;
	bool 		button2;
	bool 		button3;
	
	bool 		shaded;
	bool 		maxsized;

	// Titlebar turned on/off
	bool 		has_titlebar;
	
	// Client buttons turned on/off
	bool 		has_close_button;
	bool		has_minimize_button;
	bool		has_maximize_button;
	bool 		has_shade_button;
	
	bool 		has_focus;
	
	MwmHints *mwm_hint;
	
public: /* member functions */

	Client(); 
	~Client();

	Client *find_client(Window w);

private:
	
	Window createChildWindow(Window parent, int x, int y, unsigned int width,
		unsigned int height,unsigned int borderwidth);
	
	Window createTopLevelWindow(int x, int y, unsigned int width,
		unsigned int height,unsigned int borderwidth);

	void init_position(Client *c);
	
	void reparent(Client *c);
	void send_config(Client *c);
	
	void resize(Client *c);
	void move(Client *c);
	void change_gravity(Client *c, int multiplier);
	void shade(Client *c);
	void maximumresize(Client *c);
	
	void closeButtonPressed(Client *c);
	void shadeButtonPressed(Client *c);
	void minimizeButtonPressed(Client *c);
	void maximizeButtonPressed(Client *c);
	
	void set_shape(Client *c);

	void drag(Client *c);
	void sweep(Client *c);
	void recalculate_sweep(Client *c, int x1, int y1, int x2, int y2);
	void draw_outline(Client *c);
	void draw_shade_button(Client *c);
	int  get_wm_state(Client *c);
	void set_wm_state(Client *c, int state);
	void redraw(Client *c);
	void installColorMap(Colormap cmap);
	void isIconic(Client *c);			// If this client is iconic the unmap it otherwise map it
	int isViewable(Client *c);			// Is this client visible?
	void mapClient(Client *c);			// Map Client to screen
	void getTransients(Client *c);			// Set this clients transient
	
	// Client window decoration member functions
	void determineWindowDecorations(Client *c);	// Determines if this client needs to have a titlebar and what buttons to display.
	void createTitleImage(Client* c);		// Creates the Title Image 
	void createButtonImage(Client* c);		// Creates the Button Image
	void createRightSidebarImage(Client *c);
	void createResizeImage(Client *c);

	void setButtonPositionDefaults(Client *c);
	
	void createParentWindow(Client *c);		// Creates the Parent Window
	void createTitlebarWindow(Client *c);		// Creates the Titlebar Window
	void createCloseButtonWindow(Client *c);	// Creates the Close Button Window
	void createMinimizeButtonWindow(Client *c);	// Creates the Minimize Button Window
	void createMaximizeButtonWindow(Client *c);	// Creates the Maximimize Button Window
	void createShadeButtonWindow(Client *c);	// Creates the Shade Button Window
	void createRightSidebarWindow(Client *c);
	void createResizeWindow(Client *c);
	
	int  theight(Client *c) const; 			// returns the titlebar height for a client
	
	int send_xmessage(Window w, Atom a, long x, long y);
	void send_wm_delete(Client *c);

	void reconfigure(Client *c);

public:
	void hide(Client *c);
	void unhide(Client *c);
	void show(Client *c) { mapClient(c); }
	
	void raise();

	void get_mouse_position(int *x, int *y);	
	void make_new_client(Window w);
	
	// Client Events
	void handle_unmap_event(XUnmapEvent *e);
	void handle_button_press_event(XButtonEvent *e);
	void handle_client_message(XClientMessageEvent *e);
	void handle_colormap_change(XColormapEvent *e);
	void handle_configure_request(XConfigureRequestEvent *e);
	void handle_enter_event(XCrossingEvent *e);
	void handle_expose_event(XExposeEvent *e);
	void handle_map_request(XMapRequestEvent *e);
	void handle_property_change(XPropertyEvent *e);
	void handle_destroy_notify(XDestroyWindowEvent *e);
	
	Window getParentWindow() const { return parent; }
	
	void themeChange(Client *c);
	void handle_shape_change(XShapeEvent *e);
	void remove_client(Client *c);
};

#endif