added an optional fix (fix_mouse_coord) that uses an alternative method for getting mouse coordinates in KeyPress/KeyRelease events. This should hopefully work around some remote desktop connection softwares that report wrong mouse coordinates (may be absolute vs relative to window?)

This commit is contained in:
stefan schippers 2023-10-28 11:19:23 +02:00
parent 8ac4c6030d
commit a2ed8fefb6
6 changed files with 55 additions and 2 deletions

View File

@ -1058,6 +1058,19 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
int draw_xhair = tclgetboolvar("draw_crosshair");
int rstate; /* (reduced state, without ShiftMask) */
/* this fix uses an alternative method for getting mouse coordinates on KeyPress/KeyRelease
* events. Some remote connection softwares do not generate the correct coordinates
* on such events */
if(fix_mouse_coord) {
if(event == KeyPress || event == KeyRelease) {
tclvareval("getmousex ", winpath, NULL);
mx = atoi(tclresult());
tclvareval("getmousey ", winpath, NULL);
my = atoi(tclresult());
dbg(1, "mx = %d my=%d\n", mx, my);
}
}
#ifndef __unix__
if(cstate & 0x0001) { /* caps lock */
tclvareval(xctx->top_path, ".statusbar.8 configure -state active -text {CAPS LOCK SET! }", NULL);
@ -2129,7 +2142,7 @@ int rstate; /* (reduced state, without ShiftMask) */
draw();
break;
}
if( 0 && (key=='u') && rstate==ControlMask) /* testmode */
if( (key=='u') && rstate==ControlMask) /* testmode */
{
static int x = 0;

View File

@ -143,6 +143,11 @@ int fix_broken_tiled_fill = 1;
int fix_broken_tiled_fill = 0;
#endif
/* this fix uses an alternative method for getting mouse coordinates on KeyPress/KeyRelease
* events. Some remote connection softwares do not generate the correct coordinates
* on such events */
int fix_mouse_coord = 0;
/* ---------------------------------------------- */
/* These variables are mirrored in tcl code */
/* ---------------------------------------------- */

View File

@ -2507,6 +2507,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
if(tclgetboolvar("change_lw")) l_width = -1.0;
cadlayers=tclgetintvar("cadlayers");
fix_broken_tiled_fill = tclgetboolvar("fix_broken_tiled_fill");
fix_mouse_coord = tclgetboolvar("fix_mouse_coord");
if(debug_var==-10) debug_var=0;
my_snprintf(tmp, S(tmp), "%.16g",CADGRID);
tclvareval("set_ne cadgrid ", tmp, NULL);

View File

@ -1124,7 +1124,6 @@ extern unsigned char **pixdata;
extern unsigned char pixdata_init[22][32];
extern Display *display;
extern int _unix; /* set to 1 on unix systems */
extern int fix_broken_tiled_fill; /* if set to 1 work around some GPUs with rotten tiled fill operations */
#ifdef HAS_XCB
extern xcb_connection_t *xcb_conn;
@ -1145,6 +1144,11 @@ extern int constrained_move;
extern double cairo_font_scale; /* default: 1.0, allows to adjust font size */
extern double cairo_font_line_spacing;
extern int debug_var;
extern int fix_broken_tiled_fill; /* if set to 1 work around some GPUs with rotten tiled fill operations */
/* this fix uses an alternative method for getting mouse coordinates on KeyPress/KeyRelease
* events. Some remote connection softwares do not generate the correct coordinates
* on such events */
extern int fix_mouse_coord;
/*********** These variables are NOT mirrored in tcl code ***********/
extern int help;

View File

@ -6288,6 +6288,21 @@ proc clear_simulate_button {button_path simvar} {
unset $simvar
}
# these two routines are workarounds for broken remote desktop connection tools
# that do not correctly return mouse coordinates (%x, %y) on KeyPress events
proc getmousex {win} {
set x [winfo pointerx $win] ;# absolute mouse position in root window
set originx [winfo rootx $win] ;# absolute position of left window corner in root window
set relx [expr {$x - $originx}] ;# mouse position relative to window origin
return $relx
}
proc getmousey {win} {
set y [winfo pointery $win] ;# absolute mouse position in root window
set originy [winfo rooty $win] ;# absolute position of top window corner in root window
set rely [expr {$y - $originy}] ;# mouse position relative to window origin
return $rely
}
proc set_bindings {topwin} {
global env has_x OS autofocus_mainwindow
###
@ -7468,6 +7483,11 @@ set_ne enable_dim_bg 0
set_ne dim_bg 0.0
set_ne dim_value 0.0
set_ne fix_broken_tiled_fill 0 ;# set to 1 on some broken X11 drivers / GPUs that show garbage on screen */
# this fix uses an alternative method for getting mouse coordinates on KeyPress/KeyRelease
# events. Some remote connection softwares do not generate the correct coordinates
# on such events */
set_ne fix_mouse_coord 0
##### set colors
if {!$rainbow_colors} {
set_ne cadlayers 22

View File

@ -479,3 +479,13 @@
#### if you see garbage on screen / graphic artifacts while editing with
#### xschem try to set this to 1. Default: not enabled (0)
# set fix_broken_tiled_fill 0
###########################################################################
#### FIX SOME REMOTE DESKTOP CONNECTION SOFTWARES NOT CORRECTLY REPORTING
#### MOUSE COORDINATES ON KEYPRESS / KEYRELEASE EVENTS
###########################################################################
#### If you see strange behavior while using keybindings to create graphic
#### objects ('w', 'l', 't', 'r', ...) try to set this to 1.
#### Default: not enabled (0)
# set fix_mouse_coord 0