diff options
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 108 |
1 files changed, 57 insertions, 51 deletions
diff --git a/src/Window.cc b/src/Window.cc index 4047f1b..9305fb6 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Window.cc,v 1.132 2003/04/15 00:50:25 rathnor Exp $ | 25 | // $Id: Window.cc,v 1.133 2003/04/15 12:18:37 fluxgen Exp $ |
26 | 26 | ||
27 | #include "Window.hh" | 27 | #include "Window.hh" |
28 | 28 | ||
@@ -34,9 +34,9 @@ | |||
34 | #include "Netizen.hh" | 34 | #include "Netizen.hh" |
35 | #include "FbWinFrameTheme.hh" | 35 | #include "FbWinFrameTheme.hh" |
36 | #include "MenuTheme.hh" | 36 | #include "MenuTheme.hh" |
37 | |||
38 | #include "TextButton.hh" | 37 | #include "TextButton.hh" |
39 | #include "EventManager.hh" | 38 | #include "EventManager.hh" |
39 | #include "FbAtoms.hh" | ||
40 | 40 | ||
41 | #ifdef HAVE_CONFIG_H | 41 | #ifdef HAVE_CONFIG_H |
42 | #include "config.h" | 42 | #include "config.h" |
@@ -279,11 +279,12 @@ void FluxboxWindow::init() { | |||
279 | // we don't want to duplicate code here and in attachClient | 279 | // we don't want to duplicate code here and in attachClient |
280 | m_clientlist.push_back(m_client); | 280 | m_clientlist.push_back(m_client); |
281 | #ifdef DEBUG | 281 | #ifdef DEBUG |
282 | cerr<<"FluxboxWindow::init(this="<<this<<")"<<endl; | 282 | cerr<<__FILE__<<": FluxboxWindow::init(this="<<this<<", client="<<hex<<m_client->window()<<dec<<")"<<endl; |
283 | #endif // DEBUG | 283 | #endif // DEBUG |
284 | TextButton *btn = new TextButton(m_frame.label(), | 284 | TextButton *btn = new TextButton(m_frame.label(), |
285 | m_frame.theme().font(), | 285 | m_frame.theme().font(), |
286 | m_client->title()); | 286 | m_client->title()); |
287 | btn->setJustify(m_frame.theme().justify()); | ||
287 | m_labelbuttons[m_client] = btn; | 288 | m_labelbuttons[m_client] = btn; |
288 | m_frame.addLabelButton(*btn); | 289 | m_frame.addLabelButton(*btn); |
289 | btn->show(); | 290 | btn->show(); |
@@ -464,10 +465,6 @@ void FluxboxWindow::attachClient(WinClient &client) { | |||
464 | if (client.m_win == this) | 465 | if (client.m_win == this) |
465 | return; | 466 | return; |
466 | 467 | ||
467 | #ifdef DEBUG | ||
468 | cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"]"<<endl; | ||
469 | cerr<<"attach client window = "<<hex<<client.window()<<dec<<endl; | ||
470 | #endif // DEBUG | ||
471 | // reparent client win to this frame | 468 | // reparent client win to this frame |
472 | m_frame.setClientWindow(client); | 469 | m_frame.setClientWindow(client); |
473 | 470 | ||
@@ -483,26 +480,31 @@ void FluxboxWindow::attachClient(WinClient &client) { | |||
483 | // reparent window to this | 480 | // reparent window to this |
484 | m_frame.setClientWindow(*(*client_it)); | 481 | m_frame.setClientWindow(*(*client_it)); |
485 | (*client_it)->m_win = this; | 482 | (*client_it)->m_win = this; |
486 | // create a labelbutton for this client and associate it with the pointer | 483 | // create a labelbutton for this client and |
484 | // associate it with the pointer | ||
487 | TextButton *btn = new TextButton(m_frame.label(), | 485 | TextButton *btn = new TextButton(m_frame.label(), |
488 | m_frame.theme().font(), | 486 | m_frame.theme().font(), |
489 | (*client_it)->title()); | 487 | (*client_it)->title()); |
488 | btn->setJustify(m_frame.theme().justify()); | ||
490 | m_labelbuttons[(*client_it)] = btn; | 489 | m_labelbuttons[(*client_it)] = btn; |
491 | m_frame.addLabelButton(*btn); | 490 | m_frame.addLabelButton(*btn); |
492 | btn->show(); | 491 | btn->show(); |
493 | FbTk::EventManager &evm = *FbTk::EventManager::instance(); | 492 | FbTk::EventManager &evm = *FbTk::EventManager::instance(); |
494 | // we need motion notify so we mask it | 493 | // we need motion notify so we mask it |
495 | btn->window().setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask | | 494 | btn->window().setEventMask(ExposureMask | ButtonPressMask | |
496 | ButtonMotionMask); | 495 | ButtonReleaseMask | ButtonMotionMask); |
497 | 496 | ||
498 | 497 | ||
499 | FbTk::RefCount<FbTk::Command> set_client_cmd(new SetClientCmd(*(*client_it))); | 498 | FbTk::RefCount<FbTk::Command> |
499 | set_client_cmd(new SetClientCmd(*(*client_it))); | ||
500 | btn->setOnClick(set_client_cmd); | 500 | btn->setOnClick(set_client_cmd); |
501 | evm.add(*this, btn->window()); // we take care of button events for this | 501 | evm.add(*this, btn->window()); // we take care of button events for this |
502 | 502 | ||
503 | // update transients in client to have this as transient_for | 503 | // update transients in client to have this as transient_for |
504 | WinClient::TransientList::iterator trans_it = (*client_it)->transientList().begin(); | 504 | WinClient::TransientList::iterator trans_it = |
505 | WinClient::TransientList::iterator trans_it_end = (*client_it)->transientList().end(); | 505 | (*client_it)->transientList().begin(); |
506 | WinClient::TransientList::iterator trans_it_end = | ||
507 | (*client_it)->transientList().end(); | ||
506 | for (; trans_it != trans_it_end; ++trans_it) { | 508 | for (; trans_it != trans_it_end; ++trans_it) { |
507 | (*trans_it)->m_client->transient_for = this; | 509 | (*trans_it)->m_client->transient_for = this; |
508 | } | 510 | } |
@@ -525,8 +527,8 @@ void FluxboxWindow::attachClient(WinClient &client) { | |||
525 | btn->show(); | 527 | btn->show(); |
526 | FbTk::EventManager &evm = *FbTk::EventManager::instance(); | 528 | FbTk::EventManager &evm = *FbTk::EventManager::instance(); |
527 | // we need motion notify so we mask it | 529 | // we need motion notify so we mask it |
528 | btn->window().setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask | | 530 | btn->window().setEventMask(ExposureMask | ButtonPressMask | |
529 | ButtonMotionMask); | 531 | ButtonReleaseMask | ButtonMotionMask); |
530 | 532 | ||
531 | 533 | ||
532 | FbTk::RefCount<FbTk::Command> set_client_cmd(new SetClientCmd(client)); | 534 | FbTk::RefCount<FbTk::Command> set_client_cmd(new SetClientCmd(client)); |
@@ -535,8 +537,10 @@ void FluxboxWindow::attachClient(WinClient &client) { | |||
535 | 537 | ||
536 | client.m_win = this; | 538 | client.m_win = this; |
537 | // update transients in client to have this as transient_for | 539 | // update transients in client to have this as transient_for |
538 | WinClient::TransientList::iterator trans_it = client.transientList().begin(); | 540 | WinClient::TransientList::iterator trans_it = |
539 | WinClient::TransientList::iterator trans_it_end = client.transientList().end(); | 541 | client.transientList().begin(); |
542 | WinClient::TransientList::iterator trans_it_end = | ||
543 | client.transientList().end(); | ||
540 | for (; trans_it != trans_it_end; ++trans_it) { | 544 | for (; trans_it != trans_it_end; ++trans_it) { |
541 | (*trans_it)->m_client->transient_for = this; | 545 | (*trans_it)->m_client->transient_for = this; |
542 | } | 546 | } |
@@ -545,19 +549,11 @@ void FluxboxWindow::attachClient(WinClient &client) { | |||
545 | } | 549 | } |
546 | 550 | ||
547 | m_frame.reconfigure(); | 551 | m_frame.reconfigure(); |
548 | #ifdef DEBUG | ||
549 | XSync(display, False); // so we see error/warnings in time | ||
550 | cerr<<"destroyed old window "<<client.window()<<endl; | ||
551 | #endif // DEBUG | ||
552 | 552 | ||
553 | // keep the current window on top | 553 | // keep the current window on top |
554 | m_client->raise(); | 554 | m_client->raise(); |
555 | 555 | ||
556 | #ifdef DEBUG | 556 | |
557 | XSync(display, False); // so we see error/warnings in time | ||
558 | cerr<<__FILE__<<"("<<__FUNCTION__<<") clientlist size: "<<m_clientlist.size()<<endl; | ||
559 | cerr<<endl<<endl<<endl; | ||
560 | #endif // DEBUG | ||
561 | 557 | ||
562 | } | 558 | } |
563 | 559 | ||
@@ -567,12 +563,6 @@ bool FluxboxWindow::detachClient(WinClient &client) { | |||
567 | if (client.m_win != this || numClients() <= 1) | 563 | if (client.m_win != this || numClients() <= 1) |
568 | return false; | 564 | return false; |
569 | 565 | ||
570 | #ifdef DEBUG | ||
571 | cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"] client to detach: "<< | ||
572 | hex<<client.window()<<dec<<endl; | ||
573 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): number of clients = "<<numClients()<<endl; | ||
574 | #endif // DEBUG | ||
575 | |||
576 | removeClient(client); | 566 | removeClient(client); |
577 | 567 | ||
578 | client.m_win = screen.createWindow(client); | 568 | client.m_win = screen.createWindow(client); |
@@ -634,11 +624,15 @@ WinClient *FluxboxWindow::findClient(Window win) { | |||
634 | 624 | ||
635 | /// raise and focus next client | 625 | /// raise and focus next client |
636 | void FluxboxWindow::nextClient() { | 626 | void FluxboxWindow::nextClient() { |
637 | if (numClients() == 1) | 627 | if (numClients() <= 1) |
638 | return; | 628 | return; |
639 | 629 | ||
640 | ClientList::iterator it = find(m_clientlist.begin(), m_clientlist.end(), m_client); | 630 | ClientList::iterator it = find(m_clientlist.begin(), m_clientlist.end(), m_client); |
641 | assert(it != m_clientlist.end()); | 631 | if (it == m_clientlist.end()) { |
632 | m_client = m_clientlist.front(); | ||
633 | return; | ||
634 | } | ||
635 | |||
642 | it++; | 636 | it++; |
643 | if (it == m_clientlist.end()) | 637 | if (it == m_clientlist.end()) |
644 | m_client = m_clientlist.front(); | 638 | m_client = m_clientlist.front(); |
@@ -649,12 +643,14 @@ void FluxboxWindow::nextClient() { | |||
649 | } | 643 | } |
650 | 644 | ||
651 | void FluxboxWindow::prevClient() { | 645 | void FluxboxWindow::prevClient() { |
652 | if (numClients() == 1) | 646 | if (numClients() <= 1) |
653 | return; | 647 | return; |
654 | 648 | ||
655 | ClientList::iterator it = find(m_clientlist.begin(), m_clientlist.end(), m_client); | 649 | ClientList::iterator it = find(m_clientlist.begin(), m_clientlist.end(), m_client); |
656 | assert(it != m_clientlist.end()); | 650 | if (it == m_clientlist.end()) { |
657 | 651 | m_client = m_clientlist.front(); | |
652 | return; | ||
653 | } | ||
658 | if (it == m_clientlist.begin()) | 654 | if (it == m_clientlist.begin()) |
659 | m_client = m_clientlist.back(); | 655 | m_client = m_clientlist.back(); |
660 | else | 656 | else |
@@ -909,11 +905,11 @@ void FluxboxWindow::getMWMHints() { | |||
909 | int format; | 905 | int format; |
910 | Atom atom_return; | 906 | Atom atom_return; |
911 | unsigned long num, len; | 907 | unsigned long num, len; |
912 | Fluxbox *fluxbox = Fluxbox::instance(); | 908 | Atom motif_wm_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False); |
913 | if (!XGetWindowProperty(display, m_client->window(), | 909 | if (!XGetWindowProperty(display, m_client->window(), |
914 | fluxbox->getMotifWMHintsAtom(), 0, | 910 | motif_wm_hints, 0, |
915 | PropMwmHintsElements, false, | 911 | PropMwmHintsElements, false, |
916 | fluxbox->getMotifWMHintsAtom(), &atom_return, | 912 | motif_wm_hints, &atom_return, |
917 | &format, &num, &len, | 913 | &format, &num, &len, |
918 | (unsigned char **) &m_client->mwm_hint) == Success && | 914 | (unsigned char **) &m_client->mwm_hint) == Success && |
919 | m_client->mwm_hint) { | 915 | m_client->mwm_hint) { |
@@ -1550,7 +1546,7 @@ void FluxboxWindow::installColormap(bool install) { | |||
1550 | Colormap *cmaps = XListInstalledColormaps(display, m_client->window(), &ncmap); | 1546 | Colormap *cmaps = XListInstalledColormaps(display, m_client->window(), &ncmap); |
1551 | XWindowAttributes wattrib; | 1547 | XWindowAttributes wattrib; |
1552 | if (cmaps) { //!! | 1548 | if (cmaps) { //!! |
1553 | if (m_client->getAttrib(wattrib)) { //XGetWindowAttributes(display, m_client->window, &wattrib)) { | 1549 | if (m_client->getAttrib(wattrib)) { |
1554 | if (install) { | 1550 | if (install) { |
1555 | // install the window's colormap | 1551 | // install the window's colormap |
1556 | for (i = 0; i < ncmap; i++) { | 1552 | for (i = 0; i < ncmap; i++) { |
@@ -1613,9 +1609,8 @@ bool FluxboxWindow::getState() { | |||
1613 | bool ret = false; | 1609 | bool ret = false; |
1614 | int foo; | 1610 | int foo; |
1615 | unsigned long *state, ulfoo, nitems; | 1611 | unsigned long *state, ulfoo, nitems; |
1616 | Fluxbox *fluxbox = Fluxbox::instance(); | 1612 | if ((XGetWindowProperty(display, m_client->window(), FbAtoms::instance()->getWMStateAtom(), |
1617 | if ((XGetWindowProperty(display, m_client->window(), fluxbox->getWMStateAtom(), | 1613 | 0l, 2l, false, FbAtoms::instance()->getWMStateAtom(), |
1618 | 0l, 2l, false, fluxbox->getWMStateAtom(), | ||
1619 | &atom_return, &foo, &nitems, &ulfoo, | 1614 | &atom_return, &foo, &nitems, &ulfoo, |
1620 | (unsigned char **) &state) != Success) || | 1615 | (unsigned char **) &state) != Success) || |
1621 | (! state)) { | 1616 | (! state)) { |
@@ -1713,13 +1708,13 @@ void FluxboxWindow::restoreAttributes() { | |||
1713 | Atom atom_return; | 1708 | Atom atom_return; |
1714 | int foo; | 1709 | int foo; |
1715 | unsigned long ulfoo, nitems; | 1710 | unsigned long ulfoo, nitems; |
1716 | Fluxbox *fluxbox = Fluxbox::instance(); | 1711 | FbAtoms *fbatoms = FbAtoms::instance(); |
1717 | 1712 | ||
1718 | BaseDisplay::BlackboxAttributes *net; | 1713 | BaseDisplay::BlackboxAttributes *net; |
1719 | if (XGetWindowProperty(display, m_client->window(), | 1714 | if (XGetWindowProperty(display, m_client->window(), |
1720 | fluxbox->getFluxboxAttributesAtom(), 0l, | 1715 | fbatoms->getFluxboxAttributesAtom(), 0l, |
1721 | PropBlackboxAttributesElements, false, | 1716 | PropBlackboxAttributesElements, false, |
1722 | fluxbox->getFluxboxAttributesAtom(), &atom_return, &foo, | 1717 | fbatoms->getFluxboxAttributesAtom(), &atom_return, &foo, |
1723 | &nitems, &ulfoo, (unsigned char **) &net) == | 1718 | &nitems, &ulfoo, (unsigned char **) &net) == |
1724 | Success && net && nitems == PropBlackboxAttributesElements) { | 1719 | Success && net && nitems == PropBlackboxAttributesElements) { |
1725 | blackbox_attrib.flags = net->flags; | 1720 | blackbox_attrib.flags = net->flags; |
@@ -1949,7 +1944,11 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) { | |||
1949 | 1944 | ||
1950 | 1945 | ||
1951 | void FluxboxWindow::mapNotifyEvent(XMapEvent &ne) { | 1946 | void FluxboxWindow::mapNotifyEvent(XMapEvent &ne) { |
1952 | if (ne.window == m_client->window() && !ne.override_redirect && visible) { | 1947 | WinClient *client = findClient(ne.window); |
1948 | if (client == 0) | ||
1949 | return; | ||
1950 | |||
1951 | if (!ne.override_redirect && visible) { | ||
1953 | Fluxbox *fluxbox = Fluxbox::instance(); | 1952 | Fluxbox *fluxbox = Fluxbox::instance(); |
1954 | fluxbox->grab(); | 1953 | fluxbox->grab(); |
1955 | if (! validateClient()) | 1954 | if (! validateClient()) |
@@ -1990,6 +1989,7 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent &ue) { | |||
1990 | 1989 | ||
1991 | #ifdef DEBUG | 1990 | #ifdef DEBUG |
1992 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): 0x"<<hex<<client->window()<<dec<<endl; | 1991 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): 0x"<<hex<<client->window()<<dec<<endl; |
1992 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): title="<<client->title()<<endl; | ||
1993 | #endif // DEBUG | 1993 | #endif // DEBUG |
1994 | 1994 | ||
1995 | restore(client, false); | 1995 | restore(client, false); |
@@ -2107,7 +2107,8 @@ void FluxboxWindow::exposeEvent(XExposeEvent &ee) { | |||
2107 | 2107 | ||
2108 | 2108 | ||
2109 | void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) { | 2109 | void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) { |
2110 | if (cr.window != m_client->window()) | 2110 | WinClient *client = findClient(cr.window); |
2111 | if (client == 0) | ||
2111 | return; | 2112 | return; |
2112 | 2113 | ||
2113 | int cx = m_frame.x(), cy = m_frame.y(); | 2114 | int cx = m_frame.x(), cy = m_frame.y(); |
@@ -2116,7 +2117,7 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) { | |||
2116 | m_frame.titlebar().height() + frame().titlebar().borderWidth() | 2117 | m_frame.titlebar().height() + frame().titlebar().borderWidth() |
2117 | : 0); | 2118 | : 0); |
2118 | if (cr.value_mask & CWBorderWidth) | 2119 | if (cr.value_mask & CWBorderWidth) |
2119 | m_client->old_bw = cr.border_width; | 2120 | client->old_bw = cr.border_width; |
2120 | 2121 | ||
2121 | if (cr.value_mask & CWX) | 2122 | if (cr.value_mask & CWX) |
2122 | cx = cr.x; | 2123 | cx = cr.x; |
@@ -2638,8 +2639,13 @@ void FluxboxWindow::restore(WinClient *client, bool remap) { | |||
2638 | 2639 | ||
2639 | delete client; | 2640 | delete client; |
2640 | 2641 | ||
2641 | if (numClients() == 0) | 2642 | #ifdef DEBUG |
2643 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): numClients() = "<<numClients()<<endl; | ||
2644 | #endif // DEBUG | ||
2645 | if (numClients() == 0) { | ||
2646 | |||
2642 | m_frame.hide(); | 2647 | m_frame.hide(); |
2648 | } | ||
2643 | 2649 | ||
2644 | } | 2650 | } |
2645 | 2651 | ||