keep track of focused widget on parent

This commit is contained in:
hippoz 2022-03-19 21:32:15 +02:00
parent d6dcff2b7c
commit 61b76df08b
Signed by: hippoz
GPG key ID: 7C52899193467641
3 changed files with 7 additions and 4 deletions

View file

@ -97,6 +97,9 @@ void Widget::handle_mouse_move_event(MouseMoveEvent &event) {
on_mouse_move(event);
on_focus_update(focus_update_event);
if (m_is_focused && m_window)
m_window->set_focused_widget(this);
if (m_consumes_hits)
event.accept();
}

View file

@ -75,7 +75,7 @@ bool Window::dispatch_repaint_on_box(Box box) {
bool Window::dispatch_full_repaint() {
return dispatch_repaint_on_box(m_current_geometry);
}
}
void Window::run(bool block) {
XEvent e;

View file

@ -10,7 +10,7 @@ namespace Raven {
class Window {
private:
Widget *m_hovered_widget { nullptr };
Widget *m_focused_widget { nullptr };
Widget *m_main_widget { nullptr };
Box m_current_geometry { 0, 0, 800, 600 };
Painter m_painter {};
@ -23,8 +23,8 @@ public:
Painter &get_painter() { return m_painter; }
Widget *get_hovered_widget() { return m_hovered_widget; }
void set_hovered_widget(Widget *hovered_widget) { m_hovered_widget = hovered_widget; }
Widget *get_focused_widget() { return m_focused_widget; }
void set_focused_widget(Widget *focused_widget) { m_focused_widget = focused_widget; }
Widget *get_main_widget() { return m_main_widget; }
void set_main_widget(Widget *main_widget);