22 #include "../../SDL_internal.h"
24 #if SDL_VIDEO_DRIVER_OS2
28 #include "../SDL_pixels_c.h"
29 #include "../SDL_shape_internals.h"
30 #include "../../events/SDL_events_c.h"
40 #define FOURCC_R666 mmioFOURCC('R','6','6','6')
43 #define WIN_CLIENT_CLASS "SDL2"
44 #define OS2DRIVER_NAME_DIVE "DIVE"
45 #define OS2DRIVER_NAME_VMAN "VMAN"
80 ULONG ulBPP, ULONG fccColorEncoding)
82 ULONG ulRshift, ulGshift, ulBshift;
83 ULONG ulRmask, ulGmask, ulBmask;
84 ULONG ulRloss, ulGloss, ulBloss;
89 switch (fccColorEncoding) {
91 ulRshift = 0; ulGshift = 0; ulBshift = 0;
92 ulRmask = 0; ulGmask = 0; ulBmask = 0;
93 ulRloss = 8; ulGloss = 8; ulBloss = 8;
97 ulRshift = 10; ulGshift = 5; ulBshift = 0;
98 ulRmask = 0x7C00; ulGmask = 0x03E0; ulBmask = 0x001F;
99 ulRloss = 3; ulGloss = 3; ulBloss = 3;
103 ulRshift = 11; ulGshift = 5; ulBshift = 0;
104 ulRmask = 0xF800; ulGmask = 0x07E0; ulBmask = 0x001F;
105 ulRloss = 3; ulGloss = 2; ulBloss = 3;
109 ulRshift = 10; ulGshift = 4; ulBshift = 0;
110 ulRmask = 0xFC00; ulGmask = 0x03F0; ulBmask = 0x000F;
111 ulRloss = 2; ulGloss = 4; ulBloss = 3;
115 ulRshift = 12; ulGshift = 6; ulBshift = 0;
116 ulRmask = 0x03F000; ulGmask = 0x000FC0; ulBmask = 0x00003F;
117 ulRloss = 2; ulGloss = 2; ulBloss = 2;
122 ulRshift = 0; ulGshift = 8; ulBshift = 16;
123 ulRmask = 0x0000FF; ulGmask = 0x00FF00; ulBmask = 0xFF0000;
124 ulRloss = 0x00; ulGloss = 0x00; ulBloss = 0x00;
129 ulRshift = 16; ulGshift = 8; ulBshift = 0;
130 ulRmask = 0xFF0000; ulGmask = 0x00FF00; ulBmask = 0x0000FF;
131 ulRloss = 0; ulGloss = 0; ulBloss = 0;
140 pSDLPixelFormat->
Rshift = ulRshift;
141 pSDLPixelFormat->
Gshift = ulGshift;
142 pSDLPixelFormat->
Bshift = ulBshift;
143 pSDLPixelFormat->
Rmask = ulRmask;
144 pSDLPixelFormat->
Gmask = ulGmask;
145 pSDLPixelFormat->
Bmask = ulBmask;
146 pSDLPixelFormat->
Rloss = ulRloss;
147 pSDLPixelFormat->
Gloss = ulGloss;
148 pSDLPixelFormat->
Bloss = ulBloss;
150 pSDLPixelFormat->
Ashift = 0x00;
151 pSDLPixelFormat->
Amask = 0x00;
152 pSDLPixelFormat->
Aloss = 0x00;
157 static Uint32 _getSDLPixelFormat(ULONG ulBPP, FOURCC fccColorEncoding)
162 if (_getSDLPixelFormatData(&stSDLPixelFormat, ulBPP, fccColorEncoding))
164 stSDLPixelFormat.
Gmask,
165 stSDLPixelFormat.
Bmask, 0);
174 if (pSDLDisplay ==
NULL) {
182 static VOID _mouseCheck(
WINDATA *pWinData)
190 WinSetCapture(HWND_DESKTOP, NULLHANDLE);
200 static VOID _setVisibleRegion(
WINDATA *pWinData, BOOL fVisible)
209 (pSDLDisplay ==
NULL) ?
214 static VOID _wmPaint(
WINDATA *pWinData, HWND hwnd)
221 hps = WinBeginPaint(hwnd, 0, &rectl);
222 WinFillRect(hps, &rectl, CLR_BLACK);
227 static VOID _wmMouseMove(
WINDATA *pWinData, SHORT lX, SHORT lY)
236 (WinQueryCapture(HWND_DESKTOP) == pWinData->
hwnd)) {
243 else if (lX >= pWinData->
window->
w)
248 else if (lY >= pWinData->
window->
h)
251 if (lX != pointl.x || lY != pointl.x) {
254 WinMapWindowPoints(pWinData->
hwnd, HWND_DESKTOP, &pointl, 1);
256 WinSetPointerPos(HWND_DESKTOP, pointl.x, pointl.y);
266 pointl.x = pWinData->
window->
w / 2;
267 pointl.y = pWinData->
window->
h / 2;
268 WinMapWindowPoints(pWinData->
hwnd, HWND_DESKTOP, &pointl, 1);
271 lX - pointl.
x, pointl.y - lY);
274 WinSetPointerPos(HWND_DESKTOP, pointl.x, pointl.y);
278 static VOID _wmMouseButton(
WINDATA *pWinData, ULONG ulButton, BOOL fDown)
286 (WinQueryCapture(HWND_DESKTOP) != pWinData->
hwnd)) {
291 pointl.x = pWinData->
window->
w / 2;
292 pointl.y = pWinData->
window->
h / 2;
293 WinMapWindowPoints(pWinData->
hwnd, HWND_DESKTOP, &pointl, 1);
295 WinSetPointerPos(HWND_DESKTOP, pointl.x, pointl.y);
298 WinSetCapture(HWND_DESKTOP, pWinData->
hwnd);
303 aBtnGROP2SDL[ulButton]);
306 static VOID _wmChar(
WINDATA *pWinData, MPARAM mp1, MPARAM mp2)
308 ULONG ulFlags = SHORT1FROMMP(mp1);
309 ULONG ulVirtualKey = SHORT2FROMMP(mp2);
310 ULONG ulCharCode = SHORT1FROMMP(mp2);
311 ULONG ulScanCode = CHAR4FROMMP(mp1);
313 if (((ulFlags & (KC_VIRTUALKEY | KC_KEYUP | KC_ALT)) == (KC_VIRTUALKEY | KC_ALT)) &&
314 (ulVirtualKey == VK_F4)) {
318 if ((ulFlags & KC_SCANCODE) != 0) {
322 if ((ulFlags & KC_CHAR) != 0) {
324 LONG lRC =
StrUTF8(1, acUTF8,
sizeof(acUTF8), (PSZ)&ulCharCode, 1);
330 static VOID _wmMove(
WINDATA *pWinData)
333 POINTL pointl = { 0 };
336 WinQueryWindowRect(pWinData->
hwnd, &rectl);
337 WinMapWindowPoints(pWinData->
hwnd, HWND_DESKTOP, (PPOINTL)&rectl, 2);
339 WinMapWindowPoints(pWinData->
hwnd, HWND_DESKTOP, &pointl, 1);
341 pSDLDisplayMode->
h - rectl.yTop);
344 static MRESULT _wmDragOver(
WINDATA *pWinData, PDRAGINFO pDragInfo)
348 USHORT usDrag = DOR_NEVERDROP;
349 USHORT usDragOp = DO_UNKNOWN;
351 if (!DrgAccessDraginfo(pDragInfo))
352 return MRFROM2SHORT(DOR_NEVERDROP, DO_UNKNOWN);
354 for (ulIdx = 0; ulIdx < pDragInfo->cditem; ulIdx++) {
355 pDragItem = DrgQueryDragitemPtr(pDragInfo, ulIdx);
358 if (!DrgVerifyRMF(pDragItem,
"DRM_OS2FILE",
NULL)) {
359 usDrag = DOR_NEVERDROP;
360 usDragOp = DO_UNKNOWN;
364 if (pDragInfo->usOperation == DO_DEFAULT &&
365 (pDragItem->fsSupportedOps & DO_COPYABLE) != 0) {
369 if (pDragInfo->usOperation == DO_LINK &&
370 (pDragItem->fsSupportedOps & DO_LINKABLE) != 0) {
374 usDrag = DOR_NODROPOP;
375 usDragOp = DO_UNKNOWN;
382 WinUpdateWindow(pWinData->
hwnd);
384 DrgFreeDraginfo(pDragInfo);
385 return MPFROM2SHORT(usDrag, usDragOp);
388 static MRESULT _wmDrop(
WINDATA *pWinData, PDRAGINFO pDragInfo)
392 CHAR acFName[_MAX_PATH];
395 if (!DrgAccessDraginfo(pDragInfo))
396 return MRFROM2SHORT(DOR_NEVERDROP, 0);
398 for (ulIdx = 0; ulIdx < pDragInfo->cditem; ulIdx++) {
399 pDragItem = DrgQueryDragitemPtr(pDragInfo, ulIdx);
401 if (DrgVerifyRMF(pDragItem,
"DRM_OS2FILE",
NULL) &&
402 pDragItem->hstrContainerName != NULLHANDLE &&
403 pDragItem->hstrSourceName != NULLHANDLE) {
405 DrgQueryStrName(pDragItem->hstrContainerName,
sizeof(acFName), acFName);
406 pcFName = strchr(acFName,
'\0');
407 DrgQueryStrName(pDragItem->hstrSourceName,
408 sizeof(acFName) - (pcFName - acFName), pcFName);
416 if (pDragItem->hwndItem)
417 DrgSendTransferMsg(pDragItem->hwndItem, DM_ENDCONVERSATION,
418 (MPARAM)pDragItem->ulItemID,
419 (MPARAM)DMFL_TARGETSUCCESSFUL);
423 DrgDeleteDraginfoStrHandles(pDragInfo);
424 DrgFreeDraginfo(pDragInfo);
428 return (MRESULT)
FALSE;
431 MRESULT EXPENTRY wndFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
433 HWND hwndClient = WinQueryWindow(hwnd, QW_BOTTOM);
434 WINDATA * pWinData = (
WINDATA *)WinQueryWindowULong(hwndClient, 0);
436 if (pWinData ==
NULL)
437 return WinDefWindowProc(hwnd, msg, mp1, mp2);
446 wmmsg.
msg.os2.hwnd = hwnd;
448 wmmsg.
msg.os2.mp1 = mp1;
449 wmmsg.
msg.os2.mp2 = mp2;
455 if ((((PSWP)mp1)->fl & SWP_RESTORE) != 0) {
459 if ((((PSWP)mp1)->fl & SWP_MINIMIZE) != 0) {
464 if ((((PSWP)mp1)->fl & SWP_MAXIMIZE) != 0) {
469 case WM_ADJUSTFRAMEPOS:
475 (((PSWP)mp1)->fl & SWP_RESTORE) != 0) {
481 rectl.xRight = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
482 rectl.yTop = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
483 WinCalcFrameRect(hwnd, &rectl,
FALSE);
484 ((PSWP)mp1)->x = rectl.xLeft;
485 ((PSWP)mp1)->y = rectl.yBottom;
486 ((PSWP)mp1)->cx = rectl.xRight - rectl.xLeft;
487 ((PSWP)mp1)->cy = rectl.yTop - rectl.yBottom;
489 if ((((PSWP)mp1)->fl & (SWP_SIZE | SWP_MINIMIZE)) == SWP_SIZE) {
493 OS2_ResizeWindowShape(pWinData->
window);
498 int iMinW, iMinH, iMaxW, iMaxH;
504 (
int *)&rectl.xRight, (
int *)&rectl.yTop);
505 iWinW = rectl.xRight;
512 rectl.xRight = iMinW;
513 else if (iMaxW != 0 && iWinW > iMaxW)
514 rectl.xRight = iMaxW;
518 else if (iMaxH != 0 && iWinH > iMaxH)
521 if (rectl.xRight == iWinW && rectl.yTop == iWinH) {
523 OS2_ResizeWindowShape(pWinData->
window);
527 WinCalcFrameRect(hwnd, &rectl,
FALSE);
528 ((PSWP)mp1)->cx = rectl.xRight - rectl.xLeft;
529 ((PSWP)mp1)->cy = rectl.yTop - rectl.yBottom;
538 MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
542 if (pWinData ==
NULL)
543 return WinDefWindowProc(hwnd, msg, mp1, mp2);
552 wmmsg.
msg.os2.hwnd = hwnd;
554 wmmsg.
msg.os2.mp1 = mp1;
555 wmmsg.
msg.os2.mp2 = mp2;
564 return (MRESULT)
FALSE;
568 _wmPaint(pWinData, hwnd);
580 return (MRESULT)
TRUE;
589 WinQueryPointerPos(HWND_DESKTOP, &pointl);
590 WinMapWindowPoints(HWND_DESKTOP, pWinData->
hwnd, &pointl, 1);
592 pointl.
x, pWinData->
window->
h - pointl.y - 1);
597 WinSetCapture(HWND_DESKTOP, NULLHANDLE);
607 _wmMouseMove(pWinData, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));
609 return (MRESULT)
FALSE;
612 case WM_BUTTON1DBLCLK:
613 _wmMouseButton(pWinData, 0,
TRUE);
617 _wmMouseButton(pWinData, 0,
FALSE);
621 case WM_BUTTON2DBLCLK:
622 _wmMouseButton(pWinData, 1,
TRUE);
626 _wmMouseButton(pWinData, 1,
FALSE);
630 case WM_BUTTON3DBLCLK:
631 _wmMouseButton(pWinData, 2,
TRUE);
635 _wmMouseButton(pWinData, 2,
FALSE);
638 case WM_TRANSLATEACCEL:
640 if (mp1 ==
NULL || ((PQMSG)mp1)->msg != WM_CHAR)
642 return (MRESULT)
FALSE;
645 _wmChar(pWinData, mp1, mp2);
654 SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
673 _setVisibleRegion(pWinData,
TRUE);
675 return (MRESULT)
TRUE;
678 _setVisibleRegion(pWinData,
FALSE);
679 return (MRESULT)
TRUE;
682 return _wmDragOver(pWinData, (PDRAGINFO)PVOIDFROMMP(mp1));
685 return _wmDrop(pWinData, (PDRAGINFO)PVOIDFROMMP(mp1));
690 WinDefWindowProc(hwnd, msg, mp1, mp2);
698 static void OS2_PumpEvents(
_THIS)
703 if (WinPeekMsg(pVData->
hab, &qmsg, NULLHANDLE, 0, 0, PM_REMOVE))
704 WinDispatchMsg(pVData->
hab, &qmsg);
713 if (pWinData ==
NULL) {
717 pWinData->
hwnd = hwnd;
720 window->driverdata = pWinData;
722 WinSetWindowULong(hwnd, 0, (ULONG)pWinData);
723 pWinData->
fnWndFrameProc = WinSubclassWindow(hwndFrame, wndFrameProc);
728 WinSetVisibleRegionNotify(hwnd,
TRUE);
736 HWND hwndFrame, hwnd;
738 ULONG ulFrameFlags = FCF_TASKLIST | FCF_TITLEBAR | FCF_SYSMENU |
739 FCF_MINBUTTON | FCF_SHELLPOSITION;
740 ULONG ulSWPFlags = SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE;
743 if (pSDLDisplayMode ==
NULL)
748 ulFrameFlags |= FCF_SIZEBORDER | FCF_DLGBORDER | FCF_MAXBUTTON;
750 ulFrameFlags |= FCF_DLGBORDER;
753 ulSWPFlags |= SWP_MAXIMIZE;
755 ulSWPFlags |= SWP_MINIMIZE;
757 hwndFrame = WinCreateStdWindow(HWND_DESKTOP, 0, &ulFrameFlags,
758 WIN_CLIENT_CLASS,
"SDL2", 0, 0, 0, &hwnd);
759 if (hwndFrame == NULLHANDLE)
763 pWinData = _setupWindow(
_this,
window, hwndFrame, hwnd);
764 if (pWinData ==
NULL) {
765 WinDestroyWindow(hwndFrame);
774 WinCalcFrameRect(hwndFrame, &rectl,
FALSE);
777 WinSetWindowPos(hwndFrame, HWND_TOP, rectl.xLeft, rectl.yBottom,
778 rectl.xRight - rectl.xLeft, rectl.yTop - rectl.yBottom,
783 WinMapWindowPoints(hwnd, HWND_DESKTOP, (PPOINTL)&rectl, 1);
785 window->y = pSDLDisplayMode->
h - (rectl.yBottom +
window->h);
797 HWND hwndUser = (HWND)
data;
798 HWND hwndFrame, hwnd;
807 if (pSDLDisplayMode ==
NULL)
812 WinQueryClassName(hwndUser,
sizeof(acBuf), acBuf);
813 if (!WinQueryClassInfo(pVData->
hab, acBuf, &stCI))
814 return SDL_SetError(
"Cannot get user window class information");
816 if ((stCI.flClassStyle & CS_FRAME) == 0) {
818 hwndFrame = WinQueryWindow(hwndUser, QW_PARENT);
819 if (hwndFrame == NULLHANDLE)
822 if ((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, 0, 0) == 0)
823 return SDL_SetError(
"Parent window is not a frame window");
828 hwnd = WinWindowFromID(hwndUser, FID_CLIENT);
829 if (hwnd == NULLHANDLE)
832 hwndFrame = hwndUser;
834 WinQueryClassName(hwnd,
sizeof(acBuf), acBuf);
835 if (!WinQueryClassInfo(pVData->
hab, acBuf, &stCI))
836 return SDL_SetError(
"Cannot get client window class information");
840 if (stCI.cbWindowData <
sizeof(ULONG))
841 return SDL_SetError(
"Reserved storage of window must be at least %u bytes",
sizeof(ULONG));
844 cbText = WinQueryWindowTextLength(hwndFrame);
848 cbText = (pszText !=
NULL)? WinQueryWindowText(hwndFrame, cbText, pszText) : 0;
861 if (WinIsWindowVisible(hwnd))
864 WinSendMsg(hwndFrame, WM_QUERYBORDERSIZE, MPFROMP(&pointl), 0);
865 if (pointl.y == WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER))
867 else if (pointl.y <= WinQuerySysValue(HWND_DESKTOP, SV_CYBORDER))
870 WinQueryWindowPos(hwndFrame, &swp);
872 if ((swp.fl & SWP_MAXIMIZE) != 0)
874 if ((swp.fl & SWP_MINIMIZE) != 0)
879 WinMapWindowPoints(hwnd, HWND_DESKTOP, &pointl, 1);
881 window->y = pSDLDisplayMode->
h - (pointl.y + swp.cy);
883 WinQueryWindowPos(hwnd, &swp);
888 pWinData = _setupWindow(
_this,
window, hwndFrame, hwnd);
889 if (pWinData ==
NULL) {
896 if (WinQueryActiveWindow(HWND_DESKTOP) == hwndFrame)
908 if (pWinData ==
NULL)
916 WinSetWindowULong(pWinData->
hwnd, 0, 0);
924 if (pWinData->
hptrIcon != NULLHANDLE) {
925 WinDestroyPointer(pWinData->
hptrIcon);
937 WinSetWindowText(((
WINDATA *)
window->driverdata)->hwndFrame, pszTitle);
946 if (hptr == NULLHANDLE)
950 if (pWinData->
hptrIcon != NULLHANDLE)
951 WinDestroyPointer(pWinData->
hptrIcon);
955 if (!WinSendMsg(pWinData->
hwndFrame, WM_SETICON, MPFROMLONG(hptr), 0)) {
956 debug_os2(
"Cannot set icon for the window");
968 if (pSDLDisplayMode ==
NULL)
980 ulFlags = SWP_ZORDER | SWP_MOVE | SWP_SIZE;
982 ulFlags = SWP_MOVE | SWP_SIZE;
986 WinSetWindowPos(pWinData->
hwndFrame, HWND_TOP,
988 (pSDLDisplayMode->
h -
window->y) -
window->h + rectl.yBottom,
989 rectl.xRight - rectl.xLeft, rectl.yTop - rectl.yBottom,
1026 WinSetWindowPos(pWinData->
hwndFrame, HWND_TOP, 0, 0, 0, 0, SWP_MAXIMIZE);
1034 WinSetWindowPos(pWinData->
hwndFrame, HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_DEACTIVATE);
1042 WinSetWindowPos(pWinData->
hwndFrame, HWND_TOP, 0, 0, 0, 0, SWP_RESTORE);
1049 ULONG ulStyle = WinQueryWindowULong(pWinData->
hwndFrame, QWL_STYLE);
1058 ulStyle &= ~(FS_SIZEBORDER | FS_BORDER | FS_DLGBORDER);
1061 WinQueryWindowRect(pWinData->
hwnd, &rectl);
1062 WinMapWindowPoints(pWinData->
hwnd, HWND_DESKTOP, (PPOINTL)&rectl, 2);
1065 WinSetWindowULong(pWinData->
hwndFrame, QWL_STYLE, ulStyle);
1066 WinSendMsg(pWinData->
hwndFrame, WM_UPDATEFRAME, MPFROMLONG(FCF_BORDER), 0);
1071 WinSetWindowPos(pWinData->
hwndFrame, HWND_TOP, rectl.xLeft, rectl.yBottom,
1072 rectl.xRight - rectl.xLeft,
1073 rectl.yTop - rectl.yBottom,
1074 SWP_SIZE | SWP_MOVE | SWP_NOADJUST);
1086 debug_os2(
"Enter, fullscreen: %u", fullscreen);
1088 if (pSDLDisplayMode ==
NULL)
1093 ulFlags = SWP_SIZE | SWP_MOVE | SWP_ZORDER | SWP_NOADJUST;
1095 ulFlags = SWP_SIZE | SWP_MOVE | SWP_NOADJUST;
1100 rectl.xRight = pSDLDisplayMode->
w;
1101 rectl.yTop = pSDLDisplayMode->
h;
1103 WinSetWindowPos(pWinData->
hwndFrame, HWND_TOP, 0, 0, 0, 0, SWP_RESTORE);
1106 rectl.xLeft =
window->windowed.x;
1107 rectl.yTop = pSDLDisplayMode->
h -
window->windowed.y;
1108 rectl.xRight = rectl.xLeft +
window->windowed.w;
1109 rectl.yBottom = rectl.yTop -
window->windowed.h;
1115 else if (!WinSetWindowPos(pWinData->
hwndFrame, HWND_TOP,
1116 rectl.xLeft, rectl.yBottom,
1117 rectl.xRight - rectl.xLeft, rectl.yTop - rectl.yBottom,
1130 info->
info.os2.hwnd = pWinData->
hwnd;
1135 SDL_SetError(
"Application not compiled with SDL %u.%u",
1155 _mouseCheck(pWinData);
1161 typedef struct _SHAPERECTS {
1167 static void _combineRectRegions(
SDL_ShapeTree *node,
void *closure)
1169 SHAPERECTS *pShapeRects = (SHAPERECTS *)closure;
1173 if ((pShapeRects->cRects & 0x0F) == 0) {
1174 pRect =
SDL_realloc(pShapeRects->pRects, (pShapeRects->cRects + 0x10) *
sizeof(RECTL));
1177 pShapeRects->pRects = pRect;
1181 pRect = &pShapeRects->pRects[pShapeRects->cRects];
1182 pShapeRects->cRects++;
1185 pRect->yTop = pShapeRects->ulWinHeight - node->
data.
shape.
y;
1187 pRect->yBottom = pRect->yTop - node->
data.
shape.
h;
1198 pSDLShaper->
userx = 0;
1199 pSDLShaper->
usery = 0;
1201 window->shaper = pSDLShaper;
1203 if (OS2_ResizeWindowShape(
window) != 0) {
1217 SHAPERECTS stShapeRects = { 0 };
1221 if (shaper ==
NULL || shape ==
NULL ||
1233 stShapeRects.ulWinHeight = shaper->
window->
h;
1237 hps = WinGetPS(pWinData->
hwnd);
1240 GpiDestroyRegion(hps, pWinData->
hrgnShape);
1242 pWinData->
hrgnShape = (stShapeRects.pRects ==
NULL) ? NULLHANDLE :
1243 GpiCreateRegion(hps, stShapeRects.cRects, stShapeRects.pRects);
1247 WinSendMsg(pWinData->
hwnd, WM_VRNENABLED, 0, 0);
1258 if (
window->x != -1000) {
1292 ULONG ulWidth, ulHeight;
1295 if (pSDLDisplay ==
NULL) {
1306 debug_os2(
"Window size: %u x %u", ulWidth, ulHeight);
1316 WinSendMsg(pWinData->
hwnd, WM_VRNENABLED, 0, 0);
1334 static int OS2_SetClipboardText(
_THIS,
const char *
text)
1344 if (pszText ==
NULL)
1348 ulRC = DosAllocSharedMem((PPVOID)&pszClipboard, 0, cbText + 1,
1349 PAG_COMMIT | PAG_READ | PAG_WRITE |
1350 OBJ_GIVEABLE | OBJ_GETTABLE | OBJ_TILE);
1351 if (ulRC != NO_ERROR) {
1352 debug_os2(
"DosAllocSharedMem() failed, rc = %u", ulRC);
1357 strcpy(pszClipboard, pszText);
1360 if (!WinOpenClipbrd(pVData->
hab)) {
1364 WinEmptyClipbrd(pVData->
hab);
1365 fSuccess = WinSetClipbrdData(pVData->
hab, (ULONG)pszClipboard, CF_TEXT, CFI_POINTER);
1369 WinCloseClipbrd(pVData->
hab);
1373 DosFreeMem(pszClipboard);
1379 static char *OS2_GetClipboardText(
_THIS)
1382 PSZ pszClipboard =
NULL;
1384 if (!WinOpenClipbrd(pVData->
hab)) {
1387 pszClipboard = (PSZ)WinQueryClipbrdData(pVData->
hab, CF_TEXT);
1388 if (pszClipboard !=
NULL)
1390 WinCloseClipbrd(pVData->
hab);
1401 if (!WinOpenClipbrd(pVData->
hab)) {
1406 fClipboard = ((PSZ)WinQueryClipbrdData(pVData->
hab, CF_TEXT) !=
NULL)?
1408 WinCloseClipbrd(pVData->
hab);
1414 static int OS2_VideoInit(
_THIS)
1426 DosGetInfoBlocks(&tib, &pib);
1427 if (pib->pib_ultype == 2 || pib->pib_ultype == 0) {
1429 pib->pib_ultype = 3;
1433 pVData->
hab = WinInitialize(0);
1434 pVData->
hmq = WinCreateMsgQueue(pVData->
hab, 0);
1435 if (pVData->
hmq == NULLHANDLE) {
1437 return SDL_SetError(
"Message queue cannot be created.");
1440 if (!WinRegisterClass(pVData->
hab, WIN_CLIENT_CLASS, wndProc,
1441 CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT,
1444 return SDL_SetError(
"Window class not successfully registered.");
1447 if (stricmp(
_this->
name, OS2DRIVER_NAME_VMAN) == 0)
1469 stSDLDisplayMode.
format = _getSDLPixelFormat(stVOInfo.
ulBPP,
1477 if (pModeData !=
NULL) {
1484 stSDLDisplay.
name =
"Primary";
1491 if (pDisplayData !=
NULL) {
1492 HPS hps = WinGetPS(HWND_DESKTOP);
1493 HDC hdc = GpiQueryDevice(hps);
1497 DevQueryCaps(hdc, CAPS_HORIZONTAL_FONT_RES, 1,
1499 DevQueryCaps(hdc, CAPS_VERTICAL_FONT_RES, 1,
1519 static void OS2_VideoQuit(
_THIS)
1525 WinDestroyMsgQueue(pVData->
hmq);
1526 WinTerminate(pVData->
hab);
1545 float *hdpi,
float *vdpi)
1550 if (pDisplayData ==
NULL)
1594 device->VideoInit = OS2_VideoInit;
1595 device->VideoQuit = OS2_VideoQuit;
1596 device->GetDisplayBounds = OS2_GetDisplayBounds;
1597 device->GetDisplayDPI = OS2_GetDisplayDPI;
1598 device->GetDisplayModes = OS2_GetDisplayModes;
1599 device->SetDisplayMode = OS2_SetDisplayMode;
1600 device->PumpEvents = OS2_PumpEvents;
1601 device->CreateSDLWindow = OS2_CreateWindow;
1602 device->CreateSDLWindowFrom = OS2_CreateWindowFrom;
1603 device->DestroyWindow = OS2_DestroyWindow;
1604 device->SetWindowTitle = OS2_SetWindowTitle;
1605 device->SetWindowIcon = OS2_SetWindowIcon;
1606 device->SetWindowPosition = OS2_SetWindowPosition;
1607 device->SetWindowSize = OS2_SetWindowSize;
1608 device->ShowWindow = OS2_ShowWindow;
1609 device->HideWindow = OS2_HideWindow;
1610 device->RaiseWindow = OS2_RaiseWindow;
1611 device->MaximizeWindow = OS2_MaximizeWindow;
1612 device->MinimizeWindow = OS2_MinimizeWindow;
1613 device->RestoreWindow = OS2_RestoreWindow;
1614 device->SetWindowBordered = OS2_SetWindowBordered;
1615 device->SetWindowFullscreen = OS2_SetWindowFullscreen;
1616 device->GetWindowWMInfo = OS2_GetWindowWMInfo;
1617 device->OnWindowEnter = OS2_OnWindowEnter;
1618 device->SetWindowHitTest = OS2_SetWindowHitTest;
1619 device->SetWindowGrab = OS2_SetWindowGrab;
1620 device->CreateWindowFramebuffer = OS2_CreateWindowFramebuffer;
1621 device->UpdateWindowFramebuffer = OS2_UpdateWindowFramebuffer;
1622 device->DestroyWindowFramebuffer = OS2_DestroyWindowFramebuffer;
1624 device->SetClipboardText = OS2_SetClipboardText;
1625 device->GetClipboardText = OS2_GetClipboardText;
1626 device->HasClipboardText = OS2_HasClipboardText;
1628 device->shape_driver.CreateShaper = OS2_CreateShaper;
1629 device->shape_driver.SetWindowShape = OS2_SetWindowShape;
1630 device->shape_driver.ResizeWindowShape = OS2_ResizeWindowShape;
1632 device->free = OS2_DeleteDevice;
1643 return OS2_CreateDevice(devindex);
1652 return OS2_CreateDevice(devindex);
1660 OS2DRIVER_NAME_DIVE,
"OS/2 video driver",
1661 OS2DIVE_CreateDevice
1666 OS2DRIVER_NAME_VMAN,
"OS/2 video driver",
1667 OS2VMAN_CreateDevice
int SDL_SendDropFile(SDL_Window *window, const char *file)
int SDL_SendDropComplete(SDL_Window *window)
#define SDL_GetWindowSize
#define SDL_GetWindowFlags
#define SDL_GetKeyboardFocus
#define SDL_GetWindowMinimumSize
#define SDL_SetWindowPosition
#define SDL_GetWindowMaximumSize
#define SDL_MasksToPixelFormatEnum
#define SDL_IsShapedWindow
#define SDL_OutOfMemory()
int SDL_SendSysWMEvent(SDL_SysWMmsg *message)
#define SDL_GetEventState(type)
void SDL_SetKeyboardFocus(SDL_Window *window)
int SDL_SendKeyboardText(const char *text)
int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
SDL_Mouse * SDL_GetMouse(void)
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
#define SDL_BUTTON_MIDDLE
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLenum GLenum GLsizei const GLuint GLboolean enabled
void OS2_QuitMouse(_THIS)
void OS2_InitMouse(_THIS, ULONG hab)
HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY)
@ SDL_PIXELFORMAT_UNKNOWN
SDL_Scancode
The SDL keyboard scancode representation.
@ SDL_SCANCODE_INTERNATIONAL4
@ SDL_SCANCODE_RIGHTBRACKET
@ SDL_SCANCODE_INTERNATIONAL1
@ SDL_SCANCODE_NONUSBACKSLASH
@ SDL_SCANCODE_APOSTROPHE
@ SDL_SCANCODE_NUMLOCKCLEAR
@ SDL_SCANCODE_SCROLLLOCK
@ SDL_SCANCODE_INTERNATIONAL3
@ SDL_SCANCODE_LEFTBRACKET
@ SDL_SCANCODE_INTERNATIONAL2
@ SDL_SCANCODE_INTERNATIONAL5
@ SDL_SCANCODE_KP_MULTIPLY
@ SDL_SCANCODE_APPLICATION
void SDL_TraverseShapeTree(SDL_ShapeTree *tree, SDL_TraversalFunction function, void *closure)
void SDL_FreeShapeTree(SDL_ShapeTree **shape_tree)
SDL_ShapeTree * SDL_CalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *shape)
#define SDL_INVALID_SHAPE_ARGUMENT
@ ShapeModeColorKey
A color key is applied.
@ ShapeModeDefault
The default mode, a binarized alpha cutoff of 1.
#define SDL_stack_alloc(type, count)
#define SDL_stack_free(data)
SDL_bool SDL_ShouldAllowTopmost(void)
VideoBootStrap OS2DIVE_bootstrap
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event)
float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches)
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
VideoBootStrap OS2VMAN_bootstrap
#define SDL_MINOR_VERSION
#define SDL_VERSION(x)
Macro to determine SDL version program was compiled against.
#define SDL_MAJOR_VERSION
static SDL_VideoDevice * _this
@ SDL_WINDOW_INPUT_GRABBED
@ SDL_WINDOWEVENT_RESIZED
@ SDL_WINDOWEVENT_MINIMIZED
@ SDL_WINDOWEVENT_MAXIMIZED
@ SDL_WINDOWEVENT_RESTORED
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
EGLSurface EGLNativeWindowType * window
EGLSurface EGLint * rects
int StrUTF8(int fToUTF8, char *pcDst, int cbDst, char *pcSrc, int cbSrc)
static SDL_AudioDeviceID device
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
BOOL(* QueryInfo)(VIDEOOUTPUTINFO *pInfo)
VOID(* VideoBufFree)(PVODATA pVOData)
PVOID(* VideoBufAlloc)(PVODATA pVOData, ULONG ulWidth, ULONG ulHeight, ULONG ulBPP, ULONG fccColorEncoding, PULONG pulScanLineSize)
BOOL(* Update)(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, ULONG cSDLRects)
VOID(* Close)(PVODATA pVOData)
BOOL(* SetVisibleRegion)(PVODATA pVOData, HWND hwnd, SDL_DisplayMode *pSDLDisplayMode, HRGN hrgnShape, BOOL fVisible)
The structure that defines a display mode.
SDL_bool relative_mode_warp
A rectangle, with the origin at the upper left (integer).
A collection of pixels used in software blitting.
union SDL_SysWMinfo::@10 info
union SDL_SysWMmsg::@8 msg
SDL_DisplayMode desktop_mode
SDL_DisplayMode current_mode
The type used to identify a window.
A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents.
SDL_WindowShapeParams parameters
Window-shape parameters.
WindowShapeMode mode
The mode of these window-shape parameters.
LONG lSkipWMAdjustFramePos
static char text[MAX_TEXT_LENGTH]
Uint8 binarizationCutoff
A cutoff alpha value for binarization of the window shape's alpha channel.