1
1

* mouse.h: Major cleanup and interface change. init_mouse()

should only be called once, disable_mouse() and enable_mouse()
should be used later.  Distinguish between disabled and
undetected mouse.  Remove debugging stuff.  Adjust all users.
* mouse.c: Implementation of the above.
* key.c: Don't use gpm_flag - check mouse_enabled instead.
Этот коммит содержится в:
Pavel Roskin 2001-09-17 04:43:58 +00:00
родитель 9b00e32f64
Коммит 34947b1819
8 изменённых файлов: 102 добавлений и 164 удалений

Просмотреть файл

@ -1,3 +1,12 @@
2001-09-17 Pavel Roskin <proski@gnu.org>
* mouse.h: Major cleanup and interface change. init_mouse()
should only be called once, disable_mouse() and enable_mouse()
should be used later. Distinguish between disabled and
undetected mouse. Remove debugging stuff. Adjust all users.
* mouse.c: Implementation of the above.
* key.c: Don't use gpm_flag - check mouse_enabled instead.
2001-09-15 Pavel Roskin <proski@gnu.org>
* view.c: Cleanup of preprocessor directives.

Просмотреть файл

@ -910,7 +910,7 @@ view_other_cmd (void)
" the panels cannot be toggled. "));
message_flag = FALSE;
} else {
shut_mouse ();
disable_mouse ();
if (clear_before_exec)
clr_scr ();
if (alternate_plus_minus)
@ -953,7 +953,7 @@ view_other_cmd (void)
reset_prog_mode ();
keypad(stdscr, TRUE);
init_mouse ();
enable_mouse ();
if (alternate_plus_minus)
application_keypad_mode ();

Просмотреть файл

@ -655,10 +655,6 @@ static int getch_with_delay (void)
return c;
}
#ifndef HAVE_LIBGPM
#define gpm_flag 0
#endif
extern int max_dirt_limit;
/* Returns a character read from stdin with appropriate interpretation */
@ -696,17 +692,15 @@ int get_event (Gpm_Event *event, int redo_event, int block)
}
/* Repeat if using mouse */
while ((xmouse_flag || gpm_flag) && !pending_keys)
{
if (xmouse_flag || gpm_flag)
{
while (mouse_enabled && !pending_keys) {
if (mouse_enabled) {
FD_ZERO (&select_set);
FD_SET (input_fd, &select_set);
add_selects (&select_set);
#ifdef HAVE_LIBGPM
if (gpm_flag) {
FD_SET (gpm_fd, &select_set);
if (mouse_enabled && use_mouse_p == MOUSE_GPM) {
FD_SET (gpm_fd, &select_set);
}
#endif
@ -761,11 +755,10 @@ int get_event (Gpm_Event *event, int redo_event, int block)
break;
}
#ifdef HAVE_LIBGPM
if (gpm_flag && FD_ISSET (gpm_fd, &select_set)){
if (gpm_flag){
Gpm_GetEvent (&ev);
Gpm_FitEvent (&ev);
}
if (mouse_enabled && use_mouse_p == MOUSE_GPM
&& FD_ISSET (gpm_fd, &select_set)) {
Gpm_GetEvent (&ev);
Gpm_FitEvent (&ev);
*event = ev;
return EV_MOUSE;
}

Просмотреть файл

@ -594,7 +594,7 @@ void done_screen ()
clr_scr ();
reset_shell_mode ();
mc_noraw_mode ();
shut_mouse ();
disable_mouse ();
keypad (stdscr, FALSE);
}

Просмотреть файл

@ -225,8 +225,8 @@ WButtonBar *the_bar;
/* For slow terminals */
int slow_terminal = 0;
/* use mouse? */
int use_mouse_p = GPM_MOUSE;
/* Mouse type: GPM, xterm or none */
Mouse_Type use_mouse_p = MOUSE_NONE;
/* If true, assume we are running on an xterm terminal */
static int force_xterm = 0;
@ -1749,8 +1749,8 @@ init_xterm_support (void)
}
/* Enable mouse unless explicitly disabled by --nomouse */
if (use_mouse_p != NO_MOUSE) {
use_mouse_p = XTERM_MOUSE;
if (use_mouse_p != MOUSE_DISABLED) {
use_mouse_p = MOUSE_XTERM;
}
#if 0 /* It works on xterm, but not on rxvt */
@ -2433,7 +2433,7 @@ process_args (int c, const char *option_arg)
#endif
case 'd':
use_mouse_p = NO_MOUSE;
use_mouse_p = MOUSE_DISABLED;
break;
#ifdef HAVE_SUBSHELL_SUPPORT

Просмотреть файл

@ -25,91 +25,52 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <signal.h> /* For kill() and SIGQUIT */
#include <fcntl.h>
#if HAVE_TERMIOS_H
# include <termios.h>
#endif
#include <stdio.h>
#include "global.h"
#include "tty.h"
#include "mouse.h"
#include "key.h" /* define sequence */
#include "tty.h" /* get ncurses header */
int xmouse_flag = 0;
int mouse_enabled = 0;
char *xmouse_seq;
#ifdef HAVE_LIBGPM
static int mouse_d; /* Handle to the mouse server */
#endif
#ifdef DEBUGMOUSE
/* Only used for debugging */
static int top_event = 0;
FILE *log;
#endif
#ifdef HAVE_LIBGPM
void show_mouse_pointer (int x, int y)
{
#ifdef HAVE_LIBGPM
if (use_mouse_p == GPM_MOUSE){
if (use_mouse_p == MOUSE_GPM) {
Gpm_DrawPointer (x, y, gpm_consolefd);
}
#endif
}
#endif /* HAVE_LIBGPM */
#if 0
int mouse_handler (Gpm_Event *gpm_event)
{
MouseEvent *event = mouse_events;
int x = last_x = gpm_event->x;
int y = last_y = gpm_event->y;
int redo = 0;
/* DEBUGM ((log, "Mouse [%d, %d]\n", x, y)); */
/* Call any registered event handlers */
for (; event; event = (MouseEvent *) event->next){
if ((event->x1 <= x) && (x <= event->x2)
&& (event->y1 <= y) && (y <= event->y2)){
gpm_event->x -= event->x1;
gpm_event->y -= event->y1;
last_mouse_event = event;
redo = (*(event->mouse_callback))(gpm_event, event->data);
gpm_event->x += event->x1;
gpm_event->y += event->y1;
break;
}
}
return redo;
}
int redo_mouse (Gpm_Event *event)
{
if (last_mouse_event){
int result;
event->x -= last_mouse_event->x1;
event->y -= last_mouse_event->y1;
result = (*(last_mouse_event->mouse_callback))
(event,last_mouse_event->data);
event->x += last_mouse_event->x1;
event->y += last_mouse_event->y1;
return result;
}
return MOU_NORMAL;
}
#endif
void init_mouse (void)
{
switch (use_mouse_p)
{
switch (use_mouse_p) {
#ifdef HAVE_LIBGPM
case GPM_MOUSE:
case MOUSE_NONE:
use_mouse_p = MOUSE_GPM;
break;
#endif /* HAVE_LIBGPM */
case MOUSE_XTERM:
define_sequence (MCKEY_MOUSE, xmouse_seq, MCKEY_NOACTION);
break;
}
enable_mouse ();
}
void enable_mouse (void)
{
if (mouse_enabled) {
return;
}
switch (use_mouse_p) {
#ifdef HAVE_LIBGPM
case MOUSE_GPM:
{
int mouse_d;
Gpm_Connect conn;
conn.eventMask = ~GPM_MOVE;
@ -117,69 +78,50 @@ void init_mouse (void)
conn.minMod = 0;
conn.maxMod = 0;
if ((mouse_d = Gpm_Open (&conn, 0)) == -1)
mouse_d = Gpm_Open (&conn, 0);
if (mouse_d == -1) {
use_mouse_p = MOUSE_NONE;
return;
#ifdef DEBUGMOUSE
log = fopen ("mouse.log", "w");
#endif
}
mouse_enabled = 1;
}
break;
#endif /* HAVE_LIBGPM */
case XTERM_MOUSE:
if (!xmouse_flag) {
case MOUSE_XTERM:
/* save old highlight mouse tracking */
printf(ESC_STR "[?1001s");
/* save old highlight mouse tracking */
printf(ESC_STR "[?1001s");
/* enable mouse tracking */
printf(ESC_STR "[?1000h");
/* enable mouse tracking */
printf(ESC_STR "[?1000h");
fflush (stdout);
/* turn on */
xmouse_flag = 1;
define_sequence (MCKEY_MOUSE, xmouse_seq, MCKEY_NOACTION);
}
break;
default:
/* nothing */
break;
} /* switch (use_mouse_p) */
}
void shut_mouse (void)
{
switch (use_mouse_p){
#ifdef HAVE_LIBGPM
case GPM_MOUSE:
Gpm_Close ();
break;
#endif
case XTERM_MOUSE:
if (xmouse_flag) {
/* disable mouse tracking */
/* Changed the 1 for an 'l' below: */
printf("%c[?1000l",27);
/* restore old highlight mouse tracking */
printf("%c[?1001r",27);
fflush (stdout);
/* off */
xmouse_flag = 0;
}
break;
default:
/* nothing */
fflush (stdout);
mouse_enabled = 1;
break;
}
}
#ifdef DEBUGMOUSE
void mouse_log (char *function, char *file, int line)
void disable_mouse (void)
{
fprintf (log, "%s called from %s:%d\n", function, file, line);
}
#endif
if (!mouse_enabled) {
return;
}
mouse_enabled = 0;
switch (use_mouse_p) {
#ifdef HAVE_LIBGPM
case MOUSE_GPM:
Gpm_Close ();
break;
#endif
case MOUSE_XTERM:
/* disable mouse tracking */
printf(ESC_STR "[?1000l");
/* restore old highlight mouse tracking */
printf(ESC_STR "[?1001r");
fflush (stdout);
break;
}
}

Просмотреть файл

@ -40,31 +40,31 @@ typedef struct Gpm_Event {
enum Gpm_Etype type;
} Gpm_Event;
extern int gpm_fd;
#endif
#endif /* !HAVE_LIBGPM */
/* General mouse support definitions */
typedef int (*mouse_h)(Gpm_Event *, void *);
#define NO_MOUSE 0
#define GPM_MOUSE 1
#define XTERM_MOUSE 2
typedef enum {
MOUSE_NONE, /* Not detected yet */
MOUSE_DISABLED, /* Explicitly disabled by -d */
MOUSE_GPM, /* Support using GPM on Linux */
MOUSE_XTERM /* Support using xterm-style mouse reporting */
} Mouse_Type;
void init_mouse (void);
void shut_mouse (void);
/* Type of the currently used mouse */
extern Mouse_Type use_mouse_p;
/* Type of mouse: NO_MOUSE, GPM_MOUSE or XTERM_MOUSE */
extern int use_mouse_p;
/* If use_mouse_p is XTERM_MOUSE: is mouse currently active? */
extern int xmouse_flag;
/* The mouse is currently: 1 - enabled, 0 - disabled */
extern int mouse_enabled;
/* String indicating that a mouse event has occured, usually "\E[M" */
extern char *xmouse_seq;
int mouse_handler (Gpm_Event *gpm_event);
int redo_mouse (Gpm_Event *event);
void init_mouse (void);
void enable_mouse (void);
void disable_mouse (void);
/* Constants returned from mouse handlers */
@ -73,12 +73,6 @@ int redo_mouse (Gpm_Event *event);
#define MOU_ENDLOOP 0x02
#define MOU_LOCK 0x04
#ifdef DEBUGMOUSE
#define DEBUGM(data) fprintf data
#else
#define DEBUGM(data)
#endif
#ifdef HAVE_LIBGPM
/* GPM specific mouse support definitions */

Просмотреть файл

@ -63,7 +63,7 @@ edition_post_exec (void)
keypad (stdscr, TRUE);
mc_raw_mode ();
channels_up ();
init_mouse ();
enable_mouse ();
if (alternate_plus_minus)
application_keypad_mode ();
}
@ -79,7 +79,7 @@ edition_pre_exec (void)
}
channels_down ();
shut_mouse ();
disable_mouse ();
reset_shell_mode ();
keypad (stdscr, FALSE);