File: scrn_vis.c

package info (click to toggle)
xview 3.2p1.4-4
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 20,068 kB
  • ctags: 24,304
  • sloc: ansic: 241,105; yacc: 1,392; sh: 1,140; makefile: 273; lex: 76; perl: 54; asm: 50; cpp: 15
file content (117 lines) | stat: -rw-r--r-- 3,276 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef lint
#ifdef sccs
static char     sccsid[] = "@(#)scrn_vis.c 20.23 93/06/28";
#endif
#endif

/*
 *	(c) Copyright 1989 Sun Microsystems, Inc. Sun design patents 
 *	pending in the U.S. and foreign countries. See LEGAL_NOTICE 
 *	file for terms of the license.
 */

#include <xview_private/scrn_impl.h>
#include <xview/server.h>


Pkg_private Screen_visual *
screen_get_visual(display, screen, visual_info)
    Display	*display;
    Screen_info *screen;
    XVisualInfo *visual_info;
{
    Screen_visual *visual = screen->screen_visuals;
    
    /* Sanity check */
    if (!visual_info) {
	visual = NULL;
    } else {

	/* See if visual has already been created */
	while (visual && (visual->vinfo != visual_info))
	  visual = visual->next;
	
	/* If we didn't find one, create it and add it to the screen's list */
	if (!visual) {
	    visual = screen_new_visual(display, screen, 
				       RootWindow(display, screen->number),
				       visual_info->depth, visual_info);
	    if (visual) {
		/* The first screen visual is the default, which is always there */
		visual->next = screen->screen_visuals->next;
		screen->screen_visuals->next = visual;
	    }
	}
    }
    return(visual);
}


Pkg_private Screen_visual *
screen_get_image_visual(display, screen, xid, depth)
    Display	*display;
    Screen_info *screen;
    XID		 xid;
    unsigned int depth;
{
    Screen_visual *visual = screen->screen_visuals;
    
    /* See if visual has already been created */
    while (visual && (visual->vinfo || (visual->depth != depth)))
      visual = visual->next;
    
    /* If we didn't find one, create it and add it to the screen's list */
    if (!visual) {
	visual = screen_new_visual(display, screen, xid, depth, NULL);
	if (visual) {
	    /* The first screen visual is the default, which is always there */
	    visual->next = screen->screen_visuals->next;
	    screen->screen_visuals->next = visual;
	}
    }
    return(visual);
}


Pkg_private Screen_visual *
screen_new_visual(display, screen, xid, depth, visual_info)
    Display	*display;
    Screen_info *screen;
    XID		 xid;
    unsigned int depth;
    XVisualInfo *visual_info;
{
    Xv_private Xv_opaque cms_default_colormap();

    Screen_visual      *visual;
    GC			gc;
    XGCValues       	gc_values;

    /* Make sure colors are correct in gc. */
    /* BUG ALERT!  This is not handling color properly!!! */
    gc_values.foreground = BlackPixel(display, screen->number);
    gc_values.background = WhitePixel(display, screen->number);
    gc = XCreateGC(display, xid, 
		   GCForeground | GCBackground, &gc_values);
    if (!gc)
      return (Screen_visual *)NULL;

    visual = xv_alloc(Screen_visual);
    visual->screen = SCREEN_PUBLIC(screen);
    visual->server = screen->server;
    visual->display = display;
    visual->root_window = screen->root_window;
    visual->vinfo = visual_info;
    visual->depth = depth;
    if (visual_info == (XVisualInfo *)NULL)
      visual->colormaps = (Xv_opaque)NULL;
    else 
      visual->colormaps = 
	cms_default_colormap(screen->server, display, screen->number, visual_info);
    visual->gc = gc;
    visual->image_bitmap = (XImage *)NULL;
    visual->image_pixmap = (XImage *)NULL;

    visual->next = (Screen_visual *)NULL;
    return (visual);
}