all repos — openbox @ 6016ff8658c53fca30b1ee530bea9c469f2cce84

openbox fork - make it a bit more like ryudo

add the ability to render and size text labels for non-window-decorations
Dana Jansens danakj@orodu.net
commit

6016ff8658c53fca30b1ee530bea9c469f2cce84

parent

af21cb131a784b3d76e9930421a3595f5819dc71

M engines/openbox/obengine.cengines/openbox/obengine.c

@@ -82,6 +82,9 @@ Appearance *ob_a_icon; /* always parentrelative, so no focused/unfocused */

Appearance *ob_a_focused_handle; Appearance *ob_a_unfocused_handle; +Appearance *ob_app_hilite_label; +Appearance *ob_app_unhilite_label; + static void layout_title(ObFrame *self); static void mouse_event(const ObEvent *e, ObFrame *self);

@@ -140,6 +143,8 @@ ob_a_unfocused_label = appearance_new(Surface_Planar, 1);

ob_a_icon = appearance_new(Surface_Planar, 1); ob_a_focused_handle = appearance_new(Surface_Planar, 0); ob_a_unfocused_handle = appearance_new(Surface_Planar, 0); + ob_app_hilite_label = appearance_new(Surface_Planar, 1); + ob_app_unhilite_label = appearance_new(Surface_Planar, 1); if (obtheme_load()) { RECT_SET(ob_a_focused_pressed_desk->area, 0, 0,

@@ -284,6 +289,8 @@ appearance_free(ob_a_unfocused_label);

appearance_free(ob_a_icon); appearance_free(ob_a_focused_handle); appearance_free(ob_a_unfocused_handle); + appearance_free(ob_app_hilite_label); + appearance_free(ob_app_unhilite_label); } static Window createWindow(Window parent, unsigned long mask,
M engines/openbox/obengine.hengines/openbox/obengine.h

@@ -75,6 +75,9 @@ extern Appearance *ob_a_icon;

extern Appearance *ob_a_focused_handle; extern Appearance *ob_a_unfocused_handle; +extern Appearance *ob_app_hilite_label; +extern Appearance *ob_app_unhilite_label; + typedef struct ObFrame { Frame frame;
M engines/openbox/obrender.cengines/openbox/obrender.c

@@ -202,3 +202,33 @@

RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE); paint(self->close, a); } + +void render_label(Window win, Rect *area, char *text, + gboolean hilight, gboolean toplevel) +{ + Appearance *a; + + a = hilight ? ob_app_hilite_label : ob_app_unhilite_label; + a->texture[0].data.text.string = text; + RECT_SET(a->area, 0, 0, area->width, area->height); + a->texture[0].position = a->area; + + if (toplevel) { + XSetWindowBorderWidth(ob_display, win, ob_s_bwidth); + XSetWindowBorder(ob_display, win, ob_s_b_color->pixel); + } + + paint(win, a); +} + +void size_label(char *text, gboolean hilight, gboolean toplevel, Size *s) +{ + Appearance *a; + + a = hilight ? ob_app_hilite_label : ob_app_unhilite_label; + a->texture[0].data.text.string = text; + + appearance_minsize(a, s); + s->width += ob_s_bevel * 2; + s->height += ob_s_bevel * 2; +}
M engines/openbox/obtheme.cengines/openbox/obtheme.c

@@ -401,6 +401,7 @@ char data[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };

ob_s_close_mask = pixmap_mask_new(7, 7, data); } + /* read the decoration textures */ if (!read_appearance(db, "window.title.focus", ob_a_focused_title)) set_default_appearance(ob_a_focused_title); if (!read_appearance(db, "window.title.unfocus", ob_a_unfocused_title))

@@ -418,6 +419,26 @@ set_default_appearance(ob_a_focused_grip);

if (!read_appearance(db, "window.grip.unfocus", ob_a_unfocused_grip)) set_default_appearance(ob_a_unfocused_grip); + /* read the appearances for rendering non-decorations. these cannot be + parent-relative */ + if (ob_a_focused_label->surface.data.planar.grad != + Background_ParentRelative) { + if (!read_appearance(db, "window.label.focus", ob_app_hilite_label)) + set_default_appearance(ob_app_hilite_label); + } else { + if (!read_appearance(db, "window.title.focus", ob_app_hilite_label)) + set_default_appearance(ob_app_hilite_label); + } + if (ob_a_unfocused_label->surface.data.planar.grad != + Background_ParentRelative) { + if (!read_appearance(db, "window.label.unfocus",ob_app_unhilite_label)) + set_default_appearance(ob_app_unhilite_label); + } else { + if (!read_appearance(db, "window.title.unfocus",ob_app_unhilite_label)) + set_default_appearance(ob_app_unhilite_label); + } + + /* read buttons textures */ if (!read_appearance(db, "window.button.pressed.focus", ob_a_focused_pressed_max)) if (!read_appearance(db, "window.button.pressed",

@@ -477,6 +498,13 @@ ob_a_focused_label->texture[0].data.text.shadow = engine_shadow;

ob_a_focused_label->texture[0].data.text.offset = engine_shadow_offset; ob_a_focused_label->texture[0].data.text.tint = engine_shadow_tint; ob_a_focused_label->texture[0].data.text.color = ob_s_title_focused_color; + ob_app_hilite_label->texture[0].type = Text; + ob_app_hilite_label->texture[0].data.text.justify = winjust; + ob_app_hilite_label->texture[0].data.text.font = ob_s_winfont; + ob_app_hilite_label->texture[0].data.text.shadow = engine_shadow; + ob_app_hilite_label->texture[0].data.text.offset = engine_shadow_offset; + ob_app_hilite_label->texture[0].data.text.tint = engine_shadow_tint; + ob_app_hilite_label->texture[0].data.text.color = ob_s_title_focused_color; ob_a_unfocused_label->texture[0].type = Text; ob_a_unfocused_label->texture[0].data.text.justify = winjust;

@@ -485,6 +513,14 @@ ob_a_unfocused_label->texture[0].data.text.shadow = engine_shadow;

ob_a_unfocused_label->texture[0].data.text.offset = engine_shadow_offset; ob_a_unfocused_label->texture[0].data.text.tint = engine_shadow_tint; ob_a_unfocused_label->texture[0].data.text.color = + ob_s_title_unfocused_color; + ob_app_unhilite_label->texture[0].type = Text; + ob_app_unhilite_label->texture[0].data.text.justify = winjust; + ob_app_unhilite_label->texture[0].data.text.font = ob_s_winfont; + ob_app_unhilite_label->texture[0].data.text.shadow = engine_shadow; + ob_app_unhilite_label->texture[0].data.text.offset = engine_shadow_offset; + ob_app_unhilite_label->texture[0].data.text.tint = engine_shadow_tint; + ob_app_unhilite_label->texture[0].data.text.color = ob_s_title_unfocused_color; ob_a_focused_unpressed_max->texture[0].type =
M openbox/engine.copenbox/engine.c

@@ -15,6 +15,21 @@ gboolean engine_shadow;

int engine_shadow_offset; int engine_shadow_tint; +EngineFrameNew *engine_frame_new; +EngineFrameGrabClient *engine_frame_grab_client; +EngineFrameReleaseClient *engine_frame_release_client; +EngineFrameAdjustArea *engine_frame_adjust_area; +EngineFrameAdjustShape *engine_frame_adjust_shape; +EngineFrameAdjustState *engine_frame_adjust_state; +EngineFrameAdjustFocus *engine_frame_adjust_focus; +EngineFrameAdjustTitle *engine_frame_adjust_title; +EngineFrameAdjustIcon *engine_frame_adjust_icon; +EngineFrameShow *engine_frame_show; +EngineFrameHide *engine_frame_hide; +EngineGetContext *engine_get_context; +EngineRenderLabel *engine_render_label; +EngineSizeLabel *engine_size_label; + static GModule *module = NULL; static EngineStartup *estartup = NULL; static EngineShutdown *eshutdown = NULL;

@@ -60,6 +75,8 @@ LOADSYM(frame_adjust_icon, engine_frame_adjust_icon);

LOADSYM(frame_show, engine_frame_show); LOADSYM(frame_hide, engine_frame_hide); LOADSYM(get_context, engine_get_context); + LOADSYM(render_label, engine_render_label); + LOADSYM(size_label, engine_size_label); if (!estartup()) return FALSE;
M openbox/engine.hopenbox/engine.h

@@ -22,21 +22,24 @@ void engine_startup();

void engine_load(); void engine_shutdown(); -EngineFrameNew *engine_frame_new; +extern EngineFrameNew *engine_frame_new; -EngineFrameGrabClient *engine_frame_grab_client; -EngineFrameReleaseClient *engine_frame_release_client; +extern EngineFrameGrabClient *engine_frame_grab_client; +extern EngineFrameReleaseClient *engine_frame_release_client; -EngineFrameAdjustArea *engine_frame_adjust_area; -EngineFrameAdjustShape *engine_frame_adjust_shape; -EngineFrameAdjustState *engine_frame_adjust_state; -EngineFrameAdjustFocus *engine_frame_adjust_focus; -EngineFrameAdjustTitle *engine_frame_adjust_title; -EngineFrameAdjustIcon *engine_frame_adjust_icon; +extern EngineFrameAdjustArea *engine_frame_adjust_area; +extern EngineFrameAdjustShape *engine_frame_adjust_shape; +extern EngineFrameAdjustState *engine_frame_adjust_state; +extern EngineFrameAdjustFocus *engine_frame_adjust_focus; +extern EngineFrameAdjustTitle *engine_frame_adjust_title; +extern EngineFrameAdjustIcon *engine_frame_adjust_icon; + +extern EngineFrameShow *engine_frame_show; +extern EngineFrameHide *engine_frame_hide; -EngineFrameShow *engine_frame_show; -EngineFrameHide *engine_frame_hide; +extern EngineGetContext *engine_get_context; -EngineGetContext *engine_get_context; +extern EngineRenderLabel *engine_render_label; +extern EngineSizeLabel *engine_size_label; #endif