1 
2 #ifndef _CLIENT_H_
3 #define _CLIENT_H_
4 
5 #include "General.h"
6 #include "Manager.h"
7 #include "Border.h"
8 
9 
10 class Client {
11 public:
12     Client(WindowManager *const, Window);
13     void release();
14 
15     /* for call from WindowManager: */
16 
17     void activate();		/* active() */
18     void deactivate();		/* setactive(0) */
19     void gravitate(Boolean invert);
20     void installColormap();
21     void unreparent();
22     void withdraw(Boolean = True);
23     void hide();
24     void unhide(Boolean map);
25     void rename();
26     void kill();
27     void mapRaised();		// without activating
28     void lower();
29 
30     void move(XButtonEvent *);		// event for grab timestamp & coords
31     void resize(XButtonEvent *, Boolean, Boolean);
32     void moveOrResize(XButtonEvent *);
33     void ensureVisible();	// make sure x, y are on-screen
34 
35     void manage(Boolean mapped);
hasWindow(Window w)36     Boolean hasWindow(Window w) {
37 	return ((m_window == w) || m_border->hasWindow(w));
38     }
39 
revertTo()40     Client *revertTo() { return m_revert; }
setRevertTo(Client * c)41     void setRevertTo(Client *c) { m_revert = c; }
42 
isHidden()43     Boolean isHidden()     { return (m_state == IconicState);    }
isWithdrawn()44     Boolean isWithdrawn()  { return (m_state == WithdrawnState); }
isNormal()45     Boolean isNormal()     { return (m_state == NormalState);    }
isTransient()46     Boolean isTransient()  { return (m_transient != None);       }
transientFor()47     Window  transientFor() { return m_transient; }
isFixedSize()48     Boolean isFixedSize()  { return m_fixedSize; }
49 
label()50     const char *label()    { return m_label;    }
name()51     const char *name()     { return m_name;     }
iconName()52     const char *iconName() { return m_iconName; }
53 
54     void sendMessage(Atom, long);
55     void sendConfigureNotify();
56 
57     void activateAndWarp();
58     void focusIfAppropriate(Boolean);
59     void selectOnMotion(Window, Boolean);
60 
61     /* for call from within: */
62 
fatal(char * m)63     void fatal(char *m)    { m_windowManager->fatal(m);              }
display()64     Display *display()     { return m_windowManager->display();      }
parent()65     Window parent()        { return m_border->parent();              }
root()66     Window root()          { return m_windowManager->root();         }
activeClient()67     Client *activeClient() { return m_windowManager->activeClient(); }
isActive()68     Boolean isActive()     { return (activeClient() == this);        }
69 
windowManager()70     WindowManager *windowManager() { return m_windowManager; }
71 
72     // for call from equivalent wm functions in Events.C:
73 
74     void eventButton(XButtonEvent *);
75     void eventMapRequest(XMapRequestEvent *);
76     void eventConfigureRequest(XConfigureRequestEvent *);
77     void eventUnmap(XUnmapEvent *);
78     void eventColormap(XColormapEvent *);
79     void eventProperty(XPropertyEvent *);
80     void eventEnter(XCrossingEvent *);
81     void eventFocusIn(XFocusInEvent *);
82     void eventExposure(XExposeEvent *);
83 
84 protected:      // cravenly submitting to gcc's warnings
85     ~Client();
86 
87 private:
88 
89     Window m_window;
90     Window m_transient;
91     Border *m_border;
92 
93     Client *m_revert;
94 
95     int m_x;
96     int m_y;
97     int m_w;
98     int m_h;
99     int m_bw;
100 
101     XSizeHints m_sizeHints;
102     Boolean m_fixedSize;
103     int m_minWidth;
104     int m_minHeight;
105     void fixResizeDimensions(int &, int &, int &, int &);
106     Boolean coordsInHole(int, int);
107 
108     int m_state;
109     int m_protocol;
110     Boolean m_managed;
111     Boolean m_reparenting;
112     Boolean m_stubborn;		// keeps popping itself to the front
113     Time m_lastPopTime;
114 
115     char *m_name;
116     char *m_iconName;
117     const char *m_label;	// alias: one of (instance,class,name,iconName)
118     static const char *const m_defaultLabel;
119 
120     Colormap m_colormap;
121     int m_colormapWinCount;
122     Window *m_colormapWindows;
123     Colormap *m_windowColormaps;
124 
125     WindowManager *const m_windowManager;
126 
127     char *getProperty(Atom);
128     int getAtomProperty(Atom, Atom);
129     int getIntegerProperty(Atom);
130 
131     // accessors
132     Boolean getState(int *);
133     void setState(int);
134 
135     // internal instantiation requests
136     Boolean setLabel(void);	// returns True if changed
137     void getColormaps(void);
138     void getProtocols(void);
139     void getTransient(void);
140 
141     void decorate(Boolean active);
142 };
143 
144 #define Pdelete    1
145 #define PtakeFocus 2
146 
147 #endif
148 
149