void guac_terminal_scrollbar_flush(guac_terminal_scrollbar* scrollbar) { guac_socket* socket = scrollbar->client->socket; /* Get old state */ int old_value = scrollbar->value; guac_terminal_scrollbar_render_state* old_state = &scrollbar->render_state; /* Calculate new state */ int new_value; guac_terminal_scrollbar_render_state new_state; calculate_state(scrollbar, &new_state, &new_value); /* Notify of scroll if value is changing */ if (new_value != old_value && scrollbar->scroll_handler) scrollbar->scroll_handler(scrollbar, new_value); /* Reposition container if moved */ if (old_state->container_x != new_state.container_x || old_state->container_y != new_state.container_y) { guac_terminal_scrollbar_move_container(scrollbar, &new_state, socket); } /* Resize and redraw container if size changed */ if (old_state->container_width != new_state.container_width || old_state->container_height != new_state.container_height) { guac_terminal_scrollbar_draw_container(scrollbar, &new_state, socket); } /* Reposition handle if moved */ if (old_state->handle_x != new_state.handle_x || old_state->handle_y != new_state.handle_y) { guac_terminal_scrollbar_move_handle(scrollbar, &new_state, socket); } /* Resize and redraw handle if size changed */ if (old_state->handle_width != new_state.handle_width || old_state->handle_height != new_state.handle_height) { guac_terminal_scrollbar_draw_handle(scrollbar, &new_state, socket); } /* Store current render state */ scrollbar->render_state = new_state; }
void guac_terminal_scrollbar_flush(guac_terminal_scrollbar* scrollbar) { guac_socket* socket = scrollbar->client->socket; /* Get old state */ int old_value = scrollbar->value; guac_terminal_scrollbar_render_state* old_state = &scrollbar->render_state; /* Calculate new state */ int new_value; guac_terminal_scrollbar_render_state new_state; calculate_state(scrollbar, &new_state, &new_value); /* Notify of scroll if value is changing */ if (new_value != old_value && scrollbar->scroll_handler) scrollbar->scroll_handler(scrollbar, new_value); /* Reposition container if moved */ if (old_state->container_x != new_state.container_x || old_state->container_y != new_state.container_y) { guac_protocol_send_move(socket, scrollbar->container, scrollbar->parent, new_state.container_x, new_state.container_y, 0); } /* Resize and redraw container if size changed */ if (old_state->container_width != new_state.container_width || old_state->container_height != new_state.container_height) { /* Set new size */ guac_protocol_send_size(socket, scrollbar->container, new_state.container_width, new_state.container_height); /* Fill container with solid color */ guac_protocol_send_rect(socket, scrollbar->container, 0, 0, new_state.container_width, new_state.container_height); guac_protocol_send_cfill(socket, GUAC_COMP_SRC, scrollbar->container, 0x40, 0x40, 0x40, 0xFF); } /* Reposition handle if moved */ if (old_state->handle_x != new_state.handle_x || old_state->handle_y != new_state.handle_y) { guac_protocol_send_move(socket, scrollbar->handle, scrollbar->container, new_state.handle_x, new_state.handle_y, 0); } /* Resize and redraw handle if size changed */ if (old_state->handle_width != new_state.handle_width || old_state->handle_height != new_state.handle_height) { /* Send new size */ guac_protocol_send_size(socket, scrollbar->handle, new_state.handle_width, new_state.handle_height); /* Fill and stroke handle with solid color */ guac_protocol_send_rect(socket, scrollbar->handle, 0, 0, new_state.handle_width, new_state.handle_height); guac_protocol_send_cfill(socket, GUAC_COMP_SRC, scrollbar->handle, 0x80, 0x80, 0x80, 0xFF); guac_protocol_send_cstroke(socket, GUAC_COMP_OVER, scrollbar->handle, GUAC_LINE_CAP_SQUARE, GUAC_LINE_JOIN_MITER, 2, 0xA0, 0xA0, 0xA0, 0xFF); } /* Store current render state */ scrollbar->render_state = new_state; }