aboutsummaryrefslogtreecommitdiff
path: root/src/WinClient.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-06-23 14:16:05 (GMT)
committerrathnor <rathnor>2003-06-23 14:16:05 (GMT)
commit09a5c23c5b099af531842ae7868e98bc8d717dac (patch)
treecf5ea34c09ee3d16ddc2e9abfc1bd2880a94067d /src/WinClient.cc
parent2e6baffb9bf988901f9fa02f651efc9b2528d7b5 (diff)
downloadfluxbox-09a5c23c5b099af531842ae7868e98bc8d717dac.zip
fluxbox-09a5c23c5b099af531842ae7868e98bc8d717dac.tar.bz2
fix grouping to persist over restart, plus various related bugs.
Also move a large proportion of window initialisation from FluxboxWindow to WinClient
Diffstat (limited to 'src/WinClient.cc')
-rw-r--r--src/WinClient.cc242
1 files changed, 231 insertions, 11 deletions
diff --git a/src/WinClient.cc b/src/WinClient.cc
index 88be980..c0079e4 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: WinClient.cc,v 1.13 2003/06/22 12:35:03 fluxgen Exp $ 22// $Id: WinClient.cc,v 1.14 2003/06/23 14:16:05 rathnor Exp $
23 23
24#include "WinClient.hh" 24#include "WinClient.hh"
25 25
@@ -38,7 +38,7 @@
38 38
39using namespace std; 39using namespace std;
40 40
41WinClient::WinClient(Window win, FluxboxWindow &fbwin):FbTk::FbWindow(win), 41WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::FbWindow(win),
42 transient_for(0), 42 transient_for(0),
43 window_group(0), 43 window_group(0),
44 x(0), y(0), old_bw(0), 44 x(0), y(0), old_bw(0),
@@ -52,12 +52,20 @@ WinClient::WinClient(Window win, FluxboxWindow &fbwin):FbTk::FbWindow(win),
52 initial_state(0), 52 initial_state(0),
53 normal_hint_flags(0), 53 normal_hint_flags(0),
54 wm_hint_flags(0), 54 wm_hint_flags(0),
55 mwm_hint(0), 55 send_focus_message(false),
56 blackbox_hint(0), 56 m_win(fbwin),
57 m_win(&fbwin),
58 modal(false), 57 modal(false),
59 m_title(""), m_icon_title(""), 58 m_title(""), m_icon_title(""),
60 m_diesig(*this), m_screen(fbwin.screen()) { } 59 m_class_name(""), m_instance_name(""),
60 m_blackbox_hint(0),
61 m_mwm_hint(0),
62 m_focus_mode(F_PASSIVE),
63 m_diesig(*this), m_screen(screen) {
64 updateBlackboxHints();
65 updateMWMHints();
66 updateWMHints();
67 updateWMNormalHints();
68}
61 69
62WinClient::~WinClient() { 70WinClient::~WinClient() {
63#ifdef DEBUG 71#ifdef DEBUG
@@ -90,11 +98,11 @@ WinClient::~WinClient() {
90 window_group = 0; 98 window_group = 0;
91 } 99 }
92 100
93 if (mwm_hint != 0) 101 if (m_mwm_hint != 0)
94 XFree(mwm_hint); 102 XFree(m_mwm_hint);
95 103
96 if (blackbox_hint != 0) 104 if (m_blackbox_hint != 0)
97 XFree(blackbox_hint); 105 XFree(m_blackbox_hint);
98 106
99 if (window()) 107 if (window())
100 fluxbox->removeWindowSearch(window()); 108 fluxbox->removeWindowSearch(window());
@@ -126,6 +134,9 @@ void WinClient::updateRect(int x, int y,
126} 134}
127 135
128void WinClient::sendFocus() { 136void WinClient::sendFocus() {
137 if (!send_focus_message)
138 return;
139
129 Display *disp = FbTk::App::instance()->display(); 140 Display *disp = FbTk::App::instance()->display();
130 // setup focus msg 141 // setup focus msg
131 XEvent ce; 142 XEvent ce;
@@ -264,7 +275,7 @@ void WinClient::updateIconTitle() {
264 XTextProperty text_prop; 275 XTextProperty text_prop;
265 char **list = 0; 276 char **list = 0;
266 int num = 0; 277 int num = 0;
267 278
268 if (getWMIconName(text_prop)) { 279 if (getWMIconName(text_prop)) {
269 if (text_prop.value && text_prop.nitems > 0) { 280 if (text_prop.value && text_prop.nitems > 0) {
270 if (text_prop.encoding != XA_STRING) { 281 if (text_prop.encoding != XA_STRING) {
@@ -288,3 +299,212 @@ void WinClient::updateIconTitle() {
288 m_icon_title = title(); 299 m_icon_title = title();
289 300
290} 301}
302
303void WinClient::saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_attribs) {
304 changeProperty(FbAtoms::instance()->getFluxboxAttributesAtom(),
305 PropModeReplace, XA_CARDINAL, 32,
306 (unsigned char *)&blackbox_attribs,
307 FluxboxWindow::PropBlackboxAttributesElements
308 );
309}
310
311void WinClient::updateBlackboxHints() {
312 int format;
313 Atom atom_return;
314 unsigned long num, len;
315 FbAtoms *atoms = FbAtoms::instance();
316
317 if (m_blackbox_hint) {
318 XFree(m_blackbox_hint);
319 m_blackbox_hint = 0;
320 }
321
322 if (property(atoms->getFluxboxHintsAtom(), 0,
323 PropBlackboxHintsElements, False,
324 atoms->getFluxboxHintsAtom(), &atom_return,
325 &format, &num, &len,
326 (unsigned char **) &m_blackbox_hint) &&
327 m_blackbox_hint) {
328 if (num != (unsigned)PropBlackboxHintsElements) {
329 XFree(m_blackbox_hint);
330 m_blackbox_hint = 0;
331 }
332 }
333}
334
335void WinClient::updateMWMHints() {
336 int format;
337 Atom atom_return;
338 unsigned long num = 0, len = 0;
339 Atom motif_wm_hints = XInternAtom(FbTk::App::instance()->display(), "_MOTIF_WM_HINTS", False);
340
341 if (m_mwm_hint) {
342 XFree(m_mwm_hint);
343 m_mwm_hint = 0;
344 }
345
346 if (!(property(motif_wm_hints, 0,
347 PropMwmHintsElements, false,
348 motif_wm_hints, &atom_return,
349 &format, &num, &len,
350 (unsigned char **) &m_mwm_hint) &&
351 m_mwm_hint)) {
352 if (num != static_cast<unsigned int>(PropMwmHintsElements)) {
353 XFree(m_mwm_hint);
354 m_mwm_hint = 0;
355 return;
356 }
357 }
358}
359
360void WinClient::updateWMHints() {
361 XWMHints *wmhint = XGetWMHints(FbTk::App::instance()->display(), window());
362 if (! wmhint) {
363 m_focus_mode = F_PASSIVE;
364 window_group = None;
365 initial_state = NormalState;
366 } else {
367 wm_hint_flags = wmhint->flags;
368 if (wmhint->flags & InputHint) {
369 if (wmhint->input) {
370 if (send_focus_message)
371 m_focus_mode = F_LOCALLYACTIVE;
372 else
373 m_focus_mode = F_PASSIVE;
374 } else {
375 if (send_focus_message)
376 m_focus_mode = F_GLOBALLYACTIVE;
377 else
378 m_focus_mode = F_NOINPUT;
379 }
380 } else
381 m_focus_mode = F_PASSIVE;
382
383 if (wmhint->flags & StateHint)
384 initial_state = wmhint->initial_state;
385 else
386 initial_state = NormalState;
387
388 if (wmhint->flags & WindowGroupHint) {
389 if (! window_group)
390 window_group = wmhint->window_group;
391 } else
392 window_group = None;
393
394 XFree(wmhint);
395 }
396}
397
398
399void WinClient::updateWMNormalHints() {
400 long icccm_mask;
401 XSizeHints sizehint;
402 if (! XGetWMNormalHints(FbTk::App::instance()->display(), window(), &sizehint, &icccm_mask)) {
403 min_width = min_height =
404 base_width = base_height =
405 width_inc = height_inc = 1;
406 max_width = 0; // unbounded
407 max_height = 0;
408 min_aspect_x = min_aspect_y =
409 max_aspect_x = max_aspect_y = 1;
410 win_gravity = NorthWestGravity;
411 } else {
412 normal_hint_flags = sizehint.flags;
413
414 if (sizehint.flags & PMinSize) {
415 min_width = sizehint.min_width;
416 min_height = sizehint.min_height;
417 } else
418 min_width = min_height = 1;
419
420 if (sizehint.flags & PMaxSize) {
421 max_width = sizehint.max_width;
422 max_height = sizehint.max_height;
423 } else {
424 max_width = 0; // unbounded
425 max_height = 0;
426 }
427
428 if (sizehint.flags & PResizeInc) {
429 width_inc = sizehint.width_inc;
430 height_inc = sizehint.height_inc;
431 } else
432 width_inc = height_inc = 1;
433
434 if (sizehint.flags & PAspect) {
435 min_aspect_x = sizehint.min_aspect.x;
436 min_aspect_y = sizehint.min_aspect.y;
437 max_aspect_x = sizehint.max_aspect.x;
438 max_aspect_y = sizehint.max_aspect.y;
439 } else
440 min_aspect_x = min_aspect_y =
441 max_aspect_x = max_aspect_y = 1;
442
443 if (sizehint.flags & PBaseSize) {
444 base_width = sizehint.base_width;
445 base_height = sizehint.base_height;
446 } else
447 base_width = base_height = 0;
448
449 if (sizehint.flags & PWinGravity)
450 win_gravity = sizehint.win_gravity;
451 else
452 win_gravity = NorthWestGravity;
453 }
454}
455
456Window WinClient::getGroupLeftWindow() const {
457 int format;
458 Atom atom_return;
459 unsigned long num = 0, len = 0;
460 Atom group_left_hint = XInternAtom(FbTk::App::instance()->display(), "_FLUXBOX_GROUP_LEFT", False);
461
462 Window *data = 0;
463 if (property(group_left_hint, 0,
464 1, false,
465 XA_WINDOW, &atom_return,
466 &format, &num, &len,
467 (unsigned char **) &data) &&
468 data) {
469 if (num != 1) {
470 XFree(data);
471 return None;
472 } else {
473 Window ret = *data;
474 XFree(data);
475 return ret;
476 }
477 }
478 return None;
479}
480
481
482void WinClient::setGroupLeftWindow(Window win) {
483 Atom group_left_hint = XInternAtom(FbTk::App::instance()->display(), "_FLUXBOX_GROUP_LEFT", False);
484 changeProperty(group_left_hint, XA_WINDOW, 32,
485 PropModeReplace, (unsigned char *) &win, 1);
486}
487
488bool WinClient::hasGroupLeftWindow() const {
489 int format;
490 Atom atom_return;
491 unsigned long num = 0, len = 0;
492 Atom group_left_hint = XInternAtom(FbTk::App::instance()->display(), "_FLUXBOX_GROUP_LEFT", False);
493
494 Window *data = 0;
495 if (property(group_left_hint, 0,
496 1, false,
497 XA_WINDOW, &atom_return,
498 &format, &num, &len,
499 (unsigned char **) &data) &&
500 data) {
501 if (num != 1) {
502 XFree(data);
503 return false;
504 } else {
505 XFree(data);
506 return true;
507 }
508 }
509 return false;
510}