fix: fix Screenshot fullscreen flickering
This commit is contained in:
@@ -99,7 +99,9 @@ namespace WinServer {
|
||||
WindowSlot& slot = g_slots[windowId];
|
||||
if (!slot.used || slot.eventMailbox == nullptr) return -1;
|
||||
|
||||
int rc = Ipc::MailboxSend(slot.eventMailbox, 0, event, sizeof(*event));
|
||||
int rc = (event->type == 1)
|
||||
? Ipc::MailboxSendCoalescedMouse(slot.eventMailbox, 0, event, sizeof(*event))
|
||||
: Ipc::MailboxSend(slot.eventMailbox, 0, event, sizeof(*event));
|
||||
return rc > 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <Timekeeping/ApicTimer.hpp>
|
||||
#include <Terminal/Terminal.hpp>
|
||||
#include <Api/UserMemory.hpp>
|
||||
#include <Api/Syscall.hpp>
|
||||
|
||||
namespace Ipc {
|
||||
|
||||
@@ -851,6 +852,45 @@ namespace Ipc {
|
||||
return MailboxSendInternal(mailbox, -1, msgType, data, len, -1);
|
||||
}
|
||||
|
||||
int MailboxSendCoalescedMouse(Mailbox* mailbox, uint32_t msgType, const void* data, uint16_t len) {
|
||||
if (mailbox == nullptr || data == nullptr) return -1;
|
||||
if (len != sizeof(Montauk::WinEvent)) return MailboxSend(mailbox, msgType, data, len);
|
||||
|
||||
const Montauk::WinEvent* incoming = (const Montauk::WinEvent*)data;
|
||||
if (incoming->type != 1 || incoming->mouse.scroll != 0)
|
||||
return MailboxSend(mailbox, msgType, data, len);
|
||||
|
||||
bool incomingTransition = incoming->mouse.buttons != incoming->mouse.prev_buttons;
|
||||
if (incomingTransition)
|
||||
return MailboxSend(mailbox, msgType, data, len);
|
||||
|
||||
mailbox->lock.Acquire();
|
||||
if (mailbox->receiverRefs == 0) {
|
||||
mailbox->lock.Release();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mailbox->count > 0) {
|
||||
uint32_t idx = (mailbox->head + MaxMailboxMessages - 1) % MaxMailboxMessages;
|
||||
MailboxMessage& latest = mailbox->messages[idx];
|
||||
if (latest.type == msgType && latest.size == len && !latest.hasAttachment) {
|
||||
const Montauk::WinEvent* queued = (const Montauk::WinEvent*)latest.data;
|
||||
bool queuedTransition = queued->type != 1 ||
|
||||
queued->mouse.scroll != 0 ||
|
||||
queued->mouse.buttons != queued->mouse.prev_buttons;
|
||||
if (!queuedTransition) {
|
||||
memcpy(latest.data, data, len);
|
||||
mailbox->lock.Release();
|
||||
NotifyObjectChanged((Object*)mailbox);
|
||||
return len;
|
||||
}
|
||||
}
|
||||
}
|
||||
mailbox->lock.Release();
|
||||
|
||||
return MailboxSend(mailbox, msgType, data, len);
|
||||
}
|
||||
|
||||
static int MailboxRecvInternal(Mailbox* mailbox, int receiverSlot, uint32_t* msgType,
|
||||
void* data, uint16_t* inOutLen, int* outAttachHandle,
|
||||
bool /*nonBlocking*/) {
|
||||
|
||||
@@ -98,6 +98,7 @@ namespace Ipc {
|
||||
void RetainMailbox(Mailbox* mailbox, bool sender, bool receiver);
|
||||
void ReleaseMailbox(Mailbox* mailbox, bool sender, bool receiver);
|
||||
int MailboxSend(Mailbox* mailbox, uint32_t msgType, const void* data, uint16_t len);
|
||||
int MailboxSendCoalescedMouse(Mailbox* mailbox, uint32_t msgType, const void* data, uint16_t len);
|
||||
int MailboxRecv(Mailbox* mailbox, uint32_t* msgType, void* data, uint16_t* inOutLen, bool nonBlocking);
|
||||
int MailboxSendHandle(int handle, uint32_t msgType, const void* data, uint16_t len, int attachHandle);
|
||||
int MailboxRecvHandle(int handle, uint32_t* msgType, void* data, uint16_t* inOutLen, int* outAttachHandle);
|
||||
|
||||
Reference in New Issue
Block a user