diff options
Diffstat (limited to 'src/Screen.cc')
-rw-r--r-- | src/Screen.cc | 110 |
1 files changed, 59 insertions, 51 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index 880d769..3838528 100644 --- a/src/Screen.cc +++ b/src/Screen.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: Screen.cc,v 1.207 2003/07/25 10:03:55 rathnor Exp $ | 25 | // $Id: Screen.cc,v 1.208 2003/07/28 15:06:33 rathnor Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
@@ -738,11 +738,11 @@ void BScreen::removeWindow(FluxboxWindow *win) { | |||
738 | 738 | ||
739 | void BScreen::removeClient(WinClient &client) { | 739 | void BScreen::removeClient(WinClient &client) { |
740 | WinClient *cyc = *cycling_window; | 740 | WinClient *cyc = *cycling_window; |
741 | FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); | 741 | WinClient *focused = Fluxbox::instance()->getFocusedWindow(); |
742 | focused_list.remove(&client); | 742 | focused_list.remove(&client); |
743 | if (cyc == &client) { | 743 | if (cyc == &client) { |
744 | cycling_window = focused_list.end(); | 744 | cycling_window = focused_list.end(); |
745 | } else if (focused && &focused->winClient() == &client) { | 745 | } else if (focused == &client) { |
746 | // if we are focused, then give our focus to our transient parent | 746 | // if we are focused, then give our focus to our transient parent |
747 | // or revert normally | 747 | // or revert normally |
748 | if (client.transientFor() && client.transientFor()->fbwindow()) | 748 | if (client.transientFor() && client.transientFor()->fbwindow()) |
@@ -832,7 +832,11 @@ void BScreen::changeWorkspaceID(unsigned int id) { | |||
832 | return; | 832 | return; |
833 | 833 | ||
834 | XSync(FbTk::App::instance()->display(), true); | 834 | XSync(FbTk::App::instance()->display(), true); |
835 | FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); | 835 | WinClient *focused_client = Fluxbox::instance()->getFocusedWindow(); |
836 | FluxboxWindow *focused = 0; | ||
837 | if (focused_client) | ||
838 | focused = focused_client->fbwindow(); | ||
839 | |||
836 | #ifdef DEBUG | 840 | #ifdef DEBUG |
837 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): focused = "<<focused<<endl; | 841 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): focused = "<<focused<<endl; |
838 | #endif // DEBUG | 842 | #endif // DEBUG |
@@ -882,8 +886,11 @@ void BScreen::sendToWorkspace(unsigned int id, FluxboxWindow *win, bool changeWS | |||
882 | if (! m_current_workspace || id >= m_workspaces_list.size()) | 886 | if (! m_current_workspace || id >= m_workspaces_list.size()) |
883 | return; | 887 | return; |
884 | 888 | ||
885 | if (!win) | 889 | if (!win) { |
886 | win = Fluxbox::instance()->getFocusedWindow(); | 890 | WinClient *client = Fluxbox::instance()->getFocusedWindow(); |
891 | if (client) | ||
892 | win = client->fbwindow(); | ||
893 | } | ||
887 | 894 | ||
888 | if (id != currentWorkspace()->workspaceID()) { | 895 | if (id != currentWorkspace()->workspaceID()) { |
889 | XSync(FbTk::App::instance()->display(), True); | 896 | XSync(FbTk::App::instance()->display(), True); |
@@ -930,7 +937,7 @@ void BScreen::addNetizen(Window win) { | |||
930 | } | 937 | } |
931 | 938 | ||
932 | Window f = ((Fluxbox::instance()->getFocusedWindow()) ? | 939 | Window f = ((Fluxbox::instance()->getFocusedWindow()) ? |
933 | Fluxbox::instance()->getFocusedWindow()->clientWindow() : None); | 940 | Fluxbox::instance()->getFocusedWindow()->window() : None); |
934 | net->sendWindowFocus(f); | 941 | net->sendWindowFocus(f); |
935 | } | 942 | } |
936 | 943 | ||
@@ -970,7 +977,7 @@ void BScreen::updateNetizenWindowFocus() { | |||
970 | Netizens::iterator it = m_netizen_list.begin(); | 977 | Netizens::iterator it = m_netizen_list.begin(); |
971 | Netizens::iterator it_end = m_netizen_list.end(); | 978 | Netizens::iterator it_end = m_netizen_list.end(); |
972 | Window f = ((Fluxbox::instance()->getFocusedWindow()) ? | 979 | Window f = ((Fluxbox::instance()->getFocusedWindow()) ? |
973 | Fluxbox::instance()->getFocusedWindow()->clientWindow() : None); | 980 | Fluxbox::instance()->getFocusedWindow()->window() : None); |
974 | for (; it != it_end; ++it) { | 981 | for (; it != it_end; ++it) { |
975 | (*it)->sendWindowFocus(f); | 982 | (*it)->sendWindowFocus(f); |
976 | } | 983 | } |
@@ -1075,8 +1082,6 @@ FluxboxWindow *BScreen::createWindow(Window client) { | |||
1075 | Fluxbox::instance()->attachSignals(*win); | 1082 | Fluxbox::instance()->attachSignals(*win); |
1076 | } | 1083 | } |
1077 | 1084 | ||
1078 | Fluxbox::instance()->saveWindowSearch(client, win); | ||
1079 | |||
1080 | // we also need to check if another window expects this window to the left | 1085 | // we also need to check if another window expects this window to the left |
1081 | // and if so, then join it. | 1086 | // and if so, then join it. |
1082 | FluxboxWindow *otherwin = 0; | 1087 | FluxboxWindow *otherwin = 0; |
@@ -1108,7 +1113,6 @@ FluxboxWindow *BScreen::createWindow(WinClient &client) { | |||
1108 | // don't add to focused_list, as it should already be in there (since the | 1113 | // don't add to focused_list, as it should already be in there (since the |
1109 | // WinClient already exists). | 1114 | // WinClient already exists). |
1110 | 1115 | ||
1111 | Fluxbox::instance()->saveWindowSearch(client.window(), win); | ||
1112 | Fluxbox::instance()->attachSignals(*win); | 1116 | Fluxbox::instance()->attachSignals(*win); |
1113 | // winclient actions should have been setup when the WinClient was created | 1117 | // winclient actions should have been setup when the WinClient was created |
1114 | if (win->workspaceNumber() == currentWorkspaceID() || win->isStuck()) { | 1118 | if (win->workspaceNumber() == currentWorkspaceID() || win->isStuck()) { |
@@ -1213,16 +1217,8 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, | |||
1213 | 1217 | ||
1214 | 1218 | ||
1215 | void BScreen::nextFocus(int opts) { | 1219 | void BScreen::nextFocus(int opts) { |
1216 | bool have_focused = false; | ||
1217 | FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); | ||
1218 | const int num_windows = currentWorkspace()->numberOfWindows(); | 1220 | const int num_windows = currentWorkspace()->numberOfWindows(); |
1219 | 1221 | ||
1220 | if (focused != 0) { | ||
1221 | if (focused->screen().screenNumber() == screenNumber()) { | ||
1222 | have_focused = true; | ||
1223 | } | ||
1224 | } | ||
1225 | |||
1226 | if (num_windows >= 1) { | 1222 | if (num_windows >= 1) { |
1227 | if (!(opts & CYCLELINEAR)) { | 1223 | if (!(opts & CYCLELINEAR)) { |
1228 | if (!cycling_focus) { | 1224 | if (!cycling_focus) { |
@@ -1272,16 +1268,30 @@ void BScreen::nextFocus(int opts) { | |||
1272 | } | 1268 | } |
1273 | cycling_window = it; | 1269 | cycling_window = it; |
1274 | } else { // not stacked cycling | 1270 | } else { // not stacked cycling |
1271 | // I really don't like this, but evidently some people use it(!) | ||
1275 | Workspace *wksp = currentWorkspace(); | 1272 | Workspace *wksp = currentWorkspace(); |
1276 | Workspace::Windows &wins = wksp->windowList(); | 1273 | Workspace::Windows &wins = wksp->windowList(); |
1277 | Workspace::Windows::iterator it = wins.begin(); | 1274 | Workspace::Windows::iterator it = wins.begin(); |
1278 | 1275 | ||
1276 | FluxboxWindow *focused_group = 0; | ||
1277 | // start from the focused window | ||
1278 | bool have_focused = false; | ||
1279 | WinClient *focused = Fluxbox::instance()->getFocusedWindow(); | ||
1280 | if (focused != 0) { | ||
1281 | if (focused->screen().screenNumber() == screenNumber()) { | ||
1282 | have_focused = true; | ||
1283 | focused_group = focused->fbwindow(); | ||
1284 | } | ||
1285 | } | ||
1286 | |||
1279 | if (!have_focused) { | 1287 | if (!have_focused) { |
1280 | focused = (*it); | 1288 | focused_group = (*it); |
1281 | } else { | 1289 | } else { |
1282 | for (; (*it) != focused; ++it) //get focused window iterator | 1290 | //get focused window iterator |
1291 | for (; it != wins.end() && (*it) != focused_group; ++it) | ||
1283 | continue; | 1292 | continue; |
1284 | } | 1293 | } |
1294 | |||
1285 | do { | 1295 | do { |
1286 | ++it; | 1296 | ++it; |
1287 | if (it == wins.end()) | 1297 | if (it == wins.end()) |
@@ -1289,8 +1299,8 @@ void BScreen::nextFocus(int opts) { | |||
1289 | // see if the window should be skipped | 1299 | // see if the window should be skipped |
1290 | if (! (doSkipWindow((*it)->winClient(), opts) || !(*it)->setInputFocus()) ) | 1300 | if (! (doSkipWindow((*it)->winClient(), opts) || !(*it)->setInputFocus()) ) |
1291 | break; | 1301 | break; |
1292 | } while ((*it) != focused); | 1302 | } while ((*it) != focused_group); |
1293 | if ((*it) != focused && it != wins.end()) | 1303 | if ((*it) != focused_group && it != wins.end()) |
1294 | (*it)->raise(); | 1304 | (*it)->raise(); |
1295 | } | 1305 | } |
1296 | 1306 | ||
@@ -1300,16 +1310,8 @@ void BScreen::nextFocus(int opts) { | |||
1300 | 1310 | ||
1301 | 1311 | ||
1302 | void BScreen::prevFocus(int opts) { | 1312 | void BScreen::prevFocus(int opts) { |
1303 | bool have_focused = false; | ||
1304 | FluxboxWindow *focused; | ||
1305 | int num_windows = currentWorkspace()->numberOfWindows(); | 1313 | int num_windows = currentWorkspace()->numberOfWindows(); |
1306 | 1314 | ||
1307 | if ((focused = Fluxbox::instance()->getFocusedWindow())) { | ||
1308 | if (focused->screen().screenNumber() == screenNumber()) { | ||
1309 | have_focused = true; | ||
1310 | } | ||
1311 | } | ||
1312 | |||
1313 | if (num_windows >= 1) { | 1315 | if (num_windows >= 1) { |
1314 | if (!(opts & CYCLELINEAR)) { | 1316 | if (!(opts & CYCLELINEAR)) { |
1315 | if (!cycling_focus) { | 1317 | if (!cycling_focus) { |
@@ -1366,13 +1368,25 @@ void BScreen::prevFocus(int opts) { | |||
1366 | Workspace::Windows &wins = wksp->windowList(); | 1368 | Workspace::Windows &wins = wksp->windowList(); |
1367 | Workspace::Windows::iterator it = wins.begin(); | 1369 | Workspace::Windows::iterator it = wins.begin(); |
1368 | 1370 | ||
1371 | FluxboxWindow *focused_group = 0; | ||
1372 | // start from the focused window | ||
1373 | bool have_focused = false; | ||
1374 | WinClient *focused = Fluxbox::instance()->getFocusedWindow(); | ||
1375 | if (focused != 0) { | ||
1376 | if (focused->screen().screenNumber() == screenNumber()) { | ||
1377 | have_focused = true; | ||
1378 | focused_group = focused->fbwindow(); | ||
1379 | } | ||
1380 | } | ||
1381 | |||
1369 | if (!have_focused) { | 1382 | if (!have_focused) { |
1370 | focused = (*it); | 1383 | focused_group = (*it); |
1371 | } else { | 1384 | } else { |
1372 | for (; (*it) != focused; ++it) //get focused window iterator | 1385 | //get focused window iterator |
1386 | for (; it != wins.end() && (*it) != focused_group; ++it) | ||
1373 | continue; | 1387 | continue; |
1374 | } | 1388 | } |
1375 | 1389 | ||
1376 | do { | 1390 | do { |
1377 | if (it == wins.begin()) | 1391 | if (it == wins.begin()) |
1378 | it = wins.end(); | 1392 | it = wins.end(); |
@@ -1380,9 +1394,9 @@ void BScreen::prevFocus(int opts) { | |||
1380 | // see if the window should be skipped | 1394 | // see if the window should be skipped |
1381 | if (! (doSkipWindow((*it)->winClient(), opts) || !(*it)->setInputFocus()) ) | 1395 | if (! (doSkipWindow((*it)->winClient(), opts) || !(*it)->setInputFocus()) ) |
1382 | break; | 1396 | break; |
1383 | } while ((*it) != focused); | 1397 | } while ((*it) != focused_group); |
1384 | 1398 | ||
1385 | if ((*it) != focused && it != wins.end()) | 1399 | if ((*it) != focused_group && it != wins.end()) |
1386 | (*it)->raise(); | 1400 | (*it)->raise(); |
1387 | } | 1401 | } |
1388 | } | 1402 | } |
@@ -2150,7 +2164,7 @@ bool BScreen::doSkipWindow(const WinClient &winclient, int opts) { | |||
2150 | return (!win || | 2164 | return (!win || |
2151 | (opts & CYCLESKIPSTUCK) != 0 && win->isStuck() || // skip if stuck | 2165 | (opts & CYCLESKIPSTUCK) != 0 && win->isStuck() || // skip if stuck |
2152 | // skip if not active client (i.e. only visit each fbwin once) | 2166 | // skip if not active client (i.e. only visit each fbwin once) |
2153 | (opts & CYCLEGROUPS) != 0 && win->winClient() != winclient.window() || | 2167 | (opts & CYCLEGROUPS) != 0 && win->winClient().window() != winclient.window() || |
2154 | (opts & CYCLESKIPSHADED) != 0 && win->isShaded() // skip if shaded | 2168 | (opts & CYCLESKIPSHADED) != 0 && win->isShaded() // skip if shaded |
2155 | ); | 2169 | ); |
2156 | } | 2170 | } |
@@ -2229,15 +2243,6 @@ WinClient *BScreen::getLastFocusedWindow(int workspace) { | |||
2229 | return 0; | 2243 | return 0; |
2230 | } | 2244 | } |
2231 | 2245 | ||
2232 | /** | ||
2233 | Access and clear the auto-group window | ||
2234 | */ | ||
2235 | FluxboxWindow* BScreen::useAutoGroupWindow() { | ||
2236 | Window w = auto_group_window; | ||
2237 | auto_group_window = 0; | ||
2238 | return w ? Fluxbox::instance()->searchWindow(w) : 0; | ||
2239 | } | ||
2240 | |||
2241 | void BScreen::updateSize() { | 2246 | void BScreen::updateSize() { |
2242 | rootWindow().updateGeometry(); | 2247 | rootWindow().updateGeometry(); |
2243 | 2248 | ||
@@ -2263,16 +2268,19 @@ FluxboxWindow *BScreen::findGroupLeft(WinClient &winclient) { | |||
2263 | if (w == None) | 2268 | if (w == None) |
2264 | return 0; | 2269 | return 0; |
2265 | 2270 | ||
2266 | FluxboxWindow *fbwin = Fluxbox::instance()->searchWindow(w); | 2271 | WinClient *have_client = Fluxbox::instance()->searchWindow(w); |
2267 | 2272 | ||
2268 | if (!fbwin) { | 2273 | if (!have_client) { |
2269 | // not found, add it to expecting | 2274 | // not found, add it to expecting |
2270 | m_expecting_groups[w] = &winclient; | 2275 | m_expecting_groups[w] = &winclient; |
2271 | } else if (&fbwin->screen() != &winclient.screen()) | 2276 | } else if (&have_client->screen() != &winclient.screen()) |
2272 | // something is not consistent | 2277 | // something is not consistent |
2273 | return 0; | 2278 | return 0; |
2274 | 2279 | ||
2275 | return fbwin; | 2280 | if (have_client) |
2281 | return have_client->fbwindow(); | ||
2282 | else | ||
2283 | return 0; | ||
2276 | } | 2284 | } |
2277 | 2285 | ||
2278 | FluxboxWindow *BScreen::findGroupRight(WinClient &winclient) { | 2286 | FluxboxWindow *BScreen::findGroupRight(WinClient &winclient) { |