|
|
@@ -11,31 +11,28 @@ It is distributed in the hope that it will be useful or harmful, it really depen |
|
|
|
|
|
|
|
#include "chapter_5.h" |
|
|
|
|
|
|
|
#define BLESSES_FONT_WIDTH (8) |
|
|
|
#define BLESSES_FONT_HEIGHT (8) |
|
|
|
|
|
|
|
#define BLESSES_FONT_WIDTH (8) |
|
|
|
#define BLESSES_FONT_HEIGHT (8) |
|
|
|
#define BLESSES_FONT_TABULATOR (4) |
|
|
|
|
|
|
|
char * blesses_window_title = "xolatile"; |
|
|
|
int blesses_window_width = 1800; |
|
|
|
int blesses_window_height = 900; |
|
|
|
int blesses_active = 1; |
|
|
|
int blesses_cursor_x = 0; |
|
|
|
int blesses_cursor_y = 0; |
|
|
|
int blesses_signal = 0; |
|
|
|
int * blesses_sub_framebuffer = NULL; |
|
|
|
int * blesses_framebuffer = NULL; |
|
|
|
|
|
|
|
void (* blesses_action [BLESSES_SIGNAL_COUNT]) (void) = { NULL }; |
|
|
|
|
|
|
|
xcb_window_t blesses_window = 0; |
|
|
|
xcb_gcontext_t blesses_context = 0; |
|
|
|
xcb_pixmap_t blesses_pixmap = 0; |
|
|
|
xcb_connection_t * blesses_connection = NULL; |
|
|
|
xcb_screen_t * blesses_screen = NULL; |
|
|
|
xcb_image_t * blesses_image = NULL; |
|
|
|
|
|
|
|
void blesses_initialize (void) { |
|
|
|
#define BLESSES_SIGNAL_COUNT (144) |
|
|
|
|
|
|
|
static char * blesses_window_title = "xolatile"; |
|
|
|
static int blesses_window_width = 1800; |
|
|
|
static int blesses_window_height = 900; |
|
|
|
static int * blesses_sub_framebuffer = NULL; |
|
|
|
static int * blesses_framebuffer = NULL; |
|
|
|
|
|
|
|
static void (* blesses_action [BLESSES_SIGNAL_COUNT]) (void) = { NULL }; |
|
|
|
|
|
|
|
static xcb_window_t blesses_window = 0; |
|
|
|
static xcb_gcontext_t blesses_context = 0; |
|
|
|
static xcb_pixmap_t blesses_pixmap = 0; |
|
|
|
static xcb_connection_t * blesses_connection = NULL; |
|
|
|
static xcb_screen_t * blesses_screen = NULL; |
|
|
|
static xcb_image_t * blesses_image = NULL; |
|
|
|
|
|
|
|
static void blesses_initialize (void) { |
|
|
|
unsigned int window_flags [2] = { |
|
|
|
0, |
|
|
|
XCB_EVENT_MASK_NO_EVENT | |
|
|
@@ -50,6 +47,10 @@ void blesses_initialize (void) { |
|
|
|
unsigned short int window_width = (unsigned short int) blesses_window_width; |
|
|
|
unsigned short int window_height = (unsigned short int) blesses_window_height; |
|
|
|
|
|
|
|
if (blesses_active == TRUE) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
blesses_connection = xcb_connect (NULL, NULL); |
|
|
|
|
|
|
|
fatal_failure (blesses_connection == NULL, "blesses : blesses_initialize : XCB connection is null pointer."); |
|
|
@@ -67,7 +68,7 @@ void blesses_initialize (void) { |
|
|
|
|
|
|
|
xcb_map_window (blesses_connection, blesses_window); |
|
|
|
|
|
|
|
xcb_change_property (blesses_connection, XCB_PROP_MODE_REPLACE, blesses_window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, string_length (blesses_window_title), blesses_window_title); |
|
|
|
xcb_change_property (blesses_connection, XCB_PROP_MODE_REPLACE, blesses_window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, (unsigned int) string_length (blesses_window_title), blesses_window_title); |
|
|
|
|
|
|
|
xcb_create_pixmap (blesses_connection, blesses_screen->root_depth, blesses_pixmap, blesses_window, window_width, window_height); |
|
|
|
|
|
|
@@ -80,7 +81,7 @@ void blesses_initialize (void) { |
|
|
|
blesses_framebuffer = allocate (blesses_window_width * blesses_window_height * (int) sizeof (* blesses_framebuffer)); |
|
|
|
} |
|
|
|
|
|
|
|
void blesses_deinitialize (void) { |
|
|
|
static void blesses_deinitialize (void) { |
|
|
|
blesses_sub_framebuffer = deallocate (blesses_sub_framebuffer); |
|
|
|
blesses_framebuffer = deallocate (blesses_framebuffer); |
|
|
|
|
|
|
@@ -93,9 +94,23 @@ void blesses_deinitialize (void) { |
|
|
|
xcb_disconnect (blesses_connection); |
|
|
|
} |
|
|
|
|
|
|
|
int blesses_active = FALSE; |
|
|
|
int blesses_cursor_x = 0; |
|
|
|
int blesses_cursor_y = 0; |
|
|
|
int blesses_signal = 0; |
|
|
|
|
|
|
|
void blesses_configure (void) { |
|
|
|
blesses_initialize (); |
|
|
|
|
|
|
|
blesses_active = TRUE; |
|
|
|
} |
|
|
|
|
|
|
|
void blesses_synchronize (void) { |
|
|
|
int i = 0; |
|
|
|
|
|
|
|
unsigned short int window_width = (unsigned short int) blesses_window_width; |
|
|
|
unsigned short int window_height = (unsigned short int) blesses_window_height; |
|
|
|
|
|
|
|
xcb_generic_event_t * generic_event = NULL; |
|
|
|
/* |
|
|
|
for (i = 0; i != blesses_window_width * blesses_window_height; i++) { |
|
|
@@ -108,15 +123,15 @@ void blesses_synchronize (void) { |
|
|
|
|
|
|
|
blesses_sub_framebuffer = deallocate (blesses_sub_framebuffer); |
|
|
|
|
|
|
|
blesses_image = xcb_image_create_native (blesses_connection, blesses_window_width, blesses_window_height, XCB_IMAGE_FORMAT_Z_PIXMAP, blesses_screen->root_depth, |
|
|
|
blesses_framebuffer, (unsigned int) (blesses_window_width * blesses_window_height * (int) sizeof (* blesses_framebuffer)), |
|
|
|
blesses_image = xcb_image_create_native (blesses_connection, window_width, window_height, XCB_IMAGE_FORMAT_Z_PIXMAP, blesses_screen->root_depth, |
|
|
|
blesses_framebuffer, (unsigned int) (window_width * window_height * (int) sizeof (* blesses_framebuffer)), |
|
|
|
(unsigned char *) blesses_framebuffer); |
|
|
|
|
|
|
|
xcb_image_put (blesses_connection, blesses_pixmap, blesses_context, blesses_image, 0, 0, 0); |
|
|
|
|
|
|
|
xcb_image_destroy (blesses_image); |
|
|
|
|
|
|
|
xcb_copy_area (blesses_connection, blesses_pixmap, blesses_window, blesses_context, 0, 0, 0, 0, blesses_window_width, blesses_window_height); |
|
|
|
xcb_copy_area (blesses_connection, blesses_pixmap, blesses_window, blesses_context, 0, 0, 0, 0, window_width, window_height); |
|
|
|
|
|
|
|
blesses_framebuffer = NULL; |
|
|
|
|
|
|
@@ -129,7 +144,7 @@ void blesses_synchronize (void) { |
|
|
|
case XCB_KEY_PRESS: { |
|
|
|
blesses_signal = (int) ((xcb_key_press_event_t *) generic_event)->detail; |
|
|
|
if (blesses_signal == 24) { |
|
|
|
blesses_active = 0; |
|
|
|
blesses_active = FALSE; |
|
|
|
} |
|
|
|
} break; |
|
|
|
default: { |
|
|
@@ -143,6 +158,10 @@ void blesses_synchronize (void) { |
|
|
|
blesses_sub_framebuffer = allocate (blesses_window_width * blesses_window_height * (int) sizeof (* blesses_sub_framebuffer)); |
|
|
|
blesses_framebuffer = allocate (blesses_window_width * blesses_window_height * (int) sizeof (* blesses_framebuffer)); |
|
|
|
} |
|
|
|
|
|
|
|
if (blesses_active == FALSE) { |
|
|
|
blesses_deinitialize (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void blesses_render_background_colour (int background) { |
|
|
@@ -150,7 +169,7 @@ void blesses_render_background_colour (int background) { |
|
|
|
|
|
|
|
for (y = 0; y != blesses_window_height/* / 2*/; ++y) { |
|
|
|
for (x = 0; x != blesses_window_width/* / 2*/; ++x) { |
|
|
|
blesses_sub_framebuffer [y * (blesses_window_width/* / 2*/) + x] = 0XFF000000 | colour; |
|
|
|
blesses_sub_framebuffer [y * (blesses_window_width/* / 2*/) + x] = (int) (0XFF000000 | (unsigned int) background); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|