aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-06-23 14:16:05 (GMT)
committerrathnor <rathnor>2003-06-23 14:16:05 (GMT)
commit09a5c23c5b099af531842ae7868e98bc8d717dac (patch)
treecf5ea34c09ee3d16ddc2e9abfc1bd2880a94067d /src/Screen.cc
parent2e6baffb9bf988901f9fa02f651efc9b2528d7b5 (diff)
downloadfluxbox_pavel-09a5c23c5b099af531842ae7868e98bc8d717dac.zip
fluxbox_pavel-09a5c23c5b099af531842ae7868e98bc8d717dac.tar.bz2
fix grouping to persist over restart, plus various related bugs.
Also move a large proportion of window initialisation from FluxboxWindow to WinClient
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc112
1 files changed, 99 insertions, 13 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 7337b9f..c8a2344 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.189 2003/06/23 13:31:47 fluxgen Exp $ 25// $Id: Screen.cc,v 1.190 2003/06/23 14:16:04 rathnor Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
@@ -835,6 +835,16 @@ void BScreen::removeClient(WinClient &client) {
835 for_each(getWorkspacesList().begin(), getWorkspacesList().end(), 835 for_each(getWorkspacesList().begin(), getWorkspacesList().end(),
836 mem_fun(&Workspace::updateClientmenu)); 836 mem_fun(&Workspace::updateClientmenu));
837 837
838 // remove any grouping this is expecting
839 Groupables::iterator it = m_expecting_groups.begin();
840 Groupables::iterator it_end = m_expecting_groups.end();
841 for (; it != it_end; ++it) {
842 if (it->second == &client) {
843 m_expecting_groups.erase(it);
844 // it should only be in there a maximum of once
845 break;
846 }
847 }
838} 848}
839 849
840FluxboxWindow *BScreen::getIcon(unsigned int index) { 850FluxboxWindow *BScreen::getIcon(unsigned int index) {
@@ -1106,23 +1116,31 @@ void BScreen::updateNetizenConfigNotify(XEvent *e) {
1106} 1116}
1107 1117
1108FluxboxWindow *BScreen::createWindow(Window client) { 1118FluxboxWindow *BScreen::createWindow(Window client) {
1109 FluxboxWindow *win = new FluxboxWindow(client, *this, 1119 WinClient *winclient = new WinClient(client, *this);
1110 winFrameTheme(), *menuTheme(), 1120
1111 *layerManager().getLayer(Fluxbox::instance()->getNormalLayer()));
1112
1113#ifdef SLIT 1121#ifdef SLIT
1114 if (win->initialState() == WithdrawnState) { 1122 if (winclient->initial_state == WithdrawnState) {
1115 delete win; 1123 delete winclient;
1116 win = 0;
1117 slit()->addClient(client); 1124 slit()->addClient(client);
1118 return 0; 1125 return 0;
1119 } 1126 }
1120#endif // SLIT 1127#endif // SLIT
1121 1128
1129 // check if it should be grouped with something else
1130 FluxboxWindow *win;
1131 if ((win = findGroupLeft(*winclient)) != 0) {
1132 win->attachClient(*winclient);
1133 } else {
1134 win = new FluxboxWindow(*winclient, *this,
1135 winFrameTheme(), *menuTheme(),
1136 *layerManager().getLayer(Fluxbox::instance()->getNormalLayer()));
1137 }
1138
1122 if (!win->isManaged()) { 1139 if (!win->isManaged()) {
1123 delete win; 1140 delete win;
1124 return 0; 1141 return 0;
1125 } else { 1142 } else {
1143
1126 // always put on end of focused list, if it gets focused it'll get pushed up 1144 // always put on end of focused list, if it gets focused it'll get pushed up
1127 // there is only the one win client at this stage 1145 // there is only the one win client at this stage
1128 if (doFocusNew()) 1146 if (doFocusNew())
@@ -1135,9 +1153,18 @@ FluxboxWindow *BScreen::createWindow(Window client) {
1135 setupWindowActions(*win); 1153 setupWindowActions(*win);
1136 Fluxbox::instance()->attachSignals(*win); 1154 Fluxbox::instance()->attachSignals(*win);
1137 } 1155 }
1138 if (win->workspaceNumber() == currentWorkspaceID() || win->isStuck()) { 1156
1157 // we also need to check if another window expects this window to the left
1158 // and if so, then join it.
1159 FluxboxWindow *otherwin = 0;
1160 // TODO: does this do the right stuff focus-wise?
1161 if ((otherwin = findGroupRight(*winclient)) && otherwin != win)
1162 win->attachClient(otherwin->winClient());
1163
1164 if (!win->isIconic() && (win->workspaceNumber() == currentWorkspaceID() || win->isStuck())) {
1139 win->show(); 1165 win->show();
1140 } 1166 }
1167
1141 XSync(FbTk::App::instance()->display(), False); 1168 XSync(FbTk::App::instance()->display(), False);
1142 return win; 1169 return win;
1143} 1170}
@@ -2349,10 +2376,16 @@ void BScreen::notifyReleasedKeys(XKeyEvent &ke) {
2349 cycling_focus = false; 2376 cycling_focus = false;
2350 cycling_last = 0; 2377 cycling_last = 0;
2351 // put currently focused window to top 2378 // put currently focused window to top
2352 WinClient *client = *cycling_window; 2379 // the iterator may be invalid if the window died
2353 focused_list.erase(cycling_window); 2380 // in which case we'll do a proper revert focus
2354 focused_list.push_front(client); 2381 if (cycling_window != focused_list.end()) {
2355 client->fbwindow()->raise(); 2382 WinClient *client = *cycling_window;
2383 focused_list.erase(cycling_window);
2384 focused_list.push_front(client);
2385 client->fbwindow()->raise();
2386 } else {
2387 Fluxbox::instance()->revertFocus(*this);
2388 }
2356 } 2389 }
2357} 2390}
2358 2391
@@ -2407,6 +2440,45 @@ void BScreen::updateSize() {
2407} 2440}
2408 2441
2409 2442
2443/**
2444 * Find the group of windows to this window's left
2445 * So, we check the leftgroup hint, and see if we know any windows
2446 */
2447FluxboxWindow *BScreen::findGroupLeft(WinClient &winclient) {
2448 Window w = winclient.getGroupLeftWindow();
2449 if (w == None)
2450 return 0;
2451
2452 FluxboxWindow *fbwin = Fluxbox::instance()->searchWindow(w);
2453
2454 if (!fbwin) {
2455 // not found, add it to expecting
2456 m_expecting_groups[w] = &winclient;
2457 } else if (&fbwin->screen() != &winclient.screen())
2458 // something is not consistent
2459 return 0;
2460
2461 return fbwin;
2462}
2463
2464FluxboxWindow *BScreen::findGroupRight(WinClient &winclient) {
2465 Groupables::iterator it = m_expecting_groups.find(winclient.window());
2466 if (it == m_expecting_groups.end())
2467 return 0;
2468
2469 // yay, this'll do.
2470 WinClient *other = it->second;
2471 m_expecting_groups.erase(it); // don't expect it anymore
2472
2473 // forget about it if it isn't the left-most client in the group, plus
2474 // it must have the atom set on it (i.e. previously encountered by fluxbox)
2475 // for us to check our expecting
2476 if (!winclient.hasGroupLeftWindow() ||
2477 other->getGroupLeftWindow() != None)
2478 return 0;
2479
2480 return other->m_win;
2481}
2410void BScreen::initXinerama() { 2482void BScreen::initXinerama() {
2411#ifdef XINERAMA 2483#ifdef XINERAMA
2412 Display *display = FbTk::App::instance()->display(); 2484 Display *display = FbTk::App::instance()->display();
@@ -2544,3 +2616,17 @@ void BScreen::setOnHead<Toolbar>(Toolbar &tbar, int head) {
2544 tbar.reconfigure(); 2616 tbar.reconfigure();
2545} 2617}
2546 2618
2619// TODO: when toolbar gets its resources moved into Toolbar.hh/cc, then
2620// this can be gone and a consistent interface for the two used
2621// on the actual objects
2622template <>
2623int BScreen::getOnHead<Slit>(Slit &slit) {
2624 return slit.getOnHead();
2625}
2626
2627template <>
2628void BScreen::setOnHead<Slit>(Slit &slit, int head) {
2629 slit.saveOnHead(head);
2630 slit.reconfigure();
2631}
2632