1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* Copyright (c) 1988 AT&T */ 23 /* All Rights Reserved */ 24 25 26 /* 27 * Copyright (c) 1997, by Sun Microsystems, Inc. 28 * All rights reserved. 29 */ 30 31 /* A panels subsystem built on curses--Move a panel to the top */ 32 33 /*LINTLIBRARY*/ 34 35 #include <sys/types.h> 36 #include <curses.h> 37 #include "private.h" 38 39 /* top_panel */ 40 int 41 top_panel(PANEL *panel) 42 { 43 _obscured_list *obs; 44 _obscured_list *prev_obs, *tmp; 45 46 if (!panel || panel == panel -> below) 47 return (ERR); 48 49 /* If the panel is already on top, there is nothing to do */ 50 51 if (_Top_panel == panel) 52 return (OK); 53 54 /* 55 * All the panels that used to obscure this panel are 56 * now obscured by this panel. 57 */ 58 59 if ((obs = panel -> obscured) != 0) { 60 do { 61 prev_obs = obs; 62 obs = obs -> next; 63 if ((tmp = prev_obs -> panel_p -> obscured) != 0) { 64 prev_obs->next = tmp->next; 65 tmp->next = prev_obs; 66 } else 67 prev_obs->next = 68 prev_obs->panel_p->obscured = prev_obs; 69 prev_obs -> panel_p = panel; 70 } 71 while (obs != panel -> obscured); 72 panel -> obscured = 0; 73 } 74 75 /* Move the panel to the top */ 76 77 if (panel == _Bottom_panel) 78 (_Bottom_panel = panel -> above) -> below = 0; 79 else { 80 panel -> above -> below = panel -> below; 81 panel -> below -> above = panel -> above; 82 } 83 84 panel -> above = 0; 85 panel -> below = _Top_panel; 86 _Top_panel = _Top_panel -> above = panel; 87 (void) touchwin(panel -> win); 88 89 return (OK); 90 } 91