wind: Stop tracking windows after they're closed
This commit is contained in:
parent
d3cc4d109b
commit
fbfa5328d7
@ -1,4 +1,5 @@
|
|||||||
#include "IPC.h"
|
#include "IPC.h"
|
||||||
|
#include "Mouse.h"
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
#include <luna/Alignment.h>
|
#include <luna/Alignment.h>
|
||||||
#include <luna/String.h>
|
#include <luna/String.h>
|
||||||
@ -129,6 +130,7 @@ static Result<void> handle_close_window_message(Client& client)
|
|||||||
auto* window = client.windows[request.window];
|
auto* window = client.windows[request.window];
|
||||||
client.windows[request.window] = nullptr;
|
client.windows[request.window] = nullptr;
|
||||||
g_windows.remove(window);
|
g_windows.remove(window);
|
||||||
|
Mouse::the().window_did_close(window);
|
||||||
delete window;
|
delete window;
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
static SharedPtr<ui::Image> g_mouse_cursor;
|
static SharedPtr<ui::Image> g_mouse_cursor;
|
||||||
|
|
||||||
|
static Mouse* s_mouse;
|
||||||
|
|
||||||
Mouse::Mouse(ui::Canvas& screen)
|
Mouse::Mouse(ui::Canvas& screen)
|
||||||
{
|
{
|
||||||
m_position.x = screen.width / 2;
|
m_position.x = screen.width / 2;
|
||||||
@ -14,6 +16,14 @@ Mouse::Mouse(ui::Canvas& screen)
|
|||||||
m_screen_rect = screen.rect();
|
m_screen_rect = screen.rect();
|
||||||
|
|
||||||
g_mouse_cursor = ui::Image::load("/usr/share/cursors/default.tga").value_or({});
|
g_mouse_cursor = ui::Image::load("/usr/share/cursors/default.tga").value_or({});
|
||||||
|
|
||||||
|
s_mouse = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mouse& Mouse::the()
|
||||||
|
{
|
||||||
|
check(s_mouse);
|
||||||
|
return *s_mouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mouse::draw(ui::Canvas& screen)
|
void Mouse::draw(ui::Canvas& screen)
|
||||||
@ -110,3 +120,10 @@ void Mouse::update(const moon::MousePacket& packet)
|
|||||||
m_active_window = new_active_window;
|
m_active_window = new_active_window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Mouse::window_did_close(Window* window)
|
||||||
|
{
|
||||||
|
if (m_dragging_window == window) { m_dragging_window = nullptr; }
|
||||||
|
|
||||||
|
if (m_active_window == window) { m_active_window = nullptr; }
|
||||||
|
}
|
||||||
|
@ -13,6 +13,10 @@ class Mouse
|
|||||||
|
|
||||||
void draw(ui::Canvas& screen);
|
void draw(ui::Canvas& screen);
|
||||||
|
|
||||||
|
void window_did_close(Window* window);
|
||||||
|
|
||||||
|
static Mouse& the();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ui::Point m_position;
|
ui::Point m_position;
|
||||||
ui::Rect m_screen_rect;
|
ui::Rect m_screen_rect;
|
||||||
|
@ -179,6 +179,7 @@ Result<int> luna_main(int argc, char** argv)
|
|||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
g_windows.remove(window);
|
g_windows.remove(window);
|
||||||
|
mouse_pointer.window_did_close(window);
|
||||||
delete window;
|
delete window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user