summaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc45
1 files changed, 31 insertions, 14 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 6fc4007..3c2cc02 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -641,8 +641,8 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
641 641
642 // reparent client win to this frame 642 // reparent client win to this frame
643 frame().setClientWindow(client); 643 frame().setClientWindow(client);
644 WinClient *was_focused = 0; 644 bool was_focused = false;
645 WinClient *focused_win = FocusControl::focusedWindow(); 645 WinClient *focused_win = 0;
646 646
647 // get the current window on the end of our client list 647 // get the current window on the end of our client list
648 Window leftwin = None; 648 Window leftwin = None;
@@ -654,19 +654,31 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
654 if (client.fbwindow() != 0) { 654 if (client.fbwindow() != 0) {
655 FluxboxWindow *old_win = client.fbwindow(); // store old window 655 FluxboxWindow *old_win = client.fbwindow(); // store old window
656 656
657 ClientList::iterator client_insert_pos = getClientInsertPosition(x, y); 657 // figure out which client to raise at the end
658 FbTk::TextButton *button_insert_pos = NULL; 658 if (FocusControl::focusedFbWindow() == old_win) {
659 if (client_insert_pos != m_clientlist.end()) 659 was_focused = true;
660 focused_win = FocusControl::focusedWindow();
661 } else if (FocusControl::focusedFbWindow() != this) {
662 FocusControl::FocusedWindows focus_list =
663 screen().focusControl().focusedOrderList();
664 FocusControl::FocusedWindows::iterator it = focus_list.begin();
665 for (; it != focus_list.end() && !focused_win; ++it) {
666 if ((*it)->fbwindow() == this || (*it)->fbwindow() == old_win)
667 focused_win = *it;
668 }
669 }
670
671 ClientList::iterator client_insert_pos = getClientInsertPosition(x, y);
672 FbTk::TextButton *button_insert_pos = NULL;
673 if (client_insert_pos != m_clientlist.end())
660 button_insert_pos = m_labelbuttons[*client_insert_pos]; 674 button_insert_pos = m_labelbuttons[*client_insert_pos];
661 675
662 // make sure we set new window search for each client 676 // make sure we set new window search for each client
663 ClientList::iterator client_it = old_win->clientList().begin(); 677 ClientList::iterator client_it = old_win->clientList().begin();
664 ClientList::iterator client_it_end = old_win->clientList().end(); 678 ClientList::iterator client_it_end = old_win->clientList().end();
665 for (; client_it != client_it_end; ++client_it) { 679 for (; client_it != client_it_end; ++client_it) {
666 // reparent window to this 680 // reparent window to this
667 frame().setClientWindow(**client_it); 681 frame().setClientWindow(**client_it);
668 if ((*client_it) == focused_win)
669 was_focused = focused_win;
670 682
671 moveResizeClient(**client_it, 683 moveResizeClient(**client_it,
672 frame().clientArea().x(), 684 frame().clientArea().x(),
@@ -679,7 +691,7 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
679 associateClient(*(*client_it)); 691 associateClient(*(*client_it));
680 692
681 //null if we want the new button at the end of the list 693 //null if we want the new button at the end of the list
682 if (x >= 0 && button_insert_pos) 694 if (x >= 0 && button_insert_pos)
683 frame().moveLabelButtonLeftOf(*m_labelbuttons[*client_it], *button_insert_pos); 695 frame().moveLabelButtonLeftOf(*m_labelbuttons[*client_it], *button_insert_pos);
684 696
685 (*client_it)->saveBlackboxAttribs(m_blackbox_attrib); 697 (*client_it)->saveBlackboxAttribs(m_blackbox_attrib);
@@ -687,8 +699,8 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
687 699
688 // add client and move over all attached clients 700 // add client and move over all attached clients
689 // from the old window to this list 701 // from the old window to this list
690 m_clientlist.splice(client_insert_pos, old_win->m_clientlist); 702 m_clientlist.splice(client_insert_pos, old_win->m_clientlist);
691 updateClientLeftWindow(); 703 updateClientLeftWindow();
692 old_win->m_client = 0; 704 old_win->m_client = 0;
693 705
694 delete old_win; 706 delete old_win;
@@ -702,8 +714,10 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
702 frame().clientArea().width(), 714 frame().clientArea().width(),
703 frame().clientArea().height()); 715 frame().clientArea().height());
704 716
705 if (&client == focused_win) 717 if (&client == FocusControl::focusedWindow()) {
706 was_focused = focused_win; 718 was_focused = true;
719 focused_win = &client;
720 }
707 721
708 client.saveBlackboxAttribs(m_blackbox_attrib); 722 client.saveBlackboxAttribs(m_blackbox_attrib);
709 m_clientlist.push_back(&client); 723 m_clientlist.push_back(&client);
@@ -716,13 +730,15 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
716 m_workspacesig.notify(); 730 m_workspacesig.notify();
717 m_layersig.notify(); 731 m_layersig.notify();
718 732
719 if (was_focused != 0) 733 if (was_focused)
720 // already has focus, we're just assuming the state of the old window 734 // already has focus, we're just assuming the state of the old window
721 FocusControl::setFocusedWindow(&client); 735 FocusControl::setFocusedWindow(&client);
722 736
723 frame().reconfigure(); 737 frame().reconfigure();
724 738
725 // keep the current window on top 739 // keep the current window on top
740 if (focused_win)
741 m_client = focused_win;
726 m_client->raise(); 742 m_client->raise();
727} 743}
728 744
@@ -777,6 +793,7 @@ bool FluxboxWindow::detachClient(WinClient &client) {
777 // m_client must be valid as there should be at least one other window 793 // m_client must be valid as there should be at least one other window
778 // otherwise this wouldn't be here (refer numClients() <= 1 return) 794 // otherwise this wouldn't be here (refer numClients() <= 1 return)
779 client.setFluxboxWindow(screen().createWindow(client)); 795 client.setFluxboxWindow(screen().createWindow(client));
796 client.setGroupLeftWindow(None);
780 return true; 797 return true;
781} 798}
782 799