mawww commented on a change in pull request #237: GUACAMOLE-871: Add support 
for hidden cursor (DECTECM)
URL: https://github.com/apache/guacamole-server/pull/237#discussion_r334727723
 
 

 ##########
 File path: src/terminal/terminal.c
 ##########
 @@ -1240,7 +1253,8 @@ static void __guac_terminal_resize(guac_terminal* term, 
int width, int height) {
             /* Update buffer top and cursor row based on shift */
             term->buffer->top += shift_amount;
             term->cursor_row  -= shift_amount;
-            term->visible_cursor_row  -= shift_amount;
+            if (term->visible_cursor_row != -1)
 
 Review comment:
   While most of the time `cursor_visible == false` is equivalent to 
`visible_cursor_... == -1`, it is not always the case. In particular when we 
just switched visibility back, we can have `cursor_visible = true` and 
`visible_cursor_...` still at -1. In that case this condition would change 
`visibile_curor_row` from `-1` to `-1 - shift_amount` which would be 
semantically incorrect.
   
   Similarly, on line 788 if we used `cursor_visible` we could trigger a buffer 
underflow by trying to access row/column -1.
   
   Documenting those properties makes sense.
   
   An alternative would be to introduce an additional `bool 
visible_cursor_visible` that would track the effective visibility of the cursor 
(while `cursor_visible` tracks the requested visibility), the proposed naming 
here is consistent with `visible_cursor_...` tracking the effective state of 
`cursor_...`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to