5 #define INCL_WINSWITCHLIST
6 #define INCL_WINWINDOWMGR
10 #define INCL_WINCLIPBOARD
19 constant(char *name, int arg)
22 if (name[0] == 'P' && name[1] == '_') {
23 if (strEQ(name, "P_BACKGROUND"))
29 if (strEQ(name, "P_DEBUG"))
35 if (strEQ(name, "P_DEFAULT"))
41 if (strEQ(name, "P_DETACH"))
47 if (strEQ(name, "P_FOREGROUND"))
53 if (strEQ(name, "P_FULLSCREEN"))
59 if (strEQ(name, "P_MAXIMIZE"))
65 if (strEQ(name, "P_MINIMIZE"))
71 if (strEQ(name, "P_NOCLOSE"))
77 if (strEQ(name, "P_NOSESSION"))
83 if (strEQ(name, "P_NOWAIT"))
89 if (strEQ(name, "P_OVERLAY"))
95 if (strEQ(name, "P_PM"))
101 if (strEQ(name, "P_QUOTE"))
107 if (strEQ(name, "P_SESSION"))
113 if (strEQ(name, "P_TILDE"))
119 if (strEQ(name, "P_UNRELATED"))
125 if (strEQ(name, "P_WAIT"))
131 if (strEQ(name, "P_WINDOWED"))
137 } else if (name[0] == 'T' && name[1] == '_') {
138 if (strEQ(name, "FAPPTYP_NOTSPEC"))
139 #ifdef FAPPTYP_NOTSPEC
140 return FAPPTYP_NOTSPEC;
144 if (strEQ(name, "T_NOTWINDOWCOMPAT"))
145 #ifdef FAPPTYP_NOTWINDOWCOMPAT
146 return FAPPTYP_NOTWINDOWCOMPAT;
150 if (strEQ(name, "T_WINDOWCOMPAT"))
151 #ifdef FAPPTYP_WINDOWCOMPAT
152 return FAPPTYP_WINDOWCOMPAT;
156 if (strEQ(name, "T_WINDOWAPI"))
157 #ifdef FAPPTYP_WINDOWAPI
158 return FAPPTYP_WINDOWAPI;
162 if (strEQ(name, "T_BOUND"))
164 return FAPPTYP_BOUND;
168 if (strEQ(name, "T_DLL"))
174 if (strEQ(name, "T_DOS"))
180 if (strEQ(name, "T_PHYSDRV"))
181 #ifdef FAPPTYP_PHYSDRV
182 return FAPPTYP_PHYSDRV;
186 if (strEQ(name, "T_VIRTDRV"))
187 #ifdef FAPPTYP_VIRTDRV
188 return FAPPTYP_VIRTDRV;
192 if (strEQ(name, "T_PROTDLL"))
193 #ifdef FAPPTYP_PROTDLL
194 return FAPPTYP_PROTDLL;
198 if (strEQ(name, "T_32BIT"))
200 return FAPPTYP_32BIT;
214 const char* const ptypes[] = { "FS", "DOS", "VIO", "PM", "DETACH" };
223 if (!(_emx_env & 0x200)) return (char*)ptypes[1]; /* not OS/2. */
224 if (CheckOSError(DosGetInfoBlocks(&tib, &pib)))
227 return (pib->pib_ultype <= 4 ? (char*)ptypes[pib->pib_ultype] : "UNKNOWN");
231 file_type(char *path)
236 if (!(_emx_env & 0x200))
237 croak("file_type not implemented on DOS"); /* not OS/2. */
238 if (CheckOSError(DosQueryAppType(path, &apptype))) {
240 if (rc == ERROR_INVALID_EXE_SIGNATURE)
241 croak("Invalid EXE signature");
242 else if (rc == ERROR_EXE_MARKED_INVALID) {
243 croak("EXE marked invalid");
246 croak_with_os2error("DosQueryAppType");
252 /* These use different type of wrapper. Good to check wrappers. ;-) */
253 /* XXXX This assumes DOS type return type, without SEVERITY?! */
254 DeclFuncByORD(HSWITCH, myWinQuerySwitchHandle, ORD_WinQuerySwitchHandle,
255 (HWND hwnd, PID pid), (hwnd, pid))
256 DeclFuncByORD(ULONG, myWinQuerySwitchEntry, ORD_WinQuerySwitchEntry,
257 (HSWITCH hsw, PSWCNTRL pswctl), (hsw, pswctl))
258 DeclFuncByORD(ULONG, myWinSetWindowText, ORD_WinSetWindowText,
259 (HWND hwnd, char* text), (hwnd, text))
260 DeclFuncByORD(BOOL, myWinQueryWindowProcess, ORD_WinQueryWindowProcess,
261 (HWND hwnd, PPID ppid, PTID ptid), (hwnd, ppid, ptid))
262 DeclFuncByORD(ULONG, XmyWinSwitchToProgram, ORD_WinSwitchToProgram,
263 (HSWITCH hsw), (hsw))
264 #define myWinSwitchToProgram(hsw) (!CheckOSError(XmyWinSwitchToProgram(hsw)))
267 /* These function croak if the return value is 0. */
268 DeclWinFunc_CACHE(HWND, QueryWindow, (HWND hwnd, LONG cmd), (hwnd, cmd))
269 DeclWinFunc_CACHE(BOOL, QueryWindowPos, (HWND hwnd, PSWP pswp),
271 DeclWinFunc_CACHE(LONG, QueryWindowText,
272 (HWND hwnd, LONG cchBufferMax, PCH pchBuffer),
273 (hwnd, cchBufferMax, pchBuffer))
274 DeclWinFunc_CACHE(LONG, QueryClassName, (HWND hwnd, LONG cchMax, PCH pch),
276 DeclWinFunc_CACHE(HWND, QueryFocus, (HWND hwndDesktop), (hwndDesktop))
277 DeclWinFunc_CACHE(BOOL, SetFocus, (HWND hwndDesktop, HWND hwndFocus),
278 (hwndDesktop, hwndFocus))
279 DeclWinFunc_CACHE(BOOL, ShowWindow, (HWND hwnd, BOOL fShow), (hwnd, fShow))
280 DeclWinFunc_CACHE(BOOL, EnableWindow, (HWND hwnd, BOOL fEnable),
282 DeclWinFunc_CACHE(BOOL, SetWindowPos,
283 (HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y,
284 LONG cx, LONG cy, ULONG fl),
285 (hwnd, hwndInsertBehind, x, y, cx, cy, fl))
286 DeclWinFunc_CACHE(HENUM, BeginEnumWindows, (HWND hwnd), (hwnd))
287 DeclWinFunc_CACHE(BOOL, EndEnumWindows, (HENUM henum), (henum))
288 DeclWinFunc_CACHE(BOOL, EnableWindowUpdate, (HWND hwnd, BOOL fEnable),
290 DeclWinFunc_CACHE(BOOL, SetWindowBits,
291 (HWND hwnd, LONG index, ULONG flData, ULONG flMask),
292 (hwnd, index, flData, flMask))
293 DeclWinFunc_CACHE(BOOL, SetWindowPtr, (HWND hwnd, LONG index, PVOID p),
295 DeclWinFunc_CACHE(BOOL, SetWindowULong, (HWND hwnd, LONG index, ULONG ul),
297 DeclWinFunc_CACHE(BOOL, SetWindowUShort, (HWND hwnd, LONG index, USHORT us),
299 DeclWinFunc_CACHE(HWND, IsChild, (HWND hwnd, HWND hwndParent),
301 DeclWinFunc_CACHE(HWND, WindowFromId, (HWND hwnd, ULONG id), (hwnd, id))
302 DeclWinFunc_CACHE(HWND, EnumDlgItem, (HWND hwndDlg, HWND hwnd, ULONG code),
303 (hwndDlg, hwnd, code))
304 DeclWinFunc_CACHE(HWND, QueryDesktopWindow, (HAB hab, HDC hdc), (hab, hdc));
305 DeclWinFunc_CACHE(BOOL, SetActiveWindow, (HWND hwndDesktop, HWND hwnd),
306 (hwndDesktop, hwnd));
307 DeclWinFunc_CACHE(BOOL, QueryActiveDesktopPathname, (PSZ pszPathName, ULONG ulSize),
308 (pszPathName, ulSize));
309 DeclWinFunc_CACHE(BOOL, InvalidateRect,
310 (HWND hwnd, /*RECTL*/ char *prcl, BOOL fIncludeChildren),
311 (hwnd, prcl, fIncludeChildren));
312 DeclWinFunc_CACHE(BOOL, CreateFrameControls,
313 (HWND hwndFrame, /*PFRAMECDATA*/ char* pfcdata, PCSZ pszTitle),
314 (hwndFrame, pfcdata, pszTitle));
315 DeclWinFunc_CACHE(BOOL, OpenClipbrd, (HAB hab), (hab));
316 DeclWinFunc_CACHE(BOOL, EmptyClipbrd, (HAB hab), (hab));
317 DeclWinFunc_CACHE(BOOL, CloseClipbrd, (HAB hab), (hab));
318 DeclWinFunc_CACHE(HWND, QueryClipbrdViewer, (HAB hab), (hab));
319 DeclWinFunc_CACHE(HWND, QueryClipbrdOwner, (HAB hab), (hab));
320 DeclWinFunc_CACHE(BOOL, QueryClipbrdFmtInfo, (HAB hab, ULONG fmt, PULONG prgfFmtInfo), (hab, fmt, prgfFmtInfo));
321 DeclWinFunc_CACHE(ULONG, QueryClipbrdData, (HAB hab, ULONG fmt), (hab, fmt));
322 DeclWinFunc_CACHE(HWND, SetClipbrdViewer, (HAB hab, HWND hwnd), (hab, hwnd));
323 DeclWinFunc_CACHE(HWND, SetClipbrdOwner, (HAB hab, HWND hwnd), (hab, hwnd));
324 DeclWinFunc_CACHE(ULONG, EnumClipbrdFmts, (HAB hab, ULONG fmt), (hab, fmt));
325 DeclWinFunc_CACHE(ATOM, AddAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
326 (hAtomTbl, pszAtomName));
327 DeclWinFunc_CACHE(ATOM, FindAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
328 (hAtomTbl, pszAtomName));
329 DeclWinFunc_CACHE(ATOM, DeleteAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
330 (hAtomTbl, pszAtomName));
331 DeclWinFunc_CACHE(ULONG, QueryAtomUsage, (HATOMTBL hAtomTbl, ATOM atom),
333 DeclWinFunc_CACHE(ULONG, QueryAtomLength, (HATOMTBL hAtomTbl, ATOM atom),
335 DeclWinFunc_CACHE(ULONG, QueryAtomName,
336 (HATOMTBL hAtomTbl, ATOM atom, PSZ pchBuffer, ULONG cchBufferMax),
337 (hAtomTbl, atom, pchBuffer, cchBufferMax));
338 DeclWinFunc_CACHE(HATOMTBL, QuerySystemAtomTable, (VOID), ());
339 DeclWinFunc_CACHE(HATOMTBL, CreateAtomTable, (ULONG initial, ULONG buckets),
341 DeclWinFunc_CACHE(HATOMTBL, DestroyAtomTable, (HATOMTBL hAtomTbl), (hAtomTbl));
342 DeclWinFunc_CACHE(ULONG, MessageBox, (HWND hwndParent, HWND hwndOwner, PCSZ pszText, PCSZ pszCaption, ULONG idWindow, ULONG flStyle), (hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle));
343 DeclWinFunc_CACHE(ULONG, MessageBox2,
344 (HWND hwndParent, HWND hwndOwner, PCSZ pszText,
345 PCSZ pszCaption, ULONG idWindow, PMB2INFO pmb2info),
346 (hwndParent, hwndOwner, pszText, pszCaption, idWindow, pmb2info));
347 DeclWinFunc_CACHE(HPOINTER, LoadPointer,
348 (HWND hwndDesktop, HMODULE hmod, ULONG idres),
349 (hwndDesktop, hmod, idres));
350 DeclWinFunc_CACHE(HPOINTER, QuerySysPointer,
351 (HWND hwndDesktop, LONG lId, BOOL fCopy),
352 (hwndDesktop, lId, fCopy));
353 DeclWinFunc_CACHE(BOOL, Alarm, (HWND hwndDesktop, ULONG rgfType), (hwndDesktop, rgfType));
354 DeclWinFunc_CACHE(BOOL, FlashWindow, (HWND hwndFrame, BOOL fFlash), (hwndFrame, fFlash));
357 /* These functions do not croak on error */
358 DeclWinFunc_CACHE_survive(BOOL, SetClipbrdData,
359 (HAB hab, ULONG ulData, ULONG fmt, ULONG rgfFmtInfo),
360 (hab, ulData, fmt, rgfFmtInfo));
362 #define get_InvalidateRect InvalidateRect
363 #define get_CreateFrameControls CreateFrameControls
365 /* These functions may return 0 on success; check $^E/Perl_rc on res==0: */
366 DeclWinFunc_CACHE_resetError(PVOID, QueryWindowPtr, (HWND hwnd, LONG index),
368 DeclWinFunc_CACHE_resetError(ULONG, QueryWindowULong, (HWND hwnd, LONG index),
370 DeclWinFunc_CACHE_resetError(SHORT, QueryWindowUShort, (HWND hwnd, LONG index),
372 DeclWinFunc_CACHE_resetError(LONG, QueryWindowTextLength, (HWND hwnd), (hwnd))
373 DeclWinFunc_CACHE_resetError(HWND, QueryActiveWindow, (HWND hwnd), (hwnd))
374 DeclWinFunc_CACHE_resetError(BOOL, PostMsg,
375 (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2),
376 (hwnd, msg, mp1, mp2))
377 DeclWinFunc_CACHE_resetError(HWND, GetNextWindow, (HENUM henum), (henum))
378 DeclWinFunc_CACHE_resetError(BOOL, IsWindowEnabled, (HWND hwnd), (hwnd))
379 DeclWinFunc_CACHE_resetError(BOOL, IsWindowVisible, (HWND hwnd), (hwnd))
380 DeclWinFunc_CACHE_resetError(BOOL, IsWindowShowing, (HWND hwnd), (hwnd))
382 /* No die()ing on error */
383 DeclWinFunc_CACHE_survive(BOOL, IsWindow, (HAB hab, HWND hwnd), (hab, hwnd))
385 /* These functions are called frow complicated wrappers: */
386 ULONG (*pWinQuerySwitchList) (HAB hab, PSWBLOCK pswblk, ULONG usDataLength);
387 ULONG (*pWinChangeSwitchEntry) (HSWITCH hsw, __const__ SWCNTRL *pswctl);
388 HWND (*pWinWindowFromPoint)(HWND hwnd, __const__ POINTL *pptl, BOOL fChildren);
391 /* These functions have different names/signatures than what is
393 #define QueryFocusWindow QueryFocus
394 #define FocusWindow_set(hwndFocus, hwndDesktop) SetFocus(hwndDesktop, hwndFocus)
395 #define WindowPos_set(hwnd, x, y, fl, cx, cy, hwndInsertBehind) \
396 SetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl)
397 #define myWinQueryWindowPtr(hwnd, i) ((ULONG)QueryWindowPtr(hwnd, i))
398 #define _ClipbrdData_set SetClipbrdData
399 #define ClipbrdOwner_set SetClipbrdOwner
400 #define ClipbrdViewer_set SetClipbrdViewer
403 WindowText_set(HWND hwnd, char* text)
405 return !CheckWinError(myWinSetWindowText(hwnd, text));
409 myQueryWindowText(HWND hwnd)
411 LONG l = QueryWindowTextLength(hwnd), len;
416 if (Perl_rc) /* Last error */
420 sv = newSVpvn("", 0);
422 len = QueryWindowText(hwnd, l + 1, SvPV_force(sv, n_a));
425 croak("WinQueryWindowText() uncompatible with WinQueryWindowTextLength()");
432 QueryWindowSWP_(HWND hwnd)
436 if (!QueryWindowPos(hwnd, &swp))
437 croak("WinQueryWindowPos() error");
442 QueryWindowSWP(HWND hwnd)
444 SWP swp = QueryWindowSWP_(hwnd);
446 return newSVpvn((char*)&swp, sizeof(swp));
450 myQueryClassName(HWND hwnd)
452 SV *sv = newSVpvn("",0);
453 STRLEN l = 46, len = 0, n_a;
455 while (l + 1 >= len) {
457 len = 2*len + 10; /* Grow quick */
461 l = QueryClassName(hwnd, len, SvPV_force(sv, n_a));
468 WindowFromPoint(long x, long y, HWND hwnd, BOOL fChildren)
472 ppl.x = x; ppl.y = y;
473 if (!pWinWindowFromPoint)
474 AssignFuncPByORD(pWinWindowFromPoint, ORD_WinWindowFromPoint);
475 return SaveWinError(pWinWindowFromPoint(hwnd, &ppl, fChildren));
479 switch_of(HWND hwnd, PID pid)
483 if (!(_emx_env & 0x200))
484 croak("switch_entry not implemented on DOS"); /* not OS/2. */
485 if (CheckWinError(hSwitch =
486 myWinQuerySwitchHandle(hwnd, pid)))
487 croak_with_os2error("WinQuerySwitchHandle");
493 fill_swentry(SWENTRY *swentryp, HWND hwnd, PID pid)
496 HSWITCH hSwitch = switch_of(hwnd, pid);
498 swentryp->hswitch = hSwitch;
499 if (CheckOSError(myWinQuerySwitchEntry(hSwitch, &swentryp->swctl)))
500 croak_with_os2error("WinQuerySwitchEntry");
504 fill_swentry_default(SWENTRY *swentryp)
506 fill_swentry(swentryp, NULLHANDLE, getpid());
510 myWinQueryActiveDesktopPathname()
512 SV *buf = newSVpv("",0);
515 SvGROW(buf, MAXPATHLEN);
516 QueryActiveDesktopPathname(SvPV(buf,n_a), MAXPATHLEN);
517 SvCUR_set(buf, strlen(SvPV(buf, n_a)));
522 myWinQueryAtomName(ATOM atom, HATOMTBL hAtomTbl)
524 ULONG len = QueryAtomLength(hAtomTbl, atom);
525 SV *sv = newSVpvn("",0);
529 QueryAtomName(hAtomTbl, atom, SvPV(sv, n_a), len);
535 #define myWinQueryClipbrdFmtInfo QueryClipbrdFmtInfo
537 /* Put data into shared memory, then call SetClipbrdData */
539 ClipbrdData_set(SV *sv, int convert_nl, unsigned long fmt, unsigned long rgfFmtInfo, HAB hab)
542 char *buf = SvPV_force(sv, len);
543 char *pByte = 0, *s = buf, c;
548 if (c == '\r' && *s == '\n')
555 if (CheckOSError(DosAllocSharedMem((PPVOID)&pByte, 0, len + nls + 1,
556 PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE | OBJ_GETTABLE)))
557 croak_with_os2error("ClipbrdData_set: DosAllocSharedMem error");
560 memcpy(pByte, buf, len + 1);
562 char *t = pByte, *e = buf + len;
566 if (c == '\n' && (t == pByte + 1 || t[-2] != '\r'))
567 t[-1] = '\r', *t++ = '\n';
571 if (!SetClipbrdData(hab, (ULONG)pByte, fmt, rgfFmtInfo)) {
572 DosFreeMem((PPVOID)&pByte);
573 croak_with_os2error("ClipbrdData_set: WinSetClipbrdData error");
580 myWinMessageBox(HWND hwndParent, HWND hwndOwner, PCSZ pszText, PCSZ pszCaption, ULONG idWindow, ULONG flStyle)
582 ULONG rc = MessageBox(hwndParent, hwndOwner, pszText, pszCaption,
585 if (rc == MBID_ERROR)
587 if (CheckWinError(rc))
588 croak_with_os2error("MessageBox");
593 myWinMessageBox2(HWND hwndParent, HWND hwndOwner, PCSZ pszText,
594 PCSZ pszCaption, ULONG idWindow, PMB2INFO pmb2info)
596 ULONG rc = MessageBox2(hwndParent, hwndOwner, pszText, pszCaption, idWindow, pmb2info);
598 if (rc == MBID_ERROR)
600 if (CheckWinError(rc))
601 croak_with_os2error("MessageBox2");
606 /* static ULONG (* APIENTRY16 pDosSmSetTitle)(ULONG, PSZ); */
607 ULONG _THUNK_FUNCTION(DosSmSetTitle)(ULONG, PSZ);
609 #if 0 /* Does not work. */
610 static ULONG (*pDosSmSetTitle)(ULONG, PSZ);
613 sesmgr_title_set(char *s)
616 static HMODULE hdosc = 0;
620 fill_swentry_default(&swentry);
621 if (!pDosSmSetTitle || !hdosc) {
622 if (CheckOSError(DosLoadModule(buf, sizeof buf, "sesmgr", &hdosc)))
623 croak("Cannot load SESMGR: no `%s'", buf);
624 if (CheckOSError(DosQueryProcAddr(hdosc, 0, "DOSSMSETTITLE",
625 (PFN*)&pDosSmSetTitle)))
626 croak("Cannot load SESMGR.DOSSMSETTITLE, err=%ld", rc);
628 /* (pDosSmSetTitle)(swcntrl.idSession,s); */
630 (_THUNK_PROLOG (2+4);
631 _THUNK_SHORT (swcntrl.idSession);
633 _THUNK_CALLI (*pDosSmSetTitle)));
634 if (CheckOSError(rc))
635 warn("*DOSSMSETTITLE: err=%ld, ses=%ld, addr=%x, *paddr=%x",
636 rc, swcntrl.idSession, &_THUNK_FUNCTION(DosSmSetTitle),
643 sesmgr_title_set(char *s)
648 fill_swentry_default(&swentry);
650 (_THUNK_PROLOG (2+4);
651 _THUNK_SHORT (swentry.swctl.idSession);
653 _THUNK_CALL (DosSmSetTitle)));
655 if (CheckOSError(rc))
656 warn("DOSSMSETTITLE: err=%ld, ses=%ld, addr=%x",
657 rc, swcntrl.idSession, _THUNK_FUNCTION(DosSmSetTitle));
659 return !CheckOSError(rc);
663 #if 0 /* Does not work. */
664 USHORT _THUNK_FUNCTION(Win16SetTitle) ();
674 _THUNK_CALL (Win16SetTitle)));
675 if (CheckWinError(rc))
676 warn("Win16SetTitle: err=%ld", rc);
681 process_swentry(unsigned long pid, HWND hwnd)
685 if (!(_emx_env & 0x200))
686 croak("process_swentry not implemented on DOS"); /* not OS/2. */
687 fill_swentry(&swentry, hwnd, pid);
688 return newSVpvn((char*)&swentry, sizeof(swentry));
697 SV *sv = newSVpvn("",0);
699 if (!(_emx_env & 0x200))
700 croak("swentries_list not implemented on DOS"); /* not OS/2. */
701 if (!pWinQuerySwitchList)
702 AssignFuncPByORD(pWinQuerySwitchList, ORD_WinQuerySwitchList);
703 num = pWinQuerySwitchList(0, NULL, 0); /* HAB is not required */
705 croak("(Unknown) error during WinQuerySwitchList()");
706 /* Allow one extra entry to allow overflow detection (may happen
707 if the list has been changed). */
712 n = 2*num + 10; /* Enlarge quickly */
713 SvGROW(sv, sizeof(ULONG) + sizeof(SWENTRY) * n + 1);
714 pswblk = (PSWBLOCK) SvPV_force(sv, n_a);
715 num = pWinQuerySwitchList(0, pswblk, SvLEN(sv));
717 SvCUR_set(sv, sizeof(ULONG) + sizeof(SWENTRY) * num);
723 swentry( char *title, HWND sw_hwnd, HWND icon_hwnd, HPROGRAM owner_phandle,
724 PID owner_pid, ULONG owner_sid, ULONG visible, ULONG nonswitchable,
725 ULONG jumpable, ULONG ptype, HSWITCH sw_entry)
729 strncpy(e.swctl.szSwtitle, title, MAXNAMEL);
730 e.swctl.szSwtitle[60] = 0;
731 e.swctl.hwnd = sw_hwnd;
732 e.swctl.hwndIcon = icon_hwnd;
733 e.swctl.hprog = owner_phandle;
734 e.swctl.idProcess = owner_pid;
735 e.swctl.idSession = owner_sid;
736 e.swctl.uchVisibility = ((visible ? SWL_VISIBLE : SWL_INVISIBLE)
737 | (nonswitchable ? SWL_GRAYED : 0));
738 e.swctl.fbJump = (jumpable ? SWL_JUMPABLE : 0);
739 e.swctl.bProgType = ptype;
740 e.hswitch = sw_entry;
745 create_swentry( char *title, HWND owner_hwnd, HWND icon_hwnd, HPROGRAM owner_phandle,
746 PID owner_pid, ULONG owner_sid, ULONG visible, ULONG nonswitchable,
747 ULONG jumpable, ULONG ptype, HSWITCH sw_entry)
749 SWENTRY e = swentry(title, owner_hwnd, icon_hwnd, owner_phandle, owner_pid,
750 owner_sid, visible, nonswitchable, jumpable, ptype,
753 return newSVpvn((char*)&e, sizeof(e));
757 change_swentrysw(SWENTRY *sw)
759 ULONG rc; /* For CheckOSError */
761 if (!(_emx_env & 0x200))
762 croak("change_entry() not implemented on DOS"); /* not OS/2. */
763 if (!pWinChangeSwitchEntry)
764 AssignFuncPByORD(pWinChangeSwitchEntry, ORD_WinChangeSwitchEntry);
765 return !CheckOSError(pWinChangeSwitchEntry(sw->hswitch, &sw->swctl));
769 change_swentry(SV *sv)
772 PSWENTRY pswentry = (PSWENTRY)SvPV(sv, l);
774 if (l != sizeof(SWENTRY))
775 croak("Wrong structure size %ld!=%ld in change_swentry()", (long)l, (long)sizeof(SWENTRY));
776 return change_swentrysw(pswentry);
780 #define swentry_size() (sizeof(SWENTRY))
783 getscrsize(int *wp, int *hp)
792 /* Force vio to not cross 64K-boundary: */
793 #define VIO_FROM_VIOB \
795 if (!_THUNK_PTR_STRUCT_OK(vio)) \
799 scrsize_set(int w, int h)
801 VIOMODEINFO viob[2], *vio;
808 vio->cb = sizeof(*vio);
809 if (CheckOSError(VioGetMode( vio, 0 )))
813 vio->col = (USHORT)w;
816 vio->row = (USHORT)h;
819 if (CheckOSError(VioSetMode( vio, 0 )))
825 cursor(int *sp, int *ep, int *wp, int *ap)
827 VIOCURSORINFO viob[2], *vio;
832 if (CheckOSError(VioGetCurType( vio, 0 )))
833 croak_with_os2error("VioGetCurType() error");
846 cursor(&s, &e, &w, &a);
854 cursor_set(int s, int e, int w, int a)
856 VIOCURSORINFO viob[2], *vio;
865 return !CheckOSError(VioSetCurType( vio, 0 ));
872 VIOMODEINFO viob[2], *vio;
877 vio->cb = sizeof(*vio);
878 if (CheckOSError(VioGetMode( vio, 0 )))
879 croak_with_os2error("Can't get size of buffer for screen");
880 #if 0 /* buf=323552247, full=1118455, partial=0 */
881 croak("Lengths: buf=%d, full=%d, partial=%d",vio->buf_length,vio->full_length,vio->partial_length);
882 return newSVpvn((char*)vio->buf_addr, vio->full_length);
884 return vio->col * vio->row * 2; /* How to get bytes/cell? 2 or 4? */
897 USHORT bufl = bufsize();
898 char b[(1<<16) * 3]; /* This/3 is enough for 16-bit calls, we need
899 2x overhead due to 2 vs 4 issue, and extra
900 64K due to alignment logic */
903 if (((ULONG)buf) & 0xFFFF)
904 buf += 0x10000 - (((ULONG)buf) & 0xFFFF);
905 if ((sizeof(b) - (buf - b)) < 2*bufl)
906 croak("panic: VIO buffer allocation");
907 if (CheckOSError(VioReadCellStr( buf, &bufl, 0, 0, 0 )))
909 return newSVpvn(buf,bufl);
916 STRLEN l = SvCUR(sv), bufl = bufsize();
917 char b[(1<<16) * 2]; /* This/2 is enough for 16-bit calls, we need
918 extra 64K due to alignment logic */
921 if (((ULONG)buf) & 0xFFFF)
922 buf += 0x10000 - (((ULONG)buf) & 0xFFFF);
923 if (!SvPOK(sv) || ((l != bufl) && (l != 2*bufl)))
924 croak("Wrong size %d of saved screen data", SvCUR(sv));
925 if ((sizeof(b) - (buf - b)) < l)
926 croak("panic: VIO buffer allocation");
927 Copy(SvPV(sv,l), buf, bufl, char);
928 if (CheckOSError(VioWrtCellStr( buf, bufl, 0, 0, 0 )))
936 ULONG cps[4], cp, rc;
938 if (CheckOSError(DosQueryCp( sizeof(cps), cps, &cp )))
939 croak_with_os2error("DosQueryCp()");
948 if (CheckOSError(VioGetCp( 0, &cp, 0 )))
949 croak_with_os2error("VioGetCp()");
954 out_codepage_set(int cp)
958 return !(CheckOSError(VioSetCp( 0, cp, 0 )));
966 if (CheckOSError(KbdGetCp( 0, &cp, 0 )))
967 croak_with_os2error("KbdGetCp()");
972 in_codepage_set(int cp)
976 return !(CheckOSError(KbdSetCp( 0, cp, 0 )));
980 process_codepage_set(int cp)
984 return !(CheckOSError(DosSetProcessCp( cp )));
995 psi = get_sysinfo(pid, QSS_PROCESS);
998 ppid = psi->procdata->ppid;
1011 psi = get_sysinfo(pid, QSS_PROCESS);
1014 sid = psi->procdata->sessid;
1019 #define ulMPFROMSHORT(i) ((unsigned long)MPFROMSHORT(i))
1020 #define ulMPVOID() ((unsigned long)MPVOID)
1021 #define ulMPFROMCHAR(i) ((unsigned long)MPFROMCHAR(i))
1022 #define ulMPFROM2SHORT(x1,x2) ((unsigned long)MPFROM2SHORT(x1,x2))
1023 #define ulMPFROMSH2CH(s, c1, c2) ((unsigned long)MPFROMSH2CH(s, c1, c2))
1024 #define ulMPFROMLONG(x) ((unsigned long)MPFROMLONG(x))
1026 #define _MessageBox MessageBox
1027 #define _MessageBox2 MessageBox2
1029 MODULE = OS2::Process PACKAGE = OS2::Process
1046 swentry_expand( SV *sv )
1050 PSWENTRY pswentry = (PSWENTRY)SvPV(sv, l);
1052 if (l != sizeof(SWENTRY))
1053 croak("Wrong structure size %ld!=%ld in swentry_expand()", (long)l, (long)sizeof(SWENTRY));
1055 PUSHs(sv_2mortal(newSVpv(pswentry->swctl.szSwtitle, 0)));
1056 PUSHs(sv_2mortal(newSVnv(pswentry->swctl.hwnd)));
1057 PUSHs(sv_2mortal(newSVnv(pswentry->swctl.hwndIcon)));
1058 PUSHs(sv_2mortal(newSViv(pswentry->swctl.hprog)));
1059 PUSHs(sv_2mortal(newSViv(pswentry->swctl.idProcess)));
1060 PUSHs(sv_2mortal(newSViv(pswentry->swctl.idSession)));
1061 PUSHs(sv_2mortal(newSViv(pswentry->swctl.uchVisibility & SWL_VISIBLE)));
1062 PUSHs(sv_2mortal(newSViv(pswentry->swctl.uchVisibility & SWL_GRAYED)));
1063 PUSHs(sv_2mortal(newSViv(pswentry->swctl.fbJump == SWL_JUMPABLE)));
1064 PUSHs(sv_2mortal(newSViv(pswentry->swctl.bProgType)));
1065 PUSHs(sv_2mortal(newSViv(pswentry->hswitch)));
1069 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)
1073 change_swentry( SV *sv )
1080 process_swentry(unsigned long pid = getpid(), HWND hwnd = NULLHANDLE);
1093 WindowText_set(HWND hwndFrame, char *title)
1096 FocusWindow_set(HWND hwndFocus, HWND hwndDesktop = HWND_DESKTOP)
1099 ShowWindow(HWND hwnd, bool fShow = TRUE)
1102 EnableWindow(HWND hwnd, bool fEnable = TRUE)
1105 PostMsg(HWND hwnd, unsigned long msg, unsigned long mp1 = 0, unsigned long mp2 = 0)
1106 C_ARGS: hwnd, msg, (MPARAM)mp1, (MPARAM)mp2
1109 WindowPos_set(HWND hwnd, long x, long y, unsigned long fl = SWP_MOVE, long cx = 0, long cy = 0, HWND hwndInsertBehind = HWND_TOP)
1113 BeginEnumWindows(HWND hwnd)
1116 EndEnumWindows(unsigned long henum)
1119 GetNextWindow(unsigned long henum)
1122 IsWindowVisible(HWND hwnd)
1125 IsWindowEnabled(HWND hwnd)
1128 IsWindowShowing(HWND hwnd)
1131 QueryWindow(HWND hwnd, long cmd)
1134 IsChild(HWND hwnd, HWND hwndParent)
1137 WindowFromId(HWND hwndParent, unsigned long id)
1140 WindowFromPoint(long x, long y, HWND hwnd = HWND_DESKTOP, bool fChildren = TRUE)
1144 EnumDlgItem(HWND hwndDlg, unsigned long code, HWND hwnd = NULLHANDLE)
1145 C_ARGS: hwndDlg, hwnd, code
1148 EnableWindowUpdate(HWND hwnd, bool fEnable = TRUE)
1151 SetWindowBits(HWND hwnd, long index, unsigned long flData, unsigned long flMask)
1154 SetWindowPtr(HWND hwnd, long index, unsigned long p)
1155 C_ARGS: hwnd, index, (PVOID)p
1158 SetWindowULong(HWND hwnd, long index, unsigned long i)
1161 SetWindowUShort(HWND hwnd, long index, unsigned short i)
1164 IsWindow(HWND hwnd, HAB hab = Acquire_hab())
1168 ActiveWindow_set(HWND hwnd, HWND hwndDesktop = HWND_DESKTOP)
1170 RETVAL = SetActiveWindow(hwndDesktop, hwnd);
1173 LoadPointer(unsigned long idres, unsigned long hmod = 0, HWND hwndDesktop = HWND_DESKTOP)
1174 C_ARGS: hwndDesktop, hmod, idres
1180 out_codepage_set(int cp)
1186 in_codepage_set(int cp)
1198 ULONG cps[4], c, i = 0, rc;
1200 if (CheckOSError(DosQueryCp( sizeof(cps), cps, &c )))
1206 PUSHs(sv_2mortal(newSViv(cps[i++])));
1210 process_codepage_set(int cp)
1213 cursor(OUTLIST int stp, OUTLIST int ep, OUTLIST int wp, OUTLIST int ap)
1217 cursor_set(int s, int e, int w = cursor__(0), int a = cursor__(1))
1220 _ClipbrdData_set(unsigned long ulData, unsigned long fmt = CF_TEXT, unsigned long rgfFmtInfo = ((fmt == CF_TEXT || fmt == CF_DSPTEXT) ? CFI_POINTER : CFI_HANDLE), HAB hab = perl_hab_GET())
1222 C_ARGS: hab, ulData, fmt, rgfFmtInfo
1224 if (CheckWinError(RETVAL))
1225 croak_with_os2error("_ClipbrdData_set() error");
1228 ClipbrdData_set(SV *text, int convert_nl = 1, unsigned long fmt = CF_TEXT, unsigned long rgfFmtInfo = ((fmt == CF_TEXT || fmt == CF_DSPTEXT) ? CFI_POINTER : CFI_HANDLE), HAB hab = perl_hab_GET())
1232 ClipbrdOwner_set(HWND hwnd, HAB hab = perl_hab_GET())
1236 ClipbrdViewer_set(HWND hwnd, HAB hab = perl_hab_GET())
1240 EnumClipbrdFmts(unsigned long fmt = 0, HAB hab = perl_hab_GET())
1244 AddAtom(char *pszAtomName, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1245 C_ARGS: hAtomTbl, pszAtomName
1248 FindAtom(char *pszAtomName, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1249 C_ARGS: hAtomTbl, pszAtomName
1252 DeleteAtom(char *pszAtomName, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1253 C_ARGS: hAtomTbl, pszAtomName
1256 Alarm(unsigned long rgfType = WA_ERROR, HWND hwndDesktop = HWND_DESKTOP)
1257 C_ARGS: hwndDesktop, rgfType
1260 FlashWindow(HWND hwndFrame, bool fFlash)
1262 MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myQuery
1265 myQueryWindowText(HWND hwnd)
1268 myQueryClassName(HWND hwnd)
1270 MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = Query
1273 QueryFocusWindow(HWND hwndDesktop = HWND_DESKTOP)
1276 QueryWindowTextLength(HWND hwnd)
1279 QueryWindowSWP(HWND hwnd)
1282 QueryWindowULong(HWND hwnd, long index)
1285 QueryWindowUShort(HWND hwnd, long index)
1288 QueryActiveWindow(HWND hwnd = HWND_DESKTOP)
1291 QueryDesktopWindow(HAB hab = Acquire_hab(), unsigned long hdc = NULLHANDLE)
1294 QueryClipbrdData(unsigned long fmt = CF_TEXT, HAB hab = perl_hab_GET())
1299 QueryClipbrdViewer(HAB hab = perl_hab_GET())
1302 QueryClipbrdOwner(HAB hab = perl_hab_GET())
1305 CloseClipbrd(HAB hab = perl_hab_GET())
1308 EmptyClipbrd(HAB hab = perl_hab_GET())
1311 OpenClipbrd(HAB hab = perl_hab_GET())
1314 QueryAtomUsage(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1315 C_ARGS: hAtomTbl, atom
1318 QueryAtomLength(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1319 C_ARGS: hAtomTbl, atom
1322 QuerySystemAtomTable()
1325 QuerySysPointer(long lId, bool fCopy = 1, HWND hwndDesktop = HWND_DESKTOP)
1326 C_ARGS: hwndDesktop, lId, fCopy
1329 CreateAtomTable(unsigned long initial = 0, unsigned long buckets = 0)
1332 DestroyAtomTable(HATOMTBL hAtomTbl)
1335 MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myWinQuery
1338 myWinQueryWindowPtr(HWND hwnd, long index)
1341 myWinQueryWindowProcess(HWND hwnd, OUTLIST unsigned long pid, OUTLIST unsigned long tid)
1344 if (CheckWinError(RETVAL))
1345 croak_with_os2error("WindowProcess() error");
1348 myWinQueryActiveDesktopPathname()
1351 myWinQueryClipbrdFmtInfo(OUTLIST unsigned long prgfFmtInfo, unsigned long fmt = CF_TEXT, HAB hab = perl_hab_GET())
1352 C_ARGS: hab, fmt, &prgfFmtInfo
1355 myWinQueryAtomName(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1357 MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myWin
1360 myWinSwitchToProgram(HSWITCH hsw = switch_of(NULLHANDLE, getpid()))
1367 myWinMessageBox(unsigned long pszText, char* pszCaption = "Perl script error", unsigned long flStyle = MB_CANCEL | MB_ICONHAND, HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = HWND_DESKTOP, unsigned long idWindow = 0)
1368 C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle
1373 _MessageBox(char* pszText, char* pszCaption = "Perl script error", unsigned long flStyle = MB_CANCEL | MB_INFORMATION | MB_MOVEABLE, HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = NULLHANDLE, unsigned long idWindow = 0)
1374 C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle
1376 if (RETVAL == MBID_ERROR)
1380 _MessageBox2(char *pszText, char* pmb2info, char *pszCaption, HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = NULLHANDLE, unsigned long idWindow = 0)
1381 C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, (PMB2INFO)pmb2info
1383 if (RETVAL == MBID_ERROR)
1386 MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myWinQuery
1388 MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = get
1394 ppidOf(int pid = getpid())
1397 sidOf(int pid = getpid())
1400 getscrsize(OUTLIST int wp, OUTLIST int hp)
1404 scrsize_set(int w_or_h, int h = -9999)
1407 get_InvalidateRect(HWND hwnd, char *prcl, bool fIncludeChildren)
1410 get_CreateFrameControls(HWND hwndFrame, char *pfcdata, char* pszTitle)
1412 MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = ul
1415 ulMPFROMSHORT(unsigned short i)
1421 ulMPFROMCHAR(unsigned char i)
1424 ulMPFROM2SHORT(unsigned short x1, unsigned short x2)
1428 ulMPFROMSH2CH(unsigned short s, unsigned char c1, unsigned char c2)
1432 ulMPFROMLONG(unsigned long x)