Skip to content

Commit

Permalink
GUACAMOLE-1944: Remove display margin on mouse position
Browse files Browse the repository at this point in the history
  • Loading branch information
corentin-soriano committed Apr 16, 2024
1 parent 4622c3f commit 3e3a182
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/terminal/terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,10 @@ int guac_terminal_send_key(guac_terminal* term, int keysym, int pressed) {
static int __guac_terminal_send_mouse(guac_terminal* term, guac_user* user,
int x, int y, int mask) {

/* Remove display margin from mouse position without going below 0 */
y = y >= term->display->margin ? y - term->display->margin : 0;
x = x >= term->display->margin ? x - term->display->margin : 0;

/* Ignore user input if terminal is not started */
if (!term->started) {
guac_client_log(term->client, GUAC_LOG_DEBUG, "Ignoring user input "
Expand Down Expand Up @@ -1801,8 +1805,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->margin) / term->display->char_height - term->scroll_offset;
int col = (x - term->display->margin) / term->display->char_width;
int row = y / term->display->char_height - term->scroll_offset;
int col = x / term->display->char_width;

/* If mouse button was already just pressed, start a new selection or
* resume the existing selection depending on whether shift is held */
Expand Down

0 comments on commit 3e3a182

Please sign in to comment.