aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-04-15 00:50:25 (GMT)
committerrathnor <rathnor>2003-04-15 00:50:25 (GMT)
commit58e19dc91eba51739d4b8ed2dfdbb49e28d96379 (patch)
tree1fbb529d593c1b1b1fabb76832a97783649cab23 /src/fluxbox.cc
parent1aa5ede1b70dfba6519eeaa38101948bbdfea8a2 (diff)
downloadfluxbox_pavel-58e19dc91eba51739d4b8ed2dfdbb49e28d96379.zip
fluxbox_pavel-58e19dc91eba51739d4b8ed2dfdbb49e28d96379.tar.bz2
add most recently used window cycling (Simon)
It is now the default cycling action
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r--src/fluxbox.cc74
1 files changed, 60 insertions, 14 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 2194b87..158e0db 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.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: fluxbox.cc,v 1.106 2003/04/14 15:28:52 fluxgen Exp $ 25// $Id: fluxbox.cc,v 1.107 2003/04/15 00:50:25 rathnor Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -373,6 +373,7 @@ Fluxbox::Fluxbox(int m_argc, char **m_argv, const char *dpy_name, const char *rc
373 m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"), 373 m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"),
374 focused_window(0), masked_window(0), 374 focused_window(0), masked_window(0),
375 timer(this), 375 timer(this),
376 watching_screen(0), watch_keyrelease(0),
376 no_focus(false), 377 no_focus(false),
377 rc_file(rc ? rc : ""), 378 rc_file(rc ? rc : ""),
378 argv(m_argv), argc(m_argc), 379 argv(m_argv), argc(m_argc),
@@ -699,6 +700,15 @@ void Fluxbox::handleEvent(XEvent * const e) {
699 case UnmapNotify: 700 case UnmapNotify:
700 handleUnmapNotify(e->xunmap); 701 handleUnmapNotify(e->xunmap);
701 break; 702 break;
703 case MappingNotify:
704 // Update stored modifier mapping
705#ifdef DEBUG
706 cerr<<__FILE__<<"("<<__FUNCTION__<<"): MappingNotify"<<endl;
707#endif // DEBUG
708 if (key.get()) {
709 key->loadModmap();
710 }
711 break;
702 case CreateNotify: 712 case CreateNotify:
703 break; 713 break;
704 case DestroyNotify: { 714 case DestroyNotify: {
@@ -767,6 +777,7 @@ void Fluxbox::handleEvent(XEvent * const e) {
767 777
768 } 778 }
769 break; 779 break;
780 case KeyRelease:
770 case KeyPress: 781 case KeyPress:
771 handleKeyEvent(e->xkey); 782 handleKeyEvent(e->xkey);
772 break; 783 break;
@@ -1136,9 +1147,19 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
1136 } 1147 }
1137 break; 1148 break;
1138 case Keys::NEXTWINDOW: //activate next window 1149 case Keys::NEXTWINDOW: //activate next window
1150 if (!watching_screen && !(key->getParam() & BScreen::CYCLELINEAR)) {
1151 // if stacked cycling, then set a watch for
1152 // the release of exactly these modifiers
1153 watchKeyRelease(screen, Keys::cleanMods(ke.state));
1154 }
1139 screen->nextFocus(key->getParam()); 1155 screen->nextFocus(key->getParam());
1140 break; 1156 break;
1141 case Keys::PREVWINDOW: //activate prev window 1157 case Keys::PREVWINDOW: //activate prev window
1158 if (!watching_screen && !(key->getParam() & BScreen::CYCLELINEAR)) {
1159 // if stacked cycling, then set a watch for
1160 // the release of exactly these modifiers
1161 watchKeyRelease(screen, Keys::cleanMods(ke.state));
1162 }
1142 screen->prevFocus(key->getParam()); 1163 screen->prevFocus(key->getParam());
1143 break; 1164 break;
1144 case Keys::NEXTTAB: 1165 case Keys::NEXTTAB:
@@ -1242,7 +1263,30 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
1242 1263
1243 break; 1264 break;
1244 } 1265 }
1245 1266 case KeyRelease:
1267 {
1268 // we ignore most key releases unless we need to use
1269 // a release to stop something (e.g. window cycling).
1270
1271 // we notify if _all_ of the watched modifiers are released
1272 if (watching_screen && watch_keyrelease) {
1273 // mask the mod of the released key out
1274 // won't mask anything if it isn't a mod
1275 ke.state &= ~key->keycodeToModmask(ke.keycode);
1276
1277 if ((watch_keyrelease & ke.state) == 0) {
1278
1279 watching_screen->notifyReleasedKeys(ke);
1280 XUngrabKeyboard(getXDisplay(), CurrentTime);
1281
1282 // once they are released, we drop the watch
1283 watching_screen = 0;
1284 watch_keyrelease = 0;
1285 }
1286 }
1287
1288 break;
1289 }
1246 default: 1290 default:
1247 break; 1291 break;
1248 } 1292 }
@@ -1470,10 +1514,7 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1470 } 1514 }
1471 // make sure each workspace get this 1515 // make sure each workspace get this
1472 BScreen &scr = win.getScreen(); 1516 BScreen &scr = win.getScreen();
1473 for (int workspace = 0; workspace < scr.getNumberOfWorkspaces(); 1517 scr.removeWindow(&win);
1474 ++workspace) {
1475 scr.getWorkspace(workspace)->removeWindow(&win);
1476 }
1477 1518
1478 } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal 1519 } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal
1479 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1520 for (size_t i=0; i<m_atomhandler.size(); ++i) {
@@ -1513,13 +1554,12 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1513 } else if (typeid(*changedsub) == typeid(WinClient::WinClientSubj)) { 1554 } else if (typeid(*changedsub) == typeid(WinClient::WinClientSubj)) {
1514 WinClient::WinClientSubj *subj = dynamic_cast<WinClient::WinClientSubj *>(changedsub); 1555 WinClient::WinClientSubj *subj = dynamic_cast<WinClient::WinClientSubj *>(changedsub);
1515 WinClient &client = subj->winClient(); 1556 WinClient &client = subj->winClient();
1516 //!! TODO we shouldn't call update netizen on every screen
1517 // just the screen it was located on
1518 ScreenList::iterator screen_it = screenList.begin();
1519 const ScreenList::iterator screen_it_end = screenList.end();
1520 for (; screen_it != screen_it_end; ++screen_it)
1521 (*screen_it)->updateNetizenWindowDel(client.window());
1522 1557
1558 if (client.fbwindow()) {
1559 BScreen &screen = client.fbwindow()->getScreen();
1560 screen.updateNetizenWindowDel(client.window());
1561 screen.removeClient(client);
1562 }
1523 1563
1524 removeWindowSearch(client.window()); 1564 removeWindowSearch(client.window());
1525 //!! TODO 1565 //!! TODO
@@ -2232,13 +2272,12 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
2232 if (focused_window != 0) { 2272 if (focused_window != 0) {
2233 old_win = focused_window; 2273 old_win = focused_window;
2234 old_screen = &old_win->getScreen(); 2274 old_screen = &old_win->getScreen();
2235 2275
2236 old_tbar = old_screen->getToolbar(); 2276 old_tbar = old_screen->getToolbar();
2237 old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber()); 2277 old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber());
2238 2278
2239 old_win->setFocusFlag(False); 2279 old_win->setFocusFlag(False);
2240 old_wkspc->menu().setItemSelected(old_win->getWindowNumber(), false); 2280 old_wkspc->menu().setItemSelected(old_win->getWindowNumber(), false);
2241
2242 } 2281 }
2243 2282
2244 if (win && ! win->isIconic()) { 2283 if (win && ! win->isIconic()) {
@@ -2272,3 +2311,10 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
2272 old_screen->updateNetizenWindowFocus(); 2311 old_screen->updateNetizenWindowFocus();
2273 2312
2274} 2313}
2314
2315void Fluxbox::watchKeyRelease(BScreen *screen, unsigned int mods) {
2316 watching_screen = screen;
2317 watch_keyrelease = mods;
2318 XGrabKeyboard(getXDisplay(),screen->getRootWindow(), True,
2319 GrabModeAsync, GrabModeAsync, CurrentTime);
2320}