Skip to content

Commit

Permalink
* Fix some redraw issues with compact mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
iProgramMC committed May 17, 2024
1 parent 1bacb10 commit 792a79c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/windows/Frontend_Win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void Frontend_Win32::OnWebsocketFail(int gatewayID, int errorCode, const std::st
if (isTLSError) {
_tcscat(
buffer,
TEXT("WARNING: Your connection may not be private\n\nDiscord Messenger could not verify that it is connecting to a Websocket service ")
TEXT("\n\nWARNING: Your connection may not be private\n\nDiscord Messenger could not verify that it is connecting to a Websocket service ")
TEXT("required to use Discord Messenger in real time.")
TEXT("\n\nThis could be because:")
TEXT("\no Your computer does not trust the certificate that the gateway has declared because it is wrong,")
Expand Down
18 changes: 15 additions & 3 deletions src/windows/MessageList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2211,8 +2211,10 @@ void MessageList::DrawMessage(HDC hdc, MessageItem& item, RECT& msgRect, RECT& c

RECT rcMsg = rc;
rcMsg.bottom -= item.m_attachHeight + item.m_embedHeight;
if (item.m_attachHeight)
rcMsg.bottom -= ATTACHMENT_GAP;
item.m_message.Layout(&mddc, Rect(W32RECT(rcMsg)), bIsCompact ? (item.m_authWidth + item.m_dateWidth + ScaleByDPI(10)) : 0);

Rect ext = item.m_message.GetExtent();
int height = std::max(item.m_authHeight, ext.Height());
int offsetY = ((rcMsg.bottom - rcMsg.top) - ext.Height()) / 2;
Expand Down Expand Up @@ -2336,6 +2338,8 @@ void MessageList::DrawMessage(HDC hdc, MessageItem& item, RECT& msgRect, RECT& c
embedRect.right = msgRect.right - ScaleByDPI(10);
embedRect.top = embedRect.bottom;

if (bIsCompact) embedRect.left = rc.left;

for (size_t i = 0; i < sz; i++)
{
auto& eitem = embedVec[i];
Expand Down Expand Up @@ -2890,7 +2894,15 @@ LRESULT CALLBACK MessageList::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
SRCCOPY
);
ReleaseDC(hWnd, hdc);
InvalidateRect(hWnd, &refreshRect, false);

SCROLLINFO si;
ZeroMemory(&si, sizeof(SCROLLINFO));
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_PAGE;
GetScrollInfo(hWnd, SB_VERT, &si);

InvalidateRect(hWnd, &refreshRect, si.nPage > pThis->m_total_height);

break;
}
case WM_MOUSEMOVE:
Expand Down Expand Up @@ -3480,7 +3492,7 @@ int MessageList::RecalcMessageSizes(bool update, int& repaintSize, Snowflake add
bool modifyChainOrder = addedMessagesBeforeThisID == 0 || iter->m_msg.m_snowflake <= addedMessagesBeforeThisID;

bool bIsDateGap = ShouldBeDateGap(prevTime, iter->m_msg.m_dateTime);
bool startNewChain = ShouldStartNewChain(prevAuthor, prevTime, prevPlaceInChain, prevType, *iter, modifyChainOrder);
bool startNewChain = isCompact || ShouldStartNewChain(prevAuthor, prevTime, prevPlaceInChain, prevType, *iter, modifyChainOrder);

bool msgOldIsDateGap = iter->m_bIsDateGap;
bool msgOldWasChainBeg = iter->m_placeInChain == 0;
Expand Down

0 comments on commit 792a79c

Please sign in to comment.