aboutsummaryrefslogtreecommitdiff
path: root/src/Gnome.cc
diff options
context:
space:
mode:
authormathias <mathias>2006-10-30 19:31:15 (GMT)
committermathias <mathias>2006-10-30 19:31:15 (GMT)
commite5e76e7761f52ba7c0deca75bcecae4fbd3e2ff5 (patch)
treec84838a84802805e9b1463045e86200b7cef917f /src/Gnome.cc
parent426c12c25c2ef095a882619ad7424684b88465b8 (diff)
downloadfluxbox_pavel-e5e76e7761f52ba7c0deca75bcecae4fbd3e2ff5.zip
fluxbox_pavel-e5e76e7761f52ba7c0deca75bcecae4fbd3e2ff5.tar.bz2
Cosmetic patch from Slava Semushin
Diffstat (limited to 'src/Gnome.cc')
-rw-r--r--src/Gnome.cc116
1 files changed, 60 insertions, 56 deletions
diff --git a/src/Gnome.cc b/src/Gnome.cc
index 81803dd..33bc88d 100644
--- a/src/Gnome.cc
+++ b/src/Gnome.cc
@@ -31,10 +31,17 @@
31#include "Layer.hh" 31#include "Layer.hh"
32#include "FbTk/I18n.hh" 32#include "FbTk/I18n.hh"
33 33
34
35#include <iostream> 34#include <iostream>
36#include <new> 35#include <new>
37using namespace std; 36
37using std::cerr;
38using std::endl;
39using std::list;
40
41#ifdef DEBUG
42using std::hex;
43using std::dec;
44#endif // DEBUG
38 45
39Gnome::Gnome() { 46Gnome::Gnome() {
40 createAtoms(); 47 createAtoms();
@@ -45,7 +52,7 @@ Gnome::~Gnome() {
45 // destroy gnome windows 52 // destroy gnome windows
46 while (!m_gnomewindows.empty()) { 53 while (!m_gnomewindows.empty()) {
47 XDestroyWindow(FbTk::App::instance()->display(), m_gnomewindows.back()); 54 XDestroyWindow(FbTk::App::instance()->display(), m_gnomewindows.back());
48 m_gnomewindows.pop_back(); 55 m_gnomewindows.pop_back();
49 } 56 }
50} 57}
51 58
@@ -56,12 +63,12 @@ void Gnome::initForScreen(BScreen &screen) {
56 Window gnome_win = XCreateSimpleWindow(disp, 63 Window gnome_win = XCreateSimpleWindow(disp,
57 screen.rootWindow().window(), 0, 0, 5, 5, 0, 0, 0); 64 screen.rootWindow().window(), 0, 0, 5, 5, 0, 0, 0);
58 // supported WM check 65 // supported WM check
59 screen.rootWindow().changeProperty(m_gnome_wm_supporting_wm_check, 66 screen.rootWindow().changeProperty(m_gnome_wm_supporting_wm_check,
60 XA_WINDOW, 32, 67 XA_WINDOW, 32,
61 PropModeReplace, (unsigned char *) &gnome_win, 1); 68 PropModeReplace, (unsigned char *) &gnome_win, 1);
62 69
63 XChangeProperty(disp, gnome_win, 70 XChangeProperty(disp, gnome_win,
64 m_gnome_wm_supporting_wm_check, 71 m_gnome_wm_supporting_wm_check,
65 XA_WINDOW, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); 72 XA_WINDOW, 32, PropModeReplace, (unsigned char *) &gnome_win, 1);
66 73
67 // supported gnome atoms 74 // supported gnome atoms
@@ -74,9 +81,9 @@ void Gnome::initForScreen(BScreen &screen) {
74 m_gnome_wm_win_layer 81 m_gnome_wm_win_layer
75 }; 82 };
76 //list atoms that we support 83 //list atoms that we support
77 screen.rootWindow().changeProperty(m_gnome_wm_prot, 84 screen.rootWindow().changeProperty(m_gnome_wm_prot,
78 XA_ATOM, 32, PropModeReplace, 85 XA_ATOM, 32, PropModeReplace,
79 (unsigned char *)gnomeatomlist, 86 (unsigned char *)gnomeatomlist,
80 (sizeof gnomeatomlist)/sizeof gnomeatomlist[0]); 87 (sizeof gnomeatomlist)/sizeof gnomeatomlist[0]);
81 88
82 m_gnomewindows.push_back(gnome_win); 89 m_gnomewindows.push_back(gnome_win);
@@ -85,7 +92,7 @@ void Gnome::initForScreen(BScreen &screen) {
85 updateWorkspaceNames(screen); 92 updateWorkspaceNames(screen);
86 updateWorkspaceCount(screen); 93 updateWorkspaceCount(screen);
87 updateCurrentWorkspace(screen); 94 updateCurrentWorkspace(screen);
88 95
89} 96}
90 97
91void Gnome::setupFrame(FluxboxWindow &win) { 98void Gnome::setupFrame(FluxboxWindow &win) {
@@ -95,8 +102,8 @@ void Gnome::setupFrame(FluxboxWindow &win) {
95 unsigned long nitems, bytes_after; 102 unsigned long nitems, bytes_after;
96 long flags, *data = 0; 103 long flags, *data = 0;
97 104
98 if (win.winClient().property(m_gnome_wm_win_state, 0, 1, False, XA_CARDINAL, 105 if (win.winClient().property(m_gnome_wm_win_state, 0, 1, False, XA_CARDINAL,
99 &ret_type, &fmt, &nitems, &bytes_after, 106 &ret_type, &fmt, &nitems, &bytes_after,
100 (unsigned char **) &data) && data) { 107 (unsigned char **) &data) && data) {
101 flags = *data; 108 flags = *data;
102 setState(&win, flags); 109 setState(&win, flags);
@@ -106,8 +113,8 @@ void Gnome::setupFrame(FluxboxWindow &win) {
106 } 113 }
107 114
108 // load gnome layer atom 115 // load gnome layer atom
109 if (win.winClient().property(m_gnome_wm_win_layer, 0, 1, False, XA_CARDINAL, 116 if (win.winClient().property(m_gnome_wm_win_layer, 0, 1, False, XA_CARDINAL,
110 &ret_type, &fmt, &nitems, &bytes_after, 117 &ret_type, &fmt, &nitems, &bytes_after,
111 (unsigned char **) &data) && data) { 118 (unsigned char **) &data) && data) {
112 flags = *data; 119 flags = *data;
113 setLayer(&win, flags); 120 setLayer(&win, flags);
@@ -117,11 +124,11 @@ void Gnome::setupFrame(FluxboxWindow &win) {
117 } 124 }
118 125
119 // load gnome workspace atom 126 // load gnome workspace atom
120 if (win.winClient().property(m_gnome_wm_win_workspace, 0, 1, False, XA_CARDINAL, 127 if (win.winClient().property(m_gnome_wm_win_workspace, 0, 1, False, XA_CARDINAL,
121 &ret_type, &fmt, &nitems, &bytes_after, 128 &ret_type, &fmt, &nitems, &bytes_after,
122 (unsigned char **) &data) && data) { 129 (unsigned char **) &data) && data) {
123 unsigned int workspace_num = *data; 130 unsigned int workspace_num = *data;
124 if (win.workspaceNumber() != workspace_num) 131 if (win.workspaceNumber() != workspace_num)
125 win.setWorkspace(workspace_num); 132 win.setWorkspace(workspace_num);
126 XFree (data); 133 XFree (data);
127 } else { 134 } else {
@@ -131,7 +138,7 @@ void Gnome::setupFrame(FluxboxWindow &win) {
131} 138}
132 139
133 140
134bool Gnome::propertyNotify(WinClient &winclient, Atom the_property) { 141bool Gnome::propertyNotify(WinClient &winclient, Atom the_property) {
135 if (the_property == m_gnome_wm_win_state) { 142 if (the_property == m_gnome_wm_win_state) {
136#ifdef DEBUG 143#ifdef DEBUG
137 cerr<<__FILE__<<"("<<__FUNCTION__<<"): _WIN_STATE"<<endl; 144 cerr<<__FILE__<<"("<<__FUNCTION__<<"): _WIN_STATE"<<endl;
@@ -151,19 +158,19 @@ void Gnome::updateClientList(BScreen &screen) {
151 size_t num=0; 158 size_t num=0;
152 159
153 // count window clients in each workspace 160 // count window clients in each workspace
154 BScreen::Workspaces::const_iterator workspace_it = 161 BScreen::Workspaces::const_iterator workspace_it =
155 screen.getWorkspacesList().begin(); 162 screen.getWorkspacesList().begin();
156 BScreen::Workspaces::const_iterator workspace_it_end = 163 BScreen::Workspaces::const_iterator workspace_it_end =
157 screen.getWorkspacesList().end(); 164 screen.getWorkspacesList().end();
158 for (; workspace_it != workspace_it_end; ++workspace_it) { 165 for (; workspace_it != workspace_it_end; ++workspace_it) {
159 Workspace::Windows::iterator win_it = 166 Workspace::Windows::iterator win_it =
160 (*workspace_it)->windowList().begin(); 167 (*workspace_it)->windowList().begin();
161 Workspace::Windows::iterator win_it_end = 168 Workspace::Windows::iterator win_it_end =
162 (*workspace_it)->windowList().end(); 169 (*workspace_it)->windowList().end();
163 for (; win_it != win_it_end; ++win_it) 170 for (; win_it != win_it_end; ++win_it)
164 num += (*win_it)->numClients(); 171 num += (*win_it)->numClients();
165 } 172 }
166 173
167 Window *wl = new Window[num]; 174 Window *wl = new Window[num];
168 if (wl == 0) { 175 if (wl == 0) {
169 _FB_USES_NLS; 176 _FB_USES_NLS;
@@ -175,19 +182,19 @@ void Gnome::updateClientList(BScreen &screen) {
175 workspace_it = screen.getWorkspacesList().begin(); 182 workspace_it = screen.getWorkspacesList().begin();
176 int win=0; 183 int win=0;
177 for (; workspace_it != workspace_it_end; ++workspace_it) { 184 for (; workspace_it != workspace_it_end; ++workspace_it) {
178 185
179 // Fill in array of window ID's 186 // Fill in array of window ID's
180 Workspace::Windows::const_iterator it = 187 Workspace::Windows::const_iterator it =
181 (*workspace_it)->windowList().begin(); 188 (*workspace_it)->windowList().begin();
182 Workspace::Windows::const_iterator it_end = 189 Workspace::Windows::const_iterator it_end =
183 (*workspace_it)->windowList().end(); 190 (*workspace_it)->windowList().end();
184 for (; it != it_end; ++it) { 191 for (; it != it_end; ++it) {
185 // TODO! 192 // TODO!
186 //check if the window don't want to be visible in the list 193 //check if the window don't want to be visible in the list
187 //if (! ( (*it)->getGnomeHints() & WIN_STATE_HIDDEN) ) { 194 //if (! ( (*it)->getGnomeHints() & WIN_STATE_HIDDEN) ) {
188 std::list<WinClient *>::iterator client_it = 195 list<WinClient *>::iterator client_it =
189 (*it)->clientList().begin(); 196 (*it)->clientList().begin();
190 std::list<WinClient *>::iterator client_it_end = 197 list<WinClient *>::iterator client_it_end =
191 (*it)->clientList().end(); 198 (*it)->clientList().end();
192 for (; client_it != client_it_end; ++client_it) 199 for (; client_it != client_it_end; ++client_it)
193 wl[win++] = (*client_it)->window(); 200 wl[win++] = (*client_it)->window();
@@ -196,10 +203,10 @@ void Gnome::updateClientList(BScreen &screen) {
196 } 203 }
197 //number of windows to show in client list 204 //number of windows to show in client list
198 num = win; 205 num = win;
199 screen.rootWindow().changeProperty(m_gnome_wm_win_client_list, 206 screen.rootWindow().changeProperty(m_gnome_wm_win_client_list,
200 XA_WINDOW, 32, 207 XA_WINDOW, 32,
201 PropModeReplace, (unsigned char *)wl, num); 208 PropModeReplace, (unsigned char *)wl, num);
202 209
203 delete[] wl; 210 delete[] wl;
204} 211}
205 212
@@ -208,14 +215,14 @@ void Gnome::updateWorkspaceNames(BScreen &screen) {
208 size_t number_of_desks = screen.getWorkspaceNames().size(); 215 size_t number_of_desks = screen.getWorkspaceNames().size();
209 const BScreen::WorkspaceNames &workspace_names = screen.getWorkspaceNames(); 216 const BScreen::WorkspaceNames &workspace_names = screen.getWorkspaceNames();
210 // convert our desktop names to a char * so we can send it 217 // convert our desktop names to a char * so we can send it
211 char *names[number_of_desks]; 218 char *names[number_of_desks];
212 219
213 for (size_t i = 0; i < number_of_desks; i++) { 220 for (size_t i = 0; i < number_of_desks; i++) {
214 names[i] = new char[workspace_names[i].size() + 1]; 221 names[i] = new char[workspace_names[i].size() + 1];
215 strcpy(names[i], workspace_names[i].c_str()); 222 strcpy(names[i], workspace_names[i].c_str());
216 } 223 }
217 224
218 XTextProperty text; 225 XTextProperty text;
219 if (XStringListToTextProperty(names, number_of_desks, &text)) { 226 if (XStringListToTextProperty(names, number_of_desks, &text)) {
220 XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(), 227 XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(),
221 &text, m_gnome_wm_win_workspace_names); 228 &text, m_gnome_wm_win_workspace_names);
@@ -254,7 +261,7 @@ void Gnome::updateWorkspace(FluxboxWindow &win) {
254 FluxboxWindow::ClientList::iterator client_it = win.clientList().begin(); 261 FluxboxWindow::ClientList::iterator client_it = win.clientList().begin();
255 FluxboxWindow::ClientList::iterator client_it_end = win.clientList().end(); 262 FluxboxWindow::ClientList::iterator client_it_end = win.clientList().end();
256 for (; client_it != client_it_end; ++client_it) 263 for (; client_it != client_it_end; ++client_it)
257 (*client_it)->changeProperty(m_gnome_wm_win_workspace, 264 (*client_it)->changeProperty(m_gnome_wm_win_workspace,
258 XA_CARDINAL, 32, PropModeReplace, 265 XA_CARDINAL, 32, PropModeReplace,
259 (unsigned char *)&val, 1); 266 (unsigned char *)&val, 1);
260} 267}
@@ -268,12 +275,12 @@ void Gnome::updateState(FluxboxWindow &win) {
268 state |= WIN_STATE_MINIMIZED; 275 state |= WIN_STATE_MINIMIZED;
269 if (win.isShaded()) 276 if (win.isShaded())
270 state |= WIN_STATE_SHADED; 277 state |= WIN_STATE_SHADED;
271 278
272 FluxboxWindow::ClientList::iterator client_it = win.clientList().begin(); 279 FluxboxWindow::ClientList::iterator client_it = win.clientList().begin();
273 FluxboxWindow::ClientList::iterator client_it_end = win.clientList().end(); 280 FluxboxWindow::ClientList::iterator client_it_end = win.clientList().end();
274 for (; client_it != client_it_end; ++client_it) { 281 for (; client_it != client_it_end; ++client_it) {
275 (*client_it)->changeProperty(m_gnome_wm_win_state, 282 (*client_it)->changeProperty(m_gnome_wm_win_state,
276 XA_CARDINAL, 32, 283 XA_CARDINAL, 32,
277 PropModeReplace, (unsigned char *)&state, 1); 284 PropModeReplace, (unsigned char *)&state, 1);
278 } 285 }
279} 286}
@@ -287,14 +294,14 @@ void Gnome::updateLayer(FluxboxWindow &win) {
287 FluxboxWindow::ClientList::iterator client_it_end = win.clientList().end(); 294 FluxboxWindow::ClientList::iterator client_it_end = win.clientList().end();
288 for (; client_it != client_it_end; ++client_it) 295 for (; client_it != client_it_end; ++client_it)
289 (*client_it)->changeProperty(m_gnome_wm_win_layer, 296 (*client_it)->changeProperty(m_gnome_wm_win_layer,
290 XA_CARDINAL, 32, PropModeReplace, 297 XA_CARDINAL, 32, PropModeReplace,
291 (unsigned char *)&layernum, 1); 298 (unsigned char *)&layernum, 1);
292 299
293} 300}
294 301
295void Gnome::updateHints(FluxboxWindow &win) { 302void Gnome::updateHints(FluxboxWindow &win) {
296 //TODO 303 //TODO
297 304
298} 305}
299 306
300bool Gnome::checkClientMessage(const XClientMessageEvent &ce, BScreen * screen, WinClient * const winclient) { 307bool Gnome::checkClientMessage(const XClientMessageEvent &ce, BScreen * screen, WinClient * const winclient) {
@@ -306,29 +313,26 @@ bool Gnome::checkClientMessage(const XClientMessageEvent &ce, BScreen * screen,
306 ce.data.l[0] >= 0 && 313 ce.data.l[0] >= 0 &&
307 ce.data.l[0] < (signed)winclient->screen().numberOfWorkspaces()) { 314 ce.data.l[0] < (signed)winclient->screen().numberOfWorkspaces()) {
308 winclient->screen().changeWorkspaceID(ce.data.l[0]); 315 winclient->screen().changeWorkspaceID(ce.data.l[0]);
309 316
310 } else if (screen!=0 && //the message sent to root window? 317 } else if (screen!=0 && //the message sent to root window?
311 ce.data.l[0] >= 0 && 318 ce.data.l[0] >= 0 &&
312 ce.data.l[0] < (signed)screen->numberOfWorkspaces()) 319 ce.data.l[0] < (signed)screen->numberOfWorkspaces())
313 screen->changeWorkspaceID(ce.data.l[0]); 320 screen->changeWorkspaceID(ce.data.l[0]);
314 return true; 321 return true;
315 } else if (winclient == 0) 322 } else if (winclient == 0)
316 return false; 323 return false;
317 324
318 325
319 if (ce.message_type == m_gnome_wm_win_state) { 326 if (ce.message_type == m_gnome_wm_win_state) {
320#ifdef DEBUG 327#ifdef DEBUG
321 cerr<<__FILE__<<"("<<__LINE__<<"): _WIN_STATE"<<endl; 328 cerr<<__FILE__<<"("<<__LINE__<<"): _WIN_STATE"<<endl;
322#endif // DEBUG
323
324#ifdef DEBUG
325 cerr<<__FILE__<<"("<<__LINE__<<"): Mask of members to change:"<< 329 cerr<<__FILE__<<"("<<__LINE__<<"): Mask of members to change:"<<
326 hex<<ce.data.l[0]<<dec<<endl; // mask_of_members_to_change 330 hex<<ce.data.l[0]<<dec<<endl; // mask_of_members_to_change
327 cerr<<"New members:"<<ce.data.l[1]<<endl; 331 cerr<<"New members:"<<ce.data.l[1]<<endl;
328#endif // DEBUG 332#endif // DEBUG
329 333
330 if (winclient && winclient->fbwindow()) { 334 if (winclient && winclient->fbwindow()) {
331 //get new states 335 //get new states
332 int flag = ce.data.l[0] & ce.data.l[1]; 336 int flag = ce.data.l[0] & ce.data.l[1];
333 //don't update this when when we set new state 337 //don't update this when when we set new state
334 disableUpdate(); 338 disableUpdate();
@@ -368,7 +372,7 @@ void Gnome::setState(FluxboxWindow *win, int state) {
368 win->stick(); 372 win->stick();
369 } else if (win->isStuck()) 373 } else if (win->isStuck())
370 win->stick(); 374 win->stick();
371 375
372 if (state & WIN_STATE_MINIMIZED) { 376 if (state & WIN_STATE_MINIMIZED) {
373#ifdef DEBUG 377#ifdef DEBUG
374 cerr<<"Gnome state: Minimized"<<endl; 378 cerr<<"Gnome state: Minimized"<<endl;
@@ -394,12 +398,12 @@ void Gnome::setState(FluxboxWindow *win, int state) {
394 } 398 }
395 399
396 400
397 /* 401 /*
398 if (state & WIN_STATE_MAXIMIZED_VERT) 402 if (state & WIN_STATE_MAXIMIZED_VERT)
399 cerr<<"Maximize Vert"<<endl; 403 cerr<<"Maximize Vert"<<endl;
400 if (state & WIN_STATE_MAXIMIZED_HORIZ) 404 if (state & WIN_STATE_MAXIMIZED_HORIZ)
401 cerr<<"Maximize Horiz"<<endl; 405 cerr<<"Maximize Horiz"<<endl;
402 406
403 if (state & WIN_STATE_HID_WORKSPACE) 407 if (state & WIN_STATE_HID_WORKSPACE)
404 cerr<<"HID Workspace"<<endl; 408 cerr<<"HID Workspace"<<endl;
405 if (state & WIN_STATE_HID_TRANSIENT) 409 if (state & WIN_STATE_HID_TRANSIENT)
@@ -407,14 +411,14 @@ void Gnome::setState(FluxboxWindow *win, int state) {
407 if (state & WIN_STATE_FIXED_POSITION) 411 if (state & WIN_STATE_FIXED_POSITION)
408 cerr<<"Fixed Position"<<endl; 412 cerr<<"Fixed Position"<<endl;
409 if (state & WIN_STATE_ARRANGE_IGNORE) 413 if (state & WIN_STATE_ARRANGE_IGNORE)
410 cerr<<"Arrange Ignore"<<endl; 414 cerr<<"Arrange Ignore"<<endl;
411 */ 415 */
412} 416}
413 417
414void Gnome::setLayer(FluxboxWindow *win, int layer) { 418void Gnome::setLayer(FluxboxWindow *win, int layer) {
415 if (!win) return; 419 if (!win) return;
416 420
417 421
418 switch (layer) { 422 switch (layer) {
419 case WIN_LAYER_DESKTOP: 423 case WIN_LAYER_DESKTOP:
420#ifdef DEBUG 424#ifdef DEBUG
@@ -433,7 +437,7 @@ void Gnome::setLayer(FluxboxWindow *win, int layer) {
433 cerr<<"Gnome::setLayer("<<win->title()<<", WIN_LAYER_NORMAL)"<<endl; 437 cerr<<"Gnome::setLayer("<<win->title()<<", WIN_LAYER_NORMAL)"<<endl;
434#endif // DEBUG 438#endif // DEBUG
435 layer = Layer::NORMAL; 439 layer = Layer::NORMAL;
436 break; 440 break;
437 case WIN_LAYER_ONTOP: 441 case WIN_LAYER_ONTOP:
438#ifdef DEBUG 442#ifdef DEBUG
439 cerr<<"Gnome::setLayer("<<win->title()<<", WIN_LAYER_ONTOP)"<<endl; 443 cerr<<"Gnome::setLayer("<<win->title()<<", WIN_LAYER_ONTOP)"<<endl;