xref: /netbsd-src/lib/libpanel/move.c (revision 5858a2db3d97dad7cb7e5425098a662ce159ce31)
1*5858a2dbSuwe /*	$NetBSD: move.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
2*5858a2dbSuwe 
3*5858a2dbSuwe /*
4*5858a2dbSuwe  * Copyright (c) 2015 Valery Ushakov
5*5858a2dbSuwe  * All rights reserved.
6*5858a2dbSuwe  *
7*5858a2dbSuwe  * Redistribution and use in source and binary forms, with or without
8*5858a2dbSuwe  * modification, are permitted provided that the following conditions
9*5858a2dbSuwe  * are met:
10*5858a2dbSuwe  * 1. Redistributions of source code must retain the above copyright
11*5858a2dbSuwe  *    notice, this list of conditions and the following disclaimer.
12*5858a2dbSuwe  * 2. Redistributions in binary form must reproduce the above copyright
13*5858a2dbSuwe  *    notice, this list of conditions and the following disclaimer in the
14*5858a2dbSuwe  *    documentation and/or other materials provided with the distribution.
15*5858a2dbSuwe  *
16*5858a2dbSuwe  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17*5858a2dbSuwe  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18*5858a2dbSuwe  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19*5858a2dbSuwe  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20*5858a2dbSuwe  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21*5858a2dbSuwe  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22*5858a2dbSuwe  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23*5858a2dbSuwe  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24*5858a2dbSuwe  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25*5858a2dbSuwe  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*5858a2dbSuwe  */
27*5858a2dbSuwe 
28*5858a2dbSuwe #include <sys/cdefs.h>
29*5858a2dbSuwe __RCSID("$NetBSD: move.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
30*5858a2dbSuwe 
31*5858a2dbSuwe #include "panel_impl.h"
32*5858a2dbSuwe 
33*5858a2dbSuwe 
34*5858a2dbSuwe int
move_panel(PANEL * p,int y,int x)35*5858a2dbSuwe move_panel(PANEL *p, int y, int x)
36*5858a2dbSuwe {
37*5858a2dbSuwe 	int oldy, oldx;
38*5858a2dbSuwe 
39*5858a2dbSuwe 	if (__predict_false(p == NULL))
40*5858a2dbSuwe 		return ERR;
41*5858a2dbSuwe 
42*5858a2dbSuwe 	getbegyx(p->win, oldy, oldx);
43*5858a2dbSuwe 	if (__predict_false(y == oldy && x == oldx))
44*5858a2dbSuwe 		return OK;
45*5858a2dbSuwe 
46*5858a2dbSuwe 	if (!PANEL_HIDDEN(p)) {
47*5858a2dbSuwe 		PANEL *other;
48*5858a2dbSuwe 
49*5858a2dbSuwe 		/* touch exposed areas at the old location now */
50*5858a2dbSuwe 		FOREACH_PANEL (other) {
51*5858a2dbSuwe 			if (other != p) {
52*5858a2dbSuwe 				touchoverlap(p->win, other->win);
53*5858a2dbSuwe 			}
54*5858a2dbSuwe 		}
55*5858a2dbSuwe 	}
56*5858a2dbSuwe 
57*5858a2dbSuwe 	return mvwin(p->win, y, x);
58*5858a2dbSuwe }
59