aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-07-28 15:06:36 (GMT)
committerrathnor <rathnor>2003-07-28 15:06:36 (GMT)
commitd353b688dec41daddeec9696586a4519f58cce45 (patch)
tree322a29e0e31cb15a7725047c10144c4ab3d5e130 /src/fluxbox.cc
parentf9bb208da8e8926281c91f3e386ec1de48f700a2 (diff)
downloadfluxbox-d353b688dec41daddeec9696586a4519f58cce45.zip
fluxbox-d353b688dec41daddeec9696586a4519f58cce45.tar.bz2
update many things to use WinClient instead of FluxboxWindow
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r--src/fluxbox.cc185
1 files changed, 106 insertions, 79 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index ee93883..2e37a46 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.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: fluxbox.cc,v 1.175 2003/07/27 13:53:34 fluxgen Exp $ 25// $Id: fluxbox.cc,v 1.176 2003/07/28 15:06:35 rathnor Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -757,9 +757,9 @@ void Fluxbox::handleEvent(XEvent * const e) {
757 handleButtonEvent(e->xbutton); 757 handleButtonEvent(e->xbutton);
758 break; 758 break;
759 case ConfigureRequest: { 759 case ConfigureRequest: {
760 FluxboxWindow *win = (FluxboxWindow *) 0; 760 WinClient *winclient = (WinClient *) 0;
761 761
762 if ((win = searchWindow(e->xconfigurerequest.window))) { 762 if ((winclient = searchWindow(e->xconfigurerequest.window))) {
763 // already handled in FluxboxWindow::handleEvent 763 // already handled in FluxboxWindow::handleEvent
764 } else { 764 } else {
765 grab(); 765 grab();
@@ -836,9 +836,10 @@ void Fluxbox::handleEvent(XEvent * const e) {
836 cerr<<"MapRequest for 0x"<<hex<<e->xmaprequest.window<<dec<<endl; 836 cerr<<"MapRequest for 0x"<<hex<<e->xmaprequest.window<<dec<<endl;
837#endif // DEBUG 837#endif // DEBUG
838 838
839 FluxboxWindow *win = searchWindow(e->xmaprequest.window); 839 WinClient *winclient = searchWindow(e->xmaprequest.window);
840 FluxboxWindow *win = 0;
840 841
841 if (! win) { 842 if (! winclient) {
842 //!!! TODO 843 //!!! TODO
843 BScreen *scr = searchScreen(e->xmaprequest.parent); 844 BScreen *scr = searchScreen(e->xmaprequest.parent);
844 if (scr != 0) 845 if (scr != 0)
@@ -846,7 +847,10 @@ void Fluxbox::handleEvent(XEvent * const e) {
846 else 847 else
847 cerr<<"Fluxbox Warning! Could not find screen to map window on!"<<endl; 848 cerr<<"Fluxbox Warning! Could not find screen to map window on!"<<endl;
848 849
850 } else {
851 win = winclient->fbwindow();
849 } 852 }
853
850 // we don't handle MapRequest in FluxboxWindow::handleEvent 854 // we don't handle MapRequest in FluxboxWindow::handleEvent
851 if (win) 855 if (win)
852 win->mapRequestEvent(e->xmaprequest); 856 win->mapRequestEvent(e->xmaprequest);
@@ -854,9 +858,6 @@ void Fluxbox::handleEvent(XEvent * const e) {
854 break; 858 break;
855 case MapNotify: { 859 case MapNotify: {
856 // handled directly in FluxboxWindow::handleEvent 860 // handled directly in FluxboxWindow::handleEvent
857 FluxboxWindow *win = searchWindow(e->xmap.window);
858 if (win)
859 win->mapNotifyEvent(e->xmap);
860 } break; 861 } break;
861 case UnmapNotify: 862 case UnmapNotify:
862 handleUnmapNotify(e->xunmap); 863 handleUnmapNotify(e->xunmap);
@@ -873,20 +874,16 @@ void Fluxbox::handleEvent(XEvent * const e) {
873 case CreateNotify: 874 case CreateNotify:
874 break; 875 break;
875 case DestroyNotify: { 876 case DestroyNotify: {
876 FluxboxWindow *win = searchWindow(e->xdestroywindow.window); 877 WinClient *winclient = searchWindow(e->xdestroywindow.window);
877 if (win != 0) { 878 if (winclient != 0) {
878 WinClient *client = win->findClient(e->xdestroywindow.window); 879 FluxboxWindow *win = winclient->fbwindow();
879 if (client != 0) { 880 if (win)
880 win->destroyNotifyEvent(e->xdestroywindow); 881 win->destroyNotifyEvent(e->xdestroywindow);
881 882
882 delete client; 883 delete winclient;
883 884
884 if (win->numClients() == 0 || 885 if (win && win->numClients() == 0)
885 &win->winClient() == client && win->numClients() == 1) { 886 delete win;
886 delete win;
887 }
888
889 }
890 } 887 }
891 888
892 } 889 }
@@ -895,13 +892,13 @@ void Fluxbox::handleEvent(XEvent * const e) {
895 break; 892 break;
896 case PropertyNotify: { 893 case PropertyNotify: {
897 m_last_time = e->xproperty.time; 894 m_last_time = e->xproperty.time;
898 FluxboxWindow *win = searchWindow(e->xproperty.window); 895 WinClient *winclient = searchWindow(e->xproperty.window);
899 if (win == 0) 896 if (winclient == 0)
900 break; 897 break;
901 // most of them are handled in FluxboxWindow::handleEvent 898 // most of them are handled in FluxboxWindow::handleEvent
902 // but some special cases like ewmh propertys needs to be checked 899 // but some special cases like ewmh propertys needs to be checked
903 for (size_t i=0; i<m_atomhandler.size(); ++i) { 900 for (size_t i=0; i<m_atomhandler.size(); ++i) {
904 if (m_atomhandler[i]->propertyNotify(*win, e->xproperty.atom)) 901 if (m_atomhandler[i]->propertyNotify(*winclient, e->xproperty.atom))
905 break; 902 break;
906 } 903 }
907 } break; 904 } break;
@@ -942,10 +939,9 @@ void Fluxbox::handleEvent(XEvent * const e) {
942 e->xfocus.detail == NotifyPointer) 939 e->xfocus.detail == NotifyPointer)
943 break; 940 break;
944 941
945 FluxboxWindow *win = searchWindow(e->xfocus.window); 942 WinClient *winclient = searchWindow(e->xfocus.window);
946 if (win && ! win->isFocused()) { 943 if (winclient && !(m_focused_window == winclient))
947 setFocusedWindow(win); 944 setFocusedWindow(winclient);
948 }
949 945
950 } break; 946 } break;
951 case FocusOut:{ 947 case FocusOut:{
@@ -953,8 +949,8 @@ void Fluxbox::handleEvent(XEvent * const e) {
953 if (e->xfocus.mode == NotifyUngrab || 949 if (e->xfocus.mode == NotifyUngrab ||
954 e->xfocus.detail == NotifyPointer) 950 e->xfocus.detail == NotifyPointer)
955 break; 951 break;
956 FluxboxWindow *win = searchWindow(e->xfocus.window); 952 WinClient *winclient = searchWindow(e->xfocus.window);
957 if (win == 0 && FbTk::Menu::focused() == 0) { 953 if (winclient == 0 && FbTk::Menu::focused() == 0) {
958#ifdef DEBUG 954#ifdef DEBUG
959 cerr<<__FILE__<<"("<<__FUNCTION__<<") Focus out is not a FluxboxWindow !!"<<endl; 955 cerr<<__FILE__<<"("<<__FUNCTION__<<") Focus out is not a FluxboxWindow !!"<<endl;
960#endif // DEBUG 956#endif // DEBUG
@@ -1079,25 +1075,29 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) {
1079void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) { 1075void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) {
1080 1076
1081 1077
1082 FluxboxWindow *win = 0; 1078 WinClient *winclient = 0;
1083 1079
1084 BScreen *screen = searchScreen(ue.event); 1080 BScreen *screen = searchScreen(ue.event);
1085 1081
1086 if ( ue.event != ue.window && (screen != 0 || !ue.send_event)) 1082 if ( ue.event != ue.window && (screen != 0 || !ue.send_event))
1087 return; 1083 return;
1088 1084
1089 if ((win = searchWindow(ue.window)) != 0) { 1085 if ((winclient = searchWindow(ue.window)) != 0) {
1090 WinClient *client = win->findClient(ue.window);
1091 1086
1092 if (client != 0) { 1087 if (winclient != 0) {
1088 FluxboxWindow *win = winclient->fbwindow();
1093 1089
1094 win->unmapNotifyEvent(ue); 1090 if (!win) {
1095 client = 0; // it's invalid now when win destroyed the client 1091 delete winclient;
1092 return;
1093 }
1094
1095 // this should delete client and adjust m_focused_window if necessary
1096 win->unmapNotifyEvent(ue);
1096 1097
1097 if (win == m_focused_window) 1098 winclient = 0; // it's invalid now when win destroyed the client
1098 revertFocus(win->screen());
1099 1099
1100 // finaly destroy window if empty 1100 // finally destroy window if empty
1101 if (win->numClients() == 0) { 1101 if (win->numClients() == 0) {
1102 delete win; 1102 delete win;
1103 win = 0; 1103 win = 0;
@@ -1120,14 +1120,14 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
1120 return; 1120 return;
1121 1121
1122 if (ce.message_type == m_fbatoms->getWMChangeStateAtom()) { 1122 if (ce.message_type == m_fbatoms->getWMChangeStateAtom()) {
1123 FluxboxWindow *win = searchWindow(ce.window); 1123 WinClient *winclient = searchWindow(ce.window);
1124 if (! win || ! win->validateClient()) 1124 if (! winclient || !winclient->fbwindow() || ! winclient->validateClient())
1125 return; 1125 return;
1126 1126
1127 if (ce.data.l[0] == IconicState) 1127 if (ce.data.l[0] == IconicState)
1128 win->iconify(); 1128 winclient->fbwindow()->iconify();
1129 if (ce.data.l[0] == NormalState) 1129 if (ce.data.l[0] == NormalState)
1130 win->deiconify(); 1130 winclient->fbwindow()->deiconify();
1131 } else if (ce.message_type == m_fbatoms->getFluxboxChangeWorkspaceAtom()) { 1131 } else if (ce.message_type == m_fbatoms->getFluxboxChangeWorkspaceAtom()) {
1132 BScreen *screen = searchScreen(ce.window); 1132 BScreen *screen = searchScreen(ce.window);
1133 1133
@@ -1136,9 +1136,12 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
1136 screen->changeWorkspaceID(ce.data.l[0]); 1136 screen->changeWorkspaceID(ce.data.l[0]);
1137 1137
1138 } else if (ce.message_type == m_fbatoms->getFluxboxChangeWindowFocusAtom()) { 1138 } else if (ce.message_type == m_fbatoms->getFluxboxChangeWindowFocusAtom()) {
1139 FluxboxWindow *win = searchWindow(ce.window); 1139 WinClient *winclient = searchWindow(ce.window);
1140 if (win && win->isVisible()) 1140 if (winclient) {
1141 win->setInputFocus(); 1141 FluxboxWindow *win = winclient->fbwindow();
1142 if (win && win->isVisible())
1143 win->setCurrentClient(*winclient, true);
1144 }
1142 } else if (ce.message_type == m_fbatoms->getFluxboxCycleWindowFocusAtom()) { 1145 } else if (ce.message_type == m_fbatoms->getFluxboxCycleWindowFocusAtom()) {
1143 BScreen *screen = searchScreen(ce.window); 1146 BScreen *screen = searchScreen(ce.window);
1144 1147
@@ -1147,12 +1150,11 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
1147 screen->prevFocus(); 1150 screen->prevFocus();
1148 else 1151 else
1149 screen->nextFocus(); 1152 screen->nextFocus();
1150 } 1153 }
1151 } else if (ce.message_type == m_fbatoms->getFluxboxChangeAttributesAtom()) { 1154 } else if (ce.message_type == m_fbatoms->getFluxboxChangeAttributesAtom()) {
1152 1155 WinClient *winclient = searchWindow(ce.window);
1153 FluxboxWindow *win = searchWindow(ce.window); 1156 FluxboxWindow *win = 0;
1154 1157 if (winclient && (win = winclient->fbwindow()) && winclient->validateClient()) {
1155 if (win && win->validateClient()) {
1156 FluxboxWindow::BlackboxHints net; 1158 FluxboxWindow::BlackboxHints net;
1157 net.flags = ce.data.l[0]; 1159 net.flags = ce.data.l[0];
1158 net.attrib = ce.data.l[1]; 1160 net.attrib = ce.data.l[1];
@@ -1162,11 +1164,13 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
1162 win->changeBlackboxHints(net); 1164 win->changeBlackboxHints(net);
1163 } 1165 }
1164 } else { 1166 } else {
1165 FluxboxWindow *win = searchWindow(ce.window); 1167 WinClient *winclient = searchWindow(ce.window);
1166 BScreen *screen = searchScreen(ce.window); 1168 BScreen *screen = searchScreen(ce.window);
1167 1169
1168 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1170 if (winclient && screen) {
1169 m_atomhandler[i]->checkClientMessage(ce, screen, win); 1171 for (size_t i=0; i<m_atomhandler.size(); ++i) {
1172 m_atomhandler[i]->checkClientMessage(ce, screen, winclient);
1173 }
1170 } 1174 }
1171 } 1175 }
1172} 1176}
@@ -1325,8 +1329,6 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1325 // make sure each workspace get this 1329 // make sure each workspace get this
1326 BScreen &scr = win.screen(); 1330 BScreen &scr = win.screen();
1327 scr.removeWindow(&win); 1331 scr.removeWindow(&win);
1328 if (m_focused_window == &win)
1329 revertFocus(scr);
1330 1332
1331 } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal 1333 } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal
1332 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1334 for (size_t i=0; i<m_atomhandler.size(); ++i) {
@@ -1372,10 +1374,14 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1372 if (m_atomhandler[i]->update()) 1374 if (m_atomhandler[i]->update())
1373 m_atomhandler[i]->updateClientClose(client); 1375 m_atomhandler[i]->updateClientClose(client);
1374 } 1376 }
1377
1375 BScreen &screen = client.screen(); 1378 BScreen &screen = client.screen();
1376 screen.updateNetizenWindowDel(client.window()); 1379 screen.updateNetizenWindowDel(client.window());
1377 screen.removeClient(client); 1380 screen.removeClient(client);
1378 1381
1382 if (m_focused_window == &client)
1383 revertFocus(screen);
1384
1379 removeWindowSearch(client.window()); 1385 removeWindowSearch(client.window());
1380 } 1386 }
1381} 1387}
@@ -1434,25 +1440,36 @@ void Fluxbox::removeAtomHandler(AtomHandler *atomh) {
1434 } 1440 }
1435} 1441}
1436 1442
1437FluxboxWindow *Fluxbox::searchWindow(Window window) { 1443WinClient *Fluxbox::searchWindow(Window window) {
1438 std::map<Window, FluxboxWindow *>::iterator it = m_window_search.find(window); 1444 std::map<Window, WinClient *>::iterator it = m_window_search.find(window);
1439 return it == m_window_search.end() ? 0 : it->second; 1445 if (it != m_window_search.end())
1446 return it->second;
1447
1448 std::map<Window, FluxboxWindow *>::iterator git = m_window_search_group.find(window);
1449 return git == m_window_search_group.end() ? 0 : &git->second->winClient();
1440} 1450}
1441 1451
1442 1452
1443FluxboxWindow *Fluxbox::searchGroup(Window window, FluxboxWindow *win) { 1453/* Not implemented until we know how it'll be used
1444 std::map<Window, FluxboxWindow *>::iterator it = m_group_search.find(window); 1454 * Recall that this refers to ICCCM groups, not fluxbox tabgroups
1445 return it == m_group_search.end() ? 0 : it->second; 1455 * See ICCCM 4.1.11 for details
1456 */
1457/*
1458WinClient *Fluxbox::searchGroup(Window window) {
1446} 1459}
1460*/
1447 1461
1448 1462void Fluxbox::saveWindowSearch(Window window, WinClient *data) {
1449void Fluxbox::saveWindowSearch(Window window, FluxboxWindow *data) {
1450 m_window_search[window] = data; 1463 m_window_search[window] = data;
1451} 1464}
1452 1465
1466/* some windows relate to the whole group */
1467void Fluxbox::saveWindowSearchGroup(Window window, FluxboxWindow *data) {
1468 m_window_search_group[window] = data;
1469}
1453 1470
1454void Fluxbox::saveGroupSearch(Window window, FluxboxWindow *data) { 1471void Fluxbox::saveGroupSearch(Window window, WinClient *data) {
1455 m_group_search[window] = data; 1472 m_group_search.insert(pair<Window, WinClient *>(window, data));
1456} 1473}
1457 1474
1458 1475
@@ -1460,6 +1477,10 @@ void Fluxbox::removeWindowSearch(Window window) {
1460 m_window_search.erase(window); 1477 m_window_search.erase(window);
1461} 1478}
1462 1479
1480void Fluxbox::removeWindowSearchGroup(Window window) {
1481 m_window_search_group.erase(window);
1482}
1483
1463void Fluxbox::removeGroupSearch(Window window) { 1484void Fluxbox::removeGroupSearch(Window window) {
1464 m_group_search.erase(window); 1485 m_group_search.erase(window);
1465} 1486}
@@ -1996,9 +2017,9 @@ void Fluxbox::timeout() {
1996} 2017}
1997 2018
1998// set focused window 2019// set focused window
1999void Fluxbox::setFocusedWindow(FluxboxWindow *win) { 2020void Fluxbox::setFocusedWindow(WinClient *client) {
2000 // already focused 2021 // already focused
2001 if (m_focused_window == win) { 2022 if (m_focused_window == client) {
2002#ifdef DEBUG 2023#ifdef DEBUG
2003 cerr<<"Focused window already win"<<endl; 2024 cerr<<"Focused window already win"<<endl;
2004#endif // DEBUG 2025#endif // DEBUG
@@ -2006,19 +2027,19 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
2006 } 2027 }
2007#ifdef DEBUG 2028#ifdef DEBUG
2008 cerr<<"-----------------"<<endl; 2029 cerr<<"-----------------"<<endl;
2009 cerr<<"Setting Focused window = "<<win<<endl; 2030 cerr<<"Setting Focused window = "<<client<<endl;
2010 cerr<<"Current Focused window = "<<m_focused_window<<endl; 2031 cerr<<"Current Focused window = "<<m_focused_window<<endl;
2011 cerr<<"------------------"<<endl; 2032 cerr<<"------------------"<<endl;
2012#endif // DEBUG 2033#endif // DEBUG
2013 BScreen *old_screen = 0, *screen = 0; 2034 BScreen *old_screen = 0, *screen = 0;
2014 FluxboxWindow *old_win = 0; 2035 WinClient *old_client = 0;
2015 Workspace *old_wkspc = 0, *wkspc = 0; 2036 Workspace *old_wkspc = 0, *wkspc = 0;
2016 2037
2017 if (m_focused_window != 0) { 2038 if (m_focused_window != 0) {
2018 // check if m_focused_window is valid 2039 // check if m_focused_window is valid
2019 bool found = false; 2040 bool found = false;
2020 std::map<Window, FluxboxWindow *>::iterator it = m_window_search.begin(); 2041 std::map<Window, WinClient *>::iterator it = m_window_search.begin();
2021 std::map<Window, FluxboxWindow *>::iterator it_end = m_window_search.end(); 2042 std::map<Window, WinClient *>::iterator it_end = m_window_search.end();
2022 for (; it != it_end; ++it) { 2043 for (; it != it_end; ++it) {
2023 if (it->second == m_focused_window) { 2044 if (it->second == m_focused_window) {
2024 // we found it, end loop 2045 // we found it, end loop
@@ -2030,26 +2051,32 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
2030 if (!found) { 2051 if (!found) {
2031 m_focused_window = 0; 2052 m_focused_window = 0;
2032 } else { 2053 } else {
2033 old_win = m_focused_window; 2054 old_client = m_focused_window;
2034 old_screen = &old_win->screen(); 2055 old_screen = &old_client->screen();
2035 2056
2036 old_wkspc = old_screen->getWorkspace(old_win->workspaceNumber()); 2057 if (old_client->fbwindow()) {
2058 FluxboxWindow *old_win = old_client->fbwindow();
2059 old_wkspc = old_screen->getWorkspace(old_win->workspaceNumber());
2037 2060
2038 old_win->setFocusFlag(false); 2061 if (!client || client->fbwindow() != old_win)
2062 old_win->setFocusFlag(false);
2063 }
2039 } 2064 }
2040 } 2065 }
2041 2066
2042 if (win && ! win->isIconic()) { 2067 if (client && client->fbwindow() && !client->fbwindow()->isIconic()) {
2068 FluxboxWindow *win = client->fbwindow();
2043 // make sure we have a valid win pointer with a valid screen 2069 // make sure we have a valid win pointer with a valid screen
2044 ScreenList::iterator winscreen = 2070 ScreenList::iterator winscreen =
2045 std::find(m_screen_list.begin(), m_screen_list.end(), 2071 std::find(m_screen_list.begin(), m_screen_list.end(),
2046 &win->screen()); 2072 &client->screen());
2047 if (winscreen == m_screen_list.end()) { 2073 if (winscreen == m_screen_list.end()) {
2048 m_focused_window = 0; // the window pointer wasn't valid, mark no window focused 2074 m_focused_window = 0; // the window pointer wasn't valid, mark no window focused
2049 } else { 2075 } else {
2050 screen = *winscreen; 2076 screen = *winscreen;
2051 wkspc = screen->getWorkspace(win->workspaceNumber()); 2077 wkspc = screen->getWorkspace(win->workspaceNumber());
2052 m_focused_window = win; // update focused window 2078 m_focused_window = client; // update focused window
2079 win->setCurrentClient(*client, false); // don't setinputfocus
2053 win->setFocusFlag(true); // set focus flag 2080 win->setFocusFlag(true); // set focus flag
2054 } 2081 }
2055 } else 2082 } else