+static inline bool isMouseEvent( WPARAM type )
+{
+ return type >= WM_MOUSEFIRST &&
+ type <= WM_MOUSELAST;
+}
+
+static inline bool isKeyEvent( WPARAM type )
+{
+ return type >= WM_KEYFIRST &&
+ type <= WM_KEYLAST;
+}
+
+static void UpdateCursor( event_thread_t *p_event, bool b_show )
+{
+ if( p_event->is_cursor_hidden == !b_show )
+ return;
+ p_event->is_cursor_hidden = !b_show;
+
+#if 1
+ HCURSOR cursor = b_show ? p_event->cursor_arrow : p_event->cursor_empty;
+ if( p_event->hvideownd )
+ SetClassLongPtr( p_event->hvideownd, GCLP_HCURSOR, (LONG_PTR)cursor );
+ if( p_event->hwnd )
+ SetClassLongPtr( p_event->hwnd, GCLP_HCURSOR, (LONG_PTR)cursor );
+#endif
+
+ /* FIXME I failed to find a cleaner way to force a redraw of the cursor */
+ POINT p;
+ GetCursorPos(&p);
+ HWND hwnd = WindowFromPoint(p);
+ if( hwnd == p_event->hvideownd || hwnd == p_event->hwnd )
+ {
+ if( b_show )
+ SetCursor( cursor );
+ else
+ SetCursorPos( p.x, p.y );
+ }
+}
+
+static HCURSOR EmptyCursor( HINSTANCE instance )
+{
+ const int cw = GetSystemMetrics(SM_CXCURSOR);
+ const int ch = GetSystemMetrics(SM_CYCURSOR);
+
+ HCURSOR cursor = NULL;
+ uint8_t *and = malloc(cw * ch);
+ uint8_t *xor = malloc(cw * ch);
+ if( and && xor )
+ {
+ memset(and, 0xff, cw * ch );
+ memset(xor, 0x00, cw * ch );
+ cursor = CreateCursor( instance, 0, 0, cw, ch, and, xor);
+ }
+ free( and );
+ free( xor );
+
+ return cursor;
+}
+
+static void MousePressed( event_thread_t *p_event, HWND hwnd, unsigned button )
+{
+ if( !p_event->button_pressed )
+ SetCapture( hwnd );
+ p_event->button_pressed |= 1 << button;
+ vout_display_SendEventMousePressed( p_event->vd, button );
+}
+
+static void MouseReleased( event_thread_t *p_event, unsigned button )
+{
+ p_event->button_pressed &= ~(1 << button);
+ if( !p_event->button_pressed )
+ ReleaseCapture();
+ vout_display_SendEventMouseReleased( p_event->vd, button );
+}