Prevent pipette dismissal upon release over 'Back'

On touch devices, the color pipette tool could easilly be
immediately dismissed due to the 'button up' event happening
right where the "Back" dismissal/cancel button appeared.
Now only pays attention to 'release' if the button was down.

(h/t Pere for reporting this)
This commit is contained in:
Bill Kendrick 2023-03-21 22:57:59 -07:00
parent 273b66f15f
commit 98cb1e62e7
2 changed files with 51 additions and 35 deletions

View file

@ -7,7 +7,7 @@ Various contributors (see below, and AUTHORS.txt)
https://tuxpaint.org/ https://tuxpaint.org/
2023.March.19 (0.9.29) ### RC2 2023.March.21 (0.9.29) ### RC2
* Improvements to "Stamp" tool: * Improvements to "Stamp" tool:
----------------------------- -----------------------------
* Stamps may now be rotated. * Stamps may now be rotated.
@ -199,6 +199,13 @@ https://tuxpaint.org/
Blocks, Chalk, and Drip (hence this being listed as a bug fix). Blocks, Chalk, and Drip (hence this being listed as a bug fix).
h/t Pere for discovering this. h/t Pere for discovering this.
* On touch devices, the color pipette tool could easilly be
immediately dismissed due to the 'button up' event happening
right where the "Back" dismissal/cancel button appeared.
Now only pays attention to 'release' if the button was down.
Bill Kendrick <bill@newbreedsoftware.com>
h/t Pere for reporting this.
* SDL1.2 supported "SDL_VIDEO_WINDOW_POS" environment variable, * SDL1.2 supported "SDL_VIDEO_WINDOW_POS" environment variable,
but SDL2 does not; so reimplemented it ourselves. (See ENVARS docs.) but SDL2 does not; so reimplemented it ourselves. (See ENVARS docs.)
Bill Kendrick <bill@newbreedsoftware.com> Bill Kendrick <bill@newbreedsoftware.com>

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
June 14, 2002 - March 19, 2023 June 14, 2002 - March 21, 2023
*/ */
#include "platform.h" #include "platform.h"
@ -24390,7 +24390,7 @@ static int do_color_sel(int temp_mode)
int stepx, stepy; int stepx, stepy;
int number_of_steps = 20; int number_of_steps = 20;
int i, dx, dy; int i, dx, dy;
int done, chose; int done, chose, mouse_was_down;
int back_left, back_top; int back_left, back_top;
int color_sel_x = 0, color_sel_y = 0; int color_sel_x = 0, color_sel_y = 0;
int want_animated_popups; int want_animated_popups;
@ -24593,6 +24593,8 @@ static int do_color_sel(int temp_mode)
r_color_sel.y + r_color_sel.h / 2); r_color_sel.y + r_color_sel.h / 2);
#endif #endif
mouse_was_down = temp_mode;
do do
{ {
while (SDL_PollEvent(&event)) while (SDL_PollEvent(&event))
@ -24625,47 +24627,54 @@ static int do_color_sel(int temp_mode)
done = 1; done = 1;
} }
} }
else if (event.type == SDL_MOUSEBUTTONUP else if (event.type == SDL_MOUSEBUTTONDOWN)
&& valid_click(event.button.button))
{ {
if (event.button.x >= r_canvas.x && mouse_was_down = 1;
event.button.x < r_canvas.x + r_canvas.w && }
event.button.y >= r_canvas.y else if (event.type == SDL_MOUSEBUTTONUP)
&& event.button.y < r_canvas.y + r_canvas.h) {
if (valid_click(event.button.button && mouse_was_down))
{ {
/* Picked a color in the canvas, and released! */ if (event.button.x >= r_canvas.x &&
event.button.x < r_canvas.x + r_canvas.w &&
chose = 1; event.button.y >= r_canvas.y
done = 1; && event.button.y < r_canvas.y + r_canvas.h)
x = event.button.x - r_canvas.x;
y = event.button.y - r_canvas.y;
color_sel_x = x;
color_sel_y = y;
}
else
{
if (!temp_mode)
{ {
if (event.button.x >= back_left && /* Picked a color in the canvas, and released! */
event.button.x < back_left + img_back->w &&
event.button.y >= back_top
&& event.button.y < back_top + img_back->h)
{
/* Full UI mode: Decided to go Back; abort */
chose = 1;
done = 1;
x = event.button.x - r_canvas.x;
y = event.button.y - r_canvas.y;
color_sel_x = x;
color_sel_y = y;
}
else
{
if (!temp_mode)
{
if (event.button.x >= back_left &&
event.button.x < back_left + img_back->w &&
event.button.y >= back_top
&& event.button.y < back_top + img_back->h)
{
/* Full UI mode: Decided to go Back; abort */
chose = 0;
done = 1;
}
}
else
{
/* Temp mode: Released outside of canvas; abort */
chose = 0; chose = 0;
done = 1; done = 1;
} }
} }
else
{
/* Temp mode: Released outside of canvas; abort */
chose = 0;
done = 1;
}
} }
mouse_was_down = 0;
} }
else if (event.type == SDL_MOUSEMOTION) else if (event.type == SDL_MOUSEMOTION)
{ {