]> git.proxmox.com Git - spiceterm.git/blob - test_display_base.h
use new unicode spice input extension
[spiceterm.git] / test_display_base.h
1 #ifndef __TEST_DISPLAY_BASE_H__
2 #define __TEST_DISPLAY_BASE_H__
3
4 #include <glib.h>
5 #include <spice.h>
6 #include "basic_event_loop.h"
7
8
9 typedef struct TextAttributes {
10 unsigned int fgcol:4;
11 unsigned int bgcol:4;
12 unsigned int bold:1;
13 unsigned int uline:1;
14 unsigned int blink:1;
15 unsigned int invers:1;
16 unsigned int unvisible:1;
17 } TextAttributes;
18
19 #define COUNT(x) ((sizeof(x)/sizeof(x[0])))
20
21 /*
22 * simple queue for commands.
23 * each command can have up to two parameters (grow as needed)
24 *
25 * TODO: switch to gtk main loop. Then add gobject-introspection. then
26 * write tests in python/guile/whatever.
27 */
28 typedef enum {
29 PATH_PROGRESS,
30 SIMPLE_CREATE_SURFACE,
31 SIMPLE_DRAW,
32 SIMPLE_DRAW_BITMAP,
33 SIMPLE_DRAW_SOLID,
34 SIMPLE_COPY_BITS,
35 SIMPLE_DESTROY_SURFACE,
36 SIMPLE_UPDATE,
37 DESTROY_PRIMARY,
38 CREATE_PRIMARY,
39 SLEEP
40 } CommandType;
41
42 typedef struct CommandCreatePrimary {
43 uint32_t width;
44 uint32_t height;
45 } CommandCreatePrimary;
46
47 typedef struct CommandCreateSurface {
48 uint32_t surface_id;
49 uint32_t format;
50 uint32_t width;
51 uint32_t height;
52 uint8_t *data;
53 } CommandCreateSurface;
54
55 typedef struct CommandDrawBitmap {
56 QXLRect bbox;
57 uint8_t *bitmap;
58 uint32_t surface_id;
59 uint32_t num_clip_rects;
60 QXLRect *clip_rects;
61 } CommandDrawBitmap;
62
63 typedef struct CommandDrawSolid {
64 QXLRect bbox;
65 uint32_t color;
66 uint32_t surface_id;
67 } CommandDrawSolid;
68
69 typedef struct CommandSleep {
70 uint32_t secs;
71 } CommandSleep;
72
73 typedef struct Command Command;
74 typedef struct Test Test;
75
76 struct Command {
77 CommandType command;
78 void (*cb)(Test *test, Command *command);
79 void *cb_opaque;
80 union {
81 CommandCreatePrimary create_primary;
82 CommandDrawBitmap bitmap;
83 CommandDrawSolid solid;
84 CommandSleep sleep;
85 CommandCreateSurface create_surface;
86 };
87 };
88
89 #define MAX_HEIGHT 2048
90 #define MAX_WIDTH 2048
91
92 #define SURF_WIDTH 320
93 #define SURF_HEIGHT 240
94
95 struct Test {
96 SpiceCoreInterface *core;
97 SpiceServer *server;
98
99 QXLInstance qxl_instance;
100 QXLWorker *qxl_worker;
101
102 SpiceKbdInstance keyboard_sin;
103
104 uint8_t primary_surface[MAX_HEIGHT * MAX_WIDTH * 4];
105 int primary_height;
106 int primary_width;
107
108 SpiceTimer *conn_timeout_timer;
109 SpiceWatch *mwatch; /* watch master pty */
110
111 int cursor_notify;
112
113 uint8_t secondary_surface[SURF_WIDTH * SURF_HEIGHT * 4];
114 int has_secondary;
115
116 // Current mode (set by create_primary)
117 int width;
118 int height;
119
120 int target_surface;
121
122 // callbacks
123 void (*on_client_connected)(Test *test);
124 void (*on_client_disconnected)(Test *test);
125 };
126
127 void test_add_display_interface(Test *test);
128 void test_add_agent_interface(SpiceServer *server); // TODO - Test *test
129 void test_add_keyboard_interface(Test *test);
130 Test* test_new(SpiceCoreInterface* core);
131
132 void test_draw_update_char(Test *test, int x, int y, int c, TextAttributes attrib);
133
134 uint32_t test_get_width(void);
135 uint32_t test_get_height(void);
136
137 void spice_test_config_parse_args(int argc, char **argv);
138
139 #endif /* __TEST_DISPLAY_BASE_H__ */