aboutsummaryrefslogtreecommitdiffstats
path: root/group.c
diff options
context:
space:
mode:
authorokan2019-02-28 23:20:52 +0000
committerokan2019-02-28 23:20:52 +0000
commit647ee7a24a435b91d26f1f2f7a9a1f199e87a7ee (patch)
tree407578053c2208c2121987b418f3aaa8f8303da5 /group.c
parentf0f3f957861987532ec41c77ea3d04cec1e43938 (diff)
downloadcwm-647ee7a24a435b91d26f1f2f7a9a1f199e87a7ee.tar.gz
Ensure we don't action on the last group when the requested one is not found.
Diffstat (limited to 'group.c')
-rw-r--r--group.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/group.c b/group.c
index af7ceaf..06e73eb 100644
--- a/group.c
+++ b/group.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: group.c,v 1.130 2019/02/28 13:11:53 okan Exp $
+ * $OpenBSD: group.c,v 1.131 2019/02/28 23:20:52 okan Exp $
*/
#include <sys/types.h>
@@ -160,15 +160,14 @@ group_movetogroup(struct client_ctx *cc, int idx)
return;
TAILQ_FOREACH(gc, &sc->groupq, entry) {
- if (gc->num == idx)
- break;
+ if (gc->num == idx) {
+ if (cc->gc == gc)
+ return;
+ if (gc->num != 0 && group_holds_only_hidden(gc))
+ client_hide(cc);
+ group_assign(gc, cc);
+ }
}
-
- if (cc->gc == gc)
- return;
- if (gc->num != 0 && group_holds_only_hidden(gc))
- client_hide(cc);
- group_assign(gc, cc);
}
void
@@ -221,17 +220,16 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
return;
TAILQ_FOREACH(gc, &sc->groupq, entry) {
- if (gc->num == idx)
- break;
- }
-
- if (group_holds_only_hidden(gc))
- group_show(gc);
- else {
- group_hide(gc);
- /* make clients stick to empty group */
- if (TAILQ_EMPTY(&gc->clientq))
- group_setactive(gc);
+ if (gc->num == idx) {
+ if (group_holds_only_hidden(gc))
+ group_show(gc);
+ else {
+ group_hide(gc);
+ /* make clients stick to empty group */
+ if (TAILQ_EMPTY(&gc->clientq))
+ group_setactive(gc);
+ }
+ }
}
}