-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwe_gpm.c
67 lines (56 loc) · 1.04 KB
/
we_gpm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifdef HAVE_LIBGPM
/* we_gpm.c -- GPM routines for xwpe.
Based on we_linux.c -- Created by Sebastiano Suraci */
#include "edit.h"
#include <gpm.h>
int WpeGpmHandler(Gpm_Event *ep, void *data);
int WpeGpmMouseInit(void)
{
Gpm_Connect c;
int ret;
Gpm_GetServerVersion(NULL);
gpm_zerobased = 1;
c.eventMask = ~0;
c.defaultMask = ~GPM_HARD;
c.minMod = 0;
c.maxMod = ~0;
ret = Gpm_Open(&c, 0);
if (ret == -2)
{
/* Xterms returns mouse information through stdin which xwpe currently
doesn't support */
Gpm_Close();
return(-1);
}
if (ret == -1)
{
return(-1);
}
gpm_handler = WpeGpmHandler;
return(0);
}
int WpeGpmHandler(Gpm_Event *ep, void *data)
{
extern struct mouse e_mouse;
GPM_DRAWPOINTER(ep);
if (ep->buttons & 7)
{
e_mouse.x = ep->x;
e_mouse.y = ep->y;
e_mouse.k = ep->buttons;
return(-(ep->buttons ^ 5));
}
e_mouse.k = 0;
return(0);
}
int WpeGpmMouse(int *g)
{
Gpm_Event e;
while (Gpm_GetSnapshot(&e) == 0)
Gpm_GetEvent(&e);
g[1] = g[0] = e.buttons;
g[2] = e.x * 8;
g[3] = e.y * 8;
return(1);
}
#endif