simply the render interface by not requiring the setting of all the areas. only take a w and h in paint(). best font layout ever.
This commit is contained in:
parent
349d0167db
commit
cd12a2eae5
15 changed files with 149 additions and 436 deletions
|
@ -349,11 +349,10 @@ void dock_configure()
|
||||||
dock->h -= theme_bwidth * 2;
|
dock->h -= theme_bwidth * 2;
|
||||||
|
|
||||||
if (dock->w > 0 && dock->h > 0) {
|
if (dock->w > 0 && dock->h > 0) {
|
||||||
RECT_SET(dock->a_frame->area, 0, 0, dock->w, dock->h);
|
|
||||||
XMoveResizeWindow(ob_display, dock->frame,
|
XMoveResizeWindow(ob_display, dock->frame,
|
||||||
dock->x, dock->y, dock->w, dock->h);
|
dock->x, dock->y, dock->w, dock->h);
|
||||||
|
|
||||||
paint(dock->frame, dock->a_frame);
|
paint(dock->frame, dock->a_frame, dock->w, dock->h);
|
||||||
XMapWindow(ob_display, dock->frame);
|
XMapWindow(ob_display, dock->frame);
|
||||||
} else
|
} else
|
||||||
XUnmapWindow(ob_display, dock->frame);
|
XUnmapWindow(ob_display, dock->frame);
|
||||||
|
|
|
@ -14,65 +14,6 @@ static void layout_title(Frame *self);
|
||||||
|
|
||||||
void frame_startup()
|
void frame_startup()
|
||||||
{
|
{
|
||||||
RECT_SET(theme_a_focused_pressed_desk->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_pressed_set_desk->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_unpressed_desk->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_pressed_desk->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_pressed_set_desk->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_unpressed_desk->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_pressed_shade->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_pressed_set_shade->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_unpressed_shade->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_pressed_shade->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_pressed_set_shade->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_unpressed_shade->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_pressed_iconify->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_unpressed_iconify->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_pressed_iconify->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_unpressed_iconify->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_unpressed_iconify->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_pressed_max->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_pressed_set_max->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_unpressed_max->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_pressed_max->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_pressed_set_max->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_unpressed_max->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_pressed_close->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_focused_unpressed_close->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_pressed_close->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
RECT_SET(theme_a_unfocused_unpressed_close->area, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
|
|
||||||
RECT_SET(theme_a_focused_grip->area, 0, 0,
|
|
||||||
theme_grip_width, theme_handle_height);
|
|
||||||
RECT_SET(theme_a_unfocused_grip->area, 0, 0,
|
|
||||||
theme_grip_width, theme_handle_height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void frame_shutdown()
|
void frame_shutdown()
|
||||||
|
@ -287,11 +228,6 @@ void frame_adjust_area(Frame *self, gboolean moved, gboolean resized)
|
||||||
self->innersize.top += theme_title_height + self->bwidth;
|
self->innersize.top += theme_title_height + self->bwidth;
|
||||||
XMapWindow(ob_display, self->title);
|
XMapWindow(ob_display, self->title);
|
||||||
|
|
||||||
RECT_SET(self->a_focused_title->area, 0, 0,
|
|
||||||
self->width, theme_title_height);
|
|
||||||
RECT_SET(self->a_unfocused_title->area, 0, 0,
|
|
||||||
self->width, theme_title_height);
|
|
||||||
|
|
||||||
/* layout the title bar elements */
|
/* layout the title bar elements */
|
||||||
layout_title(self);
|
layout_title(self);
|
||||||
} else
|
} else
|
||||||
|
@ -310,25 +246,11 @@ void frame_adjust_area(Frame *self, gboolean moved, gboolean resized)
|
||||||
self->bwidth;
|
self->bwidth;
|
||||||
XMapWindow(ob_display, self->handle);
|
XMapWindow(ob_display, self->handle);
|
||||||
|
|
||||||
if (theme_a_focused_grip->surface.grad ==
|
/* XXX make a subwindow with these dimentions?
|
||||||
Background_ParentRelative)
|
theme_grip_width + self->bwidth, 0,
|
||||||
RECT_SET(self->a_focused_handle->area, 0, 0,
|
self->width - (theme_grip_width + self->bwidth) * 2,
|
||||||
self->width, theme_handle_height);
|
theme_handle_height);
|
||||||
else
|
*/
|
||||||
RECT_SET(self->a_focused_handle->area,
|
|
||||||
theme_grip_width + self->bwidth, 0,
|
|
||||||
self->width - (theme_grip_width + self->bwidth) * 2,
|
|
||||||
theme_handle_height);
|
|
||||||
if (theme_a_unfocused_grip->surface.grad ==
|
|
||||||
Background_ParentRelative)
|
|
||||||
RECT_SET(self->a_unfocused_handle->area, 0, 0,
|
|
||||||
self->width, theme_handle_height);
|
|
||||||
else
|
|
||||||
RECT_SET(self->a_unfocused_handle->area,
|
|
||||||
theme_grip_width + self->bwidth, 0,
|
|
||||||
self->width - (theme_grip_width + self->bwidth) * 2,
|
|
||||||
theme_handle_height);
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
XUnmapWindow(ob_display, self->handle);
|
XUnmapWindow(ob_display, self->handle);
|
||||||
}
|
}
|
||||||
|
@ -561,8 +483,6 @@ static void layout_title(Frame *self)
|
||||||
case 'N':
|
case 'N':
|
||||||
if (!n) break;
|
if (!n) break;
|
||||||
self->icon_x = x;
|
self->icon_x = x;
|
||||||
RECT_SET(self->a_icon->area, 0, 0,
|
|
||||||
theme_button_size + 2, theme_button_size + 2);
|
|
||||||
XMapWindow(ob_display, self->icon);
|
XMapWindow(ob_display, self->icon);
|
||||||
XMoveWindow(ob_display, self->icon, x, theme_bevel);
|
XMoveWindow(ob_display, self->icon, x, theme_bevel);
|
||||||
x += theme_button_size + 2 + theme_bevel + 1;
|
x += theme_button_size + 2 + theme_bevel + 1;
|
||||||
|
@ -611,11 +531,6 @@ static void layout_title(Frame *self)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RECT_SET(self->a_focused_label->area, 0, 0,
|
|
||||||
self->label_width, theme_label_height);
|
|
||||||
RECT_SET(self->a_unfocused_label->area, 0, 0,
|
|
||||||
self->label_width, theme_label_height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Context frame_context_from_string(char *name)
|
Context frame_context_from_string(char *name)
|
||||||
|
|
|
@ -76,7 +76,7 @@ void framerender_frame(Frame *self)
|
||||||
theme_a_unfocused_pressed_close :
|
theme_a_unfocused_pressed_close :
|
||||||
theme_a_unfocused_unpressed_close));
|
theme_a_unfocused_unpressed_close));
|
||||||
|
|
||||||
paint(self->title, t);
|
paint(self->title, t, self->width, theme_title_height);
|
||||||
|
|
||||||
/* set parents for any parent relative guys */
|
/* set parents for any parent relative guys */
|
||||||
l->surface.parent = t;
|
l->surface.parent = t;
|
||||||
|
@ -121,38 +121,33 @@ void framerender_frame(Frame *self)
|
||||||
|
|
||||||
h = (self->focused ?
|
h = (self->focused ?
|
||||||
self->a_focused_handle : self->a_unfocused_handle);
|
self->a_focused_handle : self->a_unfocused_handle);
|
||||||
|
|
||||||
|
paint(self->handle, h, self->width, theme_handle_height);
|
||||||
|
|
||||||
g = (self->focused ?
|
g = (self->focused ?
|
||||||
theme_a_focused_grip : theme_a_unfocused_grip);
|
theme_a_focused_grip : theme_a_unfocused_grip);
|
||||||
|
|
||||||
if (g->surface.grad == Background_ParentRelative) {
|
if (g->surface.grad == Background_ParentRelative)
|
||||||
g->surface.parent = h;
|
g->surface.parent = h;
|
||||||
paint(self->handle, h);
|
|
||||||
} else
|
|
||||||
paint(self->handle, h);
|
|
||||||
|
|
||||||
g->surface.parentx = 0;
|
g->surface.parentx = 0;
|
||||||
g->surface.parenty = 0;
|
g->surface.parenty = 0;
|
||||||
|
|
||||||
paint(self->lgrip, g);
|
paint(self->lgrip, g, theme_grip_width, theme_handle_height);
|
||||||
|
|
||||||
g->surface.parentx = self->width - theme_grip_width;
|
g->surface.parentx = self->width - theme_grip_width;
|
||||||
g->surface.parenty = 0;
|
g->surface.parenty = 0;
|
||||||
|
|
||||||
paint(self->rgrip, g);
|
paint(self->rgrip, g, theme_grip_width, theme_handle_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void framerender_label(Frame *self, Appearance *a)
|
static void framerender_label(Frame *self, Appearance *a)
|
||||||
{
|
{
|
||||||
if (self->label_x < 0) return;
|
if (self->label_x < 0) return;
|
||||||
|
|
||||||
|
|
||||||
/* set the texture's text! */
|
/* set the texture's text! */
|
||||||
a->texture[0].data.text.string = self->client->title;
|
a->texture[0].data.text.string = self->client->title;
|
||||||
RECT_SET(a->texture[0].position, 0, 0,
|
paint(self->label, a, self->label_width, theme_label_height);
|
||||||
self->label_width, theme_label_height);
|
|
||||||
|
|
||||||
paint(self->label, a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void framerender_icon(Frame *self, Appearance *a)
|
static void framerender_icon(Frame *self, Appearance *a)
|
||||||
|
@ -166,55 +161,38 @@ static void framerender_icon(Frame *self, Appearance *a)
|
||||||
a->texture[0].data.rgba.width = icon->width;
|
a->texture[0].data.rgba.width = icon->width;
|
||||||
a->texture[0].data.rgba.height = icon->height;
|
a->texture[0].data.rgba.height = icon->height;
|
||||||
a->texture[0].data.rgba.data = icon->data;
|
a->texture[0].data.rgba.data = icon->data;
|
||||||
RECT_SET(self->a_icon->texture[0].position, 0, 0,
|
|
||||||
theme_button_size + 2, theme_button_size + 2);
|
|
||||||
} else
|
} else
|
||||||
a->texture[0].type = NoTexture;
|
a->texture[0].type = NoTexture;
|
||||||
|
|
||||||
paint(self->icon, a);
|
paint(self->icon, a, theme_button_size + 2, theme_button_size + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void framerender_max(Frame *self, Appearance *a)
|
static void framerender_max(Frame *self, Appearance *a)
|
||||||
{
|
{
|
||||||
if (self->max_x < 0) return;
|
if (self->max_x < 0) return;
|
||||||
|
paint(self->max, a, theme_button_size, theme_button_size);
|
||||||
RECT_SET(a->texture[0].position, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
paint(self->max, a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void framerender_iconify(Frame *self, Appearance *a)
|
static void framerender_iconify(Frame *self, Appearance *a)
|
||||||
{
|
{
|
||||||
if (self->iconify_x < 0) return;
|
if (self->iconify_x < 0) return;
|
||||||
|
paint(self->iconify, a, theme_button_size, theme_button_size);
|
||||||
RECT_SET(a->texture[0].position, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
paint(self->iconify, a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void framerender_desk(Frame *self, Appearance *a)
|
static void framerender_desk(Frame *self, Appearance *a)
|
||||||
{
|
{
|
||||||
if (self->desk_x < 0) return;
|
if (self->desk_x < 0) return;
|
||||||
|
paint(self->desk, a, theme_button_size, theme_button_size);
|
||||||
RECT_SET(a->texture[0].position, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
paint(self->desk, a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void framerender_shade(Frame *self, Appearance *a)
|
static void framerender_shade(Frame *self, Appearance *a)
|
||||||
{
|
{
|
||||||
if (self->shade_x < 0) return;
|
if (self->shade_x < 0) return;
|
||||||
|
paint(self->shade, a, theme_button_size, theme_button_size);
|
||||||
RECT_SET(a->texture[0].position, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
paint(self->shade, a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void framerender_close(Frame *self, Appearance *a)
|
static void framerender_close(Frame *self, Appearance *a)
|
||||||
{
|
{
|
||||||
if (self->close_x < 0) return;
|
if (self->close_x < 0) return;
|
||||||
|
paint(self->close, a, theme_button_size, theme_button_size);
|
||||||
RECT_SET(a->texture[0].position, 0, 0,
|
|
||||||
theme_button_size, theme_button_size);
|
|
||||||
paint(self->close, a);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,15 +61,6 @@ void menu_render_full(Menu *self) {
|
||||||
self->item_h += theme_bevel * 2;
|
self->item_h += theme_bevel * 2;
|
||||||
items_h = self->item_h * MAX(nitems, 1);
|
items_h = self->item_h * MAX(nitems, 1);
|
||||||
|
|
||||||
if (self->label) {
|
|
||||||
RECT_SET(self->a_title->area, 0, 0, self->size.width,
|
|
||||||
self->title_h);
|
|
||||||
RECT_SET(self->a_title->texture[0].position, 0, 0, self->size.width,
|
|
||||||
self->title_h);
|
|
||||||
}
|
|
||||||
|
|
||||||
RECT_SET(self->a_items->area, 0, 0, self->size.width, items_h);
|
|
||||||
|
|
||||||
XResizeWindow(ob_display, self->frame, self->size.width,
|
XResizeWindow(ob_display, self->frame, self->size.width,
|
||||||
MAX(self->title_h + items_h, 1));
|
MAX(self->title_h + items_h, 1));
|
||||||
if (self->label)
|
if (self->label)
|
||||||
|
@ -81,8 +72,8 @@ void menu_render_full(Menu *self) {
|
||||||
items_h);
|
items_h);
|
||||||
|
|
||||||
if (self->label)
|
if (self->label)
|
||||||
paint(self->title, self->a_title);
|
paint(self->title, self->a_title, self->size.width, self->title_h);
|
||||||
paint(self->items, self->a_items);
|
paint(self->items, self->a_items, self->size.width, items_h);
|
||||||
|
|
||||||
item_y = 0;
|
item_y = 0;
|
||||||
for (it = self->entries; it; it = it->next) {
|
for (it = self->entries; it; it = it->next) {
|
||||||
|
@ -125,17 +116,12 @@ void menu_entry_render(MenuEntry *self)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
RECT_SET(a->area, 0, 0, menu->size.width,
|
|
||||||
menu->item_h);
|
|
||||||
RECT_SET(a->texture[0].position, menu->bullet_w,
|
|
||||||
0, menu->size.width - 2 * menu->bullet_w,
|
|
||||||
menu->item_h);
|
|
||||||
|
|
||||||
XMoveResizeWindow(ob_display, self->item, 0, self->y,
|
XMoveResizeWindow(ob_display, self->item, 0, self->y,
|
||||||
menu->size.width, menu->item_h);
|
menu->size.width, menu->item_h);
|
||||||
|
|
||||||
a->surface.parent = menu->a_items;
|
a->surface.parent = menu->a_items;
|
||||||
a->surface.parentx = 0;
|
a->surface.parentx = 0;
|
||||||
a->surface.parenty = self->y;
|
a->surface.parenty = self->y;
|
||||||
|
|
||||||
paint(self->item, a);
|
paint(self->item, a, menu->size.width, menu->item_h);
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,12 +189,8 @@ void popup_show(Popup *self, char *text, Icon *icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the windows/appearances up */
|
/* set the windows/appearances up */
|
||||||
RECT_SET(self->a_bg->area, 0, 0, w, h);
|
|
||||||
XMoveResizeWindow(ob_display, self->bg, x, y, w, h);
|
XMoveResizeWindow(ob_display, self->bg, x, y, w, h);
|
||||||
|
|
||||||
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.parent = self->a_bg;
|
self->a_text->surface.parent = self->a_bg;
|
||||||
self->a_text->surface.parentx = iconw +
|
self->a_text->surface.parentx = iconw +
|
||||||
theme_bevel * (self->hasicon ? 2 : 1);
|
theme_bevel * (self->hasicon ? 2 : 1);
|
||||||
|
@ -205,8 +201,6 @@ void popup_show(Popup *self, char *text, Icon *icon)
|
||||||
|
|
||||||
if (self->hasicon) {
|
if (self->hasicon) {
|
||||||
if (iconw < 1) iconw = 1; /* sanity check for crashes */
|
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.parent = self->a_bg;
|
self->a_icon->surface.parent = self->a_bg;
|
||||||
self->a_icon->surface.parentx = theme_bevel;
|
self->a_icon->surface.parentx = theme_bevel;
|
||||||
self->a_icon->surface.parenty = theme_bevel;
|
self->a_icon->surface.parenty = theme_bevel;
|
||||||
|
@ -214,10 +208,10 @@ void popup_show(Popup *self, char *text, Icon *icon)
|
||||||
theme_bevel, theme_bevel, iconw, texth);
|
theme_bevel, theme_bevel, iconw, texth);
|
||||||
}
|
}
|
||||||
|
|
||||||
paint(self->bg, self->a_bg);
|
paint(self->bg, self->a_bg, w, h);
|
||||||
paint(self->text, self->a_text);
|
paint(self->text, self->a_text, textw, texth);
|
||||||
if (self->hasicon)
|
if (self->hasicon)
|
||||||
paint(self->icon, self->a_icon);
|
paint(self->icon, self->a_icon, iconw, texth);
|
||||||
|
|
||||||
if (!self->mapped) {
|
if (!self->mapped) {
|
||||||
XMapWindow(ob_display, self->bg);
|
XMapWindow(ob_display, self->bg);
|
||||||
|
|
|
@ -47,8 +47,7 @@ void client_menu_show(Menu *self, int x, int y, Client *client)
|
||||||
g_assert(!self->invalid);
|
g_assert(!self->invalid);
|
||||||
g_assert(client);
|
g_assert(client);
|
||||||
|
|
||||||
newy = MAX(client->frame->area.y +
|
newy = MAX(client->frame->area.y + client->frame->size.top,
|
||||||
client->frame->a_focused_title->area.height + theme_bwidth,
|
|
||||||
y - theme_bwidth);
|
y - theme_bwidth);
|
||||||
|
|
||||||
POINT_SET(self->location,
|
POINT_SET(self->location,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
#include "theme.h"
|
||||||
#include "kernel/openbox.h"
|
#include "kernel/openbox.h"
|
||||||
#include "kernel/geom.h"
|
#include "kernel/geom.h"
|
||||||
#include "kernel/gettext.h"
|
#include "kernel/gettext.h"
|
||||||
|
@ -102,7 +103,7 @@ int font_max_char_width(ObFont *f)
|
||||||
return (signed) f->xftfont->max_advance_width;
|
return (signed) f->xftfont->max_advance_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void font_draw(XftDraw *d, TextureText *t, Rect *position)
|
void font_draw(XftDraw *d, TextureText *t, Rect *area)
|
||||||
{
|
{
|
||||||
int x,y,w,h;
|
int x,y,w,h;
|
||||||
XftColor c;
|
XftColor c;
|
||||||
|
@ -111,20 +112,22 @@ void font_draw(XftDraw *d, TextureText *t, Rect *position)
|
||||||
size_t l;
|
size_t l;
|
||||||
gboolean shortened = FALSE;
|
gboolean shortened = FALSE;
|
||||||
|
|
||||||
y = position->y;
|
/* center vertically */
|
||||||
w = position->width;
|
y = area->y +
|
||||||
h = position->height;
|
(area->height - font_height(t->font, t->shadow, t->offset)) / 2;
|
||||||
|
w = area->width;
|
||||||
|
h = area->height;
|
||||||
|
|
||||||
text = g_string_new(t->string);
|
text = g_string_new(t->string);
|
||||||
l = g_utf8_strlen(text->str, -1);
|
l = g_utf8_strlen(text->str, -1);
|
||||||
font_measure_full(t->font, text->str, t->shadow, t->offset, &mw, &mh);
|
font_measure_full(t->font, text->str, t->shadow, t->offset, &mw, &mh);
|
||||||
while (l && mw > position->width) {
|
while (l && mw > area->width) {
|
||||||
shortened = TRUE;
|
shortened = TRUE;
|
||||||
/* remove a character from the middle */
|
/* remove a character from the middle */
|
||||||
text = g_string_erase(text, l-- / 2, 1);
|
text = g_string_erase(text, l-- / 2, 1);
|
||||||
em = ELIPSES_LENGTH(t->font, t->shadow, t->offset);
|
em = ELIPSES_LENGTH(t->font, t->shadow, t->offset);
|
||||||
/* if the elipses are too large, don't show them at all */
|
/* if the elipses are too large, don't show them at all */
|
||||||
if (em > position->width)
|
if (em > area->width)
|
||||||
shortened = FALSE;
|
shortened = FALSE;
|
||||||
font_measure_full(t->font, text->str, t->shadow, t->offset, &mw, &mh);
|
font_measure_full(t->font, text->str, t->shadow, t->offset, &mw, &mh);
|
||||||
mw += em;
|
mw += em;
|
||||||
|
@ -135,18 +138,15 @@ void font_draw(XftDraw *d, TextureText *t, Rect *position)
|
||||||
}
|
}
|
||||||
if (!l) return;
|
if (!l) return;
|
||||||
|
|
||||||
/* center vertically */
|
|
||||||
y -= ((t->font->xftfont->ascent + t->font->xftfont->descent) - mh) / 2;
|
|
||||||
|
|
||||||
switch (t->justify) {
|
switch (t->justify) {
|
||||||
case Justify_Left:
|
case Justify_Left:
|
||||||
x = position->x;
|
x = area->x + theme_bevel;
|
||||||
break;
|
break;
|
||||||
case Justify_Right:
|
case Justify_Right:
|
||||||
x = position->x + (w - mw);
|
x = area->x + (w - mw) - theme_bevel;
|
||||||
break;
|
break;
|
||||||
case Justify_Center:
|
case Justify_Center:
|
||||||
x = position->x + (w - mw) / 2;
|
x = area->x + (w - mw) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -295,9 +295,9 @@ void gradient_solid(Appearance *l, int x, int y, int w, int h)
|
||||||
+ (sp->primary->g << default_green_offset)
|
+ (sp->primary->g << default_green_offset)
|
||||||
+ (sp->primary->b << default_blue_offset);
|
+ (sp->primary->b << default_blue_offset);
|
||||||
|
|
||||||
for (a = 0; a < l->area.width; a++)
|
for (a = 0; a < w; a++)
|
||||||
for (b = 0; b < l->area.height; b++)
|
for (b = 0; b < h; b++)
|
||||||
sp->pixel_data[a + b*l->area.width] = pix;
|
sp->pixel_data[a + b * w] = pix;
|
||||||
|
|
||||||
XFillRectangle(ob_display, l->pixmap, sp->primary->gc,
|
XFillRectangle(ob_display, l->pixmap, sp->primary->gc,
|
||||||
x, y, w, h);
|
x, y, w, h);
|
||||||
|
|
|
@ -2,18 +2,12 @@
|
||||||
#include "../kernel/geom.h"
|
#include "../kernel/geom.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
|
||||||
void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
|
void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *area)
|
||||||
Rect *surarea)
|
|
||||||
{
|
{
|
||||||
pixel32 *draw = rgba->data;
|
pixel32 *draw = rgba->data;
|
||||||
guint c, i, e, t, sfw, sfh;
|
guint c, i, e, t, sfw, sfh;
|
||||||
sfw = position->width;
|
sfw = area->width;
|
||||||
sfh = position->height;
|
sfh = area->height;
|
||||||
|
|
||||||
/* it would be nice if this worked, but this function is well broken in
|
|
||||||
these circumstances. */
|
|
||||||
g_assert(position->width == surarea->width &&
|
|
||||||
position->height == surarea->height);
|
|
||||||
|
|
||||||
g_assert(rgba->data != NULL);
|
g_assert(rgba->data != NULL);
|
||||||
|
|
||||||
|
@ -28,7 +22,7 @@ void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
|
||||||
/* scale it and cache it */
|
/* scale it and cache it */
|
||||||
if (rgba->cache != NULL)
|
if (rgba->cache != NULL)
|
||||||
g_free(rgba->cache);
|
g_free(rgba->cache);
|
||||||
rgba->cache = g_new(unsigned long, sfw * sfh);
|
rgba->cache = g_new(pixel32, sfw * sfh);
|
||||||
rgba->cwidth = sfw;
|
rgba->cwidth = sfw;
|
||||||
rgba->cheight = sfh;
|
rgba->cheight = sfh;
|
||||||
for (i = 0, c = 0, e = sfw*sfh; i < e; ++i) {
|
for (i = 0, c = 0, e = sfw*sfh; i < e; ++i) {
|
||||||
|
@ -47,7 +41,7 @@ void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
|
||||||
draw = rgba->cache;
|
draw = rgba->cache;
|
||||||
|
|
||||||
/* apply the alpha channel */
|
/* apply the alpha channel */
|
||||||
for (i = 0, c = 0, t = position->x, e = sfw*sfh; i < e; ++i, ++t) {
|
for (i = 0, c = 0, t = area->x, e = sfw*sfh; i < e; ++i, ++t) {
|
||||||
guchar alpha, r, g, b, bgr, bgg, bgb;
|
guchar alpha, r, g, b, bgr, bgg, bgb;
|
||||||
|
|
||||||
alpha = draw[i] >> default_alpha_offset;
|
alpha = draw[i] >> default_alpha_offset;
|
||||||
|
@ -57,7 +51,7 @@ void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
|
||||||
|
|
||||||
if (c >= sfw) {
|
if (c >= sfw) {
|
||||||
c = 0;
|
c = 0;
|
||||||
t += surarea->width - sfw;
|
t += area->width - sfw;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* background color */
|
/* background color */
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "../kernel/geom.h"
|
#include "../kernel/geom.h"
|
||||||
|
|
||||||
void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
|
void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *area);
|
||||||
Rect *surarea);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
308
render/render.c
308
render/render.c
|
@ -1,10 +1,6 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#ifdef USE_GL
|
|
||||||
# include <GL/glx.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "gradient.h"
|
#include "gradient.h"
|
||||||
|
@ -30,122 +26,26 @@ int render_red_shift, render_green_shift, render_blue_shift;
|
||||||
int render_red_mask, render_green_mask, render_blue_mask;
|
int render_red_mask, render_green_mask, render_blue_mask;
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_GL
|
|
||||||
|
|
||||||
GLXContext render_glx_context;
|
|
||||||
|
|
||||||
int render_glx_rating(XVisualInfo *v)
|
|
||||||
{
|
|
||||||
int er;
|
|
||||||
int rating = 0;
|
|
||||||
int val;
|
|
||||||
printf("evaluating visual %d\n", v->visualid);
|
|
||||||
glXGetConfig(ob_display, v, GLX_BUFFER_SIZE, &val);
|
|
||||||
printf("buffer size %d\n", val);
|
|
||||||
|
|
||||||
switch (val) {
|
|
||||||
case 32:
|
|
||||||
rating += 300;
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
rating += 200;
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
rating += 100;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
glXGetConfig(ob_display, v, GLX_LEVEL, &val);
|
|
||||||
printf("level %d\n", val);
|
|
||||||
if (val != 0)
|
|
||||||
rating = -10000;
|
|
||||||
|
|
||||||
glXGetConfig(ob_display, v, GLX_DEPTH_SIZE, &val);
|
|
||||||
printf("depth size %d\n", val);
|
|
||||||
switch (val) {
|
|
||||||
case 32:
|
|
||||||
rating += 30;
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
rating += 20;
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
rating += 10;
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
rating -= 10000;
|
|
||||||
}
|
|
||||||
|
|
||||||
glXGetConfig(ob_display, v, GLX_DOUBLEBUFFER, &val);
|
|
||||||
printf("double buffer %d\n", val);
|
|
||||||
if (val)
|
|
||||||
rating++;
|
|
||||||
return rating;
|
|
||||||
}
|
|
||||||
#endif /* USE_GL */
|
|
||||||
|
|
||||||
void render_startup(void)
|
void render_startup(void)
|
||||||
{
|
{
|
||||||
int count, i = 0, val, best = 0, rate = 0, temp;
|
|
||||||
XVisualInfo vimatch, *vilist;
|
|
||||||
paint = x_paint;
|
|
||||||
|
|
||||||
render_depth = DefaultDepth(ob_display, ob_screen);
|
render_depth = DefaultDepth(ob_display, ob_screen);
|
||||||
render_visual = DefaultVisual(ob_display, ob_screen);
|
render_visual = DefaultVisual(ob_display, ob_screen);
|
||||||
render_colormap = DefaultColormap(ob_display, ob_screen);
|
render_colormap = DefaultColormap(ob_display, ob_screen);
|
||||||
|
|
||||||
#ifdef USE_GL
|
switch (render_visual->class) {
|
||||||
vimatch.screen = ob_screen;
|
case TrueColor:
|
||||||
vimatch.class = TrueColor;
|
truecolor_startup();
|
||||||
vilist = XGetVisualInfo(ob_display, VisualScreenMask | VisualClassMask,
|
break;
|
||||||
&vimatch, &count);
|
case PseudoColor:
|
||||||
|
case StaticColor:
|
||||||
if (vilist) {
|
case GrayScale:
|
||||||
printf("looking for a GL visualin %d visuals\n", count);
|
case StaticGray:
|
||||||
for (i = 0; i < count; i++) {
|
pseudocolor_startup();
|
||||||
glXGetConfig(ob_display, &vilist[i], GLX_USE_GL, &val);
|
break;
|
||||||
if (val) {
|
default:
|
||||||
temp = render_glx_rating(&vilist[i]);
|
g_critical("unsupported visual class.\n");
|
||||||
if (temp > rate) {
|
exit(EXIT_FAILURE);
|
||||||
best = i;
|
|
||||||
rate = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (rate > 0) {
|
|
||||||
printf("picked visual %d with rating %d\n", best, rate);
|
|
||||||
render_depth = vilist[best].depth;
|
|
||||||
render_visual = vilist[best].visual;
|
|
||||||
render_colormap = XCreateColormap(ob_display, ob_root,
|
|
||||||
render_visual, AllocNone);
|
|
||||||
render_visual_info = vilist[best];
|
|
||||||
render_glx_context = glXCreateContext(ob_display, &render_visual_info,
|
|
||||||
NULL, True);
|
|
||||||
if (render_glx_context == NULL)
|
|
||||||
printf("sadness\n");
|
|
||||||
else {
|
|
||||||
paint = gl_paint;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /*USE_GL*/
|
|
||||||
|
|
||||||
|
|
||||||
switch (render_visual->class) {
|
|
||||||
case TrueColor:
|
|
||||||
truecolor_startup();
|
|
||||||
break;
|
|
||||||
case PseudoColor:
|
|
||||||
case StaticColor:
|
|
||||||
case GrayScale:
|
|
||||||
case StaticGray:
|
|
||||||
pseudocolor_startup();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_critical("unsupported visual class.\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void truecolor_startup(void)
|
void truecolor_startup(void)
|
||||||
|
@ -259,22 +159,27 @@ void pseudocolor_startup(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void x_paint(Window win, Appearance *l)
|
void paint(Window win, Appearance *l, int w, int h)
|
||||||
{
|
{
|
||||||
int i, transferred = 0, sw;
|
int i, transferred = 0, sw;
|
||||||
pixel32 *source, *dest;
|
pixel32 *source, *dest;
|
||||||
Pixmap oldp;
|
Pixmap oldp;
|
||||||
int x = l->area.x;
|
|
||||||
int y = l->area.y;
|
|
||||||
int w = l->area.width;
|
|
||||||
int h = l->area.height;
|
|
||||||
Rect tarea; /* area in which to draw textures */
|
Rect tarea; /* area in which to draw textures */
|
||||||
|
gboolean resized;
|
||||||
|
|
||||||
if (w <= 0 || h <= 0 || x+w <= 0 || y+h <= 0) return;
|
if (w <= 0 || h <= 0) return;
|
||||||
|
|
||||||
|
resized = (l->w != w || l->h != h);
|
||||||
|
|
||||||
|
if (resized) {
|
||||||
|
oldp = l->pixmap; /* save to free after changing the visible pixmap */
|
||||||
|
l->pixmap = XCreatePixmap(ob_display, ob_root, w, h, render_depth);
|
||||||
|
} else
|
||||||
|
oldp = None;
|
||||||
|
|
||||||
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);
|
g_assert(l->pixmap != None);
|
||||||
|
l->w = w;
|
||||||
|
l->h = h;
|
||||||
|
|
||||||
if (l->xftdraw != NULL)
|
if (l->xftdraw != NULL)
|
||||||
XftDrawDestroy(l->xftdraw);
|
XftDrawDestroy(l->xftdraw);
|
||||||
|
@ -285,72 +190,72 @@ void x_paint(Window win, Appearance *l)
|
||||||
g_free(l->surface.pixel_data);
|
g_free(l->surface.pixel_data);
|
||||||
l->surface.pixel_data = g_new(pixel32, w * h);
|
l->surface.pixel_data = g_new(pixel32, w * h);
|
||||||
|
|
||||||
|
|
||||||
if (l->surface.grad == Background_ParentRelative) {
|
if (l->surface.grad == Background_ParentRelative) {
|
||||||
sw = l->surface.parent->area.width;
|
g_assert (l->surface.parent);
|
||||||
source = l->surface.parent->surface.pixel_data
|
g_assert (l->surface.parent->w);
|
||||||
+ l->surface.parentx
|
|
||||||
+ sw * l->surface.parenty;
|
sw = l->surface.parent->w;
|
||||||
|
source = (l->surface.parent->surface.pixel_data + l->surface.parentx +
|
||||||
|
sw * l->surface.parenty);
|
||||||
dest = l->surface.pixel_data;
|
dest = l->surface.pixel_data;
|
||||||
for (i = 0; i < h; i++, source += sw, dest += w) {
|
for (i = 0; i < h; i++, source += sw, dest += w) {
|
||||||
memcpy(dest, source, w * sizeof(pixel32));
|
memcpy(dest, source, w * sizeof(pixel32));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (l->surface.grad == Background_Solid)
|
else if (l->surface.grad == Background_Solid)
|
||||||
gradient_solid(l, x, y, w, h);
|
gradient_solid(l, 0, 0, w, h);
|
||||||
else gradient_render(&l->surface, w, h);
|
else gradient_render(&l->surface, w, h);
|
||||||
|
|
||||||
for (i = 0; i < l->textures; i++) {
|
RECT_SET(tarea, 0, 0, w, h);
|
||||||
tarea = l->texture[i].position;
|
if (l->surface.grad != Background_ParentRelative) {
|
||||||
if (l->surface.grad != Background_ParentRelative) {
|
if (l->surface.relief != Flat) {
|
||||||
if (l->surface.relief != Flat) {
|
switch (l->surface.bevel) {
|
||||||
switch (l->surface.bevel) {
|
case Bevel1:
|
||||||
case Bevel1:
|
|
||||||
tarea.x += 1; tarea.y += 1;
|
|
||||||
tarea.width -= 2; tarea.height -= 2;
|
|
||||||
break;
|
|
||||||
case Bevel2:
|
|
||||||
tarea.x += 2; tarea.y += 2;
|
|
||||||
tarea.width -= 4; tarea.height -= 4;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (l->surface.border) {
|
|
||||||
tarea.x += 1; tarea.y += 1;
|
tarea.x += 1; tarea.y += 1;
|
||||||
tarea.width -= 2; tarea.height -= 2;
|
tarea.width -= 2; tarea.height -= 2;
|
||||||
|
break;
|
||||||
|
case Bevel2:
|
||||||
|
tarea.x += 2; tarea.y += 2;
|
||||||
|
tarea.width -= 4; tarea.height -= 4;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (l->surface.border) {
|
||||||
|
tarea.x += 1; tarea.y += 1;
|
||||||
|
tarea.width -= 2; tarea.height -= 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < l->textures; i++) {
|
||||||
switch (l->texture[i].type) {
|
switch (l->texture[i].type) {
|
||||||
|
case NoTexture:
|
||||||
|
break;
|
||||||
case Text:
|
case Text:
|
||||||
if (!transferred) {
|
if (!transferred) {
|
||||||
transferred = 1;
|
transferred = 1;
|
||||||
if (l->surface.grad != Background_Solid)
|
if (l->surface.grad != Background_Solid)
|
||||||
pixel32_to_pixmap(l->surface.pixel_data,
|
pixel32_to_pixmap(l->surface.pixel_data,
|
||||||
l->pixmap,x,y,w,h);
|
l->pixmap, 0, 0, w, h);
|
||||||
}
|
}
|
||||||
if (l->xftdraw == NULL) {
|
if (l->xftdraw == NULL) {
|
||||||
l->xftdraw = XftDrawCreate(ob_display, l->pixmap,
|
l->xftdraw = XftDrawCreate(ob_display, l->pixmap,
|
||||||
render_visual, render_colormap);
|
render_visual, render_colormap);
|
||||||
}
|
}
|
||||||
font_draw(l->xftdraw, &l->texture[i].data.text,
|
font_draw(l->xftdraw, &l->texture[i].data.text, &tarea);
|
||||||
&tarea);
|
|
||||||
break;
|
break;
|
||||||
case Bitmask:
|
case Bitmask:
|
||||||
if (!transferred) {
|
if (!transferred) {
|
||||||
transferred = 1;
|
transferred = 1;
|
||||||
if (l->surface.grad != Background_Solid)
|
if (l->surface.grad != Background_Solid)
|
||||||
pixel32_to_pixmap(l->surface.pixel_data,
|
pixel32_to_pixmap(l->surface.pixel_data,
|
||||||
l->pixmap,x,y,w,h);
|
l->pixmap, 0, 0, w, h);
|
||||||
}
|
}
|
||||||
if (l->texture[i].data.mask.color->gc == None)
|
if (l->texture[i].data.mask.color->gc == None)
|
||||||
color_allocate_gc(l->texture[i].data.mask.color);
|
color_allocate_gc(l->texture[i].data.mask.color);
|
||||||
mask_draw(l->pixmap, &l->texture[i].data.mask,
|
mask_draw(l->pixmap, &l->texture[i].data.mask, &tarea);
|
||||||
&tarea);
|
|
||||||
break;
|
break;
|
||||||
case RGBA:
|
case RGBA:
|
||||||
image_draw(l->surface.pixel_data,
|
image_draw(l->surface.pixel_data,
|
||||||
&l->texture[i].data.rgba,
|
&l->texture[i].data.rgba, &tarea);
|
||||||
&tarea, &l->area);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,14 +263,13 @@ void x_paint(Window win, Appearance *l)
|
||||||
if (!transferred) {
|
if (!transferred) {
|
||||||
transferred = 1;
|
transferred = 1;
|
||||||
if (l->surface.grad != Background_Solid)
|
if (l->surface.grad != Background_Solid)
|
||||||
pixel32_to_pixmap(l->surface.pixel_data, l->pixmap
|
pixel32_to_pixmap(l->surface.pixel_data, l->pixmap, 0, 0, w, h);
|
||||||
,x,y,w,h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XSetWindowBackgroundPixmap(ob_display, win, l->pixmap);
|
XSetWindowBackgroundPixmap(ob_display, win, l->pixmap);
|
||||||
XClearWindow(ob_display, win);
|
XClearWindow(ob_display, win);
|
||||||
if (oldp != None) XFreePixmap(ob_display, oldp);
|
if (oldp) XFreePixmap(ob_display, oldp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_shutdown(void)
|
void render_shutdown(void)
|
||||||
|
@ -383,6 +287,7 @@ Appearance *appearance_new(int numtex)
|
||||||
if (numtex) out->texture = g_new0(Texture, numtex);
|
if (numtex) out->texture = g_new0(Texture, numtex);
|
||||||
else out->texture = NULL;
|
else out->texture = NULL;
|
||||||
out->pixmap = None;
|
out->pixmap = None;
|
||||||
|
out->w = out->h = 0;
|
||||||
|
|
||||||
p = &out->surface;
|
p = &out->surface;
|
||||||
p->primary = NULL;
|
p->primary = NULL;
|
||||||
|
@ -442,6 +347,7 @@ Appearance *appearance_copy(Appearance *orig)
|
||||||
copy->texture = g_memdup(orig->texture, orig->textures * sizeof(Texture));
|
copy->texture = g_memdup(orig->texture, orig->textures * sizeof(Texture));
|
||||||
copy->pixmap = None;
|
copy->pixmap = None;
|
||||||
copy->xftdraw = NULL;
|
copy->xftdraw = NULL;
|
||||||
|
copy->w = copy->h = 0;
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,45 +397,52 @@ void appearance_minsize(Appearance *l, int *w, int *h)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int m;
|
int m;
|
||||||
*w = *h = 1;
|
*w = *h = 0;
|
||||||
|
|
||||||
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) {
|
for (i = 0; i < l->textures; ++i) {
|
||||||
switch (l->texture[i].type) {
|
switch (l->texture[i].type) {
|
||||||
case Bitmask:
|
case Bitmask:
|
||||||
*w += l->texture[i].data.mask.mask->w;
|
*w = MAX(*w, l->texture[i].data.mask.mask->w);
|
||||||
*h += l->texture[i].data.mask.mask->h;
|
*h = MAX(*h, l->texture[i].data.mask.mask->h);
|
||||||
break;
|
break;
|
||||||
case Text:
|
case Text:
|
||||||
m = font_measure_string(l->texture[i].data.text.font,
|
m = font_measure_string(l->texture[i].data.text.font,
|
||||||
l->texture[i].data.text.string,
|
l->texture[i].data.text.string,
|
||||||
l->texture[i].data.text.shadow,
|
l->texture[i].data.text.shadow,
|
||||||
l->texture[i].data.text.offset);
|
l->texture[i].data.text.offset);
|
||||||
*w += m;
|
*w = MAX(*w, m);
|
||||||
m = font_height(l->texture[i].data.text.font,
|
m = font_height(l->texture[i].data.text.font,
|
||||||
l->texture[i].data.text.shadow,
|
l->texture[i].data.text.shadow,
|
||||||
l->texture[i].data.text.offset);
|
l->texture[i].data.text.offset);
|
||||||
*h += m;
|
*h += MAX(*h, m);
|
||||||
break;
|
break;
|
||||||
case RGBA:
|
case RGBA:
|
||||||
*w += l->texture[i].data.rgba.width;
|
*w += MAX(*w, l->texture[i].data.rgba.width);
|
||||||
*h += l->texture[i].data.rgba.height;
|
*h += MAX(*h, l->texture[i].data.rgba.height);
|
||||||
break;
|
break;
|
||||||
case NoTexture:
|
case NoTexture:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (l->surface.relief != Flat) {
|
||||||
|
switch (l->surface.bevel) {
|
||||||
|
case Bevel1:
|
||||||
|
*w += 2;
|
||||||
|
*h += 2;
|
||||||
|
break;
|
||||||
|
case Bevel2:
|
||||||
|
*w += 4;
|
||||||
|
*h += 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (l->surface.border) {
|
||||||
|
*w += 2;
|
||||||
|
*h += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*w < 1) *w = 1;
|
||||||
|
if (*h < 1) *h = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean render_pixmap_to_rgba(Pixmap pmap, Pixmap mask,
|
gboolean render_pixmap_to_rgba(Pixmap pmap, Pixmap mask,
|
||||||
|
@ -579,54 +492,3 @@ gboolean render_pixmap_to_rgba(Pixmap pmap, Pixmap mask,
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_GL
|
|
||||||
void gl_paint(Window win, Appearance *l)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
Window root, child;
|
|
||||||
int i, transferred = 0, sw, b, d;
|
|
||||||
pixel32 *source, *dest;
|
|
||||||
Pixmap oldp;
|
|
||||||
int tempx, tempy, absx, absy, absw, absh;
|
|
||||||
int x = l->area.x;
|
|
||||||
int y = l->area.y;
|
|
||||||
int w = l->area.width;
|
|
||||||
int h = l->area.height;
|
|
||||||
Rect tarea; /* area in which to draw textures */
|
|
||||||
if (w <= 0 || h <= 0 || x+w <= 0 || y+h <= 0) return;
|
|
||||||
|
|
||||||
g_assert(l->surface.type == Surface_Planar);
|
|
||||||
|
|
||||||
printf("making %p, %p, %p current\n", ob_display, win, render_glx_context);
|
|
||||||
err = glXMakeCurrent(ob_display, win, render_glx_context);
|
|
||||||
g_assert(err != 0);
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
glOrtho(0, 1376, 1032, 0, 0, 10);
|
|
||||||
if (XGetGeometry(ob_display, win, &root, &tempx, &tempy,
|
|
||||||
&absw, &absh, &b, &d) &&
|
|
||||||
XTranslateCoordinates(ob_display, win, root, tempx, tempy,
|
|
||||||
&absx, &absy, &child))
|
|
||||||
printf("window at %d, %d (%d,%d)\n", absx, absy, absw, absh);
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
|
|
||||||
glViewport(0, 0, 1376, 1032);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glTranslatef(-absx, 1032-absh-absy, 0);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
|
|
||||||
if (l->surface.grad == Background_ParentRelative) {
|
|
||||||
printf("crap\n");
|
|
||||||
} else
|
|
||||||
render_gl_gradient(&l->surface, absx+x, absy+y, absw, absh);
|
|
||||||
|
|
||||||
glXSwapBuffers(ob_display, win);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* USE_GL */
|
|
||||||
|
|
|
@ -59,7 +59,6 @@ typedef struct Surface {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
XftFont *xftfont;
|
XftFont *xftfont;
|
||||||
int height;
|
|
||||||
int elipses_length;
|
int elipses_length;
|
||||||
} ObFont;
|
} ObFont;
|
||||||
|
|
||||||
|
@ -107,18 +106,19 @@ typedef union {
|
||||||
} TextureData;
|
} TextureData;
|
||||||
|
|
||||||
typedef struct Texture {
|
typedef struct Texture {
|
||||||
Rect position;
|
|
||||||
TextureType type;
|
TextureType type;
|
||||||
TextureData data;
|
TextureData data;
|
||||||
} Texture;
|
} Texture;
|
||||||
|
|
||||||
typedef struct Appearance {
|
typedef struct Appearance {
|
||||||
Surface surface;
|
Surface surface;
|
||||||
Rect area;
|
|
||||||
int textures;
|
int textures;
|
||||||
Texture *texture;
|
Texture *texture;
|
||||||
Pixmap pixmap;
|
Pixmap pixmap;
|
||||||
XftDraw *xftdraw;
|
XftDraw *xftdraw;
|
||||||
|
|
||||||
|
/* cached for internal use */
|
||||||
|
int w, h;
|
||||||
} Appearance;
|
} Appearance;
|
||||||
|
|
||||||
extern Visual *render_visual;
|
extern Visual *render_visual;
|
||||||
|
@ -126,12 +126,9 @@ extern XVisualInfo render_visual_info;
|
||||||
extern int render_depth;
|
extern int render_depth;
|
||||||
extern Colormap render_colormap;
|
extern Colormap render_colormap;
|
||||||
|
|
||||||
void (*paint)(Window win, Appearance *l);
|
|
||||||
|
|
||||||
void render_startup(void);
|
void render_startup(void);
|
||||||
void init_appearance(Appearance *l);
|
void init_appearance(Appearance *l);
|
||||||
void x_paint(Window win, Appearance *l);
|
void paint(Window win, Appearance *l, int w, int h);
|
||||||
void gl_paint(Window win, Appearance *l);
|
|
||||||
void render_shutdown(void);
|
void render_shutdown(void);
|
||||||
Appearance *appearance_new(int numtex);
|
Appearance *appearance_new(int numtex);
|
||||||
Appearance *appearance_copy(Appearance *a);
|
Appearance *appearance_copy(Appearance *a);
|
||||||
|
|
|
@ -21,25 +21,19 @@ Window ob_root;
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Window win;
|
Window win;
|
||||||
GC gc;
|
|
||||||
Pixmap pm;
|
|
||||||
Appearance *look;
|
Appearance *look;
|
||||||
|
|
||||||
int grabbed = 0;
|
|
||||||
Window root;
|
Window root;
|
||||||
XGCValues values;
|
|
||||||
XEvent report;
|
XEvent report;
|
||||||
int h = 500, w = 500, tmp;
|
int h = 500, w = 500;
|
||||||
XVisualInfo *vi;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
ob_display = XOpenDisplay(NULL);
|
ob_display = XOpenDisplay(NULL);
|
||||||
XSetErrorHandler(x_error_handler);
|
XSetErrorHandler(x_error_handler);
|
||||||
ob_screen = DefaultScreen(ob_display);
|
ob_screen = DefaultScreen(ob_display);
|
||||||
ob_root = RootWindow(ob_display, ob_screen);
|
ob_root = RootWindow(ob_display, ob_screen);
|
||||||
win =
|
win =
|
||||||
XCreateWindow(ob_display, RootWindow(ob_display, 0)
|
XCreateWindow(ob_display, RootWindow(ob_display, 0),
|
||||||
, 10, 10, w, h, 10,
|
10, 10, w, h, 10,
|
||||||
CopyFromParent, /* depth */
|
CopyFromParent, /* depth */
|
||||||
CopyFromParent, /* class */
|
CopyFromParent, /* class */
|
||||||
CopyFromParent, /* visual */
|
CopyFromParent, /* visual */
|
||||||
|
@ -55,25 +49,21 @@ int main()
|
||||||
look->surface.secondary = color_parse("Yellow");
|
look->surface.secondary = color_parse("Yellow");
|
||||||
look->surface.primary = color_parse("Blue");
|
look->surface.primary = color_parse("Blue");
|
||||||
look->surface.interlaced = FALSE;
|
look->surface.interlaced = FALSE;
|
||||||
look->area.x = 0;
|
|
||||||
look->area.y = 0;
|
|
||||||
look->area.width = 500;
|
|
||||||
look->area.height = 500;
|
|
||||||
if (ob_display == NULL) {
|
if (ob_display == NULL) {
|
||||||
fprintf(stderr, "couldn't connect to X server :0\n");
|
fprintf(stderr, "couldn't connect to X server :0\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
paint(win, look);
|
paint(win, look, w, h);
|
||||||
while (1) {
|
while (1) {
|
||||||
XNextEvent(ob_display, &report);
|
XNextEvent(ob_display, &report);
|
||||||
switch (report.type) {
|
switch (report.type) {
|
||||||
case Expose:
|
case Expose:
|
||||||
break;
|
break;
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
look->area.width = report.xconfigure.width;
|
paint(win, look,
|
||||||
look->area.height = report.xconfigure.height;
|
report.xconfigure.width,
|
||||||
paint(win, look);
|
report.xconfigure.height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -515,7 +515,7 @@ char *theme_load(char *theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load the font stuff */
|
/* load the font stuff */
|
||||||
font_str = "arial:bold:pixelsize=10:minsize";
|
font_str = "arial:bold:pixelsize=10";
|
||||||
|
|
||||||
theme_winfont_shadow = FALSE;
|
theme_winfont_shadow = FALSE;
|
||||||
if (read_string(db, "window.xft.flags", &str)) {
|
if (read_string(db, "window.xft.flags", &str)) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ extern int theme_handle_height;
|
||||||
extern int theme_bwidth;
|
extern int theme_bwidth;
|
||||||
extern int theme_cbwidth;
|
extern int theme_cbwidth;
|
||||||
|
|
||||||
#define theme_label_height (theme_winfont_height + 2)
|
#define theme_label_height (theme_winfont_height)
|
||||||
#define theme_title_height (theme_label_height + theme_bevel * 2)
|
#define theme_title_height (theme_label_height + theme_bevel * 2)
|
||||||
#define theme_button_size (theme_label_height - 2)
|
#define theme_button_size (theme_label_height - 2)
|
||||||
#define theme_grip_width (theme_button_size * 2)
|
#define theme_grip_width (theme_button_size * 2)
|
||||||
|
|
Loading…
Reference in a new issue