From be9d1a061fdd3460a350bc74a2bc496aaca2d2d6 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Wed, 9 Nov 2022 14:03:51 -0500 Subject: [PATCH] [client] overlay/status: draw a tooltip if the user mouses over the spice icon --- client/src/app.c | 3 +-- client/src/overlay/status.c | 44 +++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/client/src/app.c b/client/src/app.c index f57f0d11..6c85cde8 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -89,8 +89,7 @@ void app_updateCursorPos(double x, double y) g_cursor.pos.y = y; g_cursor.valid = true; - if (app_isOverlayMode()) - g_state.io->MousePos = (ImVec2) { x, y }; + g_state.io->MousePos = (ImVec2) { x, y }; } void app_handleFocusEvent(bool focused) diff --git a/client/src/overlay/status.c b/client/src/overlay/status.c index bf4b5f99..c3e0c99e 100644 --- a/client/src/overlay/status.c +++ b/client/src/overlay/status.c @@ -89,6 +89,7 @@ static int status_render(void * udata, bool interactive, struct Rect * windowRec }; int xPos = screen->x - marginX; + int rects = 1; for(int i = 0; i < LG_USER_STATUS_MAX; ++i) { OverlayImage * img = &l_image[i]; @@ -99,27 +100,52 @@ static int status_render(void * udata, bool interactive, struct Rect * windowRec if (i == LG_USER_STATUS_RECORDING && !l_recordToggle) goto next; + const ImVec2 topRight = (ImVec2){ + xPos, + marginY + }; + const ImVec2 bottomLeft = (ImVec2){ + xPos - ICON_SIZE, + img->height / l_scale + marginY + }; ImDrawList_AddImage( igGetBackgroundDrawList_Nil(), img->tex, - (ImVec2){ - xPos, - marginY - }, - (ImVec2){ - xPos - ICON_SIZE, - img->height / l_scale + marginY - }, + topRight, + bottomLeft, (ImVec2){ 0, 0 }, (ImVec2){ 1, 1 }, 0xFFFFFFFF); + // draw a helpful little tooltip if the user tries to mouse over the spice icon + if (i == LG_USER_STATUS_SPICE && g_cursor.valid) { + const double x = g_state.io->MousePos.x; + const double y = g_state.io->MousePos.y; + if (x >= bottomLeft.x && y <= bottomLeft.y && x <= topRight.x && y >= topRight.y) { + igBeginTooltipEx(ImGuiTooltipFlags_None, ImGuiWindowFlags_None); + igText("Using looking glass through SPICE emulation, there is likely a problem with your setup"); + ImVec2 windowPos; + ImVec2 windowSize; + igGetWindowPos(&windowPos); + igGetWindowSize(&windowSize); + igEndTooltip(); + *windowRects = (struct Rect) { + .x = floorf(windowPos.x), + .y = floorf(windowPos.y), + .w = ceilf(windowSize.x), + .h = ceilf(windowSize.y) + }; + rects++; + windowRects++; + } + } + next: xPos -= ICON_SIZE + gapX; } *windowRects = rect; - return 1; + return rects; } static bool status_tick(void * udata, unsigned long long tickCount)