From: Mikko Rasa Date: Sun, 8 Sep 2019 15:28:21 +0000 (+0300) Subject: Only focus widgets if the container is focused X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f83d032c4b3d7ac694b3c8481e2086145245c0ef;p=libs%2Fgltk.git 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. --- 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)