Fix focus after destruction of StartChatDialog

On destroy() the window that was last focused gets the focus
again. if destroy() is called from the StartChat Dialog, the new
ChatControl is not yet focused, because present() seems to be asynchron,
at least on KDE, and takes time.
This commit is contained in:
Philipp Hörist 2017-12-26 21:55:06 +01:00
parent 23de7d5331
commit 1b2ab928f0
2 changed files with 10 additions and 1 deletions

View File

@ -2776,6 +2776,7 @@ class StartChatDialog(Gtk.ApplicationWindow):
self.set_show_menubar(False)
self.set_title(_('Start new Conversation'))
self.set_default_size(-1, 400)
self.ready_to_destroy = False
self.builder = gtkgui_helpers.get_gtk_builder(
'start_chat_dialog.ui')
@ -2891,7 +2892,7 @@ class StartChatDialog(Gtk.ApplicationWindow):
else:
app.interface.new_chat_from_jid(row.account, row.jid)
self.destroy()
self.ready_to_destroy = True
def _on_search_changed(self, entry):
search_text = entry.get_text()

View File

@ -204,6 +204,14 @@ class MessageWindow(object):
gtkgui_helpers.resize_window(self.window, width, height)
def _on_window_focus(self, widget, event):
# on destroy() the window that was last focused gets the focus
# again. if destroy() is called from the StartChat Dialog, this
# Window is not yet focused, because present() seems to be asynchron
# at least on KDE, and takes time.
if 'start_chat' in app.interface.instances:
if app.interface.instances['start_chat'].ready_to_destroy:
app.interface.instances['start_chat'].destroy()
# window received focus, so if we had urgency REMOVE IT
# NOTE: we do not have to read the message (it maybe in a bg tab)
# to remove urgency hint so this functions does that