diff options
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 172 |
1 files changed, 86 insertions, 86 deletions
diff --git a/src/Window.cc b/src/Window.cc index 0b46c07..e4ade8e 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -527,10 +527,11 @@ void FluxboxWindow::init() { | |||
527 | maximize(req_maximized); | 527 | maximize(req_maximized); |
528 | } | 528 | } |
529 | 529 | ||
530 | setFocusFlag(false); // update graphics before mapping | ||
531 | |||
530 | if (stuck) { | 532 | if (stuck) { |
531 | stuck = false; | 533 | stuck = false; |
532 | stick(); | 534 | stick(); |
533 | deiconify(); //we're omnipresent and visible | ||
534 | } | 535 | } |
535 | 536 | ||
536 | if (shaded) { // start shaded | 537 | if (shaded) { // start shaded |
@@ -541,12 +542,13 @@ void FluxboxWindow::init() { | |||
541 | if (iconic) { | 542 | if (iconic) { |
542 | iconic = false; | 543 | iconic = false; |
543 | iconify(); | 544 | iconify(); |
544 | } else | 545 | } else { |
545 | deiconify(false); | 546 | iconic = true; |
547 | if (m_workspace_number == screen().currentWorkspaceID()) | ||
548 | deiconify(false); | ||
549 | } | ||
546 | 550 | ||
547 | sendConfigureNotify(); | 551 | sendConfigureNotify(); |
548 | // no focus default | ||
549 | setFocusFlag(false); | ||
550 | 552 | ||
551 | if (m_shaped) | 553 | if (m_shaped) |
552 | shape(); | 554 | shape(); |
@@ -664,13 +666,13 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { | |||
664 | if (was_focused) { | 666 | if (was_focused) { |
665 | // don't ask me why, but client doesn't seem to keep focus in new window | 667 | // don't ask me why, but client doesn't seem to keep focus in new window |
666 | // and we don't seem to get a FocusIn event from setInputFocus | 668 | // and we don't seem to get a FocusIn event from setInputFocus |
667 | setCurrentClient(client); | 669 | client.focus(); |
668 | FocusControl::setFocusedWindow(&client); | 670 | FocusControl::setFocusedWindow(&client); |
669 | } else { | 671 | } else { |
670 | if (!focused_win) | 672 | if (!focused_win) |
671 | focused_win = screen().focusControl().lastFocusedWindow(*this); | 673 | focused_win = screen().focusControl().lastFocusedWindow(*this); |
672 | if (focused_win) | 674 | if (focused_win) |
673 | setCurrentClient(*focused_win, false); | 675 | focused_win->focus(); |
674 | } | 676 | } |
675 | frame().reconfigure(); | 677 | frame().reconfigure(); |
676 | } | 678 | } |
@@ -1244,29 +1246,26 @@ void FluxboxWindow::resize(unsigned int width, unsigned int height) { | |||
1244 | 1246 | ||
1245 | // send_event is just an override | 1247 | // send_event is just an override |
1246 | void FluxboxWindow::moveResize(int new_x, int new_y, | 1248 | void FluxboxWindow::moveResize(int new_x, int new_y, |
1247 | unsigned int new_width, unsigned int new_height, bool send_event) { | 1249 | unsigned int new_width, unsigned int new_height, |
1250 | bool send_event) { | ||
1248 | 1251 | ||
1249 | // magic to detect if moved during initialisation | 1252 | // magic to detect if moved during initialisation |
1250 | if (!m_initialized) | 1253 | if (!m_initialized) |
1251 | m_old_pos_x = 1; | 1254 | m_old_pos_x = 1; |
1252 | 1255 | ||
1253 | send_event = send_event || (frame().x() != new_x || frame().y() != new_y); | 1256 | send_event = send_event || frame().x() != new_x || frame().y() != new_y; |
1257 | |||
1258 | if ((new_width != frame().width() || new_height != frame().height()) && | ||
1259 | isResizable() && !isShaded()) { | ||
1254 | 1260 | ||
1255 | if (new_width != frame().width() || new_height != frame().height()) { | ||
1256 | if ((((signed) frame().width()) + new_x) < 0) | 1261 | if ((((signed) frame().width()) + new_x) < 0) |
1257 | new_x = 0; | 1262 | new_x = 0; |
1258 | if ((((signed) frame().height()) + new_y) < 0) | 1263 | if ((((signed) frame().height()) + new_y) < 0) |
1259 | new_y = 0; | 1264 | new_y = 0; |
1260 | 1265 | ||
1261 | if (!isResizable()) { | ||
1262 | new_width = width(); | ||
1263 | new_height = height(); | ||
1264 | } | ||
1265 | |||
1266 | frame().moveResize(new_x, new_y, new_width, new_height); | 1266 | frame().moveResize(new_x, new_y, new_width, new_height); |
1267 | setFocusFlag(m_focused); | 1267 | setFocusFlag(m_focused); |
1268 | 1268 | ||
1269 | shaded = false; | ||
1270 | send_event = true; | 1269 | send_event = true; |
1271 | } else if (send_event) | 1270 | } else if (send_event) |
1272 | frame().move(new_x, new_y); | 1271 | frame().move(new_x, new_y); |
@@ -1362,10 +1361,13 @@ bool FluxboxWindow::focus() { | |||
1362 | return false; | 1361 | return false; |
1363 | 1362 | ||
1364 | if (screen().currentWorkspaceID() != workspaceNumber() && !isStuck()) { | 1363 | if (screen().currentWorkspaceID() != workspaceNumber() && !isStuck()) { |
1365 | menu().hide(); | 1364 | |
1366 | BScreen::FollowModel model = screen().getUserFollowModel(); | 1365 | BScreen::FollowModel model = screen().getUserFollowModel(); |
1367 | if (model == BScreen::IGNORE_OTHER_WORKSPACES) | 1366 | if (model == BScreen::IGNORE_OTHER_WORKSPACES) { |
1367 | Fluxbox::instance()->attentionHandler().addAttention(*this); | ||
1368 | return false; | 1368 | return false; |
1369 | } | ||
1370 | |||
1369 | // fetch the window to the current workspace | 1371 | // fetch the window to the current workspace |
1370 | if (model == BScreen::FETCH_ACTIVE_WINDOW || | 1372 | if (model == BScreen::FETCH_ACTIVE_WINDOW || |
1371 | (isIconic() && model == BScreen::SEMIFOLLOW_ACTIVE_WINDOW)) | 1373 | (isIconic() && model == BScreen::SEMIFOLLOW_ACTIVE_WINDOW)) |
@@ -1375,8 +1377,17 @@ bool FluxboxWindow::focus() { | |||
1375 | screen().changeWorkspaceID(workspaceNumber()); | 1377 | screen().changeWorkspaceID(workspaceNumber()); |
1376 | } | 1378 | } |
1377 | 1379 | ||
1378 | if (isIconic()) | 1380 | FluxboxWindow *cur = FocusControl::focusedFbWindow(); |
1381 | if (cur && cur != this && cur->isFullscreen()) { | ||
1382 | Fluxbox::instance()->attentionHandler().addAttention(*this); | ||
1383 | return false; | ||
1384 | } | ||
1385 | |||
1386 | if (isIconic()) { | ||
1379 | deiconify(); | 1387 | deiconify(); |
1388 | m_focused = true; // signal to mapNotifyEvent to set focus when mapped | ||
1389 | return true; // the window probably will get focused, just not yet | ||
1390 | } | ||
1380 | 1391 | ||
1381 | // this needs to be here rather than setFocusFlag because | 1392 | // this needs to be here rather than setFocusFlag because |
1382 | // FocusControl::revertFocus will return before FocusIn events arrive | 1393 | // FocusControl::revertFocus will return before FocusIn events arrive |
@@ -1443,8 +1454,11 @@ void FluxboxWindow::hide(bool interrupt_moving) { | |||
1443 | attachTo(0, 0, true); | 1454 | attachTo(0, 0, true); |
1444 | } | 1455 | } |
1445 | 1456 | ||
1457 | setState(IconicState, false); | ||
1458 | |||
1446 | menu().hide(); | 1459 | menu().hide(); |
1447 | frame().hide(); | 1460 | frame().hide(); |
1461 | |||
1448 | } | 1462 | } |
1449 | 1463 | ||
1450 | void FluxboxWindow::show() { | 1464 | void FluxboxWindow::show() { |
@@ -1550,9 +1564,12 @@ void FluxboxWindow::deiconify(bool reassoc, bool do_raise) { | |||
1550 | show(); | 1564 | show(); |
1551 | 1565 | ||
1552 | // focus new, OR if it's the only window on the workspace | 1566 | // focus new, OR if it's the only window on the workspace |
1553 | if (was_iconic && (screen().focusControl().focusNew() || screen().currentWorkspace()->numberOfWindows() == 1)) | 1567 | // but not on startup: focus will be handled after creating everything |
1554 | focus(); | 1568 | // we use m_focused as a signal to focus the window when mapped |
1555 | 1569 | if (was_iconic && !Fluxbox::instance()->isStartup() && | |
1570 | (screen().focusControl().focusNew() || m_client->isTransient() || | ||
1571 | screen().currentWorkspace()->numberOfWindows() == 1)) | ||
1572 | m_focused = true; | ||
1556 | 1573 | ||
1557 | oplock = false; | 1574 | oplock = false; |
1558 | 1575 | ||
@@ -1817,22 +1834,11 @@ void FluxboxWindow::shade() { | |||
1817 | if (m_initialized && m_frame.isShaded() == shaded) | 1834 | if (m_initialized && m_frame.isShaded() == shaded) |
1818 | frame().shade(); | 1835 | frame().shade(); |
1819 | 1836 | ||
1820 | if (shaded) { | 1837 | shaded = !shaded; |
1821 | shaded = false; | 1838 | m_blackbox_attrib.flags ^= ATTRIB_SHADED; |
1822 | m_blackbox_attrib.flags ^= ATTRIB_SHADED; | 1839 | m_blackbox_attrib.attrib ^= ATTRIB_SHADED; |
1823 | m_blackbox_attrib.attrib ^= ATTRIB_SHADED; | ||
1824 | |||
1825 | if (m_initialized) | ||
1826 | setState(NormalState, false); | ||
1827 | } else { | ||
1828 | shaded = true; | ||
1829 | m_blackbox_attrib.flags |= ATTRIB_SHADED; | ||
1830 | m_blackbox_attrib.attrib |= ATTRIB_SHADED; | ||
1831 | // shading is the same as iconic | ||
1832 | if (m_initialized) | ||
1833 | setState(IconicState, false); | ||
1834 | } | ||
1835 | 1840 | ||
1841 | // TODO: this should set IconicState, but then we can't focus the window | ||
1836 | } | 1842 | } |
1837 | 1843 | ||
1838 | void FluxboxWindow::shadeOn() { | 1844 | void FluxboxWindow::shadeOn() { |
@@ -1851,19 +1857,9 @@ void FluxboxWindow::shadeOff() { | |||
1851 | 1857 | ||
1852 | void FluxboxWindow::stick() { | 1858 | void FluxboxWindow::stick() { |
1853 | 1859 | ||
1854 | if (stuck) { | 1860 | m_blackbox_attrib.flags ^= ATTRIB_OMNIPRESENT; |
1855 | m_blackbox_attrib.flags ^= ATTRIB_OMNIPRESENT; | 1861 | m_blackbox_attrib.attrib ^= ATTRIB_OMNIPRESENT; |
1856 | m_blackbox_attrib.attrib ^= ATTRIB_OMNIPRESENT; | 1862 | stuck = !stuck; |
1857 | |||
1858 | stuck = false; | ||
1859 | |||
1860 | } else { | ||
1861 | stuck = true; | ||
1862 | |||
1863 | m_blackbox_attrib.flags |= ATTRIB_OMNIPRESENT; | ||
1864 | m_blackbox_attrib.attrib |= ATTRIB_OMNIPRESENT; | ||
1865 | |||
1866 | } | ||
1867 | 1863 | ||
1868 | if (m_initialized) { | 1864 | if (m_initialized) { |
1869 | setState(m_current_state, false); | 1865 | setState(m_current_state, false); |
@@ -2097,24 +2093,32 @@ void FluxboxWindow::saveBlackboxAttribs() { | |||
2097 | That'll happen when its mapped | 2093 | That'll happen when its mapped |
2098 | */ | 2094 | */ |
2099 | void FluxboxWindow::setState(unsigned long new_state, bool setting_up) { | 2095 | void FluxboxWindow::setState(unsigned long new_state, bool setting_up) { |
2100 | if (numClients() == 0) | 2096 | m_current_state = new_state; |
2097 | if (numClients() == 0 || setting_up) | ||
2101 | return; | 2098 | return; |
2102 | 2099 | ||
2103 | m_current_state = new_state; | 2100 | unsigned long state[2]; |
2104 | if (!setting_up) { | 2101 | state[0] = (unsigned long) m_current_state; |
2105 | unsigned long state[2]; | 2102 | state[1] = (unsigned long) None; |
2106 | state[0] = (unsigned long) m_current_state; | ||
2107 | state[1] = (unsigned long) None; | ||
2108 | 2103 | ||
2109 | for_each(m_clientlist.begin(), m_clientlist.end(), | 2104 | for_each(m_clientlist.begin(), m_clientlist.end(), |
2110 | FbTk::ChangeProperty(display, FbAtoms::instance()->getWMStateAtom(), | 2105 | FbTk::ChangeProperty(display, |
2111 | PropModeReplace, | 2106 | FbAtoms::instance()->getWMStateAtom(), |
2112 | (unsigned char *)state, 2)); | 2107 | PropModeReplace, |
2108 | (unsigned char *)state, 2)); | ||
2113 | 2109 | ||
2114 | saveBlackboxAttribs(); | 2110 | ClientList::iterator it = clientList().begin(); |
2115 | //notify state changed | 2111 | ClientList::iterator it_end = clientList().end(); |
2116 | m_statesig.notify(); | 2112 | for (; it != it_end; ++it) { |
2113 | if (new_state == IconicState) | ||
2114 | (*it)->hide(); | ||
2115 | else if (new_state == NormalState) | ||
2116 | (*it)->show(); | ||
2117 | } | 2117 | } |
2118 | |||
2119 | saveBlackboxAttribs(); | ||
2120 | //notify state changed | ||
2121 | m_statesig.notify(); | ||
2118 | } | 2122 | } |
2119 | 2123 | ||
2120 | bool FluxboxWindow::getState() { | 2124 | bool FluxboxWindow::getState() { |
@@ -2374,33 +2378,25 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) { | |||
2374 | 2378 | ||
2375 | void FluxboxWindow::mapNotifyEvent(XMapEvent &ne) { | 2379 | void FluxboxWindow::mapNotifyEvent(XMapEvent &ne) { |
2376 | WinClient *client = findClient(ne.window); | 2380 | WinClient *client = findClient(ne.window); |
2377 | if (client == 0) | 2381 | if (!client || client != m_client) |
2378 | return; | 2382 | return; |
2379 | #ifdef DEBUG | ||
2380 | cerr<<"FluxboxWindow::mapNotifyEvent: " | ||
2381 | <<"ne.override_redirect = "<<ne.override_redirect | ||
2382 | <<" isVisible() = "<<isVisible()<<endl; | ||
2383 | #endif // DEBUG | ||
2384 | 2383 | ||
2385 | if (!ne.override_redirect && isVisible()) { | 2384 | if (ne.override_redirect || !isVisible() || !client->validateClient()) |
2386 | #ifdef DEBUG | 2385 | return; |
2387 | cerr<<"FluxboxWindow::mapNotify: not override redirect ans visible!"<<endl; | ||
2388 | #endif // DEBUG | ||
2389 | if (! client->validateClient()) | ||
2390 | return; | ||
2391 | 2386 | ||
2392 | setState(NormalState, false); | 2387 | iconic = false; |
2393 | 2388 | ||
2394 | FluxboxWindow *cur = FocusControl::focusedFbWindow(); | 2389 | // setting state will cause all tabs to be mapped, but we only want the |
2395 | if (client->isTransient() || | 2390 | // original tab to be focused |
2396 | m_screen.currentWorkspace()->numberOfWindows() == 1 || | 2391 | if (m_current_state != NormalState) |
2397 | m_screen.focusControl().focusNew() && !(cur && cur->isFullscreen())) | 2392 | setState(NormalState, false); |
2398 | setCurrentClient(*client, true); | ||
2399 | else if (m_screen.focusControl().focusNew()) | ||
2400 | Fluxbox::instance()->attentionHandler().addAttention(*client); | ||
2401 | 2393 | ||
2402 | iconic = false; | 2394 | // we use m_focused as a signal that this should be focused when mapped |
2395 | if (isFocused()) { | ||
2396 | m_focused = false; | ||
2397 | focus(); | ||
2403 | } | 2398 | } |
2399 | |||
2404 | } | 2400 | } |
2405 | 2401 | ||
2406 | /** | 2402 | /** |
@@ -2417,7 +2413,11 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent &ue) { | |||
2417 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): title="<<client->title()<<endl; | 2413 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): title="<<client->title()<<endl; |
2418 | #endif // DEBUG | 2414 | #endif // DEBUG |
2419 | 2415 | ||
2420 | restore(client, false); | 2416 | // if window was in IconicState, then this event could have come from us |
2417 | // unmapping the window -- but if send_event is set, then the client wants | ||
2418 | // to be withdrawn | ||
2419 | if (m_current_state == NormalState || ue.send_event) | ||
2420 | restore(client, false); | ||
2421 | 2421 | ||
2422 | } | 2422 | } |
2423 | 2423 | ||
@@ -2776,7 +2776,7 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2776 | XWarpPointer(display, None, me.root, 0, 0, 0, 0, | 2776 | XWarpPointer(display, None, me.root, 0, 0, 0, 0, |
2777 | m_last_resize_x, m_last_resize_y); | 2777 | m_last_resize_x, m_last_resize_y); |
2778 | 2778 | ||
2779 | screen().changeWorkspaceID(new_id); | 2779 | screen().sendToWorkspace(new_id, this, true); |
2780 | } | 2780 | } |
2781 | } | 2781 | } |
2782 | 2782 | ||