diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-03-30 15:48:01 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-03-30 15:48:01 +0530 |
| commit | e690963fb6c0240171236fc2d669f95ee26b6798 (patch) | |
| tree | 367a74e7d23c44ff6d9a576dc08e34cf43e2d65c | |
| parent | 997891b27d17377111f484c62ba41caf15475d72 (diff) | |
| download | null-browser-e690963fb6c0240171236fc2d669f95ee26b6798.tar.gz null-browser-e690963fb6c0240171236fc2d669f95ee26b6798.zip | |
Remove from router on window close
Diffstat (limited to '')
| -rw-r--r-- | TODO.org | 2 | ||||
| -rw-r--r-- | config.lua | 6 | ||||
| -rw-r--r-- | src/WindowActionRouter.cpp | 8 | ||||
| -rw-r--r-- | src/widgets/BrowserWindow.cpp | 1 | ||||
| -rw-r--r-- | src/widgets/BrowserWindow.hpp | 7 |
5 files changed, 17 insertions, 7 deletions
@@ -10,7 +10,7 @@ - [X] Get tab list api - [X] Assign ID to each tab (reference in lua api) - [X] Tab select by id -- [ ] Multi-window +- [X] Multi-window - [ ] Handle resource cleanup + signal disconnecting - [ ] Socket for opening window in current session (lua eval) - [ ] Log stdout, errors and results from lua somewhere @@ -1,9 +1,9 @@ print('hello starting up...') --- @type table -web = web +local web = web --- @type table -uv = uv +local uv = uv local function trim(s) local res, _ = string.gsub(s, "^%s*(.-)%s*$", "%1") @@ -36,7 +36,7 @@ function Dmenu.select(list, opts, callback) end end) - uv.read_start(stdout, function(_err, data) + uv.read_start(stdout, function(_, data) if data then selection = data end end) diff --git a/src/WindowActionRouter.cpp b/src/WindowActionRouter.cpp index 51fb1af..c04b330 100644 --- a/src/WindowActionRouter.cpp +++ b/src/WindowActionRouter.cpp @@ -63,9 +63,13 @@ void WindowActionRouter::initialize() { } void WindowActionRouter::add_window(BrowserWindow *window) { - window_map.insert({last_id, window}); - window->set_id(last_id); + auto win_id = last_id; last_id++; + + window_map.insert({win_id, window}); + window->set_id(win_id); + connect(window, &BrowserWindow::closed, this, + [this, win_id]() { window_map.erase(win_id); }); } const WindowMap &WindowActionRouter::windows() { return window_map; } diff --git a/src/widgets/BrowserWindow.cpp b/src/widgets/BrowserWindow.cpp index 4eb0ad7..886572e 100644 --- a/src/widgets/BrowserWindow.cpp +++ b/src/widgets/BrowserWindow.cpp @@ -5,7 +5,6 @@ #include "Configuration.hpp" #include "LuaRuntime.hpp" -#include "WindowActionRouter.hpp" #include "WindowMediator.hpp" #include "keymap/KeymapEvaluator.hpp" #include "widgets/BrowserWindow.hpp" diff --git a/src/widgets/BrowserWindow.hpp b/src/widgets/BrowserWindow.hpp index 364aa12..cab7721 100644 --- a/src/widgets/BrowserWindow.hpp +++ b/src/widgets/BrowserWindow.hpp @@ -9,6 +9,8 @@ using WindowId = uint64_t; class BrowserWindow : public QMainWindow { + Q_OBJECT + public: BrowserWindow(const Configuration &configuration); @@ -18,6 +20,11 @@ public: bool on_window_key_event(QKeyEvent *event); + void closeEvent(QCloseEvent * /*event*/) override { emit closed(); } + +signals: + void closed(); + private: WindowMediator *input_mediator; const Configuration &configuration; |
