comparison src/gpmevent.c @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents e45d5e7c476e
children 74fd4e045ea6
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
1 /* William Perry 1997 */ 1 /* William Perry 1997 */
2 2
3 #include <config.h> 3 #include <config.h>
4 #include "lisp.h" 4 #include "lisp.h"
5 #include "console.h"
5 #include "console-tty.h" 6 #include "console-tty.h"
6 #include "device.h" 7 #include "device.h"
7 #include "events.h" 8 #include "events.h"
8 #include "events-mod.h" 9 #include "events-mod.h"
9 #include "process.h"
10 #include "sysdep.h" 10 #include "sysdep.h"
11 #include "sysproc.h" /* select stuff */
12 #include "systime.h"
13 11
14 #ifdef HAVE_GPM 12 #ifdef HAVE_GPM
15 #include "gpmevent.h" 13 #include "gpmevent.h"
16 #include <gpm.h> 14 #include <gpm.h>
17 15
18 #if (!defined(__linux__)) /* possible under xterm */ 16 #if (!defined(__linux__)) /* possible under xterm */
19 #define KG_SHIFT 0 17 #define KG_SHIFT 0
20 #define KG_CTRL 2 18 #define KG_CTRL 2
21 #define KG_ALT 3 19 #define KG_ALT 3
22 #else 20 #else
23 #include <linux/keyboard.h> 21 #include <linux/keyboard.h>
24 #endif 22 #endif
25 23
26 int handle_gpm_read(struct Lisp_Event *event, struct console *con, int fd) 24 int
25 handle_gpm_read (struct Lisp_Event *event, struct console *con, int fd)
27 { 26 {
28 Gpm_Event ev; 27 Gpm_Event ev;
29 int modifiers,type,button; 28 int modifiers = 0;
30 29 int type = -1;
31 type = -1; 30 int button = 1;
32 button = 1;
33 31
34 if (!Gpm_GetEvent(&ev)) 32 if (!Gpm_GetEvent(&ev))
35 return(0); 33 return 0;
36 34
37 event->timestamp = 0; 35 event->timestamp = 0;
38 event->channel = CONSOLE_SELECTED_FRAME (con); 36 event->channel = CONSOLE_SELECTED_FRAME (con);
39 37
40 /* Whow, wouldn't named defines be NICE!?!?! */ 38 /* Whow, wouldn't named defines be NICE!?!?! */
41 modifiers = 0; 39 modifiers = 0;
42 40
43 if (ev.modifiers & 1) modifiers |= MOD_SHIFT; 41 if (ev.modifiers & 1) modifiers |= MOD_SHIFT;
44 if (ev.modifiers & 2) modifiers |= MOD_META; 42 if (ev.modifiers & 2) modifiers |= MOD_META;
62 button = 3; 60 button = 3;
63 61
64 switch (type) { 62 switch (type) {
65 case GPM_DOWN: 63 case GPM_DOWN:
66 case GPM_UP: 64 case GPM_UP:
67 if (type == GPM_DOWN) 65 event->event_type =
68 event->event_type = button_press_event; 66 type == GPM_DOWN ? button_press_event : button_release_event;
69 else event->event_type = button_release_event;
70 event->event.button.x = ev.x; 67 event->event.button.x = ev.x;
71 event->event.button.y = ev.y; 68 event->event.button.y = ev.y;
72 event->event.button.button = button; 69 event->event.button.button = button;
73 event->event.button.modifiers = modifiers; 70 event->event.button.modifiers = modifiers;
74 break; 71 break;
76 event->event_type = pointer_motion_event; 73 event->event_type = pointer_motion_event;
77 event->event.motion.x = ev.x; 74 event->event.motion.x = ev.x;
78 event->event.motion.y = ev.y; 75 event->event.motion.y = ev.y;
79 event->event.motion.modifiers = modifiers; 76 event->event.motion.modifiers = modifiers;
80 default: 77 default:
81 return (0); 78 return 0;
82 } 79 }
83 return (1); 80 return 1;
84 } 81 }
85 82
86 void connect_to_gpm(struct console *con) 83 void
84 connect_to_gpm (struct console *con)
87 { 85 {
88 /* Only do this if we are running after dumping and really interactive */ 86 /* Only do this if we are running after dumping and really interactive */
89 if (!noninteractive && initialized) { 87 if (!noninteractive && initialized) {
90 /* We really only want to do this on a TTY */ 88 /* We really only want to do this on a TTY */
91 CONSOLE_TTY_MOUSE_FD (con) = -1; 89 CONSOLE_TTY_MOUSE_FD (con) = -1;