Commit 3ff5cee9 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added enum GimpMotionMode which can be one of { EXACT, HINT, COMPRESS }.

2002-03-19  Michael Natterer  <mitch@gimp.org>

	* app/tools/tools-types.h: added enum GimpMotionMode which can be
	one of { EXACT, HINT, COMPRESS }.

	* app/tools/gimptool.[ch]: removed tool->perfectmouse and added
	tool->motion_mode. Default to GIMP_MOTION_MODE_HINT.

	* app/tools/gimpinktool.c
	* app/tools/gimppainttool.c: set GIMP_MOTION_MODE_EXACT.

	* app/tools/gimpfuzzyselecttool.c: set GIMP_MOTION_MODE_COMPRESS.

	* app/tools/gimpeditselectiontool.[ch]: ditto. Removed
	gtkutil_compress_motion().

	* app/display/gimpdisplayshell-callbacks.c: look at
	active_tool->motion_mode and perform pointer grabbing and motion
	compression accordingly. Also, don't request motion hints from
	XInput devices because the wacom driver sends crap (fixes #6901).
	This change also brings hints and ordinary motions back in sync
	albeit compression, so IMHO it also fixes #68542 and #22375, but
	this needs further investigation.
parent 1963320e
2002-03-19 Michael Natterer <mitch@gimp.org>
* app/tools/tools-types.h: added enum GimpMotionMode which can be
one of { EXACT, HINT, COMPRESS }.
* app/tools/gimptool.[ch]: removed tool->perfectmouse and added
tool->motion_mode. Default to GIMP_MOTION_MODE_HINT.
* app/tools/gimpinktool.c
* app/tools/gimppainttool.c: set GIMP_MOTION_MODE_EXACT.
* app/tools/gimpfuzzyselecttool.c: set GIMP_MOTION_MODE_COMPRESS.
* app/tools/gimpeditselectiontool.[ch]: ditto. Removed
gtkutil_compress_motion().
* app/display/gimpdisplayshell-callbacks.c: look at
active_tool->motion_mode and perform pointer grabbing and motion
compression accordingly. Also, don't request motion hints from
XInput devices because the wacom driver sends crap (fixes #6901).
This change also brings hints and ordinary motions back in
sync albeit compression, so IMHO it also fixes #68542 and #22375,
but this needs further investigation.
2002-03-18 Sven Neumann <sven@gimp.org>
 
* app/widgets/Makefile.am
......
......@@ -93,6 +93,9 @@ static void gimp_display_shell_origin_menu_position (GtkMenu *menu,
gint *y,
gpointer data);
GdkEvent * gimp_display_shell_compress_motion (GimpDisplayShell *shell);
/* public functions */
gboolean
......@@ -427,7 +430,15 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case 1:
state |= GDK_BUTTON1_MASK;
if (active_tool->perfectmouse && gimprc.perfectmouse)
if (((active_tool->motion_mode == GIMP_MOTION_MODE_EXACT) &&
gimprc.perfectmouse) ||
/* don't request motion hins for XInput devices because
* the wacom driver is known to report crappy hints
* (#6901) --mitch
*/
(gimp_devices_get_current (gimage->gimp) !=
gdk_device_get_core_pointer ()))
{
gdk_pointer_grab (canvas->window, FALSE,
GDK_BUTTON1_MOTION_MASK |
......@@ -668,6 +679,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_MOTION_NOTIFY:
{
GdkEventMotion *mevent;
GdkEvent *compressed_motion = NULL;
GimpTool *active_tool;
mevent = (GdkEventMotion *) event;
......@@ -675,6 +687,39 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (gimage->gimp->busy)
return TRUE;
active_tool = tool_manager_get_active (gimage->gimp);
switch (active_tool->motion_mode)
{
case GIMP_MOTION_MODE_EXACT:
case GIMP_MOTION_MODE_HINT:
break;
case GIMP_MOTION_MODE_COMPRESS:
compressed_motion = gimp_display_shell_compress_motion (shell);
break;
}
if (compressed_motion)
{
g_print ("gimp_display_shell_compress_motion() returned an event\n");
gimp_display_shell_get_coords (shell, compressed_motion,
gimp_devices_get_current (gimage->gimp),
&display_coords);
gimp_display_shell_get_state (shell, compressed_motion,
gimp_devices_get_current (gimage->gimp),
&state);
time = gdk_event_get_time (event);
image_coords = display_coords;
/* GimpCoords passed to tools are ALWAYS in image coordinates */
gimp_display_shell_untransform_coords (shell,
&display_coords,
&image_coords);
}
/* Ask for the pointer position, but ignore it except for cursor
* handling, so motion events sync with the button press/release events
*/
......@@ -693,8 +738,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
gimp_display_shell_check_device_cursor (shell);
}
active_tool = tool_manager_get_active (gimage->gimp);
if (state & GDK_BUTTON1_MASK)
{
if (active_tool &&
......@@ -1325,3 +1368,62 @@ gimp_display_shell_origin_menu_position (GtkMenu *menu,
if (*y + GTK_WIDGET (menu)->allocation.height > gdk_screen_height ())
*y -= (GTK_WIDGET (menu)->allocation.height);
}
/* gimp_display_shell_compress_motion:
*
* This function walks the whole GDK event queue seeking motion events
* corresponding to the widget 'widget'. If it finds any it will
* remove them from the queue, and return the most recent motion event.
* Otherwise it will return NULL.
*
* The gimp_display_shell_compress_motion function source may be re-used under
* the XFree86-style license. <adam@gimp.org>
*/
GdkEvent *
gimp_display_shell_compress_motion (GimpDisplayShell *shell)
{
GdkEvent *event;
GList *requeued_events = NULL;
GList *list;
GdkEvent *last_motion = NULL;
/* Move the entire GDK event queue to a private list, filtering
* out any motion events for the desired widget.
*/
while (gdk_events_pending ())
{
event = gdk_event_get ();
if (!event)
{
/* Do nothing */
}
else if ((gtk_get_event_widget (event) == shell->canvas) &&
(event->any.type == GDK_MOTION_NOTIFY))
{
if (last_motion)
gdk_event_free (last_motion);
last_motion = event;
}
else
{
requeued_events = g_list_prepend (requeued_events, event);
}
}
/* Replay the remains of our private event list back into the
* event queue in order.
*/
requeued_events = g_list_reverse (requeued_events);
for (list = requeued_events; list; list = g_list_next (list))
{
gdk_event_put ((GdkEvent*) list->data);
gdk_event_free ((GdkEvent*) list->data);
}
g_list_free (requeued_events);
return last_motion;
}
......@@ -321,8 +321,8 @@ gimp_ink_tool_init (GimpInkTool *ink_tool)
tool = GIMP_TOOL (ink_tool);
tool->perfectmouse = TRUE;
tool->tool_cursor = GIMP_INK_TOOL_CURSOR;
tool->motion_mode = GIMP_MOTION_MODE_EXACT;
tool->tool_cursor = GIMP_INK_TOOL_CURSOR;
}
static void
......
......@@ -157,7 +157,7 @@ gimp_paint_tool_init (GimpPaintTool *paint_tool)
tool = GIMP_TOOL (paint_tool);
tool->perfectmouse = TRUE;
tool->motion_mode = GIMP_MOTION_MODE_EXACT;
paint_tool->pick_colors = FALSE;
paint_tool->pick_state = FALSE;
......
......@@ -95,7 +95,7 @@ struct _GimpEditSelectionToolClass
};
static GType gimp_edit_selection_tool_get_type (void);
static GType gimp_edit_selection_tool_get_type (void) G_GNUC_CONST;
static void gimp_edit_selection_tool_class_init (GimpEditSelectionToolClass *klass);
static void gimp_edit_selection_tool_init (GimpEditSelectionTool *edit_selection_tool);
......@@ -123,7 +123,7 @@ static void gimp_edit_selection_tool_draw (GimpDrawTool *tool);
static GimpDrawToolClass *parent_class = NULL;
GType
static GType
gimp_edit_selection_tool_get_type (void)
{
static GType tool_type = 0;
......@@ -178,6 +178,7 @@ gimp_edit_selection_tool_init (GimpEditSelectionTool *edit_selection_tool)
tool->scroll_lock = EDIT_SELECT_SCROLL_LOCK;
tool->auto_snap_to = FALSE;
tool->motion_mode = GIMP_MOTION_MODE_COMPRESS;
edit_selection_tool->origx = 0;
edit_selection_tool->origy = 0;
......@@ -404,7 +405,7 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
{
GimpEditSelectionTool *edit_select;
GimpDisplayShell *shell;
gdouble lastmotion_x, lastmotion_y;
gdouble motion_x, motion_y;
edit_select = GIMP_EDIT_SELECTION_TOOL (tool);
......@@ -420,34 +421,22 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
/* Perform motion compression so that we don't lag and/or waste time. */
if (gtkutil_compress_motion (shell->canvas,
&lastmotion_x,
&lastmotion_y))
{
gdisplay_untransform_coords_f (gdisp,
lastmotion_x, lastmotion_y,
&lastmotion_x, &lastmotion_y,
TRUE);
}
else
{
gint off_x, off_y;
{
gint off_x, off_y;
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
&off_x, &off_y);
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
&off_x, &off_y);
lastmotion_x = coords->x - off_x;
lastmotion_y = coords->y - off_y;
}
motion_x = coords->x - off_x;
motion_y = coords->y - off_y;
}
/* now do the actual move. */
gimp_edit_selection_tool_snap (edit_select,
gdisp,
RINT (lastmotion_x),
RINT (lastmotion_y));
RINT (motion_x),
RINT (motion_y));
/******************************************* adam's live move *******/
/********************************************************************/
......@@ -954,68 +943,3 @@ gimp_edit_selection_tool_arrow_key (GimpTool *tool,
undo_push_group_end (gdisp->gimage);
gdisplays_flush ();
}
/* gtkutil_compress_motion:
*
* This function walks the whole GDK event queue seeking motion events
* corresponding to the widget 'widget'. If it finds any it will
* remove them from the queue, write the most recent motion offset
* to 'lastmotion_x' and 'lastmotion_y', then return TRUE. Otherwise
* it will return FALSE and 'lastmotion_x' / 'lastmotion_y' will be
* untouched.
*/
/* The gtkutil_compress_motion function source may be re-used under
* the XFree86-style license. <adam@gimp.org>
*/
gboolean
gtkutil_compress_motion (GtkWidget *widget,
gdouble *lastmotion_x,
gdouble *lastmotion_y)
{
GdkEvent *event;
GList *requeued_events = NULL;
GList *list;
gboolean success = FALSE;
/* Move the entire GDK event queue to a private list, filtering
* out any motion events for the desired widget. */
while (gdk_events_pending ())
{
event = gdk_event_get ();
if (!event)
{
/* Do nothing */
}
else if ((gtk_get_event_widget (event) == widget) &&
(event->any.type == GDK_MOTION_NOTIFY))
{
*lastmotion_x = event->motion.x;
*lastmotion_y = event->motion.y;
gdk_event_free (event);
success = TRUE;
}
else
{
requeued_events = g_list_prepend (requeued_events, event);
}
}
/* Replay the remains of our private event list back into the
event queue in order. */
requeued_events = g_list_reverse (requeued_events);
for (list = requeued_events; list; list = g_list_next (list))
{
gdk_event_put ((GdkEvent*) list->data);
gdk_event_free ((GdkEvent*) list->data);
}
g_list_free (requeued_events);
return success;
}
......@@ -39,9 +39,5 @@ void gimp_edit_selection_tool_arrow_key (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
gboolean gtkutil_compress_motion (GtkWidget *widget,
gdouble *lastmotion_x,
gdouble *lastmotion_y);
#endif /* __GIMP_EDIT_SELECTION_TOOL_H__ */
......@@ -169,7 +169,8 @@ gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select)
select_tool = GIMP_SELECTION_TOOL (fuzzy_select);
tool->tool_cursor = GIMP_FUZZY_SELECT_TOOL_CURSOR;
tool->scroll_lock = TRUE; /* Do not allow scrolling */
tool->scroll_lock = TRUE;
tool->motion_mode = GIMP_MOTION_MODE_COMPRESS;
fuzzy_select->fuzzy_mask = NULL;
fuzzy_select->x = 0;
......@@ -191,6 +192,8 @@ gimp_fuzzy_select_tool_finalize (GObject *object)
g_object_unref (G_OBJECT (fuzzy_sel->fuzzy_mask));
fuzzy_sel->fuzzy_mask = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
......
......@@ -321,8 +321,8 @@ gimp_ink_tool_init (GimpInkTool *ink_tool)
tool = GIMP_TOOL (ink_tool);
tool->perfectmouse = TRUE;
tool->tool_cursor = GIMP_INK_TOOL_CURSOR;
tool->motion_mode = GIMP_MOTION_MODE_EXACT;
tool->tool_cursor = GIMP_INK_TOOL_CURSOR;
}
static void
......
......@@ -157,7 +157,7 @@ gimp_paint_tool_init (GimpPaintTool *paint_tool)
tool = GIMP_TOOL (paint_tool);
tool->perfectmouse = TRUE;
tool->motion_mode = GIMP_MOTION_MODE_EXACT;
paint_tool->pick_colors = FALSE;
paint_tool->pick_state = FALSE;
......
......@@ -169,7 +169,8 @@ gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select)
select_tool = GIMP_SELECTION_TOOL (fuzzy_select);
tool->tool_cursor = GIMP_FUZZY_SELECT_TOOL_CURSOR;
tool->scroll_lock = TRUE; /* Do not allow scrolling */
tool->scroll_lock = TRUE;
tool->motion_mode = GIMP_MOTION_MODE_COMPRESS;
fuzzy_select->fuzzy_mask = NULL;
fuzzy_select->x = 0;
......@@ -191,6 +192,8 @@ gimp_fuzzy_select_tool_finalize (GObject *object)
g_object_unref (G_OBJECT (fuzzy_sel->fuzzy_mask));
fuzzy_sel->fuzzy_mask = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
......
......@@ -142,7 +142,7 @@ gimp_tool_init (GimpTool *tool)
tool->auto_snap_to = TRUE; /* Snap to guides */
tool->preserve = TRUE; /* Preserve across drawable change */
tool->handle_empty_image = FALSE; /* Require active drawable */
tool->perfectmouse = FALSE; /* Use MOTION_HINT compression */
tool->motion_mode = GIMP_MOTION_MODE_HINT;
tool->cursor = GIMP_MOUSE_CURSOR;
tool->tool_cursor = GIMP_TOOL_CURSOR_NONE;
......
......@@ -59,8 +59,8 @@ struct _GimpTool
* changes */
gboolean handle_empty_image; /* invoke the tool on images without *
* active drawable */
gboolean perfectmouse; /* tool is affected by gimprc's *
* "prefectmouse" setting */
GimpMotionMode motion_mode; /* how to process motion events before *
* they are forwarded to the tool */
GdkCursorType cursor;
GimpToolCursorType tool_cursor;
......
......@@ -93,6 +93,14 @@ typedef enum /*< pdb-skip >*/
HALT
} GimpToolAction;
/* Motion event report modes */
typedef enum /*< pdb-skip >*/
{
GIMP_MOTION_MODE_EXACT,
GIMP_MOTION_MODE_HINT,
GIMP_MOTION_MODE_COMPRESS
} GimpMotionMode;
/* possible transform functions */
typedef enum /*< pdb-skip >*/
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment