mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Simplify GUI event handling
This commit is contained in:
+13
-21
@@ -24,7 +24,7 @@ HWND Editor::open() {
|
||||
}
|
||||
|
||||
void Editor::close() {
|
||||
// RAII does the rest for us
|
||||
// RAII will destroy the window for us
|
||||
win32_handle = std::nullopt;
|
||||
|
||||
// TODO: Do we need to do something on the X11 side or does the host do
|
||||
@@ -44,26 +44,6 @@ bool Editor::resize(const VstRect& new_size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Below function shouldn't be needed
|
||||
bool Editor::update() {
|
||||
if (!win32_handle.has_value()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Doing this manually should not be needed
|
||||
UpdateWindow(win32_handle->get());
|
||||
|
||||
// TODO: This should also be done somewhere else
|
||||
// Pump events since the Win32 API won't do it for us
|
||||
MSG msg;
|
||||
while (PeekMessage(&msg, win32_handle->get(), 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Editor::embed_into(const size_t parent_window_handle) {
|
||||
if (!win32_handle.has_value()) {
|
||||
return false;
|
||||
@@ -101,6 +81,18 @@ bool Editor::embed_into(const size_t parent_window_handle) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Editor::handle_events() {
|
||||
// Process any remaining events, otherwise we won't be able to interact with
|
||||
// the window
|
||||
if (win32_handle.has_value()) {
|
||||
MSG msg;
|
||||
while (PeekMessage(&msg, win32_handle->get(), 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<size_t> Editor::get_x11_handle() {
|
||||
if (!win32_handle.has_value()) {
|
||||
return std::nullopt;
|
||||
|
||||
Reference in New Issue
Block a user