📄 imwheel_new.patch
字号:
diff -r -u gpm-1.19.3.original/doc/doc.gpm gpm-1.19.3/doc/doc.gpm--- gpm-1.19.3.original/doc/doc.gpm Tue Jul 18 22:43:18 2000+++ gpm-1.19.3/doc/doc.gpm Mon Sep 25 07:51:52 2000@@ -911,8 +911,26 @@ of them is active at a time, to allow using @code{switch} on the value. Vertical outrun takes precedence on horizontal outrun. @xref{Margins}.++@item short w; /* Extended element */+ Wheel position. It is not checked on an overflow, and therefore+ using dw is prefered. Another way of wheel processing is provided+ by FWHEEL and BWHEEL event types. These events types must be disabled,+ if wheel position is processed in an application.++@item short dw; /* Extended element */+ Wheel displacement after last event reading.++@item char pad[40]; /* Extended element */+ Reserved for future use.+ @end table +Extended elements are available for an event handler, Gpm_GetEventExt+and Gpm_GetSnapshotExt, while after Gpm_GetEvent or Gpm_GetSnapshot+their values are unpredictable. Check if @code{GPM_EVENT_EXT} is+defined before using extended elements in an application.+ %========================================================================== @node Margins, Event Types, Events, Gpm Internals @section How margins are managed@@ -969,6 +987,13 @@ @item GPM_LEAVE This is only delivered by the high level library, too. Events of type @code{GPM_LEAVE} have all other fields undefined.+@item GPM_FWHEEL+ Wheel turned 1 notch forward (toward the user). Turning a wheel more+ than one notch will produce additional GPM_FWHEEL events. This is an+ extended type - you need to put '#ifdef GPM_FWHEEL' before + using the type in your code. +@item GPM_BWHEEL+ Same as GPM_FWHEEL but for turning the wheel back. @end table Cooked events are the following:@@ -1022,10 +1047,15 @@ @table @code @item eventMask- A bitmask of the events the client wants- to receive. Both bare and cooked events are- allowed to appear in the mask.-+ A bitmask of the events the client wants to receive.+ Both bare and cooked events are allowed to appear in the mask.+ In particular, GPM_FWHEEL and GPM_BWHEEL can be disabled by+ omitting the masks:++ Gpm_Connect conn;+ /* Enable all events, except GPM_FWHEEL and GPM_BWHEEL+ conn.eventMask = ~(GPM_FWHEEL | GPM_BWHEEL);+ @item defaultMask A mask to tell which events allow a default treatment (the selection one). These are mouse events,@@ -1366,8 +1396,28 @@ failure, and 0 after closing the connection. Failure can happen if a signal interrupted the read system call. This function doesn't work with xterm mouse reporting and is meant for internal use by the library.++This function does not return the extended part. @end deftypefun +@deftypefun int Gpm_GetEventExt (Gpm_Event *@var{event});+As Gpm_GetEvent, but returns extended part. For backward compatibility+the application should check @code{GPM_EVENT_EXT}, as given by the following+example: +@table @code+ int dw, w, result;+ Gpm_Event mevnt;++#ifdef GPM_EVENT_EXT+ result = Gpm_GetEventExt(&mevnt); + w = mevnt.w; dw = nevnt.dw;+#else+ result = Gpm_GetEvent(&mevnt); + w = dw = 0;+#endif+@end table+@end deftypefun+ %......................................................................... @deftypefun int Gpm_CharsQueued (void); @@ -1512,8 +1562,14 @@ events, and applications usually don't want to lose events, the function returns 0 if the input queue is not empty. +The functions does not return the extended part. @end deftypefun +@deftypefun int Gpm_GetSnapshotExt (Gpm_Event *@var{event});+As Gpm_GetSnapshot, but returns extended part. For backward compatibility+the application should check whether @code{GPM_EVENT_EXT} has been defined.++@end deftypefun %-------------------------------------------------------------------------- @node High Level Lib, Xterm, Low Level Library, The ClientLibdiff -r -u gpm-1.19.3.original/gpm.c gpm-1.19.3/gpm.c--- gpm-1.19.3.original/gpm.c Tue Jul 18 22:06:06 2000+++ gpm-1.19.3/gpm.c Mon Sep 25 07:02:20 2000@@ -4,6 +4,8 @@ * Copyright (C) 1993 Andreq Haylett <ajh@gec-mrc.co.uk> * Copyright (C) 1994-1999 Alessandro Rubini <rubini@linux.it> * Copyright (C) 1998 Ian Zimmerman <itz@rahul.net>+ * imps2 wheel support: Michael Glickman <xsadp@yahoo.com> 2000/09/24+ * Influenced by Jonathan Atkin's patch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by@@ -61,6 +63,7 @@ DEF_TYPE, DEF_DEV, DEF_SEQUENCE, DEF_BAUD, DEF_SAMPLE, DEF_DELTA, DEF_ACCEL, DEF_SCALE, 0 /* scaley */, DEF_TIME, DEF_CLUSTER, DEF_THREE, DEF_GLIDEPOINT_TAP,+ DEF_SIMWHEEL, (char *)NULL /* extra */, (Gpm_Type *)NULL },@@ -384,7 +387,7 @@ } -static int statusX,statusY,statusB; /* to return info */+static int statusX,statusY,statusW,statusB; /* to return info */ static int statusC=0; /* clicks */ void get_console_size(Gpm_Event *ePtr); @@ -401,6 +404,7 @@ static struct timeval timeout={0,0}; fd_set fdSet; static int newB=0, oldB=0, oldT=0; /* old buttons and Type to chain events */+ static Gpm_Cinfo *ci; /* static int buttonlock, buttonlockflag; */ #define GET_TIME(tv) (gettimeofday(&tv, (struct timezone *)NULL))@@ -409,6 +413,7 @@ oldT=event->type;+ memset (event->pad, '\0', GPM_EVENT_PAD_SIZE * sizeof(int)); if (eventFlag) {@@ -425,13 +430,14 @@ } else {- event->dx=event->dy=0;+ event->dx=event->dy=event->dw=0; nEvent.modifiers = 0; /* some mice set them */ FD_ZERO(&fdSet); FD_SET(fd,&fdSet); i=0; do /* cluster loop */ {+ nEvent.dx=nEvent.dy=nEvent.dw=0; if ( ((data=getMouseData(fd,m_type,kd_mode))==NULL) || ((*(m_type->fun))(&nEvent,data)==-1) ) {@@ -439,6 +445,12 @@ else break; } + if (which_mouse->opt_simwheel && (nEvent.buttons & GPM_B_MIDDLE) && nEvent.dy) {+ nEvent.buttons &= !GPM_B_MIDDLE;+ nEvent.dw = nEvent.dy;+ nEvent.dy = 0;+ }+ event->modifiers = nEvent.modifiers; /* propagate modifiers */ /* propagate buttons */@@ -461,6 +473,7 @@ /* increment the reported dx,dy */ event->dx+=nEvent.dx; event->dy+=nEvent.dy;+ event->dw+=nEvent.dw; } else /* a pen */ {@@ -490,7 +503,7 @@ static struct timeval rept1,rept2; gettimeofday(&rept2, (struct timezone *)NULL); if (((rept2.tv_sec -rept1.tv_sec) *1000+(rept2.tv_usec-rept1.tv_usec)/1000)>250) - { event->dx=0; event->dy=0; }+ { event->dx=0; event->dy=0; event->dw=0; } rept1=rept2; event->dy=event->dy*((win.ws_col/win.ws_row)+1);@@ -512,7 +525,7 @@ fine_dx %= opt_scale; fine_dy %= opt_scaley; } - if (!event->dx && !event->dy && (event->buttons==oldB))+ if (!event->dx && !event->dy && !event->dw && (event->buttons==oldB)) do { /* so to break */ static long awaketime;@@ -528,7 +541,7 @@ /*....................................... fill missing fields */ - event->x+=event->dx, event->y+=event->dy;+ event->x+=event->dx; event->y+=event->dy; event->w+=event->dw; statusB=event->buttons; i=open_console(O_RDONLY);@@ -559,6 +572,21 @@ else event->type = (event->buttons > oldB ? GPM_DOWN : GPM_UP); + ci = cinfo[stat.v_active];+ if (ci != NULL)+ {+ i = (ci->data).eventMask;+ if (event->w > 0 && (i & GPM_FWHEEL))+ {+ event->type |= GPM_FWHEEL; (event->w)--;+ }+ else+ if (event->w < 0 && (i & GPM_BWHEEL))+ {+ event->type |= GPM_BWHEEL; (event->w)++;+ }+ } + switch(event->type) /* now provide the cooked bits */ { case GPM_DOWN:@@ -583,6 +611,7 @@ case GPM_MOVE: statusC=0;+ default: break; }@@ -619,7 +648,7 @@ event->clicks); /* update the global state */- statusX=event->x; statusY=event->y;+ statusX=event->x; statusY=event->y; statusW=event->w; if (opt_special && event->type & GPM_DOWN) return processSpecial(event);@@ -733,8 +762,8 @@ oops("get_shift_state"); close(i); event.vc = stat.v_active;- event.x=statusX; event.y=statusY;- event.dx=maxx; event.dy=maxy;+ event.x=statusX; event.y=statusY; event.w=statusW;+ event.dx=maxx; event.dy=maxy; event.buttons= statusB; event.clicks=statusC; /* fall through */@@ -869,7 +898,7 @@ /* if the client gets motions, give it the current position */ if(request->eventMask & GPM_MOVE) {- Gpm_Event event={0,0,vc,0,0,statusX,statusY,GPM_MOVE,0,0};+ Gpm_Event event={0,0,vc,0,0,statusX,statusY,GPM_MOVE,0,0,0,statusW}; do_client(info, &event); } @@ -899,6 +928,7 @@ if (!prevmaxx) { /* first invocation, place the pointer in the middle */ statusX = ePtr->x = maxx/2; statusY = ePtr->y = maxy/2;+ statusW = ePtr->w = 0; } else { /* keep the pointer in the same position where it was */ statusX = ePtr->x = ePtr->x * maxx / prevmaxx; statusY = ePtr->y = ePtr->y * maxy / prevmaxy;diff -r -u gpm-1.19.3.original/gpm.h gpm-1.19.3/gpm.h--- gpm-1.19.3.original/gpm.h Fri Jan 28 09:09:00 2000+++ gpm-1.19.3/gpm.h Mon Sep 25 07:02:29 2000@@ -3,6 +3,8 @@ * * Copyright 1994,1995 rubini@linux.it (Alessandro Rubini) * Copyright (C) 1998 Ian Zimmerman <itz@rahul.net>+ * imps2 wheel support: Michael Glickman <xsadp@yahoo.com> 2000/09/24+ * Influenced by Jonathan Atkin's patch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by@@ -84,8 +86,6 @@ GPM_DOWN=4, GPM_UP= 8, -#define GPM_BARE_EVENTS(type) ((type)&(0x0f|GPM_ENTER|GPM_LEAVE))- GPM_SINGLE=16, /* at most one in three is set */ GPM_DOUBLE=32, GPM_TRIPLE=64, /* WARNING: I depend on the values */@@ -98,6 +98,11 @@ GPM_LEAVE=1024 /* leave event, used in Roi's */ }; +#define GPM_FWHEEL 4096 /* wheel move forward - M.G. 2000/09/24 */+#define GPM_BWHEEL 8192 /* wheel move backward - M.G. 2000/09/24 */++#define GPM_BARE_EVENTS(type) ((type)&(0x0f|GPM_ENTER|GPM_LEAVE|GPM_FWHEEL|GPM_BWHEEL))+ #define Gpm_StrictSingle(type) (((type)&GPM_SINGLE) && !((type)&GPM_MFLAG)) #define Gpm_AnySingle(type) ((type)&GPM_SINGLE) #define Gpm_StrictDouble(type) (((type)&GPM_DOUBLE) && !((type)&GPM_MFLAG))@@ -111,6 +116,19 @@ /*....................................... The reported event */ +#define GPM_EVENT_EXT++typedef struct Gpm_EventOld {+ unsigned char buttons, modifiers; /* try to be a multiple of 4 */+ unsigned short vc;+ short dx, dy, x, y;+ enum Gpm_Etype type;+ int clicks;+ enum Gpm_Margin margin;+} Gpm_EventOld;++#define GPM_EVENT_PAD_SIZE 20 /* Should be enough for now */+ typedef struct Gpm_Event { unsigned char buttons, modifiers; /* try to be a multiple of 4 */ unsigned short vc;@@ -118,6 +136,8 @@ enum Gpm_Etype type; int clicks; enum Gpm_Margin margin;+ short dw, w; /* M.G. 2000/09/24 */ + int pad[GPM_EVENT_PAD_SIZE]; /* M.G. 2000/09/24 */ } Gpm_Event; /*....................................... The handling function */@@ -181,6 +201,7 @@ extern int Gpm_Open(Gpm_Connect *, int); extern int Gpm_Close(void); extern int Gpm_GetEvent(Gpm_Event *);+extern int Gpm_GetEventExt(Gpm_Event *); extern int Gpm_CharsQueued(void); extern int Gpm_Getc(FILE *); #define Gpm_Getchar() Gpm_Getc(stdin)@@ -246,6 +267,7 @@ char *Gpm_GetLibVersion(int *where); char *Gpm_GetServerVersion(int *where); int Gpm_GetSnapshot(Gpm_Event *ePtr);+int Gpm_GetSnapshotExt(Gpm_Event *ePtr); #ifdef __cplusplus };diff -r -u gpm-1.19.3.original/gpmCfg.h gpm-1.19.3/gpmCfg.h--- gpm-1.19.3.original/gpmCfg.h Tue Jan 18 09:23:00 2000+++ gpm-1.19.3/gpmCfg.h Thu Sep 21 20:42:12 2000@@ -62,5 +62,7 @@ #define DEF_TEST 0 #define DEF_PTRDRAG 1 /* double or triple click */ #define DEF_GLIDEPOINT_TAP 0 /* tapping emulates no buttons by default */+#define DEF_SIMWHEEL 0 /* simulate wheel with middle button and */+ /* y-axis movement */ #endif /* _GPMCFG_INCLUDED */diff -r -u gpm-1.19.3.original/gpmInt.h gpm-1.19.3/gpmInt.h--- gpm-1.19.3.original/gpmInt.h Tue Jul 18 22:18:54 2000+++ gpm-1.19.3/gpmInt.h Fri Sep 22 08:00:56 2000@@ -88,6 +88,7 @@ char *opt_type, *opt_dev, *opt_sequence; int opt_baud,opt_sample,opt_delta, opt_accel, opt_scale, opt_scaley; int opt_time, opt_cluster, opt_three, opt_glidepoint_tap;+ int opt_simwheel; char *opt_options; /* extra textual configuration */ Gpm_Type *m_type; int fd;diff -r -u gpm-1.19.3.original/gpn.c gpm-1.19.3/gpn.c--- gpm-1.19.3.original/gpn.c Tue Jul 18 22:06:06 2000+++ gpm-1.19.3/gpn.c Thu Sep 21 20:53:38 2000@@ -177,7 +177,9 @@ " Use a non-existent type (e.g. \"help\") to get a list\n" " -T test: read mouse, no clients\n" " -v print version and exit\n"- " -V verbosity increase number of logged messages\n", + " -V verbosity increase number of logged messages\n"+ " -w simulate wheel operation by pressing middle\n"+ " mouse button and y-axis movement\n", DEF_ACCEL, DEF_BAUD, DEF_SEQUENCE, DEF_DELTA, DEF_TIME, DEF_LUT, DEF_SCALE, DEF_SAMPLE, DEF_TYPE); return 1;@@ -286,7 +288,7 @@ int cmdline(int argc, char **argv) {- char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:TvV::23";+ char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:TvV::w23"; int i, opt; static struct {char *in; char *out;} seq[] = { {"123","01234567"},@@ -359,6 +361,9 @@ case 'v': printf(GPM_NAME " " GPM_RELEASE ", " GPM_DATE "\n"); exit(0); case 'V': gpm_debug_level += (0 == optarg ? 1 : strtol(optarg, 0, 0));+ break;+ case 'w':+ which_mouse->opt_simwheel=1; break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -