ui: Handle main window refresh independently

- Cleanup various dead code and minor restructure for clarity
- Separate host and guest updates
- Fix freezes while moving or resizing the main window on Windows by
  registering event watch callback
This commit is contained in:
Matt Borgerson
2026-01-31 13:16:21 -07:00
committed by mborgerson
parent df47b4a7e2
commit 3b7a83d64b
6 changed files with 448 additions and 431 deletions
-32
View File
@@ -1,32 +0,0 @@
#ifndef XEMU_DISPLAY_H
#define XEMU_DISPLAY_H
/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */
#undef WIN32_LEAN_AND_MEAN
#include <SDL3/SDL.h>
#include "ui/kbd-state.h"
struct xemu_console {
DisplayChangeListener dcl;
DisplaySurface *surface;
DisplayOptions *opts;
SDL_Texture *texture;
SDL_Window *real_window;
SDL_Renderer *real_renderer;
int idx;
int last_vm_running; /* per console for caption reasons */
int x, y, w, h;
int hidden;
int opengl;
int updates;
int idle_counter;
int ignore_hotkeys;
SDL_GLContext winctx;
QKbdState *kbd;
bool y0_top;
bool scanout_mode;
};
#endif /* XEMU_DISPLAY_H */
+4 -4
View File
@@ -285,7 +285,7 @@ static void absolute_mouse_grab(struct sdl2_console *scon)
}
}
static void sdl_mouse_mode_change(Notifier *notify, void *data)
static void mouse_mode_change(Notifier *notify, void *data)
{
if (qemu_input_is_absolute(sdl2_console[0].dcl.con)) {
if (!absolute_enabled) {
@@ -939,7 +939,7 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
SDL_SetWindowIcon(sdl2_console[0].real_window, icon);
}
mouse_mode_notifier.notify = sdl_mouse_mode_change;
mouse_mode_notifier.notify = mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&mouse_mode_notifier);
sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0);
@@ -961,12 +961,12 @@ static QemuDisplay qemu_display_sdl2 = {
.init = sdl2_display_init,
};
static void register_sdl1(void)
static void register_xemu_display(void)
{
qemu_display_register(&qemu_display_sdl2);
}
type_init(register_sdl1);
type_init(register_xemu_display);
#ifdef CONFIG_OPENGL
module_dep("ui-opengl");
+435 -394
View File
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -189,7 +189,7 @@ void xemu_hud_set_framebuffer_texture(GLuint tex, bool flip)
g_flip_req = flip;
}
void xemu_hud_render(void)
void xemu_hud_update(void)
{
ImGuiIO& io = ImGui::GetIO();
uint32_t now = SDL_GetTicks();
@@ -320,7 +320,10 @@ void xemu_hud_render(void)
// static bool show_demo = true;
// if (show_demo) ImGui::ShowDemoWindow(&show_demo);
}
void xemu_hud_render()
{
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
+2
View File
@@ -30,7 +30,9 @@ static void RunOnMainThread(std::function<void()> &&func)
[](void *userdata) {
std::unique_ptr<std::function<void()>> f(
static_cast<std::function<void()> *>(userdata));
xemu_main_loop_lock();
(*f)();
xemu_main_loop_unlock();
},
p, false)) {
delete p;
+3
View File
@@ -36,10 +36,13 @@ void xemu_toggle_fullscreen(void);
SDL_Window *xemu_get_window(void);
void xemu_eject_disc(Error **errp);
void xemu_load_disc(const char *path, Error **errp);
void xemu_main_loop_lock(void);
void xemu_main_loop_unlock(void);
// Implemented in xemu_hud.cc
void xemu_hud_init(SDL_Window *window, void *sdl_gl_context);
void xemu_hud_cleanup(void);
void xemu_hud_update(void);
void xemu_hud_render(void);
void xemu_hud_process_sdl_events(SDL_Event *event);
void xemu_hud_should_capture_kbd_mouse(int *kbd, int *mouse);