aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-04-20 12:21:35 (GMT)
committerrathnor <rathnor>2003-04-20 12:21:35 (GMT)
commit2a1bc27e90ae96f14a2fc0164fef074974023389 (patch)
tree260f797a90be16e2d86c64156d96c2089b730040 /src
parente75378d0e6d5891536e24389fcbeabeb7a9d579a (diff)
downloadfluxbox-2a1bc27e90ae96f14a2fc0164fef074974023389.zip
fluxbox-2a1bc27e90ae96f14a2fc0164fef074974023389.tar.bz2
add directional focus movement (Simon)
incl new keybindings FocusUp, FocusDown, FocusLeft, FocusRight
Diffstat (limited to 'src')
-rw-r--r--src/Keys.cc6
-rw-r--r--src/Keys.hh3
-rw-r--r--src/Screen.cc91
-rw-r--r--src/Screen.hh5
-rw-r--r--src/fluxbox.cc18
5 files changed, 118 insertions, 5 deletions
diff --git a/src/Keys.cc b/src/Keys.cc
index 02cfabd..a818e3b 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22//$Id: Keys.cc,v 1.25 2003/04/15 00:50:24 rathnor Exp $ 22//$Id: Keys.cc,v 1.26 2003/04/20 12:21:35 rathnor Exp $
23 23
24 24
25#include "Keys.hh" 25#include "Keys.hh"
@@ -110,6 +110,10 @@ Keys::t_actionstr Keys::m_actionlist[] = {
110 {"MoveTabNext", MOVETABNEXT}, 110 {"MoveTabNext", MOVETABNEXT},
111 {"AttachLast", ATTACHLAST}, 111 {"AttachLast", ATTACHLAST},
112 {"DetachClient", DETACHCLIENT}, 112 {"DetachClient", DETACHCLIENT},
113 {"FocusUp", FOCUSUP},
114 {"FocusDown", FOCUSDOWN},
115 {"FocusLeft", FOCUSLEFT},
116 {"FocusRight", FOCUSRIGHT},
113 {"ShadeWindow", SHADE}, 117 {"ShadeWindow", SHADE},
114 {"MaximizeWindow", MAXIMIZE}, 118 {"MaximizeWindow", MAXIMIZE},
115 {"StickWindow", STICK}, 119 {"StickWindow", STICK},
diff --git a/src/Keys.hh b/src/Keys.hh
index 57e826c..d0eb344 100644
--- a/src/Keys.hh
+++ b/src/Keys.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Keys.hh,v 1.22 2003/04/15 00:50:24 rathnor Exp $ 22// $Id: Keys.hh,v 1.23 2003/04/20 12:21:35 rathnor Exp $
23 23
24#ifndef KEYS_HH 24#ifndef KEYS_HH
25#define KEYS_HH 25#define KEYS_HH
@@ -52,6 +52,7 @@ public:
52 KILLWINDOW, NEXTWINDOW, PREVWINDOW, 52 KILLWINDOW, NEXTWINDOW, PREVWINDOW,
53 NEXTTAB, PREVTAB, FIRSTTAB, LASTTAB, MOVETABPREV, MOVETABNEXT, 53 NEXTTAB, PREVTAB, FIRSTTAB, LASTTAB, MOVETABPREV, MOVETABNEXT,
54 ATTACHLAST, DETACHCLIENT, 54 ATTACHLAST, DETACHCLIENT,
55 FOCUSUP, FOCUSDOWN, FOCUSLEFT, FOCUSRIGHT,
55 SHADE, MAXIMIZE, 56 SHADE, MAXIMIZE,
56 STICK, // Make Sticky 57 STICK, // Make Sticky
57 EXECUTE, // Run command 58 EXECUTE, // Run command
diff --git a/src/Screen.cc b/src/Screen.cc
index 80466df..574c51a 100644
--- a/src/Screen.cc
+++ b/src/Screen.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: Screen.cc,v 1.127 2003/04/18 12:51:14 fluxgen Exp $ 25// $Id: Screen.cc,v 1.128 2003/04/20 12:21:35 rathnor Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
@@ -1618,6 +1618,95 @@ void BScreen::setFocusedWindow(WinClient &winclient) {
1618 } 1618 }
1619} 1619}
1620 1620
1621void BScreen::dirFocus(FluxboxWindow &win, FocusDir dir) {
1622 // change focus to the window in direction dir from the given window
1623
1624 // we scan through the list looking for the window that is "closest"
1625 // in the given direction
1626
1627 FluxboxWindow *foundwin = 0;
1628 int weight = 999999, exposure = 0; // extreme values
1629 int borderW = getBorderWidth(),
1630 top = win.getYFrame(),
1631 bottom = win.getYFrame() + win.getHeight() + 2*borderW,
1632 left = win.getXFrame(),
1633 right = win.getXFrame() + win.getWidth() + 2*borderW;
1634
1635 Workspace::Windows &wins = getCurrentWorkspace()->getWindowList();
1636 Workspace::Windows::iterator it = wins.begin();
1637 for (; it != wins.end(); ++it) {
1638 if ((*it) == &win) continue; // skip self
1639
1640 // we check things against an edge, and within the bounds (draw a picture)
1641 int edge=0, upper=0, lower=0, oedge=0, oupper=0, olower=0;
1642
1643 int otop = (*it)->getYFrame(),
1644 obottom = (*it)->getYFrame() + (*it)->getHeight() + 2*borderW,
1645 oleft = (*it)->getXFrame(),
1646 oright = (*it)->getXFrame() + (*it)->getWidth() + 2*borderW;
1647 // check if they intersect
1648 switch (dir) {
1649 case FOCUSUP:
1650 edge = obottom;
1651 oedge = bottom;
1652 upper = left;
1653 oupper = oleft;
1654 lower = right;
1655 olower = oright;
1656 break;
1657 case FOCUSDOWN:
1658 edge = top;
1659 oedge = otop;
1660 upper = left;
1661 oupper = oleft;
1662 lower = right;
1663 olower = oright;
1664 break;
1665 case FOCUSLEFT:
1666 edge = oright;
1667 oedge = right;
1668 upper = top;
1669 oupper = otop;
1670 lower = bottom;
1671 olower = obottom;
1672 break;
1673 case FOCUSRIGHT:
1674 edge = left;
1675 oedge = oleft;
1676 upper = top;
1677 oupper = otop;
1678 lower = bottom;
1679 olower = obottom;
1680 break;
1681 }
1682
1683 if (oedge < edge) continue; // not in the right direction
1684 if (olower <= upper || oupper >= lower) {
1685 // outside our horz bounds, get a heavy weight penalty
1686 int myweight = 100000 + oedge - edge + abs(upper-oupper)+abs(lower-olower);
1687 if (myweight < weight) {
1688 foundwin = *it;
1689 exposure = 0;
1690 weight = myweight;
1691 }
1692 } else if ((oedge - edge) < weight) {
1693 foundwin = *it;
1694 weight = oedge - edge;
1695 exposure = ((lower < olower)?lower:olower) - ((upper > oupper)?upper:oupper);
1696 } else if (foundwin && oedge - edge == weight) {
1697 int myexp = ((lower < olower)?lower:olower) - ((upper > oupper)?upper:oupper);
1698 if (myexp > exposure) {
1699 foundwin = *it;
1700 // weight is same
1701 exposure = myexp;
1702 }
1703 } // else not improvement
1704 }
1705
1706 if (foundwin)
1707 foundwin->setInputFocus();
1708}
1709
1621void BScreen::initMenu() { 1710void BScreen::initMenu() {
1622 I18n *i18n = I18n::instance(); 1711 I18n *i18n = I18n::instance();
1623 1712
diff --git a/src/Screen.hh b/src/Screen.hh
index 8b4d74a..84d7f74 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -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: Screen.hh,v 1.80 2003/04/16 16:17:57 rathnor Exp $ 25// $Id: Screen.hh,v 1.81 2003/04/20 12:21:35 rathnor Exp $
26 26
27#ifndef SCREEN_HH 27#ifndef SCREEN_HH
28#define SCREEN_HH 28#define SCREEN_HH
@@ -278,6 +278,9 @@ public:
278 void raiseFocus(); 278 void raiseFocus();
279 void setFocusedWindow(WinClient &winclient); 279 void setFocusedWindow(WinClient &winclient);
280 280
281 enum FocusDir { FOCUSUP, FOCUSDOWN, FOCUSLEFT, FOCUSRIGHT };
282 void dirFocus(FluxboxWindow &win, FocusDir dir);
283
281 void reconfigure(); 284 void reconfigure();
282 void rereadMenu(); 285 void rereadMenu();
283 void shutdown(); 286 void shutdown();
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index a0a75f0..d2dc234 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.114 2003/04/16 16:18:06 rathnor Exp $ 25// $Id: fluxbox.cc,v 1.115 2003/04/20 12:21:35 rathnor Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -1165,6 +1165,22 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
1165 } 1165 }
1166 screen->prevFocus(key->getParam()); 1166 screen->prevFocus(key->getParam());
1167 break; 1167 break;
1168 case Keys::FOCUSUP:
1169 if (focused_window)
1170 screen->dirFocus(*focused_window, BScreen::FOCUSUP);
1171 break;
1172 case Keys::FOCUSDOWN:
1173 if (focused_window)
1174 screen->dirFocus(*focused_window, BScreen::FOCUSDOWN);
1175 break;
1176 case Keys::FOCUSLEFT:
1177 if (focused_window)
1178 screen->dirFocus(*focused_window, BScreen::FOCUSLEFT);
1179 break;
1180 case Keys::FOCUSRIGHT:
1181 if (focused_window)
1182 screen->dirFocus(*focused_window, BScreen::FOCUSRIGHT);
1183 break;
1168 case Keys::NEXTTAB: 1184 case Keys::NEXTTAB:
1169 if (focused_window && focused_window->numClients() > 1) 1185 if (focused_window && focused_window->numClients() > 1)
1170 focused_window->nextClient(); 1186 focused_window->nextClient();