diff --git a/src/develop/blend.c b/src/develop/blend.c index 716edeb09844..8c12f0ea8167 100644 --- a/src/develop/blend.c +++ b/src/develop/blend.c @@ -504,9 +504,7 @@ void dt_develop_blend_process(dt_iop_module_t *self, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out) { - if(piece->pipe->bypass_blendif - && self->dev->gui_attached - && (self == self->dev->gui_module)) + if(piece->pipe->bypass_blendif && dt_iop_has_focus(self)) return; const dt_develop_blend_params_t *const d = piece->blendop_data; @@ -545,10 +543,7 @@ void dt_develop_blend_process(dt_iop_module_t *self, return; } - const gboolean valid_request = - self->dev->gui_attached - && (self == self->dev->gui_module) - && (piece->pipe == self->dev->full.pipe); + const gboolean valid_request = dt_iop_has_focus(self) && (piece->pipe == self->dev->full.pipe); // does user want us to display a specific channel? const dt_dev_pixelpipe_display_mask_t request_mask_display = @@ -934,9 +929,7 @@ gboolean dt_develop_blend_process_cl(dt_iop_module_t *self, const dt_iop_roi_t *roi_in, const dt_iop_roi_t *roi_out) { - if(piece->pipe->bypass_blendif - && self->dev->gui_attached - && (self == self->dev->gui_module)) + if(piece->pipe->bypass_blendif && dt_iop_has_focus(self)) return TRUE; dt_develop_blend_params_t *const d = piece->blendop_data; @@ -971,10 +964,7 @@ gboolean dt_develop_blend_process_cl(dt_iop_module_t *self, // only non-zero if mask_display was set by an _earlier_ module const dt_dev_pixelpipe_display_mask_t mask_display = piece->pipe->mask_display; - const gboolean valid_request = - self->dev->gui_attached - && (self == self->dev->gui_module) - && (piece->pipe == self->dev->full.pipe); + const gboolean valid_request = dt_iop_has_focus(self) && (piece->pipe == self->dev->full.pipe); // does user want us to display a specific channel? const dt_dev_pixelpipe_display_mask_t request_mask_display = diff --git a/src/develop/imageop.c b/src/develop/imageop.c index 4ef8b781d709..f7cb7351af55 100644 --- a/src/develop/imageop.c +++ b/src/develop/imageop.c @@ -2310,6 +2310,15 @@ static gboolean _presets_scroll_callback(GtkWidget *widget, return TRUE; } +gboolean dt_iop_has_focus(const dt_iop_module_t *module) +{ + return module + && module->dev + && module->dev->gui_attached + && module == module->dev->gui_module + && dt_dev_modulegroups_test_activated(darktable.develop); +} + void dt_iop_request_focus(dt_iop_module_t *module) { dt_develop_t *dev = darktable.develop; @@ -2320,8 +2329,7 @@ void dt_iop_request_focus(dt_iop_module_t *module) if(!darktable.lib->proxy.colorpicker.restrict_histogram) dt_iop_color_picker_reset(NULL, TRUE); - if(darktable.gui->reset - || (out_focus_module == module)) + if(darktable.gui->reset || (out_focus_module == module)) return; dev->gui_module = module; diff --git a/src/develop/imageop.h b/src/develop/imageop.h index c78fa5c7244a..f0c7b6d4dd34 100644 --- a/src/develop/imageop.h +++ b/src/develop/imageop.h @@ -412,6 +412,8 @@ GtkWidget *dt_iop_gui_header_button(dt_iop_module_t *module, /** requests the focus for this plugin (to draw overlays over the center image) */ void dt_iop_request_focus(dt_iop_module_t *module); +/** returns TRUE if tested module has focus */ +gboolean dt_iop_has_focus(const dt_iop_module_t *module); /** allocate and load default settings from introspection. */ void dt_iop_default_init(dt_iop_module_t *module); /** loads default settings from database. */ diff --git a/src/iop/ashift.c b/src/iop/ashift.c index c22cb6e70aba..4d74fa7097d7 100644 --- a/src/iop/ashift.c +++ b/src/iop/ashift.c @@ -4054,13 +4054,6 @@ static gboolean _get_points(dt_iop_module_t *self, return FALSE; } -// does this gui have focus? -static gboolean _gui_has_focus(dt_iop_module_t *self) -{ - return (self->dev->gui_module == self - && dt_dev_modulegroups_test_activated(darktable.develop)); -} - /* this function replaces this sentence, it calls distort_transform() for this module on the pipe if(!dt_dev_distort_transform_plus(self->dev, self->dev->preview_pipe, @@ -4154,7 +4147,7 @@ void gui_post_expose(dt_iop_module_t *self, // we draw the cropping area; we need x_off/y_off/width/height which is only available // after g->buf has been processed - if(g->buf && self->enabled && _gui_has_focus(self)) + if(g->buf && self->enabled && dt_iop_has_focus(self)) { // roi data of the preview pipe input buffer @@ -4354,7 +4347,7 @@ void gui_post_expose(dt_iop_module_t *self, if(g->fitting) return; // no structural data or visibility switched off? -> stop here - if(g->lines == NULL || !_gui_has_focus(self)) return; + if(g->lines == NULL || !dt_iop_has_focus(self)) return; // get hash value that reflects distortions from here to the end of the pixelpipe const dt_hash_t hash = dt_dev_hash_distort_plus(dev, @@ -5630,7 +5623,7 @@ void commit_params(dt_iop_module_t *self, d->orthocorr = (p->mode == ASHIFT_MODE_GENERIC) ? 0.0f : p->orthocorr; d->aspect = (p->mode == ASHIFT_MODE_GENERIC) ? 1.0f : p->aspect; - if(_gui_has_focus(self) + if(dt_iop_has_focus(self) || dt_isnan(p->cl) || dt_isnan(p->cr) || dt_isnan(p->ct) diff --git a/src/iop/clipping.c b/src/iop/clipping.c index 83cba2e4dcb7..13fcc7b550dd 100644 --- a/src/iop/clipping.c +++ b/src/iop/clipping.c @@ -391,12 +391,6 @@ dt_iop_colorspace_type_t default_colorspace(dt_iop_module_t *self, return IOP_CS_RGB; } -static int gui_has_focus(dt_iop_module_t *self) -{ - return (self->dev->gui_module == self - && dt_dev_modulegroups_test_activated(darktable.develop)); -} - static void keystone_get_matrix(const dt_boundingbox_t k_space, float kxa, float kxb, float kxc, float kxd, float kya, float kyb, float kyc, float kyd, float *a, float *b, float *d, float *e, float *g, float *h) @@ -1328,7 +1322,7 @@ void commit_params(dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_ d->k_apply = 0; } - if(gui_has_focus(self)) + if(dt_iop_has_focus(self)) { d->cx = 0.0f; d->cy = 0.0f; diff --git a/src/iop/colorequal.c b/src/iop/colorequal.c index c528a7d4d446..ca9e3c8e7330 100644 --- a/src/iop/colorequal.c +++ b/src/iop/colorequal.c @@ -2537,7 +2537,7 @@ static gboolean _iop_colorequalizer_draw(GtkWidget *widget, dt_free_align(g->LUT); - if(self->enabled && (self == self->dev->gui_module) && g->picking) + if(self->enabled && dt_iop_has_focus(self) && g->picking) _draw_color_picker(self, cr, p, g, (double)graph_width, (double)graph_height); cairo_restore(cr); diff --git a/src/iop/colorzones.c b/src/iop/colorzones.c index 7f78185af822..d2649b95ff76 100644 --- a/src/iop/colorzones.c +++ b/src/iop/colorzones.c @@ -585,8 +585,9 @@ void process(dt_iop_module_t *self, // display selection if requested if((piece->pipe->type & DT_DEV_PIXELPIPE_FULL) && g - && g->display_mask && self->dev->gui_attached - && (self == self->dev->gui_module) && (piece->pipe == self->dev->full.pipe)) + && g->display_mask + && dt_iop_has_focus(self) + && (piece->pipe == self->dev->full.pipe)) process_display(self, piece, ivoid, ovoid, roi_in, roi_out); else if(d->mode == DT_IOP_COLORZONES_MODE_SMOOTH) process_v3(self, piece, ivoid, ovoid, roi_in, roi_out); diff --git a/src/iop/crop.c b/src/iop/crop.c index 07e065c8a32a..4a500d614cb1 100644 --- a/src/iop/crop.c +++ b/src/iop/crop.c @@ -166,12 +166,6 @@ dt_iop_colorspace_type_t default_colorspace(dt_iop_module_t *self, return IOP_CS_RGB; } -static int _gui_has_focus(dt_iop_module_t *self) -{ - return (self->dev->gui_module == self - && dt_dev_modulegroups_test_activated(darktable.develop)); -} - static void _commit_box(dt_iop_module_t *self, dt_iop_crop_gui_data_t *g, dt_iop_crop_params_t *p) @@ -421,7 +415,7 @@ void commit_params(dt_iop_module_t *self, dt_iop_crop_params_t *p = (dt_iop_crop_params_t *)p1; dt_iop_crop_data_t *d = piece->data; - if(_gui_has_focus(self) && (pipe->type & DT_DEV_PIXELPIPE_BASIC)) + if(dt_iop_has_focus(self) && (pipe->type & DT_DEV_PIXELPIPE_BASIC)) { d->cx = 0.0f; d->cy = 0.0f; diff --git a/src/iop/retouch.c b/src/iop/retouch.c index 9105e1c34b05..5d78670a4905 100644 --- a/src/iop/retouch.c +++ b/src/iop/retouch.c @@ -3860,9 +3860,7 @@ void process(dt_iop_module_t *self, retouch_user_data_t usr_data = { 0 }; dwt_params_t *dwt_p = NULL; - const int gui_active = (self->dev) ? (self == self->dev->gui_module) : 0; - const gboolean display_wavelet_scale = - (g && gui_active) ? g->display_wavelet_scale : FALSE; + const gboolean display_wavelet_scale = g && dt_iop_has_focus(self) ? g->display_wavelet_scale : FALSE; // we will do all the clone, heal, etc on the input image, // this way the source for one algorithm can be the destination from a previous one @@ -3881,8 +3879,7 @@ void process(dt_iop_module_t *self, usr_data.mask_display = FALSE; usr_data.suppress_mask = (g && g->suppress_mask - && self->dev->gui_attached - && (self == self->dev->gui_module) + && dt_iop_has_focus(self) && (piece->pipe == self->dev->full.pipe)); usr_data.display_scale = p->curr_scale; @@ -3898,8 +3895,8 @@ void process(dt_iop_module_t *self, // check if this module should expose mask. if((piece->pipe->type & DT_DEV_PIXELPIPE_FULL) && g - && (g->mask_display || display_wavelet_scale) && self->dev->gui_attached - && (self == self->dev->gui_module) && (piece->pipe == self->dev->full.pipe)) + && (g->mask_display || display_wavelet_scale) + && dt_iop_has_focus(self) && (piece->pipe == self->dev->full.pipe)) { for(size_t j = 0; j < (size_t)roi_rt->width * roi_rt->height * 4; j += 4) in_retouch[j + 3] = 0.f; @@ -3913,7 +3910,7 @@ void process(dt_iop_module_t *self, if(piece->pipe->type & DT_DEV_PIXELPIPE_FULL) { // check if the image support this number of scales - if(gui_active) + if(dt_iop_has_focus(self)) { const int max_scales = dwt_get_max_scale(dwt_p); if(dwt_p->scales > max_scales) @@ -4671,8 +4668,7 @@ int process_cl(dt_iop_module_t *self, retouch_user_data_t usr_data = { 0 }; dwt_params_cl_t *dwt_p = NULL; - const gboolean gui_active = (self->dev) ? (self == self->dev->gui_module) : FALSE; - const gboolean display_wavelet_scale = g && gui_active ? g->display_wavelet_scale : FALSE; + const gboolean display_wavelet_scale = g && dt_iop_has_focus(self) ? g->display_wavelet_scale : FALSE; // we will do all the clone, heal, etc on the input image, this way // the source for one algorithm can be the destination from a @@ -4696,8 +4692,7 @@ int process_cl(dt_iop_module_t *self, usr_data.mask_display = FALSE; usr_data.suppress_mask = (g && g->suppress_mask - && self->dev->gui_attached - && (self == self->dev->gui_module) + && dt_iop_has_focus(self) && (piece->pipe == self->dev->full.pipe)); usr_data.display_scale = p->curr_scale; @@ -4718,8 +4713,7 @@ int process_cl(dt_iop_module_t *self, // check if this module should expose mask. if((piece->pipe->type & DT_DEV_PIXELPIPE_FULL) && g && g->mask_display - && self->dev->gui_attached - && (self == self->dev->gui_module) + && dt_iop_has_focus(self) && (piece->pipe == self->dev->full.pipe)) { const int kernel = gd->kernel_retouch_clear_alpha; @@ -4738,7 +4732,7 @@ int process_cl(dt_iop_module_t *self, if(piece->pipe->type & DT_DEV_PIXELPIPE_FULL) { // check if the image support this number of scales - if(gui_active) + if(dt_iop_has_focus(self)) { const int max_scales = dwt_get_max_scale_cl(dwt_p); if(dwt_p->scales > max_scales)