]> git.proxmox.com Git - spiceterm.git/blame - spiceterm.h
resize: discard pending commands
[spiceterm.git] / spiceterm.h
CommitLineData
e3759a34
DM
1#include <glib.h>
2#include <spice.h>
22e5ba02
DM
3
4#define IBUFSIZE 1024
5#define MAX_ESC_PARAMS 16
6
e3759a34 7typedef struct TextAttributes {
44a22215
DM
8 unsigned int fgcol:4;
9 unsigned int bgcol:4;
10 unsigned int bold:1;
11 unsigned int uline:1;
12 unsigned int blink:1;
13 unsigned int invers:1;
14 unsigned int unvisible:1;
1d11aa12 15 unsigned int selected:1;
e3759a34 16} TextAttributes;
22e5ba02
DM
17
18typedef struct TextCell {
44a22215
DM
19 gunichar2 ch;
20 TextAttributes attrib;
22e5ba02
DM
21} TextCell;
22
c783f726 23#define COMMANDS_SIZE (1024)
baa9598b
DM
24#define MAX_HEIGHT 1440
25#define MAX_WIDTH 2560
e3759a34 26
64bc7a2f 27typedef struct SpiceScreen SpiceScreen;
e3759a34 28
e70e45a9
DM
29typedef struct CachedImage {
30 uint8_t *bitmap;
31 int cache_id;
32} CachedImage;
33
64bc7a2f 34struct SpiceScreen {
e3759a34
DM
35 SpiceCoreInterface *core;
36 SpiceServer *server;
37
38 QXLInstance qxl_instance;
39 QXLWorker *qxl_worker;
40
e3759a34
DM
41 uint8_t primary_surface[MAX_HEIGHT * MAX_WIDTH * 4];
42 int primary_height;
43 int primary_width;
44
45 SpiceTimer *conn_timeout_timer;
46 SpiceWatch *mwatch; /* watch master pty */
47
e3759a34
DM
48 // Current mode (set by create_primary)
49 int width;
50 int height;
51
e3759a34
DM
52 GCond* command_cond;
53 GMutex* command_mutex;
54
55 int commands_end;
56 int commands_start;
57 struct QXLCommandExt* commands[COMMANDS_SIZE];
58
e70e45a9
DM
59 //cache for glyphs bitmaps
60 GHashTable *image_cache;
6508981f
DM
61
62 gboolean cursor_set;
e70e45a9 63
e3759a34 64 // callbacks
64bc7a2f
DM
65 void (*on_client_connected)(SpiceScreen *spice_screen);
66 void (*on_client_disconnected)(SpiceScreen *spice_screen);
e3759a34
DM
67};
68
8f53ae81 69SpiceScreen* spice_screen_new(SpiceCoreInterface* core, uint32_t width, uint32_t height, guint timeout);
e3759a34 70
8f53ae81 71void spice_screen_resize(SpiceScreen *spice_screen, uint32_t width, uint32_t height);
b052e9c7 72void spice_screen_draw_char(SpiceScreen *spice_screen, int x, int y, gunichar2 ch, TextAttributes attrib);
64bc7a2f
DM
73void spice_screen_scroll(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2, int src_x, int src_y);
74void spice_screen_clear(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2);
64bc7a2f
DM
75uint32_t spice_screen_get_width(void);
76uint32_t spice_screen_get_height(void);
e3759a34 77
d6a5f5a9 78typedef struct spiceTerm {
8f53ae81 79 int pty; // pty file descriptor
22e5ba02 80
44a22215
DM
81 int width;
82 int height;
22e5ba02 83
44a22215
DM
84 int total_height;
85 int scroll_height;
86 int y_base;
87 int y_displ;
88 int altbuf:1;
89
90 unsigned int utf8:1; // utf8 mode
91 long utf_char; // used by utf8 parser
92 int utf_count; // used by utf8 parser
93
94 TextAttributes default_attrib;
95
96 TextCell *cells;
97 TextCell *altcells;
98
99 SpiceScreen *screen;
100 SpiceKbdInstance keyboard_sin;
101 SpiceCharDeviceInstance vdagent_sin;
102
103 // cursor
104 TextAttributes cur_attrib;
105 TextAttributes cur_attrib_saved;
106 int tty_state; // 0 - normal, 1 - ESC, 2 - CSI
107 int cx; // cursor x position
108 int cy; // cursor y position
109 int cx_saved; // saved cursor x position
110 int cy_saved; // saved cursor y position
111 int esc_buf[MAX_ESC_PARAMS];
112 int esc_count;
113 int esc_ques;
114 int esc_has_par;
115 char osc_textbuf[4096];
116 char osc_cmd;
117 int region_top;
118 int region_bottom;
119
120 unsigned int charset:1; // G0 or G1
121 unsigned int charset_saved:1; // G0 or G1
122 unsigned int g0enc:2;
123 unsigned int g0enc_saved:2;
124 unsigned int g1enc:2;
125 unsigned int g1enc_saved:2;
126 unsigned int cur_enc:2;
127 unsigned int cur_enc_saved:2;
128
129 // input buffer
130 char ibuf[IBUFSIZE];
131 int ibuf_count;
132
133 gunichar2 *selection;
134 int selection_len;
135
136 unsigned int mark_active:1;
137
138 unsigned int report_mouse:1;
139
140} spiceTerm;