xref: /netbsd-src/lib/libpanel/below.c (revision 411bbd24b918b2da1392dc6d1bb24db0c571655d)
1*411bbd24Suwe /*	$NetBSD: below.c,v 1.2 2015/11/01 01:40:23 uwe Exp $ */
25858a2dbSuwe 
35858a2dbSuwe /*
45858a2dbSuwe  * Copyright (c) 2015 Valery Ushakov
55858a2dbSuwe  * All rights reserved.
65858a2dbSuwe  *
75858a2dbSuwe  * Redistribution and use in source and binary forms, with or without
85858a2dbSuwe  * modification, are permitted provided that the following conditions
95858a2dbSuwe  * are met:
105858a2dbSuwe  * 1. Redistributions of source code must retain the above copyright
115858a2dbSuwe  *    notice, this list of conditions and the following disclaimer.
125858a2dbSuwe  * 2. Redistributions in binary form must reproduce the above copyright
135858a2dbSuwe  *    notice, this list of conditions and the following disclaimer in the
145858a2dbSuwe  *    documentation and/or other materials provided with the distribution.
155858a2dbSuwe  *
165858a2dbSuwe  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
175858a2dbSuwe  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
185858a2dbSuwe  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
195858a2dbSuwe  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
205858a2dbSuwe  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
215858a2dbSuwe  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
225858a2dbSuwe  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
235858a2dbSuwe  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
245858a2dbSuwe  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
255858a2dbSuwe  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
265858a2dbSuwe  */
275858a2dbSuwe 
285858a2dbSuwe #include <sys/cdefs.h>
29*411bbd24Suwe __RCSID("$NetBSD: below.c,v 1.2 2015/11/01 01:40:23 uwe Exp $");
305858a2dbSuwe 
315858a2dbSuwe #include "panel_impl.h"
325858a2dbSuwe 
335858a2dbSuwe 
345858a2dbSuwe PANEL *
panel_below(PANEL * p)355858a2dbSuwe panel_below(PANEL *p)
365858a2dbSuwe {
375858a2dbSuwe 	PANEL *below;
385858a2dbSuwe 
39*411bbd24Suwe 	if (p == NULL)
40*411bbd24Suwe 		below = TAILQ_LAST(&_deck, deck);
41*411bbd24Suwe 	else if (__predict_true(!PANEL_HIDDEN(p)))
425858a2dbSuwe 		below = PANEL_BELOW(p);
43*411bbd24Suwe 	else
44*411bbd24Suwe 		return NULL;
45*411bbd24Suwe 
465858a2dbSuwe 	if (below == &_stdscr_panel)
475858a2dbSuwe 		return NULL;
485858a2dbSuwe 	else
495858a2dbSuwe 		return below;
505858a2dbSuwe }
51