all: ${PROGRAMS}
spiceterm: ${SOURCES} ${HEADERS} spiceterm.c
- gcc ${SOURCES} spiceterm.c -o $@ -lutil $(shell pkg-config --cflags gdk-3.0) $(shell pkg-config --cflags --libs gthread-2.0,spice-protocol,spice-server)
+ gcc -Werror -Wall -Wtype-limits ${SOURCES} spiceterm.c -o $@ -lutil $(shell pkg-config --cflags gdk-3.0) $(shell pkg-config --cflags --libs gthread-2.0,spice-protocol,spice-server)
.PHONY: test
test: spiceterm
static void channel_event(int event, SpiceChannelEventInfo *info)
{
- DPRINTF(0, "channel event con, type, id, event: %ld, %d, %d, %d",
+ DPRINTF(0, "channel event con, type, id, event: %d, %d, %d, %d",
info->connection_id, info->type, info->id, event);
}
-static int vt_font_size = 850;
+int vt_font_size = 850;
-static unsigned char vt_font_data[] = {
+unsigned char vt_font_data[] = {
/* 0 0x00 */
0x00, /* 00000000 */
0x00, /* 00000000 */
};
-static unsigned short vt_fontmap[65536] = {
+unsigned short vt_fontmap[65536] = {
/* 0x0000 => */ 0,
/* 0x0001 => */ 0,
/* 0x0002 => */ 0,
*/
+#define _GNU_SOURCE
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <locale.h>
#include "spiceterm.h"
-#include "glyphs.h"
+//#include "glyphs.h"
#include <glib.h>
#include <spice.h>
/* these colours are from linux kernel drivers/char/vt.c */
-static int idle_timeout = 1;
-
unsigned char color_table[] = { 0, 4, 2, 6, 1, 5, 3, 7,
8,12,10,14, 9,13,11,15 };
}
/* Convert UCS2 to UTF8 sequence, trailing zero */
+/*
static int
ucs2_to_utf8 (unicode c, char *out)
{
return 0;
}
-
+*/
static void
draw_char_at (vncTerm *vt, int x, int y, unicode ch, TextAttributes attrib)
return;
}
-
- int ec = vt_fontmap[ch];
-
- test_draw_update_char(vt->screen, x, y, ec, attrib);
+ test_draw_update_char(vt->screen, x, y, ch, attrib);
}
static void
vt->selection_len = len;
}
*/
+/*
static void
mouse_report (vncTerm *vt, int butt, int mrx, int mry)
{
vncterm_respond_esc (vt, buf);
}
+*/
void
vncterm_toggle_marked_cell (vncTerm *vt, int pos)
{
- int x= (pos%vt->width)*8;
- int y= (pos/vt->width)*16;
/* fixme:
+ int x= (pos%vt->width)*8;
+ int y= (pos/vt->width)*16;
int i,j;
rfbScreenInfoPtr s=vt->screen;
}
*/
-static int client_count = 0;
-static int client_connected = 0;
-static int last_client = 1;
-static time_t last_time = 0;
-
static void my_kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
{
- vncTerm *vt = SPICE_CONTAINEROF(sin, vncTerm, keyboard_sin);
+ // vncTerm *vt = SPICE_CONTAINEROF(sin, vncTerm, keyboard_sin);
/* we no not need this */
int pid;
int master;
char ptyname[1024];
- fd_set fs, fs1;
- struct timeval tv, tv1;
- time_t elapsed, cur_time;
struct winsize dimensions;
g_thread_init(NULL);
}
}
+ if (0) print_usage(NULL); // fixme:
+
vncTerm *vt = create_vncterm (argc, argv, 745, 400);
setlocale(LC_ALL, ""); // set from environment
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 320
-#define SINGLE_PART 4
-static const int angle_parts = 64 / SINGLE_PART;
+//#define SINGLE_PART 4
+//static const int angle_parts = 64 / SINGLE_PART;
static int unique = 1;
-static int color = -1;
-static int c_i = 0;
+//static int color = -1;
+//static int c_i = 0;
__attribute__((noreturn))
static void sigchld_handler(int signal_num) // wait for the child process and exit
static int req_cmd_notification(QXLInstance *qin)
{
- Test *test = SPICE_CONTAINEROF(qin, Test, qxl_instance);
-
+ //Test *test = SPICE_CONTAINEROF(qin, Test, qxl_instance);
//test->core->timer_start(test->wakeup_timer, test->wakeup_ms);
+
return TRUE;
}
static int get_cursor_command(QXLInstance *qin, struct QXLCommandExt *ext)
{
Test *test = SPICE_CONTAINEROF(qin, Test, qxl_instance);
- static int color = 0;
static int set = 1;
static int x = 0, y = 0;
QXLCursorCmd *cursor_cmd;
static void do_conn_timeout(void *opaque)
{
- Test *test = opaque;
+ // Test *test = opaque;
if (client_count <= 0) {
printf("do_conn_timeout\n");
spice_server_add_interface(server, &vdagent_sin.base);
}
-static int my_charcode = 65;
-static int my_posx = 0;
static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
{
Test *test = SPICE_CONTAINEROF(sin, Test, keyboard_sin);
}
-void test_draw_update_char(Test *test, int x, int y, int c, TextAttributes attrib)
+void test_draw_update_char(Test *test, int x, int y, gunichar ch, TextAttributes attrib)
{
int fg, bg;
//rfbDrawLine (vt->screen, rx, ry + 14, rxe, ry + 14, fg);
//}
+ int c = vt_fontmap[ch];
+
SimpleSpiceUpdate *update;
update = test_draw_char(test, x, y, c, fg, bg);
push_command(test, &update->ext);
}
cursor_init();
- test->has_secondary = 0;
int timeout = 10; // max time to wait for client connection
test->conn_timeout_timer = core->timer_add(do_conn_timeout, test);
#include <glib.h>
#include <spice.h>
+
#include "basic_event_loop.h"
#define COUNT(x) ((sizeof(x)/sizeof(x[0])))
-/*
- * simple queue for commands.
- * each command can have up to two parameters (grow as needed)
- *
- * TODO: switch to gtk main loop. Then add gobject-introspection. then
- * write tests in python/guile/whatever.
- */
-typedef enum {
- PATH_PROGRESS,
- SIMPLE_CREATE_SURFACE,
- SIMPLE_DRAW,
- SIMPLE_DRAW_BITMAP,
- SIMPLE_DRAW_SOLID,
- SIMPLE_COPY_BITS,
- SIMPLE_DESTROY_SURFACE,
- SIMPLE_UPDATE,
- DESTROY_PRIMARY,
- CREATE_PRIMARY,
- SLEEP
-} CommandType;
-
-typedef struct CommandCreatePrimary {
- uint32_t width;
- uint32_t height;
-} CommandCreatePrimary;
-
-typedef struct CommandCreateSurface {
- uint32_t surface_id;
- uint32_t format;
- uint32_t width;
- uint32_t height;
- uint8_t *data;
-} CommandCreateSurface;
-
-typedef struct CommandDrawBitmap {
- QXLRect bbox;
- uint8_t *bitmap;
- uint32_t surface_id;
- uint32_t num_clip_rects;
- QXLRect *clip_rects;
-} CommandDrawBitmap;
-
-typedef struct CommandDrawSolid {
- QXLRect bbox;
- uint32_t color;
- uint32_t surface_id;
-} CommandDrawSolid;
-
-typedef struct CommandSleep {
- uint32_t secs;
-} CommandSleep;
-
-typedef struct Command Command;
typedef struct Test Test;
-struct Command {
- CommandType command;
- void (*cb)(Test *test, Command *command);
- void *cb_opaque;
- union {
- CommandCreatePrimary create_primary;
- CommandDrawBitmap bitmap;
- CommandDrawSolid solid;
- CommandSleep sleep;
- CommandCreateSurface create_surface;
- };
-};
-
#define COMMANDS_SIZE 1024
#define MAX_HEIGHT 2048
#define MAX_WIDTH 2048
-#define SURF_WIDTH 320
-#define SURF_HEIGHT 240
-
struct Test {
SpiceCoreInterface *core;
SpiceServer *server;
int cursor_notify;
- uint8_t secondary_surface[SURF_WIDTH * SURF_HEIGHT * 4];
- int has_secondary;
-
// Current mode (set by create_primary)
int width;
int height;
void test_add_keyboard_interface(Test *test);
Test* test_new(SpiceCoreInterface* core);
-void test_draw_update_char(Test *test, int x, int y, int c, TextAttributes attrib);
+void test_draw_update_char(Test *test, int x, int y, gunichar ch, TextAttributes attrib);
void test_spice_scroll(Test *test, int x1, int y1, int x2, int y2, int src_x, int src_y);
void test_spice_clear(Test *test, int x1, int y1, int x2, int y2);