6 #include "../kernel/openbox.h"
10 Colormap render_colormap
;
12 void render_startup(void)
16 render_depth
= DefaultDepth(ob_display
, ob_screen
);
17 render_visual
= DefaultVisual(ob_display
, ob_screen
);
18 render_colormap
= DefaultColormap(ob_display
, ob_screen
);
20 if (render_depth
< 8) {
21 XVisualInfo vinfo_template
, *vinfo_return
;
22 // search for a TrueColor Visual... if we can't find one...
23 // we will use the default visual for the screen
27 vinfo_template
.screen
= ob_screen
;
28 vinfo_template
.class = TrueColor
;
29 vinfo_return
= XGetVisualInfo(ob_display
,
30 VisualScreenMask
| VisualClassMask
,
31 &vinfo_template
, &vinfo_nitems
);
35 for (i
= 0; i
< vinfo_nitems
; ++i
) {
36 if (vinfo_return
[i
].depth
> max_depth
) {
37 if (max_depth
== 24 && vinfo_return
[i
].depth
> 24)
38 break; // prefer 24 bit over 32
39 max_depth
= vinfo_return
[i
].depth
;
43 if (max_depth
< render_depth
) best
= -1;
46 render_depth
= vinfo_return
[best
].depth
;
47 render_visual
= vinfo_return
[best
].visual
;
48 render_colormap
= XCreateColormap(ob_display
, ob_root
, render_visual
,
55 void x_paint(Window win
, Appearance
*l
, int w
, int h
)
60 if (w
<= 0 || h
<= 0) return;
62 g_assert(l
->surface
.type
== Surface_Planar
);
63 // printf("painting window %ld\n", win);
65 if (l
->pixmap
!= None
) XFreePixmap(ob_display
, l
->pixmap
);
66 l
->pixmap
= XCreatePixmap(ob_display
, ob_root
, w
, h
, render_depth
);
67 g_assert(l
->pixmap
!= None
);
69 if (l
->xftdraw
!= NULL
)
70 XftDrawDestroy(l
->xftdraw
);
71 l
->xftdraw
= XftDrawCreate(ob_display
, l
->pixmap
, render_visual
,
73 g_assert(l
->xftdraw
!= NULL
);
75 if (l
->surface
.data
.planar
.pixel_data
!= NULL
)
76 g_free(l
->surface
.data
.planar
.pixel_data
);
77 l
->surface
.data
.planar
.pixel_data
= g_new(pixel32
, w
* h
);
79 if (l
->surface
.data
.planar
.grad
== Background_Solid
)
80 gradient_solid(l
, w
, h
);
81 else gradient_render(&l
->surface
, w
, h
);
82 for (i
= 0; i
< l
->textures
; i
++) {
83 printf("I AM DOING SOMETHING NOW\n");
86 if (l
->surface
.data
.planar
.grad
!= Background_Solid
) {
87 im
= XCreateImage(ob_display
, render_visual
, render_depth
,
88 ZPixmap
, 0, NULL
, w
, h
, 32, 0);
90 im
->byte_order
= endian
;
91 im
->data
= l
->surface
.data
.planar
.pixel_data
;
92 XPutImage(ob_display
, l
->pixmap
, DefaultGC(ob_display
, ob_screen
),
93 im
, 0, 0, 0, 0, w
, h
);
97 XSetWindowBackgroundPixmap(ob_display
, win
, l
->pixmap
);
98 XClearWindow(ob_display
, win
);
102 void gl_paint(Window win, Appearance *l)
104 glXMakeCurrent(ob_display, win, gl_context);
108 void render_shutdown(void)
112 Appearance
*appearance_new(SurfaceType type
, int numtex
)
117 out
= g_new(Appearance
, 1);
118 out
->surface
.type
= type
;
119 out
->textures
= numtex
;
121 if (numtex
) out
->texture
= g_new(Texture
, numtex
);
126 p
= &out
->surface
.data
.planar
;
129 p
->border_color
= NULL
;
130 p
->pixel_data
= NULL
;
136 Appearance
*appearance_copy(Appearance
*orig
)
138 PlanarSurface
*spo
, *spc
;
139 Appearance
*copy
= g_new(Appearance
, 1);
140 copy
->surface
.type
= orig
->surface
.type
;
141 switch (orig
->surface
.type
) {
143 spo
= &(orig
->surface
.data
.planar
);
144 spc
= &(copy
->surface
.data
.planar
);
145 spc
->grad
= spo
->grad
;
146 spc
->relief
= spo
->relief
;
147 spc
->bevel
= spo
->bevel
;
148 if (spo
->primary
!= NULL
)
149 spc
->primary
= color_new(spo
->primary
->r
,
152 else spc
->primary
= NULL
;
154 if (spo
->secondary
!= NULL
)
155 spc
->secondary
= color_new(spo
->secondary
->r
,
158 else spc
->secondary
= NULL
;
160 if (spo
->border_color
!= NULL
)
161 spc
->border_color
= color_new(spo
->border_color
->r
,
162 spo
->border_color
->g
,
163 spo
->border_color
->b
);
164 else spc
->border_color
= NULL
;
166 spc
->interlaced
= spo
->interlaced
;
167 spc
->border
= spo
->border
;
168 spc
->pixel_data
= NULL
;
171 copy
->textures
= orig
->textures
;
172 copy
->texture
= NULL
; /* XXX FIX ME */
174 copy
->xftdraw
= NULL
;
178 void appearance_free(Appearance
*a
)
183 if (a
->surface
.type
== Surface_Planar
) {
184 p
= &a
->surface
.data
.planar
;
185 if (p
->primary
!= NULL
) color_free(p
->primary
);
186 if (p
->secondary
!= NULL
) color_free(p
->secondary
);
187 if (p
->border_color
!= NULL
) color_free(p
->border_color
);