aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-07-20 18:05:40 (GMT)
committerrathnor <rathnor>2003-07-20 18:05:40 (GMT)
commit037bd174bfb107fef4657c949ce49c188090f3e7 (patch)
tree35d56080c76f4751946be2ddf95e4ce18e2a5bf2 /src/Window.cc
parent8500132b0a05d22470e63cee1d16191ecb138ecf (diff)
downloadfluxbox-037bd174bfb107fef4657c949ce49c188090f3e7.zip
fluxbox-037bd174bfb107fef4657c949ce49c188090f3e7.tar.bz2
fix focus and raising for transient windows in particular
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc70
1 files changed, 42 insertions, 28 deletions
diff --git a/src/Window.cc b/src/Window.cc
index bfb7dae..4e45370 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.206 2003/07/20 08:12:36 rathnor Exp $ 25// $Id: Window.cc,v 1.207 2003/07/20 18:05:39 rathnor Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -145,6 +145,11 @@ void raiseFluxboxWindow(FluxboxWindow &win) {
145 if (win.oplock) return; 145 if (win.oplock) return;
146 win.oplock = true; 146 win.oplock = true;
147 147
148 // we need to lock actual restacking so that raising above active transient
149 // won't do anything nasty
150 if (!win.winClient().transientList().empty())
151 win.screen().layerManager().lock();
152
148 if (!win.isIconic()) { 153 if (!win.isIconic()) {
149 win.screen().updateNetizenWindowRaise(win.clientWindow()); 154 win.screen().updateNetizenWindowRaise(win.clientWindow());
150 win.layerItem().raise(); 155 win.layerItem().raise();
@@ -159,6 +164,9 @@ void raiseFluxboxWindow(FluxboxWindow &win) {
159 raiseFluxboxWindow(*(*it)->fbwindow()); 164 raiseFluxboxWindow(*(*it)->fbwindow());
160 } 165 }
161 win.oplock = false; 166 win.oplock = false;
167
168 if (!win.winClient().transientList().empty())
169 win.screen().layerManager().unlock();
162} 170}
163 171
164/// lower window and do the same for each transient it holds 172/// lower window and do the same for each transient it holds
@@ -166,6 +174,11 @@ void lowerFluxboxWindow(FluxboxWindow &win) {
166 if (win.oplock) return; 174 if (win.oplock) return;
167 win.oplock = true; 175 win.oplock = true;
168 176
177 // we need to lock actual restacking so that raising above active transient
178 // won't do anything nasty
179 if (!win.winClient().transientList().empty())
180 win.screen().layerManager().lock();
181
169 if (!win.isIconic()) { 182 if (!win.isIconic()) {
170 win.screen().updateNetizenWindowLower(win.clientWindow()); 183 win.screen().updateNetizenWindowLower(win.clientWindow());
171 win.layerItem().lower(); 184 win.layerItem().lower();
@@ -179,6 +192,8 @@ void lowerFluxboxWindow(FluxboxWindow &win) {
179 lowerFluxboxWindow(*(*it)->fbwindow()); 192 lowerFluxboxWindow(*(*it)->fbwindow());
180 } 193 }
181 win.oplock = false; 194 win.oplock = false;
195 if (!win.winClient().transientList().empty())
196 win.screen().layerManager().unlock();
182} 197}
183 198
184/// raise window and do the same for each transient it holds 199/// raise window and do the same for each transient it holds
@@ -186,6 +201,9 @@ void tempRaiseFluxboxWindow(FluxboxWindow &win) {
186 if (win.oplock) return; 201 if (win.oplock) return;
187 win.oplock = true; 202 win.oplock = true;
188 203
204 if (!win.winClient().transientList().empty())
205 win.screen().layerManager().lock();
206
189 if (!win.isIconic()) { 207 if (!win.isIconic()) {
190 // don't update netizen, as it is only temporary 208 // don't update netizen, as it is only temporary
191 win.layerItem().tempRaise(); 209 win.layerItem().tempRaise();
@@ -200,6 +218,10 @@ void tempRaiseFluxboxWindow(FluxboxWindow &win) {
200 tempRaiseFluxboxWindow(*(*it)->fbwindow()); 218 tempRaiseFluxboxWindow(*(*it)->fbwindow());
201 } 219 }
202 win.oplock = false; 220 win.oplock = false;
221
222 if (!win.winClient().transientList().empty())
223 win.screen().layerManager().unlock();
224
203} 225}
204 226
205class SetClientCmd:public FbTk::Command { 227class SetClientCmd:public FbTk::Command {
@@ -1107,8 +1129,6 @@ bool FluxboxWindow::setInputFocus() {
1107 if (! validateClient()) 1129 if (! validateClient())
1108 return false; 1130 return false;
1109 1131
1110 bool ret = false;
1111
1112 if (!m_client->transients.empty() && m_client->isModal()) { 1132 if (!m_client->transients.empty() && m_client->isModal()) {
1113 WinClient::TransientList::iterator it = m_client->transients.begin(); 1133 WinClient::TransientList::iterator it = m_client->transients.begin();
1114 WinClient::TransientList::iterator it_end = m_client->transients.end(); 1134 WinClient::TransientList::iterator it_end = m_client->transients.end();
@@ -1116,30 +1136,19 @@ bool FluxboxWindow::setInputFocus() {
1116 if ((*it)->isModal()) 1136 if ((*it)->isModal())
1117 return (*it)->fbwindow()->setCurrentClient(**it, true); 1137 return (*it)->fbwindow()->setCurrentClient(**it, true);
1118 } 1138 }
1139 }
1140 if (m_client->getFocusMode() == WinClient::F_LOCALLYACTIVE ||
1141 m_client->getFocusMode() == WinClient::F_PASSIVE) {
1142 m_client->setInputFocus(RevertToPointerRoot, CurrentTime);
1119 } else { 1143 } else {
1120 if (m_client->getFocusMode() == WinClient::F_LOCALLYACTIVE || 1144 return false;
1121 m_client->getFocusMode() == WinClient::F_PASSIVE) {
1122 m_client->setInputFocus(RevertToPointerRoot, CurrentTime);
1123 } else {
1124 return false;
1125 }
1126
1127 screen().setFocusedWindow(*m_client);
1128
1129 Fluxbox::instance()->setFocusedWindow(this);
1130
1131 frame().setFocus(true);
1132
1133 m_client->sendFocus();
1134
1135 if ((screen().isSloppyFocus() || screen().isSemiSloppyFocus())
1136 && screen().doAutoRaise())
1137 m_timer.start();
1138
1139 ret = true;
1140 } 1145 }
1141 1146
1142 return ret; 1147 if ((screen().isSloppyFocus() || screen().isSemiSloppyFocus())
1148 && screen().doAutoRaise())
1149 m_timer.start();
1150
1151 return true;
1143} 1152}
1144 1153
1145void FluxboxWindow::hide() { 1154void FluxboxWindow::hide() {
@@ -1224,8 +1233,9 @@ void FluxboxWindow::deiconify(bool reassoc, bool do_raise) {
1224 1233
1225 frame().show(); 1234 frame().show();
1226 1235
1227 if (was_iconic && screen().doFocusNew()) 1236 if (was_iconic && screen().doFocusNew()) {
1228 setInputFocus(); 1237 setInputFocus();
1238 }
1229 1239
1230 if (focused != frame().focused()) 1240 if (focused != frame().focused())
1231 frame().setFocus(focused); 1241 frame().setFocus(focused);
@@ -1579,9 +1589,11 @@ void FluxboxWindow::setFocusFlag(bool focus) {
1579 if (focused) 1589 if (focused)
1580 gettimeofday(&m_last_focus_time, 0); 1590 gettimeofday(&m_last_focus_time, 0);
1581 1591
1592 screen().setFocusedWindow(*m_client);
1593 m_client->sendFocus();
1582 frame().setFocus(focus); 1594 frame().setFocus(focus);
1583 1595
1584 if ((screen().isSloppyFocus() || screen().isSemiSloppyFocus()) && 1596 if (!focused && (screen().isSloppyFocus() || screen().isSemiSloppyFocus()) &&
1585 screen().doAutoRaise()) 1597 screen().doAutoRaise())
1586 m_timer.stop(); 1598 m_timer.stop();
1587} 1599}
@@ -2042,8 +2054,9 @@ void FluxboxWindow::mapNotifyEvent(XMapEvent &ne) {
2042 2054
2043 setState(NormalState); 2055 setState(NormalState);
2044 2056
2045 if (client->isTransient() || screen().doFocusNew()) 2057 if (client->isTransient() || screen().doFocusNew()) {
2046 setInputFocus(); 2058 setInputFocus();
2059 }
2047 else 2060 else
2048 setFocusFlag(false); 2061 setFocusFlag(false);
2049 2062
@@ -2555,8 +2568,9 @@ void FluxboxWindow::enterNotifyEvent(XCrossingEvent &ev) {
2555 2568
2556 // if client is set, use setCurrent client, otherwise just setInputFocus 2569 // if client is set, use setCurrent client, otherwise just setInputFocus
2557 if ((!sa.leave || sa.inferior) && 2570 if ((!sa.leave || sa.inferior) &&
2558 ((client && setCurrentClient(*client, true)) || setInputFocus())) 2571 ((client && setCurrentClient(*client, true)) || setInputFocus())) {
2559 installColormap(True); 2572 installColormap(True);
2573 }
2560 } 2574 }
2561 } 2575 }
2562} 2576}