diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-21 14:05:44 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-21 14:05:44 (GMT) |
commit | 533c70cb570c56a586f8946700f57a832128a705 (patch) | |
tree | 72540dbd91014a29d10c9f798fd17f6a59c71504 /src/Window.cc | |
parent | 0116a83aa6b5275cbe3cd2bd851dc6959cacf79b (diff) | |
download | fluxbox_pavel-533c70cb570c56a586f8946700f57a832128a705.zip fluxbox_pavel-533c70cb570c56a586f8946700f57a832128a705.tar.bz2 |
some cleanup
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 182 |
1 files changed, 33 insertions, 149 deletions
diff --git a/src/Window.cc b/src/Window.cc index d5679d4..73da2d4 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -388,13 +388,19 @@ FluxboxWindow::~FluxboxWindow() { | |||
388 | void FluxboxWindow::init() { | 388 | void FluxboxWindow::init() { |
389 | m_attaching_tab = 0; | 389 | m_attaching_tab = 0; |
390 | 390 | ||
391 | assert(m_client); | 391 | // fetch client size and placement |
392 | XWindowAttributes wattrib; | ||
393 | if (! m_client->getAttrib(wattrib) || | ||
394 | !wattrib.screen || // no screen? ?? | ||
395 | wattrib.override_redirect || // override redirect | ||
396 | m_client->initial_state == WithdrawnState) // Slit client | ||
397 | return; | ||
398 | |||
392 | m_client->setFluxboxWindow(this); | 399 | m_client->setFluxboxWindow(this); |
393 | m_client->setGroupLeftWindow(None); // nothing to the left. | 400 | m_client->setGroupLeftWindow(None); // nothing to the left. |
394 | 401 | ||
395 | if (Fluxbox::instance()->haveShape()) { | 402 | if (Fluxbox::instance()->haveShape()) |
396 | Shape::setShapeNotify(winClient()); | 403 | Shape::setShapeNotify(winClient()); |
397 | } | ||
398 | 404 | ||
399 | //!! TODO init of client should be better | 405 | //!! TODO init of client should be better |
400 | // we don't want to duplicate code here and in attachClient | 406 | // we don't want to duplicate code here and in attachClient |
@@ -407,24 +413,18 @@ void FluxboxWindow::init() { | |||
407 | 413 | ||
408 | Fluxbox &fluxbox = *Fluxbox::instance(); | 414 | Fluxbox &fluxbox = *Fluxbox::instance(); |
409 | 415 | ||
410 | // setup cursors for resize grips | ||
411 | frame().gripLeft().setCursor(frame().theme()->lowerLeftAngleCursor()); | ||
412 | frame().gripRight().setCursor(frame().theme()->lowerRightAngleCursor()); | ||
413 | |||
414 | associateClient(*m_client); | 416 | associateClient(*m_client); |
415 | 417 | ||
416 | frame().setLabelButtonFocus(*m_labelbuttons[m_client]); | 418 | frame().setLabelButtonFocus(*m_labelbuttons[m_client]); |
417 | 419 | ||
418 | // redirect events from frame to us | 420 | // redirect events from frame to us |
419 | frame().setEventHandler(*this); | 421 | frame().setEventHandler(*this); |
422 | fluxbox.saveWindowSearchGroup(frame().window().window(), this); | ||
423 | fluxbox.saveWindowSearchGroup(frame().tabcontainer().window(), this); | ||
420 | 424 | ||
421 | frame().resize(m_client->width(), m_client->height()); | 425 | frame().resize(m_client->width(), m_client->height()); |
422 | 426 | ||
423 | m_blackbox_attrib.workspace = m_workspace_number = m_screen.currentWorkspaceID(); | 427 | m_workspace_number = m_screen.currentWorkspaceID(); |
424 | |||
425 | m_blackbox_attrib.flags = m_blackbox_attrib.attrib = m_blackbox_attrib.stack = 0; | ||
426 | m_blackbox_attrib.premax_x = m_blackbox_attrib.premax_y = 0; | ||
427 | m_blackbox_attrib.premax_w = m_blackbox_attrib.premax_h = 0; | ||
428 | 428 | ||
429 | // set default decorations but don't apply them | 429 | // set default decorations but don't apply them |
430 | setDecorationMask(FbWinFrame::getDecoMaskFromString(screen().defaultDeco()), | 430 | setDecorationMask(FbWinFrame::getDecoMaskFromString(screen().defaultDeco()), |
@@ -435,45 +435,27 @@ void FluxboxWindow::init() { | |||
435 | 435 | ||
436 | updateMWMHintsFromClient(*m_client); | 436 | updateMWMHintsFromClient(*m_client); |
437 | 437 | ||
438 | //!! | ||
439 | // fetch client size and placement | ||
440 | XWindowAttributes wattrib; | ||
441 | if (! m_client->getAttrib(wattrib) || | ||
442 | !wattrib.screen || // no screen? ?? | ||
443 | wattrib.override_redirect || // override redirect | ||
444 | m_client->initial_state == WithdrawnState) // Slit client | ||
445 | return; | ||
446 | |||
447 | // save old border width so we can restore it later | ||
448 | m_client->old_bw = wattrib.border_width; | ||
449 | m_client->x = wattrib.x; m_client->y = wattrib.y; | ||
450 | |||
451 | m_timer.setTimeout(fluxbox.getAutoRaiseDelay()); | 438 | m_timer.setTimeout(fluxbox.getAutoRaiseDelay()); |
452 | FbTk::RefCount<FbTk::Command<void> > raise_cmd(new FbTk::SimpleCommand<FluxboxWindow>(*this, | 439 | FbTk::RefCount<FbTk::Command<void> > raise_cmd(new FbTk::SimpleCommand<FluxboxWindow>(*this, |
453 | &FluxboxWindow::raise)); | 440 | &FluxboxWindow::raise)); |
454 | m_timer.setCommand(raise_cmd); | 441 | m_timer.setCommand(raise_cmd); |
455 | m_timer.fireOnce(true); | 442 | m_timer.fireOnce(true); |
456 | 443 | ||
457 | Fluxbox::instance()->saveWindowSearchGroup(frame().window().window(), this); | ||
458 | Fluxbox::instance()->saveWindowSearchGroup(frame().tabcontainer().window(), this); | ||
459 | |||
460 | /**************************************************/ | 444 | /**************************************************/ |
461 | /* Read state above here, apply state below here. */ | 445 | /* Read state above here, apply state below here. */ |
462 | /**************************************************/ | 446 | /**************************************************/ |
463 | 447 | ||
464 | if (m_client->transientFor() && m_client->transientFor()->fbwindow() && | 448 | if (m_client->isTransient()) { |
465 | m_client->transientFor()->fbwindow()->isStuck()) | 449 | if (m_client->transientFor()->fbwindow()) |
466 | stick(); | 450 | stuck = m_client->transientFor()->fbwindow()->isStuck(); |
467 | 451 | ||
468 | // adjust the window decorations based on transience and window sizes | 452 | if (!screen().decorateTransient()) { |
469 | if (m_client->isTransient() && !screen().decorateTransient()) { | 453 | decorations.maximize = functions.maximize = false; |
470 | decorations.maximize = functions.maximize = false; | 454 | decorations.handle = false; |
471 | decorations.handle = false; | 455 | } |
472 | } | 456 | } |
473 | 457 | ||
474 | if ((m_client->normal_hint_flags & PMinSize) && | 458 | if (m_client->maxWidth() != 0 && m_client->maxHeight() != 0 && |
475 | (m_client->normal_hint_flags & PMaxSize) && | ||
476 | m_client->maxWidth() != 0 && m_client->maxHeight() != 0 && | ||
477 | m_client->maxWidth() <= m_client->minWidth() && | 459 | m_client->maxWidth() <= m_client->minWidth() && |
478 | m_client->maxHeight() <= m_client->minHeight()) { | 460 | m_client->maxHeight() <= m_client->minHeight()) { |
479 | decorations.maximize = decorations.handle = | 461 | decorations.maximize = decorations.handle = |
@@ -481,10 +463,7 @@ void FluxboxWindow::init() { | |||
481 | decorations.tab = false; //no tab for this window | 463 | decorations.tab = false; //no tab for this window |
482 | } | 464 | } |
483 | 465 | ||
484 | associateClientWindow(true, | 466 | associateClientWindow(); |
485 | wattrib.x, wattrib.y, | ||
486 | wattrib.width, wattrib.height, | ||
487 | m_client->gravity(), m_client->old_bw); | ||
488 | 467 | ||
489 | setWindowType(m_client->getWindowType()); | 468 | setWindowType(m_client->getWindowType()); |
490 | 469 | ||
@@ -513,18 +492,9 @@ void FluxboxWindow::init() { | |||
513 | // this window is managed, we are now allowed to modify actual state | 492 | // this window is managed, we are now allowed to modify actual state |
514 | m_initialized = true; | 493 | m_initialized = true; |
515 | 494 | ||
516 | restoreAttributes(); | ||
517 | |||
518 | if (m_workspace_number >= screen().numberOfWorkspaces()) | 495 | if (m_workspace_number >= screen().numberOfWorkspaces()) |
519 | m_workspace_number = screen().currentWorkspaceID(); | 496 | m_workspace_number = screen().currentWorkspaceID(); |
520 | 497 | ||
521 | /* | ||
522 | if (wattrib.width <= 0) | ||
523 | wattrib.width = 1; | ||
524 | if (wattrib.height <= 0) | ||
525 | wattrib.height = 1; | ||
526 | */ | ||
527 | |||
528 | // if we're a transient then we should be on the same layer as our parent | 498 | // if we're a transient then we should be on the same layer as our parent |
529 | if (m_client->isTransient() && | 499 | if (m_client->isTransient() && |
530 | m_client->transientFor()->fbwindow() && | 500 | m_client->transientFor()->fbwindow() && |
@@ -535,13 +505,12 @@ void FluxboxWindow::init() { | |||
535 | 505 | ||
536 | // transients should be on the same workspace as parent | 506 | // transients should be on the same workspace as parent |
537 | if (m_client->isTransient() && | 507 | if (m_client->isTransient() && |
538 | m_client->transientFor()->fbwindow() && | 508 | m_client->transientFor()->fbwindow()) { |
539 | m_client->transientFor()->fbwindow() != this) { | ||
540 | m_workspace_number = | 509 | m_workspace_number = |
541 | m_client->transientFor()->fbwindow()->workspaceNumber(); | 510 | m_client->transientFor()->fbwindow()->workspaceNumber(); |
542 | } | 511 | } |
543 | 512 | ||
544 | 513 | ||
545 | #ifdef DEBUG | 514 | #ifdef DEBUG |
546 | cerr<<"FluxboxWindow::init("<<title()<<") transientFor: "<< | 515 | cerr<<"FluxboxWindow::init("<<title()<<") transientFor: "<< |
547 | m_client->transientFor()<<endl; | 516 | m_client->transientFor()<<endl; |
@@ -551,10 +520,8 @@ void FluxboxWindow::init() { | |||
551 | } | 520 | } |
552 | #endif // DEBUG | 521 | #endif // DEBUG |
553 | 522 | ||
554 | unsigned int real_width = frame().width(); | 523 | unsigned int real_width = frame().width(), real_height = frame().height() |
555 | unsigned int real_height = frame().height() - frame().titlebarHeight() - frame().handleHeight(); | 524 | frame().applySizeHints(real_width, real_height); |
556 | frame().sizeHints().apply(real_width, real_height); | ||
557 | real_height += frame().titlebarHeight() + frame().handleHeight(); | ||
558 | 525 | ||
559 | if (m_placed) | 526 | if (m_placed) |
560 | moveResize(frame().x(), frame().y(), real_width, real_height); | 527 | moveResize(frame().x(), frame().y(), real_width, real_height); |
@@ -665,9 +632,6 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { | |||
665 | //null if we want the new button at the end of the list | 632 | //null if we want the new button at the end of the list |
666 | if (x >= 0 && button_insert_pos) | 633 | if (x >= 0 && button_insert_pos) |
667 | frame().moveLabelButtonLeftOf(*m_labelbuttons[*client_it], *button_insert_pos); | 634 | frame().moveLabelButtonLeftOf(*m_labelbuttons[*client_it], *button_insert_pos); |
668 | |||
669 | (*client_it)->saveBlackboxAttribs(m_blackbox_attrib, | ||
670 | PropBlackboxAttributesElements); | ||
671 | } | 635 | } |
672 | 636 | ||
673 | // add client and move over all attached clients | 637 | // add client and move over all attached clients |
@@ -695,8 +659,6 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { | |||
695 | m_focused = focusRequestFromClient(client); | 659 | m_focused = focusRequestFromClient(client); |
696 | focused_win = (m_focus_new || is_startup) ? &client : m_client; | 660 | focused_win = (m_focus_new || is_startup) ? &client : m_client; |
697 | 661 | ||
698 | client.saveBlackboxAttribs(m_blackbox_attrib, | ||
699 | PropBlackboxAttributesElements); | ||
700 | m_clientlist.push_back(&client); | 662 | m_clientlist.push_back(&client); |
701 | } | 663 | } |
702 | 664 | ||
@@ -1076,21 +1038,13 @@ bool FluxboxWindow::isGroupable() const { | |||
1076 | return false; | 1038 | return false; |
1077 | } | 1039 | } |
1078 | 1040 | ||
1079 | void FluxboxWindow::associateClientWindow(bool use_attrs, | 1041 | void FluxboxWindow::associateClientWindow() { |
1080 | int x, int y, | ||
1081 | unsigned int width, unsigned int height, | ||
1082 | int gravity, unsigned int client_bw) { | ||
1083 | m_client->updateTitle(); | ||
1084 | |||
1085 | frame().setShapingClient(m_client, false); | 1042 | frame().setShapingClient(m_client, false); |
1086 | 1043 | ||
1087 | if (use_attrs) | 1044 | frame().moveResizeForClient(m_client->x(), m_client->y(), |
1088 | frame().moveResizeForClient(x, y, | 1045 | m_client->width(), m_client->height(), |
1089 | width, height, gravity, client_bw); | 1046 | m_client->gravity(), m_client->old_bw); |
1090 | else | ||
1091 | frame().resizeForClient(m_client->width(), m_client->height()); | ||
1092 | 1047 | ||
1093 | frame().setActiveGravity(m_client->gravity(), m_client->old_bw); | ||
1094 | frame().setSizeHints(m_client->sizeHints()); | 1048 | frame().setSizeHints(m_client->sizeHints()); |
1095 | frame().setClientWindow(*m_client); | 1049 | frame().setClientWindow(*m_client); |
1096 | } | 1050 | } |
@@ -1719,12 +1673,7 @@ void FluxboxWindow::setWorkspace(int n) { | |||
1719 | void FluxboxWindow::setLayerNum(int layernum) { | 1673 | void FluxboxWindow::setLayerNum(int layernum) { |
1720 | m_layernum = layernum; | 1674 | m_layernum = layernum; |
1721 | 1675 | ||
1722 | m_blackbox_attrib.flags |= ATTRIB_STACK; | ||
1723 | m_blackbox_attrib.stack = layernum; | ||
1724 | |||
1725 | if (m_initialized) { | 1676 | if (m_initialized) { |
1726 | saveBlackboxAttribs(); | ||
1727 | |||
1728 | #ifdef DEBUG | 1677 | #ifdef DEBUG |
1729 | cerr<<this<<" notify layer signal"<<endl; | 1678 | cerr<<this<<" notify layer signal"<<endl; |
1730 | #endif // DEBUG | 1679 | #endif // DEBUG |
@@ -1779,8 +1728,8 @@ void FluxboxWindow::stick() { | |||
1779 | WinClient::TransientList::const_iterator it = (*client_it)->transientList().begin(); | 1728 | WinClient::TransientList::const_iterator it = (*client_it)->transientList().begin(); |
1780 | WinClient::TransientList::const_iterator it_end = (*client_it)->transientList().end(); | 1729 | WinClient::TransientList::const_iterator it_end = (*client_it)->transientList().end(); |
1781 | for (; it != it_end; ++it) { | 1730 | for (; it != it_end; ++it) { |
1782 | if ((*it)->fbwindow() && (*it)->fbwindow()->isStuck() != stuck) | 1731 | if ((*it)->fbwindow()) |
1783 | (*it)->fbwindow()->stick(); | 1732 | (*it)->fbwindow()->setStuck(stuck); |
1784 | } | 1733 | } |
1785 | 1734 | ||
1786 | } | 1735 | } |
@@ -2009,20 +1958,6 @@ void FluxboxWindow::installColormap(bool install) { | |||
2009 | } | 1958 | } |
2010 | 1959 | ||
2011 | /** | 1960 | /** |
2012 | Saves blackbox attributes for every client in our list | ||
2013 | */ | ||
2014 | void FluxboxWindow::saveBlackboxAttribs() { | ||
2015 | for_each(m_clientlist.begin(), m_clientlist.end(), | ||
2016 | ChangeProperty( | ||
2017 | display, | ||
2018 | FbAtoms::instance()->getFluxboxAttributesAtom(), | ||
2019 | PropModeReplace, | ||
2020 | (unsigned char *)&m_blackbox_attrib, | ||
2021 | PropBlackboxAttributesElements | ||
2022 | )); | ||
2023 | } | ||
2024 | |||
2025 | /** | ||
2026 | Sets state on each client in our list | 1961 | Sets state on each client in our list |
2027 | Use setting_up for setting startup state - it may not be committed yet | 1962 | Use setting_up for setting startup state - it may not be committed yet |
2028 | That'll happen when its mapped | 1963 | That'll happen when its mapped |
@@ -2077,53 +2012,6 @@ bool FluxboxWindow::getState() { | |||
2077 | } | 2012 | } |
2078 | 2013 | ||
2079 | /** | 2014 | /** |
2080 | * Sets the attributes to what they should be | ||
2081 | * but doesn't change the actual state | ||
2082 | * (so the caller can set defaults etc as well) | ||
2083 | */ | ||
2084 | void FluxboxWindow::restoreAttributes() { | ||
2085 | if (!getState()) { | ||
2086 | m_current_state = m_client->initial_state; | ||
2087 | if (m_current_state == IconicState) | ||
2088 | iconic = true; | ||
2089 | } | ||
2090 | |||
2091 | Atom atom_return; | ||
2092 | int foo; | ||
2093 | unsigned long ulfoo, nitems; | ||
2094 | FbAtoms *fbatoms = FbAtoms::instance(); | ||
2095 | |||
2096 | BlackboxAttributes *net; | ||
2097 | if (m_client->property(fbatoms->getFluxboxAttributesAtom(), 0l, | ||
2098 | PropBlackboxAttributesElements, false, | ||
2099 | fbatoms->getFluxboxAttributesAtom(), &atom_return, &foo, | ||
2100 | &nitems, &ulfoo, (unsigned char **) &net) && | ||
2101 | net) { | ||
2102 | if (nitems != (unsigned)PropBlackboxAttributesElements) { | ||
2103 | XFree(net); | ||
2104 | return; | ||
2105 | } | ||
2106 | m_blackbox_attrib.flags = net->flags; | ||
2107 | m_blackbox_attrib.attrib = net->attrib; | ||
2108 | m_blackbox_attrib.workspace = net->workspace; | ||
2109 | m_blackbox_attrib.stack = net->stack; | ||
2110 | m_blackbox_attrib.premax_x = net->premax_x; | ||
2111 | m_blackbox_attrib.premax_y = net->premax_y; | ||
2112 | m_blackbox_attrib.premax_w = net->premax_w; | ||
2113 | m_blackbox_attrib.premax_h = net->premax_h; | ||
2114 | |||
2115 | XFree(static_cast<void *>(net)); | ||
2116 | } else | ||
2117 | return; | ||
2118 | |||
2119 | if (m_blackbox_attrib.flags & ATTRIB_STACK) { | ||
2120 | //!! TODO check value? | ||
2121 | m_layernum = m_blackbox_attrib.stack; | ||
2122 | } | ||
2123 | |||
2124 | } | ||
2125 | |||
2126 | /** | ||
2127 | Show the window menu at pos mx, my | 2015 | Show the window menu at pos mx, my |
2128 | */ | 2016 | */ |
2129 | void FluxboxWindow::showMenu(int menu_x, int menu_y) { | 2017 | void FluxboxWindow::showMenu(int menu_x, int menu_y) { |
@@ -2243,7 +2131,7 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) { | |||
2243 | } | 2131 | } |
2244 | 2132 | ||
2245 | // Note: this function never gets called from WithdrawnState | 2133 | // Note: this function never gets called from WithdrawnState |
2246 | // initial state is handled in restoreAttributes() and init() | 2134 | // initial state is handled in init() |
2247 | 2135 | ||
2248 | setCurrentClient(*client, false); // focus handled on MapNotify | 2136 | setCurrentClient(*client, false); // focus handled on MapNotify |
2249 | deiconify(); | 2137 | deiconify(); |
@@ -2610,7 +2498,6 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) { | |||
2610 | bool onTitlebar = frame().gripLeft().window() != be.window && | 2498 | bool onTitlebar = frame().gripLeft().window() != be.window && |
2611 | frame().gripRight().window() != be.window && | 2499 | frame().gripRight().window() != be.window && |
2612 | frame().handle().window() != be.window && | 2500 | frame().handle().window() != be.window && |
2613 | frame().clientArea().window() != be.window && | ||
2614 | frame().window() != be.window; | 2501 | frame().window() != be.window; |
2615 | 2502 | ||
2616 | if (onTitlebar && be.button == 1) | 2503 | if (onTitlebar && be.button == 1) |
@@ -2670,7 +2557,6 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2670 | 2557 | ||
2671 | bool inside_titlebar = frame().gripLeft().window() != me.window && | 2558 | bool inside_titlebar = frame().gripLeft().window() != me.window && |
2672 | frame().gripRight().window() != me.window && | 2559 | frame().gripRight().window() != me.window && |
2673 | frame().clientArea().window() != me.window && | ||
2674 | frame().window() != me.window; | 2560 | frame().window() != me.window; |
2675 | 2561 | ||
2676 | if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0 | 2562 | if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0 |
@@ -3733,8 +3619,6 @@ void FluxboxWindow::sendConfigureNotify() { | |||
3733 | of the client window is. (ie frame pos + client pos inside the frame = send pos) | 3619 | of the client window is. (ie frame pos + client pos inside the frame = send pos) |
3734 | */ | 3620 | */ |
3735 | //!! | 3621 | //!! |
3736 | client.x = frame().x(); | ||
3737 | client.y = frame().y(); | ||
3738 | moveResizeClient(client, | 3622 | moveResizeClient(client, |
3739 | frame().clientArea().x(), | 3623 | frame().clientArea().x(), |
3740 | frame().clientArea().y(), | 3624 | frame().clientArea().y(), |