(U+6215): Apply new conventions for glyph granularity.
[chise/xemacs-chise.git.1] / src / event-msw.c
index aaeaa4f..2b41016 100644 (file)
@@ -812,7 +812,7 @@ winsock_closer (Lstream *lstr)
   else
     shutdown (str->s, 1);
 
-  CloseHandle ((HANDLE)str->s);
+  closesocket (str->s);
   if (str->pending_p)
     WaitForSingleObject (str->ov.hEvent, INFINITE);
 
@@ -981,6 +981,9 @@ mswindows_enqueue_mouse_button_event (HWND hwnd, UINT msg, POINTS where,
   int downp = (msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN ||
               msg == WM_RBUTTONDOWN);
 
+  /* Wheel rotation amount: positive is away from user, negative towards user */
+  int delta = (short) HIWORD (mods);
+  
   /* We always use last message time, because mouse button
      events may get delayed, and XEmacs double click
      recognition will fail */
@@ -993,7 +996,9 @@ mswindows_enqueue_mouse_button_event (HWND hwnd, UINT msg, POINTS where,
   event->timestamp = when;
   event->event.button.button =
     (msg==WM_LBUTTONDOWN || msg==WM_LBUTTONUP) ? 1 :
-    ((msg==WM_RBUTTONDOWN || msg==WM_RBUTTONUP) ? 3 : 2);
+    (msg==WM_MBUTTONDOWN || msg==WM_MBUTTONUP) ? 2 :
+    (msg==WM_RBUTTONDOWN || msg==WM_RBUTTONUP) ? 3 :
+    (msg==WM_MOUSEWHEEL && delta>0) ? 4 : 5;
   event->event.button.x = where.x;
   event->event.button.y = where.y;
   event->event.button.modifiers = mswindows_modifier_state (NULL, mods, 0);
@@ -1069,7 +1074,7 @@ mswindows_dequeue_dispatch_event (void)
  * Timeout event matches if interval_id is equal to that of the given event.
  * Keypress event matches if logical AND between modifiers bitmask of the
  * event in the queue and that of the given event is non-zero.
- * For all other event types, this function aborts.
+ * For all other event types, this function ABORTs.
  */
 
 Lisp_Object
@@ -2950,13 +2955,18 @@ mswindows_wnd_proc (HWND hwnd, UINT message_, WPARAM wParam, LPARAM lParam)
        int keys = LOWORD (wParam); /* Modifier key flags */
        int delta = (short) HIWORD (wParam); /* Wheel rotation amount */
 
-       if (mswindows_handle_mousewheel_event (mswindows_find_frame (hwnd),
+        /* enqueue button4/5 events if mswindows_handle_mousewheel_event
+           doesn't handle the event, such as when the scrollbars are not
+           displayed */
+       if (!mswindows_handle_mousewheel_event (mswindows_find_frame (hwnd),
                                               keys, delta,
                                               MAKEPOINTS (lParam)))
-         /* We are not in a modal loop so no pumping is necessary. */
-         break;
-       else
-         goto defproc;
+          mswindows_enqueue_mouse_button_event (hwnd, message_,
+                                                MAKEPOINTS (lParam),
+                                                wParam,
+                                                GetMessageTime());
+        /* We are not in a modal loop so no pumping is necessary. */
+        break;
       }
 #endif
 
@@ -3865,7 +3875,7 @@ FROB (WM_SETHOTKEY)
 FROB (WM_GETHOTKEY)
 FROB (WM_QUERYDRAGICON)
 FROB (WM_COMPAREITEM)
-#if(WINVER >= 0x0500)
+#if(WINVER >= 0x0500) && defined(WM_GETOBJECT)
 FROB (WM_GETOBJECT)
 #endif /* WINVER >= 0x0500 */
 FROB (WM_COMPACTING)
@@ -3947,10 +3957,18 @@ FROB (WM_MENUCHAR)
 FROB (WM_ENTERIDLE)
 #if(WINVER >= 0x0500)
 FROB (WM_MENURBUTTONUP)
+#ifdef WM_MENUDRAG
 FROB (WM_MENUDRAG)
+#endif
+#ifdef WM_MENUGETOBJECT
 FROB (WM_MENUGETOBJECT)
+#endif
+#ifdef WM_UNINITMENUPOPUP
 FROB (WM_UNINITMENUPOPUP)
+#endif
+#ifdef WM_MENUCOMMAND
 FROB (WM_MENUCOMMAND)
+#endif
 #endif /* WINVER >= 0x0500 */
 
 
@@ -4026,7 +4044,7 @@ FROB (WM_IME_COMPOSITIONFULL)
 FROB (WM_IME_SELECT)
 FROB (WM_IME_CHAR)
 #endif /* WINVER >= 0x0400 */
-#if(WINVER >= 0x0500)
+#if(WINVER >= 0x0500) && defined(WM_IME_REQUEST)
 FROB (WM_IME_REQUEST)
 #endif /* WINVER >= 0x0500 */
 #if(WINVER >= 0x0400) && !defined(CYGWIN)