From 8a78cb8bc0ac16a0cc8130638873b0eac7b8a165 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Wed, 26 Sep 2007 10:39:29 -0400 Subject: Fixed focus error between multiple instances of Textadept; src/textadept.c --- src/textadept.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/textadept.c b/src/textadept.c index 220986be..2caa014f 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -14,6 +14,7 @@ static bool c_keypress(GtkWidget *widget, GdkEventKey *event, gpointer); static void t_notification(GtkWidget*, gint, gpointer lParam, gpointer); static void t_command(GtkWidget *editor, gint wParam, gpointer, gpointer); static bool t_keypress(GtkWidget*, GdkEventKey *event, gpointer); +static bool w_focus(GtkWidget*, GdkEventFocus *, gpointer); static bool w_keypress(GtkWidget*, GdkEventKey *event, gpointer); static bool w_exit(GtkWidget*, GdkEventAny*, gpointer); @@ -29,6 +30,7 @@ int main(int argc, char **argv) { void create_ui() { window = gtk_window_new(GTK_WINDOW_TOPLEVEL); signal(window, "delete_event", w_exit); + signal(window, "focus-in-event", w_focus); signal(window, "key_press_event", w_keypress); GtkWidget *vbox = gtk_vbox_new(false, 0); gtk_container_add(GTK_CONTAINER(window), vbox); @@ -265,6 +267,12 @@ static bool t_keypress(GtkWidget*, GdkEventKey *event, gpointer) { return l_handle_keypress(event->keyval, event); } +static bool w_focus(GtkWidget*, GdkEventFocus*, gpointer) { + if (focused_editor && !GTK_WIDGET_HAS_FOCUS(focused_editor)) + gtk_widget_grab_focus(focused_editor); + return false; +} + /** Window key events. * Escape - hides the search dialog if it's open. */ -- cgit v1.2.3