[gnote] Introduce initial focus for embeds



commit 90ab9ddfcea261a8f86d306aa56bac2e43f8360b
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Mon Jan 4 22:48:45 2021 +0200

    Introduce initial focus for embeds

 src/mainwindowembeds.hpp | 3 ++-
 src/recentchanges.cpp    | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/mainwindowembeds.hpp b/src/mainwindowembeds.hpp
index 9984782b..dd69a0c5 100644
--- a/src/mainwindowembeds.hpp
+++ b/src/mainwindowembeds.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2013,2015-2017,2019 Aurimas Cernius
+ * Copyright (C) 2013,2015-2017,2019,2021 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -57,6 +57,7 @@ public:
   virtual void hint_position(int & x, int & y);
   virtual void hint_size(int & width, int & height);
   virtual void size_internals();
+  virtual void set_initial_focus() {}
   EmbeddableWidgetHost *host() const
     {
       return m_host;
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index b6cad1ed..9c9bcb5c 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -719,6 +719,12 @@ namespace gnote {
   bool NoteRecentChanges::on_map_event(GdkEventAny *evt)
   {
     bool res = MainWindow::on_map_event(evt);
+    if(!m_mapped) {
+      auto widget = currently_embedded();
+      if(widget) {
+        widget->set_initial_focus();
+      }
+    }
     m_mapped = true;
     return res;
   }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]