summaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc68
1 files changed, 42 insertions, 26 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 4e45370..10892df 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.207 2003/07/20 18:05:39 rathnor Exp $ 25// $Id: Window.cc,v 1.208 2003/07/21 15:26:56 rathnor Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -1097,9 +1097,13 @@ void FluxboxWindow::moveResize(int new_x, int new_y,
1097 shape(); 1097 shape();
1098} 1098}
1099 1099
1100// returns whether the focus was "set" to this window
1101// it doesn't guarantee that it has focus, but says that we have
1102// tried. A FocusqIn event should eventually arrive for that
1103// window if it actually got the focus, then setFocusedFlag is called,
1104// which updates all the graphics etc
1100bool FluxboxWindow::setInputFocus() { 1105bool FluxboxWindow::setInputFocus() {
1101 1106
1102 //TODO hint skip focus
1103 if (((signed) (frame().x() + frame().width())) < 0) { 1107 if (((signed) (frame().x() + frame().width())) < 0) {
1104 if (((signed) (frame().y() + frame().height())) < 0) { 1108 if (((signed) (frame().y() + frame().height())) < 0) {
1105 moveResize(frame().window().borderWidth(), frame().window().borderWidth(), 1109 moveResize(frame().window().borderWidth(), frame().window().borderWidth(),
@@ -1137,18 +1141,16 @@ bool FluxboxWindow::setInputFocus() {
1137 return (*it)->fbwindow()->setCurrentClient(**it, true); 1141 return (*it)->fbwindow()->setCurrentClient(**it, true);
1138 } 1142 }
1139 } 1143 }
1144
1140 if (m_client->getFocusMode() == WinClient::F_LOCALLYACTIVE || 1145 if (m_client->getFocusMode() == WinClient::F_LOCALLYACTIVE ||
1141 m_client->getFocusMode() == WinClient::F_PASSIVE) { 1146 m_client->getFocusMode() == WinClient::F_PASSIVE) {
1142 m_client->setInputFocus(RevertToPointerRoot, CurrentTime); 1147 m_client->setInputFocus(RevertToPointerRoot, CurrentTime);
1148 // this may or may not send, but we've setInputFocus already, so return true
1149 m_client->sendFocus();
1150 return true;
1143 } else { 1151 } else {
1144 return false; 1152 return m_client->sendFocus(); // checks if it should send or not
1145 } 1153 }
1146
1147 if ((screen().isSloppyFocus() || screen().isSemiSloppyFocus())
1148 && screen().doAutoRaise())
1149 m_timer.start();
1150
1151 return true;
1152} 1154}
1153 1155
1154void FluxboxWindow::hide() { 1156void FluxboxWindow::hide() {
@@ -1581,28 +1583,36 @@ void FluxboxWindow::moveToLayer(int layernum) {
1581} 1583}
1582 1584
1583 1585
1584 1586// window has actually RECEIVED focus (got a FocusIn event)
1587// so now we make it a focused frame etc
1585void FluxboxWindow::setFocusFlag(bool focus) { 1588void FluxboxWindow::setFocusFlag(bool focus) {
1586 focused = focus; 1589 focused = focus;
1587 1590
1588 // Record focus timestamp for window cycling enhancements 1591 // Record focus timestamp for window cycling enhancements
1589 if (focused) 1592 if (focused) {
1590 gettimeofday(&m_last_focus_time, 0); 1593 gettimeofday(&m_last_focus_time, 0);
1594 screen().setFocusedWindow(*m_client);
1595 }
1591 1596
1592 screen().setFocusedWindow(*m_client); 1597 installColormap(focus);
1593 m_client->sendFocus();
1594 frame().setFocus(focus); 1598 frame().setFocus(focus);
1595 1599
1596 if (!focused && (screen().isSloppyFocus() || screen().isSemiSloppyFocus()) && 1600 if ((screen().isSloppyFocus() || screen().isSemiSloppyFocus())
1597 screen().doAutoRaise()) 1601 && screen().doAutoRaise())
1598 m_timer.stop(); 1602 if (focused)
1603 m_timer.start();
1604 else
1605 m_timer.stop();
1599} 1606}
1600 1607
1601 1608
1602void FluxboxWindow::installColormap(bool install) { 1609void FluxboxWindow::installColormap(bool install) {
1610 if (m_client == 0) return;
1611
1603 Fluxbox *fluxbox = Fluxbox::instance(); 1612 Fluxbox *fluxbox = Fluxbox::instance();
1604 fluxbox->grab(); 1613 fluxbox->grab();
1605 if (! validateClient()) return; 1614 if (! validateClient())
1615 return;
1606 1616
1607 int i = 0, ncmap = 0; 1617 int i = 0, ncmap = 0;
1608 Colormap *cmaps = XListInstalledColormaps(display, m_client->window(), &ncmap); 1618 Colormap *cmaps = XListInstalledColormaps(display, m_client->window(), &ncmap);
@@ -2567,17 +2577,21 @@ void FluxboxWindow::enterNotifyEvent(XCrossingEvent &ev) {
2567 XCheckIfEvent(display, &dummy, queueScanner, (char *) &sa); 2577 XCheckIfEvent(display, &dummy, queueScanner, (char *) &sa);
2568 2578
2569 // if client is set, use setCurrent client, otherwise just setInputFocus 2579 // if client is set, use setCurrent client, otherwise just setInputFocus
2570 if ((!sa.leave || sa.inferior) && 2580 if ((!sa.leave || sa.inferior)) {
2571 ((client && setCurrentClient(*client, true)) || setInputFocus())) { 2581 if (client)
2572 installColormap(True); 2582 setCurrentClient(*client, true);
2583 else
2584 setInputFocus();
2573 } 2585 }
2586
2574 } 2587 }
2575 } 2588 }
2576} 2589}
2577 2590
2578void FluxboxWindow::leaveNotifyEvent(XCrossingEvent &ev) { 2591void FluxboxWindow::leaveNotifyEvent(XCrossingEvent &ev) {
2579 if (ev.window == frame().window()) 2592 // I hope commenting this out is right - simon 21jul2003
2580 installColormap(false); 2593 //if (ev.window == frame().window())
2594 //installColormap(false);
2581} 2595}
2582 2596
2583// TODO: functions should not be affected by decoration 2597// TODO: functions should not be affected by decoration
@@ -2728,11 +2742,11 @@ bool FluxboxWindow::validateClient() {
2728 XSync(display, false); 2742 XSync(display, false);
2729 2743
2730 XEvent e; 2744 XEvent e;
2731 if (XCheckTypedWindowEvent(display, m_client->window(), DestroyNotify, &e) || 2745 if (!m_client ||
2732 XCheckTypedWindowEvent(display, m_client->window(), UnmapNotify, &e)) { 2746 ( XCheckTypedWindowEvent(display, m_client->window(), DestroyNotify, &e) ||
2733 XPutBackEvent(display, &e); 2747 XCheckTypedWindowEvent(display, m_client->window(), UnmapNotify, &e))
2748 && XPutBackEvent(display, &e)) {
2734 Fluxbox::instance()->ungrab(); 2749 Fluxbox::instance()->ungrab();
2735
2736 return false; 2750 return false;
2737 } 2751 }
2738 2752
@@ -3041,6 +3055,8 @@ void FluxboxWindow::restore(WinClient *client, bool remap) {
3041 if (remap) 3055 if (remap)
3042 client->show(); 3056 client->show();
3043 3057
3058 installColormap(false);
3059
3044 delete client; 3060 delete client;
3045 3061
3046#ifdef DEBUG 3062#ifdef DEBUG