+void FreezePointer::freeze_pointer(ui::Widget widget, FreezePointer::MotionDeltaFunction function, void *data)
+{
+ 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 );
+
+ 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 );
+
+ 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 );
+}
+
+void FreezePointer::unfreeze_pointer(ui::Widget widget)
+{
+ g_signal_handler_disconnect( G_OBJECT( widget ), handle_motion );
+
+ m_function = 0;
+ m_data = 0;
+
+ Sys_SetCursorPos( widget, recorded_x, recorded_y );
+
+ gdk_pointer_ungrab( GDK_CURRENT_TIME );