summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbWinFrame.cc16
-rw-r--r--src/Window.cc158
-rw-r--r--src/Window.hh4
3 files changed, 158 insertions, 20 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 7f4b4c8..de0c962 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -410,15 +410,11 @@ void FbWinFrame::moveLabelButtonLeftOf(const FbTk::TextButton &btn, const FbTk::
410 &dest); 410 &dest);
411 411
412 // make sure we found them 412 // make sure we found them
413 if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end()) 413 if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end()) {
414 {
415 cout<<"button to move not found"<<endl;
416 return; 414 return;
417 } 415 }
418 //moving a button to the left of itself results in no change 416 //moving a button to the left of itself results in no change
419 if( new_pos == it) 417 if( new_pos == it) {
420 {
421 cout<<"source and dest button are the same"<<endl;
422 return; 418 return;
423 } 419 }
424 FbTk::TextButton *item = *it; 420 FbTk::TextButton *item = *it;
@@ -439,15 +435,11 @@ void FbWinFrame::moveLabelButtonRightOf(const FbTk::TextButton &btn, const FbTk:
439 &dest); 435 &dest);
440 436
441 // make sure we found them 437 // make sure we found them
442 if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end()) 438 if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end()){
443 {
444 cout<<"button to move not found"<<endl;
445 return; 439 return;
446 } 440 }
447 //moving a button to the right of itself results in no change 441 //moving a button to the right of itself results in no change
448 if( new_pos == it) 442 if( new_pos == it){
449 {
450 cout<<"source and dest button are the same"<<endl;
451 return; 443 return;
452 } 444 }
453 FbTk::TextButton *item = *it; 445 FbTk::TextButton *item = *it;
diff --git a/src/Window.cc b/src/Window.cc
index d0fae02..83f8771 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -639,10 +639,16 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
639 if (client.fbwindow() != 0) { 639 if (client.fbwindow() != 0) {
640 FluxboxWindow *old_win = client.fbwindow(); // store old window 640 FluxboxWindow *old_win = client.fbwindow(); // store old window
641 641
642 ClientList::iterator client_insert_pos=getClientInsertPosition(x,y);
643 FbTk::TextButton *button_insert_pos=NULL;
644 if(client_insert_pos!=m_clientlist.end())
645 button_insert_pos=m_labelbuttons[*client_insert_pos];
646
647
642 // make sure we set new window search for each client 648 // make sure we set new window search for each client
643 ClientList::iterator client_it = old_win->clientList().begin(); 649 ClientList::iterator client_it = old_win->clientList().begin();
644 ClientList::iterator client_it_end = old_win->clientList().end(); 650 ClientList::iterator client_it_end = old_win->clientList().end();
645 for (; client_it != client_it_end; ++client_it) { 651 for (; client_it != client_it_end; ++client_it) {
646 // setup eventhandlers for client 652 // setup eventhandlers for client
647 evm.add(*this, (*client_it)->window()); 653 evm.add(*this, (*client_it)->window());
648 654
@@ -666,8 +672,11 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
666 btn->setJustify(frame().theme().justify()); 672 btn->setJustify(frame().theme().justify());
667 m_labelbuttons[(*client_it)] = btn; 673 m_labelbuttons[(*client_it)] = btn;
668 frame().addLabelButton(*btn); 674 frame().addLabelButton(*btn);
669 if(x >= 0) 675 if(x >= 0) {
670 frame().moveLabelButtonTo(*btn, x ,y); 676 if(button_insert_pos){ //null if we want the new button at the end of the list
677 frame().moveLabelButtonLeftOf(*btn, *button_insert_pos);
678 }
679 }
671 btn->show(); 680 btn->show();
672 // we need motion notify so we mask it 681 // we need motion notify so we mask it
673 btn->setEventMask(ExposureMask | ButtonPressMask | 682 btn->setEventMask(ExposureMask | ButtonPressMask |
@@ -682,11 +691,11 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
682 691
683 (*client_it)->saveBlackboxAttribs(m_blackbox_attrib); 692 (*client_it)->saveBlackboxAttribs(m_blackbox_attrib);
684 } 693 }
685 694
686 // add client and move over all attached clients 695 // add client and move over all attached clients
687 // from the old window to this list 696 // from the old window to this list
688 // all the "left window"s will remain the same, except for the first. 697 m_clientlist.splice(client_insert_pos, old_win->m_clientlist);
689 m_clientlist.splice(m_clientlist.end(), old_win->m_clientlist); 698 updateClientLeftWindow();
690 old_win->m_client = 0; 699 old_win->m_client = 0;
691 700
692 delete old_win; 701 delete old_win;
@@ -928,6 +937,140 @@ void FluxboxWindow::moveClientRight() {
928 updateClientLeftWindow(); 937 updateClientLeftWindow();
929} 938}
930 939
940//std::list<*WinClient>::iterator FluxboxWindow::getClientInsertPosition(int x, int y) {
941FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x, int y) {
942
943 int dest_x=0, dest_y=0;
944 Window labelbutton=0;
945 if(!XTranslateCoordinates(FbTk::App::instance()->display(),
946 parent().window(), frame().label().window(),
947 x,y, &dest_x, &dest_y,
948 &labelbutton))
949 return m_clientlist.end();
950 Client2ButtonMap::iterator it = m_labelbuttons.begin();
951 Client2ButtonMap::iterator it_end = m_labelbuttons.end();
952 //find the label button to move next to
953 for(; it!=it_end; it++) {
954 if( (*it).second->window()==labelbutton)
955 break;
956 }
957 //label button not found
958 if(it==it_end) {
959 return m_clientlist.end();
960 }
961 Window child_return=0;
962 //make x and y relative to our labelbutton
963 if(!XTranslateCoordinates(FbTk::App::instance()->display(),
964 frame().label().window(),labelbutton,
965 dest_x,dest_y, &x, &y,
966 &child_return))
967 return m_clientlist.end();
968 ClientList::iterator client = find(m_clientlist.begin(),
969 m_clientlist.end(),
970 it->first);
971 if(x>(*it).second->width()/2)
972 client++;
973 return client;
974
975
976}
977
978
979
980void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) {
981 int dest_x=0, dest_y=0;
982 Window labelbutton=0;
983 if(!XTranslateCoordinates(FbTk::App::instance()->display(),
984 parent().window(), frame().label().window(),
985 x,y, &dest_x, &dest_y,
986 &labelbutton))
987 return;
988 Client2ButtonMap::iterator it = m_labelbuttons.begin();
989 Client2ButtonMap::iterator it_end = m_labelbuttons.end();
990 //find the label button to move next to
991 for(; it!=it_end; it++) {
992 if( (*it).second->window()==labelbutton)
993 break;
994 }
995 //label button not found
996 if(it==it_end) {
997 return;
998 }
999 Window child_return=0;
1000 //make x and y relative to our labelbutton
1001 if(!XTranslateCoordinates(FbTk::App::instance()->display(),
1002 frame().label().window(),labelbutton,
1003 dest_x,dest_y, &x, &y,
1004 &child_return))
1005 return;
1006 if(x>(*it).second->width()/2) {
1007 moveClientRightOf(win, *it->first);
1008 } else {
1009 moveClientLeftOf(win, *it->first);
1010 }
1011
1012}
1013
1014
1015void FluxboxWindow::moveClientLeftOf(WinClient &win, WinClient &dest) {
1016
1017 frame().moveLabelButtonLeftOf(*m_labelbuttons[&win], *m_labelbuttons[&dest]);
1018
1019 ClientList::iterator it = find(m_clientlist.begin(),
1020 m_clientlist.end(),
1021 &win);
1022 ClientList::iterator new_pos = find(m_clientlist.begin(),
1023 m_clientlist.end(),
1024 &dest);
1025
1026 // make sure we found them
1027 if (it == m_clientlist.end() || new_pos==m_clientlist.end()) {
1028 return;
1029 }
1030 //moving a button to the left of itself results in no change
1031 if( new_pos == it) {
1032 return;
1033 }
1034 //remove from list
1035 m_clientlist.erase(it);
1036 //insert on the new place
1037 m_clientlist.insert(new_pos, &win);
1038
1039 updateClientLeftWindow();
1040}
1041
1042
1043void FluxboxWindow::moveClientRightOf(WinClient &win, WinClient &dest) {
1044 frame().moveLabelButtonRightOf(*m_labelbuttons[&win], *m_labelbuttons[&dest]);
1045
1046 ClientList::iterator it = find(m_clientlist.begin(),
1047 m_clientlist.end(),
1048 &win);
1049 ClientList::iterator new_pos = find(m_clientlist.begin(),
1050 m_clientlist.end(),
1051 &dest);
1052
1053 // make sure we found them
1054 if (it == m_clientlist.end() || new_pos==m_clientlist.end()) {
1055 return;
1056 }
1057 //moving a button to the right of itself results in no change
1058 if( new_pos == it) {
1059 return;
1060 }
1061 //remove from list
1062 m_clientlist.erase(it);
1063 //need to insert into the next position
1064 new_pos++;
1065 //insert on the new place
1066 if(new_pos == m_clientlist.end())
1067 m_clientlist.push_back(&win);
1068 else
1069 m_clientlist.insert(new_pos, &win);
1070
1071 updateClientLeftWindow();
1072}
1073
931/// Update LEFT window atom on all clients. 1074/// Update LEFT window atom on all clients.
932void FluxboxWindow::updateClientLeftWindow() { 1075void FluxboxWindow::updateClientLeftWindow() {
933 if (clientList().empty()) 1076 if (clientList().empty())
@@ -3224,8 +3367,7 @@ void FluxboxWindow::attachTo(int x, int y, bool interrupted) {
3224 } 3367 }
3225 else if(attach_to_win==this && attach_to_win->isTabable()) { 3368 else if(attach_to_win==this && attach_to_win->isTabable()) {
3226 //reording of tabs within a frame 3369 //reording of tabs within a frame
3227 FbWinFrame *frame=&attach_to_win->frame(); 3370 moveClientTo(*old_attached, x, y);
3228 frame->moveLabelButtonTo(*m_labelbuttons[old_attached], x, y);
3229 } 3371 }
3230 3372
3231 } 3373 }
diff --git a/src/Window.hh b/src/Window.hh
index f624466..c20f8a9 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -178,6 +178,10 @@ public:
178 void prevClient(); 178 void prevClient();
179 void moveClientLeft(); 179 void moveClientLeft();
180 void moveClientRight(); 180 void moveClientRight();
181 void moveClientRightOf(WinClient &win, WinClient &dest);
182 void moveClientLeftOf(WinClient &win, WinClient &dest);
183 void moveClientTo(WinClient &win, int x, int y);
184 ClientList::iterator getClientInsertPosition(int x, int y);
181 185
182 bool setInputFocus(); 186 bool setInputFocus();
183 void raiseAndFocus() { raise(); setInputFocus(); } 187 void raiseAndFocus() { raise(); setInputFocus(); }