aleitner commented on code in PR #385:
URL: https://github.com/apache/guacamole-server/pull/385#discussion_r918166144


##########
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 was due to me reverting to the code's state when it was previously 
working properly, and then working from there. I agree that re-duplication is a 
bad thing so I made sure to remove the duplicated code again.



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