Add window object

This commit is contained in:
momo5502
2025-05-18 09:13:26 +02:00
parent c2fe56e60b
commit d08bcbae9c
4 changed files with 54 additions and 6 deletions

View File

@@ -19,6 +19,7 @@ struct handle_types
registry,
mutant,
token,
window,
};
};
@@ -238,7 +239,7 @@ class handle_store : public generic_handle_store
return h;
}
bool erase(const typename value_map::iterator& entry)
std::pair<typename value_map::iterator, bool> erase(const typename value_map::iterator& entry)
{
if (this->block_mutation_)
{
@@ -247,25 +248,25 @@ class handle_store : public generic_handle_store
if (entry == this->store_.end())
{
return false;
return {entry, false};
}
if constexpr (handle_detail::has_deleter_function<T>())
{
if (!T::deleter(entry->second))
{
return true;
return {entry, true};
}
}
this->store_.erase(entry);
return true;
auto new_iter = this->store_.erase(entry);
return {new_iter, true};
}
bool erase(const handle_value h)
{
const auto entry = this->get_iterator(h);
return this->erase(entry);
return this->erase(entry).second;
}
bool erase(const handle h) override

View File

@@ -109,6 +109,7 @@ struct process_context
handle_store<handle_types::semaphore, semaphore> semaphores{};
handle_store<handle_types::port, port> ports{};
handle_store<handle_types::mutant, mutant> mutants{};
handle_store<handle_types::window, window> windows{};
handle_store<handle_types::registry, registry_key, 2> registry_keys{};
std::map<uint16_t, atom_entry> atoms{};

View File

@@ -279,6 +279,19 @@ namespace syscalls
thread->exit_status = exit_status;
c.win_emu.callbacks.on_thread_terminated(thread_handle, *thread);
for (auto i = c.proc.windows.begin(); i != c.proc.windows.end();)
{
if (i->second.thread_id != thread->id)
{
++i;
continue;
}
i->second.ref_count = 1;
i = c.proc.windows.erase(i).first;
}
if (thread == c.proc.active_thread)
{
c.win_emu.yield_thread();

View File

@@ -39,6 +39,39 @@ struct event : ref_counted_object
}
};
struct window : ref_counted_object
{
uint32_t thread_id{};
std::u16string name{};
std::u16string class_name{};
uint32_t width;
uint32_t height;
uint32_t x;
uint32_t y;
void serialize_object(utils::buffer_serializer& buffer) const override
{
buffer.write(this->thread_id);
buffer.write(this->name);
buffer.write(this->class_name);
buffer.write(this->width);
buffer.write(this->height);
buffer.write(this->x);
buffer.write(this->y);
}
void deserialize_object(utils::buffer_deserializer& buffer) override
{
buffer.read(this->thread_id);
buffer.read(this->name);
buffer.read(this->class_name);
buffer.read(this->width);
buffer.read(this->height);
buffer.read(this->x);
buffer.read(this->y);
}
};
struct mutant : ref_counted_object
{
uint32_t locked_count{0};