mike-jumper commented on code in PR #385:
URL: https://github.com/apache/guacamole-server/pull/385#discussion_r917172055


##########
src/terminal/terminal.c:
##########
@@ -1458,22 +1428,38 @@ int guac_terminal_resize(guac_terminal* terminal, int 
width, int height) {
     /* Acquire exclusive access to terminal */
     guac_terminal_lock(terminal);
 
-    /* Calculate available text display area by character size */
-    int rows, columns;
-    calculate_rows_and_columns(terminal, height, width, &rows, &columns);
+   /* Set size of available screen area */

Review Comment:
   Looks like a space was accidentally removed here (indentation is now 
misaligned).



##########
src/terminal/terminal.c:
##########
@@ -1458,22 +1428,38 @@ int guac_terminal_resize(guac_terminal* terminal, int 
width, int height) {
     /* Acquire exclusive access to terminal */
     guac_terminal_lock(terminal);
 
-    /* Calculate available text display area by character size */
-    int rows, columns;
-    calculate_rows_and_columns(terminal, height, width, &rows, &columns);
+   /* Set size of available screen area */
+    terminal->outer_width = width;
+    terminal->outer_height = height;
 
-    /* Calculate available text display area in pixels */
+    /* Calculate available display area */
     int available_height, available_width;
-    calculate_height_and_width(terminal, rows, columns,
-        &available_height, &available_width);
+    calculate_available_height_and_width(terminal, 
+        height, width, &available_height, &available_width);
 
-    /* Set size of available screen area */
-    terminal->outer_height = height;
-    terminal->outer_width = width;
+    /* Calculate dimensions */
+    int rows    = available_height / display->char_height;
+    int columns = available_width / display->char_width;
 
-    /* Set pixel size */
-    terminal->height = available_height;
-    terminal->width = available_width;
+    int margin = terminal->display->margin;
+
+    /* Keep height within predefined maximum */
+    if (rows > GUAC_TERMINAL_MAX_ROWS) {
+        rows = GUAC_TERMINAL_MAX_ROWS;
+        available_height = rows * display->char_height;
+        height = available_height + 2 * margin;
+    }
+
+    /* Keep width within predefined maximum */
+    if (columns > GUAC_TERMINAL_MAX_COLUMNS) {
+        columns = GUAC_TERMINAL_MAX_COLUMNS;
+        available_width = columns * display->char_width;
+        width = available_width + GUAC_TERMINAL_SCROLLBAR_WIDTH + 2 * margin;
+    }

Review Comment:
   This used to be within `calculate_rows_and_columns()`, avoiding duplication 
and ensuring bounds are always enforced. Why did this need to be removed from 
`calculate_rows_and_columns()` and re-duplicated?



-- 
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]

Reply via email to