File: windowmanager.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 (217 lines) | stat: -rw-r--r-- 5,822 bytes parent folder | download | duplicates (5)
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
/*
 * 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 _WM_HH_
#define _WM_HH_

#include "sapphire.hh"

class WindowManager 
{

private: /* variables */

	LinkedList<BaseMenu> *menulist;
	LinkedList<BaseMenu> *extramenulist;
	LinkedList<Client>   *ClientList;

	Client		*head_client;	

	Toolbar  	*t;
	IconMenu 	*im;
	RootMenu 	*rm;	
	Theme 	 	*theme;
	BImageControl 	*image_control;
	BaseMenu 	*menu;

	Atom		xa_wm_state;
	Atom		xa_wm_change_state;
	Atom		xa_wm_protos;
        Atom		xa_wm_delete;
	Atom		xa_wm_cmapwins;
	Atom		xa_wm_take_focus;
	Atom		xa_wm_motif_hints;

	Window		root;
	
	Display		*dpy;
	
	Visual 		*visual;
	
	Pixmap		font_pix;
		
	XFontStruct	*xfont;	

	XGCValues 	gv;
	
	XColor		xforeground_color;
	XColor		xbackground_color; 
	XColor		xborder_color;

	GC		invert_gc;
	GC		string_gc;
	GC		border_gc;

	Cursor		move_curs;
	Cursor		resize_curs;
	Cursor		left_arrow;
	
	char 		*display;
	char 		*font;
	char 		*menufont;
	char 		*foreground_color;
	char 		*background_color;
	char 		*border_color;

	int		depth;
	int		xres;
	int 		yres;
	int		shape_event;
	int 		colors_per_channel;
	int 		toolbar_position;
	int 		toolbar_visible;
	int		screen;
	int		iheight;
	int 		font_position;

	bool 		image_dither;
	bool		shape;
	bool 		menu_event;

	// Configuration file stuff
        char		*clock_format;
	char		*configurationPath;
	char		*windowmanager_conf;

	static KeySym 	AltKeys[];
public: 

	// member functions below
	
	WindowManager(int argc, char **argv);
	~WindowManager();

	XColor 	getBorderColor()     	const { return xborder_color; }
	XColor 	getForegroundColor() 	const { return xforeground_color; }
	XColor 	getBackgroundColor() 	const { return xbackground_color; }
	
	GC 	getInvertGC() 		const { return invert_gc; }
	GC 	getStringGC() 		const { return string_gc; }
	GC 	getBorderGC() 		const { return border_gc; }
	
	int 	getIHeight() 		const { return iheight; }
	char*  	getMenuFont() 	    	const { return menufont; }
	
	Cursor 	getMoveCursor() 	const { return move_curs; }
	Cursor 	getResizeCursor() 	const { return resize_curs; }
	Cursor 	getLeftArrowCursor() 	const { return left_arrow; }
	
	XFontStruct* getXFont() 	const { return xfont; }

	bool getShape() 		const { return shape; }
	
	void setShape(bool s) { shape=s; }
	
	int getFontPosition() const { return font_position; }

	Theme* getTheme() const { return theme; }

	void changeTheme(char* themeFile);

	// Client List member functions
	void insertClient(Client *c) { ClientList->insert(c); }
	void removeClient(Client *c) { ClientList->remove(c); }

	unsigned int getClientCount() const { return ClientList->count(); }
	LinkedList<Client>* getClientListObject() const { return ClientList; }

	// Server Grab member functions	
	void Grab() { XGrabServer(dpy); }
	void Ungrab() { XUngrabServer(dpy); }
	void SyncUngrab() { XSync(dpy, False); XUngrabServer(dpy); }

	void addToMenuList(BaseMenu *m) { menulist->insert(m); }
	void addToExtraMenuList(BaseMenu *m) { extramenulist->insert(m); }
	void reconfigureMenu();
	void removeFromMenuList(BaseMenu *m) { menulist->remove(m); }
	LinkedList<BaseMenu>* getMenuList() { return menulist; }		
	BaseMenu* findInMenuList(Window *w);
		
  	Atom getWMChangeStateAtom() const { return xa_wm_change_state; }
  	Atom getWMStateAtom() const       { return xa_wm_state; }
  	Atom getWMDeleteAtom() const      { return xa_wm_delete; }
 	Atom getWMProtocolsAtom() const   { return xa_wm_protos; }
  	Atom getWMFocusAtom() const       { return xa_wm_take_focus; }
  	Atom getWMColormapAtom() const    { return xa_wm_cmapwins; }
	Atom getMotifWMHintsAtom() const      { return xa_wm_motif_hints; }

	int 	getDepth() const { return depth; }
	int	getScreen() const { return screen; }
	Visual* getVisual() const { return visual; }
	int	getColorsPerChannel() const { return colors_per_channel; }
	bool    getImageDither() const { return image_dither; }
	BImageControl *getImageControl() const { return image_control; }

	Display* getDisplay() const { return dpy; }
	Window  getRootWindow() const { return root; }

	RootMenu* getRootMenu() const { return rm; }
	IconMenu* getIconMenu() const { return im; }
	Toolbar*  getToolbar() const { return t; }

	void grabPointer(Window w, unsigned int mask, Cursor curs);
	void ungrabPointer();

	void quit_nicely();
	void restart();
	void start_another_windowmanager(char * wmCommand);
	
	int getXRes() const { return xres; }
	int getYRes() const { return yres; }

	char* getClockFormat() const { return clock_format; }
	//void handleKeyPress(XEvent *ev);

	// desktop is from 0 to 15, inclusive (not a bit mask like in changeDesktop)
	void goToDesktop(int desktop);
	void goToNextDesktop();
	void goToPreviousDesktop();

	void setMenu(BaseMenu* bm) { menu=bm; }
	void setMenuEvent(bool me) { menu_event=me; }

private: /* member functions */
	
	int QueryShapeExtentions();
	
	void scan_windows();
	void do_event_loop();	
	void createFontPixmap();
	void createMenuFontPixmap();
	void saveCurrentTheme();
	void getCurrentTheme();
};

extern WindowManager *wm;

#endif