From 5e3f824301449c51f187033d32bf350b529c6294 Mon Sep 17 00:00:00 2001 From: Pere Pujal i Carabantes Date: Sun, 15 May 2011 16:05:21 +0000 Subject: [PATCH] Adding a switchin when the mouse returns in mouse accessibility mode. Also removing ghost previews for lines and the first step of shapes when the mouse goes out. For the secon step of shapes, I think there is a bug report in sourceforge that must be taked in account. --- src/tuxpaint.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index bf4bb8c62..fb5767bc4 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -2109,7 +2109,20 @@ static void mainloop(void) } else if (event.type == SDL_ACTIVEEVENT) { + /* Reset Shapes tool and clean the canvas if we lose focus*/ + if (mouseaccessibility && emulate_button_pressed && + ((cur_tool == TOOL_SHAPES && shape_tool_mode != SHAPE_TOOL_MODE_DONE) || cur_tool == TOOL_LINES) && + event.active.state & SDL_APPINPUTFOCUS|SDL_APPACTIVE && + event.active.gain == 0) + { + do_undo(); + tool_avail[TOOL_REDO] = 0; /* Don't let them 'redo' to get preview back */ + draw_toolbar(); + update_screen_rect(&r_tools); + shape_tool_mode = SHAPE_TOOL_MODE_DONE; + } handle_active(&event); + } else if (event.type == SDL_KEYUP) { @@ -16526,9 +16539,15 @@ static void handle_active(SDL_Event * event) } if (event->active.state & SDL_APPINPUTFOCUS|SDL_APPACTIVE) { - if (mouseaccessibility && emulate_button_pressed) { - magic_switchout(canvas); + if (event->active.gain == 1) + { + if (mouseaccessibility) { + magic_switchin(canvas); + } } + else if (mouseaccessibility && emulate_button_pressed) { + magic_switchout(canvas); + } #ifdef _WIN32 SetActivationState(event->active.gain);