[w3m-dev-en 00030] Re: 0.1.6: MENU_CANCEL

From: Christian Weisgerber (w3m-dev-en@mips.rhein-neckar.de)
Date: Mon Jan 24 2000 - 14:10:36 CST


<hsaka@mth.biglobe.ne.jp> wrote:

> I implemented almost code for the menu except the code for GPM.

Great, now I know who to ask about this part of w3m. :-)

> The last part of action_menu() can be written in detail.
>
> /* for MENU_CANCEL */
> } else if (select == MENU_CANCEL) {
> }
> return(0);

Thanks for clearing this up.

> I don't have/use GPM, please fix the behavior under GPM.

In retrospect it's really obvious. gpm_process_menu_mouse() was
throwing away error values returned by process_mMouse(). Here's
the patch for 0.1.6:

--- menu.c.orig Mon Jan 24 17:10:38 2000
+++ menu.c Mon Jan 24 17:11:50 2000
@@ -520,7 +520,8 @@
 #ifdef USE_GPM
     if (c == X_GPM_SELECTED) {
       select = X_Gpm_Selection;
- break;
+ if (select != MENU_NOTHING)
+ break;
     }
 #endif
     if ((c & 0x80) == 0) { /* Ascii */
@@ -859,9 +860,7 @@
   x = event->x;
   y = event->y;
   X_Gpm_Selection = process_mMouse(btn, x-1, y-1);
- if (X_Gpm_Selection >= 0)
- return X_GPM_SELECTED;
- return 0;
+ return X_GPM_SELECTED;
 }
 #endif
 #else

And here's the one including my sysmouse changes to menu.c:

--- menu.c.orig Fri Jan 21 09:29:35 2000
+++ menu.c Mon Jan 24 17:02:07 2000
@@ -12,8 +12,15 @@
 #include <gpm.h>
 static int gpm_process_menu_mouse(Gpm_Event *event, void *data);
 extern int gpm_process_mouse(Gpm_Event*,void*);
-#define X_GPM_SELECTED (char)0xff
-static int X_Gpm_Selection;
+#endif
+#ifdef USE_SYSMOUSE
+extern int (*sysm_handler)(int x, int y, int nbs, int obs);
+static int sysm_process_menu_mouse(int, int, int, int);
+extern int sysm_process_mouse(int, int, int, int);
+#endif
+#if defined(USE_GPM) || defined(USE_SYSMOUSE)
+#define X_MOUSE_SELECTED (char)0xff
+static int X_Mouse_Selection;
 extern int do_getch();
 #define getch() do_getch()
 #endif
@@ -517,10 +524,11 @@
 #ifdef MOUSE
     if (use_mouse) mouse_inactive();
 #endif
-#ifdef USE_GPM
- if (c == X_GPM_SELECTED) {
- select = X_Gpm_Selection;
- break;
+#if defined(USE_GPM) || defined(USE_SYSMOUSE)
+ if (c == X_MOUSE_SELECTED) {
+ select = X_Mouse_Selection;
+ if (select != MENU_NOTHING)
+ break;
     }
 #endif
     if ((c & 0x80) == 0) { /* Ascii */
@@ -561,6 +569,9 @@
 #ifdef USE_GPM
   gpm_handler = gpm_process_menu_mouse;
 #endif
+#ifdef USE_SYSMOUSE
+ sysm_handler = sysm_process_menu_mouse;
+#endif
   menu->parent = parent;
   menu->select = menu->initial;
   menu->offset = 0;
@@ -583,6 +594,10 @@
   if (CurrentMenu == NULL)
     gpm_handler = gpm_process_mouse;
 #endif
+#ifdef USE_SYSMOUSE
+ if (CurrentMenu == NULL)
+ sysm_handler = sysm_process_mouse;
+#endif
 }
 
 void
@@ -858,10 +873,28 @@
   }
   x = event->x;
   y = event->y;
- X_Gpm_Selection = process_mMouse(btn, x-1, y-1);
- if (X_Gpm_Selection >= 0)
- return X_GPM_SELECTED;
- return 0;
+ X_Mouse_Selection = process_mMouse(btn, x-1, y-1);
+ return X_MOUSE_SELECTED;
+}
+#endif
+
+#ifdef USE_SYSMOUSE
+static int
+sysm_process_menu_mouse(int x, int y, int nbs, int obs)
+{
+ int btn;
+ int bits;
+
+ if (obs & ~nbs)
+ btn = MOUSE_BTN_UP;
+ else if (bits = nbs & ~obs)
+ btn = bits & 0x1 ? MOUSE_BTN1_DOWN :
+ (bits & 0x2 ? MOUSE_BTN2_DOWN :
+ (bits & 0x4 ? MOUSE_BTN3_DOWN : 0));
+ else /* nbs == obs */
+ return 0;
+ X_Mouse_Selection = process_mMouse(btn, x, y);
+ return X_MOUSE_SELECTED;
 }
 #endif
 #else

-- 
Christian "naddy" Weisgerber                  naddy@mips.rhein-neckar.de



This archive was generated by hypermail 2b29 : Wed Jul 19 2000 - 10:30:43 CDT