1b39c5158Smillert #include <process.h>
2b39c5158Smillert #define INCL_DOS
3b39c5158Smillert #define INCL_DOSERRORS
4b39c5158Smillert #define INCL_DOSNLS
5b39c5158Smillert #define INCL_WINSWITCHLIST
6b39c5158Smillert #define INCL_WINWINDOWMGR
7b39c5158Smillert #define INCL_WININPUT
8b39c5158Smillert #define INCL_VIO
9b39c5158Smillert #define INCL_KBD
10b39c5158Smillert #define INCL_WINCLIPBOARD
11b39c5158Smillert #define INCL_WINATOM
12b39c5158Smillert #include <os2.h>
13b39c5158Smillert
14b39c5158Smillert #include "EXTERN.h"
15b39c5158Smillert #include "perl.h"
16b39c5158Smillert #include "XSUB.h"
17b39c5158Smillert
18b39c5158Smillert static unsigned long
constant(char * name,int arg)19b39c5158Smillert constant(char *name, int arg)
20b39c5158Smillert {
21b39c5158Smillert errno = 0;
22b39c5158Smillert if (name[0] == 'P' && name[1] == '_') {
23b39c5158Smillert if (strEQ(name, "P_BACKGROUND"))
24b39c5158Smillert #ifdef P_BACKGROUND
25b39c5158Smillert return P_BACKGROUND;
26b39c5158Smillert #else
27b39c5158Smillert goto not_there;
28b39c5158Smillert #endif
29b39c5158Smillert if (strEQ(name, "P_DEBUG"))
30b39c5158Smillert #ifdef P_DEBUG
31b39c5158Smillert return P_DEBUG;
32b39c5158Smillert #else
33b39c5158Smillert goto not_there;
34b39c5158Smillert #endif
35b39c5158Smillert if (strEQ(name, "P_DEFAULT"))
36b39c5158Smillert #ifdef P_DEFAULT
37b39c5158Smillert return P_DEFAULT;
38b39c5158Smillert #else
39b39c5158Smillert goto not_there;
40b39c5158Smillert #endif
41b39c5158Smillert if (strEQ(name, "P_DETACH"))
42b39c5158Smillert #ifdef P_DETACH
43b39c5158Smillert return P_DETACH;
44b39c5158Smillert #else
45b39c5158Smillert goto not_there;
46b39c5158Smillert #endif
47b39c5158Smillert if (strEQ(name, "P_FOREGROUND"))
48b39c5158Smillert #ifdef P_FOREGROUND
49b39c5158Smillert return P_FOREGROUND;
50b39c5158Smillert #else
51b39c5158Smillert goto not_there;
52b39c5158Smillert #endif
53b39c5158Smillert if (strEQ(name, "P_FULLSCREEN"))
54b39c5158Smillert #ifdef P_FULLSCREEN
55b39c5158Smillert return P_FULLSCREEN;
56b39c5158Smillert #else
57b39c5158Smillert goto not_there;
58b39c5158Smillert #endif
59b39c5158Smillert if (strEQ(name, "P_MAXIMIZE"))
60b39c5158Smillert #ifdef P_MAXIMIZE
61b39c5158Smillert return P_MAXIMIZE;
62b39c5158Smillert #else
63b39c5158Smillert goto not_there;
64b39c5158Smillert #endif
65b39c5158Smillert if (strEQ(name, "P_MINIMIZE"))
66b39c5158Smillert #ifdef P_MINIMIZE
67b39c5158Smillert return P_MINIMIZE;
68b39c5158Smillert #else
69b39c5158Smillert goto not_there;
70b39c5158Smillert #endif
71b39c5158Smillert if (strEQ(name, "P_NOCLOSE"))
72b39c5158Smillert #ifdef P_NOCLOSE
73b39c5158Smillert return P_NOCLOSE;
74b39c5158Smillert #else
75b39c5158Smillert goto not_there;
76b39c5158Smillert #endif
77b39c5158Smillert if (strEQ(name, "P_NOSESSION"))
78b39c5158Smillert #ifdef P_NOSESSION
79b39c5158Smillert return P_NOSESSION;
80b39c5158Smillert #else
81b39c5158Smillert goto not_there;
82b39c5158Smillert #endif
83b39c5158Smillert if (strEQ(name, "P_NOWAIT"))
84b39c5158Smillert #ifdef P_NOWAIT
85b39c5158Smillert return P_NOWAIT;
86b39c5158Smillert #else
87b39c5158Smillert goto not_there;
88b39c5158Smillert #endif
89b39c5158Smillert if (strEQ(name, "P_OVERLAY"))
90b39c5158Smillert #ifdef P_OVERLAY
91b39c5158Smillert return P_OVERLAY;
92b39c5158Smillert #else
93b39c5158Smillert goto not_there;
94b39c5158Smillert #endif
95b39c5158Smillert if (strEQ(name, "P_PM"))
96b39c5158Smillert #ifdef P_PM
97b39c5158Smillert return P_PM;
98b39c5158Smillert #else
99b39c5158Smillert goto not_there;
100b39c5158Smillert #endif
101b39c5158Smillert if (strEQ(name, "P_QUOTE"))
102b39c5158Smillert #ifdef P_QUOTE
103b39c5158Smillert return P_QUOTE;
104b39c5158Smillert #else
105b39c5158Smillert goto not_there;
106b39c5158Smillert #endif
107b39c5158Smillert if (strEQ(name, "P_SESSION"))
108b39c5158Smillert #ifdef P_SESSION
109b39c5158Smillert return P_SESSION;
110b39c5158Smillert #else
111b39c5158Smillert goto not_there;
112b39c5158Smillert #endif
113b39c5158Smillert if (strEQ(name, "P_TILDE"))
114b39c5158Smillert #ifdef P_TILDE
115b39c5158Smillert return P_TILDE;
116b39c5158Smillert #else
117b39c5158Smillert goto not_there;
118b39c5158Smillert #endif
119b39c5158Smillert if (strEQ(name, "P_UNRELATED"))
120b39c5158Smillert #ifdef P_UNRELATED
121b39c5158Smillert return P_UNRELATED;
122b39c5158Smillert #else
123b39c5158Smillert goto not_there;
124b39c5158Smillert #endif
125b39c5158Smillert if (strEQ(name, "P_WAIT"))
126b39c5158Smillert #ifdef P_WAIT
127b39c5158Smillert return P_WAIT;
128b39c5158Smillert #else
129b39c5158Smillert goto not_there;
130b39c5158Smillert #endif
131b39c5158Smillert if (strEQ(name, "P_WINDOWED"))
132b39c5158Smillert #ifdef P_WINDOWED
133b39c5158Smillert return P_WINDOWED;
134b39c5158Smillert #else
135b39c5158Smillert goto not_there;
136b39c5158Smillert #endif
137b39c5158Smillert } else if (name[0] == 'T' && name[1] == '_') {
138b39c5158Smillert if (strEQ(name, "FAPPTYP_NOTSPEC"))
139b39c5158Smillert #ifdef FAPPTYP_NOTSPEC
140b39c5158Smillert return FAPPTYP_NOTSPEC;
141b39c5158Smillert #else
142b39c5158Smillert goto not_there;
143b39c5158Smillert #endif
144b39c5158Smillert if (strEQ(name, "T_NOTWINDOWCOMPAT"))
145b39c5158Smillert #ifdef FAPPTYP_NOTWINDOWCOMPAT
146b39c5158Smillert return FAPPTYP_NOTWINDOWCOMPAT;
147b39c5158Smillert #else
148b39c5158Smillert goto not_there;
149b39c5158Smillert #endif
150b39c5158Smillert if (strEQ(name, "T_WINDOWCOMPAT"))
151b39c5158Smillert #ifdef FAPPTYP_WINDOWCOMPAT
152b39c5158Smillert return FAPPTYP_WINDOWCOMPAT;
153b39c5158Smillert #else
154b39c5158Smillert goto not_there;
155b39c5158Smillert #endif
156b39c5158Smillert if (strEQ(name, "T_WINDOWAPI"))
157b39c5158Smillert #ifdef FAPPTYP_WINDOWAPI
158b39c5158Smillert return FAPPTYP_WINDOWAPI;
159b39c5158Smillert #else
160b39c5158Smillert goto not_there;
161b39c5158Smillert #endif
162b39c5158Smillert if (strEQ(name, "T_BOUND"))
163b39c5158Smillert #ifdef FAPPTYP_BOUND
164b39c5158Smillert return FAPPTYP_BOUND;
165b39c5158Smillert #else
166b39c5158Smillert goto not_there;
167b39c5158Smillert #endif
168b39c5158Smillert if (strEQ(name, "T_DLL"))
169b39c5158Smillert #ifdef FAPPTYP_DLL
170b39c5158Smillert return FAPPTYP_DLL;
171b39c5158Smillert #else
172b39c5158Smillert goto not_there;
173b39c5158Smillert #endif
174b39c5158Smillert if (strEQ(name, "T_DOS"))
175b39c5158Smillert #ifdef FAPPTYP_DOS
176b39c5158Smillert return FAPPTYP_DOS;
177b39c5158Smillert #else
178b39c5158Smillert goto not_there;
179b39c5158Smillert #endif
180b39c5158Smillert if (strEQ(name, "T_PHYSDRV"))
181b39c5158Smillert #ifdef FAPPTYP_PHYSDRV
182b39c5158Smillert return FAPPTYP_PHYSDRV;
183b39c5158Smillert #else
184b39c5158Smillert goto not_there;
185b39c5158Smillert #endif
186b39c5158Smillert if (strEQ(name, "T_VIRTDRV"))
187b39c5158Smillert #ifdef FAPPTYP_VIRTDRV
188b39c5158Smillert return FAPPTYP_VIRTDRV;
189b39c5158Smillert #else
190b39c5158Smillert goto not_there;
191b39c5158Smillert #endif
192b39c5158Smillert if (strEQ(name, "T_PROTDLL"))
193b39c5158Smillert #ifdef FAPPTYP_PROTDLL
194b39c5158Smillert return FAPPTYP_PROTDLL;
195b39c5158Smillert #else
196b39c5158Smillert goto not_there;
197b39c5158Smillert #endif
198b39c5158Smillert if (strEQ(name, "T_32BIT"))
199b39c5158Smillert #ifdef FAPPTYP_32BIT
200b39c5158Smillert return FAPPTYP_32BIT;
201b39c5158Smillert #else
202b39c5158Smillert goto not_there;
203b39c5158Smillert #endif
204b39c5158Smillert }
205b39c5158Smillert
206b39c5158Smillert errno = EINVAL;
207b39c5158Smillert return 0;
208b39c5158Smillert
209b39c5158Smillert not_there:
210b39c5158Smillert errno = ENOENT;
211b39c5158Smillert return 0;
212b39c5158Smillert }
213b39c5158Smillert
214b39c5158Smillert const char* const ptypes[] = { "FS", "DOS", "VIO", "PM", "DETACH" };
215b39c5158Smillert
216b39c5158Smillert static char *
my_type()217b39c5158Smillert my_type()
218b39c5158Smillert {
219b39c5158Smillert int rc;
220b39c5158Smillert TIB *tib;
221b39c5158Smillert PIB *pib;
222b39c5158Smillert
223b39c5158Smillert if (!(_emx_env & 0x200)) return (char*)ptypes[1]; /* not OS/2. */
224b39c5158Smillert if (CheckOSError(DosGetInfoBlocks(&tib, &pib)))
225b39c5158Smillert return NULL;
226b39c5158Smillert
227b39c5158Smillert return (pib->pib_ultype <= 4 ? (char*)ptypes[pib->pib_ultype] : "UNKNOWN");
228b39c5158Smillert }
229b39c5158Smillert
230b39c5158Smillert static ULONG
file_type(char * path)231b39c5158Smillert file_type(char *path)
232b39c5158Smillert {
233b39c5158Smillert int rc;
234b39c5158Smillert ULONG apptype;
235b39c5158Smillert
236b39c5158Smillert if (!(_emx_env & 0x200))
237b39c5158Smillert croak("file_type not implemented on DOS"); /* not OS/2. */
238b39c5158Smillert if (CheckOSError(DosQueryAppType(path, &apptype))) {
239b39c5158Smillert #if 0
240b39c5158Smillert if (rc == ERROR_INVALID_EXE_SIGNATURE)
241b39c5158Smillert croak("Invalid EXE signature");
242b39c5158Smillert else if (rc == ERROR_EXE_MARKED_INVALID) {
243b39c5158Smillert croak("EXE marked invalid");
244b39c5158Smillert }
245b39c5158Smillert #endif
246b39c5158Smillert croak_with_os2error("DosQueryAppType");
247b39c5158Smillert }
248b39c5158Smillert
249b39c5158Smillert return apptype;
250b39c5158Smillert }
251b39c5158Smillert
252b39c5158Smillert /* These use different type of wrapper. Good to check wrappers. ;-) */
253b39c5158Smillert /* XXXX This assumes DOS type return type, without SEVERITY?! */
254b39c5158Smillert DeclFuncByORD(HSWITCH, myWinQuerySwitchHandle, ORD_WinQuerySwitchHandle,
255b39c5158Smillert (HWND hwnd, PID pid), (hwnd, pid))
256b39c5158Smillert DeclFuncByORD(ULONG, myWinQuerySwitchEntry, ORD_WinQuerySwitchEntry,
257b39c5158Smillert (HSWITCH hsw, PSWCNTRL pswctl), (hsw, pswctl))
258b39c5158Smillert DeclFuncByORD(ULONG, myWinSetWindowText, ORD_WinSetWindowText,
259b39c5158Smillert (HWND hwnd, char* text), (hwnd, text))
260b39c5158Smillert DeclFuncByORD(BOOL, myWinQueryWindowProcess, ORD_WinQueryWindowProcess,
261b39c5158Smillert (HWND hwnd, PPID ppid, PTID ptid), (hwnd, ppid, ptid))
262b39c5158Smillert DeclFuncByORD(ULONG, XmyWinSwitchToProgram, ORD_WinSwitchToProgram,
263b39c5158Smillert (HSWITCH hsw), (hsw))
264b39c5158Smillert #define myWinSwitchToProgram(hsw) (!CheckOSError(XmyWinSwitchToProgram(hsw)))
265b39c5158Smillert
266b39c5158Smillert
267b39c5158Smillert /* These function croak if the return value is 0. */
268b39c5158Smillert DeclWinFunc_CACHE(HWND, QueryWindow, (HWND hwnd, LONG cmd), (hwnd, cmd))
269b39c5158Smillert DeclWinFunc_CACHE(BOOL, QueryWindowPos, (HWND hwnd, PSWP pswp),
270b39c5158Smillert (hwnd, pswp))
271b39c5158Smillert DeclWinFunc_CACHE(LONG, QueryWindowText,
272b39c5158Smillert (HWND hwnd, LONG cchBufferMax, PCH pchBuffer),
273b39c5158Smillert (hwnd, cchBufferMax, pchBuffer))
274b39c5158Smillert DeclWinFunc_CACHE(LONG, QueryClassName, (HWND hwnd, LONG cchMax, PCH pch),
275b39c5158Smillert (hwnd, cchMax, pch))
276b39c5158Smillert DeclWinFunc_CACHE(HWND, QueryFocus, (HWND hwndDesktop), (hwndDesktop))
277b39c5158Smillert DeclWinFunc_CACHE(BOOL, SetFocus, (HWND hwndDesktop, HWND hwndFocus),
278b39c5158Smillert (hwndDesktop, hwndFocus))
279b39c5158Smillert DeclWinFunc_CACHE(BOOL, ShowWindow, (HWND hwnd, BOOL fShow), (hwnd, fShow))
280b39c5158Smillert DeclWinFunc_CACHE(BOOL, EnableWindow, (HWND hwnd, BOOL fEnable),
281b39c5158Smillert (hwnd, fEnable))
282b39c5158Smillert DeclWinFunc_CACHE(BOOL, SetWindowPos,
283b39c5158Smillert (HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y,
284b39c5158Smillert LONG cx, LONG cy, ULONG fl),
285b39c5158Smillert (hwnd, hwndInsertBehind, x, y, cx, cy, fl))
286b39c5158Smillert DeclWinFunc_CACHE(HENUM, BeginEnumWindows, (HWND hwnd), (hwnd))
287b39c5158Smillert DeclWinFunc_CACHE(BOOL, EndEnumWindows, (HENUM henum), (henum))
288b39c5158Smillert DeclWinFunc_CACHE(BOOL, EnableWindowUpdate, (HWND hwnd, BOOL fEnable),
289b39c5158Smillert (hwnd, fEnable))
290b39c5158Smillert DeclWinFunc_CACHE(BOOL, SetWindowBits,
291b39c5158Smillert (HWND hwnd, LONG index, ULONG flData, ULONG flMask),
292b39c5158Smillert (hwnd, index, flData, flMask))
293b39c5158Smillert DeclWinFunc_CACHE(BOOL, SetWindowPtr, (HWND hwnd, LONG index, PVOID p),
294b39c5158Smillert (hwnd, index, p))
295b39c5158Smillert DeclWinFunc_CACHE(BOOL, SetWindowULong, (HWND hwnd, LONG index, ULONG ul),
296b39c5158Smillert (hwnd, index, ul))
297b39c5158Smillert DeclWinFunc_CACHE(BOOL, SetWindowUShort, (HWND hwnd, LONG index, USHORT us),
298b39c5158Smillert (hwnd, index, us))
299b39c5158Smillert DeclWinFunc_CACHE(HWND, IsChild, (HWND hwnd, HWND hwndParent),
300b39c5158Smillert (hwnd, hwndParent))
301b39c5158Smillert DeclWinFunc_CACHE(HWND, WindowFromId, (HWND hwnd, ULONG id), (hwnd, id))
302b39c5158Smillert DeclWinFunc_CACHE(HWND, EnumDlgItem, (HWND hwndDlg, HWND hwnd, ULONG code),
303b39c5158Smillert (hwndDlg, hwnd, code))
304b39c5158Smillert DeclWinFunc_CACHE(HWND, QueryDesktopWindow, (HAB hab, HDC hdc), (hab, hdc));
305b39c5158Smillert DeclWinFunc_CACHE(BOOL, SetActiveWindow, (HWND hwndDesktop, HWND hwnd),
306b39c5158Smillert (hwndDesktop, hwnd));
307b39c5158Smillert DeclWinFunc_CACHE(BOOL, QueryActiveDesktopPathname, (PSZ pszPathName, ULONG ulSize),
308b39c5158Smillert (pszPathName, ulSize));
309b39c5158Smillert DeclWinFunc_CACHE(BOOL, InvalidateRect,
310b39c5158Smillert (HWND hwnd, /*RECTL*/ char *prcl, BOOL fIncludeChildren),
311b39c5158Smillert (hwnd, prcl, fIncludeChildren));
312b39c5158Smillert DeclWinFunc_CACHE(BOOL, CreateFrameControls,
313b39c5158Smillert (HWND hwndFrame, /*PFRAMECDATA*/ char* pfcdata, PCSZ pszTitle),
314b39c5158Smillert (hwndFrame, pfcdata, pszTitle));
315b39c5158Smillert DeclWinFunc_CACHE(BOOL, OpenClipbrd, (HAB hab), (hab));
316b39c5158Smillert DeclWinFunc_CACHE(BOOL, EmptyClipbrd, (HAB hab), (hab));
317b39c5158Smillert DeclWinFunc_CACHE(BOOL, CloseClipbrd, (HAB hab), (hab));
318b39c5158Smillert DeclWinFunc_CACHE(BOOL, QueryClipbrdFmtInfo, (HAB hab, ULONG fmt, PULONG prgfFmtInfo), (hab, fmt, prgfFmtInfo));
319b39c5158Smillert DeclWinFunc_CACHE(ULONG, QueryClipbrdData, (HAB hab, ULONG fmt), (hab, fmt));
320b39c5158Smillert DeclWinFunc_CACHE(HWND, SetClipbrdViewer, (HAB hab, HWND hwnd), (hab, hwnd));
321b39c5158Smillert DeclWinFunc_CACHE(HWND, SetClipbrdOwner, (HAB hab, HWND hwnd), (hab, hwnd));
322b39c5158Smillert DeclWinFunc_CACHE(ULONG, EnumClipbrdFmts, (HAB hab, ULONG fmt), (hab, fmt));
323b39c5158Smillert DeclWinFunc_CACHE(ATOM, AddAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
324b39c5158Smillert (hAtomTbl, pszAtomName));
325b39c5158Smillert DeclWinFunc_CACHE(ULONG, QueryAtomUsage, (HATOMTBL hAtomTbl, ATOM atom),
326b39c5158Smillert (hAtomTbl, atom));
327b39c5158Smillert DeclWinFunc_CACHE(ULONG, QueryAtomLength, (HATOMTBL hAtomTbl, ATOM atom),
328b39c5158Smillert (hAtomTbl, atom));
329b39c5158Smillert DeclWinFunc_CACHE(ULONG, QueryAtomName,
330b39c5158Smillert (HATOMTBL hAtomTbl, ATOM atom, PSZ pchBuffer, ULONG cchBufferMax),
331b39c5158Smillert (hAtomTbl, atom, pchBuffer, cchBufferMax));
332b39c5158Smillert DeclWinFunc_CACHE(HATOMTBL, QuerySystemAtomTable, (VOID), ());
333b39c5158Smillert DeclWinFunc_CACHE(HATOMTBL, CreateAtomTable, (ULONG initial, ULONG buckets),
334b39c5158Smillert (initial, buckets));
335b39c5158Smillert DeclWinFunc_CACHE(ULONG, MessageBox, (HWND hwndParent, HWND hwndOwner, PCSZ pszText, PCSZ pszCaption, ULONG idWindow, ULONG flStyle), (hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle));
336b39c5158Smillert DeclWinFunc_CACHE(ULONG, MessageBox2,
337b39c5158Smillert (HWND hwndParent, HWND hwndOwner, PCSZ pszText,
338b39c5158Smillert PCSZ pszCaption, ULONG idWindow, PMB2INFO pmb2info),
339b39c5158Smillert (hwndParent, hwndOwner, pszText, pszCaption, idWindow, pmb2info));
340b39c5158Smillert DeclWinFunc_CACHE(HPOINTER, LoadPointer,
341b39c5158Smillert (HWND hwndDesktop, HMODULE hmod, ULONG idres),
342b39c5158Smillert (hwndDesktop, hmod, idres));
343b39c5158Smillert DeclWinFunc_CACHE(HPOINTER, QuerySysPointer,
344b39c5158Smillert (HWND hwndDesktop, LONG lId, BOOL fCopy),
345b39c5158Smillert (hwndDesktop, lId, fCopy));
346b39c5158Smillert DeclWinFunc_CACHE(BOOL, Alarm, (HWND hwndDesktop, ULONG rgfType), (hwndDesktop, rgfType));
347b39c5158Smillert DeclWinFunc_CACHE(BOOL, FlashWindow, (HWND hwndFrame, BOOL fFlash), (hwndFrame, fFlash));
348b39c5158Smillert
349b39c5158Smillert #if 0 /* Need to have the entry points described in the parent */
350b39c5158Smillert DeclWinFunc_CACHE(BOOL, QueryClassInfo, (HAB hab, char* pszClassName, PCLASSINFO pClassInfo), (hab, pszClassName, pClassInfo));
351b39c5158Smillert
352b39c5158Smillert #define _QueryClassInfo(hab, pszClassName, pClassInfo) \
353b39c5158Smillert QueryClassInfo(hab, pszClassName, (PCLASSINFO)pClassInfo)
354b39c5158Smillert
355b39c5158Smillert #endif
356b39c5158Smillert
357b39c5158Smillert /* These functions do not croak on error */
358b39c5158Smillert DeclWinFunc_CACHE_survive(BOOL, SetClipbrdData,
359b39c5158Smillert (HAB hab, ULONG ulData, ULONG fmt, ULONG rgfFmtInfo),
360b39c5158Smillert (hab, ulData, fmt, rgfFmtInfo));
361b39c5158Smillert
362b39c5158Smillert #define get_InvalidateRect InvalidateRect
363b39c5158Smillert #define get_CreateFrameControls CreateFrameControls
364b39c5158Smillert
365b39c5158Smillert /* These functions may return 0 on success; check $^E/Perl_rc on res==0: */
366b39c5158Smillert DeclWinFunc_CACHE_resetError(PVOID, QueryWindowPtr, (HWND hwnd, LONG index),
367b39c5158Smillert (hwnd, index))
368b39c5158Smillert DeclWinFunc_CACHE_resetError(ULONG, QueryWindowULong, (HWND hwnd, LONG index),
369b39c5158Smillert (hwnd, index))
370b39c5158Smillert DeclWinFunc_CACHE_resetError(SHORT, QueryWindowUShort, (HWND hwnd, LONG index),
371b39c5158Smillert (hwnd, index))
372b39c5158Smillert DeclWinFunc_CACHE_resetError(LONG, QueryWindowTextLength, (HWND hwnd), (hwnd))
373b39c5158Smillert DeclWinFunc_CACHE_resetError(HWND, QueryActiveWindow, (HWND hwnd), (hwnd))
374b39c5158Smillert DeclWinFunc_CACHE_resetError(BOOL, PostMsg,
375b39c5158Smillert (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2),
376b39c5158Smillert (hwnd, msg, mp1, mp2))
377b39c5158Smillert DeclWinFunc_CACHE_resetError(HWND, GetNextWindow, (HENUM henum), (henum))
378b39c5158Smillert DeclWinFunc_CACHE_resetError(BOOL, IsWindowEnabled, (HWND hwnd), (hwnd))
379b39c5158Smillert DeclWinFunc_CACHE_resetError(BOOL, IsWindowVisible, (HWND hwnd), (hwnd))
380b39c5158Smillert DeclWinFunc_CACHE_resetError(BOOL, IsWindowShowing, (HWND hwnd), (hwnd))
381b39c5158Smillert DeclWinFunc_CACHE_resetError(ATOM, FindAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
382b39c5158Smillert (hAtomTbl, pszAtomName));
383b39c5158Smillert DeclWinFunc_CACHE_resetError(ATOM, DeleteAtom, (HATOMTBL hAtomTbl, ATOM atom),
384b39c5158Smillert (hAtomTbl, atom));
385b39c5158Smillert DeclWinFunc_CACHE_resetError(HATOMTBL, DestroyAtomTable, (HATOMTBL hAtomTbl), (hAtomTbl));
386b39c5158Smillert DeclWinFunc_CACHE_resetError(HWND, QueryClipbrdViewer, (HAB hab), (hab));
387b39c5158Smillert DeclWinFunc_CACHE_resetError(HWND, QueryClipbrdOwner, (HAB hab), (hab));
388b39c5158Smillert
389b39c5158Smillert #define _DeleteAtom DeleteAtom
390b39c5158Smillert #define _DestroyAtomTable DestroyAtomTable
391b39c5158Smillert
392b39c5158Smillert /* No die()ing on error */
393b39c5158Smillert DeclWinFunc_CACHE_survive(BOOL, IsWindow, (HAB hab, HWND hwnd), (hab, hwnd))
394b39c5158Smillert
395b39c5158Smillert /* These functions are called frow complicated wrappers: */
396b39c5158Smillert ULONG (*pWinQuerySwitchList) (HAB hab, PSWBLOCK pswblk, ULONG usDataLength);
397b39c5158Smillert ULONG (*pWinChangeSwitchEntry) (HSWITCH hsw, __const__ SWCNTRL *pswctl);
398b39c5158Smillert HWND (*pWinWindowFromPoint)(HWND hwnd, __const__ POINTL *pptl, BOOL fChildren);
399b39c5158Smillert
400b39c5158Smillert
401b39c5158Smillert /* These functions have different names/signatures than what is
402b39c5158Smillert declared above */
403b39c5158Smillert #define QueryFocusWindow QueryFocus
404b39c5158Smillert #define FocusWindow_set(hwndFocus, hwndDesktop) SetFocus(hwndDesktop, hwndFocus)
405b39c5158Smillert #define WindowPos_set(hwnd, x, y, fl, cx, cy, hwndInsertBehind) \
406b39c5158Smillert SetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl)
407b39c5158Smillert #define myWinQueryWindowPtr(hwnd, i) ((ULONG)QueryWindowPtr(hwnd, i))
408b39c5158Smillert #define _ClipbrdData_set SetClipbrdData
409b39c5158Smillert #define ClipbrdOwner_set SetClipbrdOwner
410b39c5158Smillert #define ClipbrdViewer_set SetClipbrdViewer
411b39c5158Smillert
412b39c5158Smillert int
WindowText_set(HWND hwnd,char * text)413b39c5158Smillert WindowText_set(HWND hwnd, char* text)
414b39c5158Smillert {
415b39c5158Smillert return !CheckWinError(myWinSetWindowText(hwnd, text));
416b39c5158Smillert }
417b39c5158Smillert
418b39c5158Smillert SV *
myQueryWindowText(HWND hwnd)419b39c5158Smillert myQueryWindowText(HWND hwnd)
420b39c5158Smillert {
421b39c5158Smillert LONG l = QueryWindowTextLength(hwnd), len;
422b39c5158Smillert SV *sv;
423b39c5158Smillert STRLEN n_a;
424b39c5158Smillert
425b39c5158Smillert if (l == 0) {
426b39c5158Smillert if (Perl_rc) /* Last error */
427b39c5158Smillert return &PL_sv_undef;
428b39c5158Smillert return &PL_sv_no;
429b39c5158Smillert }
430*b8851fccSafresh1 sv = newSVpvs("");
431b39c5158Smillert SvGROW(sv, l + 1);
432b39c5158Smillert len = QueryWindowText(hwnd, l + 1, SvPV_force(sv, n_a));
433b39c5158Smillert if (len != l) {
434b39c5158Smillert Safefree(sv);
435b39c5158Smillert croak("WinQueryWindowText() uncompatible with WinQueryWindowTextLength()");
436b39c5158Smillert }
437b39c5158Smillert SvCUR_set(sv, l);
438b39c5158Smillert return sv;
439b39c5158Smillert }
440b39c5158Smillert
441b39c5158Smillert SWP
QueryWindowSWP_(HWND hwnd)442b39c5158Smillert QueryWindowSWP_(HWND hwnd)
443b39c5158Smillert {
444b39c5158Smillert SWP swp;
445b39c5158Smillert
446b39c5158Smillert if (!QueryWindowPos(hwnd, &swp))
447b39c5158Smillert croak("WinQueryWindowPos() error");
448b39c5158Smillert return swp;
449b39c5158Smillert }
450b39c5158Smillert
451b39c5158Smillert SV *
QueryWindowSWP(HWND hwnd)452b39c5158Smillert QueryWindowSWP(HWND hwnd)
453b39c5158Smillert {
454b39c5158Smillert SWP swp = QueryWindowSWP_(hwnd);
455b39c5158Smillert
456b39c5158Smillert return newSVpvn((char*)&swp, sizeof(swp));
457b39c5158Smillert }
458b39c5158Smillert
459b39c5158Smillert SV *
myQueryClassName(HWND hwnd)460b39c5158Smillert myQueryClassName(HWND hwnd)
461b39c5158Smillert {
462*b8851fccSafresh1 SV *sv = newSVpvs("");
463b39c5158Smillert STRLEN l = 46, len = 0, n_a;
464b39c5158Smillert
465b39c5158Smillert while (l + 1 >= len) {
466b39c5158Smillert if (len)
467b39c5158Smillert len = 2*len + 10; /* Grow quick */
468b39c5158Smillert else
469b39c5158Smillert len = l + 2;
470b39c5158Smillert SvGROW(sv, len);
471b39c5158Smillert l = QueryClassName(hwnd, len, SvPV_force(sv, n_a));
472b39c5158Smillert }
473b39c5158Smillert SvCUR_set(sv, l);
474b39c5158Smillert return sv;
475b39c5158Smillert }
476b39c5158Smillert
477b39c5158Smillert HWND
WindowFromPoint(long x,long y,HWND hwnd,BOOL fChildren)478b39c5158Smillert WindowFromPoint(long x, long y, HWND hwnd, BOOL fChildren)
479b39c5158Smillert {
480b39c5158Smillert POINTL ppl;
481b39c5158Smillert
482b39c5158Smillert ppl.x = x; ppl.y = y;
483b39c5158Smillert if (!pWinWindowFromPoint)
484b39c5158Smillert AssignFuncPByORD(pWinWindowFromPoint, ORD_WinWindowFromPoint);
485b39c5158Smillert return SaveWinError(pWinWindowFromPoint(hwnd, &ppl, fChildren));
486b39c5158Smillert }
487b39c5158Smillert
488b39c5158Smillert static HSWITCH
switch_of(HWND hwnd,PID pid)489b39c5158Smillert switch_of(HWND hwnd, PID pid)
490b39c5158Smillert {
491b39c5158Smillert HSWITCH hSwitch;
492b39c5158Smillert
493b39c5158Smillert if (!(_emx_env & 0x200))
494b39c5158Smillert croak("switch_entry not implemented on DOS"); /* not OS/2. */
495b39c5158Smillert if (CheckWinError(hSwitch =
496b39c5158Smillert myWinQuerySwitchHandle(hwnd, pid)))
497b39c5158Smillert croak_with_os2error("WinQuerySwitchHandle");
498b39c5158Smillert return hSwitch;
499b39c5158Smillert }
500b39c5158Smillert
501b39c5158Smillert
502b39c5158Smillert static void
fill_swentry(SWENTRY * swentryp,HWND hwnd,PID pid)503b39c5158Smillert fill_swentry(SWENTRY *swentryp, HWND hwnd, PID pid)
504b39c5158Smillert {
505b39c5158Smillert int rc;
506b39c5158Smillert HSWITCH hSwitch = switch_of(hwnd, pid);
507b39c5158Smillert
508b39c5158Smillert swentryp->hswitch = hSwitch;
509b39c5158Smillert if (CheckOSError(myWinQuerySwitchEntry(hSwitch, &swentryp->swctl)))
510b39c5158Smillert croak_with_os2error("WinQuerySwitchEntry");
511b39c5158Smillert }
512b39c5158Smillert
513b39c5158Smillert static void
fill_swentry_default(SWENTRY * swentryp)514b39c5158Smillert fill_swentry_default(SWENTRY *swentryp)
515b39c5158Smillert {
516b39c5158Smillert fill_swentry(swentryp, NULLHANDLE, getpid());
517b39c5158Smillert }
518b39c5158Smillert
519b39c5158Smillert static SV*
myWinQueryActiveDesktopPathname()520b39c5158Smillert myWinQueryActiveDesktopPathname()
521b39c5158Smillert {
522b39c5158Smillert SV *buf = newSVpv("",0);
523b39c5158Smillert STRLEN n_a;
524b39c5158Smillert
525b39c5158Smillert SvGROW(buf, MAXPATHLEN);
526b39c5158Smillert QueryActiveDesktopPathname(SvPV(buf,n_a), MAXPATHLEN);
527b39c5158Smillert SvCUR_set(buf, strlen(SvPV(buf, n_a)));
528b39c5158Smillert return buf;
529b39c5158Smillert }
530b39c5158Smillert
531b39c5158Smillert SV *
myWinQueryAtomName(ATOM atom,HATOMTBL hAtomTbl)532b39c5158Smillert myWinQueryAtomName(ATOM atom, HATOMTBL hAtomTbl)
533b39c5158Smillert {
534b39c5158Smillert ULONG len = QueryAtomLength(hAtomTbl, atom);
535b39c5158Smillert
536b39c5158Smillert if (len) { /* Probably always so... */
537*b8851fccSafresh1 SV *sv = newSVpvs("");
538b39c5158Smillert STRLEN n_a;
539b39c5158Smillert
540b39c5158Smillert SvGROW(sv, len + 1);
541b39c5158Smillert len = QueryAtomName(hAtomTbl, atom, SvPV(sv, n_a), len + 1);
542b39c5158Smillert if (len) { /* Probably always so... */
543b39c5158Smillert SvCUR_set(sv, len);
544b39c5158Smillert *SvEND(sv) = 0;
545b39c5158Smillert return sv;
546b39c5158Smillert }
547b39c5158Smillert SvREFCNT_dec(sv);
548b39c5158Smillert }
549b39c5158Smillert return &PL_sv_undef;
550b39c5158Smillert }
551b39c5158Smillert
552b39c5158Smillert #define myWinQueryClipbrdFmtInfo QueryClipbrdFmtInfo
553b39c5158Smillert
554b39c5158Smillert /* Put data into shared memory, then call SetClipbrdData */
555b39c5158Smillert void
ClipbrdData_set(SV * sv,int convert_nl,unsigned long fmt,unsigned long rgfFmtInfo,HAB hab)556b39c5158Smillert ClipbrdData_set(SV *sv, int convert_nl, unsigned long fmt, unsigned long rgfFmtInfo, HAB hab)
557b39c5158Smillert {
558b39c5158Smillert STRLEN len;
559b39c5158Smillert char *buf;
560b39c5158Smillert char *pByte = 0, *s, c;
561b39c5158Smillert ULONG nls = 0, rc, handle;
562b39c5158Smillert
563b39c5158Smillert if (rgfFmtInfo & CFI_POINTER) {
564b39c5158Smillert s = buf = SvPV_force(sv, len);
565b39c5158Smillert if (convert_nl) {
566b39c5158Smillert while ((c = *s++)) {
567b39c5158Smillert if (c == '\r' && *s == '\n')
568b39c5158Smillert s++;
569b39c5158Smillert else if (c == '\n')
570b39c5158Smillert nls++;
571b39c5158Smillert }
572b39c5158Smillert }
573b39c5158Smillert
574b39c5158Smillert if (CheckOSError(DosAllocSharedMem((PPVOID)&pByte, 0, len + nls + 1,
575b39c5158Smillert PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE | OBJ_GETTABLE)))
576b39c5158Smillert croak_with_os2error("ClipbrdData_set: DosAllocSharedMem error");
577b39c5158Smillert
578b39c5158Smillert if (!nls)
579b39c5158Smillert memcpy(pByte, buf, len + 1);
580b39c5158Smillert else {
581b39c5158Smillert char *t = pByte, *e = buf + len;
582b39c5158Smillert
583b39c5158Smillert while (buf < e) {
584b39c5158Smillert c = *t++ = *buf++;
585b39c5158Smillert if (c == '\n' && (t == pByte + 1 || t[-2] != '\r'))
586b39c5158Smillert t[-1] = '\r', *t++ = '\n';
587b39c5158Smillert }
588b39c5158Smillert }
589b39c5158Smillert handle = (ULONG)pByte;
590b39c5158Smillert } else {
591b39c5158Smillert handle = (ULONG)SvUV(sv);
592b39c5158Smillert }
593b39c5158Smillert
594b39c5158Smillert if (!SetClipbrdData(hab, handle, fmt, rgfFmtInfo)) {
595b39c5158Smillert if (fmt & CFI_POINTER)
596b39c5158Smillert DosFreeMem((PPVOID)&pByte);
597b39c5158Smillert croak_with_os2error("ClipbrdData_set: WinSetClipbrdData error");
598b39c5158Smillert }
599b39c5158Smillert }
600b39c5158Smillert
601b39c5158Smillert ULONG
QueryMemoryRegionSize(ULONG addr,ULONG * flagp,ULONG len,I32 interrupt)602b39c5158Smillert QueryMemoryRegionSize(ULONG addr, ULONG *flagp, ULONG len, I32 interrupt)
603b39c5158Smillert {
604b39c5158Smillert ULONG l, f; /* Modifiable copy */
605b39c5158Smillert ULONG rc;
606b39c5158Smillert
607b39c5158Smillert do {
608b39c5158Smillert l = len;
609b39c5158Smillert rc = DosQueryMem((void *)addr, &l, &f);
610b39c5158Smillert } while ( interrupt ? 0 : rc == ERROR_INTERRUPT );
611b39c5158Smillert
612b39c5158Smillert /* We assume this is not about addr */
613b39c5158Smillert /*
614b39c5158Smillert if (rc == ERROR_INVALID_ADDRESS)
615b39c5158Smillert return 0xFFFFFFFF;
616b39c5158Smillert */
617b39c5158Smillert os2cp_croak(rc,"QueryMemoryRegionSize");
618b39c5158Smillert if (flagp)
619b39c5158Smillert *flagp = f;
620b39c5158Smillert return l;
621b39c5158Smillert }
622b39c5158Smillert
623b39c5158Smillert static ULONG
default_fmtInfo(ULONG fmt)624b39c5158Smillert default_fmtInfo(ULONG fmt)
625b39c5158Smillert {
626b39c5158Smillert switch (fmt) {
627b39c5158Smillert case CF_PALETTE: /* Actually, fmtInfo not documented for palette... */
628b39c5158Smillert case CF_BITMAP:
629b39c5158Smillert case CF_METAFILE:
630b39c5158Smillert case CF_DSPBITMAP:
631b39c5158Smillert case CF_DSPMETAFILE:
632b39c5158Smillert return CFI_HANDLE;
633b39c5158Smillert default:
634b39c5158Smillert return CFI_POINTER;
635b39c5158Smillert }
636b39c5158Smillert }
637b39c5158Smillert
638b39c5158Smillert #if 0
639b39c5158Smillert
640b39c5158Smillert ULONG
641b39c5158Smillert myWinMessageBox(HWND hwndParent, HWND hwndOwner, PCSZ pszText, PCSZ pszCaption, ULONG idWindow, ULONG flStyle)
642b39c5158Smillert {
643b39c5158Smillert ULONG rc = MessageBox(hwndParent, hwndOwner, pszText, pszCaption,
644b39c5158Smillert idWindow, flStyle);
645b39c5158Smillert
646b39c5158Smillert if (rc == MBID_ERROR)
647b39c5158Smillert rc = 0;
648b39c5158Smillert if (CheckWinError(rc))
649b39c5158Smillert croak_with_os2error("MessageBox");
650b39c5158Smillert return rc;
651b39c5158Smillert }
652b39c5158Smillert
653b39c5158Smillert ULONG
654b39c5158Smillert myWinMessageBox2(HWND hwndParent, HWND hwndOwner, PCSZ pszText,
655b39c5158Smillert PCSZ pszCaption, ULONG idWindow, PMB2INFO pmb2info)
656b39c5158Smillert {
657b39c5158Smillert ULONG rc = MessageBox2(hwndParent, hwndOwner, pszText, pszCaption, idWindow, pmb2info);
658b39c5158Smillert
659b39c5158Smillert if (rc == MBID_ERROR)
660b39c5158Smillert rc = 0;
661b39c5158Smillert if (CheckWinError(rc))
662b39c5158Smillert croak_with_os2error("MessageBox2");
663b39c5158Smillert return rc;
664b39c5158Smillert }
665b39c5158Smillert #endif
666b39c5158Smillert
667b39c5158Smillert /* static ULONG (* APIENTRY16 pDosSmSetTitle)(ULONG, PSZ); */
668b39c5158Smillert ULONG _THUNK_FUNCTION(DosSmSetTitle)(ULONG, PSZ);
669b39c5158Smillert
670b39c5158Smillert #if 0 /* Does not work. */
671b39c5158Smillert static ULONG (*pDosSmSetTitle)(ULONG, PSZ);
672b39c5158Smillert
673b39c5158Smillert static void
674b39c5158Smillert sesmgr_title_set(char *s)
675b39c5158Smillert {
676b39c5158Smillert SWENTRY swentry;
677b39c5158Smillert static HMODULE hdosc = 0;
678b39c5158Smillert BYTE buf[20];
679b39c5158Smillert long rc;
680b39c5158Smillert
681b39c5158Smillert fill_swentry_default(&swentry);
682b39c5158Smillert if (!pDosSmSetTitle || !hdosc) {
683b39c5158Smillert if (CheckOSError(DosLoadModule(buf, sizeof buf, "sesmgr", &hdosc)))
684b39c5158Smillert croak("Cannot load SESMGR: no `%s'", buf);
685b39c5158Smillert if (CheckOSError(DosQueryProcAddr(hdosc, 0, "DOSSMSETTITLE",
686b39c5158Smillert (PFN*)&pDosSmSetTitle)))
687b39c5158Smillert croak("Cannot load SESMGR.DOSSMSETTITLE, err=%ld", rc);
688b39c5158Smillert }
689b39c5158Smillert /* (pDosSmSetTitle)(swcntrl.idSession,s); */
690b39c5158Smillert rc = ((USHORT)
691b39c5158Smillert (_THUNK_PROLOG (2+4);
692b39c5158Smillert _THUNK_SHORT (swcntrl.idSession);
693b39c5158Smillert _THUNK_FLAT (s);
694b39c5158Smillert _THUNK_CALLI (*pDosSmSetTitle)));
695b39c5158Smillert if (CheckOSError(rc))
696b39c5158Smillert warn("*DOSSMSETTITLE: err=%ld, ses=%ld, addr=%x, *paddr=%x",
697b39c5158Smillert rc, swcntrl.idSession, &_THUNK_FUNCTION(DosSmSetTitle),
698b39c5158Smillert pDosSmSetTitle);
699b39c5158Smillert }
700b39c5158Smillert
701b39c5158Smillert #else /* !0 */
702b39c5158Smillert
703b39c5158Smillert static bool
sesmgr_title_set(char * s)704b39c5158Smillert sesmgr_title_set(char *s)
705b39c5158Smillert {
706b39c5158Smillert SWENTRY swentry;
707b39c5158Smillert long rc;
708b39c5158Smillert
709b39c5158Smillert fill_swentry_default(&swentry);
710b39c5158Smillert rc = ((USHORT)
711b39c5158Smillert (_THUNK_PROLOG (2+4);
712b39c5158Smillert _THUNK_SHORT (swentry.swctl.idSession);
713b39c5158Smillert _THUNK_FLAT (s);
714b39c5158Smillert _THUNK_CALL (DosSmSetTitle)));
715b39c5158Smillert #if 0
716b39c5158Smillert if (CheckOSError(rc))
717b39c5158Smillert warn("DOSSMSETTITLE: err=%ld, ses=%ld, addr=%x",
718b39c5158Smillert rc, swcntrl.idSession, _THUNK_FUNCTION(DosSmSetTitle));
719b39c5158Smillert #endif
720b39c5158Smillert return !CheckOSError(rc);
721b39c5158Smillert }
722b39c5158Smillert #endif /* !0 */
723b39c5158Smillert
724b39c5158Smillert #if 0 /* Does not work. */
725b39c5158Smillert USHORT _THUNK_FUNCTION(Win16SetTitle) ();
726b39c5158Smillert
727b39c5158Smillert static void
728b39c5158Smillert set_title2(char *s)
729b39c5158Smillert {
730b39c5158Smillert long rc;
731b39c5158Smillert
732b39c5158Smillert rc = ((USHORT)
733b39c5158Smillert (_THUNK_PROLOG (4);
734b39c5158Smillert _THUNK_FLAT (s);
735b39c5158Smillert _THUNK_CALL (Win16SetTitle)));
736b39c5158Smillert if (CheckWinError(rc))
737b39c5158Smillert warn("Win16SetTitle: err=%ld", rc);
738b39c5158Smillert }
739b39c5158Smillert #endif
740b39c5158Smillert
741b39c5158Smillert SV *
process_swentry(unsigned long pid,HWND hwnd)742b39c5158Smillert process_swentry(unsigned long pid, HWND hwnd)
743b39c5158Smillert {
744b39c5158Smillert SWENTRY swentry;
745b39c5158Smillert
746b39c5158Smillert if (!(_emx_env & 0x200))
747b39c5158Smillert croak("process_swentry not implemented on DOS"); /* not OS/2. */
748b39c5158Smillert fill_swentry(&swentry, hwnd, pid);
749b39c5158Smillert return newSVpvn((char*)&swentry, sizeof(swentry));
750b39c5158Smillert }
751b39c5158Smillert
752b39c5158Smillert SV *
swentries_list()753b39c5158Smillert swentries_list()
754b39c5158Smillert {
755b39c5158Smillert int num, n = 0;
756b39c5158Smillert STRLEN n_a;
757b39c5158Smillert PSWBLOCK pswblk;
758*b8851fccSafresh1 SV *sv = newSVpvs("");
759b39c5158Smillert
760b39c5158Smillert if (!(_emx_env & 0x200))
761b39c5158Smillert croak("swentries_list not implemented on DOS"); /* not OS/2. */
762b39c5158Smillert if (!pWinQuerySwitchList)
763b39c5158Smillert AssignFuncPByORD(pWinQuerySwitchList, ORD_WinQuerySwitchList);
764b39c5158Smillert num = pWinQuerySwitchList(0, NULL, 0); /* HAB is not required */
765b39c5158Smillert if (!num)
766b39c5158Smillert croak("(Unknown) error during WinQuerySwitchList()");
767b39c5158Smillert /* Allow one extra entry to allow overflow detection (may happen
768b39c5158Smillert if the list has been changed). */
769b39c5158Smillert while (num > n) {
770b39c5158Smillert if (n == 0)
771b39c5158Smillert n = num + 1;
772b39c5158Smillert else
773b39c5158Smillert n = 2*num + 10; /* Enlarge quickly */
774b39c5158Smillert SvGROW(sv, sizeof(ULONG) + sizeof(SWENTRY) * n + 1);
775b39c5158Smillert pswblk = (PSWBLOCK) SvPV_force(sv, n_a);
776b39c5158Smillert num = pWinQuerySwitchList(0, pswblk, SvLEN(sv));
777b39c5158Smillert }
778b39c5158Smillert SvCUR_set(sv, sizeof(ULONG) + sizeof(SWENTRY) * num);
779b39c5158Smillert *SvEND(sv) = 0;
780b39c5158Smillert return sv;
781b39c5158Smillert }
782b39c5158Smillert
783b39c5158Smillert SWENTRY
swentry(char * title,HWND sw_hwnd,HWND icon_hwnd,HPROGRAM owner_phandle,PID owner_pid,ULONG owner_sid,ULONG visible,ULONG nonswitchable,ULONG jumpable,ULONG ptype,HSWITCH sw_entry)784b39c5158Smillert swentry( char *title, HWND sw_hwnd, HWND icon_hwnd, HPROGRAM owner_phandle,
785b39c5158Smillert PID owner_pid, ULONG owner_sid, ULONG visible, ULONG nonswitchable,
786b39c5158Smillert ULONG jumpable, ULONG ptype, HSWITCH sw_entry)
787b39c5158Smillert {
788b39c5158Smillert SWENTRY e;
789b39c5158Smillert
790b39c5158Smillert strncpy(e.swctl.szSwtitle, title, MAXNAMEL);
791b39c5158Smillert e.swctl.szSwtitle[60] = 0;
792b39c5158Smillert e.swctl.hwnd = sw_hwnd;
793b39c5158Smillert e.swctl.hwndIcon = icon_hwnd;
794b39c5158Smillert e.swctl.hprog = owner_phandle;
795b39c5158Smillert e.swctl.idProcess = owner_pid;
796b39c5158Smillert e.swctl.idSession = owner_sid;
797b39c5158Smillert e.swctl.uchVisibility = ((visible ? SWL_VISIBLE : SWL_INVISIBLE)
798b39c5158Smillert | (nonswitchable ? SWL_GRAYED : 0));
799b39c5158Smillert e.swctl.fbJump = (jumpable ? SWL_JUMPABLE : 0);
800b39c5158Smillert e.swctl.bProgType = ptype;
801b39c5158Smillert e.hswitch = sw_entry;
802b39c5158Smillert return e;
803b39c5158Smillert }
804b39c5158Smillert
805b39c5158Smillert SV *
create_swentry(char * title,HWND owner_hwnd,HWND icon_hwnd,HPROGRAM owner_phandle,PID owner_pid,ULONG owner_sid,ULONG visible,ULONG nonswitchable,ULONG jumpable,ULONG ptype,HSWITCH sw_entry)806b39c5158Smillert create_swentry( char *title, HWND owner_hwnd, HWND icon_hwnd, HPROGRAM owner_phandle,
807b39c5158Smillert PID owner_pid, ULONG owner_sid, ULONG visible, ULONG nonswitchable,
808b39c5158Smillert ULONG jumpable, ULONG ptype, HSWITCH sw_entry)
809b39c5158Smillert {
810b39c5158Smillert SWENTRY e = swentry(title, owner_hwnd, icon_hwnd, owner_phandle, owner_pid,
811b39c5158Smillert owner_sid, visible, nonswitchable, jumpable, ptype,
812b39c5158Smillert sw_entry);
813b39c5158Smillert
814b39c5158Smillert return newSVpvn((char*)&e, sizeof(e));
815b39c5158Smillert }
816b39c5158Smillert
817b39c5158Smillert int
change_swentrysw(SWENTRY * sw)818b39c5158Smillert change_swentrysw(SWENTRY *sw)
819b39c5158Smillert {
820b39c5158Smillert ULONG rc; /* For CheckOSError */
821b39c5158Smillert
822b39c5158Smillert if (!(_emx_env & 0x200))
823b39c5158Smillert croak("change_entry() not implemented on DOS"); /* not OS/2. */
824b39c5158Smillert if (!pWinChangeSwitchEntry)
825b39c5158Smillert AssignFuncPByORD(pWinChangeSwitchEntry, ORD_WinChangeSwitchEntry);
826b39c5158Smillert return !CheckOSError(pWinChangeSwitchEntry(sw->hswitch, &sw->swctl));
827b39c5158Smillert }
828b39c5158Smillert
829b39c5158Smillert int
change_swentry(SV * sv)830b39c5158Smillert change_swentry(SV *sv)
831b39c5158Smillert {
832b39c5158Smillert STRLEN l;
833b39c5158Smillert PSWENTRY pswentry = (PSWENTRY)SvPV(sv, l);
834b39c5158Smillert
835b39c5158Smillert if (l != sizeof(SWENTRY))
836b39c5158Smillert croak("Wrong structure size %ld!=%ld in change_swentry()", (long)l, (long)sizeof(SWENTRY));
837b39c5158Smillert return change_swentrysw(pswentry);
838b39c5158Smillert }
839b39c5158Smillert
840b39c5158Smillert
841b39c5158Smillert #define swentry_size() (sizeof(SWENTRY))
842b39c5158Smillert
843b39c5158Smillert void
getscrsize(int * wp,int * hp)844b39c5158Smillert getscrsize(int *wp, int *hp)
845b39c5158Smillert {
846b39c5158Smillert int i[2];
847b39c5158Smillert
848b39c5158Smillert _scrsize(i);
849b39c5158Smillert *wp = i[0];
850b39c5158Smillert *hp = i[1];
851b39c5158Smillert }
852b39c5158Smillert
853b39c5158Smillert /* Force vio to not cross 64K-boundary: */
854b39c5158Smillert #define VIO_FROM_VIOB \
855b39c5158Smillert vio = viob; \
856b39c5158Smillert if (!_THUNK_PTR_STRUCT_OK(vio)) \
857b39c5158Smillert vio++
858b39c5158Smillert
859b39c5158Smillert bool
scrsize_set(int w,int h)860b39c5158Smillert scrsize_set(int w, int h)
861b39c5158Smillert {
862b39c5158Smillert VIOMODEINFO viob[2], *vio;
863b39c5158Smillert ULONG rc;
864b39c5158Smillert
865b39c5158Smillert VIO_FROM_VIOB;
866b39c5158Smillert
867b39c5158Smillert if (h == -9999)
868b39c5158Smillert h = w, w = 0;
869b39c5158Smillert vio->cb = sizeof(*vio);
870b39c5158Smillert if (CheckOSError(VioGetMode( vio, 0 )))
871b39c5158Smillert return 0;
872b39c5158Smillert
873b39c5158Smillert if( w > 0 )
874b39c5158Smillert vio->col = (USHORT)w;
875b39c5158Smillert
876b39c5158Smillert if( h > 0 )
877b39c5158Smillert vio->row = (USHORT)h;
878b39c5158Smillert
879b39c5158Smillert vio->cb = 8;
880b39c5158Smillert if (CheckOSError(VioSetMode( vio, 0 )))
881b39c5158Smillert return 0;
882b39c5158Smillert return 1;
883b39c5158Smillert }
884b39c5158Smillert
885b39c5158Smillert void
cursor(int * sp,int * ep,int * wp,int * ap)886b39c5158Smillert cursor(int *sp, int *ep, int *wp, int *ap)
887b39c5158Smillert {
888b39c5158Smillert VIOCURSORINFO viob[2], *vio;
889b39c5158Smillert ULONG rc;
890b39c5158Smillert
891b39c5158Smillert VIO_FROM_VIOB;
892b39c5158Smillert
893b39c5158Smillert if (CheckOSError(VioGetCurType( vio, 0 )))
894b39c5158Smillert croak_with_os2error("VioGetCurType() error");
895b39c5158Smillert
896b39c5158Smillert *sp = vio->yStart;
897b39c5158Smillert *ep = vio->cEnd;
898b39c5158Smillert *wp = vio->cx;
899b39c5158Smillert *ep = vio->attr;
900b39c5158Smillert }
901b39c5158Smillert
902b39c5158Smillert bool
cursor__(int is_a)903b39c5158Smillert cursor__(int is_a)
904b39c5158Smillert {
905b39c5158Smillert int s,e,w,a;
906b39c5158Smillert
907b39c5158Smillert cursor(&s, &e, &w, &a);
908b39c5158Smillert if (is_a)
909b39c5158Smillert return a;
910b39c5158Smillert else
911b39c5158Smillert return w;
912b39c5158Smillert }
913b39c5158Smillert
914b39c5158Smillert bool
cursor_set(int s,int e,int w,int a)915b39c5158Smillert cursor_set(int s, int e, int w, int a)
916b39c5158Smillert {
917b39c5158Smillert VIOCURSORINFO viob[2], *vio;
918b39c5158Smillert ULONG rc;
919b39c5158Smillert
920b39c5158Smillert VIO_FROM_VIOB;
921b39c5158Smillert
922b39c5158Smillert vio->yStart = s;
923b39c5158Smillert vio->cEnd = e;
924b39c5158Smillert vio->cx = w;
925b39c5158Smillert vio->attr = a;
926b39c5158Smillert return !CheckOSError(VioSetCurType( vio, 0 ));
927b39c5158Smillert }
928b39c5158Smillert
929b39c5158Smillert static int
bufsize(void)930b39c5158Smillert bufsize(void)
931b39c5158Smillert {
932b39c5158Smillert #if 1
933b39c5158Smillert VIOMODEINFO viob[2], *vio;
934b39c5158Smillert ULONG rc;
935b39c5158Smillert
936b39c5158Smillert VIO_FROM_VIOB;
937b39c5158Smillert
938b39c5158Smillert vio->cb = sizeof(*vio);
939b39c5158Smillert if (CheckOSError(VioGetMode( vio, 0 )))
940b39c5158Smillert croak_with_os2error("Can't get size of buffer for screen");
941b39c5158Smillert #if 0 /* buf=323552247, full=1118455, partial=0 */
942b39c5158Smillert croak("Lengths: buf=%d, full=%d, partial=%d",vio->buf_length,vio->full_length,vio->partial_length);
943b39c5158Smillert return newSVpvn((char*)vio->buf_addr, vio->full_length);
944b39c5158Smillert #endif
945b39c5158Smillert return vio->col * vio->row * 2; /* How to get bytes/cell? 2 or 4? */
946b39c5158Smillert #else /* 0 */
947b39c5158Smillert int i[2];
948b39c5158Smillert
949b39c5158Smillert _scrsize(i);
950b39c5158Smillert return i[0]*i[1]*2;
951b39c5158Smillert #endif /* 0 */
952b39c5158Smillert }
953b39c5158Smillert
954b39c5158Smillert SV*
_kbdChar(unsigned int nowait,int handle)955b39c5158Smillert _kbdChar(unsigned int nowait, int handle)
956b39c5158Smillert {
957b39c5158Smillert KBDKEYINFO viob[2], *vio;
958b39c5158Smillert ULONG rc;
959b39c5158Smillert
960b39c5158Smillert VIO_FROM_VIOB;
961b39c5158Smillert
962b39c5158Smillert if (nowait > 2)
963b39c5158Smillert croak("unexpected nowait");
964b39c5158Smillert if (CheckOSError(nowait == 2
965b39c5158Smillert ? KbdPeek( vio, handle )
966b39c5158Smillert : KbdCharIn( vio, nowait == 1, handle )))
967b39c5158Smillert croak_with_os2error("Can't _kbdChar");
968b39c5158Smillert return newSVpvn((char*)vio, sizeof(*vio));
969b39c5158Smillert }
970b39c5158Smillert
971b39c5158Smillert SV*
_kbdStatus(int handle)972b39c5158Smillert _kbdStatus(int handle)
973b39c5158Smillert {
974b39c5158Smillert KBDINFO viob[2], *vio;
975b39c5158Smillert ULONG rc;
976b39c5158Smillert
977b39c5158Smillert VIO_FROM_VIOB;
978b39c5158Smillert
979b39c5158Smillert vio->cb = sizeof(*vio);
980b39c5158Smillert if (CheckOSError(KbdGetStatus( vio, handle )))
981b39c5158Smillert croak_with_os2error("Can't _kbdStatus");
982b39c5158Smillert return newSVpvn((char*)vio, sizeof(*vio));
983b39c5158Smillert }
984b39c5158Smillert
985b39c5158Smillert void
_kbdStatus_set(SV * sv,int handle)986b39c5158Smillert _kbdStatus_set(SV* sv, int handle)
987b39c5158Smillert {
988b39c5158Smillert KBDINFO viob[2], *vio;
989b39c5158Smillert ULONG rc;
990b39c5158Smillert STRLEN l;
991b39c5158Smillert char *s = SvPV(sv, l);
992b39c5158Smillert
993b39c5158Smillert VIO_FROM_VIOB;
994b39c5158Smillert
995b39c5158Smillert if (l != sizeof(*vio))
996b39c5158Smillert croak("unexpected datasize");
997b39c5158Smillert Copy((KBDINFO*)s, vio, 1, KBDINFO);
998b39c5158Smillert if (vio->cb != sizeof(*vio))
999b39c5158Smillert croak("unexpected datasize");
1000b39c5158Smillert if (CheckOSError(KbdSetStatus( vio, handle )))
1001b39c5158Smillert croak_with_os2error("Can't kbdStatus_set()");
1002b39c5158Smillert }
1003b39c5158Smillert
1004b39c5158Smillert SV*
_vioConfig(int which,int handle)1005b39c5158Smillert _vioConfig(int which, int handle)
1006b39c5158Smillert {
1007b39c5158Smillert struct {VIOCONFIGINFO i; short a[20];} viob[2], *vio;
1008b39c5158Smillert ULONG rc;
1009b39c5158Smillert
1010b39c5158Smillert VIO_FROM_VIOB;
1011b39c5158Smillert
1012b39c5158Smillert vio->i.cb = 2;
1013b39c5158Smillert if (CheckOSError(VioGetConfig( which, &vio->i, handle )))
1014b39c5158Smillert croak_with_os2error("Can't get VIO config size");
1015b39c5158Smillert if (vio->i.cb > sizeof(*vio))
1016b39c5158Smillert vio->i.cb = sizeof(*vio);
1017b39c5158Smillert if (CheckOSError(VioGetConfig( which, &vio->i, handle )))
1018b39c5158Smillert croak_with_os2error("Can't get VIO config");
1019b39c5158Smillert return newSVpvn((char*)vio, vio->i.cb);
1020b39c5158Smillert }
1021b39c5158Smillert
1022b39c5158Smillert SV*
_vioMode(void)1023b39c5158Smillert _vioMode(void)
1024b39c5158Smillert {
1025b39c5158Smillert VIOMODEINFO viob[2], *vio;
1026b39c5158Smillert ULONG rc;
1027b39c5158Smillert
1028b39c5158Smillert VIO_FROM_VIOB;
1029b39c5158Smillert
1030b39c5158Smillert vio->cb = sizeof(*vio);
1031b39c5158Smillert if (CheckOSError(VioGetMode( vio, 0 )))
1032b39c5158Smillert croak_with_os2error("Can't get VIO mode");
1033b39c5158Smillert return newSVpvn((char*)vio, sizeof(*vio));
1034b39c5158Smillert }
1035b39c5158Smillert
1036b39c5158Smillert void
_vioMode_set(SV * sv)1037b39c5158Smillert _vioMode_set(SV* sv)
1038b39c5158Smillert {
1039b39c5158Smillert VIOMODEINFO viob[2], *vio;
1040b39c5158Smillert ULONG rc;
1041b39c5158Smillert STRLEN l;
1042b39c5158Smillert char *s = SvPV(sv, l);
1043b39c5158Smillert
1044b39c5158Smillert VIO_FROM_VIOB;
1045b39c5158Smillert
1046b39c5158Smillert Copy((VIOMODEINFO*)s, vio, 1, VIOMODEINFO);
1047b39c5158Smillert if (vio->cb != sizeof(*vio) || l != vio->cb)
1048b39c5158Smillert croak("unexpected datasize");
1049b39c5158Smillert if (CheckOSError(VioSetMode( vio, 0 )))
1050b39c5158Smillert croak_with_os2error("Can't set VIO mode");
1051b39c5158Smillert }
1052b39c5158Smillert
1053b39c5158Smillert SV*
vioFont(int type,int * w,int * h)1054b39c5158Smillert vioFont(int type, int *w, int *h) /* 0 for actual RAM font, 1 for ROM font */
1055b39c5158Smillert {
1056b39c5158Smillert VIOFONTINFO viob[2], *vio;
1057b39c5158Smillert ULONG rc;
1058b39c5158Smillert UCHAR b[1<<17];
1059b39c5158Smillert UCHAR *buf = b;
1060b39c5158Smillert SV *sv;
1061b39c5158Smillert
1062b39c5158Smillert VIO_FROM_VIOB;
1063b39c5158Smillert
1064b39c5158Smillert /* Should not cross 64K boundaries too: */
1065b39c5158Smillert if (((ULONG)buf) & 0xFFFF)
1066b39c5158Smillert buf += 0x10000 - (((ULONG)buf) & 0xFFFF);
1067b39c5158Smillert
1068b39c5158Smillert vio->cb = sizeof(*vio);
1069b39c5158Smillert vio->type = type; /* BIOS or the loaded font. */
1070b39c5158Smillert vio->cbData = 0xFFFF; /* How large is my buffer? */
1071b39c5158Smillert vio->pbData = _emx_32to16(buf); /* Wants an 16:16 pointer */
1072b39c5158Smillert if (CheckOSError(VioGetFont( vio, 0 )))
1073b39c5158Smillert croak_with_os2error("Can't get VIO font");
1074b39c5158Smillert *w = vio->cxCell;
1075b39c5158Smillert *h = vio->cyCell;
1076b39c5158Smillert return newSVpvn(buf,vio->cbData);
1077b39c5158Smillert }
1078b39c5158Smillert
1079b39c5158Smillert void
vioFont_set(SV * sv,int cellwidth,int cellheight,int type)1080b39c5158Smillert vioFont_set(SV *sv, int cellwidth, int cellheight, int type)
1081b39c5158Smillert {
1082b39c5158Smillert VIOFONTINFO viob[2], *vio;
1083b39c5158Smillert ULONG rc;
1084b39c5158Smillert UCHAR b[1<<17];
1085b39c5158Smillert UCHAR *buf = b;
1086b39c5158Smillert STRLEN l;
1087b39c5158Smillert char *s = SvPV(sv, l);
1088b39c5158Smillert
1089b39c5158Smillert VIO_FROM_VIOB;
1090b39c5158Smillert
1091b39c5158Smillert /* Should not cross 64K boundaries too: */
1092b39c5158Smillert if (((ULONG)buf) & 0xFFFF)
1093b39c5158Smillert buf += 0x10000 - (((ULONG)buf) & 0xFFFF);
1094b39c5158Smillert
1095b39c5158Smillert if (l > 0xFFFF)
1096b39c5158Smillert croak("length overflow of VIO font");
1097b39c5158Smillert if (l != (cellwidth + 7)/8 * cellheight * 256)
1098b39c5158Smillert warn("unexpected length of VIO font");
1099b39c5158Smillert vio->cb = sizeof(*vio);
1100b39c5158Smillert vio->type = type; /* BIOS or the loaded font. */
1101b39c5158Smillert vio->cbData = l; /* How large is my buffer? */
1102b39c5158Smillert vio->pbData = _emx_32to16(buf); /* Wants an 16:16 pointer */
1103b39c5158Smillert vio->cxCell = cellwidth;
1104b39c5158Smillert vio->cyCell = cellheight;
1105b39c5158Smillert Copy(s, buf, l, char);
1106b39c5158Smillert
1107b39c5158Smillert if (CheckOSError(VioSetFont( vio, 0 )))
1108b39c5158Smillert croak_with_os2error("Can't set VIO font");
1109b39c5158Smillert }
1110b39c5158Smillert
1111b39c5158Smillert /*
1112b39c5158Smillert uses use32,os2def,os2base,crt,defs;
1113b39c5158Smillert var Plt :Plt256;
1114b39c5158Smillert const Pal :VioPalState=(Cb:sizeof(VioPalState);rType:0;iFirst:0;
1115b39c5158Smillert Acolor:($FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF));
1116b39c5158Smillert CReg:VioColorReg=(Cb:sizeof(VioColorReg);rType:3;FirstColorReg:0;
1117b39c5158Smillert NumColorRegs:256; ColorRegAddr:@Plt);
1118b39c5158Smillert var ii:Pointer;
1119b39c5158Smillert begin
1120b39c5158Smillert VioGetState(Pal,0);
1121b39c5158Smillert Pal.Acolor[09]:=$0F;
1122b39c5158Smillert Pal.Acolor[10]:=$A;
1123b39c5158Smillert Pal.Acolor[13]:=$2F;
1124b39c5158Smillert VioSetState(Pal,0); // ce smena EGA registrov
1125b39c5158Smillert asm
1126b39c5158Smillert lea eax,Plt
1127b39c5158Smillert call DosFlatToSel
1128b39c5158Smillert mov ii,eax
1129b39c5158Smillert end;
1130b39c5158Smillert CReg.ColorRegAddr:=ii;
1131b39c5158Smillert VioGetState(CReg,0);
1132b39c5158Smillert Plt[10,0]:=$00;
1133b39c5158Smillert Plt[10,1]:=$32;
1134b39c5158Smillert Plt[10,2]:=$2A;
1135b39c5158Smillert VioSetState(CReg,0); // a ce - VGA registrov
1136b39c5158Smillert end.
1137b39c5158Smillert */
1138b39c5158Smillert
1139b39c5158Smillert typedef union {
1140b39c5158Smillert VIOPALSTATE pal;
1141b39c5158Smillert struct { VIOPALSTATE pal; USHORT a[15]; } pal_padded;
1142b39c5158Smillert VIOOVERSCAN overscan;
1143b39c5158Smillert VIOINTENSITY intensity;
1144b39c5158Smillert VIOCOLORREG colorreg;
1145b39c5158Smillert struct { VIOCOLORREG reg; char rgb[3*256]; } colorreg_padded;
1146b39c5158Smillert VIOSETULINELOC lineloc;
1147b39c5158Smillert VIOSETTARGET target;
1148b39c5158Smillert } my_VIOSTATE;
1149b39c5158Smillert
1150b39c5158Smillert int
vio_state_size(int what)1151b39c5158Smillert vio_state_size(int what)
1152b39c5158Smillert {
1153b39c5158Smillert static const char sizes[] = {
1154b39c5158Smillert sizeof(VIOPALSTATE),
1155b39c5158Smillert sizeof(VIOOVERSCAN),
1156b39c5158Smillert sizeof(VIOINTENSITY),
1157b39c5158Smillert sizeof(VIOCOLORREG),
1158b39c5158Smillert 6, /* Random number: Reserved entry */
1159b39c5158Smillert sizeof(VIOSETULINELOC),
1160b39c5158Smillert sizeof(VIOSETTARGET)
1161b39c5158Smillert };
1162b39c5158Smillert if (what < 0 || what >= sizeof(sizes))
1163b39c5158Smillert croak("Unexpected VIO state type");
1164b39c5158Smillert return sizes[what];
1165b39c5158Smillert }
1166b39c5158Smillert
1167b39c5158Smillert SV*
_vioState(int what,int first,int count)1168b39c5158Smillert _vioState(int what, int first, int count)
1169b39c5158Smillert {
1170b39c5158Smillert my_VIOSTATE viob[2], *vio;
1171b39c5158Smillert ULONG rc, size = vio_state_size(what);
1172b39c5158Smillert
1173b39c5158Smillert VIO_FROM_VIOB;
1174b39c5158Smillert
1175b39c5158Smillert vio->pal.cb = size;
1176b39c5158Smillert vio->pal.type = what;
1177b39c5158Smillert if (what == 0) {
1178b39c5158Smillert vio->pal.iFirst = first;
1179b39c5158Smillert if (first < 0 || first >= 16)
1180b39c5158Smillert croak("unexpected palette start value");
1181b39c5158Smillert if (count < 0 || count > 16)
1182b39c5158Smillert croak("unexpected palette count");
1183b39c5158Smillert vio->pal.cb = (size += (count - 1) * sizeof(short));
1184b39c5158Smillert } else if (what == 3) {
1185b39c5158Smillert /* Wants an 16:16 pointer */
1186b39c5158Smillert if (count < 0 || count > 256)
1187b39c5158Smillert croak("unexpected palette count");
1188b39c5158Smillert vio->colorreg.colorregaddr = (PCH)_emx_32to16(vio->colorreg_padded.rgb);
1189b39c5158Smillert vio->colorreg.numcolorregs = count; /* 256 is max */
1190b39c5158Smillert vio->colorreg.firstcolorreg = first;
1191b39c5158Smillert size += 3 * count;
1192b39c5158Smillert }
1193b39c5158Smillert if (CheckOSError(VioGetState( (void*)vio, 0 )))
1194b39c5158Smillert croak_with_os2error("Can't get VIO state");
1195b39c5158Smillert return newSVpvn((char*)vio, size);
1196b39c5158Smillert }
1197b39c5158Smillert
1198b39c5158Smillert void
_vioState_set(SV * sv)1199b39c5158Smillert _vioState_set(SV *sv)
1200b39c5158Smillert {
1201b39c5158Smillert my_VIOSTATE viob[2], *ovio = (my_VIOSTATE*)SvPV_nolen(sv), *vio = ovio;
1202b39c5158Smillert int what = ovio->pal.type, cb = ovio->pal.cb;
1203b39c5158Smillert ULONG rc, size = vio_state_size(what);
1204b39c5158Smillert STRLEN l;
1205b39c5158Smillert char *s = SvPV(sv, l);
1206b39c5158Smillert
1207b39c5158Smillert VIO_FROM_VIOB;
1208b39c5158Smillert
1209b39c5158Smillert switch (what) {
1210b39c5158Smillert case 0:
1211b39c5158Smillert if ( cb < size || cb > size + 15*sizeof(SHORT) || l != cb)
1212b39c5158Smillert croak("unexpected datasize");
1213b39c5158Smillert size = l;
1214b39c5158Smillert break;
1215b39c5158Smillert case 3:
1216b39c5158Smillert if (l != cb + 3 * ovio->colorreg.numcolorregs || cb != size)
1217b39c5158Smillert croak("unexpected datasize");
1218b39c5158Smillert size = l;
1219b39c5158Smillert break;
1220b39c5158Smillert default:
1221b39c5158Smillert if (l != cb || l != size )
1222b39c5158Smillert croak("unexpected datasize");
1223b39c5158Smillert break;
1224b39c5158Smillert }
1225b39c5158Smillert Copy(s, (char*)vio, size, char);
1226b39c5158Smillert if (what == 3) /* We expect colors put after VIOCOLORREG */
1227b39c5158Smillert vio->colorreg.colorregaddr = (PCH)_emx_32to16(vio->colorreg_padded.rgb);
1228b39c5158Smillert
1229b39c5158Smillert if (CheckOSError(VioSetState( (void*)vio, 0 )))
1230b39c5158Smillert croak_with_os2error("Can't set VIO state");
1231b39c5158Smillert }
1232b39c5158Smillert
1233b39c5158Smillert SV *
screen(void)1234b39c5158Smillert screen(void)
1235b39c5158Smillert {
1236b39c5158Smillert ULONG rc;
1237b39c5158Smillert USHORT bufl = bufsize();
1238b39c5158Smillert char b[(1<<16) * 3]; /* This/3 is enough for 16-bit calls, we need
1239b39c5158Smillert 2x overhead due to 2 vs 4 issue, and extra
1240b39c5158Smillert 64K due to alignment logic */
1241b39c5158Smillert char *buf = b;
1242b39c5158Smillert
1243b39c5158Smillert if (((ULONG)buf) & 0xFFFF)
1244b39c5158Smillert buf += 0x10000 - (((ULONG)buf) & 0xFFFF);
1245b39c5158Smillert if ((sizeof(b) - (buf - b)) < 2*bufl)
1246b39c5158Smillert croak("panic: VIO buffer allocation");
1247b39c5158Smillert if (CheckOSError(VioReadCellStr( buf, &bufl, 0, 0, 0 )))
1248b39c5158Smillert return &PL_sv_undef;
1249b39c5158Smillert return newSVpvn(buf,bufl);
1250b39c5158Smillert }
1251b39c5158Smillert
1252b39c5158Smillert bool
screen_set(SV * sv)1253b39c5158Smillert screen_set(SV *sv)
1254b39c5158Smillert {
1255b39c5158Smillert ULONG rc;
1256b39c5158Smillert STRLEN l = SvCUR(sv), bufl = bufsize();
1257b39c5158Smillert char b[(1<<16) * 2]; /* This/2 is enough for 16-bit calls, we need
1258b39c5158Smillert extra 64K due to alignment logic */
1259b39c5158Smillert char *buf = b;
1260b39c5158Smillert
1261b39c5158Smillert if (((ULONG)buf) & 0xFFFF)
1262b39c5158Smillert buf += 0x10000 - (((ULONG)buf) & 0xFFFF);
1263b39c5158Smillert if (!SvPOK(sv) || ((l != bufl) && (l != 2*bufl)))
1264b39c5158Smillert croak("Wrong size %d of saved screen data", SvCUR(sv));
1265b39c5158Smillert if ((sizeof(b) - (buf - b)) < l)
1266b39c5158Smillert croak("panic: VIO buffer allocation");
1267b39c5158Smillert Copy(SvPV(sv,l), buf, bufl, char);
1268b39c5158Smillert if (CheckOSError(VioWrtCellStr( buf, bufl, 0, 0, 0 )))
1269b39c5158Smillert return 0;
1270b39c5158Smillert return 1;
1271b39c5158Smillert }
1272b39c5158Smillert
1273b39c5158Smillert int
process_codepages()1274b39c5158Smillert process_codepages()
1275b39c5158Smillert {
1276b39c5158Smillert ULONG cps[4], cp, rc;
1277b39c5158Smillert
1278b39c5158Smillert if (CheckOSError(DosQueryCp( sizeof(cps), cps, &cp )))
1279b39c5158Smillert croak_with_os2error("DosQueryCp()");
1280b39c5158Smillert return cp;
1281b39c5158Smillert }
1282b39c5158Smillert
1283b39c5158Smillert int
out_codepage()1284b39c5158Smillert out_codepage()
1285b39c5158Smillert {
1286b39c5158Smillert USHORT cp, rc;
1287b39c5158Smillert
1288b39c5158Smillert if (CheckOSError(VioGetCp( 0, &cp, 0 )))
1289b39c5158Smillert croak_with_os2error("VioGetCp()");
1290b39c5158Smillert return cp;
1291b39c5158Smillert }
1292b39c5158Smillert
1293b39c5158Smillert bool
out_codepage_set(int cp)1294b39c5158Smillert out_codepage_set(int cp)
1295b39c5158Smillert {
1296b39c5158Smillert USHORT rc;
1297b39c5158Smillert
1298b39c5158Smillert return !(CheckOSError(VioSetCp( 0, cp, 0 )));
1299b39c5158Smillert }
1300b39c5158Smillert
1301b39c5158Smillert int
in_codepage()1302b39c5158Smillert in_codepage()
1303b39c5158Smillert {
1304b39c5158Smillert USHORT cp, rc;
1305b39c5158Smillert
1306b39c5158Smillert if (CheckOSError(KbdGetCp( 0, &cp, 0 )))
1307b39c5158Smillert croak_with_os2error("KbdGetCp()");
1308b39c5158Smillert return cp;
1309b39c5158Smillert }
1310b39c5158Smillert
1311b39c5158Smillert bool
in_codepage_set(int cp)1312b39c5158Smillert in_codepage_set(int cp)
1313b39c5158Smillert {
1314b39c5158Smillert USHORT rc;
1315b39c5158Smillert
1316b39c5158Smillert return !(CheckOSError(KbdSetCp( 0, cp, 0 )));
1317b39c5158Smillert }
1318b39c5158Smillert
1319b39c5158Smillert bool
process_codepage_set(int cp)1320b39c5158Smillert process_codepage_set(int cp)
1321b39c5158Smillert {
1322b39c5158Smillert USHORT rc;
1323b39c5158Smillert
1324b39c5158Smillert return !(CheckOSError(DosSetProcessCp( cp )));
1325b39c5158Smillert }
1326b39c5158Smillert
1327b39c5158Smillert int
ppidOf(int pid)1328b39c5158Smillert ppidOf(int pid)
1329b39c5158Smillert {
1330b39c5158Smillert PQTOPLEVEL psi;
1331b39c5158Smillert int ppid;
1332b39c5158Smillert
1333b39c5158Smillert if (!pid)
1334b39c5158Smillert return -1;
1335b39c5158Smillert psi = get_sysinfo(pid, QSS_PROCESS);
1336b39c5158Smillert if (!psi)
1337b39c5158Smillert return -1;
1338b39c5158Smillert ppid = psi->procdata->ppid;
1339b39c5158Smillert Safefree(psi);
1340b39c5158Smillert return ppid;
1341b39c5158Smillert }
1342b39c5158Smillert
1343b39c5158Smillert int
sidOf(int pid)1344b39c5158Smillert sidOf(int pid)
1345b39c5158Smillert {
1346b39c5158Smillert PQTOPLEVEL psi;
1347b39c5158Smillert int sid;
1348b39c5158Smillert
1349b39c5158Smillert if (!pid)
1350b39c5158Smillert return -1;
1351b39c5158Smillert psi = get_sysinfo(pid, QSS_PROCESS);
1352b39c5158Smillert if (!psi)
1353b39c5158Smillert return -1;
1354b39c5158Smillert sid = psi->procdata->sessid;
1355b39c5158Smillert Safefree(psi);
1356b39c5158Smillert return sid;
1357b39c5158Smillert }
1358b39c5158Smillert
1359b39c5158Smillert STRLEN
StrLen(ULONG addr,ULONG lim,I32 unitsize)1360b39c5158Smillert StrLen(ULONG addr, ULONG lim, I32 unitsize)
1361b39c5158Smillert {
1362b39c5158Smillert switch (unitsize) {
1363b39c5158Smillert case 1:
1364b39c5158Smillert {
1365b39c5158Smillert char *s = (char *)addr;
1366b39c5158Smillert char *s1 = s, *e = (char *)(addr + lim);
1367b39c5158Smillert
1368b39c5158Smillert while (s < e && *s)
1369b39c5158Smillert s++;
1370b39c5158Smillert return s - s1;
1371b39c5158Smillert }
1372b39c5158Smillert break;
1373b39c5158Smillert case 2:
1374b39c5158Smillert {
1375b39c5158Smillert short *s = (short *)addr;
1376b39c5158Smillert short *s1 = s, *e = (short *)(addr + lim);
1377b39c5158Smillert
1378b39c5158Smillert while (s < e && *s)
1379b39c5158Smillert s++;
1380b39c5158Smillert return (char*)s - (char*)s1;
1381b39c5158Smillert }
1382b39c5158Smillert break;
1383b39c5158Smillert case 4:
1384b39c5158Smillert {
1385b39c5158Smillert int *s = (int *)addr;
1386b39c5158Smillert int *s1 = s, *e = (int *)(addr + lim);
1387b39c5158Smillert
1388b39c5158Smillert while (s < e && *s)
1389b39c5158Smillert s++;
1390b39c5158Smillert return (char*)s - (char*)s1;
1391b39c5158Smillert }
1392b39c5158Smillert break;
1393b39c5158Smillert case 8:
1394b39c5158Smillert {
1395b39c5158Smillert long long *s = (long long *)addr;
1396b39c5158Smillert long long *s1 = s, *e = (long long *)(addr + lim);
1397b39c5158Smillert
1398b39c5158Smillert while (s < e && *s)
1399b39c5158Smillert s++;
1400b39c5158Smillert return (char*)s - (char*)s1;
1401b39c5158Smillert }
1402b39c5158Smillert break;
1403b39c5158Smillert default:
1404b39c5158Smillert croak("StrLen: unknown unitsize %d", (int)unitsize);
1405b39c5158Smillert }
1406b39c5158Smillert }
1407b39c5158Smillert
1408b39c5158Smillert #define ulMPFROMSHORT(i) ((unsigned long)MPFROMSHORT(i))
1409b39c5158Smillert #define ulMPVOID() ((unsigned long)MPVOID)
1410b39c5158Smillert #define ulMPFROMCHAR(i) ((unsigned long)MPFROMCHAR(i))
1411b39c5158Smillert #define ulMPFROM2SHORT(x1,x2) ((unsigned long)MPFROM2SHORT(x1,x2))
1412b39c5158Smillert #define ulMPFROMSH2CH(s, c1, c2) ((unsigned long)MPFROMSH2CH(s, c1, c2))
1413b39c5158Smillert #define ulMPFROMLONG(x) ((unsigned long)MPFROMLONG(x))
1414b39c5158Smillert
1415b39c5158Smillert #define _MessageBox MessageBox
1416b39c5158Smillert #define _MessageBox2 MessageBox2
1417b39c5158Smillert
1418b39c5158Smillert MODULE = OS2::Process PACKAGE = OS2::Process
1419b39c5158Smillert
1420b39c5158Smillert PROTOTYPES: ENABLE
1421b39c5158Smillert
1422b39c5158Smillert unsigned long
constant(name,arg)1423b39c5158Smillert constant(name,arg)
1424b39c5158Smillert char * name
1425b39c5158Smillert int arg
1426b39c5158Smillert
1427b39c5158Smillert char *
1428b39c5158Smillert my_type()
1429b39c5158Smillert
1430b39c5158Smillert U32
1431b39c5158Smillert file_type(path)
1432b39c5158Smillert char *path
1433b39c5158Smillert
1434b39c5158Smillert SV *
1435b39c5158Smillert swentry_expand( SV *sv )
1436b39c5158Smillert PPCODE:
1437b39c5158Smillert {
1438b39c5158Smillert STRLEN l;
1439b39c5158Smillert PSWENTRY pswentry = (PSWENTRY)SvPV(sv, l);
1440b39c5158Smillert
1441b39c5158Smillert if (l != sizeof(SWENTRY))
1442b39c5158Smillert croak("Wrong structure size %ld!=%ld in swentry_expand()", (long)l, (long)sizeof(SWENTRY));
1443b39c5158Smillert EXTEND(sp,11);
1444b39c5158Smillert PUSHs(sv_2mortal(newSVpv(pswentry->swctl.szSwtitle, 0)));
1445b39c5158Smillert PUSHs(sv_2mortal(newSVnv(pswentry->swctl.hwnd)));
1446b39c5158Smillert PUSHs(sv_2mortal(newSVnv(pswentry->swctl.hwndIcon)));
1447b39c5158Smillert PUSHs(sv_2mortal(newSViv(pswentry->swctl.hprog)));
1448b39c5158Smillert PUSHs(sv_2mortal(newSViv(pswentry->swctl.idProcess)));
1449b39c5158Smillert PUSHs(sv_2mortal(newSViv(pswentry->swctl.idSession)));
1450b39c5158Smillert PUSHs(sv_2mortal(newSViv(pswentry->swctl.uchVisibility & SWL_VISIBLE)));
1451b39c5158Smillert PUSHs(sv_2mortal(newSViv(pswentry->swctl.uchVisibility & SWL_GRAYED)));
1452b39c5158Smillert PUSHs(sv_2mortal(newSViv(pswentry->swctl.fbJump == SWL_JUMPABLE)));
1453b39c5158Smillert PUSHs(sv_2mortal(newSViv(pswentry->swctl.bProgType)));
1454b39c5158Smillert PUSHs(sv_2mortal(newSViv(pswentry->hswitch)));
1455b39c5158Smillert }
1456b39c5158Smillert
1457b39c5158Smillert SV *
1458b39c5158Smillert create_swentry( char *title, unsigned long sw_hwnd, unsigned long icon_hwnd, unsigned long owner_phandle, unsigned long owner_pid, unsigned long owner_sid, unsigned long visible, unsigned long switchable, unsigned long jumpable, unsigned long ptype, unsigned long sw_entry)
1459b39c5158Smillert PROTOTYPE: DISABLE
1460b39c5158Smillert
1461b39c5158Smillert int
1462b39c5158Smillert change_swentry( SV *sv )
1463b39c5158Smillert
1464b39c5158Smillert bool
1465b39c5158Smillert sesmgr_title_set(s)
1466b39c5158Smillert char *s
1467b39c5158Smillert
1468b39c5158Smillert SV *
1469b39c5158Smillert process_swentry(unsigned long pid = getpid(), HWND hwnd = NULLHANDLE);
1470b39c5158Smillert PROTOTYPE: DISABLE
1471b39c5158Smillert
1472b39c5158Smillert int
1473b39c5158Smillert swentry_size()
1474b39c5158Smillert
1475b39c5158Smillert SV *
1476b39c5158Smillert swentries_list()
1477b39c5158Smillert
1478b39c5158Smillert void
1479b39c5158Smillert ResetWinError()
1480b39c5158Smillert POSTCALL:
1481b39c5158Smillert XSRETURN_YES;
1482b39c5158Smillert
1483b39c5158Smillert int
1484b39c5158Smillert WindowText_set(HWND hwndFrame, char *title)
1485b39c5158Smillert
1486b39c5158Smillert bool
1487b39c5158Smillert FocusWindow_set(HWND hwndFocus, HWND hwndDesktop = HWND_DESKTOP)
1488b39c5158Smillert
1489b39c5158Smillert bool
1490b39c5158Smillert ShowWindow(HWND hwnd, bool fShow = TRUE)
1491b39c5158Smillert
1492b39c5158Smillert bool
1493b39c5158Smillert EnableWindow(HWND hwnd, bool fEnable = TRUE)
1494b39c5158Smillert
1495b39c5158Smillert bool
1496b39c5158Smillert PostMsg(HWND hwnd, unsigned long msg, unsigned long mp1 = 0, unsigned long mp2 = 0)
1497b39c5158Smillert C_ARGS: hwnd, msg, (MPARAM)mp1, (MPARAM)mp2
1498b39c5158Smillert
1499b39c5158Smillert bool
1500b39c5158Smillert WindowPos_set(HWND hwnd, long x, long y, unsigned long fl = SWP_MOVE, long cx = 0, long cy = 0, HWND hwndInsertBehind = HWND_TOP)
1501b39c5158Smillert PROTOTYPE: DISABLE
1502b39c5158Smillert
1503b39c5158Smillert unsigned long
1504b39c5158Smillert BeginEnumWindows(HWND hwnd)
1505b39c5158Smillert
1506b39c5158Smillert bool
1507b39c5158Smillert EndEnumWindows(unsigned long henum)
1508b39c5158Smillert
1509b39c5158Smillert unsigned long
1510b39c5158Smillert GetNextWindow(unsigned long henum)
1511b39c5158Smillert
1512b39c5158Smillert bool
1513b39c5158Smillert IsWindowVisible(HWND hwnd)
1514b39c5158Smillert
1515b39c5158Smillert bool
1516b39c5158Smillert IsWindowEnabled(HWND hwnd)
1517b39c5158Smillert
1518b39c5158Smillert bool
1519b39c5158Smillert IsWindowShowing(HWND hwnd)
1520b39c5158Smillert
1521b39c5158Smillert unsigned long
1522b39c5158Smillert QueryWindow(HWND hwnd, long cmd)
1523b39c5158Smillert
1524b39c5158Smillert unsigned long
1525b39c5158Smillert IsChild(HWND hwnd, HWND hwndParent)
1526b39c5158Smillert
1527b39c5158Smillert unsigned long
1528b39c5158Smillert WindowFromId(HWND hwndParent, unsigned long id)
1529b39c5158Smillert
1530b39c5158Smillert unsigned long
1531b39c5158Smillert WindowFromPoint(long x, long y, HWND hwnd = HWND_DESKTOP, bool fChildren = TRUE)
1532b39c5158Smillert PROTOTYPE: DISABLE
1533b39c5158Smillert
1534b39c5158Smillert unsigned long
1535b39c5158Smillert EnumDlgItem(HWND hwndDlg, unsigned long code, HWND hwnd = NULLHANDLE)
1536b39c5158Smillert C_ARGS: hwndDlg, hwnd, code
1537b39c5158Smillert
1538b39c5158Smillert bool
1539b39c5158Smillert EnableWindowUpdate(HWND hwnd, bool fEnable = TRUE)
1540b39c5158Smillert
1541b39c5158Smillert bool
1542b39c5158Smillert SetWindowBits(HWND hwnd, long index, unsigned long flData, unsigned long flMask)
1543b39c5158Smillert
1544b39c5158Smillert bool
1545b39c5158Smillert SetWindowPtr(HWND hwnd, long index, unsigned long p)
1546b39c5158Smillert C_ARGS: hwnd, index, (PVOID)p
1547b39c5158Smillert
1548b39c5158Smillert bool
1549b39c5158Smillert SetWindowULong(HWND hwnd, long index, unsigned long i)
1550b39c5158Smillert
1551b39c5158Smillert bool
1552b39c5158Smillert SetWindowUShort(HWND hwnd, long index, unsigned short i)
1553b39c5158Smillert
1554b39c5158Smillert bool
1555b39c5158Smillert IsWindow(HWND hwnd, HAB hab = Acquire_hab())
1556b39c5158Smillert C_ARGS: hab, hwnd
1557b39c5158Smillert
1558b39c5158Smillert BOOL
1559b39c5158Smillert ActiveWindow_set(HWND hwnd, HWND hwndDesktop = HWND_DESKTOP)
1560b39c5158Smillert CODE:
1561b39c5158Smillert RETVAL = SetActiveWindow(hwndDesktop, hwnd);
1562b39c5158Smillert
1563b39c5158Smillert unsigned long
1564b39c5158Smillert LoadPointer(unsigned long idres, unsigned long hmod = 0, HWND hwndDesktop = HWND_DESKTOP)
1565b39c5158Smillert C_ARGS: hwndDesktop, hmod, idres
1566b39c5158Smillert
1567b39c5158Smillert int
1568b39c5158Smillert out_codepage()
1569b39c5158Smillert
1570b39c5158Smillert bool
1571b39c5158Smillert out_codepage_set(int cp)
1572b39c5158Smillert
1573b39c5158Smillert int
1574b39c5158Smillert in_codepage()
1575b39c5158Smillert
1576b39c5158Smillert bool
1577b39c5158Smillert in_codepage_set(int cp)
1578b39c5158Smillert
1579b39c5158Smillert SV *
1580b39c5158Smillert screen()
1581b39c5158Smillert
1582b39c5158Smillert bool
1583b39c5158Smillert screen_set(SV *sv)
1584b39c5158Smillert
1585b39c5158Smillert SV *
1586b39c5158Smillert process_codepages()
1587b39c5158Smillert PPCODE:
1588b39c5158Smillert {
1589b39c5158Smillert ULONG cps[4], c, i = 0, rc;
1590b39c5158Smillert
1591b39c5158Smillert if (CheckOSError(DosQueryCp( sizeof(cps), cps, &c )))
1592b39c5158Smillert c = 0;
1593b39c5158Smillert c /= sizeof(ULONG);
1594b39c5158Smillert if (c >= 3)
1595b39c5158Smillert EXTEND(sp, c);
1596b39c5158Smillert while (i < c)
1597b39c5158Smillert PUSHs(sv_2mortal(newSViv(cps[i++])));
1598b39c5158Smillert }
1599b39c5158Smillert
1600b39c5158Smillert bool
1601b39c5158Smillert process_codepage_set(int cp)
1602b39c5158Smillert
1603b39c5158Smillert void
1604b39c5158Smillert cursor(OUTLIST int stp, OUTLIST int ep, OUTLIST int wp, OUTLIST int ap)
1605b39c5158Smillert PROTOTYPE:
1606b39c5158Smillert
1607b39c5158Smillert bool
1608b39c5158Smillert cursor_set(int s, int e, int w = cursor__(0), int a = cursor__(1))
1609b39c5158Smillert
1610b39c5158Smillert SV*
1611b39c5158Smillert _kbdChar(int nowait = 0, int handle = 0)
1612b39c5158Smillert
1613b39c5158Smillert SV*
1614b39c5158Smillert _kbdStatus(int handle = 0)
1615b39c5158Smillert
1616b39c5158Smillert void
1617b39c5158Smillert _kbdStatus_set(SV *sv, int handle = 0)
1618b39c5158Smillert POSTCALL:
1619b39c5158Smillert XSRETURN_YES;
1620b39c5158Smillert
1621b39c5158Smillert SV*
1622b39c5158Smillert _vioConfig(int which = 0, int handle = 0)
1623b39c5158Smillert
1624b39c5158Smillert SV*
1625b39c5158Smillert _vioMode()
1626b39c5158Smillert
1627b39c5158Smillert void
1628b39c5158Smillert _vioMode_set(SV *buffer)
1629b39c5158Smillert POSTCALL:
1630b39c5158Smillert XSRETURN_YES;
1631b39c5158Smillert
1632b39c5158Smillert SV*
1633b39c5158Smillert _vioState(int what, int first = -1, int count = -1)
1634b39c5158Smillert
1635b39c5158Smillert void
1636b39c5158Smillert _vioState_set(SV *buffer)
1637b39c5158Smillert POSTCALL:
1638b39c5158Smillert XSRETURN_YES;
1639b39c5158Smillert
1640b39c5158Smillert SV*
1641b39c5158Smillert vioFont( int type = 0, OUTLIST int w, OUTLIST int h)
1642b39c5158Smillert
1643b39c5158Smillert void
1644b39c5158Smillert vioFont_set(SV *buffer, int cellwidth, int cellheight, int type = 0)
1645b39c5158Smillert POSTCALL:
1646b39c5158Smillert XSRETURN_YES;
1647b39c5158Smillert
1648b39c5158Smillert NO_OUTPUT bool
1649b39c5158Smillert _ClipbrdData_set(unsigned long ulData, unsigned long fmt = CF_TEXT, unsigned long rgfFmtInfo = default_fmtInfo(fmt), HAB hab = perl_hab_GET())
1650b39c5158Smillert PROTOTYPE: DISABLE
1651b39c5158Smillert C_ARGS: hab, ulData, fmt, rgfFmtInfo
1652b39c5158Smillert POSTCALL:
1653b39c5158Smillert if (CheckWinError(RETVAL))
1654b39c5158Smillert croak_with_os2error("_ClipbrdData_set() error");
1655b39c5158Smillert XSRETURN_YES;
1656b39c5158Smillert
1657b39c5158Smillert void
1658b39c5158Smillert ClipbrdData_set(SV *text, int convert_nl = 1, unsigned long fmt = CF_TEXT, unsigned long rgfFmtInfo = default_fmtInfo(fmt), HAB hab = perl_hab_GET())
1659b39c5158Smillert PROTOTYPE: DISABLE
1660b39c5158Smillert POSTCALL:
1661b39c5158Smillert XSRETURN_YES;
1662b39c5158Smillert
1663b39c5158Smillert void
1664b39c5158Smillert ClipbrdOwner_set(HWND hwnd, HAB hab = perl_hab_GET())
1665b39c5158Smillert C_ARGS: hab, hwnd
1666b39c5158Smillert POSTCALL:
1667b39c5158Smillert XSRETURN_YES;
1668b39c5158Smillert
1669b39c5158Smillert void
1670b39c5158Smillert ClipbrdViewer_set(HWND hwnd, HAB hab = perl_hab_GET())
1671b39c5158Smillert C_ARGS: hab, hwnd
1672b39c5158Smillert POSTCALL:
1673b39c5158Smillert XSRETURN_YES;
1674b39c5158Smillert
1675b39c5158Smillert unsigned long
1676b39c5158Smillert EnumClipbrdFmts(unsigned long fmt = 0, HAB hab = perl_hab_GET())
1677b39c5158Smillert C_ARGS: hab, fmt
1678b39c5158Smillert
1679b39c5158Smillert unsigned long
1680b39c5158Smillert AddAtom(char *pszAtomName, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1681b39c5158Smillert C_ARGS: hAtomTbl, pszAtomName
1682b39c5158Smillert
1683b39c5158Smillert unsigned long
1684b39c5158Smillert FindAtom(char *pszAtomName, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1685b39c5158Smillert C_ARGS: hAtomTbl, pszAtomName
1686b39c5158Smillert
1687b39c5158Smillert unsigned long
1688b39c5158Smillert _DeleteAtom(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1689b39c5158Smillert PROTOTYPE: DISABLE
1690b39c5158Smillert C_ARGS: hAtomTbl, atom
1691b39c5158Smillert
1692b39c5158Smillert #if 0
1693b39c5158Smillert
1694b39c5158Smillert unsigned long
1695b39c5158Smillert WinDeleteAtom(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1696b39c5158Smillert C_ARGS: hAtomTbl, atom
1697b39c5158Smillert
1698b39c5158Smillert #endif
1699b39c5158Smillert
1700b39c5158Smillert void
1701b39c5158Smillert Alarm(unsigned long rgfType = WA_ERROR, HWND hwndDesktop = HWND_DESKTOP)
1702b39c5158Smillert C_ARGS: hwndDesktop, rgfType
1703b39c5158Smillert POSTCALL:
1704b39c5158Smillert XSRETURN_YES;
1705b39c5158Smillert
1706b39c5158Smillert void
1707b39c5158Smillert FlashWindow(HWND hwndFrame, bool fFlash)
1708b39c5158Smillert POSTCALL:
1709b39c5158Smillert XSRETURN_YES;
1710b39c5158Smillert
1711b39c5158Smillert STRLEN
1712b39c5158Smillert StrLen(ULONG addr, ULONG lim, I32 unitsize = 1)
1713b39c5158Smillert
1714b39c5158Smillert MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myQuery
1715b39c5158Smillert
1716b39c5158Smillert SV *
1717b39c5158Smillert myQueryWindowText(HWND hwnd)
1718b39c5158Smillert
1719b39c5158Smillert SV *
1720b39c5158Smillert myQueryClassName(HWND hwnd)
1721b39c5158Smillert
1722b39c5158Smillert MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = Query
1723b39c5158Smillert
1724b39c5158Smillert unsigned long
1725b39c5158Smillert QueryFocusWindow(HWND hwndDesktop = HWND_DESKTOP)
1726b39c5158Smillert
1727b39c5158Smillert long
1728b39c5158Smillert QueryWindowTextLength(HWND hwnd)
1729b39c5158Smillert
1730b39c5158Smillert SV *
1731b39c5158Smillert QueryWindowSWP(HWND hwnd)
1732b39c5158Smillert
1733b39c5158Smillert unsigned long
1734b39c5158Smillert QueryWindowULong(HWND hwnd, long index)
1735b39c5158Smillert
1736b39c5158Smillert unsigned short
1737b39c5158Smillert QueryWindowUShort(HWND hwnd, long index)
1738b39c5158Smillert
1739b39c5158Smillert unsigned long
1740b39c5158Smillert QueryActiveWindow(HWND hwnd = HWND_DESKTOP)
1741b39c5158Smillert
1742b39c5158Smillert unsigned long
1743b39c5158Smillert QueryDesktopWindow(HAB hab = Acquire_hab(), unsigned long hdc = NULLHANDLE)
1744b39c5158Smillert
1745b39c5158Smillert unsigned long
1746b39c5158Smillert QueryClipbrdData(unsigned long fmt = CF_TEXT, HAB hab = perl_hab_GET())
1747b39c5158Smillert C_ARGS: hab, fmt
1748b39c5158Smillert PROTOTYPE: DISABLE
1749b39c5158Smillert
1750b39c5158Smillert ULONG
1751b39c5158Smillert QueryMemoryRegionSize(ULONG addr, OUTLIST ULONG flagp, ULONG len = 0xFFFFFFFF - addr, I32 interrupt = 1)
1752b39c5158Smillert
1753b39c5158Smillert unsigned long
1754b39c5158Smillert QueryClipbrdViewer(HAB hab = perl_hab_GET())
1755b39c5158Smillert
1756b39c5158Smillert unsigned long
1757b39c5158Smillert QueryClipbrdOwner(HAB hab = perl_hab_GET())
1758b39c5158Smillert
1759b39c5158Smillert void
1760b39c5158Smillert CloseClipbrd(HAB hab = perl_hab_GET())
1761b39c5158Smillert POSTCALL:
1762b39c5158Smillert XSRETURN_YES;
1763b39c5158Smillert
1764b39c5158Smillert void
1765b39c5158Smillert EmptyClipbrd(HAB hab = perl_hab_GET())
1766b39c5158Smillert POSTCALL:
1767b39c5158Smillert XSRETURN_YES;
1768b39c5158Smillert
1769b39c5158Smillert bool
1770b39c5158Smillert OpenClipbrd(HAB hab = perl_hab_GET())
1771b39c5158Smillert
1772b39c5158Smillert unsigned long
1773b39c5158Smillert QueryAtomUsage(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1774b39c5158Smillert C_ARGS: hAtomTbl, atom
1775b39c5158Smillert
1776b39c5158Smillert unsigned long
1777b39c5158Smillert QueryAtomLength(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1778b39c5158Smillert C_ARGS: hAtomTbl, atom
1779b39c5158Smillert POSTCALL:
1780b39c5158Smillert if (!RETVAL)
1781b39c5158Smillert XSRETURN_EMPTY;
1782b39c5158Smillert
1783b39c5158Smillert unsigned long
1784b39c5158Smillert QuerySystemAtomTable()
1785b39c5158Smillert
1786b39c5158Smillert unsigned long
1787b39c5158Smillert QuerySysPointer(long lId, bool fCopy = 1, HWND hwndDesktop = HWND_DESKTOP)
1788b39c5158Smillert C_ARGS: hwndDesktop, lId, fCopy
1789b39c5158Smillert
1790b39c5158Smillert unsigned long
1791b39c5158Smillert CreateAtomTable(unsigned long initial = 0, unsigned long buckets = 0)
1792b39c5158Smillert
1793b39c5158Smillert unsigned long
1794b39c5158Smillert _DestroyAtomTable(HATOMTBL hAtomTbl)
1795b39c5158Smillert PROTOTYPE: DISABLE
1796b39c5158Smillert
1797b39c5158Smillert
1798b39c5158Smillert MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myWinQuery
1799b39c5158Smillert
1800b39c5158Smillert unsigned long
1801b39c5158Smillert myWinQueryWindowPtr(HWND hwnd, long index)
1802b39c5158Smillert
1803b39c5158Smillert NO_OUTPUT BOOL
1804b39c5158Smillert myWinQueryWindowProcess(HWND hwnd, OUTLIST unsigned long pid, OUTLIST unsigned long tid)
1805b39c5158Smillert PROTOTYPE: $
1806b39c5158Smillert POSTCALL:
1807b39c5158Smillert if (CheckWinError(RETVAL))
1808b39c5158Smillert croak_with_os2error("WindowProcess() error");
1809b39c5158Smillert
1810b39c5158Smillert SV *
1811b39c5158Smillert myWinQueryActiveDesktopPathname()
1812b39c5158Smillert
1813b39c5158Smillert void
1814b39c5158Smillert myWinQueryClipbrdFmtInfo(OUTLIST unsigned long prgfFmtInfo, unsigned long fmt = CF_TEXT, HAB hab = perl_hab_GET())
1815b39c5158Smillert C_ARGS: hab, fmt, &prgfFmtInfo
1816b39c5158Smillert
1817b39c5158Smillert SV *
1818b39c5158Smillert myWinQueryAtomName(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1819b39c5158Smillert
1820b39c5158Smillert MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myWin
1821b39c5158Smillert
1822b39c5158Smillert int
1823b39c5158Smillert myWinSwitchToProgram(HSWITCH hsw = switch_of(NULLHANDLE, getpid()))
1824b39c5158Smillert PREINIT:
1825b39c5158Smillert ULONG rc;
1826b39c5158Smillert
1827b39c5158Smillert #if 0
1828b39c5158Smillert
1829b39c5158Smillert unsigned long
1830b39c5158Smillert myWinMessageBox(unsigned long pszText, char* pszCaption = "Perl script message", unsigned long flStyle = MB_CANCEL | MB_ICONHAND, HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = HWND_DESKTOP, unsigned long idWindow = 0)
1831b39c5158Smillert C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle
1832b39c5158Smillert
1833b39c5158Smillert #endif
1834b39c5158Smillert
1835b39c5158Smillert unsigned long
1836b39c5158Smillert _MessageBox(char* pszText, char* pszCaption = "Perl script message", unsigned long flStyle = MB_CANCEL | MB_INFORMATION | MB_MOVEABLE, HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = NULLHANDLE, unsigned long idWindow = 0)
1837b39c5158Smillert C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle
1838b39c5158Smillert POSTCALL:
1839b39c5158Smillert if (RETVAL == MBID_ERROR)
1840b39c5158Smillert RETVAL = 0;
1841b39c5158Smillert
1842b39c5158Smillert unsigned long
1843b39c5158Smillert _MessageBox2(char *pszText, char* pmb2info, char *pszCaption = "Perl script message", HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = NULLHANDLE, unsigned long idWindow = 0)
1844b39c5158Smillert C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, (PMB2INFO)pmb2info
1845b39c5158Smillert POSTCALL:
1846b39c5158Smillert if (RETVAL == MBID_ERROR)
1847b39c5158Smillert RETVAL = 0;
1848b39c5158Smillert
1849b39c5158Smillert MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myWinQuery
1850b39c5158Smillert
1851b39c5158Smillert MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = get
1852b39c5158Smillert
1853b39c5158Smillert int
1854b39c5158Smillert getppid()
1855b39c5158Smillert
1856b39c5158Smillert int
1857b39c5158Smillert ppidOf(int pid = getpid())
1858b39c5158Smillert
1859b39c5158Smillert int
1860b39c5158Smillert sidOf(int pid = getpid())
1861b39c5158Smillert
1862b39c5158Smillert void
1863b39c5158Smillert getscrsize(OUTLIST int wp, OUTLIST int hp)
1864b39c5158Smillert PROTOTYPE:
1865b39c5158Smillert
1866b39c5158Smillert bool
1867b39c5158Smillert scrsize_set(int w_or_h, int h = -9999)
1868b39c5158Smillert
1869b39c5158Smillert void
1870b39c5158Smillert get_InvalidateRect(HWND hwnd, char *prcl, bool fIncludeChildren)
1871b39c5158Smillert
1872b39c5158Smillert void
1873b39c5158Smillert get_CreateFrameControls(HWND hwndFrame, char *pfcdata, char* pszTitle)
1874b39c5158Smillert
1875b39c5158Smillert MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = ul
1876b39c5158Smillert
1877b39c5158Smillert unsigned long
1878b39c5158Smillert ulMPFROMSHORT(unsigned short i)
1879b39c5158Smillert
1880b39c5158Smillert unsigned long
1881b39c5158Smillert ulMPVOID()
1882b39c5158Smillert
1883b39c5158Smillert unsigned long
1884b39c5158Smillert ulMPFROMCHAR(unsigned char i)
1885b39c5158Smillert
1886b39c5158Smillert unsigned long
1887b39c5158Smillert ulMPFROM2SHORT(unsigned short x1, unsigned short x2)
1888b39c5158Smillert PROTOTYPE: DISABLE
1889b39c5158Smillert
1890b39c5158Smillert unsigned long
1891b39c5158Smillert ulMPFROMSH2CH(unsigned short s, unsigned char c1, unsigned char c2)
1892b39c5158Smillert PROTOTYPE: DISABLE
1893b39c5158Smillert
1894b39c5158Smillert unsigned long
1895b39c5158Smillert ulMPFROMLONG(unsigned long x)
1896b39c5158Smillert
1897