Skip to content

Commit

Permalink
prevent tooltip over filter range popover
Browse files Browse the repository at this point in the history
+ fix hiding popups (shift+t) under WSL2
+ hide popups when pressing any modifier
  • Loading branch information
dterrahe committed Aug 26, 2024
1 parent ecb9c4d commit f7a835e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/control/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ static void _dt_ctl_switch_mode_prepare()
{
darktable.control->button_down = 0;
darktable.control->button_down_which = 0;
darktable.gui->center_tooltip = 0;
GtkWidget *widget = dt_ui_center(darktable.gui->ui);
gtk_widget_set_tooltip_text(widget, "");
gtk_widget_grab_focus(widget);
Expand Down
2 changes: 2 additions & 0 deletions src/dtgtk/range.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,13 +589,15 @@ static void _current_set_text(GtkDarktableRangeSelect *range, const double curre
static void _current_hide_popup(GtkDarktableRangeSelect *range)
{
if(!range->cur_window) return;
darktable.gui->hide_tooltips--;
gtk_widget_destroy(range->cur_window);
range->cur_window = NULL;
}

static void _current_show_popup(GtkDarktableRangeSelect *range)
{
if(range->cur_window) return;
darktable.gui->hide_tooltips++;
range->cur_window = gtk_popover_new(range->band);
gtk_widget_set_name(range->cur_window, "range-current");
gtk_popover_set_modal(GTK_POPOVER(range->cur_window), FALSE);
Expand Down
6 changes: 4 additions & 2 deletions src/gui/accelerators.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,8 +987,10 @@ gboolean dt_shortcut_tooltip_callback(GtkWidget *widget,
&& gtk_window_get_window_type(top) != GTK_WINDOW_POPUP)
return FALSE;

if(dt_key_modifier_state() & (GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK)
|| darktable.bauhaus->current)
if(dt_key_modifier_state() & (GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK
|GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_MOD1_MASK)
|| darktable.bauhaus->current
|| darktable.gui->hide_tooltips)
return FALSE;

gchar *markup_text = NULL;
Expand Down
25 changes: 5 additions & 20 deletions src/gui/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,25 +180,10 @@ static void _fullscreen_key_accel_callback(dt_action_t *action)

static void _toggle_tooltip_visibility(dt_action_t *action)
{
if(gdk_screen_is_composited(gdk_screen_get_default()))
{
gboolean tooltip_hidden = !dt_conf_get_bool("ui/hide_tooltips");
dt_conf_set_bool("ui/hide_tooltips", tooltip_hidden);
if(tooltip_hidden)
dt_toast_log(_("tooltips off"));
else
dt_toast_log(_("tooltips on"));
}
else
{
dt_conf_set_bool("ui/hide_tooltips", FALSE);
dt_control_log(_("tooltip visibility can only be toggled"
" if compositing is enabled in your window manager"));
}

const char *theme = dt_conf_get_string_const("ui_last/theme");
dt_gui_load_theme(theme);
dt_bauhaus_load_theme();
gboolean tooltip_hidden = !dt_conf_get_bool("ui/hide_tooltips");
dt_conf_set_bool("ui/hide_tooltips", tooltip_hidden);
darktable.gui->hide_tooltips += tooltip_hidden ? 1 : -1;
dt_toast_log(tooltip_hidden ? _("tooltips off") : _("tooltips on"));
}

static inline void _update_focus_peaking_button()
Expand Down Expand Up @@ -1257,7 +1242,7 @@ int dt_gui_gtk_init(dt_gui_gtk_t *gui)
GtkWidget *widget;
gui->ui = g_malloc0(sizeof(dt_ui_t));
gui->surface = NULL;
gui->center_tooltip = 0;
gui->hide_tooltips = dt_conf_get_bool("ui/hide_tooltips") ? 1 : 0;
gui->grouping = dt_conf_get_bool("ui_last/grouping");
gui->expanded_group_id = NO_IMGID;
gui->show_overlays = dt_conf_get_bool("lighttable/ui/expose_statuses");
Expand Down
2 changes: 1 addition & 1 deletion src/gui/gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ typedef struct dt_gui_gtk_t
int32_t reset;
GdkRGBA colors[DT_GUI_COLOR_LAST];

int32_t center_tooltip; // 0 = no tooltip, 1 = new tooltip, 2 = old tooltip
int32_t hide_tooltips;

gboolean grouping;
int32_t expanded_group_id;
Expand Down

0 comments on commit f7a835e

Please sign in to comment.