Graphics protocol: Add support for having the terminal emulator assign image ids

Useful when multiple non co-operating programs want to share the screen.
Fixes #3163
This commit is contained in:
Kovid Goyal
2020-12-16 17:31:15 +05:30
parent 09e75ea329
commit e96ff19a7a
8 changed files with 214 additions and 42 deletions

View File

@@ -24,6 +24,7 @@ static inline void parse_graphics_code(Screen *screen,
format = 'f',
more = 'm',
id = 'i',
image_number = 'I',
placement_id = 'p',
quiet = 'q',
width = 'w',
@@ -72,6 +73,9 @@ static inline void parse_graphics_code(Screen *screen,
case id:
value_state = UINT;
break;
case image_number:
value_state = UINT;
break;
case placement_id:
value_state = UINT;
break;
@@ -140,8 +144,8 @@ static inline void parse_graphics_code(Screen *screen,
case action: {
g.action = screen->parser_buf[pos++] & 0xff;
if (g.action != 'q' && g.action != 'd' && g.action != 'p' &&
g.action != 'T' && g.action != 't') {
if (g.action != 'T' && g.action != 'd' && g.action != 'p' &&
g.action != 't' && g.action != 'q') {
REPORT_ERROR("Malformed GraphicsCommand control block, unknown flag "
"value for action: 0x%x",
g.action);
@@ -151,14 +155,14 @@ static inline void parse_graphics_code(Screen *screen,
case delete_action: {
g.delete_action = screen->parser_buf[pos++] & 0xff;
if (g.delete_action != 'y' && g.delete_action != 'q' &&
g.delete_action != 'z' && g.delete_action != 'Z' &&
g.delete_action != 'a' && g.delete_action != 'A' &&
g.delete_action != 'Q' && g.delete_action != 'X' &&
g.delete_action != 'i' && g.delete_action != 'p' &&
g.delete_action != 'Y' && g.delete_action != 'P' &&
g.delete_action != 'c' && g.delete_action != 'x' &&
g.delete_action != 'C' && g.delete_action != 'I') {
if (g.delete_action != 'y' && g.delete_action != 'c' &&
g.delete_action != 'x' && g.delete_action != 'p' &&
g.delete_action != 'P' && g.delete_action != 'Q' &&
g.delete_action != 'C' && g.delete_action != 'Y' &&
g.delete_action != 'i' && g.delete_action != 'z' &&
g.delete_action != 'A' && g.delete_action != 'a' &&
g.delete_action != 'q' && g.delete_action != 'Z' &&
g.delete_action != 'X' && g.delete_action != 'I') {
REPORT_ERROR("Malformed GraphicsCommand control block, unknown flag "
"value for delete_action: 0x%x",
g.delete_action);
@@ -168,8 +172,8 @@ static inline void parse_graphics_code(Screen *screen,
case transmission_type: {
g.transmission_type = screen->parser_buf[pos++] & 0xff;
if (g.transmission_type != 'f' && g.transmission_type != 's' &&
g.transmission_type != 't' && g.transmission_type != 'd') {
if (g.transmission_type != 's' && g.transmission_type != 'd' &&
g.transmission_type != 't' && g.transmission_type != 'f') {
REPORT_ERROR("Malformed GraphicsCommand control block, unknown flag "
"value for transmission_type: 0x%x",
g.transmission_type);
@@ -242,6 +246,7 @@ static inline void parse_graphics_code(Screen *screen,
U(format);
U(more);
U(id);
U(image_number);
U(placement_id);
U(quiet);
U(width);
@@ -314,12 +319,13 @@ static inline void parse_graphics_code(Screen *screen,
}
REPORT_VA_COMMAND(
"s {sc sc sc sc sI sI sI sI sI sI sI sI sI sI sI sI sI sI sI sI sI si "
"s {sc sc sc sc sI sI sI sI sI sI sI sI sI sI sI sI sI sI sI sI sI sI si "
"sI} y#",
"graphics_command", "action", g.action, "delete_action", g.delete_action,
"transmission_type", g.transmission_type, "compressed", g.compressed,
"format", (unsigned int)g.format, "more", (unsigned int)g.more, "id",
(unsigned int)g.id, "placement_id", (unsigned int)g.placement_id, "quiet",
(unsigned int)g.id, "image_number", (unsigned int)g.image_number,
"placement_id", (unsigned int)g.placement_id, "quiet",
(unsigned int)g.quiet, "width", (unsigned int)g.width, "height",
(unsigned int)g.height, "x_offset", (unsigned int)g.x_offset, "y_offset",
(unsigned int)g.y_offset, "data_height", (unsigned int)g.data_height,