aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-04-10 22:02:11 -0400
committerJesse Luehrs <doy@tozt.net>2014-04-10 22:02:11 -0400
commit76581ac4a67ed1d440a9e9a34d65b04fa494888e (patch)
tree02a09516816e5c01312a0b023474f22ea0ae40e9
parent91e64a89e379b8dbdc0252e4bd11627c0a5285a0 (diff)
downloadrunes-76581ac4a67ed1d440a9e9a34d65b04fa494888e.tar.gz
runes-76581ac4a67ed1d440a9e9a34d65b04fa494888e.zip
redraw the window when it's hidden and reshown
-rw-r--r--display.c2
-rw-r--r--term.c6
-rw-r--r--term.h1
-rw-r--r--window-xlib.c9
4 files changed, 15 insertions, 3 deletions
diff --git a/display.c b/display.c
index cf38fa5..a5e0068 100644
--- a/display.c
+++ b/display.c
@@ -4,6 +4,8 @@
void runes_display_init(RunesTerm *t)
{
+ cairo_set_source_rgb(t->cr, 1.0, 1.0, 1.0);
+ cairo_paint(t->cr);
cairo_select_font_face(t->cr, "monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(t->cr, 14.0);
cairo_set_source_rgb(t->cr, 0.0, 0.0, 1.0);
diff --git a/term.c b/term.c
index 2199332..06f4571 100644
--- a/term.c
+++ b/term.c
@@ -4,6 +4,8 @@
void runes_term_init(RunesTerm *t, int argc, char *argv[])
{
+ int x, y;
+
/* doing most of the pty initialization right at the beginning, because
* libuv will set up a bunch of state (including potentially things like
* spawning threads) when that is initialized, and i'm not really sure how
@@ -15,7 +17,9 @@ void runes_term_init(RunesTerm *t, int argc, char *argv[])
runes_pty_backend_loop_init(t);
runes_window_backend_init(t, argc, argv);
- t->cr = cairo_create(runes_window_backend_surface_create(t));
+ t->backend_cr = cairo_create(runes_window_backend_surface_create(t));
+ runes_window_backend_get_size(t, &x, &y);
+ t->cr = cairo_create(cairo_surface_create_similar_image(cairo_get_target(t->backend_cr), CAIRO_FORMAT_RGB24, x, y));
}
void runes_term_cleanup(RunesTerm *t)
diff --git a/term.h b/term.h
index 0d00cfb..9856ce2 100644
--- a/term.h
+++ b/term.h
@@ -6,6 +6,7 @@ struct runes_term {
RunesPtyBackend pty;
cairo_t *cr;
+ cairo_t *backend_cr;
uv_loop_t *loop;
int row;
diff --git a/window-xlib.c b/window-xlib.c
index 7360dde..17351ed 100644
--- a/window-xlib.c
+++ b/window-xlib.c
@@ -66,6 +66,9 @@ static void runes_process_event(uv_work_t *req, int status)
free(buf);
break;
}
+ case Expose:
+ runes_window_backend_flush(t);
+ break;
case ClientMessage: {
Atom a = e->xclient.data.l[0];
if (a == w->atoms[RUNES_ATOM_WM_DELETE_WINDOW]) {
@@ -130,7 +133,7 @@ static void runes_window_init_loop(RunesTerm *t)
w = &t->w;
XGetICValues(w->ic, XNFilterEvents, &mask, NULL);
- XSelectInput(w->dpy, w->w, mask|KeyPressMask|StructureNotifyMask);
+ XSelectInput(w->dpy, w->w, mask|KeyPressMask|StructureNotifyMask|ExposureMask);
XSetICFocus(w->ic);
data = malloc(sizeof(RunesXlibLoopData));
@@ -201,6 +204,8 @@ cairo_surface_t *runes_window_backend_surface_create(RunesTerm *t)
void runes_window_backend_flush(RunesTerm *t)
{
+ cairo_set_source_surface(t->backend_cr, cairo_get_target(t->cr), 0.0, 0.0);
+ cairo_paint(t->backend_cr);
XFlush(t->w.dpy);
}
@@ -208,7 +213,7 @@ void runes_window_backend_get_size(RunesTerm *t, int *xpixel, int *ypixel)
{
cairo_surface_t *surface;
- surface = cairo_get_target(t->cr);
+ surface = cairo_get_target(t->backend_cr);
*xpixel = cairo_xlib_surface_get_width(surface);
*ypixel = cairo_xlib_surface_get_height(surface);
}