changeset 33625:d213a148b3f1

ensure exp. terminal widget has focus at startup * main-window.cc (main_window): call focus_command_window only if event loop is idle by using a single shot timer * main-window.h: make focus_command_window a public slot
author Torsten Lilge <ttl-octave@mailbox.org>
date Sun, 26 May 2024 02:29:44 +0200
parents e0c037a01fde
children a44ab15f75c4
files libgui/src/main-window.cc libgui/src/main-window.h
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/main-window.cc	Sat May 25 14:36:01 2024 +0200
+++ b/libgui/src/main-window.cc	Sun May 26 02:29:44 2024 +0200
@@ -195,7 +195,8 @@
 
   Q_EMIT init_window_menu ();
 
-  focus_command_window ();
+  // This only works reliably if the event loop is idle.s
+  QTimer::singleShot (0, this, SLOT (focus_command_window ()));
 }
 
 main_window::~main_window () { }
--- a/libgui/src/main-window.h	Sat May 25 14:36:01 2024 +0200
+++ b/libgui/src/main-window.h	Sun May 26 02:29:44 2024 +0200
@@ -86,8 +86,6 @@
 
   bool command_window_has_focus () const;
 
-  void focus_command_window ();
-
   bool confirm_shutdown ();
 
 Q_SIGNALS:
@@ -135,6 +133,7 @@
 
 public Q_SLOTS:
 
+  void focus_command_window ();
   void focus_changed (QWidget *w_old, QWidget *w_new);
   void focus_window (const QString& win_name);
   void request_reload_settings ();