From c7ddf2e4e566a1587c9276a0f71f71d2a72ff014 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Tue, 20 May 2008 20:48:58 -0700 Subject: fix negative arguments to :GoToWindow --- src/FocusControl.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/FocusControl.cc b/src/FocusControl.cc index d094a55..3f8aac5 100644 --- a/src/FocusControl.cc +++ b/src/FocusControl.cc @@ -168,12 +168,16 @@ void FocusControl::cycleFocus(const FocusableList &window_list, void FocusControl::goToWindowNumber(const FocusableList &winlist, int num, const ClientPattern *pat) { + Focusables list = winlist.clientList(); + if (num < 0) { + list.reverse(); + num = -num; + } Focusable *win = 0; - Focusables::const_iterator it = winlist.clientList().begin(); - Focusables::const_iterator it_end = winlist.clientList().end(); - for (; it != it_end && num; ++it) { + Focusables::const_iterator it = list.begin(), it_end = list.end(); + for (; num && it != it_end; ++it) { if (!doSkipWindow(**it, pat) && (*it)->acceptsFocus()) { - num > 0 ? --num : ++num; + --num; win = *it; } } -- cgit v0.11.2