60
54
StructureNotifyMask |
63
_window = XCreateWindow (d, XDefaultRootWindow (d), _x, _y, _width, _height, 0,
64
CopyFromParent, InputOutput, CopyFromParent,
65
CWOverrideRedirect | CWEventMask, &attrib);
67
_native_windows.push_front (_window);
57
window_ = XCreateWindow(display_, XDefaultRootWindow(display_),
58
geometry_.x, geometry_.y,
59
geometry_.width, geometry_.height, 0,
60
CopyFromParent, InputOutput, CopyFromParent,
61
CWOverrideRedirect | CWEventMask, &attrib);
63
native_windows_.push_front(window_);
71
data[i++] = XInternAtom (d, "_NET_WM_STATE_STICKY", 0);
72
data[i++] = XInternAtom (d, "_NET_WM_STATE_SKIP_TASKBAR", 0);
73
data[i++] = XInternAtom (d, "_NET_WM_STATE_SKIP_PAGER", 0);
75
XChangeProperty (d, _window, XInternAtom (d, "_NET_WM_STATE", 0),
76
XA_ATOM, 32, PropModeReplace,
77
(unsigned char *) data, i);
67
data[i++] = XInternAtom(display_, "_NET_WM_STATE_STICKY", 0);
68
data[i++] = XInternAtom(display_, "_NET_WM_STATE_SKIP_TASKBAR", 0);
69
data[i++] = XInternAtom(display_, "_NET_WM_STATE_SKIP_PAGER", 0);
71
XChangeProperty(display_, window_,
72
XInternAtom(display_, "_NET_WM_STATE", 0),
73
XA_ATOM, 32, PropModeReplace,
74
(unsigned char *) data, i);
80
type[0] = XInternAtom (d, "_NET_WM_WINDOW_TYPE_DOCK", 0);
81
XChangeProperty (d, _window, XInternAtom (d, "_NET_WM_WINDOW_TYPE", 0),
82
XA_ATOM, 32, PropModeReplace,
83
(unsigned char *) type, 1);
85
XStoreName (d, _window, title);
77
type[0] = XInternAtom(display_, "_NET_WM_WINDOW_TYPE_DOCK", 0);
78
XChangeProperty(display_, window_,
79
XInternAtom(display_, "_NET_WM_WINDOW_TYPE", 0),
80
XA_ATOM, 32, PropModeReplace,
81
(unsigned char *) type, 1);
83
XStoreName(display_, window_, title);
95
92
XInputWindow::~XInputWindow()
97
_native_windows.remove (_window);
98
XDestroyWindow (_display, _window);
94
native_windows_.remove(window_);
95
XDestroyWindow(display_, window_);
102
99
std::list<Window> XInputWindow::NativeHandleList()
104
return _native_windows;
101
return native_windows_;
107
104
void XInputWindow::SetStruts()
109
106
int screenHeight, screenWidth;
110
107
long int data[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
112
screenHeight = XDisplayHeight (_display, 0);
113
screenWidth = XDisplayWidth (_display, 0);
115
if (_width > _height)
109
screenHeight = XDisplayHeight(display_, 0);
110
screenWidth = XDisplayWidth(display_, 0);
112
if (geometry_.width > geometry_.height)
117
if (_y < screenHeight / 2)
114
if (geometry_.y < screenHeight / 2)
120
data[2] = _y + _height;
122
data[9] = _x + _width - 1;
117
data[2] = geometry_.y + geometry_.height;
118
data[8] = geometry_.x;
119
data[9] = geometry_.x + geometry_.width - 1;
127
data[3] = (screenHeight - 1) - _y;
129
data[11] = _x + _width - 1;
124
data[3] = (screenHeight - 1) - geometry_.y;
125
data[10] = geometry_.x;
126
data[11] = geometry_.x + geometry_.width - 1;
134
if (_x < screenWidth / 2)
131
if (geometry_.x < screenWidth / 2)
137
data[0] = _x + _width;
139
data[5] = _y + _height - 1;
134
data[0] = geometry_.x + geometry_.width;
135
data[4] = geometry_.y;
136
data[5] = geometry_.y + geometry_.height - 1;
144
data[1] = (screenWidth - 1) - _y;
146
data[7] = _y + _height - 1;
141
data[1] = (screenWidth - 1) - geometry_.y;
142
data[6] = geometry_.y;
143
data[7] = geometry_.y + geometry_.height - 1;
150
XChangeProperty (_display, _window, XInternAtom (_display, "_NET_WM_STRUT_PARTIAL", 0),
151
XA_CARDINAL, 32, PropModeReplace,
152
(unsigned char *) data, 12);
147
XChangeProperty(display_, window_,
148
XInternAtom(display_, "_NET_WM_STRUT_PARTIAL", 0),
149
XA_CARDINAL, 32, PropModeReplace,
150
(unsigned char *) data, 12);
155
153
void XInputWindow::UnsetStruts()
157
XDeleteProperty (_display, _window, XInternAtom (_display, "_NET_WM_STRUT_PARTIAL", 0));
155
XDeleteProperty(display_, window_,
156
XInternAtom(display_, "_NET_WM_STRUT_PARTIAL", 0));
160
159
void XInputWindow::EnableStruts(bool enable)
162
if (_strutsEnabled == enable)
161
if (strutsEnabled_ == enable)
165
_strutsEnabled = enable;
164
strutsEnabled_ = enable;
188
187
PropertyChangeMask |
189
188
StructureNotifyMask |
190
189
FocusChangeMask);
194
void XInputWindow::EnableTakeFocus ()
192
void XInputWindow::EnableTakeFocus()
196
Atom wmTakeFocus = XInternAtom (_display, "WM_TAKE_FOCUS", False);
197
XWMHints* wmHints = NULL;
194
Atom wmTakeFocus = XInternAtom (display_, "WM_TAKE_FOCUS", False);
195
XWMHints* wmHints = NULL;
199
197
wmHints = (XWMHints*) calloc (1, sizeof (XWMHints));
200
198
wmHints->flags |= InputHint;
201
199
wmHints->input = False;
202
XSetWMHints (_display, _window, wmHints);
204
XSetWMProtocols (_display, _window, &wmTakeFocus, 1);
200
XSetWMHints(display_, window_, wmHints);
202
XSetWMProtocols(display_, window_, &wmTakeFocus, 1);
207
void XInputWindow::EnableDnd ()
205
void XInputWindow::EnableDnd()
210
XChangeProperty (_display, _window, XInternAtom (_display, "XdndAware", false),
211
XA_ATOM, 32, PropModeReplace, (unsigned char *) &version, 1);
208
XChangeProperty(display_, window_,
209
XInternAtom(display_, "XdndAware", false),
210
XA_ATOM, 32, PropModeReplace,
211
(unsigned char *) &version, 1);
214
void XInputWindow::DisableDnd ()
214
void XInputWindow::DisableDnd()
216
XDeleteProperty (_display, _window, XInternAtom (_display, "XdndAware", false));
216
XDeleteProperty(display_, window_,
217
XInternAtom(display_, "XdndAware", false));
219
220
//! Set the position and size of the window
220
void XInputWindow::SetGeometry(const Rect& geo)
221
void XInputWindow::SetGeometry(Rect const& geo)
222
SetGeometry(geo.x, geo.y, geo.width, geo.height);
226
XMoveResizeWindow(display_, window_,
227
geo.x, geo.y, geo.width, geo.height);
225
234
//! Set the position and size of the window
226
235
void XInputWindow::SetGeometry(int x, int y, int width, int height)
234
XMoveResizeWindow (_display, _window, x, y, width, height);
237
SetGeometry(Rect(x, y, width, height));
241
240
//! Get the window geometry.
242
Rect XInputWindow::GetGeometry() const
241
Rect const& XInputWindow::GetGeometry() const
244
Rect r(_x, _y, _width, _height);
249
246
Window XInputWindow::GetWindow ()
254
251
void XInputWindow::SetInputFocus ()
256
XSetInputFocus (_display, _window, RevertToParent, CurrentTime);
253
XSetInputFocus(display_, window_, RevertToParent, CurrentTime);
259
256
void XInputWindow::Hide ()
261
XMoveResizeWindow (_display, _window, -100 - _width, -100 - _height, _width, _height);
258
XMoveResizeWindow(display_, window_,
259
-100 - geometry_.width,
260
-100 - geometry_.height,
265
266
void XInputWindow::Show ()
271
XMapRaised (_display, _window);
272
XMapRaised (display_, window_);
274
XMoveResizeWindow (_display, _window, _x, _y, _width, _height);
275
XMoveResizeWindow(display_, window_,
276
geometry_.x, geometry_.y,
277
geometry_.width, geometry_.height);