Commit 967d3e4e authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Removed pointer grabbing from all tools:

2002-02-05  Michael Natterer  <mitch@gimp.org>

	Removed pointer grabbing from all tools:

	* app/tools/gimptool.[ch]: added "gboolean perfectmouse" which
	defaults to FALSE but can be set to TRUE in a tool's instance_init
	function.

	* app/display/gimpdisplayshell-callbacks.c: look at
	active_tool->perfectmouse and gimprc.perfectmouse and do the
	pointer grab/ungrab here. The pointer is now grabbed right before
	dispatching the button_press to the tool and ungrabbed after
	the tool's button_release has returned. It is also grabbed
	*always*, not only if tool->state got ACTIVE by button_press,
	which makes it all much simpler...

	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpblendtool.c
	* app/tools/gimpbucketfilltool.c
	* app/tools/gimpbycolorselecttool.c
	* app/tools/gimpclonetool.c
	* app/tools/gimpcolorpickertool.c
	* app/tools/gimpcroptool.c
	* app/tools/gimpeditselectiontool.c
	* app/tools/gimpfliptool.c
	* app/tools/gimpfreeselecttool.c
	* app/tools/gimpfuzzyselecttool.c
	* app/tools/gimpinktool.c
	* app/tools/gimpiscissorstool.c
	* app/tools/gimpmagnifytool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimpmovetool.c
	* app/tools/gimppainttool.c
	* app/tools/gimppathtool.c
	* app/tools/gimprectselecttool.c
	* app/tools/gimpselectiontool.c
	* app/tools/gimptexttool.c
	* app/tools/gimptransformtool.c: removed
	gdk_pointer_grab()/ungrab() calls all over the place. Also removed
	inclusion of "display/gimpdisplayshell.h" from most of them.
parent ad327cf3
2002-02-05 Michael Natterer <mitch@gimp.org>
Removed pointer grabbing from all tools:
* app/tools/gimptool.[ch]: added "gboolean perfectmouse" which
defaults to FALSE but can be set to TRUE in a tool's instance_init
function.
* app/display/gimpdisplayshell-callbacks.c: look at
active_tool->perfectmouse and gimprc.perfectmouse and do the
pointer grab/ungrab here. The pointer is now grabbed right before
dispatching the button_press to the tool and ungrabbed after
the tool's button_release has returned. It is also grabbed
*always*, not only if tool->state got ACTIVE by button_press,
which makes it all much simpler...
* app/tools/gimpbezierselecttool.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpclonetool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpcroptool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpfliptool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimpinktool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpmagnifytool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/tools/gimppainttool.c
* app/tools/gimppathtool.c
* app/tools/gimprectselecttool.c
* app/tools/gimpselectiontool.c
* app/tools/gimptexttool.c
* app/tools/gimptransformtool.c: removed
gdk_pointer_grab()/ungrab() calls all over the place. Also removed
inclusion of "display/gimpdisplayshell.h" from most of them.
2002-02-04 Michael Natterer <mitch@gimp.org>
 
* app/tools/gimptool.[ch]: added fields for both the tool's
......
......@@ -427,7 +427,21 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case 1:
state |= GDK_BUTTON1_MASK;
gtk_grab_add (canvas);
if (active_tool->perfectmouse && gimprc.perfectmouse)
{
gdk_pointer_grab (canvas->window, FALSE,
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
}
else
{
gdk_pointer_grab (canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
}
/* save the current modifier state because tools don't get
* key events while BUTTON1 is down
......@@ -519,8 +533,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case 1:
state &= ~GDK_BUTTON1_MASK;
gtk_grab_remove (canvas);
if (active_tool && (! gimp_image_is_empty (gimage) ||
active_tool->handle_empty_image))
{
......@@ -547,6 +559,8 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
}
}
gdk_pointer_ungrab (time);
/* restore the tool's modifier state because it didn't get
* key events while BUTTON1 was down
*/
......
......@@ -42,7 +42,6 @@
#include "core/gimptoolinfo.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "gimpclonetool.h"
#include "paint_options.h"
......@@ -383,8 +382,10 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool,
else if (state == POSTTRACE_PAINT)
{
/* Find the target cursor's location onscreen */
gdisplay_transform_coords (src_gdisp, src_x, src_y,
&trans_tx, &trans_ty, 1);
gdisplay_transform_coords (src_gdisp,
src_x, src_y,
&trans_tx, &trans_ty,
TRUE);
gimp_draw_tool_resume (draw_tool);
}
}
......
......@@ -44,7 +44,6 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "gimpinktool.h"
#include "gimpinktool-blob.h"
......@@ -320,7 +319,8 @@ gimp_ink_tool_init (GimpInkTool *ink_tool)
tool = GIMP_TOOL (ink_tool);
tool->tool_cursor = GIMP_INK_TOOL_CURSOR;
tool->perfectmouse = TRUE;
tool->tool_cursor = GIMP_INK_TOOL_CURSOR;
}
static void
......@@ -374,18 +374,15 @@ gimp_ink_tool_button_press (GimpTool *tool,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpInkTool *ink_tool;
InkOptions *options;
GimpDisplayShell *shell;
GimpDrawable *drawable;
Blob *b;
GimpInkTool *ink_tool;
InkOptions *options;
GimpDrawable *drawable;
Blob *b;
ink_tool = GIMP_INK_TOOL (tool);
options = (InkOptions *) tool->tool_info->tool_options;
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
drawable = gimp_image_active_drawable (gdisp->gimage);
ink_init (ink_tool, drawable, coords->x, coords->y);
......@@ -394,26 +391,9 @@ gimp_ink_tool_button_press (GimpTool *tool,
tool->gdisp = gdisp;
tool->paused_count = 0;
/* pause the current selection and grab the pointer */
/* pause the current selection */
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE);
/* add motion memory if you press mod1 first ^ perfectmouse */
if (((state & GDK_MOD1_MASK) != 0) != (gimprc.perfectmouse != 0))
{
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
}
else
{
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
}
b = ink_pen_ellipse (options,
coords->x,
coords->y,
......@@ -449,12 +429,9 @@ gimp_ink_tool_button_release (GimpTool *tool,
gimage = gdisp->gimage;
/* resume the current selection and ungrab the pointer */
/* resume the current selection */
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME);
gdk_pointer_ungrab (time);
gdk_flush ();
/* Set tool state to inactive -- no longer painting */
tool->state = INACTIVE;
......
......@@ -257,10 +257,16 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
}
static void
gimp_paint_tool_init (GimpPaintTool *tool)
gimp_paint_tool_init (GimpPaintTool *paint_tool)
{
tool->pick_colors = FALSE;
tool->flags = 0;
GimpTool *tool;
tool = GIMP_TOOL (paint_tool);
tool->perfectmouse = TRUE;
paint_tool->pick_colors = FALSE;
paint_tool->flags = 0;
}
static void
......@@ -301,18 +307,15 @@ gimp_paint_tool_button_press (GimpTool *tool,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpPaintTool *paint_tool;
GimpDisplayShell *shell;
GimpBrush *current_brush;
gboolean draw_line;
GimpDrawable *drawable;
gdouble x, y;
gint off_x, off_y;
GimpPaintTool *paint_tool;
GimpBrush *current_brush;
gboolean draw_line;
GimpDrawable *drawable;
gdouble x, y;
gint off_x, off_y;
paint_tool = GIMP_PAINT_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
drawable = gimp_image_active_drawable (gdisp->gimage);
gimp_drawable_offsets (drawable, &off_x, &off_y);
......@@ -390,26 +393,9 @@ gimp_paint_tool_button_press (GimpTool *tool,
tool->gdisp = gdisp;
tool->paused_count = 0;
/* pause the current selection and grab the pointer */
/* pause the current selection */
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE);
/* add motion memory if perfectmouse is set */
if (gimprc.perfectmouse)
{
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
}
else
{
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
}
/* Let the specific painting function initialize itself */
gimp_paint_tool_paint (paint_tool, drawable, INIT_PAINT);
......@@ -489,12 +475,9 @@ gimp_paint_tool_button_release (GimpTool *tool,
drawable = gimp_image_active_drawable (gdisp->gimage);
/* resume the current selection and ungrab the pointer */
/* resume the current selection */
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME);
gdk_pointer_ungrab (time);
gdk_flush ();
/* Let the specific painting function finish up */
gimp_paint_tool_paint (paint_tool, drawable, FINISH_PAINT);
......@@ -576,7 +559,8 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
/* undraw the current tool */
gimp_draw_tool_pause (draw_tool);
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "paint_tool");
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar),
g_type_name (G_TYPE_FROM_INSTANCE (tool)));
if ((layer = gimp_image_get_active_layer (gdisp->gimage)))
{
......@@ -649,7 +633,8 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
g_snprintf (status_str, sizeof (status_str), format_str, d);
}
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), "paint_tool",
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
g_type_name (G_TYPE_FROM_INSTANCE (tool)),
status_str);
if (draw_tool->gc == NULL)
......
......@@ -42,7 +42,6 @@
#include "core/gimptoolinfo.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "gimpclonetool.h"
#include "paint_options.h"
......@@ -383,8 +382,10 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool,
else if (state == POSTTRACE_PAINT)
{
/* Find the target cursor's location onscreen */
gdisplay_transform_coords (src_gdisp, src_x, src_y,
&trans_tx, &trans_ty, 1);
gdisplay_transform_coords (src_gdisp,
src_x, src_y,
&trans_tx, &trans_ty,
TRUE);
gimp_draw_tool_resume (draw_tool);
}
}
......
......@@ -43,7 +43,6 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "gui/paths-dialog.h"
......@@ -375,18 +374,15 @@ gimp_bezier_select_tool_button_press (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpBezierSelectTool *bezier_sel;
GimpDisplayShell *shell;
GimpBezierSelectPoint *points;
GimpBezierSelectPoint *start_pt;
GimpBezierSelectPoint *curve_start;
gboolean grab_pointer;
gboolean grab_pointer; /* abused legacy name */
gint op;
gint halfwidth, halfheight;
bezier_sel = GIMP_BEZIER_SELECT_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
grab_pointer = FALSE;
tool->drawable = gimp_image_active_drawable (gdisp->gimage);
......@@ -454,15 +450,7 @@ gimp_bezier_select_tool_button_press (GimpTool *tool,
bezier_sel->draw_mode = BEZIER_DRAW_ALL;
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
if (grab_pointer)
{
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
}
else
if (! grab_pointer)
{
paths_dialog_set_default_op ();
......@@ -540,15 +528,8 @@ gimp_bezier_select_tool_button_press (GimpTool *tool,
bezier_sel->draw_mode = BEZIER_DRAW_ALL;
gimp_draw_tool_resume ((GimpDrawTool *)bezier_sel);
if (grab_pointer)
{
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
}
else
if (! grab_pointer)
{
paths_dialog_set_default_op ();
/* recursive call */
......@@ -709,13 +690,6 @@ gimp_bezier_select_tool_button_press (GimpTool *tool,
break;
}
if (grab_pointer)
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
/* Don't bother doing this if we don't have any points */
if (bezier_sel->num_points > 0)
paths_first_button_press (bezier_sel, gdisp);
......@@ -736,9 +710,6 @@ gimp_bezier_select_tool_button_release (GimpTool *tool,
bezier_sel->state &= ~BEZIER_DRAG;
gdk_pointer_ungrab (time);
gdk_flush ();
if (bezier_sel->closed)
bezier_convert (bezier_sel, gdisp, SUBDIVIDE, FALSE);
......@@ -2814,7 +2785,6 @@ void
bezier_paste_bezierselect_to_current (GimpDisplay *gdisp,
GimpBezierSelectTool *bsel)
{
GimpDisplayShell *shell;
GimpBezierSelectPoint *pts;
gint i;
GimpTool *tool;
......@@ -2824,8 +2794,6 @@ bezier_paste_bezierselect_to_current (GimpDisplay *gdisp,
/* g_print ("bezier_paste_bezierselect_to_current::\n"); */
/* printSel(bsel); */
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
tool = tool_manager_get_active (gdisp->gimage->gimp);
/* If the tool was being used before clear it */
......
......@@ -37,7 +37,6 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "widgets/gimpdnd.h"
......@@ -228,14 +227,11 @@ gimp_blend_tool_button_press (GimpTool *tool,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpBlendTool *blend_tool;
GimpDisplayShell *shell;
gint off_x, off_y;
GimpBlendTool *blend_tool;
gint off_x, off_y;
blend_tool = GIMP_BLEND_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
switch (gimp_drawable_type (gimp_image_active_drawable (gdisp->gimage)))
{
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
......@@ -256,12 +252,6 @@ gimp_blend_tool_button_press (GimpTool *tool,
tool->gdisp = gdisp;
tool->state = ACTIVE;
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
/* initialize the statusbar display */
gimp_tool_push_status (tool, _("Blend: 0, 0"));
......@@ -292,9 +282,6 @@ gimp_blend_tool_button_release (GimpTool *tool,
gimage = gdisp->gimage;
gdk_pointer_ungrab (time);
gdk_flush ();
gimp_tool_pop_status (tool);
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
......
......@@ -257,10 +257,16 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
}
static void
gimp_paint_tool_init (GimpPaintTool *tool)
gimp_paint_tool_init (GimpPaintTool *paint_tool)
{
tool->pick_colors = FALSE;
tool->flags = 0;
GimpTool *tool;
tool = GIMP_TOOL (paint_tool);
tool->perfectmouse = TRUE;
paint_tool->pick_colors = FALSE;
paint_tool->flags = 0;
}
static void
......@@ -301,18 +307,15 @@ gimp_paint_tool_button_press (GimpTool *tool,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpPaintTool *paint_tool;
GimpDisplayShell *shell;
GimpBrush *current_brush;
gboolean draw_line;
GimpDrawable *drawable;
gdouble x, y;
gint off_x, off_y;
GimpPaintTool *paint_tool;
GimpBrush *current_brush;
gboolean draw_line;
GimpDrawable *drawable;
gdouble x, y;
gint off_x, off_y;
paint_tool = GIMP_PAINT_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
drawable = gimp_image_active_drawable (gdisp->gimage);
gimp_drawable_offsets (drawable, &off_x, &off_y);
......@@ -390,26 +393,9 @@ gimp_paint_tool_button_press (GimpTool *tool,
tool->gdisp = gdisp;
tool->paused_count = 0;
/* pause the current selection and grab the pointer */
/* pause the current selection */
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE);
/* add motion memory if perfectmouse is set */
if (gimprc.perfectmouse)
{
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
}
else
{
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
}
/* Let the specific painting function initialize itself */
gimp_paint_tool_paint (paint_tool, drawable, INIT_PAINT);
......@@ -489,12 +475,9 @@ gimp_paint_tool_button_release (GimpTool *tool,
drawable = gimp_image_active_drawable (gdisp->gimage);
/* resume the current selection and ungrab the pointer */
/* resume the current selection */
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME);
gdk_pointer_ungrab (time);
gdk_flush ();
/* Let the specific painting function finish up */
gimp_paint_tool_paint (paint_tool, drawable, FINISH_PAINT);
......@@ -576,7 +559,8 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
/* undraw the current tool */
gimp_draw_tool_pause (draw_tool);
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "paint_tool");
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar),
g_type_name (G_TYPE_FROM_INSTANCE (tool)));
if ((layer = gimp_image_get_active_layer (gdisp->gimage)))
{
......@@ -649,7 +633,8 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
g_snprintf (status_str, sizeof (status_str), format_str, d);
}
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), "paint_tool",
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
g_type_name (G_TYPE_FROM_INSTANCE (tool)),
status_str);
if (draw_tool->gc == NULL)
......
......@@ -37,7 +37,6 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "gimpbucketfilltool.h"
#include "paint_options.h"
......@@ -184,14 +183,11 @@ gimp_bucket_fill_tool_button_press (GimpTool *tool,
{
GimpBucketFillTool *bucket_tool;
BucketOptions *options;
GimpDisplayShell *shell;
bucket_tool = GIMP_BUCKET_FILL_TOOL (tool);
options = (BucketOptions *) tool->tool_info->tool_options;
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
bucket_tool->target_x = coords->x;
bucket_tool->target_y = coords->y;
......@@ -206,13 +202,6 @@ gimp_bucket_fill_tool_button_press (GimpTool *tool,
bucket_tool->target_y -= off_y;
}
gdk_pointer_grab (shell->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
/* Make the tool active and set the gdisplay which owns it */
tool->gdisp = gdisp;
tool->state = ACTIVE;
}
......@@ -233,9 +222,6 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool,
options = (BucketOptions *) tool->tool_info->tool_options;
gdk_pointer_ungrab (time);
gdk_flush ();
/* if the 3rd button isn't pressed, fill the selected region */
if (! (state & GDK_BUTTON3_MASK))
{
......
......@@ -52,7 +52,6 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "gimpbycolorselecttool.h"
#include "selection_options.h"
......@@ -302,15 +301,12 @@ by_color_select_button_press (GimpTool *tool,
GimpByColorSelectTool *by_color_sel;
GimpDrawTool *draw_tool;
SelectionOptions *sel_options;
GimpDisplayShell *shell;
draw_tool = GIMP_DRAW_TOOL (tool);
by_color_sel = GIMP_BY_COLOR_SELECT_TOOL (tool);
sel_options = (SelectionOptions *) tool->tool_info->tool_options;