]> git.proxmox.com Git - spiceterm.git/blobdiff - spiceterm.h
resize: discard pending commands
[spiceterm.git] / spiceterm.h
index 0473712e201949ee8382b21016528128966e1892..6657186717d27a31179ffae4dd4255a6a020fce7 100644 (file)
@@ -1,44 +1,43 @@
-#ifndef __SPICETERM_H__
-#define __SPICETERM_H__
-
 #include <glib.h>
 #include <spice.h>
 
 #define IBUFSIZE 1024
 #define MAX_ESC_PARAMS 16
 
-typedef unsigned short unicode; // fixme
-
 typedef struct TextAttributes {
-  unsigned int fgcol:4;
-  unsigned int bgcol:4;
-  unsigned int bold:1;
-  unsigned int uline:1;
-  unsigned int blink:1;
-  unsigned int invers:1;
-  unsigned int unvisible:1;
+    unsigned int fgcol:4;
+    unsigned int bgcol:4;
+    unsigned int bold:1;
+    unsigned int uline:1;
+    unsigned int blink:1;
+    unsigned int invers:1;
+    unsigned int unvisible:1;
+    unsigned int selected:1;
 } TextAttributes;
 
 typedef struct TextCell {
-  unicode ch;
-  TextAttributes attrib;
+    gunichar2 ch;
+    TextAttributes attrib;
 } TextCell;
 
-#define COMMANDS_SIZE 1024
-#define MAX_HEIGHT 2048
-#define MAX_WIDTH 2048
+#define COMMANDS_SIZE (1024)
+#define MAX_HEIGHT 1440
+#define MAX_WIDTH 2560
+
+typedef struct SpiceScreen SpiceScreen;
 
-typedef struct Test Test;
+typedef struct CachedImage {
+    uint8_t *bitmap;
+    int cache_id;
+} CachedImage;
 
-struct Test {
+struct SpiceScreen {
     SpiceCoreInterface *core;
     SpiceServer *server;
 
     QXLInstance qxl_instance;
     QXLWorker *qxl_worker;
 
-    SpiceKbdInstance keyboard_sin;
-
     uint8_t primary_surface[MAX_HEIGHT * MAX_WIDTH * 4];
     int primary_height;
     int primary_width;
@@ -46,14 +45,10 @@ struct Test {
     SpiceTimer *conn_timeout_timer;
     SpiceWatch *mwatch; /* watch master pty */
 
-    int cursor_notify;
-
     // Current mode (set by create_primary)
     int width;
     int height;
 
-    int target_surface;
-
     GCond* command_cond;
     GMutex* command_mutex;
 
@@ -61,89 +56,85 @@ struct Test {
     int commands_start;
     struct QXLCommandExt* commands[COMMANDS_SIZE];
 
+    //cache for glyphs bitmaps
+    GHashTable *image_cache;
+    
+    gboolean cursor_set;
+
     // callbacks
-    void (*on_client_connected)(Test *test);
-    void (*on_client_disconnected)(Test *test);
+    void (*on_client_connected)(SpiceScreen *spice_screen);
+    void (*on_client_disconnected)(SpiceScreen *spice_screen);
 };
 
-void test_add_display_interface(Test *test);
-void test_add_agent_interface(SpiceServer *server); // TODO - Test *test
-void test_add_keyboard_interface(Test *test);
-Test* test_new(SpiceCoreInterface* core);
+SpiceScreen* spice_screen_new(SpiceCoreInterface* core, uint32_t width, uint32_t height, guint timeout);
 
-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);
+void spice_screen_resize(SpiceScreen *spice_screen, uint32_t width, uint32_t height);
+void spice_screen_draw_char(SpiceScreen *spice_screen, int x, int y, gunichar2 ch, TextAttributes attrib);
+void spice_screen_scroll(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2, int src_x, int src_y);
+void spice_screen_clear(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2);
+uint32_t spice_screen_get_width(void);
+uint32_t spice_screen_get_height(void);
 
+typedef struct spiceTerm {
+    int pty; // pty file descriptor
 
-uint32_t test_get_width(void);
-uint32_t test_get_height(void);
+    int width;
+    int height;
 
-void spice_test_config_parse_args(int argc, char **argv);
+    int total_height;
+    int scroll_height;
+    int y_base;
+    int y_displ;
+    int altbuf:1;
 
-typedef struct spiceTerm {
-  int maxx;
-  int maxy;
-
-  int width;
-  int height;
-
-  int total_height;
-  int scroll_height;
-  int y_base;
-  int y_displ;
-  int altbuf:1;
-
-  unsigned int utf8:1; // utf8 mode
-  long utf_char;       // used by utf8 parser
-  int utf_count;       // used by utf8 parser
-
-
-  TextAttributes default_attrib;
-
-  TextCell *cells;
-  TextCell *altcells;
-
-  Test *screen;
-  SpiceKbdInstance keyboard_sin;
-
-  // cursor
-  TextAttributes cur_attrib;
-  TextAttributes cur_attrib_saved;
-  int tty_state; // 0 - normal, 1 - ESC, 2 - CSI
-  int cx; // cursor x position
-  int cy; // cursor y position
-  int cx_saved; // saved cursor x position
-  int cy_saved; // saved cursor y position
-  int esc_buf[MAX_ESC_PARAMS];
-  int esc_count;
-  int esc_ques;
-  int esc_has_par;
-  char osc_textbuf[4096];
-  char osc_cmd;
-  int region_top;
-  int region_bottom;
-
-  unsigned int charset:1; // G0 or G1
-  unsigned int charset_saved:1; // G0 or G1
-  unsigned int g0enc:2;
-  unsigned int g0enc_saved:2;
-  unsigned int g1enc:2;
-  unsigned int g1enc_saved:2;
-  unsigned int cur_enc:2;
-  unsigned int cur_enc_saved:2;
-
-  // input buffer
-  char ibuf[IBUFSIZE];
-  int ibuf_count;
-
-  unicode *selection;
-  int selection_len;
-
-  unsigned int mark_active:1;
-
-  unsigned int report_mouse:1;
+    unsigned int utf8:1; // utf8 mode
+    long utf_char;       // used by utf8 parser
+    int utf_count;       // used by utf8 parser
 
-} spiceTerm;
+    TextAttributes default_attrib;
 
-#endif /* __SPICETERM_H__ */
+    TextCell *cells;
+    TextCell *altcells;
+
+    SpiceScreen *screen;
+    SpiceKbdInstance keyboard_sin;
+    SpiceCharDeviceInstance vdagent_sin;
+
+    // cursor
+    TextAttributes cur_attrib;
+    TextAttributes cur_attrib_saved;
+    int tty_state; // 0 - normal, 1 - ESC, 2 - CSI
+    int cx; // cursor x position
+    int cy; // cursor y position
+    int cx_saved; // saved cursor x position
+    int cy_saved; // saved cursor y position
+    int esc_buf[MAX_ESC_PARAMS];
+    int esc_count;
+    int esc_ques;
+    int esc_has_par;
+    char osc_textbuf[4096];
+    char osc_cmd;
+    int region_top;
+    int region_bottom;
+
+    unsigned int charset:1; // G0 or G1
+    unsigned int charset_saved:1; // G0 or G1
+    unsigned int g0enc:2;
+    unsigned int g0enc_saved:2;
+    unsigned int g1enc:2;
+    unsigned int g1enc_saved:2;
+    unsigned int cur_enc:2;
+    unsigned int cur_enc_saved:2;
+
+    // input buffer
+    char ibuf[IBUFSIZE];
+    int ibuf_count;
+
+    gunichar2 *selection;
+    int selection_len;
+
+    unsigned int mark_active:1;
+
+    unsigned int report_mouse:1;
+
+} spiceTerm;