Commit 4c9747d2 authored by Ulrich Pegelow's avatar Ulrich Pegelow

re-enable pressure reading for tablet devices; fixes #10367

Gdk3 handles input devices via GdkDeviceManager which requires a different
approach to get pressure readings from tablet pens (tablets not visible
to the application as phyiscal devices but as virtual slave devices; no need
to activate them explicitely; different route to identify device as pen;
different way to retrieve pressure axis reading).
parent 9c489d78
......@@ -689,8 +689,6 @@ static int _blendop_masks_add_brush(GtkWidget *widget, GdkEventButton *event, dt
bd->masks_shown = DT_MASKS_EDIT_FULL;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bd->masks_edit), TRUE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
// enable advanced input devices to get pressure readings and stuff like that
dt_gui_enable_extended_input_devices();
// we create the new form
dt_masks_form_t *form = dt_masks_create(DT_MASKS_BRUSH);
dt_masks_change_form_gui(form);
......
......@@ -1537,9 +1537,6 @@ static int dt_brush_events_button_released(struct dt_iop_module_t *module, float
{
if(!gui) return 0;
// disable pressure readings
dt_gui_disable_extended_input_devices();
dt_masks_form_gui_points_t *gpt = (dt_masks_form_gui_points_t *)g_list_nth_data(gui->points, index);
if(!gpt) return 0;
......
......@@ -1353,7 +1353,6 @@ static void _menu_add_brush(struct dt_iop_module_t *module)
{
// we want to be sure that the iop has focus
dt_iop_request_focus(module);
dt_gui_enable_extended_input_devices();
// we create the new form
dt_masks_form_t *form = dt_masks_create(DT_MASKS_BRUSH);
dt_masks_change_form_gui(form);
......
......@@ -647,11 +647,11 @@ static gboolean key_released(GtkWidget *w, GdkEventKey *event, gpointer user_dat
static gboolean button_pressed(GtkWidget *w, GdkEventButton *event, gpointer user_data)
{
double pressure = 1.0;
if(gdk_device_get_source(event->device) == GDK_SOURCE_PEN)
GdkDevice *device = gdk_event_get_source_device((GdkEvent *)event);
if(device && gdk_device_get_source(device) == GDK_SOURCE_PEN)
{
gdouble axes[gdk_device_get_n_axes(event->device)];
gdk_device_get_state(event->device, gtk_widget_get_window(w), axes, NULL);
gdk_device_get_axis(event->device, axes, GDK_AXIS_PRESSURE, &pressure);
gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure);
}
dt_control_button_pressed(event->x, event->y, pressure, event->button, event->type, event->state & 0xf);
gtk_widget_grab_focus(w);
......@@ -669,11 +669,11 @@ static gboolean button_released(GtkWidget *w, GdkEventButton *event, gpointer us
static gboolean mouse_moved(GtkWidget *w, GdkEventMotion *event, gpointer user_data)
{
double pressure = 1.0;
if(gdk_device_get_source(event->device) == GDK_SOURCE_PEN)
GdkDevice *device = gdk_event_get_source_device((GdkEvent *)event);
if(device && gdk_device_get_source(device) == GDK_SOURCE_PEN)
{
gdouble axes[gdk_device_get_n_axes(event->device)];
gdk_device_get_state(event->device, gtk_widget_get_window(w), axes, NULL);
gdk_device_get_axis(event->device, axes, GDK_AXIS_PRESSURE, &pressure);
gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure);
}
dt_control_mouse_moved(event->x, event->y, pressure, event->state & 0xf);
gint x, y;
......@@ -1557,55 +1557,6 @@ void dt_ellipsize_combo(GtkComboBox *cbox)
g_list_free(renderers);
}
// we only try to enable/disable those devices that are pens and that have a pressure axis
void dt_gui_enable_extended_input_devices()
{
GdkDevice *core_pointer
= gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gdk_display_get_default()));
GList *input_devices = gdk_device_manager_list_devices(
gdk_display_get_device_manager(gdk_display_get_default()), GDK_DEVICE_TYPE_MASTER);
while(input_devices)
{
GdkDevice *device = (GdkDevice *)input_devices->data;
if(device != core_pointer && gdk_device_get_source(device) == GDK_SOURCE_PEN)
{
for(int i = 0; i < gdk_device_get_n_axes(device); i++)
{
if(gdk_device_get_axis_use(device, i) == GDK_AXIS_PRESSURE)
{
gdk_device_set_mode(device, GDK_MODE_SCREEN);
break;
}
}
}
input_devices = g_list_next(input_devices);
}
}
void dt_gui_disable_extended_input_devices()
{
GdkDevice *core_pointer
= gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gdk_display_get_default()));
GList *input_devices = gdk_device_manager_list_devices(
gdk_display_get_device_manager(gdk_display_get_default()), GDK_DEVICE_TYPE_MASTER);
while(input_devices)
{
GdkDevice *device = (GdkDevice *)input_devices->data;
if(device != core_pointer && gdk_device_get_source(device) == GDK_SOURCE_PEN)
{
for(int i = 0; i < gdk_device_get_n_axes(device); i++)
{
if(gdk_device_get_axis_use(device, i) == GDK_AXIS_PRESSURE)
{
gdk_device_set_mode(device, GDK_MODE_DISABLED);
break;
}
}
}
input_devices = g_list_next(input_devices);
}
}
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
// vim: shiftwidth=2 expandtab tabstop=2 cindent
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-space on;
......@@ -124,10 +124,6 @@ void dt_gui_key_accel_block_on_focus_connect(GtkWidget *w);
/** clean up connected signal handlers before destroying your widget: */
void dt_gui_key_accel_block_on_focus_disconnect(GtkWidget *w);
/** handle pressure sensitive input devices */
void dt_gui_enable_extended_input_devices();
void dt_gui_disable_extended_input_devices();
/*
* new ui api
*/
......
......@@ -197,8 +197,6 @@ static void _bt_add_gradient(GtkWidget *widget, GdkEventButton *event, dt_lib_mo
}
static void _tree_add_brush(GtkButton *button, dt_iop_module_t *module)
{
// enable pressure readings
dt_gui_enable_extended_input_devices();
// we create the new form
dt_masks_form_t *spot = dt_masks_create(DT_MASKS_BRUSH);
dt_masks_change_form_gui(spot);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment