# --- ROCK-COPYRIGHT-NOTE-BEGIN --- # # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # Please add additional copyright information _after_ the line containing # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by # the ./scripts/Create-CopyPatch script. Do not edit this copyright text! # # ROCK Linux: rock-src/package/jimmy/zgv/mousexy-fix.patch # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at https://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # --- ROCK-COPYRIGHT-NOTE-END --- --- ./src/readnbkey.c.orig 2003-04-05 16:40:39.000000000 +0300 +++ ./src/readnbkey.c 2003-08-10 12:27:23.000000000 +0300 @@ -62,7 +62,7 @@ /* saved mx/my in in range 0..MPOS_SAVE_MAX. */ -#define MPOS_SAVE_MAX 16383 +#define MPOS_SAVE_MAX 16383.0 static int old_click_status=0,new_click_status=0; @@ -276,7 +276,8 @@ } -static int saved_mx=0,saved_my=0; +/* All save/restore calculations are done in float to avoid int truncating. */ +static float saved_mx=0.0,saved_my=0.0; /* save mouse pointer's current position. used when switching over * to the panning-follows-mouse model used by vgadisp.c, so that on @@ -288,7 +289,7 @@ */ void save_mouse_pos() { -int mx,my; +float mx,my; if(!has_mouse) return; @@ -297,13 +298,13 @@ */ if(vga_getcurrentmode()==TEXT) { - mx=MPOS_SAVE_MAX/2; - my=MPOS_SAVE_MAX/2; + mx=MPOS_SAVE_MAX/2.0; + my=MPOS_SAVE_MAX/2.0; } else { - mx=(mouse_getx()*MPOS_SAVE_MAX)/(vga_getxdim()-1); - my=(mouse_gety()*MPOS_SAVE_MAX)/(vga_getydim()-1); + mx=(mouse_getx()*MPOS_SAVE_MAX)/(vga_getxdim()-1.0); + my=(mouse_gety()*MPOS_SAVE_MAX)/(vga_getydim()-1.0); } /* just in case */ if(mx>MPOS_SAVE_MAX) mx=MPOS_SAVE_MAX; @@ -323,12 +324,13 @@ /* restore saved pos assuming given size screen */ void restore_mouse_pos_with_size(int width,int height) { -int mx,my; +extern float roundf(float x); /* may be missing from math.h, must be declared */ +float mx,my; if(!has_mouse) return; -mx=(saved_mx*(width-1))/MPOS_SAVE_MAX; -my=(saved_my*(height-1))/MPOS_SAVE_MAX; +mx=roundf((saved_mx*(width-1.0))/MPOS_SAVE_MAX); +my=roundf((saved_my*(height-1.0))/MPOS_SAVE_MAX); /* just in case */ if(mx>width-1) mx=width-1; if(my>height-1) my=height-1;