From 71f94df70704c49625b8250e35a974885ee3f8fd Mon Sep 17 00:00:00 2001 From: ketmar Date: Mon, 5 Nov 2012 23:23:04 +0200 Subject: [PATCH] hacked bugs with cursor --- src/libk8sterm/tdraw.c | 22 ++++++++++++---------- src/libk8sterm/ttyutils.c | 3 +++ src/x11CB.c | 12 +++++++----- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/libk8sterm/tdraw.c b/src/libk8sterm/tdraw.c index d8e6868..7adf69a 100644 --- a/src/libk8sterm/tdraw.c +++ b/src/libk8sterm/tdraw.c @@ -10,15 +10,14 @@ K8TERM_API void k8t_DrawClear (K8Term *term, int x1, int y1, int x2, int y2) { /* copy buffer pixmap to screen pixmap */ K8TERM_API void k8t_DrawCopy (K8Term *term, int x, int y, int cols, int rows) { - if (term != NULL) { - term->drawCopyArea(term, x, y, cols, rows); - } + if (term != NULL) term->drawCopyArea(term, x, y, cols, rows); } K8TERM_API void k8t_DrawCursor (K8Term *term) { K8TGlyph g; - int sl, scrx, scry, cmy; + int sl, scrx, scry; + //int cmy; int focused; // if (term == NULL) return; @@ -27,24 +26,26 @@ K8TERM_API void k8t_DrawCursor (K8Term *term) { K8T_LIMIT(term->oldcy, 0, term->row-1); // focused = term->isFocused(term); - cmy = term->row-term->topline-1; + //cmy = term->row-term->topline-1; // + //fprintf(stderr, "cur: cx=%d; cy=%d; sy=%d; cmy=%d\n", term->c.x, term->c.y, term->c.y+term->topline, cmy); if (!focused && !term->curblinkinactive) term->curbhidden = 0; // - if (term->oldcy != cmy) { + if (1/*term->oldcy != cmy*/) { scrx = term->oldcx; scry = term->oldcy+term->topline; // + //FIXME: avoid unnecessary cursor erase when window is not focused if (scry >= 0 && scry < term->row) { if (term->curbhidden < 0 || - term->oldcy != term->c.y || term->oldcx != term->c.x || (term->c.state&K8T_CURSOR_HIDE) || - !focused) { + (!focused && term->defcurinactivebg) || + term->oldcy != term->c.y || term->oldcx != term->c.x) { /* remove the old cursor */ if (!term->isUnderOverlay(term, scrx, scry, 1)) { sl = k8t_UTF8Size(term->line[term->oldcy][scrx].c); g = term->line[term->oldcy][scrx]; - if (k8t_isSelected(term, scrx, term->c.y)) g.attr ^= K8T_ATTR_REVERSE; + if (k8t_isSelected(term, scrx, scry)) g.attr ^= K8T_ATTR_REVERSE; k8t_DrawString(term, g.c, &g, scrx, scry, 1, sl); //k8t_DrawClear(term, scrx, term->oldcy, scrx, term->oldcy); k8t_DrawCopy(term, scrx, scry, 1, 1); @@ -54,7 +55,7 @@ K8TERM_API void k8t_DrawCursor (K8Term *term) { } } // - if (term->oldcy == cmy || (term->c.state&K8T_CURSOR_HIDE) || term->curbhidden) return; + if (/*term->oldcy == cmy ||*/ (term->c.state&K8T_CURSOR_HIDE) || term->curbhidden) return; /* draw the new one */ scrx = term->c.x; scry = term->c.y+term->topline; @@ -62,6 +63,7 @@ K8TERM_API void k8t_DrawCursor (K8Term *term) { if (scry >= 0 && scry < term->row && !term->isUnderOverlay(term, scrx, scry, 1)) { int nodraw = 0; // + //fprintf(stderr, "cx=%d; cy=%d\n", scrx, scry); if (!focused) { if (term->defcurinactivebg < 0) { term->drawSetFG(term, term->defcurbg); diff --git a/src/libk8sterm/ttyutils.c b/src/libk8sterm/ttyutils.c index fb380ba..b41ba8a 100644 --- a/src/libk8sterm/ttyutils.c +++ b/src/libk8sterm/ttyutils.c @@ -445,6 +445,8 @@ K8TERM_API int k8t_tmInitialize (K8Term *term, int col, int row, int maxhistory) term->tabsize = 8; term->wrbufsize = K8T_WBUFSIZ; // + // colors should be already set here + /* term->deffg = 7; term->defbg = 0; term->defboldfg = -1; @@ -454,6 +456,7 @@ K8TERM_API int k8t_tmInitialize (K8Term *term, int col, int row, int maxhistory) term->defcurbg = 16; term->defcurinactivefg = 0; term->defcurinactivebg = 17; + */ // term->row = row; term->col = col; diff --git a/src/x11CB.c b/src/x11CB.c index d4e3dae..f8c1e83 100644 --- a/src/x11CB.c +++ b/src/x11CB.c @@ -44,11 +44,13 @@ static void drawFillRectCB (K8Term *term, int x0, int y0, int cols, int rows) { // copy pixmap to screen static void drawCopyAreaCB (K8Term *term, int x0, int y0, int cols, int rows) { - int src_x = x0*xw.cw, src_y = y0*xw.ch, src_w = cols*xw.cw, src_h = rows*xw.ch; - int dst_x = src_x, dst_y = src_y; - // - if (opt_tabposition == 1) { dst_y += xw.tabheight; } - XCopyArea(xw.dpy, K8T_DATA(term)->picbuf, xw.win, dc.gc, src_x, src_y, src_w, src_h, dst_x, dst_y); + if (cols > 0 && rows > 0) { + int src_x = x0*xw.cw, src_y = y0*xw.ch, src_w = cols*xw.cw, src_h = rows*xw.ch; + int dst_x = src_x, dst_y = src_y; + // + if (opt_tabposition == 1) { dst_y += xw.tabheight; } + XCopyArea(xw.dpy, K8T_DATA(term)->picbuf, xw.win, dc.gc, src_x, src_y, src_w, src_h, dst_x, dst_y); + } } -- 2.11.4.GIT