MCPcopy Create free account
hub / github.com/MiniMax-AI/OpenRoom / AppWindow

Function AppWindow

apps/webuiapps/src/components/AppWindow/index.tsx:33–152  ·  view source on GitHub ↗
({ win })

Source from the content-addressed store, hash-verified

31}
32
33const AppWindow: React.FC<Props> = ({ win }) => {
34 const dragRef = useRef<{ startX: number; startY: number; winX: number; winY: number } | null>(
35 null,
36 );
37 const resizeRef = useRef<{ startX: number; startY: number; winW: number; winH: number } | null>(
38 null,
39 );
40
41 const handleResizeMouseDown = useCallback(
42 (e: React.MouseEvent) => {
43 e.stopPropagation();
44 e.preventDefault();
45 focusWindow(win.appId);
46 resizeRef.current = {
47 startX: e.clientX,
48 startY: e.clientY,
49 winW: win.width,
50 winH: win.height,
51 };
52
53 const handleMouseMove = (ev: MouseEvent) => {
54 if (!resizeRef.current) return;
55 const dx = ev.clientX - resizeRef.current.startX;
56 const dy = ev.clientY - resizeRef.current.startY;
57 resizeWindow(win.appId, resizeRef.current.winW + dx, resizeRef.current.winH + dy);
58 };
59
60 const handleMouseUp = () => {
61 resizeRef.current = null;
62 document.removeEventListener('mousemove', handleMouseMove);
63 document.removeEventListener('mouseup', handleMouseUp);
64 };
65
66 document.addEventListener('mousemove', handleMouseMove);
67 document.addEventListener('mouseup', handleMouseUp);
68 },
69 [win.appId, win.width, win.height],
70 );
71
72 const handleMouseDown = useCallback(
73 (e: React.MouseEvent) => {
74 focusWindow(win.appId);
75 dragRef.current = {
76 startX: e.clientX,
77 startY: e.clientY,
78 winX: win.x,
79 winY: win.y,
80 };
81
82 const handleMouseMove = (ev: MouseEvent) => {
83 if (!dragRef.current) return;
84 const dx = ev.clientX - dragRef.current.startX;
85 const dy = ev.clientY - dragRef.current.startY;
86 moveWindow(win.appId, dragRef.current.winX + dx, dragRef.current.winY + dy);
87 };
88
89 const handleMouseUp = () => {
90 dragRef.current = null;

Callers

nothing calls this directly

Calls 4

focusWindowFunction · 0.90
minimizeWindowFunction · 0.90
closeWindowFunction · 0.90
reportUserOsActionFunction · 0.90

Tested by

no test coverage detected