LOGIN / SIGN UP

/ src / Frame.hh

2 Commit: 352461f2cc35034425dbe0e7dd4ec4f9cc8087e2
Author: Claes Nästén
Date: Tue Jul 13 18:24:46 +0200 2010
Subject: Do not include screen edge when placing windows with a strut on xrandr resize.
Show file history
difference betwen
and
Frame.hh
 
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
//
// Frame.hh for pekwm
// Copyright © 2003-2009 Claes Nästén <me{@}pekdon{.}net>
//
// This program is licensed under the GNU GPL.
// See the LICENSE file for more information.
//

#ifndef _FRAME_HH_
#define _FRAME_HH_

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H

#include "pekwm.hh"
#include "Action.hh"
#include "PDecor.hh"

class PScreen;
class PWinObj;
class Strut;
class Theme;
class ClassHint;
class AutoProperty;

class Client;

#include <string>
#include <list>
#include <vector>

class Frame : public PDecor
{
public:
Frame(Client *client, AutoProperty *ap);
virtual ~Frame(void);

// START - PWinObj interface.
virtual void iconify(void);
virtual void stick(void);

virtual void setWorkspace(uint workspace);

virtual ActionEvent *handleMotionEvent(XMotionEvent *ev);
virtual ActionEvent *handleEnterEvent(XCrossingEvent *ev);
virtual ActionEvent *handleLeaveEvent(XCrossingEvent *ev);

virtual ActionEvent *handleMapRequest(XMapRequestEvent *ev);
virtual ActionEvent *handleUnmapEvent(XUnmapEvent *ev);
// END - PWinObj interface.

virtual void handleShapeEvent(XAnyEvent *ev);

// START - PDecor interface.
virtual void addChild(PWinObj *child, std::list<PWinObj*>::iterator *it = 0);
virtual void removeChild(PWinObj *child, bool do_delete = true);
virtual void activateChild(PWinObj *child);

virtual void updatedChildOrder(void);
virtual void updatedActiveChild(void);

virtual void getDecorInfo(wchar_t *buf, uint size);

virtual void setShaded(StateAction sa);
virtual void setSkip(uint skip);
// END - PDecor interface.

void addChildOrdered(Client *child);

static Frame *findFrameFromWindow(Window win);
static Frame *findFrameFromID(uint id);

// START - Iterators
static uint frame_size(void) { return _frame_list.size(); }
static std::list<Frame*>::iterator frame_begin(void) {
return _frame_list.begin();
}
static std::list<Frame*>::iterator frame_end(void) {
return _frame_list.end();
}
static std::list<Frame*>::reverse_iterator frame_rbegin(void) {
return _frame_list.rbegin();
}
static std::list<Frame*>::reverse_iterator frame_rend(void) {
return _frame_list.rend();
}
// END - Iterator

inline uint getId(void) const { return _id; }
void setId(uint id);

void detachClient(Client *client);

inline const ClassHint* getClassHint(void) const { return _class_hint; }

void growDirection(uint direction);
void moveToEdge(OrientationType ori);

void updateInactiveChildInfo(void);

// state actions
void setStateMaximized(StateAction sa, bool horz, bool vert, bool fill);
void setStateFullscreen(StateAction sa);
void setStateSticky(StateAction sa);
void setStateAlwaysOnTop(StateAction sa);
void setStateAlwaysBelow(StateAction sa);
void setStateDecorBorder(StateAction sa);
void setStateDecorTitlebar(StateAction sa);
void setStateIconified(StateAction sa);
void setStateTagged(StateAction sa, bool behind);
void setStateSkip(StateAction sa, uint skip);
void setStateTitle(StateAction sa, Client *client, const std::wstring &title);
void setStateMarked(StateAction sa, Client *client);

void close(void);

void readAutoprops(uint type = APPLY_ON_RELOAD);

void doResize(XMotionEvent *ev); // redirects to doResize(bool...
void doResize(BorderPosition pos); // redirect to doResize(bool...
void doResize(bool left, bool x, bool top, bool y);
void doGroupingDrag(XMotionEvent *ev, Client *client, bool behind);

bool fixGeometry(void);

// client message handling
void handleConfigureRequest(XConfigureRequestEvent *ev, Client *client);
void handleClientMessage(XClientMessageEvent *ev, Client *client);
void handlePropertyChange(XPropertyEvent *ev, Client *client);

static Frame *getTagFrame(void) { return _tag_frame; }
static bool getTagBehind(void) { return _tag_behind; }

static void resetFrameIDs(void);

protected:
// BEGIN - PDecor interface
virtual int resizeHorzStep(int diff) const;
virtual int resizeVertStep(int diff) const;
// END - PDecor interface

private:
void handleClientStateMessage(XClientMessageEvent *ev, Client *client);
static StateAction getStateActionFromMessage(XClientMessageEvent *ev);
void handleStateAtom(StateAction sa, long atom, Client *client);
void handleCurrentClientStateAtom(StateAction sa, long atom, Client *client);
void handleConfigureRequestGeometry(XConfigureRequestEvent *ev, Client *client);
bool isRequestGeometryFullscreen(XConfigureRequestEvent *ev, Client *client);

void recalcResizeDrag(int nx, int ny, bool left, bool top);
void getMaxBounds(int &max_x,int &max_r, int &max_y, int &max_b);
void calcSizeInCells(uint &width, uint &height);
void calcGravityPosition(int gravity, int x, int y, int &g_x, int &g_y);
void downSize(Geometry &gm, bool keep_x, bool keep_y);

void handleTitleChange(Client *client);

void getState(Client *cl);
void applyState(Client *cl);

void setupAPGeometry(Client *client, AutoProperty *ap);
void applyAPGeometry(Geometry &gm, const Geometry &ap_gm, int mask);

void setActiveTitle(void);

static uint findFrameID(void);
static void returnFrameID(uint id);

static std::string getClientDecorName(Client *client);

private:
PScreen *_scr;

uint _id; // unique id of the frame

Client *_client; // to skip all the casts from PWinObj
ClassHint *_class_hint;

// frame information used when maximizing / going fullscreen
Geometry _old_gm; // FIXME: move to PDecor?
uint _non_fullscreen_decor_state; // FIXME: move to PDecor?
uint _non_fullscreen_layer;

// ID list, list of free Frame ids.
static std::list<Frame*> _frame_list; //!< List of all Frames.
static std::vector<uint> _frameid_list; //!< List of free Frame IDs.

// Tagging, static as only one Frame can be tagged
static Frame *_tag_frame; //!< Pointer to tagged frame.
static bool _tag_behind; //!< Tagging actions will set behind.

// EWMH
static const int NET_WM_STATE_REMOVE = 0; // remove/unset property
static const int NET_WM_STATE_ADD = 1; // add/set property
static const int NET_WM_STATE_TOGGLE = 2; // toggle property
};

#endif // _FRAME_HH_