diff options
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 113 |
1 files changed, 27 insertions, 86 deletions
diff --git a/src/Window.cc b/src/Window.cc index ac2333b..70d1ee1 100644 --- a/src/Window.cc +++ b/src/Window.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: Window.cc,v 1.212 2003/07/28 12:49:18 fluxgen Exp $ | 25 | // $Id: Window.cc,v 1.213 2003/07/28 15:06:34 rathnor Exp $ |
26 | 26 | ||
27 | #include "Window.hh" | 27 | #include "Window.hh" |
28 | 28 | ||
@@ -262,7 +262,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client, BScreen &scr, FbWinFrameTheme &t | |||
262 | m_old_decoration(DECOR_NORMAL), | 262 | m_old_decoration(DECOR_NORMAL), |
263 | m_client(&client), | 263 | m_client(&client), |
264 | m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)), | 264 | m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)), |
265 | m_strut(0), | ||
266 | m_layeritem(m_frame->window(), layer), | 265 | m_layeritem(m_frame->window(), layer), |
267 | m_layernum(layer.getLayerNum()), | 266 | m_layernum(layer.getLayerNum()), |
268 | m_parent(scr.rootWindow()) { | 267 | m_parent(scr.rootWindow()) { |
@@ -279,15 +278,13 @@ FluxboxWindow::~FluxboxWindow() { | |||
279 | cerr<<__FILE__<<"("<<__LINE__<<"): m_labelbuttons.size = "<<m_labelbuttons.size()<<endl; | 278 | cerr<<__FILE__<<"("<<__LINE__<<"): m_labelbuttons.size = "<<m_labelbuttons.size()<<endl; |
280 | #endif // DEBUG | 279 | #endif // DEBUG |
281 | 280 | ||
282 | clearStrut(); | ||
283 | |||
284 | if (moving || resizing || m_attaching_tab) { | 281 | if (moving || resizing || m_attaching_tab) { |
285 | screen().hideGeometry(); | 282 | screen().hideGeometry(); |
286 | XUngrabPointer(display, CurrentTime); | 283 | XUngrabPointer(display, CurrentTime); |
287 | } | 284 | } |
288 | 285 | ||
289 | // no longer a valid window to do stuff with | 286 | // no longer a valid window to do stuff with |
290 | Fluxbox::instance()->removeWindowSearch(frame().window().window()); | 287 | Fluxbox::instance()->removeWindowSearchGroup(frame().window().window()); |
291 | 288 | ||
292 | Client2ButtonMap::iterator it = m_labelbuttons.begin(); | 289 | Client2ButtonMap::iterator it = m_labelbuttons.begin(); |
293 | Client2ButtonMap::iterator it_end = m_labelbuttons.end(); | 290 | Client2ButtonMap::iterator it_end = m_labelbuttons.end(); |
@@ -421,20 +418,15 @@ void FluxboxWindow::init() { | |||
421 | 418 | ||
422 | 419 | ||
423 | functions.resize = functions.move = functions.iconify = functions.maximize = true; | 420 | functions.resize = functions.move = functions.iconify = functions.maximize = true; |
424 | functions.close = decorations.close = false; | 421 | decorations.close = false; |
422 | |||
423 | functions.close = m_client->isClosable(); | ||
425 | 424 | ||
426 | if (m_client->getBlackboxHint() != 0) | 425 | if (m_client->getBlackboxHint() != 0) |
427 | getBlackboxHints(); | 426 | getBlackboxHints(); |
428 | else | 427 | else |
429 | getMWMHints(); | 428 | getMWMHints(); |
430 | 429 | ||
431 | // get size, aspect, minimum/maximum size and other hints set | ||
432 | // by the client | ||
433 | |||
434 | getWMProtocols(); | ||
435 | if (m_client->window_group != None) | ||
436 | Fluxbox::instance()->saveGroupSearch(m_client->window_group, this); | ||
437 | |||
438 | //!! | 430 | //!! |
439 | // fetch client size and placement | 431 | // fetch client size and placement |
440 | XWindowAttributes wattrib; | 432 | XWindowAttributes wattrib; |
@@ -448,8 +440,6 @@ void FluxboxWindow::init() { | |||
448 | m_client->old_bw = wattrib.border_width; | 440 | m_client->old_bw = wattrib.border_width; |
449 | m_client->x = wattrib.x; m_client->y = wattrib.y; | 441 | m_client->x = wattrib.x; m_client->y = wattrib.y; |
450 | 442 | ||
451 | fluxbox.saveWindowSearch(frame().window().window(), this); | ||
452 | |||
453 | m_timer.setTimeout(fluxbox.getAutoRaiseDelay()); | 443 | m_timer.setTimeout(fluxbox.getAutoRaiseDelay()); |
454 | m_timer.fireOnce(true); | 444 | m_timer.fireOnce(true); |
455 | 445 | ||
@@ -458,6 +448,8 @@ void FluxboxWindow::init() { | |||
458 | } | 448 | } |
459 | 449 | ||
460 | m_managed = true; //this window is managed | 450 | m_managed = true; //this window is managed |
451 | |||
452 | Fluxbox::instance()->saveWindowSearchGroup(frame().window().window(), this); | ||
461 | 453 | ||
462 | // update transient infomation | 454 | // update transient infomation |
463 | m_client->updateTransientInfo(); | 455 | m_client->updateTransientInfo(); |
@@ -603,13 +595,11 @@ void FluxboxWindow::attachClient(WinClient &client) { | |||
603 | if (client.fbwindow() != 0) { | 595 | if (client.fbwindow() != 0) { |
604 | FluxboxWindow *old_win = client.fbwindow(); // store old window | 596 | FluxboxWindow *old_win = client.fbwindow(); // store old window |
605 | 597 | ||
606 | Fluxbox *fb = Fluxbox::instance(); | ||
607 | // make sure we set new window search for each client | 598 | // make sure we set new window search for each client |
608 | ClientList::iterator client_it = old_win->clientList().begin(); | 599 | ClientList::iterator client_it = old_win->clientList().begin(); |
609 | ClientList::iterator client_it_end = old_win->clientList().end(); | 600 | ClientList::iterator client_it_end = old_win->clientList().end(); |
610 | for (; client_it != client_it_end; ++client_it) { | 601 | for (; client_it != client_it_end; ++client_it) { |
611 | // setup eventhandlers for client | 602 | // setup eventhandlers for client |
612 | fb->saveWindowSearch((*client_it)->window(), this); | ||
613 | evm.add(*this, (*client_it)->window()); | 603 | evm.add(*this, (*client_it)->window()); |
614 | 604 | ||
615 | // reparent window to this | 605 | // reparent window to this |
@@ -671,7 +661,6 @@ void FluxboxWindow::attachClient(WinClient &client) { | |||
671 | 661 | ||
672 | client.m_win = this; | 662 | client.m_win = this; |
673 | 663 | ||
674 | Fluxbox::instance()->saveWindowSearch(client.window(), this); | ||
675 | client.saveBlackboxAttribs(m_blackbox_attrib); | 664 | client.saveBlackboxAttribs(m_blackbox_attrib); |
676 | m_clientlist.push_back(&client); | 665 | m_clientlist.push_back(&client); |
677 | } | 666 | } |
@@ -993,30 +982,6 @@ void FluxboxWindow::updateIconNameFromClient() { | |||
993 | } | 982 | } |
994 | 983 | ||
995 | 984 | ||
996 | void FluxboxWindow::getWMProtocols() { | ||
997 | Atom *proto = 0; | ||
998 | int num_return = 0; | ||
999 | FbAtoms *fbatoms = FbAtoms::instance(); | ||
1000 | |||
1001 | if (XGetWMProtocols(display, m_client->window(), &proto, &num_return)) { | ||
1002 | |||
1003 | for (int i = 0; i < num_return; ++i) { | ||
1004 | if (proto[i] == fbatoms->getWMDeleteAtom()) | ||
1005 | functions.close = true; | ||
1006 | else if (proto[i] == fbatoms->getWMTakeFocusAtom()) | ||
1007 | m_client->send_focus_message = true; | ||
1008 | else if (proto[i] == fbatoms->getFluxboxStructureMessagesAtom()) | ||
1009 | screen().addNetizen(m_client->window()); | ||
1010 | } | ||
1011 | |||
1012 | XFree(proto); | ||
1013 | } else { | ||
1014 | cerr<<"Warning: Failed to read WM Protocols. "<<endl; | ||
1015 | } | ||
1016 | |||
1017 | } | ||
1018 | |||
1019 | |||
1020 | void FluxboxWindow::getMWMHints() { | 985 | void FluxboxWindow::getMWMHints() { |
1021 | const WinClient::MwmHints *hint = m_client->getMwmHint(); | 986 | const WinClient::MwmHints *hint = m_client->getMwmHint(); |
1022 | 987 | ||
@@ -1185,7 +1150,7 @@ bool FluxboxWindow::setInputFocus() { | |||
1185 | } | 1150 | } |
1186 | } | 1151 | } |
1187 | 1152 | ||
1188 | if (! validateClient()) | 1153 | if (! m_client->validateClient()) |
1189 | return false; | 1154 | return false; |
1190 | 1155 | ||
1191 | if (!m_client->transients.empty() && m_client->isModal()) { | 1156 | if (!m_client->transients.empty() && m_client->isModal()) { |
@@ -1256,7 +1221,9 @@ void FluxboxWindow::iconify() { | |||
1256 | (*it)->fbwindow()->iconify(); | 1221 | (*it)->fbwindow()->iconify(); |
1257 | } | 1222 | } |
1258 | } | 1223 | } |
1259 | if (Fluxbox::instance()->getFocusedWindow() == this) | 1224 | |
1225 | WinClient *focused_client = Fluxbox::instance()->getFocusedWindow(); | ||
1226 | if (focused_client && focused_client->fbwindow() == this) | ||
1260 | Fluxbox::instance()->revertFocus(screen()); | 1227 | Fluxbox::instance()->revertFocus(screen()); |
1261 | 1228 | ||
1262 | } | 1229 | } |
@@ -1319,16 +1286,6 @@ void FluxboxWindow::deiconify(bool reassoc, bool do_raise) { | |||
1319 | } | 1286 | } |
1320 | 1287 | ||
1321 | /** | 1288 | /** |
1322 | Send close request to client window | ||
1323 | */ | ||
1324 | void FluxboxWindow::close() { | ||
1325 | #ifdef DEBUG | ||
1326 | cerr<<__FILE__<<"("<<__FUNCTION__<<")"<<endl; | ||
1327 | #endif // DEBUG | ||
1328 | m_client->sendClose(); | ||
1329 | } | ||
1330 | |||
1331 | /** | ||
1332 | Set window in withdrawn state | 1289 | Set window in withdrawn state |
1333 | */ | 1290 | */ |
1334 | void FluxboxWindow::withdraw() { | 1291 | void FluxboxWindow::withdraw() { |
@@ -1703,7 +1660,7 @@ void FluxboxWindow::installColormap(bool install) { | |||
1703 | 1660 | ||
1704 | Fluxbox *fluxbox = Fluxbox::instance(); | 1661 | Fluxbox *fluxbox = Fluxbox::instance(); |
1705 | fluxbox->grab(); | 1662 | fluxbox->grab(); |
1706 | if (! validateClient()) | 1663 | if (! m_client->validateClient()) |
1707 | return; | 1664 | return; |
1708 | 1665 | ||
1709 | int i = 0, ncmap = 0; | 1666 | int i = 0, ncmap = 0; |
@@ -2151,13 +2108,13 @@ void FluxboxWindow::mapNotifyEvent(XMapEvent &ne) { | |||
2151 | if (!ne.override_redirect && isVisible()) { | 2108 | if (!ne.override_redirect && isVisible()) { |
2152 | Fluxbox *fluxbox = Fluxbox::instance(); | 2109 | Fluxbox *fluxbox = Fluxbox::instance(); |
2153 | fluxbox->grab(); | 2110 | fluxbox->grab(); |
2154 | if (! validateClient()) | 2111 | if (! client->validateClient()) |
2155 | return; | 2112 | return; |
2156 | 2113 | ||
2157 | setState(NormalState); | 2114 | setState(NormalState); |
2158 | 2115 | ||
2159 | if (client->isTransient() || screen().doFocusNew()) { | 2116 | if (client->isTransient() || screen().doFocusNew()) { |
2160 | setInputFocus(); | 2117 | setCurrentClient(*client, true); |
2161 | } | 2118 | } |
2162 | else | 2119 | else |
2163 | setFocusFlag(false); | 2120 | setFocusFlag(false); |
@@ -2197,6 +2154,8 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent &ue) { | |||
2197 | 2154 | ||
2198 | /** | 2155 | /** |
2199 | Checks if event is for m_client->window. | 2156 | Checks if event is for m_client->window. |
2157 | If it isn't, we leave it until the window is unmapped, if it is, | ||
2158 | we just hide it for now. | ||
2200 | */ | 2159 | */ |
2201 | void FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent &de) { | 2160 | void FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent &de) { |
2202 | if (de.window == m_client->window()) { | 2161 | if (de.window == m_client->window()) { |
@@ -2295,7 +2254,7 @@ void FluxboxWindow::propertyNotifyEvent(Atom atom) { | |||
2295 | 2254 | ||
2296 | default: | 2255 | default: |
2297 | if (atom == FbAtoms::instance()->getWMProtocolsAtom()) { | 2256 | if (atom == FbAtoms::instance()->getWMProtocolsAtom()) { |
2298 | getWMProtocols(); | 2257 | m_client->getWMProtocols(); |
2299 | //!!TODO check this area | 2258 | //!!TODO check this area |
2300 | // reset window actions | 2259 | // reset window actions |
2301 | setupWindow(); | 2260 | setupWindow(); |
@@ -2771,18 +2730,6 @@ void FluxboxWindow::toggleDecoration() { | |||
2771 | } | 2730 | } |
2772 | } | 2731 | } |
2773 | 2732 | ||
2774 | void FluxboxWindow::setStrut(Strut *strut) { | ||
2775 | clearStrut(); | ||
2776 | m_strut = strut; | ||
2777 | } | ||
2778 | |||
2779 | void FluxboxWindow::clearStrut() { | ||
2780 | if (m_strut != 0) { | ||
2781 | screen().clearStrut(m_strut); | ||
2782 | m_strut = 0; | ||
2783 | } | ||
2784 | } | ||
2785 | |||
2786 | unsigned int FluxboxWindow::decorationMask() const { | 2733 | unsigned int FluxboxWindow::decorationMask() const { |
2787 | unsigned int ret = 0; | 2734 | unsigned int ret = 0; |
2788 | if (decorations.titlebar) | 2735 | if (decorations.titlebar) |
@@ -2825,21 +2772,6 @@ void FluxboxWindow::setDecorationMask(unsigned int mask) { | |||
2825 | applyDecorations(); | 2772 | applyDecorations(); |
2826 | } | 2773 | } |
2827 | 2774 | ||
2828 | bool FluxboxWindow::validateClient() { | ||
2829 | XSync(display, false); | ||
2830 | |||
2831 | XEvent e; | ||
2832 | if (!m_client || | ||
2833 | ( XCheckTypedWindowEvent(display, m_client->window(), DestroyNotify, &e) || | ||
2834 | XCheckTypedWindowEvent(display, m_client->window(), UnmapNotify, &e)) | ||
2835 | && XPutBackEvent(display, &e)) { | ||
2836 | Fluxbox::instance()->ungrab(); | ||
2837 | return false; | ||
2838 | } | ||
2839 | |||
2840 | return true; | ||
2841 | } | ||
2842 | |||
2843 | void FluxboxWindow::startMoving(Window win) { | 2775 | void FluxboxWindow::startMoving(Window win) { |
2844 | moving = true; | 2776 | moving = true; |
2845 | Fluxbox *fluxbox = Fluxbox::instance(); | 2777 | Fluxbox *fluxbox = Fluxbox::instance(); |
@@ -3096,7 +3028,12 @@ void FluxboxWindow::attachTo(int x, int y) { | |||
3096 | parent().window(), | 3028 | parent().window(), |
3097 | x, y, &dest_x, &dest_y, &child)) { | 3029 | x, y, &dest_x, &dest_y, &child)) { |
3098 | // search for a fluxboxwindow | 3030 | // search for a fluxboxwindow |
3099 | FluxboxWindow *attach_to_win = Fluxbox::instance()->searchWindow(child); | 3031 | WinClient *client = Fluxbox::instance()->searchWindow(child); |
3032 | FluxboxWindow *attach_to_win = 0; | ||
3033 | if (client) | ||
3034 | attach_to_win = client->fbwindow(); | ||
3035 | |||
3036 | cerr<<"client = "<<client<<", child = "<<hex<<child<<dec<<", fbwin = "<<attach_to_win<<endl; | ||
3100 | 3037 | ||
3101 | if (attach_to_win != this && | 3038 | if (attach_to_win != this && |
3102 | attach_to_win != 0) { | 3039 | attach_to_win != 0) { |
@@ -3468,6 +3405,10 @@ void FluxboxWindow::removeExtraMenu(FbTk::Menu *menu) { | |||
3468 | setupWindow(); | 3405 | setupWindow(); |
3469 | } | 3406 | } |
3470 | 3407 | ||
3408 | void FluxboxWindow::close() { | ||
3409 | if (m_client) | ||
3410 | m_client->sendClose(false); | ||
3411 | } | ||
3471 | 3412 | ||
3472 | void FluxboxWindow::setupWindow() { | 3413 | void FluxboxWindow::setupWindow() { |
3473 | // sets up our window | 3414 | // sets up our window |