From c58a403196d4f9e9d8b32bbabfc1ac639643d7c1 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sun, 12 May 2019 21:23:10 -0400 Subject: [PATCH] added window borders to clearly separate windows embedded in a tframe --- config.h | 3 ++- src/lib/draw.c | 2 ++ src/pick.c | 8 +++++++- src/tframe.c | 42 +++++++++++++++++++++--------------------- src/tide.c | 1 + 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/config.h b/config.h index 0a6a422..8126537 100644 --- a/config.h +++ b/config.h @@ -8,7 +8,7 @@ enum { /* Color Names */ EditBg, EditFg, EditSel, TagsBg, TagsFg, TagsSel, ScrollBg, ScrollFg, - VerBdr, HorBdr, + VerBdr, HorBdr, WinBdr, ClrCount }; @@ -75,6 +75,7 @@ static int Palette[ClrCount] = { [ScrollFg] = 0xF0F0E5, /* Scroll region foreground */ [VerBdr] = 0x909047, /* Vertical border */ [HorBdr] = 0x000000, /* Horizontal border */ + [WinBdr] = 0x000000, /* Window border */ }; #ifdef FETCH_RULES diff --git a/src/lib/draw.c b/src/lib/draw.c index e842491..24ca7de 100644 --- a/src/lib/draw.c +++ b/src/lib/draw.c @@ -17,6 +17,7 @@ void draw_statbox(XConf* x, int status) { case OUTDATED: draw_rect(x, Orange, 0, 0, ScrollWidth, x->height/4); break; case ERRORED: draw_rect(x, Red, 0, 0, ScrollWidth, x->height/4); break; } + draw_rect(x, WinBdr, 0, 0, 1, x->height/4); } int draw_hrule(XConf* x, drawcsr* csr) { @@ -86,4 +87,5 @@ void draw_scroll(XConf* x, drawcsr* csr, View* view, int divider) { draw_rect(x, VerBdr, ScrollWidth, divider + 2, 1, thumbreg); draw_rect(x, ScrollBg, 0, divider + 2, ScrollWidth, thumbreg); draw_rect(x, ScrollFg, 0, thumboff + 2, ScrollWidth, thumbsz); + draw_rect(x, WinBdr, 0, divider + 2, 1, thumbreg); } diff --git a/src/pick.c b/src/pick.c index 503b49d..4cb5c66 100644 --- a/src/pick.c +++ b/src/pick.c @@ -161,7 +161,13 @@ int main(int argc, char** argv) { } static void xkeypress(XConf* x, XEvent* e) { - KeySym key = x11_getkey(x, e); + char buf[8]; + KeySym key; + Status status; + if (x->xic) + Xutf8LookupString(x->xic, &(e->xkey), buf, sizeof(buf), &key, &status); + else + XLookupString(&(e->xkey), buf, sizeof(buf), &key, 0); if (key == XK_Return) { x->running = false; } else if (key == XK_Escape) { diff --git a/src/tframe.c b/src/tframe.c index 3490bd9..553cfd8 100644 --- a/src/tframe.c +++ b/src/tframe.c @@ -42,6 +42,27 @@ size_t glyph_width(View* view, int c) { return extents.xOff; } +static Child_T* win_delete(Child_T* child, Window id) { + if (!child) return NULL; + if (child->wid == id) { + Child_T* next = child->next; + free(child); + return next; + } else { + child->next = win_delete(child->next, id); + return child; + } +} + +static void get_position(int x, int y, size_t* row, size_t* col) { + int startx = ScrollWidth+3; + int maxy = Divider - 4; + x = (x < 0 ? 0 : (x > X.width ? X.width : x)); + y = (y < 0 ? 0 : (y > maxy ? maxy : y)); + *row = y / X.font->height; + *col = (startx <= x ? x - startx : 0); +} + /* X11 Event Code ******************************************************************************/ static void xmaprequest(XConf* x, XEvent* e) { @@ -55,18 +76,6 @@ static void xmaprequest(XConf* x, XEvent* e) { retile = 1; } -static Child_T* win_delete(Child_T* child, Window id) { - if (!child) return NULL; - if (child->wid == id) { - Child_T* next = child->next; - free(child); - return next; - } else { - child->next = win_delete(child->next, id); - return child; - } -} - static void xdestroy(XConf* x, XEvent* e) { (void)x; NChildren--; @@ -98,15 +107,6 @@ static void xkeypress(XConf* x, XEvent* e) { view_insert(&Tags, key); } -static void get_position(int x, int y, size_t* row, size_t* col) { - int startx = ScrollWidth+3; - int maxy = Divider - 4; - x = (x < 0 ? 0 : (x > X.width ? X.width : x)); - y = (y < 0 ? 0 : (y > maxy ? maxy : y)); - *row = y / X.font->height; - *col = (startx <= x ? x - startx : 0); -} - static void xmousebtn(XConf* x, XEvent* e) { (void)x; size_t row, col; diff --git a/src/tide.c b/src/tide.c index 256ba3b..33b04ac 100644 --- a/src/tide.c +++ b/src/tide.c @@ -193,6 +193,7 @@ static void xredraw(XConf* x) { Divider = draw_hrule(x, &csr); draw_view(x, &Regions[EDIT], x->font, editrows, &csr, EditBg, EditFg, EditSel, SyncMouse); draw_scroll(x, &csr, win_view(EDIT), Divider); + draw_rect(x, WinBdr, 0, x->height-1, x->width, 1); XCopyArea(x->display, x->pixmap, x->self, x->gc, 0, 0, x->width, x->height, 0, 0); SyncMouse = false; XFlush(x->display); -- 2.51.0