home *** CD-ROM | disk | FTP | other *** search
- /*
- * desktop.c - This module contains the routines to access other windows
- * on the screen.
- *
- * Exported routines:
- * WalkWinTree
- * Get_Root
- */
-
- /**************************************************************************
- * palette - a colormap editor
- * Copyright (c) 1988 Wayne Mesard *
- * *
- * This is free software. It may be reproduced, retransmitted, *
- * redistributed and otherwise propogated at will, provided that *
- * no monetary profit is realized and that this notice remains *
- * intact and in place. *
- * *
- * Please direct bug reports, code enhancements and comments *
- * to mesard@BBN.COM. *
- * *
- **************************************************************************/
-
- #include <suntool/sunview.h>
- #include <suntool/panel.h>
- #include <sunwindow/win_enum.h>
- #include <stdio.h>
- #include <fcntl.h>
-
- #include "wsm_types.h"
-
- /*
- * WalkWinTree - Given a root fd, call the function Get_CMS_Data() on
- * every window on the screen, or if kids_onlyP, only call
- * it on the children of the root (i.e., top level frames).
- */
-
- boolean WalkWinTree(root_fd, kids_onlyP)
- int root_fd;
- boolean kids_onlyP;
- {
- enum win_enumerator_result Get_CMS_Data();
- enum win_enumerator_result result;
-
- if (kids_onlyP) {
- (void) Get_CMS_Data(root_fd);
- result = win_enumerate_children(root_fd, Get_CMS_Data, NULL);
- }
- else
- result = win_enumerate_subtree(root_fd, Get_CMS_Data, NULL);
- return ((result == Enum_Fail) ? false : true);
- }
-
-
-
- /*
- * Get_Root - Given a window, return an open fd of its root window.
- */
-
- int Get_Root(win)
- Window win;
- {
- struct screen rootscreen;
-
- win_screenget((int) window_get(win, WIN_FD), &rootscreen);
- return(open(rootscreen.scr_rootname, O_RDONLY));
- }
-
-
-
- /*
- * Get_CMS_Data - Given a window fd, get its color map, and if this map
- * isn't in the table yet (because it's not being shared with
- * another window), call MakeCMS() to have it inserted.
- */
-
- static enum win_enumerator_result Get_CMS_Data(fd)
- int fd;
- {
- extern char *malloc();
- boolean MakeCMS();
- struct colormapseg cmsdata;
- struct cms_map themap;
- int planes;
- Pixwin *pw;
- enum win_enumerator_result result = Enum_Normal;
-
- pw = (Pixwin *) pw_open(fd);
- pw_getattributes(pw, &planes);
- pw_getcmsdata(pw, &cmsdata, &planes);
- if (H_Member(cmsdata.cms_name, NIL(struct cms_map),
- NIL(Panel_item *)) == 0) {
- themap.cm_red = (unsigned char *) malloc((unsigned)cmsdata.cms_size);
- themap.cm_green = (unsigned char *) malloc((unsigned)cmsdata.cms_size);
- themap.cm_blue = (unsigned char *) malloc((unsigned)cmsdata.cms_size);
- pw_getcolormap(pw, 0, cmsdata.cms_size,
- themap.cm_red, themap.cm_green, themap.cm_blue);
- if (!MakeCMS(&cmsdata, &themap))
- result = Enum_Fail;
- }
- pw_close(pw);
- return(result);
- }
-
-