From: Dana Jansens Date: Fri, 20 Jun 2003 00:05:51 +0000 (+0000) Subject: remove non-planar surfaces X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=6e93be1d2e07ace0c21bc040cfb2e4890667d033;p=chaz%2Fopenbox remove non-planar surfaces --- diff --git a/openbox/frame.c b/openbox/frame.c index 211a275c..358144dc 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -310,7 +310,7 @@ void frame_adjust_area(Frame *self, gboolean moved, gboolean resized) self->bwidth; XMapWindow(ob_display, self->handle); - if (theme_a_focused_grip->surface.data.planar.grad == + if (theme_a_focused_grip->surface.grad == Background_ParentRelative) RECT_SET(self->a_focused_handle->area, 0, 0, self->width, theme_handle_height); @@ -319,7 +319,7 @@ void frame_adjust_area(Frame *self, gboolean moved, gboolean resized) theme_grip_width + self->bwidth, 0, self->width - (theme_grip_width + self->bwidth) * 2, theme_handle_height); - if (theme_a_unfocused_grip->surface.data.planar.grad == + if (theme_a_unfocused_grip->surface.grad == Background_ParentRelative) RECT_SET(self->a_unfocused_handle->area, 0, 0, self->width, theme_handle_height); diff --git a/openbox/framerender.c b/openbox/framerender.c index 737dfe95..11092333 100644 --- a/openbox/framerender.c +++ b/openbox/framerender.c @@ -79,33 +79,33 @@ void framerender_frame(Frame *self) paint(self->title, t); /* set parents for any parent relative guys */ - l->surface.data.planar.parent = t; - l->surface.data.planar.parentx = self->label_x; - l->surface.data.planar.parenty = theme_bevel; + l->surface.parent = t; + l->surface.parentx = self->label_x; + l->surface.parenty = theme_bevel; - m->surface.data.planar.parent = t; - m->surface.data.planar.parentx = self->max_x; - m->surface.data.planar.parenty = theme_bevel + 1; + m->surface.parent = t; + m->surface.parentx = self->max_x; + m->surface.parenty = theme_bevel + 1; - n->surface.data.planar.parent = t; - n->surface.data.planar.parentx = self->icon_x; - n->surface.data.planar.parenty = theme_bevel; + n->surface.parent = t; + n->surface.parentx = self->icon_x; + n->surface.parenty = theme_bevel; - i->surface.data.planar.parent = t; - i->surface.data.planar.parentx = self->iconify_x; - i->surface.data.planar.parenty = theme_bevel + 1; + i->surface.parent = t; + i->surface.parentx = self->iconify_x; + i->surface.parenty = theme_bevel + 1; - d->surface.data.planar.parent = t; - d->surface.data.planar.parentx = self->desk_x; - d->surface.data.planar.parenty = theme_bevel + 1; + d->surface.parent = t; + d->surface.parentx = self->desk_x; + d->surface.parenty = theme_bevel + 1; - s->surface.data.planar.parent = t; - s->surface.data.planar.parentx = self->shade_x; - s->surface.data.planar.parenty = theme_bevel + 1; + s->surface.parent = t; + s->surface.parentx = self->shade_x; + s->surface.parenty = theme_bevel + 1; - c->surface.data.planar.parent = t; - c->surface.data.planar.parentx = self->close_x; - c->surface.data.planar.parenty = theme_bevel + 1; + c->surface.parent = t; + c->surface.parentx = self->close_x; + c->surface.parenty = theme_bevel + 1; framerender_label(self, l); framerender_max(self, m); @@ -124,19 +124,19 @@ void framerender_frame(Frame *self) g = (self->focused ? theme_a_focused_grip : theme_a_unfocused_grip); - if (g->surface.data.planar.grad == Background_ParentRelative) { - g->surface.data.planar.parent = h; + if (g->surface.grad == Background_ParentRelative) { + g->surface.parent = h; paint(self->handle, h); } else paint(self->handle, h); - g->surface.data.planar.parentx = 0; - g->surface.data.planar.parenty = 0; + g->surface.parentx = 0; + g->surface.parenty = 0; paint(self->lgrip, g); - g->surface.data.planar.parentx = self->width - theme_grip_width; - g->surface.data.planar.parenty = 0; + g->surface.parentx = self->width - theme_grip_width; + g->surface.parenty = 0; paint(self->rgrip, g); } diff --git a/openbox/menu_render.c b/openbox/menu_render.c index 4df4e413..fcaf6869 100644 --- a/openbox/menu_render.c +++ b/openbox/menu_render.c @@ -133,9 +133,9 @@ void menu_entry_render(MenuEntry *self) XMoveResizeWindow(ob_display, self->item, 0, self->y, menu->size.width, menu->item_h); - a->surface.data.planar.parent = menu->a_items; - a->surface.data.planar.parentx = 0; - a->surface.data.planar.parenty = self->y; + a->surface.parent = menu->a_items; + a->surface.parentx = 0; + a->surface.parenty = self->y; paint(self->item, a); } diff --git a/openbox/popup.c b/openbox/popup.c index a550e815..7406d2f1 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -195,10 +195,10 @@ void popup_show(Popup *self, char *text, Icon *icon) RECT_SET(self->a_text->area, 0, 0, textw, texth); RECT_SET(self->a_text->texture[0].position, theme_bevel, theme_bevel, textw - theme_bevel * 2, texth - theme_bevel * 2); - self->a_text->surface.data.planar.parent = self->a_bg; - self->a_text->surface.data.planar.parentx = iconw + + self->a_text->surface.parent = self->a_bg; + self->a_text->surface.parentx = iconw + theme_bevel * (self->hasicon ? 2 : 1); - self->a_text->surface.data.planar.parenty = theme_bevel; + self->a_text->surface.parenty = theme_bevel; XMoveResizeWindow(ob_display, self->text, iconw + theme_bevel * (self->hasicon ? 2 : 1), theme_bevel, textw, texth); @@ -207,9 +207,9 @@ void popup_show(Popup *self, char *text, Icon *icon) if (iconw < 1) iconw = 1; /* sanity check for crashes */ RECT_SET(self->a_icon->area, 0, 0, iconw, texth); RECT_SET(self->a_icon->texture[0].position, 0, 0, iconw, texth); - self->a_icon->surface.data.planar.parent = self->a_bg; - self->a_icon->surface.data.planar.parentx = theme_bevel; - self->a_icon->surface.data.planar.parenty = theme_bevel; + self->a_icon->surface.parent = self->a_bg; + self->a_icon->surface.parentx = theme_bevel; + self->a_icon->surface.parenty = theme_bevel; XMoveResizeWindow(ob_display, self->icon, theme_bevel, theme_bevel, iconw, texth); } diff --git a/openbox/screen.c b/openbox/screen.c index 984010bf..85bf036d 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -336,7 +336,9 @@ void screen_set_desktop(guint num) /* focus the last focused window on the desktop, and ignore enter events from the switch so it doesnt mess with the focus */ while (XCheckTypedEvent(ob_display, EnterNotify, &e)); + g_message("switch fallback"); focus_fallback(Fallback_Desktop); + g_message("/switch fallback"); dispatch_ob(Event_Ob_Desktop, num, old); } diff --git a/render/gradient.c b/render/gradient.c index 31d4c730..602f93da 100644 --- a/render/gradient.c +++ b/render/gradient.c @@ -9,12 +9,12 @@ void gradient_render(Surface *sf, int w, int h) { - pixel32 *data = sf->data.planar.pixel_data; + pixel32 *data = sf->pixel_data; pixel32 current; unsigned int r,g,b; int off, x; - switch (sf->data.planar.grad) { + switch (sf->grad) { case Background_Solid: /* already handled */ return; case Background_Vertical: @@ -43,10 +43,10 @@ void gradient_render(Surface *sf, int w, int h) return; } - if (sf->data.planar.relief == Flat && sf->data.planar.border) { - r = sf->data.planar.border_color->r; - g = sf->data.planar.border_color->g; - b = sf->data.planar.border_color->b; + if (sf->relief == Flat && sf->border) { + r = sf->border_color->r; + g = sf->border_color->g; + b = sf->border_color->b; current = (r << default_red_offset) + (g << default_green_offset) + (b << default_blue_offset); @@ -60,27 +60,27 @@ void gradient_render(Surface *sf, int w, int h) } } - if (sf->data.planar.relief != Flat) { - if (sf->data.planar.bevel == Bevel1) { + if (sf->relief != Flat) { + if (sf->bevel == Bevel1) { for (off = 1, x = 1; x < w - 1; ++x, off++) highlight(data + off, data + off + (h-1) * w, - sf->data.planar.relief==Raised); + sf->relief==Raised); for (off = 0, x = 0; x < h; ++x, off++) highlight(data + off * w, data + off * w + w - 1, - sf->data.planar.relief==Raised); + sf->relief==Raised); } - if (sf->data.planar.bevel == Bevel2) { + if (sf->bevel == Bevel2) { for (off = 2, x = 2; x < w - 2; ++x, off++) highlight(data + off + w, data + off + (h-2) * w, - sf->data.planar.relief==Raised); + sf->relief==Raised); for (off = 1, x = 1; x < h-1; ++x, off++) highlight(data + off * w + 1, data + off * w + w - 2, - sf->data.planar.relief==Raised); + sf->relief==Raised); } } } @@ -89,25 +89,25 @@ void gradient_render(Surface *sf, int w, int h) void gradient_vertical(Surface *sf, int w, int h) { - pixel32 *data = sf->data.planar.pixel_data; + pixel32 *data = sf->pixel_data; pixel32 current; float dr, dg, db; unsigned int r,g,b; int x, y; - dr = (float)(sf->data.planar.secondary->r - sf->data.planar.primary->r); + dr = (float)(sf->secondary->r - sf->primary->r); dr/= (float)h; - dg = (float)(sf->data.planar.secondary->g - sf->data.planar.primary->g); + dg = (float)(sf->secondary->g - sf->primary->g); dg/= (float)h; - db = (float)(sf->data.planar.secondary->b - sf->data.planar.primary->b); + db = (float)(sf->secondary->b - sf->primary->b); db/= (float)h; for (y = 0; y < h; ++y) { - r = sf->data.planar.primary->r + (int)(dr * y); - g = sf->data.planar.primary->g + (int)(dg * y); - b = sf->data.planar.primary->b + (int)(db * y); + r = sf->primary->r + (int)(dr * y); + g = sf->primary->g + (int)(dg * y); + b = sf->primary->b + (int)(db * y); current = (r << default_red_offset) + (g << default_green_offset) + (b << default_blue_offset); @@ -118,25 +118,25 @@ void gradient_vertical(Surface *sf, int w, int h) void gradient_horizontal(Surface *sf, int w, int h) { - pixel32 *data = sf->data.planar.pixel_data; + pixel32 *data = sf->pixel_data; pixel32 current; float dr, dg, db; unsigned int r,g,b; int x, y; - dr = (float)(sf->data.planar.secondary->r - sf->data.planar.primary->r); + dr = (float)(sf->secondary->r - sf->primary->r); dr/= (float)w; - dg = (float)(sf->data.planar.secondary->g - sf->data.planar.primary->g); + dg = (float)(sf->secondary->g - sf->primary->g); dg/= (float)w; - db = (float)(sf->data.planar.secondary->b - sf->data.planar.primary->b); + db = (float)(sf->secondary->b - sf->primary->b); db/= (float)w; for (x = 0; x < w; ++x, ++data) { - r = sf->data.planar.primary->r + (int)(dr * x); - g = sf->data.planar.primary->g + (int)(dg * x); - b = sf->data.planar.primary->b + (int)(db * x); + r = sf->primary->r + (int)(dr * x); + g = sf->primary->g + (int)(dg * x); + b = sf->primary->b + (int)(db * x); current = (r << default_red_offset) + (g << default_green_offset) + (b << default_blue_offset); @@ -147,33 +147,33 @@ void gradient_horizontal(Surface *sf, int w, int h) void gradient_diagonal(Surface *sf, int w, int h) { - pixel32 *data = sf->data.planar.pixel_data; + pixel32 *data = sf->pixel_data; pixel32 current; float drx, dgx, dbx, dry, dgy, dby; unsigned int r,g,b; int x, y; for (y = 0; y < h; ++y) { - drx = (float)(sf->data.planar.secondary->r - - sf->data.planar.primary->r); + drx = (float)(sf->secondary->r - + sf->primary->r); dry = drx/(float)h; drx/= (float)w; - dgx = (float)(sf->data.planar.secondary->g - - sf->data.planar.primary->g); + dgx = (float)(sf->secondary->g - + sf->primary->g); dgy = dgx/(float)h; dgx/= (float)w; - dbx = (float)(sf->data.planar.secondary->b - - sf->data.planar.primary->b); + dbx = (float)(sf->secondary->b - + sf->primary->b); dby = dbx/(float)h; dbx/= (float)w; for (x = 0; x < w; ++x, ++data) { - r = sf->data.planar.primary->r + + r = sf->primary->r + ((int)(drx * x) + (int)(dry * y))/2; - g = sf->data.planar.primary->g + + g = sf->primary->g + ((int)(dgx * x) + (int)(dgy * y))/2; - b = sf->data.planar.primary->b + + b = sf->primary->b + ((int)(dbx * x) + (int)(dby * y))/2; current = (r << default_red_offset) + (g << default_green_offset) @@ -185,33 +185,33 @@ void gradient_diagonal(Surface *sf, int w, int h) void gradient_crossdiagonal(Surface *sf, int w, int h) { - pixel32 *data = sf->data.planar.pixel_data; + pixel32 *data = sf->pixel_data; pixel32 current; float drx, dgx, dbx, dry, dgy, dby; unsigned int r,g,b; int x, y; for (y = 0; y < h; ++y) { - drx = (float)(sf->data.planar.secondary->r - - sf->data.planar.primary->r); + drx = (float)(sf->secondary->r - + sf->primary->r); dry = drx/(float)h; drx/= (float)w; - dgx = (float)(sf->data.planar.secondary->g - - sf->data.planar.primary->g); + dgx = (float)(sf->secondary->g - + sf->primary->g); dgy = dgx/(float)h; dgx/= (float)w; - dbx = (float)(sf->data.planar.secondary->b - - sf->data.planar.primary->b); + dbx = (float)(sf->secondary->b - + sf->primary->b); dby = dbx/(float)h; dbx/= (float)w; for (x = w; x > 0; --x, ++data) { - r = sf->data.planar.primary->r + + r = sf->primary->r + ((int)(drx * (x-1)) + (int)(dry * y))/2; - g = sf->data.planar.primary->g + + g = sf->primary->g + ((int)(dgx * (x-1)) + (int)(dgy * y))/2; - b = sf->data.planar.primary->b + + b = sf->primary->b + ((int)(dbx * (x-1)) + (int)(dby * y))/2; current = (r << default_red_offset) + (g << default_green_offset) @@ -260,36 +260,36 @@ static void create_bevel_colors(Appearance *l) int r, g, b; /* light color */ - r = l->surface.data.planar.primary->r; + r = l->surface.primary->r; r += r >> 1; - g = l->surface.data.planar.primary->g; + g = l->surface.primary->g; g += g >> 1; - b = l->surface.data.planar.primary->b; + b = l->surface.primary->b; b += b >> 1; if (r > 0xFF) r = 0xFF; if (g > 0xFF) g = 0xFF; if (b > 0xFF) b = 0xFF; - g_assert(!l->surface.data.planar.bevel_light); - l->surface.data.planar.bevel_light = color_new(r, g, b); - color_allocate_gc(l->surface.data.planar.bevel_light); + g_assert(!l->surface.bevel_light); + l->surface.bevel_light = color_new(r, g, b); + color_allocate_gc(l->surface.bevel_light); /* dark color */ - r = l->surface.data.planar.primary->r; + r = l->surface.primary->r; r = (r >> 1) + (r >> 2); - g = l->surface.data.planar.primary->g; + g = l->surface.primary->g; g = (g >> 1) + (g >> 2); - b = l->surface.data.planar.primary->b; + b = l->surface.primary->b; b = (b >> 1) + (b >> 2); - g_assert(!l->surface.data.planar.bevel_dark); - l->surface.data.planar.bevel_dark = color_new(r, g, b); - color_allocate_gc(l->surface.data.planar.bevel_dark); + g_assert(!l->surface.bevel_dark); + l->surface.bevel_dark = color_new(r, g, b); + color_allocate_gc(l->surface.bevel_dark); } void gradient_solid(Appearance *l, int x, int y, int w, int h) { pixel32 pix; int i, a, b; - PlanarSurface *sp = &l->surface.data.planar; + Surface *sp = &l->surface; int left = x, top = y, right = x + w - 1, bottom = y + h - 1; if (sp->primary->gc == None) @@ -396,33 +396,33 @@ void gradient_solid(Appearance *l, int x, int y, int w, int h) void gradient_pyramid(Surface *sf, int inw, int inh) { - pixel32 *data = sf->data.planar.pixel_data; + pixel32 *data = sf->pixel_data; pixel32 *end = data + inw*inh - 1; pixel32 current; float drx, dgx, dbx, dry, dgy, dby; unsigned int r,g,b; int x, y, h=(inh/2) + 1, w=(inw/2) + 1; for (y = 0; y < h; ++y) { - drx = (float)(sf->data.planar.secondary->r - - sf->data.planar.primary->r); + drx = (float)(sf->secondary->r - + sf->primary->r); dry = drx/(float)h; drx/= (float)w; - dgx = (float)(sf->data.planar.secondary->g - - sf->data.planar.primary->g); + dgx = (float)(sf->secondary->g - + sf->primary->g); dgy = dgx/(float)h; dgx/= (float)w; - dbx = (float)(sf->data.planar.secondary->b - - sf->data.planar.primary->b); + dbx = (float)(sf->secondary->b - + sf->primary->b); dby = dbx/(float)h; dbx/= (float)w; for (x = 0; x < w; ++x, data) { - r = sf->data.planar.primary->r + + r = sf->primary->r + ((int)(drx * x) + (int)(dry * y))/2; - g = sf->data.planar.primary->g + + g = sf->primary->g + ((int)(dgx * x) + (int)(dgy * y))/2; - b = sf->data.planar.primary->b + + b = sf->primary->b + ((int)(dbx * x) + (int)(dby * y))/2; current = (r << default_red_offset) + (g << default_green_offset) @@ -439,7 +439,7 @@ void gradient_pyramid(Surface *sf, int inw, int inh) void gradient_rectangle(Surface *sf, int inw, int inh) { - pixel32 *data = sf->data.planar.pixel_data; + pixel32 *data = sf->pixel_data; pixel32 *end = data + inw*inh - 1; pixel32 current; float drx, dgx, dbx, dry, dgy, dby; @@ -448,27 +448,27 @@ void gradient_rectangle(Surface *sf, int inw, int inh) int val; for (y = 0; y < h; ++y) { - drx = (float)(sf->data.planar.primary->r - - sf->data.planar.secondary->r); + drx = (float)(sf->primary->r - + sf->secondary->r); dry = drx/(float)h; drx/= (float)w; - dgx = (float)(sf->data.planar.primary->g - - sf->data.planar.secondary->g); + dgx = (float)(sf->primary->g - + sf->secondary->g); dgy = dgx/(float)h; dgx/= (float)w; - dbx = (float)(sf->data.planar.primary->b - - sf->data.planar.secondary->b); + dbx = (float)(sf->primary->b - + sf->secondary->b); dby = dbx/(float)h; dbx/= (float)w; for (x = 0; x < w; ++x, data) { if ((float)x/(float)w < (float)y/(float)h) val = (int)(drx * x); else val = (int)(dry * y); - r = sf->data.planar.secondary->r + val; - g = sf->data.planar.secondary->g + val; - b = sf->data.planar.secondary->b + val; + r = sf->secondary->r + val; + g = sf->secondary->g + val; + b = sf->secondary->b + val; current = (r << default_red_offset) + (g << default_green_offset) + (b << default_blue_offset); @@ -484,7 +484,7 @@ void gradient_rectangle(Surface *sf, int inw, int inh) void gradient_pipecross(Surface *sf, int inw, int inh) { - pixel32 *data = sf->data.planar.pixel_data; + pixel32 *data = sf->pixel_data; pixel32 *end = data + inw*inh - 1; pixel32 current; float drx, dgx, dbx, dry, dgy, dby; @@ -493,27 +493,27 @@ void gradient_pipecross(Surface *sf, int inw, int inh) int val; for (y = 0; y < h; ++y) { - drx = (float)(sf->data.planar.secondary->r - - sf->data.planar.primary->r); + drx = (float)(sf->secondary->r - + sf->primary->r); dry = drx/(float)h; drx/= (float)w; - dgx = (float)(sf->data.planar.secondary->g - - sf->data.planar.primary->g); + dgx = (float)(sf->secondary->g - + sf->primary->g); dgy = dgx/(float)h; dgx/= (float)w; - dbx = (float)(sf->data.planar.secondary->b - - sf->data.planar.primary->b); + dbx = (float)(sf->secondary->b - + sf->primary->b); dby = dbx/(float)h; dbx/= (float)w; for (x = 0; x < w; ++x, data) { if ((float)x/(float)w > (float)y/(float)h) val = (int)(drx * x); else val = (int)(dry * y); - r = sf->data.planar.primary->r + val; - g = sf->data.planar.primary->g + val; - b = sf->data.planar.primary->b + val; + r = sf->primary->r + val; + g = sf->primary->g + val; + b = sf->primary->b + val; current = (r << default_red_offset) + (g << default_green_offset) + (b << default_blue_offset); @@ -533,15 +533,15 @@ void render_gl_gradient(Surface *sf, int x, int y, int w, int h) float sr, sg, sb; float ar, ag, ab; - pr = (float)sf->data.planar.primary->r/255.0; - pg = (float)sf->data.planar.primary->g/255.0; - pb = (float)sf->data.planar.primary->b/255.0; - if (sf->data.planar.secondary) { - sr = (float)sf->data.planar.secondary->r/255.0; - sg = (float)sf->data.planar.secondary->g/255.0; - sb = (float)sf->data.planar.secondary->b/255.0; + pr = (float)sf->primary->r/255.0; + pg = (float)sf->primary->g/255.0; + pb = (float)sf->primary->b/255.0; + if (sf->secondary) { + sr = (float)sf->secondary->r/255.0; + sg = (float)sf->secondary->g/255.0; + sb = (float)sf->secondary->b/255.0; } - switch (sf->data.planar.grad) { + switch (sf->grad) { case Background_Solid: /* already handled */ glBegin(GL_TRIANGLES); glColor3f(pr, pg, pb); diff --git a/render/render.c b/render/render.c index 712ed7fb..3a129012 100644 --- a/render/render.c +++ b/render/render.c @@ -272,8 +272,6 @@ void x_paint(Window win, Appearance *l) if (w <= 0 || h <= 0 || x+w <= 0 || y+h <= 0) return; - g_assert(l->surface.type == Surface_Planar); - oldp = l->pixmap; /* save to free after changing the visible pixmap */ l->pixmap = XCreatePixmap(ob_display, ob_root, x+w, y+h, render_depth); g_assert(l->pixmap != None); @@ -284,29 +282,29 @@ void x_paint(Window win, Appearance *l) render_colormap); g_assert(l->xftdraw != NULL); - g_free(l->surface.data.planar.pixel_data); - l->surface.data.planar.pixel_data = g_new(pixel32, w * h); + g_free(l->surface.pixel_data); + l->surface.pixel_data = g_new(pixel32, w * h); - if (l->surface.data.planar.grad == Background_ParentRelative) { - sw = l->surface.data.planar.parent->area.width; - source = l->surface.data.planar.parent->surface.data.planar.pixel_data - + l->surface.data.planar.parentx - + sw * l->surface.data.planar.parenty; - dest = l->surface.data.planar.pixel_data; + if (l->surface.grad == Background_ParentRelative) { + sw = l->surface.parent->area.width; + source = l->surface.parent->surface.pixel_data + + l->surface.parentx + + sw * l->surface.parenty; + dest = l->surface.pixel_data; for (i = 0; i < h; i++, source += sw, dest += w) { memcpy(dest, source, w * sizeof(pixel32)); } } - else if (l->surface.data.planar.grad == Background_Solid) + else if (l->surface.grad == Background_Solid) gradient_solid(l, x, y, w, h); else gradient_render(&l->surface, w, h); for (i = 0; i < l->textures; i++) { tarea = l->texture[i].position; - if (l->surface.data.planar.grad != Background_ParentRelative) { - if (l->surface.data.planar.relief != Flat) { - switch (l->surface.data.planar.bevel) { + if (l->surface.grad != Background_ParentRelative) { + if (l->surface.relief != Flat) { + switch (l->surface.bevel) { case Bevel1: tarea.x += 1; tarea.y += 1; tarea.width -= 2; tarea.height -= 2; @@ -316,7 +314,7 @@ void x_paint(Window win, Appearance *l) tarea.width -= 4; tarea.height -= 4; break; } - } else if (l->surface.data.planar.border) { + } else if (l->surface.border) { tarea.x += 1; tarea.y += 1; tarea.width -= 2; tarea.height -= 2; } @@ -326,8 +324,8 @@ void x_paint(Window win, Appearance *l) case Text: if (!transferred) { transferred = 1; - if (l->surface.data.planar.grad != Background_Solid) - pixel32_to_pixmap(l->surface.data.planar.pixel_data, + if (l->surface.grad != Background_Solid) + pixel32_to_pixmap(l->surface.pixel_data, l->pixmap,x,y,w,h); } if (l->xftdraw == NULL) { @@ -340,8 +338,8 @@ void x_paint(Window win, Appearance *l) case Bitmask: if (!transferred) { transferred = 1; - if (l->surface.data.planar.grad != Background_Solid) - pixel32_to_pixmap(l->surface.data.planar.pixel_data, + if (l->surface.grad != Background_Solid) + pixel32_to_pixmap(l->surface.pixel_data, l->pixmap,x,y,w,h); } if (l->texture[i].data.mask.color->gc == None) @@ -350,7 +348,7 @@ void x_paint(Window win, Appearance *l) &tarea); break; case RGBA: - image_draw(l->surface.data.planar.pixel_data, + image_draw(l->surface.pixel_data, &l->texture[i].data.rgba, &tarea, &l->area); break; @@ -359,8 +357,8 @@ void x_paint(Window win, Appearance *l) if (!transferred) { transferred = 1; - if (l->surface.data.planar.grad != Background_Solid) - pixel32_to_pixmap(l->surface.data.planar.pixel_data, l->pixmap + if (l->surface.grad != Background_Solid) + pixel32_to_pixmap(l->surface.pixel_data, l->pixmap ,x,y,w,h); } @@ -374,80 +372,72 @@ void render_shutdown(void) { } -Appearance *appearance_new(SurfaceType type, int numtex) +Appearance *appearance_new(int numtex) { - PlanarSurface *p; + Surface *p; Appearance *out; out = g_new(Appearance, 1); - out->surface.type = type; out->textures = numtex; out->xftdraw = NULL; if (numtex) out->texture = g_new0(Texture, numtex); else out->texture = NULL; out->pixmap = None; - switch (type) { - case Surface_Planar: - p = &out->surface.data.planar; - p->primary = NULL; - p->secondary = NULL; - p->border_color = NULL; - p->bevel_dark = NULL; - p->bevel_light = NULL; - p->pixel_data = NULL; - break; - } + p = &out->surface; + p->primary = NULL; + p->secondary = NULL; + p->border_color = NULL; + p->bevel_dark = NULL; + p->bevel_light = NULL; + p->pixel_data = NULL; return out; } Appearance *appearance_copy(Appearance *orig) { - PlanarSurface *spo, *spc; + Surface *spo, *spc; Appearance *copy = g_new(Appearance, 1); - copy->surface.type = orig->surface.type; - switch (orig->surface.type) { - case Surface_Planar: - spo = &(orig->surface.data.planar); - spc = &(copy->surface.data.planar); - spc->grad = spo->grad; - spc->relief = spo->relief; - spc->bevel = spo->bevel; - if (spo->primary != NULL) - spc->primary = color_new(spo->primary->r, - spo->primary->g, - spo->primary->b); - else spc->primary = NULL; - - if (spo->secondary != NULL) - spc->secondary = color_new(spo->secondary->r, - spo->secondary->g, - spo->secondary->b); - else spc->secondary = NULL; - - if (spo->border_color != NULL) - spc->border_color = color_new(spo->border_color->r, - spo->border_color->g, - spo->border_color->b); - else spc->border_color = NULL; - - if (spo->bevel_dark != NULL) - spc->bevel_dark = color_new(spo->bevel_dark->r, - spo->bevel_dark->g, - spo->bevel_dark->b); - else spc->bevel_dark = NULL; - - if (spo->bevel_light != NULL) - spc->bevel_light = color_new(spo->bevel_light->r, - spo->bevel_light->g, - spo->bevel_light->b); - else spc->bevel_light = NULL; - - spc->interlaced = spo->interlaced; - spc->border = spo->border; - spc->pixel_data = NULL; - break; - } + + spo = &(orig->surface); + spc = &(copy->surface); + spc->grad = spo->grad; + spc->relief = spo->relief; + spc->bevel = spo->bevel; + if (spo->primary != NULL) + spc->primary = color_new(spo->primary->r, + spo->primary->g, + spo->primary->b); + else spc->primary = NULL; + + if (spo->secondary != NULL) + spc->secondary = color_new(spo->secondary->r, + spo->secondary->g, + spo->secondary->b); + else spc->secondary = NULL; + + if (spo->border_color != NULL) + spc->border_color = color_new(spo->border_color->r, + spo->border_color->g, + spo->border_color->b); + else spc->border_color = NULL; + + if (spo->bevel_dark != NULL) + spc->bevel_dark = color_new(spo->bevel_dark->r, + spo->bevel_dark->g, + spo->bevel_dark->b); + else spc->bevel_dark = NULL; + + if (spo->bevel_light != NULL) + spc->bevel_light = color_new(spo->bevel_light->r, + spo->bevel_light->g, + spo->bevel_light->b); + else spc->bevel_light = NULL; + + spc->interlaced = spo->interlaced; + spc->border = spo->border; + spc->pixel_data = NULL; + copy->textures = orig->textures; copy->texture = g_memdup(orig->texture, orig->textures * sizeof(Texture)); copy->pixmap = None; @@ -458,20 +448,19 @@ Appearance *appearance_copy(Appearance *orig) void appearance_free(Appearance *a) { if (a) { - PlanarSurface *p; + Surface *p; if (a->pixmap != None) XFreePixmap(ob_display, a->pixmap); if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw); if (a->textures) g_free(a->texture); - if (a->surface.type == Surface_Planar) { - p = &a->surface.data.planar; - color_free(p->primary); - color_free(p->secondary); - color_free(p->border_color); - color_free(p->bevel_dark); - color_free(p->bevel_light); - g_free(p->pixel_data); - } + p = &a->surface; + color_free(p->primary); + color_free(p->secondary); + color_free(p->border_color); + color_free(p->bevel_dark); + color_free(p->bevel_light); + g_free(p->pixel_data); + g_free(a); } } @@ -504,46 +493,42 @@ void appearance_minsize(Appearance *l, int *w, int *h) int m; *w = *h = 1; - switch (l->surface.type) { - case Surface_Planar: - if (l->surface.data.planar.relief != Flat) { - switch (l->surface.data.planar.bevel) { - case Bevel1: - *w = *h = 2; - break; - case Bevel2: - *w = *h = 4; - break; - } - } else if (l->surface.data.planar.border) + if (l->surface.relief != Flat) { + switch (l->surface.bevel) { + case Bevel1: *w = *h = 2; + break; + case Bevel2: + *w = *h = 4; + break; + } + } else if (l->surface.border) + *w = *h = 2; - for (i = 0; i < l->textures; ++i) { - switch (l->texture[i].type) { - case Bitmask: - *w += l->texture[i].data.mask.mask->w; - *h += l->texture[i].data.mask.mask->h; - break; - case Text: - m = font_measure_string(l->texture[i].data.text.font, - l->texture[i].data.text.string, - l->texture[i].data.text.shadow, - l->texture[i].data.text.offset); - *w += m; - m = font_height(l->texture[i].data.text.font, - l->texture[i].data.text.shadow, - l->texture[i].data.text.offset); - *h += m; - break; - case RGBA: - *w += l->texture[i].data.rgba.width; - *h += l->texture[i].data.rgba.height; - break; - case NoTexture: - break; - } + for (i = 0; i < l->textures; ++i) { + switch (l->texture[i].type) { + case Bitmask: + *w += l->texture[i].data.mask.mask->w; + *h += l->texture[i].data.mask.mask->h; + break; + case Text: + m = font_measure_string(l->texture[i].data.text.font, + l->texture[i].data.text.string, + l->texture[i].data.text.shadow, + l->texture[i].data.text.offset); + *w += m; + m = font_height(l->texture[i].data.text.font, + l->texture[i].data.text.shadow, + l->texture[i].data.text.offset); + *h += m; + break; + case RGBA: + *w += l->texture[i].data.rgba.width; + *h += l->texture[i].data.rgba.height; + break; + case NoTexture: + break; } - break; } } @@ -636,7 +621,7 @@ g_assert(err != 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - if (l->surface.data.planar.grad == Background_ParentRelative) { + if (l->surface.grad == Background_ParentRelative) { printf("crap\n"); } else render_gl_gradient(&l->surface, absx+x, absy+y, absw, absh); diff --git a/render/render.h b/render/render.h index 16f5c31c..1b1cce1d 100644 --- a/render/render.h +++ b/render/render.h @@ -8,11 +8,6 @@ #include "color.h" #include "kernel/geom.h" -typedef enum { - Surface_Planar, - Surface_Nonplanar -} SurfaceType; - typedef enum { Flat, Raised, @@ -45,7 +40,7 @@ typedef enum { struct Appearance; -typedef struct PlanarSurface { +typedef struct Surface { SurfaceColorType grad; ReliefType relief; BevelType bevel; @@ -60,21 +55,6 @@ typedef struct PlanarSurface { int parentx; int parenty; pixel32 *pixel_data; -} PlanarSurface; - -typedef struct NonplanarSurface { - int poo; -} NonplanarSurface; - -typedef union { - PlanarSurface planar; - NonplanarSurface nonplanar; -} SurfaceData; - -typedef struct Surface { - SurfaceType type; - SurfaceColorType colortype; - SurfaceData data; } Surface; typedef struct { @@ -153,7 +133,7 @@ void init_appearance(Appearance *l); void x_paint(Window win, Appearance *l); void gl_paint(Window win, Appearance *l); void render_shutdown(void); -Appearance *appearance_new(SurfaceType type, int numtex); +Appearance *appearance_new(int numtex); Appearance *appearance_copy(Appearance *a); void appearance_free(Appearance *a); void truecolor_startup(void); diff --git a/render/test.c b/render/test.c index 7c3c83b3..4dfed619 100644 --- a/render/test.c +++ b/render/test.c @@ -50,11 +50,11 @@ int main() root = RootWindow (ob_display, DefaultScreen (ob_display)); render_startup(); - look = appearance_new(Surface_Planar, 0); - look->surface.data.planar.grad = Background_Pyramid; - look->surface.data.planar.secondary = color_parse("Yellow"); - look->surface.data.planar.primary = color_parse("Blue"); - look->surface.data.planar.interlaced = FALSE; + look = appearance_new(0); + look->surface.grad = Background_Pyramid; + look->surface.secondary = color_parse("Yellow"); + look->surface.primary = color_parse("Blue"); + look->surface.interlaced = FALSE; look->area.x = 0; look->area.y = 0; look->area.width = 500; diff --git a/render/theme.c b/render/theme.c index 8ba7a9dc..2ebcead3 100644 --- a/render/theme.c +++ b/render/theme.c @@ -113,12 +113,12 @@ void theme_startup() theme_shade_set_mask = theme_shade_unset_mask = NULL; theme_iconify_mask = theme_close_mask = NULL; - theme_a_focused_unpressed_max = appearance_new(Surface_Planar, 1); - theme_a_focused_pressed_max = appearance_new(Surface_Planar, 1); - theme_a_focused_pressed_set_max = appearance_new(Surface_Planar, 1); - theme_a_unfocused_unpressed_max = appearance_new(Surface_Planar, 1); - theme_a_unfocused_pressed_max = appearance_new(Surface_Planar, 1); - theme_a_unfocused_pressed_set_max = appearance_new(Surface_Planar, 1); + theme_a_focused_unpressed_max = appearance_new(1); + theme_a_focused_pressed_max = appearance_new(1); + theme_a_focused_pressed_set_max = appearance_new(1); + theme_a_unfocused_unpressed_max = appearance_new(1); + theme_a_unfocused_pressed_max = appearance_new(1); + theme_a_unfocused_pressed_set_max = appearance_new(1); theme_a_focused_unpressed_close = NULL; theme_a_focused_pressed_close = NULL; theme_a_unfocused_unpressed_close = NULL; @@ -139,26 +139,26 @@ void theme_startup() theme_a_focused_pressed_iconify = NULL; theme_a_unfocused_unpressed_iconify = NULL; theme_a_unfocused_pressed_iconify = NULL; - theme_a_focused_grip = appearance_new(Surface_Planar, 0); - theme_a_unfocused_grip = appearance_new(Surface_Planar, 0); - theme_a_focused_title = appearance_new(Surface_Planar, 0); - theme_a_unfocused_title = appearance_new(Surface_Planar, 0); - theme_a_focused_label = appearance_new(Surface_Planar, 1); - theme_a_unfocused_label = appearance_new(Surface_Planar, 1); - theme_a_icon = appearance_new(Surface_Planar, 1); - theme_a_focused_handle = appearance_new(Surface_Planar, 0); - theme_a_unfocused_handle = appearance_new(Surface_Planar, 0); - theme_a_menu = appearance_new(Surface_Planar, 0); - theme_a_menu_title = appearance_new(Surface_Planar, 1); - theme_a_menu_item = appearance_new(Surface_Planar, 1); - theme_a_menu_disabled = appearance_new(Surface_Planar, 1); - theme_a_menu_hilite = appearance_new(Surface_Planar, 1); - - theme_app_hilite_bg = appearance_new(Surface_Planar, 0); - theme_app_unhilite_bg = appearance_new(Surface_Planar, 0); - theme_app_hilite_label = appearance_new(Surface_Planar, 1); - theme_app_unhilite_label = appearance_new(Surface_Planar, 1); - theme_app_icon = appearance_new(Surface_Planar, 1); + theme_a_focused_grip = appearance_new(0); + theme_a_unfocused_grip = appearance_new(0); + theme_a_focused_title = appearance_new(0); + theme_a_unfocused_title = appearance_new(0); + theme_a_focused_label = appearance_new(1); + theme_a_unfocused_label = appearance_new(1); + theme_a_icon = appearance_new(1); + theme_a_focused_handle = appearance_new(0); + theme_a_unfocused_handle = appearance_new(0); + theme_a_menu = appearance_new(0); + theme_a_menu_title = appearance_new(1); + theme_a_menu_item = appearance_new(1); + theme_a_menu_disabled = appearance_new(1); + theme_a_menu_hilite = appearance_new(1); + + theme_app_hilite_bg = appearance_new(0); + theme_app_unhilite_bg = appearance_new(0); + theme_app_hilite_label = appearance_new(1); + theme_app_unhilite_label = appearance_new(1); + theme_app_icon = appearance_new(1); } @@ -455,19 +455,19 @@ static gboolean read_appearance(XrmDatabase db, char *rname, Appearance *value) if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr != NULL) { parse_appearance(retvalue.addr, - &value->surface.data.planar.grad, - &value->surface.data.planar.relief, - &value->surface.data.planar.bevel, - &value->surface.data.planar.interlaced, - &value->surface.data.planar.border); - if (!read_color(db, cname, &value->surface.data.planar.primary)) - value->surface.data.planar.primary = color_new(0, 0, 0); - if (!read_color(db, ctoname, &value->surface.data.planar.secondary)) - value->surface.data.planar.secondary = color_new(0, 0, 0); - if (value->surface.data.planar.border) + &value->surface.grad, + &value->surface.relief, + &value->surface.bevel, + &value->surface.interlaced, + &value->surface.border); + if (!read_color(db, cname, &value->surface.primary)) + value->surface.primary = color_new(0, 0, 0); + if (!read_color(db, ctoname, &value->surface.secondary)) + value->surface.secondary = color_new(0, 0, 0); + if (value->surface.border) if (!read_color(db, bcname, - &value->surface.data.planar.border_color)) - value->surface.data.planar.border_color = color_new(0, 0, 0); + &value->surface.border_color)) + value->surface.border_color = color_new(0, 0, 0); ret = TRUE; } @@ -480,13 +480,13 @@ static gboolean read_appearance(XrmDatabase db, char *rname, Appearance *value) static void set_default_appearance(Appearance *a) { - a->surface.data.planar.grad = Background_Solid; - a->surface.data.planar.relief = Flat; - a->surface.data.planar.bevel = Bevel1; - a->surface.data.planar.interlaced = FALSE; - a->surface.data.planar.border = FALSE; - a->surface.data.planar.primary = color_new(0, 0, 0); - a->surface.data.planar.secondary = color_new(0, 0, 0); + a->surface.grad = Background_Solid; + a->surface.relief = Flat; + a->surface.bevel = Bevel1; + a->surface.interlaced = FALSE; + a->surface.border = FALSE; + a->surface.primary = color_new(0, 0, 0); + a->surface.secondary = color_new(0, 0, 0); } char *theme_load(char *theme) @@ -515,7 +515,7 @@ char *theme_load(char *theme) } /* load the font stuff */ - font_str = "arial-8:bold"; + font_str = "arial:bold:pixelsize=10:minsize"; theme_winfont_shadow = FALSE; if (read_string(db, "window.xft.flags", &str)) { @@ -810,7 +810,7 @@ char *theme_load(char *theme) theme_a_focused_pressed_set_max = appearance_copy(theme_a_focused_pressed_max); - theme_a_icon->surface.data.planar.grad = Background_ParentRelative; + theme_a_icon->surface.grad = Background_ParentRelative; /* set up the textures */ theme_a_focused_label->texture[0].type = @@ -861,10 +861,9 @@ char *theme_load(char *theme) theme_mtitlefont_shadow_tint; theme_a_menu_title->texture[0].data.text.color = theme_menu_title_color; - theme_a_menu_item->surface.data.planar.grad = - theme_a_menu_disabled->surface.data.planar.grad = - theme_app_icon->surface.data.planar.grad = - Background_ParentRelative; + theme_a_menu_item->surface.grad = + theme_a_menu_disabled->surface.grad = + theme_app_icon->surface.grad = Background_ParentRelative; theme_a_menu_item->texture[0].type = theme_a_menu_disabled->texture[0].type =