From 435f6e3974ff701c4db8c6d86fcf50ccd95c962b Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 3 Sep 2008 19:24:51 +0000 Subject: [PATCH] app/display/gimpdisplayshell-callbacks.c libgimpwidgets/gimpcolorselect.c 2008-09-03 Michael Natterer * 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 --- ChangeLog | 15 +++++ app/display/gimpdisplayshell-callbacks.c | 11 +--- libgimpwidgets/gimpcolorselect.c | 27 +++------ modules/color-selector-water.c | 4 +- plug-ins/ifs-compose/ifs-compose.c | 73 +++++++++++------------- 5 files changed, 60 insertions(+), 70 deletions(-) diff --git a/ChangeLog b/ChangeLog index d75324bc2f..de8baca11d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-09-03 Michael Natterer + + * 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 * libgimpwidgets/gimpbutton.c: massively simplified. Don't fiddle diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index 7d15981031..2502e7dc4b 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -1137,15 +1137,8 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas, } } - /* Ask for the pointer position, but ignore it except for cursor - * handling, so motion events sync with the button press/release events - */ - if (mevent->is_hint) - { - gimp_display_shell_get_device_coords (shell, - mevent->device, - &display_coords); - } + /* Ask for more motion events in case the event was a hint */ + gdk_event_request_motions (mevent); update_sw_cursor = TRUE; diff --git a/libgimpwidgets/gimpcolorselect.c b/libgimpwidgets/gimpcolorselect.c index b6e447022a..c7e5664b33 100644 --- a/libgimpwidgets/gimpcolorselect.c +++ b/libgimpwidgets/gimpcolorselect.c @@ -667,15 +667,8 @@ gimp_color_select_xy_events (GtkWidget *widget, case GDK_MOTION_NOTIFY: mevent = (GdkEventMotion *) event; - if (mevent->is_hint) - { - gdk_window_get_pointer (widget->window, &x, &y, NULL); - } - else - { - x = mevent->x; - y = mevent->y; - } + x = mevent->x; + y = mevent->y; break; default: @@ -700,8 +693,8 @@ gimp_color_select_xy_events (GtkWidget *widget, gimp_color_select_update (select, UPDATE_VALUES | UPDATE_CALLER); - if (event->type == GDK_MOTION_NOTIFY) - gdk_event_request_motions ((GdkEventMotion *) event); + /* Ask for more motion events in case the event was a hint */ + gdk_event_request_motions ((GdkEventMotion *) event); return TRUE; } @@ -760,14 +753,7 @@ gimp_color_select_z_events (GtkWidget *widget, case GDK_MOTION_NOTIFY: mevent = (GdkEventMotion *) event; - if (mevent->is_hint) - { - gdk_window_get_pointer (widget->window, NULL, &z, NULL); - } - else - { - z = mevent->y; - } + z = mevent->y; break; default: @@ -787,6 +773,9 @@ gimp_color_select_z_events (GtkWidget *widget, gimp_color_select_update (select, 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; } diff --git a/modules/color-selector-water.c b/modules/color-selector-water.c index 730ca8ebd0..a1691f500e 100644 --- a/modules/color-selector-water.c +++ b/modules/color-selector-water.c @@ -395,8 +395,8 @@ motion_notify_event (GtkWidget *widget, } } - if (event->is_hint) - gdk_device_get_state (event->device, event->window, NULL, NULL); + /* Ask for more motion events in case the event was a hint */ + gdk_event_request_motions (event); return TRUE; } diff --git a/plug-ins/ifs-compose/ifs-compose.c b/plug-ins/ifs-compose/ifs-compose.c index 45f9e4e642..56815ce7b6 100644 --- a/plug-ins/ifs-compose/ifs-compose.c +++ b/plug-ins/ifs-compose/ifs-compose.c @@ -1694,25 +1694,18 @@ static gint design_area_motion (GtkWidget *widget, GdkEventMotion *event) { - gint i; + gint i; gdouble xo; gdouble yo; gdouble xn; gdouble yn; - gint px, py; - gdouble width = ifsDesign->area->allocation.width; + gdouble width = ifsDesign->area->allocation.width; gdouble height = ifsDesign->area->allocation.height; Aff2 trans, t1, t2, t3; - 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; - } + if (! (ifsDesign->button_state & GDK_BUTTON1_MASK)) + return FALSE; xo = (ifsDesign->op_x - ifsDesign->op_xcenter); yo = (ifsDesign->op_y - ifsDesign->op_ycenter); @@ -1722,36 +1715,32 @@ design_area_motion (GtkWidget *widget, switch (ifsDesign->op) { case OP_ROTATE: - { - aff2_translate (&t1,-ifsDesign->op_xcenter*width, - -ifsDesign->op_ycenter*width); - aff2_scale (&t2, - sqrt((SQR(xn)+SQR(yn))/(SQR(xo)+SQR(yo))), - 0); - aff2_compose (&t3, &t2, &t1); - aff2_rotate (&t1, - atan2(yn, xn) + atan2(yo, xo)); - aff2_compose (&t2, &t1, &t3); - aff2_translate (&t3, ifsDesign->op_xcenter*width, - ifsDesign->op_ycenter*width); - aff2_compose (&trans, &t3, &t2); - break; - } + aff2_translate (&t1,-ifsDesign->op_xcenter*width, + -ifsDesign->op_ycenter*width); + aff2_scale (&t2, + sqrt((SQR(xn)+SQR(yn))/(SQR(xo)+SQR(yo))), + 0); + aff2_compose (&t3, &t2, &t1); + aff2_rotate (&t1, - atan2(yn, xn) + atan2(yo, xo)); + aff2_compose (&t2, &t1, &t3); + aff2_translate (&t3, ifsDesign->op_xcenter*width, + ifsDesign->op_ycenter*width); + aff2_compose (&trans, &t3, &t2); + break; + case OP_STRETCH: - { - aff2_translate (&t1,-ifsDesign->op_xcenter*width, - -ifsDesign->op_ycenter*width); - aff2_compute_stretch (&t2, xo, yo, xn, yn); - aff2_compose (&t3, &t2, &t1); - aff2_translate (&t1, ifsDesign->op_xcenter*width, - ifsDesign->op_ycenter*width); - aff2_compose (&trans, &t1, &t3); - break; - } + aff2_translate (&t1,-ifsDesign->op_xcenter*width, + -ifsDesign->op_ycenter*width); + aff2_compute_stretch (&t2, xo, yo, xn, yn); + aff2_compose (&t3, &t2, &t1); + aff2_translate (&t1, ifsDesign->op_xcenter*width, + ifsDesign->op_ycenter*width); + aff2_compose (&trans, &t1, &t3); + break; + case OP_TRANSLATE: - { - aff2_translate (&trans,(xn-xo)*width,(yn-yo)*width); - break; - } + aff2_translate (&trans,(xn-xo)*width,(yn-yo)*width); + break; } for (i = 0; i < ifsvals.num_elements; i++) @@ -1775,16 +1764,20 @@ design_area_motion (GtkWidget *widget, aff2_compose (&elements[i]->trans, &trans, &ifsD->selected_orig[i].trans); } + aff_element_decompose_trans (elements[i],&elements[i]->trans, width, height, ifsvals.center_x, ifsvals.center_y); aff_element_compute_trans (elements[i],width, height, - ifsvals.center_x, ifsvals.center_y); + ifsvals.center_x, ifsvals.center_y); } update_values (); design_area_redraw (); + /* Ask for more motion events in case the event was a hint */ + gdk_event_request_motions (event); + return FALSE; }