ui+wind: Send mouse move events through IPC
This commit is contained in:
parent
02c72e15d5
commit
0a39628bb1
@ -9,6 +9,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <os/IPC.h>
|
||||
#include <ui/Point.h>
|
||||
|
||||
namespace ui
|
||||
{
|
||||
@ -17,6 +18,7 @@ namespace ui
|
||||
IPC_ENUM_CLIENT(ui),
|
||||
CREATE_WINDOW_RESPONSE_ID,
|
||||
WINDOW_CLOSE_REQUEST_ID,
|
||||
MOUSE_EVENT_REQUEST_ID,
|
||||
};
|
||||
|
||||
struct CreateWindowResponse
|
||||
@ -33,4 +35,13 @@ namespace ui
|
||||
|
||||
int window;
|
||||
};
|
||||
|
||||
struct MouseEventRequest
|
||||
{
|
||||
static constexpr u8 ID = MOUSE_EVENT_REQUEST_ID;
|
||||
|
||||
int window;
|
||||
Point position;
|
||||
int buttons;
|
||||
};
|
||||
}
|
||||
|
@ -92,6 +92,12 @@ namespace ui
|
||||
window->close();
|
||||
return {};
|
||||
}
|
||||
case MOUSE_EVENT_REQUEST_ID: {
|
||||
MouseEventRequest request;
|
||||
TRY(m_client->recv_typed(request));
|
||||
os::eprintln("ui: Mouse move to (%d, %d)", request.position.x, request.position.y);
|
||||
return {};
|
||||
}
|
||||
default: fail("Unexpected IPC request from server!");
|
||||
}
|
||||
}
|
||||
|
@ -78,4 +78,21 @@ void Mouse::update(const moon::MousePacket& packet)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Window* window = g_windows.last().value_or(nullptr); window;
|
||||
window = g_windows.previous(window).value_or(nullptr))
|
||||
{
|
||||
auto titlebar = window->surface.absolute(window->titlebar);
|
||||
auto contents = window->surface.absolute(window->contents);
|
||||
if (titlebar.contains(m_position)) break;
|
||||
if (contents.contains(m_position))
|
||||
{
|
||||
ui::MouseEventRequest request;
|
||||
request.window = window->id;
|
||||
request.position = contents.relative(m_position);
|
||||
request.buttons = packet.buttons;
|
||||
os::IPC::send_async(window->client->conn, request);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user