From 7490c80a9c92b97ba8b8085d0fc977bc87e1f9de Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Thu, 4 Nov 2021 13:30:50 +0100 Subject: [PATCH] fix UI bug when placing text and immediately deleting it (did not delete) --- scconfig/src/gui/Makefile.plugin | 1 + scconfig/src/gui/find_gtk3.c | 24 ++++++++++-------------- scconfig/src/gui/gui.c | 3 +++ src/actions.c | 5 +++-- src/callback.c | 12 ++++++++++-- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/scconfig/src/gui/Makefile.plugin b/scconfig/src/gui/Makefile.plugin index 5fede0af..4d3e8982 100644 --- a/scconfig/src/gui/Makefile.plugin +++ b/scconfig/src/gui/Makefile.plugin @@ -2,6 +2,7 @@ GUI_CFLAGS = -DPLUGIN_GUI GUI_OBJS = \ $(BIN)/gui/find_gtk2.o \ $(BIN)/gui/find_gtk3.o \ + $(BIN)/gui/find_gtk4.o \ $(BIN)/gui/find_lesstif2.o \ $(BIN)/gui/find_x.o \ $(BIN)/gui/find_gd.o \ diff --git a/scconfig/src/gui/find_gtk3.c b/scconfig/src/gui/find_gtk3.c index 0657be7f..2a566e93 100644 --- a/scconfig/src/gui/find_gtk3.c +++ b/scconfig/src/gui/find_gtk3.c @@ -32,29 +32,25 @@ int find_gtk3(const char *name, int logdepth, int fatal, const char *call, const const char *test_c = NL "#include " NL - NL "static void" - NL "activate (GtkApplication* app," - NL " gpointer user_data)" + NL "static void activate(GtkApplication* app, gpointer user_data)" NL "{" NL " GtkWidget *window;" NL - NL " window = gtk_application_window_new (app);" - NL " gtk_window_set_title (GTK_WINDOW (window), \"Window\");" - NL " gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);" - NL " gtk_widget_show_all (window);" + NL " window = gtk_application_window_new(app);" + NL " gtk_window_set_title(GTK_WINDOW(window), \"Window\");" + NL " gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);" + NL " gtk_widget_show_all(window);" NL "}" NL - NL "int" - NL "main (int argc," - NL " char **argv)" + NL "int main (int argc, char **argv)" NL "{" NL " GtkApplication *app;" NL " int status;" NL - NL " app = gtk_application_new (\"org.gtk.example\", G_APPLICATION_FLAGS_NONE);" - NL " g_signal_connect (app, \"activate\", G_CALLBACK (activate), NULL);" - NL " status = g_application_run (G_APPLICATION (app), argc, argv);" - NL " g_object_unref (app);" + NL " app = gtk_application_new(\"org.gtk.example\", G_APPLICATION_FLAGS_NONE);" + NL " g_signal_connect(app, \"activate\", G_CALLBACK(activate), NULL);" + NL " status = g_application_run(G_APPLICATION(app), argc, argv);" + NL " g_object_unref(app);" NL NL " return status;" NL "}" diff --git a/scconfig/src/gui/gui.c b/scconfig/src/gui/gui.c index 385cb175..852482f6 100644 --- a/scconfig/src/gui/gui.c +++ b/scconfig/src/gui/gui.c @@ -6,6 +6,7 @@ #include "find_x.h" #include "find_gtk2.h" #include "find_gtk3.h" +#include "find_gtk4.h" #include "find_lesstif2.h" #include "find_gd.h" #include "find_cairo.h" @@ -26,6 +27,8 @@ void deps_gui_init() dep_add("libs/gui/gtk2/key_prefix", find_gtk2_key_prefix); dep_add("libs/gui/gtk2/modversion", find_gtk2_modversion); dep_add("libs/gui/gtk3/*", find_gtk3); + dep_add("libs/gui/gtk4/*", find_gtk4); + dep_add("libs/gui/gtk4/modversion", find_gtk4_modversion); dep_add("libs/gui/lesstif2/exthi/*", find_lesstif2_exthi); dep_add("libs/gui/lesstif2/*", find_lesstif2); dep_add("libs/gui/libstroke/*", find_libstroke); diff --git a/src/actions.c b/src/actions.c index deee4153..8f90bd6a 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2323,10 +2323,11 @@ void place_text(int draw_text, double mx, double my) cairo_restore(xctx->cairo_save_ctx); } #endif - select_text(xctx->texts, SELECTED, 0); + xctx->texts++; + select_text(xctx->texts - 1, SELECTED, 0); + rebuild_selected_array(); /* sets xctx->ui_state |= SELECTION */ drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); - xctx->texts++; set_modify(1); } diff --git a/src/callback.c b/src/callback.c index 96d9b19e..d895c133 100644 --- a/src/callback.c +++ b/src/callback.c @@ -725,7 +725,11 @@ int callback(int event, int mx, int my, KeySym key, { if(xctx->semaphore >= 2) break; xctx->last_command = 0; - place_text(1, xctx->mousex_snap, xctx->mousey_snap); /* 1 = draw text 24122002 */ + place_text(0, xctx->mousex_snap, xctx->mousey_snap); /* 1 = draw text 24122002 */ + xctx->mx_save = mx; xctx->my_save = my; + xctx->mx_double_save=xctx->mousex_snap; + xctx->my_double_save=xctx->mousey_snap; + move_objects(START,0,0,0); break; } if(key=='r' && !xctx->ui_state && state==0) /* start rect */ @@ -1500,7 +1504,11 @@ int callback(int event, int mx, int my, KeySym key, break; case 6: xctx->last_command = 0; - place_text(1, xctx->mousex_snap, xctx->mousey_snap); /* 1 = draw text */ + place_text(0, xctx->mousex_snap, xctx->mousey_snap); /* 1 = draw text */ + xctx->mx_save = mx; xctx->my_save = my; + xctx->mx_double_save=xctx->mousex_snap; + xctx->my_double_save=xctx->mousey_snap; + move_objects(START,0,0,0); break; case 7: /* cut selection into clipboard */ rebuild_selected_array();