From: Mikko Rasa Date: Mon, 23 Sep 2019 18:23:08 +0000 (+0300) Subject: Improve pointer grab handling X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=32d668c967c881ed386be22f17e3477a4405436b;p=libs%2Fgltk.git Improve pointer grab handling This fixes a bug where hiding a widget with active pointer grab would leave the grab flag set, preventing pointer events from being sent anywere. --- diff --git a/source/container.cpp b/source/container.cpp index 03dff11..53eeaa7 100644 --- a/source/container.cpp +++ b/source/container.cpp @@ -130,7 +130,7 @@ void Container::raise(Widget &wdg) throw hierarchy_error("widget not in container"); } -void Container::set_pointer_focus(Widget *wdg) +void Container::set_pointer_focus(Widget *wdg, bool grab) { if(wdg!=pointer_focus) { @@ -138,10 +138,13 @@ void Container::set_pointer_focus(Widget *wdg) pointer_focus->pointer_leave(); pointer_focus = wdg; + pointer_grabbed = grab; if(pointer_focus) pointer_focus->pointer_enter(); } + else + pointer_grabbed = grab; } void Container::set_input_focus(Widget *wdg) @@ -411,8 +414,7 @@ void Container::Child::grab_pointer() { if(!container.pointer_grabbed) { - container.set_pointer_focus(widget); - container.pointer_grabbed = true; + container.set_pointer_focus(widget, true); container.signal_grab_pointer.emit(); } } @@ -423,7 +425,6 @@ void Container::Child::ungrab_pointer() { // XXX Should set to the widget under pointer container.set_pointer_focus(0); - container.pointer_grabbed = false; container.signal_ungrab_pointer.emit(); } } diff --git a/source/container.h b/source/container.h index f16a9ba..d98ce39 100644 --- a/source/container.h +++ b/source/container.h @@ -63,7 +63,7 @@ public: void raise(Widget &); protected: - void set_pointer_focus(Widget *); + void set_pointer_focus(Widget *, bool = false); void set_input_focus(Widget *); public: Widget *get_input_focus() const { return input_focus; }