From 591cfca4e8a604000ce2950b3bbf29ce5a500667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Wed, 11 Jul 2012 22:25:29 +0200 Subject: [PATCH] editor: deactivate old text model before activating the new one --- clients/editor.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/clients/editor.c b/clients/editor.c index 145ba20c..9498d53b 100644 --- a/clients/editor.c +++ b/clients/editor.c @@ -20,6 +20,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include #include @@ -233,22 +234,29 @@ button_handler(struct widget *widget, x -= allocation.x; y -= allocation.y; - editor->entry->active = 0; - editor->editor->active = 0; + int32_t activate_entry = rectangle_contains(&editor->entry->allocation, x, y); + int32_t activate_editor = rectangle_contains(&editor->editor->allocation, x, y); + assert(!(activate_entry && activate_editor)); - editor->entry->active = rectangle_contains(&editor->entry->allocation, x, y); - editor->editor->active = rectangle_contains(&editor->editor->allocation, x, y); - - if (editor->entry->active) { - text_entry_activate(editor->entry); + if (activate_entry) { + if (editor->editor->active) + text_entry_deactivate(editor->editor); + if (!editor->entry->active) + text_entry_activate(editor->entry); + } else if (activate_editor) { + if (editor->entry->active) + text_entry_deactivate(editor->entry); + if (!editor->editor->active) + text_entry_activate(editor->editor); } else { - text_entry_deactivate(editor->entry); - } - if (editor->editor->active) { - text_entry_activate(editor->editor); - } else { - text_entry_deactivate(editor->editor); + if (editor->entry->active) + text_entry_deactivate(editor->entry); + if (editor->editor->active) + text_entry_deactivate(editor->editor); } + editor->entry->active = activate_entry; + editor->editor->active = activate_editor; + assert(!(editor->entry->active && editor->editor->active)); widget_schedule_redraw(widget); }