+ /* FIXME: This bug can happen if the pointer goes outside of the
+ XY Window while the right mouse button is not released,
+ the XY Window loses focus and can't read the right mouse button
+ release event and then cannot unfreeze the pointer, meaning the
+ user can attempt to freeze the pointer in another XY window.
+
+ This can happen with touch screen, especially those used to drive
+ virtual machine pointers, the cursor can be teleported outside of
+ the XY Window while maintaining pressure on the right mouse button.
+ This can also happen when the render is slow.
+
+ The bug also occurs with the Camera Window.
+
+ FIXME: It's would be possible to tell the user to save the map
+ at assert time before crashing because this bug does not corrupt
+ map saving. */
+ ASSERT_MESSAGE( m_function == 0, "can't freeze pointer" );
+
+ const GdkEventMask mask = static_cast<GdkEventMask>( GDK_POINTER_MOTION_MASK
+ | GDK_POINTER_MOTION_HINT_MASK
+ | GDK_BUTTON_MOTION_MASK
+ | GDK_BUTTON1_MOTION_MASK
+ | GDK_BUTTON2_MOTION_MASK
+ | GDK_BUTTON3_MOTION_MASK
+ | GDK_BUTTON_PRESS_MASK
+ | GDK_BUTTON_RELEASE_MASK
+ | GDK_VISIBILITY_NOTIFY_MASK );
+
+#if defined(WORKAROUND_MACOS_GTK2_LAGGYPOINTER)
+ /* Keep the pointer visible during the move operation.
+ Because of a bug, it remains visible even if we give
+ the order to hide it anyway.
+ Other parts of the code assume the pointer is visible,
+ so make sure it is consistently visible accross
+ third-party updates that may fix the mouse pointer
+ visibility issue. */
+#else
+ GdkCursor* cursor = create_blank_cursor();
+ //GdkGrabStatus status =
+ gdk_pointer_grab( gtk_widget_get_window( widget ), TRUE, mask, 0, cursor, GDK_CURRENT_TIME );
+ gdk_cursor_unref( cursor );
+#endif
+
+ Sys_GetCursorPos( widget, &recorded_x, &recorded_y );
+
+ Sys_SetCursorPos( widget, recorded_x, recorded_y );
+
+ last_x = recorded_x;
+ last_y = recorded_y;
+
+ m_function = function;
+ m_data = data;
+
+ handle_motion = widget.connect( "motion_notify_event", G_CALLBACK( motion_delta ), this );