150276Speter/**************************************************************************** 2166124Srafan * Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 3050276Speter * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 3150276Speter * and: Eric S. Raymond <esr@snark.thyrsus.com> * 3250276Speter ****************************************************************************/ 3350276Speter 3450276Speter/* 3550276Speter** lib_mvwin.c 3650276Speter** 3750276Speter** The routine mvwin(). 3850276Speter** 3950276Speter*/ 4050276Speter 4150276Speter#include <curses.priv.h> 4250276Speter 43166124SrafanMODULE_ID("$Id: lib_mvwin.c,v 1.14 2006/02/25 22:53:46 tom Exp $") 4450276Speter 4576726SpeterNCURSES_EXPORT(int) 4676726Spetermvwin(WINDOW *win, int by, int bx) 4750276Speter{ 4876726Speter T((T_CALLED("mvwin(%p,%d,%d)"), win, by, bx)); 4950276Speter 5076726Speter if (!win || (win->_flags & _ISPAD)) 5176726Speter returnCode(ERR); 5250276Speter 53166124Srafan /* 54166124Srafan * mvwin() should only modify the indices. See test/demo_menus.c and 55166124Srafan * test/movewindow.c for examples. 56166124Srafan */ 57166124Srafan#if 0 5876726Speter /* Copying subwindows is allowed, but it is expensive... */ 5976726Speter if (win->_flags & _SUBWIN) { 6076726Speter int err = ERR; 6176726Speter WINDOW *parent = win->_parent; 6276726Speter if (parent) { /* Now comes the complicated and costly part, you should really 6376726Speter * try to avoid to move subwindows. Because a subwindow shares 6476726Speter * the text buffers with its parent, one can't do a simple 6576726Speter * memmove of the text buffers. One has to create a copy, then 6676726Speter * to relocate the subwindow and then to do a copy. 6776726Speter */ 6876726Speter if ((by - parent->_begy == win->_pary) && 6976726Speter (bx - parent->_begx == win->_parx)) 7076726Speter err = OK; /* we don't actually move */ 7176726Speter else { 7276726Speter WINDOW *clone = dupwin(win); 7350276Speter if (clone) { 7476726Speter /* now we have the clone, so relocate win */ 7576726Speter 7676726Speter werase(win); /* Erase the original place */ 7797049Speter /* fill with parents background */ 7897049Speter wbkgrnd(win, CHREF(parent->_nc_bkgd)); 7976726Speter wsyncup(win); /* Tell the parent(s) */ 8076726Speter 8176726Speter err = mvderwin(win, 8276726Speter by - parent->_begy, 8376726Speter bx - parent->_begx); 8476726Speter if (err != ERR) { 8576726Speter err = copywin(clone, win, 8676726Speter 0, 0, 0, 0, win->_maxy, win->_maxx, 0); 8776726Speter if (ERR != err) 8876726Speter wsyncup(win); 8976726Speter } 9076726Speter if (ERR == delwin(clone)) 9176726Speter err = ERR; 9250276Speter } 9350276Speter } 9450276Speter } 9576726Speter returnCode(err); 9676726Speter } 97166124Srafan#endif 9850276Speter 9976726Speter if (by + win->_maxy > screen_lines - 1 10076726Speter || bx + win->_maxx > screen_columns - 1 10176726Speter || by < 0 10276726Speter || bx < 0) 10376726Speter returnCode(ERR); 10450276Speter 10576726Speter /* 10676726Speter * Whether or not the window is moved, touch the window's contents so 10776726Speter * that a following call to 'wrefresh()' will paint the window at the 10876726Speter * new location. This ensures that if the caller has refreshed another 10976726Speter * window at the same location, that this one will be displayed. 11076726Speter */ 11176726Speter win->_begy = by; 11276726Speter win->_begx = bx; 11376726Speter returnCode(touchwin(win)); 11450276Speter} 115