File: miwm.h

package info (click to toggle)
miwm 1.1-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,296 kB
  • ctags: 910
  • sloc: cpp: 8,179; sh: 231; makefile: 148
file content (354 lines) | stat: -rw-r--r-- 9,751 bytes parent folder | download | duplicates (3)
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
//-*-c++-*-
// -------------------------------------------
// RCS data:
// $Date: 2003/07/04 16:43:44 $
// $Revision: 1.4 $
// $Source: /cvsroot/miwm/miwm/miwm/miwm.h,v $
// $Id: miwm.h,v 1.4 2003/07/04 16:43:44 sgbeal Exp $
// $RCSfile: miwm.h,v $
// -------------------------------------------
// Copyright by Ben Paul Wise.
// -------------------------------------------
// 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
// (at your option) 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., 675 Mass Ave, Cambridge, MA 02139, USA.
// -------------------------------------------

#ifndef MIWM_BASIC_H
#define MIWM_BASIC_H

// -------------------------------------------


#include        <iostream>
#include        <stdio.h>
#include        <stdlib.h>
#include        <signal.h>
#include        <errno.h>
#include        <assert.h>

#include        <unistd.h>
#include        <sys/types.h>
#include        <sys/wait.h>
#include       <sys/time.h> // try to get timeval struct and select function



#include	<X11/X.h>
#include	<X11/Xos.h>
#include	<X11/Xlib.h>
#include	<X11/Xutil.h>
#include <X11/xpm.h>

// dogdog
// experimental
#include "mlchckr.h"

#include "alpha.h"
#include "rng.h"
#include "nodes.h"

#include "miconfig.h"

#include "struct.h"
#include "client.h"



// ----------------------------------------------     

// classes
class WorkSpace;
class WindowManager;
extern WindowManager *theWM;


//  This should really have been in X.h --- if you select both ButtonPress
//  and ButtonRelease events, the server makes an automatic grab on the
//  pressed button for you. This is almost always exactly what you want.

#define ButtonMask (ButtonPressMask | ButtonReleaseMask)

// ----------------------------------------------
// these are the reference declarations of the variables,
// which should be available to all who include this header.
// ----------------------------------------------
//	miwm.c	
// extern Mode mode;
extern int start_x;
extern int start_y;
extern Display	*dpy;            // the display
extern int display_width;
extern int display_height;
extern Window	root;            // the root window
extern Window	popup;   // this is the one popup that gets resized for various things
extern GC gc;                       // root gc
extern GC gc_thin;              // like root gc, but thinner lines
extern GC menu_gc;
extern GC size_gc;
extern XFontStruct *font;
extern XFontStruct *popup_font;
extern Atom wm_state;
extern Atom wm_change_state;
extern Atom wm_protocols;
extern Atom wm_delete;
extern Atom wm_take_focus;
extern Atom wm_colormaps;

extern Bool shape;
extern int shape_event;
extern char *argv0;
extern void shell(int, int, int);
extern void sendConfigureNotify(Client *);
extern int titleHeight(void);


void menuButtonRelease(XEvent *ev);



extern Edge interacting_edge;
extern Client *getClient(Window);
extern Client *addClient(Window);
extern void adjustClientBorder(Client *, Edge, int *, int *, int *, int *);
extern void drawClientBorder(Client *, int);
extern void setactive(Client *, int, long);
extern void Client_SizeFeedback(void);
extern void size_expose(void);
extern void reshapeClientEdge(Client *, Edge);
extern void moveClient(Client*);
extern void setClientState(Client *, int);
extern void closeClient(Client *);
extern void removeClient(Client *);
extern void Client_FreeAll(void);
extern void Client_ColorMap(XEvent*);
extern int hidden(Client *);
extern int withdrawn(Client *);
extern int normal(Client *);
extern Client *current;
extern Client *clients;


extern Cursor root_cursor;
extern Cursor frame_cursor;
extern Cursor menu_cursor;
extern Cursor edgecursor(Edge edge);
extern void initCursor(void);


extern void dispatch(XEvent *);

extern int ignore_badwindow;
extern int ErrorHandler(Display *, XErrorEvent *);
extern void miAbort(const char*);


extern void getWindowName(Client *);
extern void getNormalHints(Client *);
extern void withdraw(Client *);
extern void cmapfocus(Client *);
extern void getColormaps(Client *);
extern void getTransientFor(Client *);
extern void Terminate(int);

// WM operations
void toggleRaiseOnFocus();
void toggleTopLeft();
void toggleClientPreview();
void toggleTiling(); // switch auto-tiling on/off
void togglePixmaps(); // switch use of pixmaps on/off
void restartWM(); // kill the current WM process and launch a new one
void terminateWM(); //  just kill the current WM
void stepWSup();// cycle up through work spaces
void stepWS(int step);// cycle up or down through work spaces
void contractWS();// contract all clients into WS 0, unhiding all
void retileWS();  // try to neatly re-tile the current WS
void rotateClients(); // successively raise clients of the current workspace

// WM operations on the current Client
void toggleSticky(); // toggle Sticky on the current Client
void idCurrent(); // show some ID
void terminateCurrent(); // toggle Sticky on the current Client



extern int current_item;	/* Last known selected menu item. -1 if none. */
extern menuitem * currentMenu;

const char * choose_label(Client *);
extern void getMouse(int * pointerX, int * pointerY);
extern void hide(Client *);
extern void unhidec(Client *, int);
extern void updateMenu(Client *);
extern int whichMenuItem(int, int);
extern void menuhit(XButtonEvent *);      // for the hidden window menu
extern void wsmenuhit(XButtonEvent *);  // for the workspace menu
extern void unhide(int n, int map);
extern void exposeMenu(void);
extern void motionNotifyMenu(XEvent *);
extern void showPreview(int);
extern void stopPreview(int);

extern int shapeevent(XEvent *);
extern int servershapes(void);
extern int isshaped(Window);

extern const char *font_name;
extern const char *popup_font_name;
extern int border;
char * stringCopy(char *);
extern void getResources(void);

// -------------------------------------------

class WindowManager
{
public:
WindowManager();
~WindowManager();

   menuType whichMenu;
  Mode mode;

  void mainLoop();
  void setupWS();
  void addWorkSpace(const char* wsName);

  void changeWorkSpace(WorkSpace* ws1, WorkSpace* ws2);
  // extern int offWorkSpace;
  void sendClientToWorkSpace(Client* client, WorkSpace* ws2);
  void innerSendClienttoWS(Client* c, int visibleP);

  int followClientToWS;
  void circulateWindowsUp();

  void manageClient(Client *client, bool preexisting = false );
  void autoPlaceCoords(Client *c);
  void diagonalPlaceCoords(Client *c, int *autoX, int *autoY);
  void tilePlaceCoords(Client *c, int *autoX, int *autoY);
  int okPlacement(Client *c1, int x, int y, int w, int h);

  void scanWindowTree();
  void freeAllClients();
  void rotateWSClients();
  
  void focusOn(Client*);
  void unhideClient(Client *c);
  void hideClient(Client *c);
  void spawn(char *command);

  void drawClientBorder(Client* c, int activeP);
  void drawDeadlyBox(Client*);
  void drawTitle(Client*);
  void drawClientOutline(Client* c);
  int titleHeightc(Client* c);

  void backClient(Client*);
  void raiseClient(Client*);

  // deal with menus
  void clearMenu();
  void setHiddenClientMenu();
  void setShellCmdMenu();
  void setWSMenu();
  void setClientOpsMenu();
  void setWMOpsMenu();

  void doFullPreview(Client*);
  void undoFullPreview(Client*);

  GC gc_frame;
  XColor titleColor;
  XColor boxColor;
  XColor parentWindowColor;
  XColor activeBorderColor;
  XColor inactiveBorderColor;
  XColor rootCursorColor;
  XColor frameCursorColor;

   NodeList* allClients; // data of type Client*
   NodeList* hiddenClients; // data of type Client*

  int root_event_mask;
  int menu_event_mask;
  int moving_event_mask;
  int resizing_event_mask;
  RNG *wmRNG;

  struct timeval sleepval;

  Menu* menu;

  void positionFeedbackWindow();
  // moving clients
  void startMovingClient(XEvent *xe, Client* c);
  void motionNotifyMoving();
  void buttonReleaseMoving();
  void positionExpose();

  // resizing clients
  void startResizingClient(XButtonEvent *xbe, Client* c);
  void motionNotifyResizing();
  void buttonReleaseResizing();
  void sizeExpose();

  Edge whichEdge(Client*, int rx, int ry);

  // killing clients
  void startKillingClient(XButtonEvent *xbe, Client* c);
  void motionNotifyKilling();
  void buttonReleaseKilling();

  int mouseInDeadlyBox(Client*);

  WorkSpace* workSpace;     // the one we are using, and will return to when previews end

  WorkSpace **allWorkSpaces;
  int numWorkSpaces;
  int tileP; // should we tile clients?
  int opaqueMoveSize; // anything below this % of screen size is opaque-moved


  int offWorkSpace;
  int auto_x;
  int auto_y;
  int insideClientP(Client* c);
  void warpPointerToBorder(Client* c);


  int usePixmapsP; // 1 to use them, 0 to not.
  Pixmap popupBgd;
  Pixmap activeBgd;
  Pixmap inactiveBgd;

  // keep this. it is only a problem under Solaris
//   struct timeval sleepval;
  int previewCP; // should we preview clients?
  int protectTopLeft;
  int raiseOnFocusP;

protected:
  int previewWSP; // should we preview workspaces?
  WorkSpace* previewedWorkSpace;     // the one we are just previewing

private:

};


// -------------------------------------------
#endif
// -------------------------------------------
// end of miwm.h
// -------------------------------------------