fix: GUI and kernel fixes, Wikipedia app rewrite, among other things
This commit is contained in:
@@ -833,6 +833,15 @@ namespace Zenith {
|
||||
return WinServer::SendEvent(windowId, event);
|
||||
}
|
||||
|
||||
static uint64_t Sys_WinResize(int windowId, int newW, int newH) {
|
||||
auto* proc = Sched::GetCurrentProcessPtr();
|
||||
if (proc == nullptr) return 0;
|
||||
uint64_t outVa = 0;
|
||||
int r = WinServer::Resize(windowId, proc->pid, proc->pml4Phys, newW, newH,
|
||||
proc->heapNext, outVa);
|
||||
return (r == 0) ? outVa : 0;
|
||||
}
|
||||
|
||||
// ---- Dispatch ----
|
||||
|
||||
extern "C" int64_t SyscallDispatch(SyscallFrame* frame) {
|
||||
@@ -986,6 +995,8 @@ namespace Zenith {
|
||||
return (int64_t)Sys_WinMap((int)frame->arg1);
|
||||
case SYS_WINSENDEVENT:
|
||||
return (int64_t)Sys_WinSendEvent((int)frame->arg1, (const WinEvent*)frame->arg2);
|
||||
case SYS_WINRESIZE:
|
||||
return (int64_t)Sys_WinResize((int)frame->arg1, (int)frame->arg2, (int)frame->arg3);
|
||||
case SYS_PROCLIST:
|
||||
return (int64_t)Sys_ProcList((ProcInfo*)frame->arg1, (int)frame->arg2);
|
||||
case SYS_KILL:
|
||||
|
||||
@@ -74,6 +74,7 @@ namespace Zenith {
|
||||
static constexpr uint64_t SYS_WINENUM = 58;
|
||||
static constexpr uint64_t SYS_WINMAP = 59;
|
||||
static constexpr uint64_t SYS_WINSENDEVENT = 60;
|
||||
static constexpr uint64_t SYS_WINRESIZE = 64;
|
||||
|
||||
// Process management syscalls
|
||||
static constexpr uint64_t SYS_PROCLIST = 61;
|
||||
|
||||
@@ -162,6 +162,45 @@ namespace WinServer {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Resize(int windowId, int callerPid, uint64_t ownerPml4, int newW, int newH,
|
||||
uint64_t& heapNext, uint64_t& outVa) {
|
||||
if (windowId < 0 || windowId >= MaxWindows) return -1;
|
||||
WindowSlot& slot = g_slots[windowId];
|
||||
if (!slot.used || slot.ownerPid != callerPid) return -1;
|
||||
if (newW <= 0 || newH <= 0) return -1;
|
||||
if (newW == slot.width && newH == slot.height) {
|
||||
outVa = slot.ownerVa;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t bufSize = (uint64_t)newW * newH * 4;
|
||||
int numPages = (int)((bufSize + 0xFFF) / 0x1000);
|
||||
if (numPages > MaxPixelPages) return -1;
|
||||
|
||||
// Allocate new pages and map into owner's address space
|
||||
uint64_t userVa = heapNext;
|
||||
for (int i = 0; i < numPages; i++) {
|
||||
void* page = Memory::g_pfa->AllocateZeroed();
|
||||
if (page == nullptr) return -1;
|
||||
uint64_t physAddr = Memory::SubHHDM((uint64_t)page);
|
||||
slot.pixelPhysPages[i] = physAddr;
|
||||
Memory::VMM::Paging::MapUserIn(ownerPml4, physAddr, userVa + (uint64_t)i * 0x1000);
|
||||
}
|
||||
|
||||
slot.width = newW;
|
||||
slot.height = newH;
|
||||
slot.pixelNumPages = numPages;
|
||||
slot.ownerVa = userVa;
|
||||
heapNext += (uint64_t)numPages * 0x1000;
|
||||
|
||||
// Invalidate desktop mapping so it re-maps on next enumerate
|
||||
slot.desktopVa = 0;
|
||||
slot.desktopPid = 0;
|
||||
|
||||
outVa = userVa;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CleanupProcess(int pid) {
|
||||
for (int i = 0; i < MaxWindows; i++) {
|
||||
if (g_slots[i].used && g_slots[i].ownerPid == pid) {
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace WinServer {
|
||||
int Enumerate(Zenith::WinInfo* outArray, int maxCount);
|
||||
uint64_t Map(int windowId, int callerPid, uint64_t callerPml4, uint64_t& heapNext);
|
||||
int SendEvent(int windowId, const Zenith::WinEvent* event);
|
||||
int Resize(int windowId, int callerPid, uint64_t ownerPml4, int newW, int newH,
|
||||
uint64_t& heapNext, uint64_t& outVa);
|
||||
void CleanupProcess(int pid);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user