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

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