diff options
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 93 |
1 files changed, 56 insertions, 37 deletions
diff --git a/src/Window.cc b/src/Window.cc index 1eb214a..ce14d08 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -239,7 +239,7 @@ int FluxboxWindow::s_num_grabs = 0; | |||
239 | 239 | ||
240 | FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm, | 240 | FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm, |
241 | FbTk::XLayer &layer): | 241 | FbTk::XLayer &layer): |
242 | Focusable(this), | 242 | Focusable(client.screen(), this), |
243 | oplock(false), | 243 | oplock(false), |
244 | m_hintsig(*this), | 244 | m_hintsig(*this), |
245 | m_statesig(*this), | 245 | m_statesig(*this), |
@@ -247,15 +247,12 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm, | |||
247 | m_workspacesig(*this), | 247 | m_workspacesig(*this), |
248 | m_diesig(*this), | 248 | m_diesig(*this), |
249 | m_focussig(*this), | 249 | m_focussig(*this), |
250 | m_titlesig(*this), | ||
251 | m_attentionsig(*this), | 250 | m_attentionsig(*this), |
252 | m_themelistener(*this), | 251 | m_themelistener(*this), |
253 | moving(false), resizing(false), shaded(false), | 252 | moving(false), resizing(false), shaded(false), iconic(false), |
254 | iconic(false), focused(false), | ||
255 | stuck(false), m_initialized(false), fullscreen(false), | 253 | stuck(false), m_initialized(false), fullscreen(false), |
256 | maximized(MAX_NONE), | 254 | maximized(MAX_NONE), |
257 | m_attaching_tab(0), | 255 | m_attaching_tab(0), |
258 | m_screen(client.screen()), | ||
259 | display(FbTk::App::instance()->display()), | 256 | display(FbTk::App::instance()->display()), |
260 | m_button_grab_x(0), m_button_grab_y(0), | 257 | m_button_grab_x(0), m_button_grab_y(0), |
261 | m_last_move_x(0), m_last_move_y(0), | 258 | m_last_move_x(0), m_last_move_y(0), |
@@ -281,6 +278,17 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm, | |||
281 | tm.reconfigSig().attach(&m_themelistener); | 278 | tm.reconfigSig().attach(&m_themelistener); |
282 | 279 | ||
283 | init(); | 280 | init(); |
281 | |||
282 | if (!isManaged()) | ||
283 | return; | ||
284 | |||
285 | // add the window to the focus list | ||
286 | // always add to front on startup to keep the focus order the same | ||
287 | if (screen().focusControl().focusNew() || Fluxbox::instance()->isStartup()) | ||
288 | screen().focusControl().addFocusWinFront(*this); | ||
289 | else | ||
290 | screen().focusControl().addFocusWinBack(*this); | ||
291 | |||
284 | } | 292 | } |
285 | 293 | ||
286 | 294 | ||
@@ -330,7 +338,9 @@ FluxboxWindow::~FluxboxWindow() { | |||
330 | } | 338 | } |
331 | } | 339 | } |
332 | 340 | ||
333 | // deal with extra menus | 341 | if (!screen().isShuttingdown()) |
342 | screen().focusControl().removeWindow(*this); | ||
343 | |||
334 | #ifdef DEBUG | 344 | #ifdef DEBUG |
335 | cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl; | 345 | cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl; |
336 | #endif // DEBUG | 346 | #endif // DEBUG |
@@ -588,18 +598,8 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { | |||
588 | if (client.fbwindow() != 0) { | 598 | if (client.fbwindow() != 0) { |
589 | FluxboxWindow *old_win = client.fbwindow(); // store old window | 599 | FluxboxWindow *old_win = client.fbwindow(); // store old window |
590 | 600 | ||
591 | // figure out which client to raise at the end | 601 | if (FocusControl::focusedFbWindow() == old_win) |
592 | if (FocusControl::focusedFbWindow() == old_win) { | ||
593 | was_focused = true; | 602 | was_focused = true; |
594 | } else if (FocusControl::focusedFbWindow() != this) { | ||
595 | FocusControl::FocusedWindows focus_list = | ||
596 | screen().focusControl().focusedOrderList(); | ||
597 | FocusControl::FocusedWindows::iterator it = focus_list.begin(); | ||
598 | for (; it != focus_list.end() && !focused_win; ++it) { | ||
599 | if ((*it)->fbwindow() == this || (*it)->fbwindow() == old_win) | ||
600 | focused_win = *it; | ||
601 | } | ||
602 | } | ||
603 | 603 | ||
604 | ClientList::iterator client_insert_pos = getClientInsertPosition(x, y); | 604 | ClientList::iterator client_insert_pos = getClientInsertPosition(x, y); |
605 | FbTk::TextButton *button_insert_pos = NULL; | 605 | FbTk::TextButton *button_insert_pos = NULL; |
@@ -668,13 +668,11 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { | |||
668 | // 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 |
669 | setCurrentClient(client); | 669 | setCurrentClient(client); |
670 | FocusControl::setFocusedWindow(&client); | 670 | FocusControl::setFocusedWindow(&client); |
671 | } else if (focused_win) | 671 | } else { |
672 | setCurrentClient(*focused_win, false); | 672 | WinClient *last = screen().focusControl().lastFocusedWindow(*this); |
673 | else | 673 | if (last) |
674 | // reparenting puts the new client on top, but the old client is keeping | 674 | setCurrentClient(*last, false); |
675 | // the focus, so we raise it | 675 | } |
676 | m_client->raise(); | ||
677 | |||
678 | frame().reconfigure(); | 676 | frame().reconfigure(); |
679 | } | 677 | } |
680 | 678 | ||
@@ -975,8 +973,6 @@ bool FluxboxWindow::setCurrentClient(WinClient &client, bool setinput) { | |||
975 | if (client.fbwindow() != this) | 973 | if (client.fbwindow() != this) |
976 | return false; | 974 | return false; |
977 | 975 | ||
978 | if (&client != m_client) | ||
979 | m_screen.focusControl().setScreenFocusedWindow(client); | ||
980 | m_client = &client; | 976 | m_client = &client; |
981 | m_client->raise(); | 977 | m_client->raise(); |
982 | m_client->focusSig().notify(); | 978 | m_client->focusSig().notify(); |
@@ -1063,7 +1059,7 @@ void FluxboxWindow::reconfigure() { | |||
1063 | 1059 | ||
1064 | applyDecorations(); | 1060 | applyDecorations(); |
1065 | 1061 | ||
1066 | setFocusFlag(focused); | 1062 | setFocusFlag(m_focused); |
1067 | 1063 | ||
1068 | moveResize(frame().x(), frame().y(), frame().width(), frame().height()); | 1064 | moveResize(frame().x(), frame().y(), frame().width(), frame().height()); |
1069 | 1065 | ||
@@ -1272,7 +1268,7 @@ void FluxboxWindow::moveResize(int new_x, int new_y, | |||
1272 | } | 1268 | } |
1273 | 1269 | ||
1274 | frame().moveResize(new_x, new_y, new_width, new_height); | 1270 | frame().moveResize(new_x, new_y, new_width, new_height); |
1275 | setFocusFlag(focused); | 1271 | setFocusFlag(m_focused); |
1276 | 1272 | ||
1277 | shaded = false; | 1273 | shaded = false; |
1278 | send_event = true; | 1274 | send_event = true; |
@@ -1299,7 +1295,7 @@ void FluxboxWindow::moveResizeForClient(int new_x, int new_y, | |||
1299 | if (!m_initialized) | 1295 | if (!m_initialized) |
1300 | m_old_pos_x = 1; | 1296 | m_old_pos_x = 1; |
1301 | frame().moveResizeForClient(new_x, new_y, new_width, new_height, gravity, client_bw); | 1297 | frame().moveResizeForClient(new_x, new_y, new_width, new_height, gravity, client_bw); |
1302 | setFocusFlag(focused); | 1298 | setFocusFlag(m_focused); |
1303 | shaded = false; | 1299 | shaded = false; |
1304 | sendConfigureNotify(); | 1300 | sendConfigureNotify(); |
1305 | 1301 | ||
@@ -1312,8 +1308,26 @@ void FluxboxWindow::moveResizeForClient(int new_x, int new_y, | |||
1312 | 1308 | ||
1313 | } | 1309 | } |
1314 | 1310 | ||
1311 | void FluxboxWindow::maxSize(unsigned int &max_width, unsigned int &max_height) { | ||
1312 | ClientList::const_iterator it = clientList().begin(); | ||
1313 | ClientList::const_iterator it_end = clientList().end(); | ||
1314 | max_width = (unsigned int) ~0; // unlimited | ||
1315 | max_height = (unsigned int) ~0; // unlimited | ||
1316 | for (; it != it_end; ++it) { | ||
1317 | // special case for max height/width == 0 | ||
1318 | // 0 indicates unlimited size, so we skip them | ||
1319 | // and set max size to 0 if max size == ~0 after the loop | ||
1320 | if ((*it)->maxHeight() != 0) | ||
1321 | max_height = std::min( (*it)->maxHeight(), max_height ); | ||
1322 | if ((*it)->maxWidth() != 0) | ||
1323 | max_width = std::min( (*it)->maxWidth(), max_width ); | ||
1324 | } | ||
1315 | 1325 | ||
1316 | 1326 | if (max_width == (unsigned int) ~0) | |
1327 | max_width = 0; | ||
1328 | if (max_height == (unsigned int) ~0) | ||
1329 | max_height = 0; | ||
1330 | } | ||
1317 | 1331 | ||
1318 | // returns whether the focus was "set" to this window | 1332 | // returns whether the focus was "set" to this window |
1319 | // it doesn't guarantee that it has focus, but says that we have | 1333 | // it doesn't guarantee that it has focus, but says that we have |
@@ -1976,7 +1990,7 @@ void FluxboxWindow::setIconHidden(bool value) { | |||
1976 | // so now we make it a focused frame etc | 1990 | // so now we make it a focused frame etc |
1977 | void FluxboxWindow::setFocusFlag(bool focus) { | 1991 | void FluxboxWindow::setFocusFlag(bool focus) { |
1978 | bool was_focused = isFocused(); | 1992 | bool was_focused = isFocused(); |
1979 | focused = focus; | 1993 | m_focused = focus; |
1980 | #ifdef DEBUG | 1994 | #ifdef DEBUG |
1981 | cerr<<"FluxboxWindow("<<title()<<")::setFocusFlag("<<focus<<")"<<endl; | 1995 | cerr<<"FluxboxWindow("<<title()<<")::setFocusFlag("<<focus<<")"<<endl; |
1982 | #endif // DEBUG | 1996 | #endif // DEBUG |
@@ -1987,7 +2001,7 @@ void FluxboxWindow::setFocusFlag(bool focus) { | |||
1987 | frame().setFocus(focus); | 2001 | frame().setFocus(focus); |
1988 | 2002 | ||
1989 | if (screen().doAutoRaise() && !screen().focusControl().isCycling()) { | 2003 | if (screen().doAutoRaise() && !screen().focusControl().isCycling()) { |
1990 | if (focused) | 2004 | if (m_focused) |
1991 | m_timer.start(); | 2005 | m_timer.start(); |
1992 | else | 2006 | else |
1993 | m_timer.stop(); | 2007 | m_timer.stop(); |
@@ -2434,7 +2448,9 @@ void FluxboxWindow::propertyNotifyEvent(WinClient &client, Atom atom) { | |||
2434 | 2448 | ||
2435 | case XA_WM_HINTS: | 2449 | case XA_WM_HINTS: |
2436 | client.updateWMHints(); | 2450 | client.updateWMHints(); |
2437 | hintSig().notify(); // notify listeners | 2451 | titleSig().notify(); |
2452 | // nothing uses this yet | ||
2453 | // hintSig().notify(); // notify listeners | ||
2438 | break; | 2454 | break; |
2439 | 2455 | ||
2440 | case XA_WM_ICON_NAME: | 2456 | case XA_WM_ICON_NAME: |
@@ -2604,7 +2620,7 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) { | |||
2604 | 2620 | ||
2605 | if (be.button == 1 || (be.button == 3 && | 2621 | if (be.button == 1 || (be.button == 3 && |
2606 | be.state == Fluxbox::instance()->getModKey())) { | 2622 | be.state == Fluxbox::instance()->getModKey())) { |
2607 | if (!focused) //check focus | 2623 | if (!m_focused) //check focus |
2608 | focus(); | 2624 | focus(); |
2609 | 2625 | ||
2610 | if (frame().window().window() == be.window || frame().tabcontainer().window() == be.window) { | 2626 | if (frame().window().window() == be.window || frame().tabcontainer().window() == be.window) { |
@@ -3664,12 +3680,16 @@ FbTk::Menu &FluxboxWindow::menu() { | |||
3664 | return screen().windowMenu(); | 3680 | return screen().windowMenu(); |
3665 | } | 3681 | } |
3666 | 3682 | ||
3683 | bool FluxboxWindow::acceptsFocus() const { | ||
3684 | return (m_client ? m_client->acceptsFocus() : false); | ||
3685 | } | ||
3686 | |||
3667 | const FbTk::FbPixmap &FluxboxWindow::iconPixmap() const { | 3687 | const FbTk::FbPixmap &FluxboxWindow::iconPixmap() const { |
3668 | return m_client->iconPixmap(); | 3688 | return (m_client ? m_client->iconPixmap() : m_icon_pixmap); |
3669 | } | 3689 | } |
3670 | 3690 | ||
3671 | const FbTk::FbPixmap &FluxboxWindow::iconMask() const { | 3691 | const FbTk::FbPixmap &FluxboxWindow::iconMask() const { |
3672 | return m_client->iconMask(); | 3692 | return (m_client ? m_client->iconMask() : m_icon_mask); |
3673 | } | 3693 | } |
3674 | 3694 | ||
3675 | const FbTk::Menu &FluxboxWindow::menu() const { | 3695 | const FbTk::Menu &FluxboxWindow::menu() const { |
@@ -4086,7 +4106,6 @@ void FluxboxWindow::updateButtons() { | |||
4086 | dir[i], | 4106 | dir[i], |
4087 | frame().titlebar(), | 4107 | frame().titlebar(), |
4088 | 0, 0, 10, 10); | 4108 | 0, 0, 10, 10); |
4089 | hintSig().attach(winbtn); | ||
4090 | titleSig().attach(winbtn); | 4109 | titleSig().attach(winbtn); |
4091 | winbtn->setOnClick(show_menu_cmd); | 4110 | winbtn->setOnClick(show_menu_cmd); |
4092 | break; | 4111 | break; |