]>
Commit | Line | Data |
---|---|---|
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 | 7 | typedef 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 | |
18 | typedef struct TextCell { | |
44a22215 DM |
19 | gunichar2 ch; |
20 | TextAttributes attrib; | |
22e5ba02 DM |
21 | } TextCell; |
22 | ||
e3759a34 DM |
23 | #define COMMANDS_SIZE 1024 |
24 | #define MAX_HEIGHT 2048 | |
25 | #define MAX_WIDTH 2048 | |
26 | ||
64bc7a2f | 27 | typedef struct SpiceScreen SpiceScreen; |
e3759a34 | 28 | |
64bc7a2f | 29 | struct SpiceScreen { |
e3759a34 DM |
30 | SpiceCoreInterface *core; |
31 | SpiceServer *server; | |
32 | ||
33 | QXLInstance qxl_instance; | |
34 | QXLWorker *qxl_worker; | |
35 | ||
e3759a34 DM |
36 | uint8_t primary_surface[MAX_HEIGHT * MAX_WIDTH * 4]; |
37 | int primary_height; | |
38 | int primary_width; | |
39 | ||
40 | SpiceTimer *conn_timeout_timer; | |
41 | SpiceWatch *mwatch; /* watch master pty */ | |
42 | ||
43 | int cursor_notify; | |
44 | ||
45 | // Current mode (set by create_primary) | |
46 | int width; | |
47 | int height; | |
48 | ||
e3759a34 DM |
49 | GCond* command_cond; |
50 | GMutex* command_mutex; | |
51 | ||
52 | int commands_end; | |
53 | int commands_start; | |
54 | struct QXLCommandExt* commands[COMMANDS_SIZE]; | |
55 | ||
56 | // callbacks | |
64bc7a2f DM |
57 | void (*on_client_connected)(SpiceScreen *spice_screen); |
58 | void (*on_client_disconnected)(SpiceScreen *spice_screen); | |
e3759a34 DM |
59 | }; |
60 | ||
11ba14dc | 61 | SpiceScreen* spice_screen_new(SpiceCoreInterface* core, guint timeout); |
e3759a34 | 62 | |
b052e9c7 | 63 | void spice_screen_draw_char(SpiceScreen *spice_screen, int x, int y, gunichar2 ch, TextAttributes attrib); |
64bc7a2f DM |
64 | void spice_screen_scroll(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2, int src_x, int src_y); |
65 | void spice_screen_clear(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2); | |
64bc7a2f DM |
66 | uint32_t spice_screen_get_width(void); |
67 | uint32_t spice_screen_get_height(void); | |
e3759a34 | 68 | |
d6a5f5a9 | 69 | typedef struct spiceTerm { |
44a22215 DM |
70 | int maxx; |
71 | int maxy; | |
22e5ba02 | 72 | |
44a22215 DM |
73 | int width; |
74 | int height; | |
22e5ba02 | 75 | |
44a22215 DM |
76 | int total_height; |
77 | int scroll_height; | |
78 | int y_base; | |
79 | int y_displ; | |
80 | int altbuf:1; | |
81 | ||
82 | unsigned int utf8:1; // utf8 mode | |
83 | long utf_char; // used by utf8 parser | |
84 | int utf_count; // used by utf8 parser | |
85 | ||
86 | TextAttributes default_attrib; | |
87 | ||
88 | TextCell *cells; | |
89 | TextCell *altcells; | |
90 | ||
91 | SpiceScreen *screen; | |
92 | SpiceKbdInstance keyboard_sin; | |
93 | SpiceCharDeviceInstance vdagent_sin; | |
94 | ||
95 | // cursor | |
96 | TextAttributes cur_attrib; | |
97 | TextAttributes cur_attrib_saved; | |
98 | int tty_state; // 0 - normal, 1 - ESC, 2 - CSI | |
99 | int cx; // cursor x position | |
100 | int cy; // cursor y position | |
101 | int cx_saved; // saved cursor x position | |
102 | int cy_saved; // saved cursor y position | |
103 | int esc_buf[MAX_ESC_PARAMS]; | |
104 | int esc_count; | |
105 | int esc_ques; | |
106 | int esc_has_par; | |
107 | char osc_textbuf[4096]; | |
108 | char osc_cmd; | |
109 | int region_top; | |
110 | int region_bottom; | |
111 | ||
112 | unsigned int charset:1; // G0 or G1 | |
113 | unsigned int charset_saved:1; // G0 or G1 | |
114 | unsigned int g0enc:2; | |
115 | unsigned int g0enc_saved:2; | |
116 | unsigned int g1enc:2; | |
117 | unsigned int g1enc_saved:2; | |
118 | unsigned int cur_enc:2; | |
119 | unsigned int cur_enc_saved:2; | |
120 | ||
121 | // input buffer | |
122 | char ibuf[IBUFSIZE]; | |
123 | int ibuf_count; | |
124 | ||
125 | gunichar2 *selection; | |
126 | int selection_len; | |
127 | ||
128 | unsigned int mark_active:1; | |
129 | ||
130 | unsigned int report_mouse:1; | |
131 | ||
132 | } spiceTerm; |