From f7392096d2d84be7143947d386528bf4f487ee83 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 28 Mar 2025 23:16:14 +0530 Subject: Split window management for multi-window --- src/widgets/BrowserApp.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/widgets/BrowserApp.cpp (limited to 'src/widgets/BrowserApp.cpp') diff --git a/src/widgets/BrowserApp.cpp b/src/widgets/BrowserApp.cpp new file mode 100644 index 0000000..0a82de0 --- /dev/null +++ b/src/widgets/BrowserApp.cpp @@ -0,0 +1,44 @@ +#include +#include + +#include "LuaRuntime.hpp" +#include "widgets/BrowserApp.hpp" +#include "widgets/MainWindow.hpp" + +BrowserApp::BrowserApp() { + auto *lua = LuaRuntime::instance(); + lua->start_event_loop(); + + // Global event filter + qApp->installEventFilter(this); + + // NOTE: TMP + lua->load_file("./config.lua"); +}; + +MainWindow *BrowserApp::create_window() { + auto *win = new MainWindow((const Configuration &)configuration); + win->setWindowTitle("null-browser"); + windows.insert({last_id, win}); + last_id++; + win->show(); + return win; +} + +bool BrowserApp::eventFilter(QObject *target, QEvent *event) { + if (event->type() != QEvent::KeyPress) + return false; + + for (auto &match : windows) { + auto *win = match.second; + + if (auto *target_widget = dynamic_cast(target); + win->isAncestorOf(target_widget)) { + auto *key_event = static_cast(event); + const bool should_skip = win->on_window_key_event(key_event); + return should_skip; + } + } + + return false; +} -- cgit v1.3.1