From f83d032c4b3d7ac694b3c8481e2086145245c0ef Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 8 Sep 2019 18:28:21 +0300 Subject: [PATCH] Only focus widgets if the container is focused This prevents issues where a widget could be focused before it's added to a rooted hierarchy, presenting inconsistent focus state. --- source/container.cpp | 3 ++- source/root.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source/container.cpp b/source/container.cpp index 62e6e12..a0d1fd7 100644 --- a/source/container.cpp +++ b/source/container.cpp @@ -388,9 +388,10 @@ void Container::Child::visibility_changed(bool v) void Container::Child::request_focus() { - container.set_input_focus(widget); if(container.parent && container.visible) container.set_focus(); + if(container.state&FOCUS) + container.set_input_focus(widget); } void Container::Child::grab_pointer() diff --git a/source/root.cpp b/source/root.cpp index ad1ca5b..a76da5b 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -58,6 +58,9 @@ void Root::init(Graphics::Window *window) else shprog = 0; + if(keyboard) + set_state(FOCUS); + update_style(); if(mouse) -- 2.45.2