app: fix drag'n drop of fg/bg colors under Wayland.
Commit 086ae77929 had broken dnd of colors from toolbox's color area on
Wayland. Clearly Wayland did not like we changed focus on a click,
breaking the drag.
To fix this, do not propagate button press and release events from the
GimpFgBgEditor editor anymore. Yet, since changing colors is usually to
be used (often immediately) on the canvas, giving back the focus to
canvas still makes sense. Therefore, instead of using press/release
events, add semantic signals to GimpFgBgEditor: color-dropped,
colors-swapped and colors-default (additionally to already existing
color-clicked). Then connect to these new signals to grab focus for
canvas when relevant.
Thanks to Massimo for raising the broken color dnd feature.
This commit is contained in:
parent
78d9f9799f
commit
d4733e5b21
3 changed files with 72 additions and 9 deletions
|
|
@ -57,6 +57,9 @@ enum
|
|||
enum
|
||||
{
|
||||
COLOR_CLICKED,
|
||||
COLOR_DROPPED,
|
||||
COLORS_SWAPPED,
|
||||
COLORS_DEFAULT,
|
||||
TOOLTIP,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
|
@ -145,6 +148,31 @@ gimp_fg_bg_editor_class_init (GimpFgBgEditorClass *klass)
|
|||
G_TYPE_NONE, 1,
|
||||
GIMP_TYPE_ACTIVE_COLOR);
|
||||
|
||||
editor_signals[COLOR_DROPPED] =
|
||||
g_signal_new ("color-dropped",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpFgBgEditorClass, color_dropped),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
GIMP_TYPE_ACTIVE_COLOR);
|
||||
|
||||
editor_signals[COLORS_SWAPPED] =
|
||||
g_signal_new ("colors-swapped",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpFgBgEditorClass, colors_swapped),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
editor_signals[COLORS_DEFAULT] =
|
||||
g_signal_new ("colors-default",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpFgBgEditorClass, colors_default),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
editor_signals[TOOLTIP] =
|
||||
g_signal_new ("tooltip",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
|
@ -512,12 +540,18 @@ gimp_fg_bg_editor_button_press (GtkWidget *widget,
|
|||
|
||||
case GIMP_FG_BG_TARGET_SWAP:
|
||||
if (editor->context)
|
||||
gimp_context_swap_colors (editor->context);
|
||||
{
|
||||
gimp_context_swap_colors (editor->context);
|
||||
g_signal_emit (editor, editor_signals[COLORS_SWAPPED], 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case GIMP_FG_BG_TARGET_DEFAULT:
|
||||
if (editor->context)
|
||||
gimp_context_set_default_colors (editor->context);
|
||||
{
|
||||
gimp_context_set_default_colors (editor->context);
|
||||
g_signal_emit (editor, editor_signals[COLORS_DEFAULT], 0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -525,7 +559,7 @@ gimp_fg_bg_editor_button_press (GtkWidget *widget,
|
|||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -561,7 +595,7 @@ gimp_fg_bg_editor_button_release (GtkWidget *widget,
|
|||
editor->click_target = GIMP_FG_BG_TARGET_INVALID;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -729,10 +763,14 @@ gimp_fg_bg_editor_drop_color (GtkWidget *widget,
|
|||
{
|
||||
case GIMP_FG_BG_TARGET_FOREGROUND:
|
||||
gimp_context_set_foreground (editor->context, color);
|
||||
g_signal_emit (editor, editor_signals[COLOR_DROPPED], 0,
|
||||
GIMP_ACTIVE_COLOR_FOREGROUND);
|
||||
break;
|
||||
|
||||
case GIMP_FG_BG_TARGET_BACKGROUND:
|
||||
gimp_context_set_background (editor->context, color);
|
||||
g_signal_emit (editor, editor_signals[COLOR_DROPPED], 0,
|
||||
GIMP_ACTIVE_COLOR_BACKGROUND);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -68,12 +68,16 @@ struct _GimpFgBgEditorClass
|
|||
|
||||
/* signals */
|
||||
|
||||
void (* color_clicked) (GimpFgBgEditor *editor,
|
||||
GimpActiveColor color);
|
||||
void (* color_clicked) (GimpFgBgEditor *editor,
|
||||
GimpActiveColor color);
|
||||
void (* color_dropped) (GimpFgBgEditor *editor,
|
||||
GimpActiveColor color);
|
||||
void (* colors_swapped) (GimpFgBgEditor *editor);
|
||||
void (* colors_default) (GimpFgBgEditor *editor);
|
||||
|
||||
void (* tooltip) (GimpFgBgEditor *editor,
|
||||
GimpFgBgTarget target,
|
||||
GtkTooltip tooltip);
|
||||
void (* tooltip) (GimpFgBgEditor *editor,
|
||||
GimpFgBgTarget target,
|
||||
GtkTooltip tooltip);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdisplay.h"
|
||||
|
||||
#include "gimpaction.h"
|
||||
#include "gimpcolordialog.h"
|
||||
|
|
@ -59,6 +60,7 @@ static void color_area_dialog_update (GimpColorDialog *dialog,
|
|||
static void color_area_color_clicked (GimpFgBgEditor *editor,
|
||||
GimpActiveColor active_color,
|
||||
GimpContext *context);
|
||||
static void color_area_color_changed (GimpContext *context);
|
||||
static void color_area_tooltip (GimpFgBgEditor *editor,
|
||||
GimpFgBgTarget target,
|
||||
GtkTooltip *tooltip,
|
||||
|
|
@ -98,6 +100,15 @@ gimp_toolbox_color_area_create (GimpToolbox *toolbox,
|
|||
g_signal_connect (color_area, "color-clicked",
|
||||
G_CALLBACK (color_area_color_clicked),
|
||||
context);
|
||||
g_signal_connect_swapped (color_area, "colors-swapped",
|
||||
G_CALLBACK (color_area_color_changed),
|
||||
context);
|
||||
g_signal_connect_swapped (color_area, "colors-default",
|
||||
G_CALLBACK (color_area_color_changed),
|
||||
context);
|
||||
g_signal_connect_swapped (color_area, "color-dropped",
|
||||
G_CALLBACK (color_area_color_changed),
|
||||
context);
|
||||
|
||||
g_signal_connect (color_area, "tooltip",
|
||||
G_CALLBACK (color_area_tooltip),
|
||||
|
|
@ -198,6 +209,9 @@ color_area_dialog_update (GimpColorDialog *dialog,
|
|||
gimp_context_set_background (context, &revert_bg);
|
||||
break;
|
||||
}
|
||||
|
||||
if (gimp_context_get_display (context))
|
||||
gimp_display_grab_focus (gimp_context_get_display (context));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -263,6 +277,13 @@ color_area_color_clicked (GimpFgBgEditor *editor,
|
|||
color_dialog_active = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
color_area_color_changed (GimpContext *context)
|
||||
{
|
||||
if (gimp_context_get_display (context))
|
||||
gimp_display_grab_focus (gimp_context_get_display (context));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
accel_find_func (GtkAccelKey *key,
|
||||
GClosure *closure,
|
||||
|
|
|
|||
Loading…
Reference in a new issue