app/display/gimpdisplayshell-callbacks.c libgimpwidgets/gimpcolorselect.c

2008-09-03  Michael Natterer  <mitch@gimp.org>

	* app/display/gimpdisplayshell-callbacks.c
	* libgimpwidgets/gimpcolorselect.c
	* modules/color-selector-water.c
	* plug-ins/ifs-compose/ifs-compose.c: instead of using
	gdk_window_get_pointer() if GdkEventMotion::is_hint is TRUE,
	simply always use the coords from the event and call
	gdk_event_request_motions() to ask for more motion events. This is
	the recommended way and also works for events from devices other
	than the core pointer.

	* plug-ins/ifs-compose/ifs-compose.c (design_area_motion): some
	code cleanup while i was at it.


svn path=/trunk/; revision=26843
This commit is contained in:
Michael Natterer 2008-09-03 19:24:51 +00:00 committed by Michael Natterer
parent 5357d42ab3
commit 435f6e3974
5 changed files with 60 additions and 70 deletions

View File

@ -1,3 +1,18 @@
2008-09-03 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplayshell-callbacks.c
* libgimpwidgets/gimpcolorselect.c
* modules/color-selector-water.c
* plug-ins/ifs-compose/ifs-compose.c: instead of using
gdk_window_get_pointer() if GdkEventMotion::is_hint is TRUE,
simply always use the coords from the event and call
gdk_event_request_motions() to ask for more motion events. This is
the recommended way and also works for events from devices other
than the core pointer.
* plug-ins/ifs-compose/ifs-compose.c (design_area_motion): some
code cleanup while i was at it.
2008-09-03 Michael Natterer <mitch@gimp.org> 2008-09-03 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpbutton.c: massively simplified. Don't fiddle * libgimpwidgets/gimpbutton.c: massively simplified. Don't fiddle

View File

@ -1137,15 +1137,8 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
} }
} }
/* Ask for the pointer position, but ignore it except for cursor /* Ask for more motion events in case the event was a hint */
* handling, so motion events sync with the button press/release events gdk_event_request_motions (mevent);
*/
if (mevent->is_hint)
{
gimp_display_shell_get_device_coords (shell,
mevent->device,
&display_coords);
}
update_sw_cursor = TRUE; update_sw_cursor = TRUE;

View File

@ -667,15 +667,8 @@ gimp_color_select_xy_events (GtkWidget *widget,
case GDK_MOTION_NOTIFY: case GDK_MOTION_NOTIFY:
mevent = (GdkEventMotion *) event; mevent = (GdkEventMotion *) event;
if (mevent->is_hint) x = mevent->x;
{ y = mevent->y;
gdk_window_get_pointer (widget->window, &x, &y, NULL);
}
else
{
x = mevent->x;
y = mevent->y;
}
break; break;
default: default:
@ -700,8 +693,8 @@ gimp_color_select_xy_events (GtkWidget *widget,
gimp_color_select_update (select, UPDATE_VALUES | UPDATE_CALLER); gimp_color_select_update (select, UPDATE_VALUES | UPDATE_CALLER);
if (event->type == GDK_MOTION_NOTIFY) /* Ask for more motion events in case the event was a hint */
gdk_event_request_motions ((GdkEventMotion *) event); gdk_event_request_motions ((GdkEventMotion *) event);
return TRUE; return TRUE;
} }
@ -760,14 +753,7 @@ gimp_color_select_z_events (GtkWidget *widget,
case GDK_MOTION_NOTIFY: case GDK_MOTION_NOTIFY:
mevent = (GdkEventMotion *) event; mevent = (GdkEventMotion *) event;
if (mevent->is_hint) z = mevent->y;
{
gdk_window_get_pointer (widget->window, NULL, &z, NULL);
}
else
{
z = mevent->y;
}
break; break;
default: default:
@ -787,6 +773,9 @@ gimp_color_select_z_events (GtkWidget *widget,
gimp_color_select_update (select, gimp_color_select_update (select,
UPDATE_VALUES | UPDATE_XY_COLOR | UPDATE_CALLER); UPDATE_VALUES | UPDATE_XY_COLOR | UPDATE_CALLER);
/* Ask for more motion events in case the event was a hint */
gdk_event_request_motions ((GdkEventMotion *) event);
return TRUE; return TRUE;
} }

View File

@ -395,8 +395,8 @@ motion_notify_event (GtkWidget *widget,
} }
} }
if (event->is_hint) /* Ask for more motion events in case the event was a hint */
gdk_device_get_state (event->device, event->window, NULL, NULL); gdk_event_request_motions (event);
return TRUE; return TRUE;
} }

View File

@ -1694,25 +1694,18 @@ static gint
design_area_motion (GtkWidget *widget, design_area_motion (GtkWidget *widget,
GdkEventMotion *event) GdkEventMotion *event)
{ {
gint i; gint i;
gdouble xo; gdouble xo;
gdouble yo; gdouble yo;
gdouble xn; gdouble xn;
gdouble yn; gdouble yn;
gint px, py; gdouble width = ifsDesign->area->allocation.width;
gdouble width = ifsDesign->area->allocation.width;
gdouble height = ifsDesign->area->allocation.height; gdouble height = ifsDesign->area->allocation.height;
Aff2 trans, t1, t2, t3; Aff2 trans, t1, t2, t3;
if (!(ifsDesign->button_state & GDK_BUTTON1_MASK)) return FALSE; if (! (ifsDesign->button_state & GDK_BUTTON1_MASK))
return FALSE;
if (event->is_hint)
{
gtk_widget_get_pointer (ifsDesign->area, &px, &py);
event->x = px;
event->y = py;
}
xo = (ifsDesign->op_x - ifsDesign->op_xcenter); xo = (ifsDesign->op_x - ifsDesign->op_xcenter);
yo = (ifsDesign->op_y - ifsDesign->op_ycenter); yo = (ifsDesign->op_y - ifsDesign->op_ycenter);
@ -1722,36 +1715,32 @@ design_area_motion (GtkWidget *widget,
switch (ifsDesign->op) switch (ifsDesign->op)
{ {
case OP_ROTATE: case OP_ROTATE:
{ aff2_translate (&t1,-ifsDesign->op_xcenter*width,
aff2_translate (&t1,-ifsDesign->op_xcenter*width, -ifsDesign->op_ycenter*width);
-ifsDesign->op_ycenter*width); aff2_scale (&t2,
aff2_scale (&t2, sqrt((SQR(xn)+SQR(yn))/(SQR(xo)+SQR(yo))),
sqrt((SQR(xn)+SQR(yn))/(SQR(xo)+SQR(yo))), 0);
0); aff2_compose (&t3, &t2, &t1);
aff2_compose (&t3, &t2, &t1); aff2_rotate (&t1, - atan2(yn, xn) + atan2(yo, xo));
aff2_rotate (&t1, - atan2(yn, xn) + atan2(yo, xo)); aff2_compose (&t2, &t1, &t3);
aff2_compose (&t2, &t1, &t3); aff2_translate (&t3, ifsDesign->op_xcenter*width,
aff2_translate (&t3, ifsDesign->op_xcenter*width, ifsDesign->op_ycenter*width);
ifsDesign->op_ycenter*width); aff2_compose (&trans, &t3, &t2);
aff2_compose (&trans, &t3, &t2); break;
break;
}
case OP_STRETCH: case OP_STRETCH:
{ aff2_translate (&t1,-ifsDesign->op_xcenter*width,
aff2_translate (&t1,-ifsDesign->op_xcenter*width, -ifsDesign->op_ycenter*width);
-ifsDesign->op_ycenter*width); aff2_compute_stretch (&t2, xo, yo, xn, yn);
aff2_compute_stretch (&t2, xo, yo, xn, yn); aff2_compose (&t3, &t2, &t1);
aff2_compose (&t3, &t2, &t1); aff2_translate (&t1, ifsDesign->op_xcenter*width,
aff2_translate (&t1, ifsDesign->op_xcenter*width, ifsDesign->op_ycenter*width);
ifsDesign->op_ycenter*width); aff2_compose (&trans, &t1, &t3);
aff2_compose (&trans, &t1, &t3); break;
break;
}
case OP_TRANSLATE: case OP_TRANSLATE:
{ aff2_translate (&trans,(xn-xo)*width,(yn-yo)*width);
aff2_translate (&trans,(xn-xo)*width,(yn-yo)*width); break;
break;
}
} }
for (i = 0; i < ifsvals.num_elements; i++) for (i = 0; i < ifsvals.num_elements; i++)
@ -1775,16 +1764,20 @@ design_area_motion (GtkWidget *widget,
aff2_compose (&elements[i]->trans, &trans, aff2_compose (&elements[i]->trans, &trans,
&ifsD->selected_orig[i].trans); &ifsD->selected_orig[i].trans);
} }
aff_element_decompose_trans (elements[i],&elements[i]->trans, aff_element_decompose_trans (elements[i],&elements[i]->trans,
width, height, ifsvals.center_x, width, height, ifsvals.center_x,
ifsvals.center_y); ifsvals.center_y);
aff_element_compute_trans (elements[i],width, height, aff_element_compute_trans (elements[i],width, height,
ifsvals.center_x, ifsvals.center_y); ifsvals.center_x, ifsvals.center_y);
} }
update_values (); update_values ();
design_area_redraw (); design_area_redraw ();
/* Ask for more motion events in case the event was a hint */
gdk_event_request_motions (event);
return FALSE; return FALSE;
} }