Skip to content

Commit 8886d06

Browse files
committed
Make touchpad gestures optional and allow >100% zooming
This addresses #20750. * New option darkroom/ui/touchpad_gestures allows to disable touchpad based pinch zooming, it is enabled by default * Touchpad pinch zooming now is on par with old CTRL + scroll zooming by allowing to zoom beyond 100% * Previous CTRL + scroll zooming is now re-enabled for touchpads next to the gesture based pinch zooming for a happy coexistance
1 parent fa1dfd0 commit 8886d06

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

data/darktableconfig.xml.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,6 +2398,13 @@
23982398
<longdescription><![CDATA[in darktable's darkroom, where you do your edits, all controls are listed on a panel on the right; you can choose whether you want to use the scroll wheel or scroll gesture on your touchpad to scroll the panel, or to change the values of the control under the pointer; this latter modality enables faster editing, but this can be dangerous because you can change the values ​​of the module controls without noticing if you are not used to it\n\n<b>enabled:</b> the mouse wheel scrolls the modules panel and with <i>Ctrl+Alt</i> adjusts a control's value\n\n<b>disabled:</b> the mouse wheel adjusts the control under the pointer and with <i>Ctrl+Alt</i> scrolls the panel.]]></longdescription>
23992399
<welcomescreen pagenum="5" questionnum="1"/>
24002400
</dtconfig>
2401+
<dtconfig prefs="misc" section="interface">
2402+
<name>darkroom/ui/touchpad_gestures</name>
2403+
<type>bool</type>
2404+
<default>true</default>
2405+
<shortdescription>enable touchpad gestures in darkroom</shortdescription>
2406+
<longdescription><![CDATA[use two-finger touchpad gestures in darkroom for panning and pinch-to-zoom. <b>enabled:</b> touchpad pinch gestures zoom the image and two-finger touchpad scrolling pans it; <i>Ctrl+scroll</i> still uses the legacy zoom behavior. <b>disabled:</b> touchpad gestures are ignored and darkroom falls back to the legacy scroll behavior, including <i>Ctrl+scroll</i> for zooming in and out.]]></longdescription>
2407+
</dtconfig>
24012408
<dtconfig prefs="darkroom" section="general">
24022409
<name>plugins/darkroom/ui/border_size</name>
24032410
<type>int</type>

src/gui/gtk.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,21 @@ static gboolean _draw(GtkWidget *da,
726726
}
727727

728728
static GdkDevice *_touchpad = NULL;
729+
static gboolean _touchpad_gestures_enabled(void)
730+
{
731+
// If conf_gen.h was built before darktableconfig.xml.in gained this key
732+
// (incremental build without cmake reconfigure), dt_confgen_value_exists
733+
// returns FALSE and dt_conf_get_bool gets an empty string → FALSE.
734+
// Default to enabled in that case so a stale build doesn't silently break gestures.
735+
if(!dt_confgen_value_exists("darkroom/ui/touchpad_gestures", DT_DEFAULT))
736+
{
737+
dt_print(DT_DEBUG_INPUT,
738+
"[touchpad] 'darkroom/ui/touchpad_gestures' missing from confgen"
739+
" (stale conf_gen.h — run cmake reconfigure), defaulting to enabled");
740+
return TRUE;
741+
}
742+
return dt_conf_get_bool("darkroom/ui/touchpad_gestures");
743+
}
729744

730745
static gboolean _input_event(GtkWidget *widget,
731746
GdkEvent *event,
@@ -744,6 +759,7 @@ static gboolean _input_event(GtkWidget *widget,
744759
}
745760

746761
if(event->type == GDK_TOUCHPAD_PINCH)
762+
if(event->type == GDK_TOUCHPAD_PINCH && _touchpad_gestures_enabled())
747763
{
748764
const GdkEventTouchpadPinch *pinch = &event->touchpad_pinch;
749765
if(dt_view_manager_gesture_pinch(darktable.view_manager, pinch->x, pinch->y,
@@ -764,8 +780,10 @@ static gboolean _scrolled(GtkWidget *widget,
764780
(void)user_data;
765781
GdkDevice *device = gdk_event_get_source_device((GdkEvent *)event);
766782

767-
if(((device && gdk_device_get_source(device) == GDK_SOURCE_TOUCHPAD)
768-
|| device == _touchpad)
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)
769787
&& event->direction == GDK_SCROLL_SMOOTH && !event->is_stop)
770788
{
771789
gdouble delta_x = 0.0, delta_y = 0.0;

src/views/darkroom.c

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

41984198
static double pinch_last_scale = 0.0;
@@ -4221,7 +4221,7 @@ gboolean gesture_pinch(dt_view_t *self,
42214221

42224222
if(zoom_step >= 0)
42234223
{
4224-
dt_dev_zoom_move(&dev->full, DT_ZOOM_SCROLL, 0.0f, zoom_step, x, y, constrained);
4224+
dt_dev_zoom_move(&dev->full, DT_ZOOM_SCROLL, 0.0f, zoom_step, x, y, FALSE);
42254225
pinch_last_scale = scale;
42264226
}
42274227

0 commit comments

Comments
 (0)