GUAC-803: Move display into separate layer, always size default layer perfectly.
This commit is contained in:
parent
37037b6f8b
commit
569f4adbac
@ -246,7 +246,7 @@ int __guac_terminal_set(guac_terminal_display* display, int row, int col, int co
|
||||
pango_cairo_show_layout(cairo, layout);
|
||||
|
||||
/* Draw */
|
||||
guac_common_surface_draw(display->default_surface,
|
||||
guac_common_surface_draw(display->display_surface,
|
||||
display->char_width * col,
|
||||
display->char_height * row,
|
||||
surface);
|
||||
@ -274,8 +274,14 @@ guac_terminal_display* guac_terminal_display_alloc(guac_client* client,
|
||||
display->client = client;
|
||||
|
||||
/* Create default surface */
|
||||
display->default_surface = guac_common_surface_alloc(client->socket, GUAC_DEFAULT_LAYER, 0, 0);
|
||||
display->display_layer = guac_client_alloc_layer(client);
|
||||
display->select_layer = guac_client_alloc_layer(client);
|
||||
display->display_surface = guac_common_surface_alloc(client->socket,
|
||||
display->display_layer, 0, 0);
|
||||
|
||||
/* Select layer is a child of the display layer */
|
||||
guac_protocol_send_move(client->socket, display->select_layer,
|
||||
display->display_layer, 0, 0, 0);
|
||||
|
||||
/* Get font */
|
||||
display->font_desc = pango_font_description_new();
|
||||
@ -516,7 +522,7 @@ void guac_terminal_display_resize(guac_terminal_display* display, int width, int
|
||||
|
||||
/* Send display size */
|
||||
guac_common_surface_resize(
|
||||
display->default_surface,
|
||||
display->display_surface,
|
||||
display->char_width * width,
|
||||
display->char_height * height);
|
||||
|
||||
@ -636,13 +642,13 @@ void __guac_terminal_display_flush_copy(guac_terminal_display* display) {
|
||||
/* Send copy */
|
||||
guac_common_surface_copy(
|
||||
|
||||
display->default_surface,
|
||||
display->display_surface,
|
||||
current->column * display->char_width,
|
||||
current->row * display->char_height,
|
||||
rect_width * display->char_width,
|
||||
rect_height * display->char_height,
|
||||
|
||||
display->default_surface,
|
||||
display->display_surface,
|
||||
col * display->char_width,
|
||||
row * display->char_height);
|
||||
|
||||
@ -771,7 +777,7 @@ void __guac_terminal_display_flush_clear(guac_terminal_display* display) {
|
||||
|
||||
/* Send rect */
|
||||
guac_common_surface_rect(
|
||||
display->default_surface,
|
||||
display->display_surface,
|
||||
col * display->char_width,
|
||||
row * display->char_height,
|
||||
rect_width * display->char_width,
|
||||
@ -835,7 +841,7 @@ void guac_terminal_display_flush(guac_terminal_display* display) {
|
||||
__guac_terminal_display_flush_set(display);
|
||||
|
||||
/* Flush surface */
|
||||
guac_common_surface_flush(display->default_surface);
|
||||
guac_common_surface_flush(display->display_surface);
|
||||
|
||||
}
|
||||
|
||||
|
@ -150,12 +150,17 @@ typedef struct guac_terminal_display {
|
||||
int glyph_background;
|
||||
|
||||
/**
|
||||
* The display.
|
||||
* The surface containing the actual terminal.
|
||||
*/
|
||||
guac_common_surface* default_surface;
|
||||
guac_common_surface* display_surface;
|
||||
|
||||
/**
|
||||
* Layer above default layer which highlights selected text.
|
||||
* Layer which contains the actual terminal.
|
||||
*/
|
||||
guac_layer* display_layer;
|
||||
|
||||
/**
|
||||
* Sub-layer of display layer which highlights selected text.
|
||||
*/
|
||||
guac_layer* select_layer;
|
||||
|
||||
|
@ -245,6 +245,8 @@ guac_terminal* guac_terminal_create(guac_client* client,
|
||||
pthread_mutex_init(&(term->lock), NULL);
|
||||
|
||||
/* Size display */
|
||||
guac_protocol_send_size(term->display->client->socket,
|
||||
GUAC_DEFAULT_LAYER, width, height);
|
||||
guac_terminal_display_resize(term->display,
|
||||
term->term_width, term->term_height);
|
||||
|
||||
@ -1117,14 +1119,21 @@ static void __guac_terminal_resize(guac_terminal* term, int width, int height) {
|
||||
|
||||
int guac_terminal_resize(guac_terminal* terminal, int width, int height) {
|
||||
|
||||
/* Calculate dimensions */
|
||||
int rows = height / terminal->display->char_height;
|
||||
int columns = width / terminal->display->char_width;
|
||||
guac_terminal_display* display = terminal->display;
|
||||
guac_client* client = display->client;
|
||||
guac_socket* socket = client->socket;
|
||||
|
||||
/* If size has changed */
|
||||
/* Calculate dimensions */
|
||||
int rows = height / display->char_height;
|
||||
int columns = width / display->char_width;
|
||||
|
||||
/* Resize default layer to given pixel dimensions */
|
||||
guac_protocol_send_size(socket, GUAC_DEFAULT_LAYER, width, height);
|
||||
|
||||
/* Resize terminal if row/column dimensions have changed */
|
||||
if (columns != terminal->term_width || rows != terminal->term_height) {
|
||||
|
||||
guac_client_log(terminal->client, GUAC_LOG_DEBUG,
|
||||
guac_client_log(client, GUAC_LOG_DEBUG,
|
||||
"Resizing terminal to %ix%i", rows, columns);
|
||||
|
||||
/* Resize terminal */
|
||||
@ -1136,6 +1145,12 @@ int guac_terminal_resize(guac_terminal* terminal, int width, int height) {
|
||||
guac_terminal_flush(terminal);
|
||||
}
|
||||
|
||||
/* If terminal size hasn't changed, still need to flush */
|
||||
else {
|
||||
guac_protocol_send_sync(socket, client->last_sent_timestamp);
|
||||
guac_socket_flush(socket);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user