aleitner commented on code in PR #385:
URL: https://github.com/apache/guacamole-server/pull/385#discussion_r919562698
##########
src/terminal/terminal.c:
##########
@@ -500,26 +528,33 @@ guac_terminal* guac_terminal_create(guac_client* client,
term->clipboard = guac_common_clipboard_alloc();
term->disable_copy = options->disable_copy;
- /* Calculate available text display area by character size */
- int rows, columns;
- calculate_rows_and_columns(term, height, width, &rows, &columns);
+ /* Set size of available screen area */
+ term->outer_width = width;
+ term->outer_height = height;
- /* Calculate available text display area in pixels */
+ /* Calculate available display area of text in pixels */
int available_height, available_width;
- calculate_height_and_width(term, rows, columns,
- &available_height, &available_width);
+ calculate_available_height_and_width(term,
+ height, width, &available_height, &available_width);
- /* Set size of available screen area */
- term->outer_height = height;
- term->outer_width = width;
+ /* Calculate available display area of text by character size */
+ int rows, columns;
+ calculate_rows_and_columns(term, available_height, available_width,
+ &rows, &columns);
- /* Set rows and columns size */
- term->term_height = rows;
- term->term_width = columns;
+ /* Calculate height & width within predefined maximum of rows and columns
*/
+ int adjusted_height = height;
+ int adjusted_width = width;
+ calculate_adjusted_height_and_width(term, rows, columns,
+ &adjusted_height, &adjusted_width);
/* Set pixel size */
- term->height = available_height;
- term->width = available_width;
+ term->width = adjusted_width;
+ term->height = adjusted_height;
Review Comment:
`outer_height` - The outer height of the terminal, in pixels.
`outer_width` - The outer width of the terminal, in pixels.
There are 3 groups of heights and widths that need to be calculated using
the `outer_height` and `outer_width` which are defined below:
`available_height` - The height of the display area available to display
text, in pixels.
`available_width` - The width of the display area available to display text,
in pixels.
`rows` - The height of the display area available to display text, in
characters.
`columns` - The width of the display area available to display text, in
characters.
`adjusted_height` - The total height of the display area available, in
pixels. This is adjusted if `rows` exceeds `GUAC_TERMINAL_MAX_ROWS`
`adjusted_width` - The total width of the display area available, in pixels.
This is adjusted if `columns` exceeds `GUAC_TERMINAL_MAX_COLUMNS`
We need `outer_height` and `outer_width` to calculate `available_height` and
`available_width`.
We need `available_height` and `available_width` to calculate rows and
columns.
We need rows and columns to calculate `adjusted_height` and `adjusted_width`.
I felt as if separating into the 3 distinct operations was cleaner than
combing into a large function and returning the 4 values. (`rows`, `columns`,
`adjusted_height`, and `adjusted_width`). However, if you are more aligned with
a single function I am happy to put it all together
```
static void calculate_dimensions(int outer_height, int outer_width,
int *rows, int *columns, int *adjusted_height, int *adjusted_width
);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]