void gimp_device_info_get_time_coords (GimpDeviceInfo *info, GdkTimeCoord *event, GimpCoords *coords) { *coords = default_coords; gdk_device_get_axis (info->device, event->axes, GDK_AXIS_X, &coords->x); gdk_device_get_axis (info->device, event->axes, GDK_AXIS_Y, &coords->y); /* CLAMP() the return value of each *_get_axis() call to be safe * against buggy XInput drivers. */ if (gdk_device_get_axis (info->device, event->axes, GDK_AXIS_PRESSURE, &coords->pressure)) { coords->pressure = gimp_device_info_map_axis (info, GDK_AXIS_PRESSURE, coords->pressure); } if (gdk_device_get_axis (info->device, event->axes, GDK_AXIS_XTILT, &coords->xtilt)) { coords->xtilt = gimp_device_info_map_axis (info, GDK_AXIS_XTILT, coords->xtilt); } if (gdk_device_get_axis (info->device, event->axes, GDK_AXIS_YTILT, &coords->ytilt)) { coords->ytilt = gimp_device_info_map_axis (info, GDK_AXIS_YTILT, coords->ytilt); } if (gdk_device_get_axis (info->device, event->axes, GDK_AXIS_WHEEL, &coords->wheel)) { coords->wheel = gimp_device_info_map_axis (info, GDK_AXIS_WHEEL, coords->wheel); } if (gimp_device_info_get_mode (info) != GDK_MODE_DISABLED && gdk_device_get_source (info->device) != GDK_SOURCE_MOUSE) { /* The event was generated by an enabled extended non-mouse device */ coords->extended = TRUE; } else { /* The event was generated by a not extended enabled device */ coords->extended = FALSE; } }
void gimp_device_info_get_device_coords (GimpDeviceInfo *info, GdkWindow *window, GimpCoords *coords) { gdouble axes[GDK_AXIS_LAST] = { 0, }; *coords = default_coords; gdk_device_get_state (info->device, window, axes, NULL); gdk_device_get_axis (info->device, axes, GDK_AXIS_X, &coords->x); gdk_device_get_axis (info->device, axes, GDK_AXIS_Y, &coords->y); if (gdk_device_get_axis (info->device, axes, GDK_AXIS_PRESSURE, &coords->pressure)) { coords->pressure = gimp_device_info_map_axis (info, GDK_AXIS_PRESSURE, coords->pressure); } if (gdk_device_get_axis (info->device, axes, GDK_AXIS_XTILT, &coords->xtilt)) { coords->xtilt = gimp_device_info_map_axis (info, GDK_AXIS_XTILT, coords->xtilt); } if (gdk_device_get_axis (info->device, axes, GDK_AXIS_YTILT, &coords->ytilt)) { coords->ytilt = gimp_device_info_map_axis (info, GDK_AXIS_YTILT, coords->ytilt); } if (gdk_device_get_axis (info->device, axes, GDK_AXIS_WHEEL, &coords->wheel)) { coords->wheel = gimp_device_info_map_axis (info, GDK_AXIS_WHEEL, coords->wheel); } if (gimp_device_info_get_mode (info) != GDK_MODE_DISABLED && gdk_device_get_source (info->device) != GDK_SOURCE_MOUSE) { /* The event was generated by an enabled extended non-mouse device */ coords->extended = TRUE; } else { /* The event was generated by a not extended enabled device */ coords->extended = FALSE; } }
gboolean gimp_device_info_get_event_coords (GimpDeviceInfo *info, GdkWindow *window, GdkEvent *event, GimpCoords *coords) { gdouble x; if (gdk_event_get_axis (event, GDK_AXIS_X, &x)) { *coords = default_coords; coords->x = x; gdk_event_get_axis (event, GDK_AXIS_Y, &coords->y); if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &coords->pressure)) { coords->pressure = gimp_device_info_map_axis (info, GDK_AXIS_PRESSURE, coords->pressure); } if (gdk_event_get_axis (event, GDK_AXIS_XTILT, &coords->xtilt)) { coords->xtilt = gimp_device_info_map_axis (info, GDK_AXIS_XTILT, coords->xtilt); } if (gdk_event_get_axis (event, GDK_AXIS_YTILT, &coords->ytilt)) { coords->ytilt = gimp_device_info_map_axis (info, GDK_AXIS_YTILT, coords->ytilt); } if (gdk_event_get_axis (event, GDK_AXIS_WHEEL, &coords->wheel)) { coords->wheel = gimp_device_info_map_axis (info, GDK_AXIS_WHEEL, coords->wheel); } return TRUE; } gimp_device_info_get_device_coords (info, window, coords); return FALSE; }
void gimp_device_info_get_time_coords (GimpDeviceInfo *info, GdkTimeCoord *event, GimpCoords *coords) { *coords = default_coords; gdk_device_get_axis (info->device, event->axes, GDK_AXIS_X, &coords->x); gdk_device_get_axis (info->device, event->axes, GDK_AXIS_Y, &coords->y); /* CLAMP() the return value of each *_get_axis() call to be safe * against buggy XInput drivers. */ if (gdk_device_get_axis (info->device, event->axes, GDK_AXIS_PRESSURE, &coords->pressure)) { coords->pressure = gimp_device_info_map_axis (info, GDK_AXIS_PRESSURE, coords->pressure); } if (gdk_device_get_axis (info->device, event->axes, GDK_AXIS_XTILT, &coords->xtilt)) { coords->xtilt = gimp_device_info_map_axis (info, GDK_AXIS_XTILT, coords->xtilt); } if (gdk_device_get_axis (info->device, event->axes, GDK_AXIS_YTILT, &coords->ytilt)) { coords->ytilt = gimp_device_info_map_axis (info, GDK_AXIS_YTILT, coords->ytilt); } if (gdk_device_get_axis (info->device, event->axes, GDK_AXIS_WHEEL, &coords->wheel)) { coords->wheel = gimp_device_info_map_axis (info, GDK_AXIS_WHEEL, coords->wheel); } }
void gimp_device_info_get_device_coords (GimpDeviceInfo *info, GdkWindow *window, GimpCoords *coords) { gdouble axes[GDK_AXIS_LAST]; *coords = default_coords; gdk_device_get_state (info->device, window, axes, NULL); gdk_device_get_axis (info->device, axes, GDK_AXIS_X, &coords->x); gdk_device_get_axis (info->device, axes, GDK_AXIS_Y, &coords->y); if (gdk_device_get_axis (info->device, axes, GDK_AXIS_PRESSURE, &coords->pressure)) { coords->pressure = gimp_device_info_map_axis (info, GDK_AXIS_PRESSURE, coords->pressure); } if (gdk_device_get_axis (info->device, axes, GDK_AXIS_XTILT, &coords->xtilt)) { coords->xtilt = gimp_device_info_map_axis (info, GDK_AXIS_XTILT, coords->xtilt); } if (gdk_device_get_axis (info->device, axes, GDK_AXIS_YTILT, &coords->ytilt)) { coords->ytilt = gimp_device_info_map_axis (info, GDK_AXIS_YTILT, coords->ytilt); } if (gdk_device_get_axis (info->device, axes, GDK_AXIS_WHEEL, &coords->wheel)) { coords->wheel = gimp_device_info_map_axis (info, GDK_AXIS_WHEEL, coords->wheel); } }
gboolean gimp_device_info_get_event_coords (GimpDeviceInfo *info, GdkWindow *window, const GdkEvent *event, GimpCoords *coords) { gdouble x; if (gdk_event_get_axis (event, GDK_AXIS_X, &x)) { *coords = default_coords; coords->x = x; gdk_event_get_axis (event, GDK_AXIS_Y, &coords->y); /* translate event coordinates to window coordinates, only * happens if we drag a guide from a ruler */ if (event->any.window && event->any.window != window) { GtkWidget *src_widget; GtkWidget *dest_widget; src_widget = gtk_get_event_widget ((GdkEvent *) event); gdk_window_get_user_data (window, (gpointer) &dest_widget); if (src_widget && dest_widget) { gint offset_x; gint offset_y; gtk_widget_translate_coordinates (src_widget, dest_widget, 0, 0, &offset_x, &offset_y); coords->x += offset_x; coords->y += offset_y; } } if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &coords->pressure)) { coords->pressure = gimp_device_info_map_axis (info, GDK_AXIS_PRESSURE, coords->pressure); } if (gdk_event_get_axis (event, GDK_AXIS_XTILT, &coords->xtilt)) { coords->xtilt = gimp_device_info_map_axis (info, GDK_AXIS_XTILT, coords->xtilt); } if (gdk_event_get_axis (event, GDK_AXIS_YTILT, &coords->ytilt)) { coords->ytilt = gimp_device_info_map_axis (info, GDK_AXIS_YTILT, coords->ytilt); } if (gdk_event_get_axis (event, GDK_AXIS_WHEEL, &coords->wheel)) { coords->wheel = gimp_device_info_map_axis (info, GDK_AXIS_WHEEL, coords->wheel); } return TRUE; } gimp_device_info_get_device_coords (info, window, coords); return FALSE; }
gboolean gimp_device_info_get_event_coords (GimpDeviceInfo *info, GdkWindow *window, const GdkEvent *event, GimpCoords *coords) { gdouble x; if (gdk_event_get_axis (event, GDK_AXIS_X, &x)) { *coords = default_coords; coords->x = x; gdk_event_get_axis (event, GDK_AXIS_Y, &coords->y); /* translate event coordinates to window coordinates, only * happens if we drag a guide from a ruler */ if (event->any.window && event->any.window != window) { GtkWidget *src_widget; GtkWidget *dest_widget; src_widget = gtk_get_event_widget ((GdkEvent *) event); gdk_window_get_user_data (window, (gpointer) &dest_widget); if (src_widget && dest_widget) { gint offset_x; gint offset_y; if (gtk_widget_translate_coordinates (src_widget, dest_widget, 0, 0, &offset_x, &offset_y)) { coords->x += offset_x; coords->y += offset_y; } } } if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &coords->pressure)) { coords->pressure = gimp_device_info_map_axis (info, GDK_AXIS_PRESSURE, coords->pressure); } if (gdk_event_get_axis (event, GDK_AXIS_XTILT, &coords->xtilt)) { coords->xtilt = gimp_device_info_map_axis (info, GDK_AXIS_XTILT, coords->xtilt); } if (gdk_event_get_axis (event, GDK_AXIS_YTILT, &coords->ytilt)) { coords->ytilt = gimp_device_info_map_axis (info, GDK_AXIS_YTILT, coords->ytilt); } if (gdk_event_get_axis (event, GDK_AXIS_WHEEL, &coords->wheel)) { coords->wheel = gimp_device_info_map_axis (info, GDK_AXIS_WHEEL, coords->wheel); } if (gimp_device_info_get_mode (info) != GDK_MODE_DISABLED && gdk_device_get_source (info->device) != GDK_SOURCE_MOUSE) { /* The event was generated by an enabled extended non-mouse device */ coords->extended = TRUE; } else { /* The event was generated by a not extended enabled device */ coords->extended = FALSE; } return TRUE; } gimp_device_info_get_device_coords (info, window, coords); return FALSE; }