From 1dc9a1c90d552c96fd74eae16871aeca72bff2a6 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 27 May 2019 23:28:21 -0500 Subject: [PATCH] *The Cheat makes some The Cheat noises* --- include/hexagram/window.h | 6 ++++++ src/window.c | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/hexagram/window.h b/include/hexagram/window.h index c0572cb..df13bf2 100644 --- a/include/hexagram/window.h +++ b/include/hexagram/window.h @@ -20,10 +20,16 @@ hexagram_window *hexagram_window_new_x11(const char *display, void hexagram_window_destroy(hexagram_window *window); +Display *hexagram_window_get_display(hexagram_window *window); + int hexagram_window_get_display_fd(hexagram_window *window); int hexagram_window_show(hexagram_window *window); +int hexagram_window_repaint_bg(hexagram_window *window); + +int hexagram_window_swap_buffer(hexagram_window *window); + cairo_t *hexagram_window_create_bg_context(hexagram_window *window); cairo_t *hexagram_window_create_fg_context(hexagram_window *window); diff --git a/src/window.c b/src/window.c index 3dafa2c..53b7e12 100644 --- a/src/window.c +++ b/src/window.c @@ -1,3 +1,4 @@ +#include #include #include @@ -165,6 +166,14 @@ void hexagram_window_destroy(hexagram_window *window) { (void)XDestroyWindow(window->display, window->win); } +Display *hexagram_window_get_display(hexagram_window *window) { + return window->display; +} + +int hexagram_window_get_display_fd(hexagram_window *window) { + return ConnectionNumber(window->display); +} + int hexagram_window_show(hexagram_window *window) { if (XSelectInput(window->display, window->win, ExposureMask | ButtonPressMask | KeyPressMask) == 0) { @@ -181,6 +190,20 @@ error_x: return -1; } +int hexagram_window_repaint_bg(hexagram_window *window) { + return XCopyArea(window->display, + window->bg, + window->buf, + window->gc, + 0, 0, + window->width, window->height, + 0, 0) == 0? -1: 1; +} + +int hexagram_window_swap_buffer(hexagram_window *window) { + return XdbeSwapBuffers(window->display, &window->swapinfo, 1) == 0? -1: 1; +} + cairo_t *hexagram_window_create_bg_context(hexagram_window *window) { return cairo_create(window->surface_bg); }