Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.
C++
fix: keep compact status and settings reachable across UI scale changes
Veyra Goal Agentee46c5f4109f
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cppindex f0b3d93d..3dd463c8 100644--- a/apps/veyra/SettingsWindow.cpp+++ b/apps/veyra/SettingsWindow.cpp@@ -19,7 +19,7 @@ LRESULT send(int id,UINT message,WPARAM w=0,LPARAM l=0){return SendMessageW(itemvoid putText(int id,const wchar_t* value){setText(item(id),value);}void check(int id,UINT value){if(send(id,BM_GETCHECK)!=value)send(id,BM_SETCHECK,value);}UINT checked(int id){return UINT(send(id,BM_GETCHECK));}-int viewportHeight(){RECT r{};GetClientRect(body,&r);return std::max(1,MulDiv(r.bottom,96,GetDpiForWindow(window)));}+int viewportHeight(){RECT r{};GetClientRect(body,&r);return std::max(1,MulDiv(r.bottom,96,veyra::ui::layoutDpi(window)));}void arrange();LRESULT CALLBACK bodyProc(HWND h,UINT msg,WPARAM wp,LPARAM lp){if(msg==WM_ERASEBKGND)return 1;@@ -115,7 +115,7 @@ LRESULT CALLBACK scrollOnly(HWND h,UINT msg,WPARAM wp,LPARAM lp,UINT_PTR id,DWORvoid refreshPresets(){auto list=item(300);SendMessageW(list,CB_RESETCONTENT,0,0);for(auto& p:store.entries())SendMessageW(list,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(p.name.c_str()));if(!store.entries().empty())SendMessageW(list,CB_SETCURSEL,0,0);PostMessageW(GetParent(window),WM_APP+42,0,0);}void arrange(){- if(!window||!body)return;RECT r{};GetClientRect(window,&r);int width=MulDiv(r.right,96,GetDpiForWindow(window)),height=MulDiv(r.bottom,96,GetDpiForWindow(window));+ if(!window||!body)return;RECT r{};GetClientRect(window,&r);int width=MulDiv(r.right,96,veyra::ui::layoutDpi(window)),height=MulDiv(r.bottom,96,veyra::ui::layoutDpi(window));const int sticky=128,viewport=std::max(1,height-sticky);contentHeight=0;for(auto& entry:items)if(entry.page==page){wchar_t cls[32]{};GetClassNameW(entry.h,cls,32);contentHeight=std::max(contentHeight,entry.y+(_wcsicmp(cls,L"COMBOBOX")==0?36:entry.height)+12);}scroll=std::clamp(scroll,0,std::max(0,contentHeight-viewport));@@ -190,9 +190,9 @@ case WM_SIZE:arrange();return 0;case WM_ERASEBKGND:return 1;case WM_PAINT:{PaintBuffer paint(h);fillSurface(paint.dc,paint.rect,h);return 0;}case WM_VSCROLL:{switch(LOWORD(wp)){case SB_LINEUP:scroll-=40;break;case SB_LINEDOWN:scroll+=40;break;case SB_PAGEUP:scroll-=240;break;case SB_PAGEDOWN:scroll+=240;break;case SB_THUMBTRACK:{SCROLLINFO si{sizeof(si),SIF_TRACKPOS};GetScrollInfo(h,SB_VERT,&si);scroll=si.nTrackPos;break;}}arrange();return 0;}-case WM_MOUSEWHEEL:scroll-=GET_WHEEL_DELTA_WPARAM(wp)/WHEEL_DELTA*90;arrange();return 0;+case WM_MOUSEWHEEL:scroll-=GET_WHEEL_DELTA_WPARAM(wp)/WHEEL_DELTA*36;arrange();return 0;case WM_CTLCOLORSTATIC:case WM_CTLCOLOREDIT:case WM_CTLCOLORLISTBOX:case WM_CTLCOLORBTN:return colors(msg,wp,lp);-case WM_COMMAND:{const int id=LOWORD(wp);if(!populating&&((id>=202&&id<=205||id==207||id==208)&&HIWORD(wp)==CBN_SELCHANGE||(id>=700&&id<=732)&&HIWORD(wp)==BN_CLICKED)){liveField(id);return 0;}if((id==206||id==213||id==214)&&HIWORD(wp)==BN_CLICKED){const auto accepted=SendMessageW(GetParent(h),WM_APP+45,id,checked(206));message(accepted?(id==213?L"请在画面中左键拖动框选;Esc取消。":L"已请求更新NR保护区域。"):L"未能操作:请先打开画面,或清除已满的4个区域。");return 0;}if((id==200||id==201)&&HIWORD(wp)==BN_CLICKED){const bool accepted=SendMessageW(GetParent(h),WM_APP+44,id,checked(id))!=0;message(accepted?L"已请求开关;确认帧边界结果后生效。":L"总增强正在切换,请待当前事务完成。");return 0;}if(HIWORD(wp)==EN_SETFOCUS){for(auto& item:items)if(GetDlgCtrlID(item.h)==id&&item.page==page){RECT r{};GetClientRect(h,&r);int height=MulDiv(r.bottom,96,GetDpiForWindow(h))-128;if(item.y<scroll)scroll=item.y;if(item.y+item.height>scroll+height)scroll=item.y+item.height-height;arrange();break;}}if(!populating&&id>=100&&id<=111&&HIWORD(wp)==EN_CHANGE){liveField(id);return 0;}+case WM_COMMAND:{const int id=LOWORD(wp);if(!populating&&((id>=202&&id<=205||id==207||id==208)&&HIWORD(wp)==CBN_SELCHANGE||(id>=700&&id<=732)&&HIWORD(wp)==BN_CLICKED)){liveField(id);return 0;}if((id==206||id==213||id==214)&&HIWORD(wp)==BN_CLICKED){const auto accepted=SendMessageW(GetParent(h),WM_APP+45,id,checked(206));message(accepted?(id==213?L"请在画面中左键拖动框选;Esc取消。":L"已请求更新NR保护区域。"):L"未能操作:请先打开画面,或清除已满的4个区域。");return 0;}if((id==200||id==201)&&HIWORD(wp)==BN_CLICKED){const bool accepted=SendMessageW(GetParent(h),WM_APP+44,id,checked(id))!=0;message(accepted?L"已请求开关;确认帧边界结果后生效。":L"总增强正在切换,请待当前事务完成。");return 0;}if(HIWORD(wp)==EN_SETFOCUS){for(auto& item:items)if(GetDlgCtrlID(item.h)==id&&item.page==page){RECT r{};GetClientRect(h,&r);int height=MulDiv(r.bottom,96,veyra::ui::layoutDpi(h))-128;if(item.y<scroll)scroll=item.y;if(item.y+item.height>scroll+height)scroll=item.y+item.height-height;arrange();break;}}if(!populating&&id>=100&&id<=111&&HIWORD(wp)==EN_CHANGE){liveField(id);return 0;}if(!populating&&id>=100&&id<=111&&HIWORD(wp)==EN_KILLFOCUS){populate(enhancementEnabled?controller->snapshot().desired:configuredSettings);return 0;}engine::EnhancementSettings s;wchar_t name[128]{};GetWindowTextW(item(301),name,128);const auto index=size_t(send(300,CB_GETCURSEL,0,0));bool ok=true;if(id==211){SetFocus(body);s={};if(submit(s)){populate(s);message(L"已还原内建默认;用户预设保留");}}diff --git a/apps/veyra/TelemetryWindow.cpp b/apps/veyra/TelemetryWindow.cppindex 6590f847..00a030c2 100644--- a/apps/veyra/TelemetryWindow.cpp+++ b/apps/veyra/TelemetryWindow.cpp@@ -33,7 +33,7 @@ void refresh(){auto s=engine->snapshot();const wchar_t* names[]={L"上传/颜色o<<L"光流请求:"<<flowName<<L";实际SDK perf="<<s.flowPerf<<L";grid=4(已验证SDK能力)\r\n内容节奏:"<<(s.contentFps?std::to_wstring(s.contentFps)+L"fps":L"未确认(静态或证据不足)")<<L";保留源时间戳,重复内容不计有效生成\r\n"<<s.status;setText(GetDlgItem(window,1),o.str());}-void arrange(){RECT r{};GetClientRect(window,&r);int width=MulDiv(r.right,96,GetDpiForWindow(window)),height=MulDiv(r.bottom,96,GetDpiForWindow(window));auto pos=[&](int id,int x,int y,int w,int h){MoveWindow(GetDlgItem(window,id),dip(window,x),dip(window,y),dip(window,std::max(1,w)),dip(window,std::max(1,h)),TRUE);};bool wide=width>=700;pos(6,width-56,8,40,32);pos(7,16,10,width-80,32);pos(1,16,52,wide?width/2-24:width-32,wide?height-116:height/2-68);pos(2,wide?width/2+8:16,wide?96:height/2+36,wide?width/2-24:width-32,wide?height-160:height/2-100);pos(3,wide?width/2+8:16,wide?52:height/2-8,wide?width/2-24:width-32,36);pos(4,16,height-52,width/2-24,36);pos(5,width/2+8,height-52,width/2-24,36);}+void arrange(){RECT r{};GetClientRect(window,&r);int width=MulDiv(r.right,96,veyra::ui::layoutDpi(window)),height=MulDiv(r.bottom,96,veyra::ui::layoutDpi(window));auto pos=[&](int id,int x,int y,int w,int h){MoveWindow(GetDlgItem(window,id),dip(window,x),dip(window,y),dip(window,std::max(1,w)),dip(window,std::max(1,h)),TRUE);};bool wide=width>=700;pos(6,width-56,8,40,32);pos(7,16,10,width-80,32);pos(1,16,52,wide?width/2-24:width-32,wide?height-116:height/2-68);pos(2,wide?width/2+8:16,wide?96:height/2+36,wide?width/2-24:width-32,wide?height-160:height/2-100);pos(3,wide?width/2+8:16,wide?52:height/2-8,wide?width/2-24:width-32,36);pos(4,16,height-52,width/2-24,36);pos(5,width/2+8,height-52,width/2-24,36);}LRESULT CALLBACK proc(HWND h,UINT m,WPARAM w,LPARAM l){switch(m){case WM_CREATE:{preview.clear();window=h;font=makeFont(h,13);auto add=[&](const wchar_t* c,const wchar_t* t,int id,DWORD style){auto child=CreateWindowExW(0,c,t,WS_CHILD|WS_VISIBLE|style,0,0,1,1,h,reinterpret_cast<HMENU>(INT_PTR(id)),GetModuleHandleW(nullptr),nullptr);SendMessageW(child,WM_SETFONT,reinterpret_cast<WPARAM>(font),TRUE);themeControl(child);};add(L"EDIT",L"",1,ES_MULTILINE|ES_READONLY|WS_VSCROLL|WS_TABSTOP);add(L"BUTTON",L"查看 / 刷新脱敏预览",3,BS_PUSHBUTTON|WS_TABSTOP);add(L"EDIT",L"点击上方按钮查看诊断。复制只会复制这里预览过的脱敏文字。",2,ES_MULTILINE|ES_READONLY|WS_VSCROLL|WS_TABSTOP);add(L"BUTTON",L"复制已预览内容",4,BS_PUSHBUTTON|WS_TABSTOP);add(L"BUTTON",L"打开本应用日志目录",5,BS_PUSHBUTTON|WS_TABSTOP);add(L"BUTTON",L"关闭诊断",6,BS_PUSHBUTTON|WS_TABSTOP);icon(GetDlgItem(h,6),Icon::Close);add(L"STATIC",L"性能与诊断 / 播放会话",7,0);SetTimer(h,1,250,nullptr);arrange();refresh();return 0;}case WM_ERASEBKGND:return 1;diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cppindex 605c42b1..0eca8c5f 100644--- a/apps/veyra/ui/AppShell.cpp+++ b/apps/veyra/ui/AppShell.cpp@@ -134,7 +134,7 @@ void switchMode(){}void layout(){if(!mainWindow||!video)return;const auto layoutBegin=std::chrono::steady_clock::now();using namespace veyra::ui;- RECT r{};GetClientRect(mainWindow,&r);int w=MulDiv(r.right,96,GetDpiForWindow(mainWindow)),h=MulDiv(r.bottom,96,GetDpiForWindow(mainWindow));+ RECT r{};GetClientRect(mainWindow,&r);int w=MulDiv(r.right,96,veyra::ui::layoutDpi(mainWindow)),h=MulDiv(r.bottom,96,veyra::ui::layoutDpi(mainWindow));const bool pro=uiState.mode==Mode::Professional;auto g=chromeLayout(w,h);auto target=engine.snapshot();auto pane=[&](int x,int y,int width,int height,int radius,BYTE tint){return GlassPane{{dip(mainWindow,x),dip(mainWindow,y),dip(mainWindow,x+width),dip(mainWindow,y+height)},dip(mainWindow,radius),tint};};std::vector<GlassPane> panes;@@ -250,10 +250,10 @@ case WM_NCACTIVATE:return DefWindowProcW(hwnd,msg,wp,-1);case WM_NCPAINT:return 0;case WM_ERASEBKGND:return 1;case WM_NCHITTEST:{LRESULT hit=DefWindowProcW(hwnd,msg,wp,lp);if(hit==HTCLIENT&&!full){POINT p{GET_X_LPARAM(lp),GET_Y_LPARAM(lp)};ScreenToClient(hwnd,&p);RECT r{};GetClientRect(hwnd,&r);int edge=veyra::ui::dip(hwnd,7);bool left=p.x<edge,right=p.x>=r.right-edge,top=p.y<edge,bottom=p.y>=r.bottom-edge;if(top&&left)return HTTOPLEFT;if(top&&right)return HTTOPRIGHT;if(bottom&&left)return HTBOTTOMLEFT;if(bottom&&right)return HTBOTTOMRIGHT;if(left)return HTLEFT;if(right)return HTRIGHT;if(top)return HTTOP;if(bottom)return HTBOTTOM;if((uiState.mode==veyra::ui::Mode::Professional&&p.y<veyra::ui::dip(hwnd,54))||(uiState.mode==veyra::ui::Mode::Daily&&p.y>r.bottom-veyra::ui::dip(hwnd,88)))return HTCAPTION;}return hit;}-case WM_PAINT:{veyra::ui::PaintBuffer paint(hwnd);auto g=chromeLayout(MulDiv(paint.rect.right,96,GetDpiForWindow(hwnd)),MulDiv(paint.rect.bottom,96,GetDpiForWindow(hwnd)));veyra::ui::paintChrome(hwnd,paint.dc,g,engine.snapshot(),full);return 0;}+case WM_PAINT:{veyra::ui::PaintBuffer paint(hwnd);auto g=chromeLayout(MulDiv(paint.rect.right,96,veyra::ui::layoutDpi(hwnd)),MulDiv(paint.rect.bottom,96,veyra::ui::layoutDpi(hwnd)));veyra::ui::paintChrome(hwnd,paint.dc,g,engine.snapshot(),full);return 0;}-case WM_LBUTTONDOWN:{if(uiState.mode==veyra::ui::Mode::Professional&&!full){RECT r{};GetClientRect(hwnd,&r);int w=MulDiv(r.right,96,GetDpiForWindow(hwnd)),x=MulDiv(GET_X_LPARAM(lp),96,GetDpiForWindow(hwnd));if(w>=1180&&abs(x-(w-uiPreferences.inspectorWidth-27))<8){inspectorResizing=true;proposedInspectorWidth=uiPreferences.inspectorWidth;SetCapture(hwnd);return 0;}}break;}-case WM_MOUSEMOVE:if(inspectorResizing){RECT r{};GetClientRect(hwnd,&r);proposedInspectorWidth=std::clamp(MulDiv(r.right-GET_X_LPARAM(lp),96,GetDpiForWindow(hwnd))-27,296,420);InvalidateRect(hwnd,nullptr,FALSE);return 0;}break;+case WM_LBUTTONDOWN:{if(uiState.mode==veyra::ui::Mode::Professional&&!full){RECT r{};GetClientRect(hwnd,&r);int w=MulDiv(r.right,96,veyra::ui::layoutDpi(hwnd)),x=MulDiv(GET_X_LPARAM(lp),96,veyra::ui::layoutDpi(hwnd));if(w>=1180&&abs(x-(w-uiPreferences.inspectorWidth-27))<8){inspectorResizing=true;proposedInspectorWidth=uiPreferences.inspectorWidth;SetCapture(hwnd);return 0;}}break;}+case WM_MOUSEMOVE:if(inspectorResizing){RECT r{};GetClientRect(hwnd,&r);proposedInspectorWidth=std::clamp(MulDiv(r.right-GET_X_LPARAM(lp),96,veyra::ui::layoutDpi(hwnd))-27,296,420);InvalidateRect(hwnd,nullptr,FALSE);return 0;}break;case WM_LBUTTONUP:if(inspectorResizing){inspectorResizing=false;ReleaseCapture();uiPreferences.inspectorWidth=proposedInspectorWidth;layout();return 0;}break;case WM_CAPTURECHANGED:if(inspectorResizing){inspectorResizing=false;InvalidateRect(hwnd,nullptr,FALSE);}break;case WM_NOTIFY:{auto header=reinterpret_cast<NMHDR*>(lp);if(header->code==TTN_GETDISPINFOW){auto info=reinterpret_cast<NMTTDISPINFOW*>(lp);HWND child=reinterpret_cast<HWND>(header->idFrom);if(auto tip=GetPropW(child,L"veyra.tip"))info->lpszText=reinterpret_cast<wchar_t*>(tip);else{static wchar_t value[512];GetWindowTextW(child,value,512);info->lpszText=value;}return 0;}break;}@@ -315,7 +315,19 @@ case WM_SYSKEYDOWN:if(wp==VK_RETURN&&(lp&(1LL<<29))){toggleFullscreen();return 0case WM_THEMECHANGED:veyra::ui::glassTextTheme().reset();[[fallthrough]];case WM_DWMCOMPOSITIONCHANGED:backdrop.configure();RedrawWindow(hwnd,nullptr,nullptr,RDW_INVALIDATE|RDW_ALLCHILDREN);return 0;case WM_ACTIVATEAPP:if(!wp){holdOriginal=false;updateComparison();}break;-case WM_DPICHANGED:{auto rect=reinterpret_cast<RECT*>(lp);if(!full)SetWindowPos(hwnd,nullptr,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,SWP_NOZORDER|SWP_NOACTIVATE);auto oldFont=font;font=CreateFontW(-MulDiv(15,HIWORD(wp),96),0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,0,0,CLEARTYPE_QUALITY,0,L"Microsoft YaHei UI");EnumChildWindows(hwnd,[](HWND c,LPARAM f)->BOOL{SendMessageW(c,WM_SETFONT,WPARAM(f),TRUE);return TRUE;},LPARAM(font));DeleteObject(oldFont);DeleteObject(emptyFont);emptyFont=veyra::ui::makeFont(hwnd,26);SendDlgItemMessageW(hwnd,EmptyTitle,WM_SETFONT,WPARAM(emptyFont),TRUE);veyra::ui::settingsDpi();veyra::ui::telemetryDpi();layout();return 0;}+case WM_APP+90:+ if(smokeSeconds<=0||!(wp==0||wp==96||wp==144||wp==192))return 0;+ veyra::ui::smokeLayoutDpi=UINT(wp);+ veyra::log::info("ui-dpi-test",std::format("syntheticLayoutDpi={} windowsDpi={}",wp,GetDpiForWindow(hwnd)));+ [[fallthrough]];+case WM_DPICHANGED:{+ endTransition();veyra::ui::cancelPopupSelector();+ if(msg==WM_DPICHANGED&&!full){auto rect=reinterpret_cast<RECT*>(lp);SetWindowPos(hwnd,nullptr,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,SWP_NOZORDER|SWP_NOACTIVATE);}+ auto oldFont=font;font=veyra::ui::makeFont(hwnd);+ EnumChildWindows(hwnd,[](HWND c,LPARAM f)->BOOL{SendMessageW(c,WM_SETFONT,WPARAM(f),FALSE);return TRUE;},LPARAM(font));+ DeleteObject(oldFont);DeleteObject(emptyFont);emptyFont=veyra::ui::makeFont(hwnd,26);+ SendDlgItemMessageW(hwnd,EmptyTitle,WM_SETFONT,WPARAM(emptyFont),FALSE);+ veyra::ui::settingsDpi();veyra::ui::telemetryDpi();layout();return 0;}case WM_TIMER:{if(wp==2){transition.sample(GetTickCount64());if(!transition.running){endTransition();veyra::log::info("ui-transition","completed; final layout and swapchain resize released");}layout();return 0;}if(full&&fullControls&&!menuOpen&&!veyra::ui::popupSelectorOpen()&&!GetCapture()&&GetTickCount64()-pointerTick>1600){POINT p{};GetCursorPos(&p);ScreenToClient(hwnd,&p);RECT r{};GetClientRect(hwnd,&r);if(p.y<r.bottom-veyra::ui::dip(hwnd,88)||p.x<0||p.x>=r.right||p.y>=r.bottom){fullControls=false;layout();if(GetForegroundWindow()==hwnd)SetCursor(nullptr);veyra::log::info("ui-fullscreen","controls hidden; video and subtitles only");}}@@ -402,7 +414,7 @@ if(smokeProtection&&startTick&&GetTickCount64()-startTick>1500){}if(smokeSeconds>0&&startTick&&GetTickCount64()-startTick>ULONGLONG(smokeSeconds)*1000){veyra::log::info("app",std::format("smoke frames={} generated={} failed={} latenessMs={:.2f} absLatenessP95Ms={:.2f} controlsStep={} capture={} processedFps={:.2f} callbackFps={:.2f} captureDropped={} callbackToPresentReturnP95Ms={:.3f} schedulingWaitP95Ms={:.3f} processCpuP95Ms={:.3f} presentCpuP95Ms={:.3f} nrEvaluated={} nvofExecuted={}",s.frames,s.generated,s.failed,s.lateMs,s.lateP95Ms,smokeStep,s.capture,s.fps,s.captureFps,s.captureDropped,s.captureAgeP95Ms,s.schedulingWaitP95Ms,s.processCpuP95Ms,s.presentCpuP95Ms,s.nrEvaluated,s.nvofExecuted));resultCode=(s.frames>0||smokeEmpty)&&!s.failed&&(!smokeZoom||zoomStep==3)&&(!smokeProtection||protectionStep==4)&&(!smokeRepair||repairStep==10)&&(!smokeSettings||settingsStep==3)&&(!smokeRollback||settingsStep==3)&&(!smokeUi||uiStep==8)&&(!smokeDual||dualStep==40)&&(!smokeMaster||masterStep==3)&&(!smokeAudio||audioStep==4)&&(!(smokeJob||smokeJobCancel)||jobStep==4)?0:1;PostMessageW(hwnd,WM_CLOSE,0,0);}return 0;}-case WM_CLOSE:endTransition();if(!closing&&smokeSeconds<=0&&exportJob.poll().active()&&MessageBoxW(hwnd,L"导出尚未完成。取消导出并退出?\n选择“否”返回播放器继续导出。",L"退出 Veyra",MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION)!=IDYES)return 0;if(!closing&&smokeSeconds<=0){auto snapshot=engine.snapshot();WINDOWPLACEMENT placement{sizeof(placement)};if(full)placement=windowPlacement;else GetWindowPlacement(hwnd,&placement);auto r=placement.rcNormalPosition;uiPreferences.width=MulDiv(r.right-r.left,96,GetDpiForWindow(hwnd));uiPreferences.height=MulDiv(r.bottom-r.top,96,GetDpiForWindow(hwnd));uiPreferences.x=r.left;uiPreferences.y=r.top;uiPreferences.positioned=true;uiPreferences.volume=snapshot.volume;uiPreferences.muted=snapshot.muted;uiPreferences.subtitles=uiState.subtitles;uiPreferences.subtitleSize=subtitlePixels;uiPreferences.inspector=uiState.inspector;const bool confirmed=snapshot.frames>0&&!snapshot.applying&&!snapshot.failed;if(!preferences.save(uiPreferences,haveSuccessful?&lastSuccessful:nullptr))veyra::log::warn("ui-preferences","preferences not saved; corrupt original preserved");}exportJob.cancel();closing=true;engine.stop();SetWindowTextW(statusBar,L"正在释放当前任务资源…");return 0;+case WM_CLOSE:endTransition();if(!closing&&smokeSeconds<=0&&exportJob.poll().active()&&MessageBoxW(hwnd,L"导出尚未完成。取消导出并退出?\n选择“否”返回播放器继续导出。",L"退出 Veyra",MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION)!=IDYES)return 0;if(!closing&&smokeSeconds<=0){auto snapshot=engine.snapshot();WINDOWPLACEMENT placement{sizeof(placement)};if(full)placement=windowPlacement;else GetWindowPlacement(hwnd,&placement);auto r=placement.rcNormalPosition;uiPreferences.width=MulDiv(r.right-r.left,96,veyra::ui::layoutDpi(hwnd));uiPreferences.height=MulDiv(r.bottom-r.top,96,veyra::ui::layoutDpi(hwnd));uiPreferences.x=r.left;uiPreferences.y=r.top;uiPreferences.positioned=true;uiPreferences.volume=snapshot.volume;uiPreferences.muted=snapshot.muted;uiPreferences.subtitles=uiState.subtitles;uiPreferences.subtitleSize=subtitlePixels;uiPreferences.inspector=uiState.inspector;const bool confirmed=snapshot.frames>0&&!snapshot.applying&&!snapshot.failed;if(!preferences.save(uiPreferences,haveSuccessful?&lastSuccessful:nullptr))veyra::log::warn("ui-preferences","preferences not saved; corrupt original preserved");}exportJob.cancel();closing=true;engine.stop();SetWindowTextW(statusBar,L"正在释放当前任务资源…");return 0;case WM_DESTROY:backdrop.detach();DeleteObject(font);DeleteObject(emptyFont);PostQuitMessage(resultCode);return 0;}return DefWindowProcW(hwnd,msg,wp,lp);}}diff --git a/apps/veyra/ui/CapturePanel.cpp b/apps/veyra/ui/CapturePanel.cppindex d81c17df..3d85f589 100644--- a/apps/veyra/ui/CapturePanel.cpp+++ b/apps/veyra/ui/CapturePanel.cpp@@ -12,7 +12,7 @@ std::vector<source::CaptureFormat> formats;void query(int device){if(busy)return;busy=true;queriedDevice=device;queryStarted=GetTickCount64();SetDlgItemTextW(window,8,L"正在查询设备能力…当前播放继续");EnableWindow(GetDlgItem(window,4),FALSE);EnableWindow(GetDlgItem(window,5),FALSE);EnableWindow(GetDlgItem(window,1),FALSE);pending=std::async(std::launch::async,[device]{CoInitializeEx(nullptr,COINIT_MULTITHREADED);Query result;result.device=device;try{if(device<0){result.video=source::CaptureCardSource::devices();result.audio=source::CaptureCardSource::devices(true);}else result.formats=source::CaptureCardSource::formats(unsigned(device));}catch(...){}CoUninitialize();return result;});}-void arrange(){RECT r{};GetClientRect(window,&r);const int width=MulDiv(r.right,96,GetDpiForWindow(window));const int ys[]={0,44,114,184,308,308,14,84,240,154};for(int id=1;id<=9;++id){int x=id==5?width-152:16;int w=id==4?width-184:id==5?136:width-32;MoveWindow(GetDlgItem(window,id),dip(window,x),dip(window,ys[id]),dip(window,w),dip(window,id<=3?180:id==8?56:id==4||id==5?36:24),TRUE);}}+void arrange(){RECT r{};GetClientRect(window,&r);const int width=MulDiv(r.right,96,veyra::ui::layoutDpi(window));const int ys[]={0,44,114,184,308,308,14,84,240,154};for(int id=1;id<=9;++id){int x=id==5?width-152:16;int w=id==4?width-184:id==5?136:width-32;MoveWindow(GetDlgItem(window,id),dip(window,x),dip(window,ys[id]),dip(window,w),dip(window,id<=3?180:id==8?56:id==4||id==5?36:24),TRUE);}}LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM wp,LPARAM lp){switch(msg){case WM_CREATE:{window=h;font=makeFont(h);titleTheme(h);auto add=[&](const wchar_t* cls,const wchar_t* label,int id,DWORD style){auto c=CreateWindowExW(0,cls,label,WS_CHILD|WS_VISIBLE|style,0,0,1,1,h,HMENU(INT_PTR(id)),GetModuleHandleW(nullptr),nullptr);SendMessageW(c,WM_SETFONT,WPARAM(font),TRUE);themeControl(c);};for(int i=1;i<=3;++i)add(L"COMBOBOX",L"",i,CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP);diff --git a/apps/veyra/ui/LiveStatusPanel.h b/apps/veyra/ui/LiveStatusPanel.hindex c7423938..0b323831 100644--- a/apps/veyra/ui/LiveStatusPanel.h+++ b/apps/veyra/ui/LiveStatusPanel.h@@ -12,11 +12,11 @@ inline LRESULT CALLBACK proc(HWND h,UINT message,WPARAM wp,LPARAM lp){case WM_CREATE:SetTimer(h,1,250,nullptr);return 0;case WM_TIMER:if(IsWindowVisible(h))InvalidateRect(h,nullptr,FALSE);return 0;case WM_SIZE:InvalidateRect(h,nullptr,FALSE);return 0;- case WM_MOUSEWHEEL:state->scroll=std::clamp(state->scroll-GET_WHEEL_DELTA_WPARAM(wp)/WHEEL_DELTA*54,0,state->maxScroll);InvalidateRect(h,nullptr,FALSE);return 0;+ case WM_MOUSEWHEEL:state->scroll=std::clamp(state->scroll-GET_WHEEL_DELTA_WPARAM(wp)/WHEEL_DELTA*50,0,state->maxScroll);InvalidateRect(h,nullptr,FALSE);return 0;case WM_ERASEBKGND:return 1;case WM_PAINT:{PaintBuffer paint(h);fillSurface(paint.dc,paint.rect,h);- const int width=MulDiv(paint.rect.right,96,GetDpiForWindow(h)),height=MulDiv(paint.rect.bottom,96,GetDpiForWindow(h));+ const int width=MulDiv(paint.rect.right,96,veyra::ui::layoutDpi(h)),height=MulDiv(paint.rect.bottom,96,veyra::ui::layoutDpi(h));const auto s=state->engine->snapshot();const auto& f=s.metrics.flow;const bool playing=s.running&&!s.image&&s.transport==engine::TransportState::Playing;const bool xess=s.applied.frameGenerationBackend==engine::FrameGenerationBackend::XeSS&&s.applied.multiplier>1;@@ -49,7 +49,7 @@ inline LRESULT CALLBACK proc(HWND h,UINT message,WPARAM wp,LPARAM lp){}rows.emplace_back(L"GPU就绪等待",timing(f.cpuTiming[size_t(diagnostics::CpuStage::ReadyWait)]));rows.emplace_back(L"呈现等待",timing(f.cpuTiming[size_t(diagnostics::CpuStage::DeadlineWait)]));- rows.emplace_back(L"Present调用与锁等待",timing(f.cpuTiming[size_t(diagnostics::CpuStage::Present)]));+ rows.emplace_back(L"Present调用",timing(f.cpuTiming[size_t(diagnostics::CpuStage::Present)]));rows.emplace_back(f.pairCaptureCallbacks?L"A/B采集到达间隔":L"A/B软件取帧间隔",xess?L"SDK内部不可测":timing(f.pairTiming[size_t(diagnostics::PairTiming::ArrivalInterval)]));rows.emplace_back(L"生成呈现距A到达",xess?L"SDK内部不可测":timing(f.pairTiming[size_t(diagnostics::PairTiming::GeneratedFromA)]));rows.emplace_back(L"生成呈现距B到达",xess?L"SDK内部不可测":timing(f.pairTiming[size_t(diagnostics::PairTiming::GeneratedFromB)]));@@ -84,8 +84,8 @@ inline LRESULT CALLBACK proc(HWND h,UINT message,WPARAM wp,LPARAM lp){for(size_t line=0;line<std::max(labels.size(),values.size());++line)wrapped.emplace_back(line<labels.size()?labels[line]:L"",line<values.size()?values[line]:L"");}SelectObject(paint.dc,oldFont);DeleteObject(rowFont);rows=std::move(wrapped);- const int top=96,rowHeight=25,available=std::max(0,height-top-30);- state->maxScroll=std::max(0,int(rows.size())*rowHeight-available);state->scroll=std::clamp(state->scroll,0,state->maxScroll);+ const int top=96,rowHeight=25,available=std::max(0,height-top-30)/rowHeight*rowHeight;+ state->maxScroll=std::max(0,int(rows.size())*rowHeight-available);state->scroll=std::clamp(state->scroll/rowHeight*rowHeight,0,state->maxScroll);const int saved=SaveDC(paint.dc);IntersectClipRect(paint.dc,0,dip(h,top),paint.rect.right,dip(h,top+available));for(size_t i=0;i<rows.size();++i){const int y=top+int(i)*rowHeight-state->scroll;// glassText renders through its own DIB; a parent DC clip does notdiff --git a/apps/veyra/ui/Theme.h b/apps/veyra/ui/Theme.hindex 6f32747a..7149b786 100644--- a/apps/veyra/ui/Theme.h+++ b/apps/veyra/ui/Theme.h@@ -20,7 +20,10 @@ inline constexpr COLORREF background=RGB(9,10,11),panel=RGB(27,28,30),raised=RGBinline HBRUSH bgBrush(){static auto b=CreateSolidBrush(background);return b;}inline HBRUSH panelBrush(){static auto b=CreateSolidBrush(panel);return b;}inline HBRUSH raisedBrush(){static auto b=CreateSolidBrush(raised);return b;}-inline int dip(HWND h,int v){return MulDiv(v,GetDpiForWindow(h),96);}+// Only the bounded smoke harness can set this; normal windows use Windows DPI.+inline UINT smokeLayoutDpi=0;+inline UINT layoutDpi(HWND h){return smokeLayoutDpi?smokeLayoutDpi:std::max(96u,GetDpiForWindow(h));}+inline int dip(HWND h,int v){return MulDiv(v,layoutDpi(h),96);}inline HFONT makeFont(HWND h,int size=14,int weight=FW_NORMAL){return CreateFontW(-dip(h,size),0,0,0,weight,0,0,0,DEFAULT_CHARSET,0,0,CLEARTYPE_QUALITY,0,L"Microsoft YaHei UI");}inline void titleTheme(HWND h){BOOL enabled=TRUE;DwmSetWindowAttribute(h,20,&enabled,sizeof(enabled));DWORD corner=2;DwmSetWindowAttribute(h,33,&corner,sizeof(corner));COLORREF border=0xfffffffe;DwmSetWindowAttribute(h,34,&border,sizeof(border));}// Compose controls and dashboard in memory; never expose the erase/fill pass.diff --git a/apps/veyra/ui/WorkspaceChrome.h b/apps/veyra/ui/WorkspaceChrome.hindex 8d230b18..8f92d7e9 100644--- a/apps/veyra/ui/WorkspaceChrome.h+++ b/apps/veyra/ui/WorkspaceChrome.h@@ -12,7 +12,7 @@ struct ChromeLayout {right=w-panelWidth-20;viewWidth=pro?((w>=960||showDrawer)?right-left-14:w-left-20):w-left*2;viewHeight=pro?std::max(160,h-306):h-88;bottom=top+viewHeight+(pro?14:0);- statusTop=std::min(h-136,std::max(top+336,h-330));+ statusTop=std::min(h-186,std::max(top+336,h-330));}};inline void chromeText(HDC dc,HWND window,std::wstring value,int x,int y,int w,int h,int size,COLORREF c,int weight=FW_NORMAL,UINT flags=DT_LEFT|DT_SINGLELINE|DT_VCENTER){auto font=makeFont(window,size,weight);auto old=SelectObject(dc,font);SetTextColor(dc,c);SetBkMode(dc,TRANSPARENT);RECT r{dip(window,x),dip(window,y),dip(window,x+w),dip(window,y+h)};glassText(dc,value.c_str(),-1,&r,flags|DT_END_ELLIPSIS);SelectObject(dc,old);DeleteObject(font);}@@ -20,7 +20,7 @@ inline void paintChrome(HWND window,HDC dc,const ChromeLayout& l,const engine::PRECT client{};GetClientRect(window,&client);if(!copyGlass(dc,client,window))FillRect(dc,&client,bgBrush());if(full)return;using namespace Gdiplus;AlphaGraphics drawing(dc);auto& g=drawing.get();g.SetSmoothingMode(SmoothingModeAntiAlias);if(l.pro){- chromeText(dc,window,L"专业工作台",l.left,18,180,24,13,secondary);+ chromeText(dc,window,L"专业工作台",l.left,18,l.w<960?112:180,24,13,secondary);const auto& resolution=s.metrics.resolution;auto extent=[](uint32_t w,uint32_t h){return w&&h?std::format(L"{} × {}",w,h):std::wstring(L"—");};const int column=std::min(154,(l.viewWidth-40)/3),size=l.viewWidth<600?13:17;diff --git a/docs/CONTINUATION_REPAIR_IMPLEMENTATION_2026-09-10.md b/docs/CONTINUATION_REPAIR_IMPLEMENTATION_2026-09-10.mdindex 20aa86d4..b05540bf 100644--- a/docs/CONTINUATION_REPAIR_IMPLEMENTATION_2026-09-10.md+++ b/docs/CONTINUATION_REPAIR_IMPLEMENTATION_2026-09-10.md@@ -4,6 +4,22 @@## 2026-09-11 续接实证(优先于下面历史进度)+### 最新续接:最小窗口、缩放与选择器回归++基线 `db98af7`,工作树干净。本轮只修改 UI 布局、DPI 与针对性测试,没有改变 SR -> NR -> FG、GPU 调度、音频或导出检查。++- 最小 540 逻辑像素高度时,原状态区只有 116 高,固定标题/主值/页脚后没有可显示的明细。现在预留至少 166 高,仍给设置正文 90 高;状态明细以完整 25 像素行滚动,避免半行裁切后永远不可见。删除已经失效的“Present调用与锁等待”名称,当前计量为 Present 调用。+- 首次实际最小窗口测试 `ui-layout-1789065061472173300` 失败:设置正文 90 高,滚轮也跳 90,FG 选择器从下缘被裁直接跳到上缘被裁。步长改为 36,用户可完整滚出选择器;控件滚轮仍不修改参数。+- 真实 `WM_DPICHANGED` 不再把普通字体从初始 14 改成 15;使用统一 `layoutDpi` 转换字体和逻辑坐标,并取消旧模式动画与弹窗。窄窗标题也限制在增强按钮前,避免绘制矩形重叠。+- 仅 `--smoke-seconds` 测试进程接受 `WM_APP+90` 的 0/96/144/192 缩放注入,普通启动不接受。所有相关窗口与自绘 popup 使用相同缩放;测试没有假造 `WM_DPICHANGED`,没有改变 Windows 缩放。真实当前显示器 DPI=96;150%/200% 是应用缩放/字体测试,**不等于真实跨显示器 DPI 验收**。+- 新 `python scripts/acceptance/ui-layout-dpi.py` 有 120 秒外部 watchdog,只控制自己启动的 PID。最终 `logs/continuation-repair-20260910/ui-layout-1789065295999940200/result.json` PASS:三档字体 14/21/28,720x540 最小布局、状态首尾截图、选择器可达/三项/Esc关闭、滚轮不改滑条、专业展开至少两个中间矩形、连续 resize、最大化、原生全屏覆盖与自动隐藏/退出恢复、空视频中心纯黑。最终截图限制在屏幕范围,旧候选超出屏幕底部的捕获白边不是 UI 白底通过证据。+- `continuation-ui-dpi-paint` 21项、0.140秒 PASS,自绘控件模型变更不触发原生立即绘制,WM_PRINTCLIENT无整块原生白底;`continuation-ui-dpi-popup` 14种交互、1.021秒 PASS,键盘/滚动/取消/焦点/异步刷新/销毁;`continuation-ui-dpi-contract` 0.070秒 PASS。均使用 `scripts/acceptance/scheduler-short-test.ps1 -Name <上述名称> -Exe out/build/x64-release/<对应测试>.exe`,结果在 `logs/scheduler-repair-20260910/`。+- 实际 RTX 后端 UI 回归 `python scripts/acceptance/ui-fg-backends.py`,`ui-fg-1789065217190095800` PASS,FRUC -> XeSS -> DLSS -> 关闭均实际 applied。app.log 的 DLSSG Create 为 `0x1`、handle非空,warm-up Evaluate `0x1`,后续20次Evaluate/19有效生成与呈现。它不是 NR/AMD 或实体采集测试,也不是扫描时刻测量。++构建命令 `powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/build.ps1 -Root <root> -Preset x64-release`,最终日志 `logs/continuation-repair-20260910/ui-dpi-build2.log` exit0。应用 SHA256 `27910DEDB2855334C45A0B92F4694542AB8631FB9AA17FED819E65585CC35C55`,FRUC worker仍 `EC8150FF88C7C84FACDF92B920DED2D6CEC5F682990C375A92550AFD5E818695`。本轮没有重跑与 UI 改动无关的联合 delivery,下面的23项记录仅代表当时版本。源码/runtime隔离不变,本地存档,不push/发布。++当前全计划仍未完成:R0的FG选择与R1状态布局已具应用侧证据,但AMD独立NR/provider仍缺;R2单GPU所有者和FRUC正确性已有前序证据,原生4K重载不代表4X实时;R3合成音频/漂移已通过,文件设备自动恢复与突变淡出还有缺口;R4真实150%/200%系统DPI、实卡验收尚未覆盖。下一条唯一任务:继续 AMD NR 的预览运行时/完整网络依赖诊断与 provider 接入,硬件不足不得用可选按钮或光流替代功能。+### 最新续接:单GPU所有者调度、断流与末帧基线`e25585e`工作树干净;上一目标轮是有效进展(音频与逐帧GPU计时两个已验证本地提交)。本轮按原计划推进S3,没有开启旧Loop或发布。diff --git a/docs/HANDOFF_2026-09-10.md b/docs/HANDOFF_2026-09-10.mdindex 14628991..f1f0c89c 100644--- a/docs/HANDOFF_2026-09-10.md+++ b/docs/HANDOFF_2026-09-10.md@@ -4,6 +4,10 @@## 2026-09-11 当前可续接状态+**以本段为当前状态,下方“下一条全DPI”等是历史快照。** 在`db98af7`之后修复最小窗口状态区没有明细、设置滚轮跳过选择器、DPI字体变化与窄标题范围。新增真实进程UI脚本`python scripts/acceptance/ui-layout-dpi.py`,最终`ui-layout-1789065295999940200`PASS,96/144/192应用缩放、最小窗、展开/滚动/弹窗/连续resize/最大化/全屏/空视频黑色;真实Windows只测DPI96,不能宣称跨显示器150%/200%完成。绘制21项/popup14种/布局合同及真实FRUC->XeSS->DLSS->关闭通过。当前EXE SHA `27910DEDB2855334C45A0B92F4694542AB8631FB9AA17FED819E65585CC35C55`,构建`ui-dpi-build2.log`exit0;本轮未重跑联合delivery、NR或实卡。具体失败与证据见[实施记录最上方](CONTINUATION_REPAIR_IMPLEMENTATION_2026-09-10.md)。++下一条唯一任务是AMD NR预览运行时/网络依赖/provider。当前没有AMD NR实现,缺权重、可用SM6.10/linalg设备创建与目标RDNA4实测;不能把AMD光流或选择项当完成。音频文件端点自动恢复、突变淡出、真实系统DPI与用户实卡也仍待收尾。单GPU所有者、FRUC像素与音频漂移的前序证据继续有效,但整体目标未完成。不启用旧Loop、不push/发布。+当前最新:`e25585e`之后单GPU所有者主循环已落地,`LiveGpuScheduler`取代并删除旧呈现线程,所有图/完成/Present由引擎线程推进;采集tryRead不阻塞,源Waiting仍推进帧,EOF完整交付62真实帧。状态机15/live30/EOF6/FRUC24/正常与失败XeSS UI通过,最终delivery `3462b28549ed4982a99799adc5a3071e`23项42.380秒PASS,EXE `1B0DF186574B552E349EBB9502AF89A001430B89407B3D15635862E668279CE6`。旧`e25585e`独立构建在`out/owner-baseline`(干净源码、ignored SDK/runtime junction),同源原生4K重载A/B均33fps、P95约59.66ms,没有性能提升结论。下一条唯一任务全DPI/最小窗/专业展开滚动与选择器验收;AMD NR provider/依赖和实卡仍未完成。完整命令、失败、限制见实施记录最上方,下面“下一步单GPU所有者”是历史快照。无发布,目标active。最新:音频修复本地提交`1821120`。其后GPU阶段计时的完成记录逐帧交付、同源补帧空闲查询槽选择已修;RTX6项/CPU71/live30项通过,源30fps对应Color30样本。联合delivery `88753f608465497dba0c2660bf7755dd`23项42.146秒PASS,EXE `F6B5F0E96B81B223FE856E888221CFF51ABBE706C9898A6609A49B7EF90413A2`。下一任务完整单GPU所有者状态机,继续解决阻塞观测与末帧计时;尚非S3完成。详见实施记录最上方,下面“下一步逐帧交付”已由本段覆盖。AMD NR/全DPI/实卡仍未完成,目标active。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex e591e985..231c8ba7 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1,5 +1,7 @@# 2026-09-11 继续修复目标模式执行中+最新UI续接(优先于下方历史):基线`db98af7`。修复最小高度状态区无明细空间、90像素滚动跳过选择器、DPI切换字体14变15、窄标题绘制区域重叠;统一应用DPI,并只给smoke进程提供96/144/192注入。最终`ui-layout-1789065295999940200`三档布局/字体、最小窗口滚动、popup、滑条滚轮不变值、展开中间帧、resize、最大化/全屏进出/自动隐藏、黑色视频区PASS;实机系统DPI96,150%/200%仅应用注入,真实跨屏未测。首轮因FG选择器被滚动步长越过失败,证据保留。绘制21项、popup14种、UI合同通过;实际RTX后端UI`ui-fg-1789065217190095800`完成FRUC/XeSS/DLSS/关闭,DLSSG Create/Evaluate0x1。构建`ui-dpi-build2.log`exit0,EXE SHA `27910DEDB2855334C45A0B92F4694542AB8631FB9AA17FED819E65585CC35C55`。详见实施记录最新段的命令/日志/限制。本轮未跑NR、实卡、AMD或新的联合delivery;未改导出检查。下一任务AMD NR依赖/provider,整体目标active,本地存档不发布。+最新单GPU所有者续接:以`e25585e`为基线,用`LiveGpuScheduler`取代呈现线程并删除旧worker;提交/完成检查/deadline/Present由引擎线程推进,容量仍2,实卡tryRead立即返回。空档仍完成已有帧,EOF先呈现尾批,退出边界不覆盖失败;时间戳在源Waiting时也采集。状态机15项、最终live30项、400ms输入空档/62帧EOF6项、FRUC24项及正常/拒绝XeSS界面通过。独立旧Git构建同源原生4K NR+VSR4+FRUC4对照,新旧均33源fps、P95约59.66ms、0有效生成,不声称性能加速。首次CMake依赖顺序/无NR缺shader目标一起修复并全新配置验证。最终delivery `3462b28549ed4982a99799adc5a3071e`23项42.380秒PASS,EXE `1B0DF186574B552E349EBB9502AF89A001430B89407B3D15635862E668279CE6`。细节、失败与完整命令见实施记录最新段。下一条全DPI/窗口交互验收,AMD NR/实卡仍未完成;本地存档,不push/发布。最新GPU计时续接:音频已提交`1821120`。修复`GpuTimer::collect`多帧完成只保留latest及同源补帧查询槽冲突,启用64条有界完成记录、逐帧/epoch/revision统计,满槽与溢出显式记录。真实RTX时间戳6项、CPU71项、最终live30项通过,30fps时Color一秒样本30。最终delivery `88753f608465497dba0c2660bf7755dd`23项42.146秒PASS,应用SHA `F6B5F0E96B81B223FE856E888221CFF51ABBE706C9898A6609A49B7EF90413A2`。命令/身份/边界见实施记录最新段。下一任务完整单GPU所有者调度;仍未实卡/AMD NR/全DPI验收,不push/发布。diff --git a/scripts/acceptance/ui-layout-dpi.py b/scripts/acceptance/ui-layout-dpi.pynew file mode 100644index 00000000..a8cb4425--- /dev/null+++ b/scripts/acceptance/ui-layout-dpi.py@@ -0,0 +1,243 @@+"""Own-process UI geometry/pixel regression; injected DPI is not OS monitor DPI."""+import ctypes as c+import ctypes.wintypes as w+import hashlib+import json+import os+import pathlib+import subprocess+import sys+import time+from PIL import ImageGrab, ImageChops++if '--worker' not in sys.argv:+ child = subprocess.Popen([sys.executable, __file__, '--worker', *sys.argv[1:]])+ try:+ sys.exit(child.wait(timeout=120))+ except subprocess.TimeoutExpired:+ subprocess.run(['taskkill.exe', '/PID', str(child.pid), '/T', '/F'], capture_output=True, timeout=5)+ sys.exit('FAIL: UI layout exceeded 120 seconds')+sys.argv.remove('--worker')+u = c.WinDLL('user32', use_last_error=True)+g = c.WinDLL('gdi32', use_last_error=True)+u.SetProcessDpiAwarenessContext.argtypes = [w.HANDLE]+u.SetProcessDpiAwarenessContext(c.c_void_p(-4))+u.GetDlgItem.argtypes = [w.HWND, c.c_int]+u.GetDlgItem.restype = w.HWND+u.GetWindowRect.argtypes = [w.HWND, c.POINTER(w.RECT)]+u.GetClientRect.argtypes = [w.HWND, c.POINTER(w.RECT)]+u.GetDpiForWindow.argtypes = [w.HWND]+u.GetWindowThreadProcessId.argtypes = [w.HWND, c.POINTER(w.DWORD)]+u.GetClassNameW.argtypes = [w.HWND, w.LPWSTR, c.c_int]+u.IsWindowVisible.argtypes = [w.HWND]+u.ShowWindow.argtypes = [w.HWND, c.c_int]+u.SetWindowPos.argtypes = [w.HWND, w.HWND, c.c_int, c.c_int, c.c_int, c.c_int, w.UINT]+u.PostMessageW.argtypes = [w.HWND, w.UINT, w.WPARAM, w.LPARAM]+u.SendMessageTimeoutW.argtypes = [w.HWND, w.UINT, w.WPARAM, w.LPARAM, w.UINT, w.UINT, c.POINTER(c.c_size_t)]+g.GetObjectW.argtypes = [w.HANDLE, c.c_int, c.c_void_p]+visit_type = c.WINFUNCTYPE(w.BOOL, w.HWND, w.LPARAM)+++def send(hwnd, message, first=0, second=0):+ result = c.c_size_t()+ if not u.SendMessageTimeoutW(hwnd, message, first, second, 2, 1500, c.byref(result)):+ raise RuntimeError('window message timed out')+ return result.value+++def windows(class_name, parent=None):+ found = []++ @visit_type+ def visit(hwnd, unused):+ pid = w.DWORD()+ u.GetWindowThreadProcessId(hwnd, c.byref(pid))+ name = c.create_unicode_buffer(128)+ u.GetClassNameW(hwnd, name, 128)+ if pid.value == process.pid and name.value == class_name:+ found.append(hwnd)+ return True++ if parent:+ u.EnumChildWindows(parent, visit, 0)+ else:+ u.EnumWindows(visit, 0)+ return found+++def wait_for(action, seconds=5):+ end = time.monotonic() + seconds+ while time.monotonic() < end:+ value = action()+ if value:+ return value+ assert process.poll() is None, 'application exited early'+ time.sleep(.025)+ raise RuntimeError('condition timed out')+++def rect(hwnd):+ value = w.RECT()+ assert u.GetWindowRect(hwnd, c.byref(value))+ return [value.left, value.top, value.right, value.bottom]+++def contains(outer, inner):+ return outer[0] <= inner[0] and outer[1] <= inner[1] and outer[2] >= inner[2] and outer[3] >= inner[3]+++def overlaps(a, b):+ return max(a[0], b[0]) < min(a[2], b[2]) and max(a[1], b[1]) < min(a[3], b[3])+++def font_height(hwnd):+ data = c.create_string_buffer(92) # LOGFONTW+ assert g.GetObjectW(send(hwnd, 0x31), len(data), data)+ return abs(c.c_long.from_buffer(data).value)+++exe = pathlib.Path(sys.argv[1] if len(sys.argv) > 1 else 'out/build/x64-release/veyra.exe').resolve()+out = pathlib.Path('logs/continuation-repair-20260910') / ('ui-layout-' + str(time.time_ns()))+out.mkdir(parents=True)+env = os.environ.copy()+env['VEYRA_LOG_FILE'] = str((out / 'app.log').resolve())+env['PATH'] = r'C:\veyra-deps\installed\x64-windows\bin;' + env['PATH']+result = {'exeHash': hashlib.sha256(exe.read_bytes()).hexdigest(), 'cases': [], 'passed': False}+startup = subprocess.STARTUPINFO()+startup.dwFlags = subprocess.STARTF_USESHOWWINDOW+startup.wShowWindow = 0+++def snapshot(name):+ shot = ImageGrab.grab(window=main).convert('RGB')+ shot.save(out / (name + '.png'))+ return shot+++def local_box(hwnd):+ outer, child = rect(main), rect(hwnd)+ return (child[0]-outer[0], child[1]-outer[1], child[2]-outer[0], child[3]-outer[1])+++with (out / 'stdout.log').open('w') as stdout, (out / 'stderr.log').open('w') as stderr:+ process = subprocess.Popen([str(exe), '--smoke-empty', '--smoke-seconds', '110', '--no-nr', '--no-sr', '--no-fg'],+ stdout=stdout, stderr=stderr, startupinfo=startup, env=env)+ try:+ main = wait_for(lambda: windows('VeyraApp'))[0]+ u.ShowWindow(main, 4)+ video = u.GetDlgItem(main, 1000)+ panel = windows('VeyraInspector', main)[0]+ body = windows('VeyraInspectorBody', panel)[0]+ status = windows('VeyraLiveStatus', main)[0]+ result['windowsDpi'] = u.GetDpiForWindow(main)+ result['dpiBoundary'] = 'Real current-monitor DPI recorded; 96/144/192 are application layout injections, not monitor transitions.'+ # Native monitor scale first; ordinary startup uses no injection.+ time.sleep(.3)+ result['startupFontHeight'] = font_height(u.GetDlgItem(main, 220))+ for dpi in [96, 144, 192]:+ send(main, 0x8000+90, dpi)+ scale = dpi/96+ u.SetWindowPos(main, None, 10, 10, round(720*scale), round(540*scale), 0x14)+ time.sleep(.25)+ assert font_height(u.GetDlgItem(main, 220)) == round(14*scale), 'font size changed at DPI transition'+ assert not u.IsWindowVisible(panel), 'daily mode exposes inspector'+ send(main, 0x111, 220)+ frames = []+ for unused in range(8):+ time.sleep(.045)+ frames.append(rect(video))+ assert len({tuple(r) for r in frames}) >= 2, 'mode transition jumped without intermediate layout'+ if not u.IsWindowVisible(panel):+ send(main, 0x111, 229)+ send(main, 0x111, 231)+ time.sleep(.2)+ assert u.IsWindowVisible(panel) and u.IsWindowVisible(status)+ assert (rect(body)[3]-rect(body)[1])/scale >= 80, 'settings viewport too short'+ assert (rect(status)[3]-rect(status)[1])/scale >= 151, 'status has no complete detail row'+ assert not overlaps(rect(panel), rect(status)), 'settings and status overlap'+ minimum_body = rect(body)+ header = [u.GetDlgItem(main, i) for i in [220, 221, 229, 243, 244, 245]]+ for i, a in enumerate(header):+ assert contains(rect(main), rect(a)), 'header outside window'+ for b in header[i+1:]:+ assert not overlaps(rect(a), rect(b)), 'header controls overlap'+ send(status, 0x20A, (120*100)<<16)+ time.sleep(.3)+ top = snapshot(f'{dpi}-minimum-top')+ vx = local_box(video)+ center = ((vx[0]+vx[2])//2, (vx[1]+vx[3])//2)+ assert max(top.getpixel(center)) <= 2, 'idle video is not opaque black'+ send(status, 0x20A, ((-120*100)&0xffff)<<16)+ time.sleep(.3)+ bottom = snapshot(f'{dpi}-minimum-bottom')+ box = local_box(status)+ assert ImageChops.difference(top.crop(box), bottom.crop(box)).getbbox(), 'status detail cannot scroll'+ # Scroll settings until the backend is genuinely inside its viewport.+ backend = u.GetDlgItem(body, 208)+ for unused in range(20):+ if contains(rect(body), rect(backend)):+ break+ send(body, 0x20A, ((-120)&0xffff)<<16)+ assert contains(rect(body), rect(backend)), 'FG selector is unreachable at minimum height'+ u.PostMessageW(backend, 0x201, 1, 10|(10<<16))+ popup = wait_for(lambda: windows('VeyraGlassSelector'))[0]+ listing = u.GetDlgItem(popup, 1)+ assert send(listing, 0x18B) == 3+ assert font_height(listing) == int(13*scale+.5), 'popup font has different scale'+ time.sleep(.15)+ ImageGrab.grab(window=popup).save(out / f'{dpi}-selector.png')+ u.PostMessageW(listing, 0x100, 0x1B, 0)+ wait_for(lambda: not windows('VeyraGlassSelector'))+ send(main, 0x111, 230)+ slider = u.GetDlgItem(body, 600)+ slider_value = send(slider, 0x400)+ send(slider, 0x20A, ((-120)&0xffff)<<16)+ assert send(slider, 0x400) == slider_value, 'scroll wheel changed enhancement strength'+ send(main, 0x111, 231)+ # Exercise resize notifications and multiple widths inside one drag session.+ send(main, 0x231)+ for width, height in [(960, 600), (1180, 760), (1280, 900), (1040, 800)]:+ physical_width = min(round(width*scale), u.GetSystemMetrics(0)-40)+ physical_height = min(round(height*scale), u.GetSystemMetrics(1)-40)+ u.SetWindowPos(main, None, 10, 10, physical_width, physical_height, 0x14)+ time.sleep(.07)+ send(main, 0x232)+ time.sleep(.2)+ snapshot(f'{dpi}-professional')+ result['cases'].append({'dpi': dpi, 'minimumBody': minimum_body, 'finalWindow': rect(main), 'transitionRects': frames, 'font': font_height(backend)})+ send(main, 0x111, 220)+ time.sleep(.35)+ # Restore actual DPI before full monitor / maximized tests.+ send(main, 0x8000+90, 0)+ u.ShowWindow(main, 3)+ time.sleep(.3)+ snapshot('native-maximized')+ u.ShowWindow(main, 9)+ before = rect(main)+ send(main, 0x111, 120)+ time.sleep(.3)+ assert rect(video) == rect(main), 'fullscreen video is not full client'+ assert not u.IsWindowVisible(panel) and not u.IsWindowVisible(status)+ time.sleep(1.8)+ assert not u.IsWindowVisible(u.GetDlgItem(main, 120)), 'fullscreen transport did not auto-hide'+ snapshot('native-fullscreen')+ send(main, 0x100, 0x1B)+ assert rect(main) == before, 'fullscreen did not restore window geometry'+ result['passed'] = True+ except Exception as error:+ result['error'] = str(error)+ finally:+ roots = windows('VeyraApp')+ if roots:+ u.PostMessageW(roots[0], 0x10, 0, 0)+ try:+ process.wait(timeout=8)+ except subprocess.TimeoutExpired:+ process.kill()+ process.wait()+ result['exit'] = process.returncode+ result['passed'] &= process.returncode == 0+ (out / 'result.json').write_text(json.dumps(result, indent=2), encoding='utf-8')+ print(out / 'result.json')+ print(json.dumps(result))+sys.exit(0 if result['passed'] else 1)