Skip to content

Commit 3cc8309

Browse files
committed
Add some temporary logging to rootcause issues
1 parent 8886d06 commit 3cc8309

2 files changed

Lines changed: 96 additions & 9 deletions

File tree

src/gui/gtk.c

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -753,21 +753,45 @@ static gboolean _input_event(GtkWidget *widget,
753753
case GDK_TOUCHPAD_PINCH:
754754
case GDK_TOUCHPAD_SWIPE:
755755
_touchpad = gdk_event_get_source_device(event);
756+
if(_touchpad)
757+
{
758+
dt_print(DT_DEBUG_INPUT,
759+
"[touchpad] gesture event type=%d source='%s' source_type=%d",
760+
event->type,
761+
gdk_device_get_name(_touchpad),
762+
gdk_device_get_source(_touchpad));
763+
}
764+
else
765+
{
766+
dt_print(DT_DEBUG_INPUT,
767+
"[touchpad] gesture event type=%d without source device",
768+
event->type);
769+
}
756770
break;
757771
default:
758772
break;
759773
}
760774

761-
if(event->type == GDK_TOUCHPAD_PINCH)
762775
if(event->type == GDK_TOUCHPAD_PINCH && _touchpad_gestures_enabled())
763776
{
764777
const GdkEventTouchpadPinch *pinch = &event->touchpad_pinch;
778+
dt_print(DT_DEBUG_INPUT,
779+
"[touchpad] pinch x=%.2f y=%.2f phase=%d scale=%.6f state=0x%x",
780+
pinch->x, pinch->y, pinch->phase, pinch->scale, pinch->state);
765781
if(dt_view_manager_gesture_pinch(darktable.view_manager, pinch->x, pinch->y,
766782
pinch->phase, pinch->scale, pinch->state & 0xf))
767783
{
768784
gtk_widget_queue_draw(widget);
769785
return TRUE;
770786
}
787+
788+
dt_print(DT_DEBUG_INPUT,
789+
"[touchpad] pinch ignored by current view");
790+
}
791+
else if(event->type == GDK_TOUCHPAD_PINCH)
792+
{
793+
dt_print(DT_DEBUG_INPUT,
794+
"[touchpad] pinch received but disabled by preference darkroom/ui/touchpad_gestures");
771795
}
772796

773797
return FALSE;
@@ -779,31 +803,67 @@ static gboolean _scrolled(GtkWidget *widget,
779803
{
780804
(void)user_data;
781805
GdkDevice *device = gdk_event_get_source_device((GdkEvent *)event);
782-
783-
if(_touchpad_gestures_enabled()
784-
&& !dt_modifier_is(event->state, GDK_CONTROL_MASK)
785-
&& ((device && gdk_device_get_source(device) == GDK_SOURCE_TOUCHPAD)
786-
|| device == _touchpad)
806+
const gboolean touchpad_enabled = _touchpad_gestures_enabled();
807+
const gboolean ctrl_pressed = dt_modifier_is(event->state, GDK_CONTROL_MASK);
808+
const gboolean is_touchpad_source = device && gdk_device_get_source(device) == GDK_SOURCE_TOUCHPAD;
809+
const gboolean matches_last_gesture_device = (device == _touchpad);
810+
811+
if(touchpad_enabled
812+
&& !ctrl_pressed
813+
&& (is_touchpad_source || matches_last_gesture_device)
787814
&& event->direction == GDK_SCROLL_SMOOTH && !event->is_stop)
788815
{
789816
gdouble delta_x = 0.0, delta_y = 0.0;
790817
if(!dt_gui_get_scroll_deltas(event, &delta_x, &delta_y))
818+
{
819+
dt_print(DT_DEBUG_INPUT,
820+
"[touchpad] smooth scroll ignored (likely pointer emulated), source='%s' source_type=%d",
821+
device ? gdk_device_get_name(device) : "<none>",
822+
device ? gdk_device_get_source(device) : -1);
791823
return TRUE;
824+
}
792825

793826
delta_x *= DT_UI_SCROLL_SMOOTH_DELTA_SCALE;
794827
delta_y *= DT_UI_SCROLL_SMOOTH_DELTA_SCALE;
795828
if((delta_x != 0.0 || delta_y != 0.0)
796829
&& dt_view_manager_gesture_pan(darktable.view_manager, event->x, event->y,
797830
delta_x, delta_y, event->state & 0xf))
798831
{
832+
dt_print(DT_DEBUG_INPUT,
833+
"[touchpad] pan x=%.2f y=%.2f dx=%.3f dy=%.3f source='%s'",
834+
event->x, event->y, delta_x, delta_y,
835+
device ? gdk_device_get_name(device) : "<none>");
799836
gtk_widget_queue_draw(widget);
800837
return TRUE;
801838
}
839+
else if(delta_x != 0.0 || delta_y != 0.0)
840+
{
841+
dt_print(DT_DEBUG_INPUT,
842+
"[touchpad] pan not handled by current view (no gesture_pan handler?)"
843+
" dx=%.3f dy=%.3f",
844+
delta_x, delta_y);
845+
}
846+
}
847+
else if(event->direction == GDK_SCROLL_SMOOTH && !event->is_stop)
848+
{
849+
dt_print(DT_DEBUG_INPUT,
850+
"[touchpad] smooth scroll not treated as pan: enabled=%d ctrl=%d touchpad_source=%d matches_last_gesture=%d source='%s' source_type=%d",
851+
touchpad_enabled,
852+
ctrl_pressed,
853+
is_touchpad_source,
854+
matches_last_gesture_device,
855+
device ? gdk_device_get_name(device) : "<none>",
856+
device ? gdk_device_get_source(device) : -1);
802857
}
803858

804859
int delta_y;
805860
if(dt_gui_get_scroll_unit_delta(event, &delta_y))
806861
{
862+
dt_print(DT_DEBUG_INPUT,
863+
"[scroll] discrete fallback x=%.2f y=%.2f up=%d state=0x%x source='%s' source_type=%d",
864+
event->x, event->y, delta_y < 0, event->state,
865+
device ? gdk_device_get_name(device) : "<none>",
866+
device ? gdk_device_get_source(device) : -1);
807867
dt_view_manager_scrolled(darktable.view_manager, event->x, event->y,
808868
delta_y < 0,
809869
event->state & 0xf);

src/views/darkroom.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4192,25 +4192,43 @@ gboolean gesture_pinch(dt_view_t *self,
41924192
{
41934193
dt_develop_t *dev = self->data;
41944194
if(!dev) return FALSE;
4195-
(void)state;
4195+
41964196
const double pinch_step_ratio = 1.1;
41974197

41984198
static double pinch_last_scale = 0.0;
41994199

42004200
if(phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN)
42014201
{
42024202
pinch_last_scale = scale > 0.0 ? scale : 1.0;
4203+
dt_print(DT_DEBUG_INPUT,
4204+
"[darkroom pinch] begin x=%.2f y=%.2f scale=%.6f state=0x%x last=%.6f",
4205+
x, y, scale, state, pinch_last_scale);
42034206
return TRUE;
42044207
}
42054208
else if(phase == GDK_TOUCHPAD_GESTURE_PHASE_END
42064209
|| phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL)
42074210
{
4211+
dt_print(DT_DEBUG_INPUT,
4212+
"[darkroom pinch] end/cancel phase=%d x=%.2f y=%.2f scale=%.6f state=0x%x",
4213+
phase, x, y, scale, state);
42084214
pinch_last_scale = 0.0;
42094215
return TRUE;
42104216
}
42114217

4212-
if(phase != GDK_TOUCHPAD_GESTURE_PHASE_UPDATE) return FALSE;
4213-
if(pinch_last_scale <= 0.0 || scale <= 0.0) return FALSE;
4218+
if(phase != GDK_TOUCHPAD_GESTURE_PHASE_UPDATE)
4219+
{
4220+
dt_print(DT_DEBUG_INPUT,
4221+
"[darkroom pinch] ignored phase=%d x=%.2f y=%.2f scale=%.6f state=0x%x",
4222+
phase, x, y, scale, state);
4223+
return FALSE;
4224+
}
4225+
if(pinch_last_scale <= 0.0 || scale <= 0.0)
4226+
{
4227+
dt_print(DT_DEBUG_INPUT,
4228+
"[darkroom pinch] invalid scale update last=%.6f scale=%.6f",
4229+
pinch_last_scale, scale);
4230+
return FALSE;
4231+
}
42144232

42154233
const double ratio = scale / pinch_last_scale;
42164234
int zoom_step = -1;
@@ -4221,9 +4239,18 @@ gboolean gesture_pinch(dt_view_t *self,
42214239

42224240
if(zoom_step >= 0)
42234241
{
4242+
dt_print(DT_DEBUG_INPUT,
4243+
"[darkroom pinch] zoom step=%d x=%.2f y=%.2f ratio=%.6f scale=%.6f last=%.6f",
4244+
zoom_step, x, y, ratio, scale, pinch_last_scale);
42244245
dt_dev_zoom_move(&dev->full, DT_ZOOM_SCROLL, 0.0f, zoom_step, x, y, FALSE);
42254246
pinch_last_scale = scale;
42264247
}
4248+
else
4249+
{
4250+
dt_print(DT_DEBUG_INPUT,
4251+
"[darkroom pinch] below threshold ratio=%.6f scale=%.6f last=%.6f",
4252+
ratio, scale, pinch_last_scale);
4253+
}
42274254

42284255
return TRUE;
42294256
}

0 commit comments

Comments
 (0)