corentin-soriano commented on code in PR #509: URL: https://github.com/apache/guacamole-server/pull/509#discussion_r1567404805
########## src/terminal/terminal.c: ########## @@ -1801,8 +1801,8 @@ static int __guac_terminal_send_mouse(guac_terminal* term, guac_user* user, * pressed */ else if (mask & GUAC_CLIENT_MOUSE_LEFT) { - int row = y / term->display->char_height - term->scroll_offset; - int col = x / term->display->char_width; + int row = (y - term->display->margin) / term->display->char_height - term->scroll_offset; + int col = (x - term->display->margin) / term->display->char_width; Review Comment: After checking, I did not encounter the issue during my tests because the margin is smaller than char_height/width. The casting of -0.xxx becomes 0. The anomaly would occur if the result of the division becomes <= to -1. What I can propose is not allowing to go below 0: ``` y = y >= term->display->margin ? y - term->display->margin : 0; x = x >= term->display->margin ? x - term->display->margin : 0; ``` And revert this : ``` int row = y / term->display->char_height - term->scroll_offset; int col = x / term->display->char_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: dev-unsubscr...@guacamole.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org