diff --git a/src/osdep/dos/dos.c b/src/osdep/dos/dos.c index be98a574..74a99271 100644 --- a/src/osdep/dos/dos.c +++ b/src/osdep/dos/dos.c @@ -61,8 +61,6 @@ do { \ #define EINTRLOOP(ret_, call_) EINTRLOOPX(ret_, call_, -1) -#define B_MOVE 96 - #ifdef __ICC /* ICC OpenMP bug */ #define overalloc_condition 0 @@ -260,10 +258,10 @@ static int dos_mouse_last_y; static int dos_mouse_last_button; static uttime dos_mouse_time; -static struct term_event *dos_mouse_queue = DUMMY; +static struct interlink_event *dos_mouse_queue = DUMMY; static int dos_mouse_queue_n; -static void (*txt_mouse_handler)(void *, unsigned char *, int) = NULL; +static void (*txt_mouse_handler)(void *, char *, int) = NULL; static void *txt_mouse_data; static int dos_mouse_coord(int v) @@ -271,7 +269,7 @@ static int dos_mouse_coord(int v) #if 0 if (!F) v /= 8; #endif - return v; + return v / 8; } static void dos_mouse_show(void) @@ -323,7 +321,9 @@ static void dos_mouse_init(unsigned x, unsigned y) void dos_mouse_terminate(void) { - mem_free(dos_mouse_queue); + if (dos_mouse_queue != DUMMY) { + mem_free_if(dos_mouse_queue); + } dos_mouse_queue = DUMMY; dos_mouse_queue_n = 0; dos_mouse_hide(); @@ -335,8 +335,14 @@ static void dos_mouse_enqueue(int x, int y, int b) dos_mouse_queue_n--; goto set_last; } - if ((unsigned)dos_mouse_queue_n > (unsigned)MAXINT / sizeof(struct term_event) - 1) overalloc(); - dos_mouse_queue = mem_realloc(dos_mouse_queue, (dos_mouse_queue_n + 1) * sizeof(struct term_event)); + if ((unsigned)dos_mouse_queue_n > (unsigned)MAXINT / sizeof(struct interlink_event) - 1) { + overalloc(); + } + if (dos_mouse_queue == DUMMY) { + dos_mouse_queue = mem_alloc((dos_mouse_queue_n + 1) * sizeof(struct interlink_event)); + } else { + dos_mouse_queue = mem_realloc(dos_mouse_queue, (dos_mouse_queue_n + 1) * sizeof(struct interlink_event)); + } set_last: dos_mouse_queue[dos_mouse_queue_n].ev = EVENT_MOUSE; dos_mouse_queue[dos_mouse_queue_n].info.mouse.x = x; @@ -421,18 +427,15 @@ x: #endif } -void *handle_mouse(int cons, void (*fn)(void *, unsigned char *, int), void *data) +void *handle_mouse(int cons, void (*fn)(void *, char *, int), void *data) { - return NULL; -#if 0 int x, y; - get_terminal_size(&x, &y); + get_terminal_size(cons, &x, &y); dos_mouse_init(x * 8, y * 8); if (!dos_mouse_initialized) return NULL; dos_mouse_show(); txt_mouse_handler = fn; txt_mouse_data = data; -#endif return DUMMY; } @@ -443,6 +446,16 @@ void unhandle_mouse(void *data) txt_mouse_handler = NULL; } +void +suspend_mouse(void *data) +{ +} + +void +resume_mouse(void *data) +{ +} + void want_draw(void) { dos_mouse_hide(); @@ -457,11 +470,11 @@ static int dos_mouse_event(void) { if (dos_mouse_queue_n) { if (/*!F &&*/ txt_mouse_handler) { - struct term_event *q = dos_mouse_queue; + struct interlink_event *q = dos_mouse_queue; int ql = dos_mouse_queue_n; dos_mouse_queue = DUMMY; dos_mouse_queue_n = 0; - txt_mouse_handler(txt_mouse_data, (unsigned char *)(void *)q, ql * sizeof(struct term_event)); + txt_mouse_handler(txt_mouse_data, (char *)(void *)q, ql * sizeof(struct interlink_event)); mem_free(q); return 1; } diff --git a/src/osdep/osdep.c b/src/osdep/osdep.c index dc62565f..215d345d 100644 --- a/src/osdep/osdep.c +++ b/src/osdep/osdep.c @@ -962,7 +962,7 @@ elinks_cfmakeraw(struct termios *t) t->c_cc[VTIME] = 0; } -#if !defined(CONFIG_MOUSE) || (!defined(CONFIG_GPM) && !defined(CONFIG_SYSMOUSE) && !defined(OS2_MOUSE)) +#if !defined(CONFIG_MOUSE) || (!defined(CONFIG_GPM) && !defined(CONFIG_SYSMOUSE) && !defined(OS2_MOUSE) && !defined(CONFIG_OS_DOS)) void * handle_mouse(int cons, void (*fn)(void *, char *, int), diff --git a/src/terminal/mouse.h b/src/terminal/mouse.h index d9d5fefb..653daaa8 100644 --- a/src/terminal/mouse.h +++ b/src/terminal/mouse.h @@ -96,12 +96,13 @@ struct term_event_mouse { #define B_WHEEL_UP 3 #define B_WHEEL_DOWN 4 -#define BM_ACT 32 -#define B_DOWN 0 -#define B_UP 32 +#define BM_ACT 48 +#define B_DOWN 0 +#define B_UP 16 +#define B_DRAG 32 +#define B_MOVE 48 #define BM_DRAG 64 -#define B_DRAG 64 #define mouse_get_action(mouse_) ((mouse_)->button & BM_ACT) #define mouse_action_is(mouse_, value) (mouse_get_action(mouse_) == (value))