| 1 | /* $Id: pmwindow.cpp,v 1.92 2000-06-07 14:51:27 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 Window Managment Code for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 6 | * Copyright 1999 Daniela Engert (dani@ngrt.de)
|
|---|
| 7 | *
|
|---|
| 8 | *
|
|---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 10 | *
|
|---|
| 11 | */
|
|---|
| 12 | #define INCL_WIN
|
|---|
| 13 | #define INCL_GPI
|
|---|
| 14 | #define INCL_DEV /* Device Function definitions */
|
|---|
| 15 | #define INCL_GPICONTROL /* GPI control Functions */
|
|---|
| 16 | #define INCL_DOSPROCESS
|
|---|
| 17 | #define INCL_WINTRACKRECT
|
|---|
| 18 |
|
|---|
| 19 | #include <os2wrap.h>
|
|---|
| 20 | #include <stdlib.h>
|
|---|
| 21 | #include <string.h>
|
|---|
| 22 | #include <win32type.h>
|
|---|
| 23 | #include <winconst.h>
|
|---|
| 24 | #include <wprocess.h>
|
|---|
| 25 | #include <misc.h>
|
|---|
| 26 | #include <win32wbase.h>
|
|---|
| 27 | #include <win32dlg.h>
|
|---|
| 28 | #include "win32wdesktop.h"
|
|---|
| 29 | #include "pmwindow.h"
|
|---|
| 30 | #include "oslibwin.h"
|
|---|
| 31 | #include "oslibutil.h"
|
|---|
| 32 | #include "oslibgdi.h"
|
|---|
| 33 | #include "oslibmsg.h"
|
|---|
| 34 | #include "dc.h"
|
|---|
| 35 | #include <thread.h>
|
|---|
| 36 | #include <wprocess.h>
|
|---|
| 37 | #include "caret.h"
|
|---|
| 38 | #include "timer.h"
|
|---|
| 39 | #include <codepage.h>
|
|---|
| 40 |
|
|---|
| 41 | #define DBG_LOCALLOG DBG_pmwindow
|
|---|
| 42 | #include "dbglocal.h"
|
|---|
| 43 |
|
|---|
| 44 | HMQ hmq = 0; /* Message queue handle */
|
|---|
| 45 | HAB hab = 0;
|
|---|
| 46 |
|
|---|
| 47 | RECTL desktopRectl = {0};
|
|---|
| 48 | ULONG ScreenWidth = 0;
|
|---|
| 49 | ULONG ScreenHeight = 0;
|
|---|
| 50 | ULONG ScreenBitsPerPel = 0;
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
|---|
| 54 |
|
|---|
| 55 | PFNWP PMFrameWindowProc = 0;
|
|---|
| 56 |
|
|---|
| 57 | //******************************************************************************
|
|---|
| 58 | //Initialize PM; create hab, message queue and register special Win32 window classes
|
|---|
| 59 | //******************************************************************************
|
|---|
| 60 | BOOL InitPM()
|
|---|
| 61 | {
|
|---|
| 62 |
|
|---|
| 63 | hab = WinInitialize(0);
|
|---|
| 64 | dprintf(("Winitialize returned %x", hab));
|
|---|
| 65 | hmq = WinCreateMsgQueue(hab, 0);
|
|---|
| 66 |
|
|---|
| 67 | if(!hab || !hmq)
|
|---|
| 68 | {
|
|---|
| 69 | UINT error;
|
|---|
| 70 | //CB: only fail on real error
|
|---|
| 71 | error = WinGetLastError(hab) & 0xFFFF; //error code
|
|---|
| 72 | if (!hab || (error != PMERR_MSG_QUEUE_ALREADY_EXISTS))
|
|---|
| 73 | {
|
|---|
| 74 | dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
|
|---|
| 75 | dprintf((" Error = %x",error));
|
|---|
| 76 | return(FALSE);
|
|---|
| 77 | }
|
|---|
| 78 | else
|
|---|
| 79 | {
|
|---|
| 80 | if(!hab) {
|
|---|
| 81 | hab = WinQueryAnchorBlock(HWND_DESKTOP);
|
|---|
| 82 | dprintf(("WinQueryAnchorBlock returned %x", hab));
|
|---|
| 83 | }
|
|---|
| 84 | if(!hmq) {
|
|---|
| 85 | hmq = HMQ_CURRENT;
|
|---|
| 86 | }
|
|---|
| 87 | }
|
|---|
| 88 | }
|
|---|
| 89 | SetThreadHAB(hab);
|
|---|
| 90 | dprintf(("InitPM: hmq = %x", hmq));
|
|---|
| 91 | SetThreadMessageQueue(hmq);
|
|---|
| 92 |
|
|---|
| 93 | BOOL rc = WinSetCp(hmq, GetDisplayCodepage());
|
|---|
| 94 | dprintf(("InitPM: WinSetCP was %sOK", rc ? "" : "not "));
|
|---|
| 95 |
|
|---|
| 96 | if(!WinRegisterClass( /* Register window class */
|
|---|
| 97 | hab, /* Anchor block handle */
|
|---|
| 98 | (PSZ)WIN32_STDCLASS, /* Window class name */
|
|---|
| 99 | (PFNWP)Win32WindowProc, /* Address of window procedure */
|
|---|
| 100 | CS_HITTEST,
|
|---|
| 101 | NROF_WIN32WNDBYTES)) {
|
|---|
| 102 | dprintf(("WinRegisterClass Win32BaseWindow failed"));
|
|---|
| 103 | return(FALSE);
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | CLASSINFO FrameClassInfo;
|
|---|
| 107 | if(!WinQueryClassInfo (hab, WC_FRAME, &FrameClassInfo)) {
|
|---|
| 108 | dprintf (("WinQueryClassInfo WC_FRAME failed"));
|
|---|
| 109 | return (FALSE);
|
|---|
| 110 | }
|
|---|
| 111 | dprintf(("WC_FRAME style %x", FrameClassInfo.flClassStyle));
|
|---|
| 112 |
|
|---|
| 113 | PMFrameWindowProc = FrameClassInfo.pfnWindowProc;
|
|---|
| 114 | if(!WinRegisterClass( /* Register window class */
|
|---|
| 115 | hab, /* Anchor block handle */
|
|---|
| 116 | (PSZ)WIN32_STDFRAMECLASS, /* Window class name */
|
|---|
| 117 | (PFNWP)Win32WindowProc, /* Address of window procedure */
|
|---|
| 118 | CS_HITTEST | CS_FRAME,
|
|---|
| 119 | FrameClassInfo.cbWindowData+NROF_WIN32WNDBYTES)) {
|
|---|
| 120 | dprintf(("WinRegisterClass Win32BaseWindow failed %x", WinGetLastError(hab)));
|
|---|
| 121 | return(FALSE);
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
|
|---|
| 125 | ScreenWidth = desktopRectl.xRight;
|
|---|
| 126 | ScreenHeight = desktopRectl.yTop;
|
|---|
| 127 |
|
|---|
| 128 | HDC hdc; /* Device-context handle */
|
|---|
| 129 | /* context data structure */
|
|---|
| 130 | DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
|
|---|
| 131 | NULL, NULL, NULL};
|
|---|
| 132 |
|
|---|
| 133 | /* create memory device context */
|
|---|
| 134 | hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
|
|---|
| 135 | DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, (PLONG)&ScreenBitsPerPel);
|
|---|
| 136 | DevCloseDC(hdc);
|
|---|
| 137 |
|
|---|
| 138 | dprintf(("InitPM: Desktop (%d,%d)", ScreenWidth, ScreenHeight));
|
|---|
| 139 | return TRUE;
|
|---|
| 140 | } /* End of main */
|
|---|
| 141 | //******************************************************************************
|
|---|
| 142 | //Win32 window message handler
|
|---|
| 143 | //******************************************************************************
|
|---|
| 144 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 145 | {
|
|---|
| 146 | POSTMSG_PACKET *postmsg;
|
|---|
| 147 | OSLIBPOINT point, ClientPoint;
|
|---|
| 148 | Win32BaseWindow *win32wnd;
|
|---|
| 149 | THDB *thdb;
|
|---|
| 150 | APIRET rc = 0;
|
|---|
| 151 | MSG winMsg, *pWinMsg;
|
|---|
| 152 |
|
|---|
| 153 | //Restore our FS selector
|
|---|
| 154 | SetWin32TIB();
|
|---|
| 155 |
|
|---|
| 156 | thdb = GetThreadTHDB();
|
|---|
| 157 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 158 |
|
|---|
| 159 | if(!thdb || (msg != WM_CREATE && win32wnd == NULL)) {
|
|---|
| 160 | dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
|
|---|
| 161 | goto RunDefWndProc;
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | if((thdb->msgstate & 1) == 0)
|
|---|
| 165 | {//message that was sent directly to our window proc handler; translate it here
|
|---|
| 166 | QMSG qmsg;
|
|---|
| 167 |
|
|---|
| 168 | qmsg.msg = msg;
|
|---|
| 169 | qmsg.hwnd = hwnd;
|
|---|
| 170 | qmsg.mp1 = mp1;
|
|---|
| 171 | qmsg.mp2 = mp2;
|
|---|
| 172 | qmsg.time = WinQueryMsgTime(thdb->hab);
|
|---|
| 173 | WinQueryMsgPos(thdb->hab, &qmsg.ptl);
|
|---|
| 174 | qmsg.reserved = 0;
|
|---|
| 175 |
|
|---|
| 176 | if(OS2ToWinMsgTranslate((PVOID)thdb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
|---|
| 177 | {//message was not translated
|
|---|
| 178 | memset(&winMsg, 0, sizeof(MSG));
|
|---|
| 179 | }
|
|---|
| 180 | pWinMsg = &winMsg;
|
|---|
| 181 | }
|
|---|
| 182 | else {
|
|---|
| 183 | pWinMsg = &thdb->msg;
|
|---|
| 184 | thdb->msgstate++;
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | if(msg == WIN32APP_POSTMSG) {
|
|---|
| 188 | //probably win32 app user message
|
|---|
| 189 | if((ULONG)mp1 == WIN32MSG_MAGICA) {
|
|---|
| 190 | return (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 191 | }
|
|---|
| 192 | else
|
|---|
| 193 | if((ULONG)mp1 == WIN32MSG_MAGICW) {
|
|---|
| 194 | return (MRESULT)win32wnd->DispatchMsgW(pWinMsg);
|
|---|
| 195 | }
|
|---|
| 196 | }
|
|---|
| 197 | switch( msg )
|
|---|
| 198 | {
|
|---|
| 199 | //OS/2 msgs
|
|---|
| 200 | case WM_CREATE:
|
|---|
| 201 | {
|
|---|
| 202 |
|
|---|
| 203 | if(thdb->newWindow == 0)
|
|---|
| 204 | goto createfail;
|
|---|
| 205 |
|
|---|
| 206 | //Processing is done in after WinCreateWindow returns
|
|---|
| 207 | dprintf(("OS2: WM_CREATE %x", hwnd));
|
|---|
| 208 | win32wnd = (Win32BaseWindow *)thdb->newWindow;
|
|---|
| 209 | thdb->newWindow = 0;
|
|---|
| 210 | if(win32wnd->MsgCreate(hwnd) == FALSE)
|
|---|
| 211 | {
|
|---|
| 212 | RestoreOS2TIB();
|
|---|
| 213 | return (MRESULT)TRUE; //discontinue window creation
|
|---|
| 214 | }
|
|---|
| 215 | RestoreOS2TIB();
|
|---|
| 216 | PMFrameWindowProc(hwnd, msg, mp1, mp2);
|
|---|
| 217 | SetWin32TIB();
|
|---|
| 218 | createfail:
|
|---|
| 219 | RestoreOS2TIB();
|
|---|
| 220 | return (MRESULT)FALSE;
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | case WM_QUIT:
|
|---|
| 224 | dprintf(("OS2: WM_QUIT %x", hwnd));
|
|---|
| 225 | win32wnd->MsgQuit();
|
|---|
| 226 | break;
|
|---|
| 227 |
|
|---|
| 228 | case WM_CLOSE:
|
|---|
| 229 | dprintf(("OS2: WM_CLOSE %x", hwnd));
|
|---|
| 230 | win32wnd->MsgClose();
|
|---|
| 231 | break;
|
|---|
| 232 |
|
|---|
| 233 | case WM_DESTROY:
|
|---|
| 234 | dprintf(("OS2: WM_DESTROY %x", hwnd));
|
|---|
| 235 | win32wnd->MsgDestroy();
|
|---|
| 236 | WinSetVisibleRegionNotify(hwnd, FALSE);
|
|---|
| 237 | goto RunDefWndProc;
|
|---|
| 238 |
|
|---|
| 239 | case WM_ENABLE:
|
|---|
| 240 | dprintf(("OS2: WM_ENABLE %x", hwnd));
|
|---|
| 241 | win32wnd->MsgEnable(SHORT1FROMMP(mp1));
|
|---|
| 242 | break;
|
|---|
| 243 |
|
|---|
| 244 | case WM_SHOW:
|
|---|
| 245 | dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
|
|---|
| 246 | win32wnd->MsgShow((ULONG)mp1);
|
|---|
| 247 | break;
|
|---|
| 248 |
|
|---|
| 249 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 250 | {
|
|---|
| 251 | PSWP pswp = (PSWP)mp1;
|
|---|
| 252 | SWP swpOld;
|
|---|
| 253 | WINDOWPOS wp,wpOld;
|
|---|
| 254 | HWND hParent = NULLHANDLE, hwndAfter;
|
|---|
| 255 |
|
|---|
| 256 | dprintf(("OS2: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 257 |
|
|---|
| 258 | //CB: show dialog in front of owner
|
|---|
| 259 | if (win32wnd->IsModalDialogOwner())
|
|---|
| 260 | {
|
|---|
| 261 | pswp->fl |= SWP_ZORDER;
|
|---|
| 262 | pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
|
|---|
| 263 | if (pswp->fl & SWP_ACTIVATE)
|
|---|
| 264 | {
|
|---|
| 265 | pswp->fl &= ~SWP_ACTIVATE;
|
|---|
| 266 | WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
|
|---|
| 267 | }
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 271 | goto RunDefWndProc;
|
|---|
| 272 |
|
|---|
| 273 | if(!win32wnd->CanReceiveSizeMsgs())
|
|---|
| 274 | break;
|
|---|
| 275 |
|
|---|
| 276 | WinQueryWindowPos(hwnd, &swpOld);
|
|---|
| 277 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 278 | if (win32wnd->isChild()) {
|
|---|
| 279 | if(win32wnd->getParent()) {
|
|---|
| 280 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 281 | }
|
|---|
| 282 | else goto RunDefWndProc;
|
|---|
| 283 | }
|
|---|
| 284 | }
|
|---|
| 285 | hwndAfter = pswp->hwndInsertBehind;
|
|---|
| 286 | if(win32wnd->getParent()) {
|
|---|
| 287 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
|
|---|
| 288 | win32wnd->getParent()->getClientRectPtr()->left,
|
|---|
| 289 | win32wnd->getParent()->getClientRectPtr()->top,
|
|---|
| 290 | hwnd);
|
|---|
| 291 | }
|
|---|
| 292 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
|---|
| 293 |
|
|---|
| 294 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 295 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 296 | {
|
|---|
| 297 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 298 | if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 299 | }
|
|---|
| 300 |
|
|---|
| 301 | wpOld = wp;
|
|---|
| 302 | win32wnd->MsgPosChanging((LPARAM)&wp);
|
|---|
| 303 |
|
|---|
| 304 | if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
|
|---|
| 305 | (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
|
|---|
| 306 | {
|
|---|
| 307 | dprintf(("OS2: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
|---|
| 308 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 309 |
|
|---|
| 310 | if(win32wnd->getParent()) {
|
|---|
| 311 | OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getWindowHeight(),
|
|---|
| 312 | win32wnd->getParent()->getClientRectPtr()->left,
|
|---|
| 313 | win32wnd->getParent()->getClientRectPtr()->top,
|
|---|
| 314 | hwnd);
|
|---|
| 315 | }
|
|---|
| 316 | else OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
|---|
| 317 |
|
|---|
| 318 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 319 | pswp->fl |= SWP_NOADJUST;
|
|---|
| 320 | pswp->hwndInsertBehind = hwndAfter;
|
|---|
| 321 | pswp->hwnd = hwnd;
|
|---|
| 322 |
|
|---|
| 323 | RestoreOS2TIB();
|
|---|
| 324 | return (MRESULT)0xf;
|
|---|
| 325 | }
|
|---|
| 326 | RestoreOS2TIB();
|
|---|
| 327 | return (MRESULT)0;
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | case WM_WINDOWPOSCHANGED:
|
|---|
| 331 | {
|
|---|
| 332 | PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
|
|---|
| 333 | SWP swpOld = *(pswp + 1);
|
|---|
| 334 | WINDOWPOS wp;
|
|---|
| 335 | HWND hParent = NULLHANDLE;
|
|---|
| 336 | RECTL rect;
|
|---|
| 337 |
|
|---|
| 338 | dprintf(("OS2: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 339 |
|
|---|
| 340 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 341 | {
|
|---|
| 342 | goto RunDefWndProc;
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 346 | if(win32wnd->isChild()) {
|
|---|
| 347 | if(win32wnd->getParent()) {
|
|---|
| 348 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 349 | }
|
|---|
| 350 | else goto PosChangedEnd; //parent has just been destroyed
|
|---|
| 351 | }
|
|---|
| 352 | }
|
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 | if(win32wnd->getParent()) {
|
|---|
| 356 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
|
|---|
| 357 | win32wnd->getParent()->getClientRectPtr()->left,
|
|---|
| 358 | win32wnd->getParent()->getClientRectPtr()->top,
|
|---|
| 359 | hwnd);
|
|---|
| 360 | }
|
|---|
| 361 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
|---|
| 362 |
|
|---|
| 363 | if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
|
|---|
| 364 | {
|
|---|
| 365 | //Note: Also updates the new window rectangle
|
|---|
| 366 | win32wnd->MsgFormatFrame(&wp);
|
|---|
| 367 |
|
|---|
| 368 | //CB: todo: use result for WM_CALCVALIDRECTS
|
|---|
| 369 | mapWin32ToOS2RectFrame(win32wnd, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
|
|---|
| 370 |
|
|---|
| 371 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 372 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 373 |
|
|---|
| 374 | if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
|
|---|
| 375 | {
|
|---|
| 376 | //redraw the frame (to prevent unnecessary client updates)
|
|---|
| 377 | BOOL redrawAll = FALSE;
|
|---|
| 378 |
|
|---|
| 379 | if (win32wnd->getWindowClass())
|
|---|
| 380 | {
|
|---|
| 381 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
|---|
| 382 |
|
|---|
| 383 | if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
|
|---|
| 384 | redrawAll = TRUE;
|
|---|
| 385 | else if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
|
|---|
| 386 | redrawAll = TRUE;
|
|---|
| 387 | } else redrawAll = TRUE;
|
|---|
| 388 |
|
|---|
| 389 | if (redrawAll)
|
|---|
| 390 | {
|
|---|
| 391 | //CB: redraw all children for now
|
|---|
| 392 | // -> problems with update region if we don't do it
|
|---|
| 393 | // todo: rewrite whole handling
|
|---|
| 394 | WinInvalidateRect(hwnd,NULL,TRUE);
|
|---|
| 395 | }
|
|---|
| 396 | else
|
|---|
| 397 | {
|
|---|
| 398 | HPS hps = WinGetPS(hwnd);
|
|---|
| 399 | RECTL frame,client,arcl[4];
|
|---|
| 400 |
|
|---|
| 401 | WinQueryWindowRect(hwnd,&frame);
|
|---|
| 402 | //top
|
|---|
| 403 | arcl[0].xLeft = 0;
|
|---|
| 404 | arcl[0].xRight = frame.xRight;
|
|---|
| 405 | arcl[0].yBottom = rect.yTop;
|
|---|
| 406 | arcl[0].yTop = frame.yTop;
|
|---|
| 407 | //right
|
|---|
| 408 | arcl[1].xLeft = rect.xRight;
|
|---|
| 409 | arcl[1].xRight = frame.xRight;
|
|---|
| 410 | arcl[1].yBottom = 0;
|
|---|
| 411 | arcl[1].yTop = frame.yTop;
|
|---|
| 412 | //left
|
|---|
| 413 | arcl[2].xLeft = 0;
|
|---|
| 414 | arcl[2].xRight = rect.xLeft;
|
|---|
| 415 | arcl[2].yBottom = 0;
|
|---|
| 416 | arcl[2].yTop = frame.yTop;
|
|---|
| 417 | //bottom
|
|---|
| 418 | arcl[3].xLeft = 0;
|
|---|
| 419 | arcl[3].xRight = frame.xRight;
|
|---|
| 420 | arcl[3].yBottom = 0;
|
|---|
| 421 | arcl[3].yTop = rect.yBottom;
|
|---|
| 422 |
|
|---|
| 423 | HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
|
|---|
| 424 |
|
|---|
| 425 | WinInvalidateRegion(hwnd,hrgn,FALSE);
|
|---|
| 426 | GpiDestroyRegion(hps,hrgn);
|
|---|
| 427 | WinReleasePS(hps);
|
|---|
| 428 | }
|
|---|
| 429 | }
|
|---|
| 430 | }
|
|---|
| 431 | else
|
|---|
| 432 | {
|
|---|
| 433 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 434 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 435 | }
|
|---|
| 436 |
|
|---|
| 437 | PosChangedEnd:
|
|---|
| 438 | RestoreOS2TIB();
|
|---|
| 439 | return (MRESULT)FALSE;
|
|---|
| 440 | }
|
|---|
| 441 |
|
|---|
| 442 | case WM_ACTIVATE:
|
|---|
| 443 | {
|
|---|
| 444 | USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
|
|---|
| 445 |
|
|---|
| 446 | dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
|
|---|
| 447 |
|
|---|
| 448 | if(win32wnd->IsWindowCreated())
|
|---|
| 449 | {
|
|---|
| 450 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
|---|
| 451 | win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
|
|---|
| 452 |
|
|---|
| 453 | //CB: show owner behind the dialog
|
|---|
| 454 | if(win32wnd->IsModalDialog())
|
|---|
| 455 | {
|
|---|
| 456 | Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
|
|---|
| 457 |
|
|---|
| 458 | if(topOwner) WinSetWindowPos(topOwner->getOS2WindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
|
|---|
| 459 | }
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | break;
|
|---|
| 463 | }
|
|---|
| 464 |
|
|---|
| 465 | case WM_SIZE:
|
|---|
| 466 | {
|
|---|
| 467 | dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp2)));
|
|---|
| 468 | break;
|
|---|
| 469 | }
|
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 | case WM_MINMAXFRAME:
|
|---|
| 473 | {
|
|---|
| 474 | PSWP swp = (PSWP)mp1;
|
|---|
| 475 |
|
|---|
| 476 | if (!win32wnd->IsWindowCreated()) goto RunDefFrameProc;
|
|---|
| 477 | dprintf(("OS2: WM_MINMAXFRAME %x",hwnd));
|
|---|
| 478 | if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
|---|
| 479 | {
|
|---|
| 480 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MINIMIZE_W) | WS_MAXIMIZE_W);
|
|---|
| 481 |
|
|---|
| 482 | RECT rect;
|
|---|
| 483 |
|
|---|
| 484 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
|---|
| 485 | win32wnd->AdjustMaximizedRect(&rect);
|
|---|
| 486 | swp->x += rect.left;
|
|---|
| 487 | swp->cx += rect.right-rect.left;
|
|---|
| 488 | swp->y -= rect.bottom;
|
|---|
| 489 | swp->cy += rect.bottom-rect.top;
|
|---|
| 490 | }
|
|---|
| 491 | else if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
|
|---|
| 492 | {
|
|---|
| 493 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
|
|---|
| 494 | }
|
|---|
| 495 | else if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
|
|---|
| 496 | {
|
|---|
| 497 | win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
|
|---|
| 498 | }
|
|---|
| 499 | goto RunDefFrameProc;
|
|---|
| 500 | }
|
|---|
| 501 |
|
|---|
| 502 | case WM_OWNERPOSCHANGE:
|
|---|
| 503 | {
|
|---|
| 504 | dprintf(("OS2: WM_OWNERPOSCHANGE"));
|
|---|
| 505 | goto RunDefWndProc;
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | case WM_CALCVALIDRECTS:
|
|---|
| 509 | #if 0
|
|---|
| 510 | {
|
|---|
| 511 | PRECTL oldRect = (PRECTL)mp1,newRect = oldRect+1;
|
|---|
| 512 | UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
|
|---|
| 513 |
|
|---|
| 514 | //CB: todo: use WM_NCCALCSIZE result
|
|---|
| 515 | if (win32wnd->getWindowClass())
|
|---|
| 516 | {
|
|---|
| 517 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
|---|
| 518 |
|
|---|
| 519 | if ((dwStyle & CS_HREDRAW_W) && (newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft))
|
|---|
| 520 | res |= CVR_REDRAW;
|
|---|
| 521 | else if ((dwStyle & CS_VREDRAW_W) && (newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom))
|
|---|
| 522 | res |= CVR_REDRAW;
|
|---|
| 523 | } else res |= CVR_REDRAW;
|
|---|
| 524 |
|
|---|
| 525 | RestoreOS2TIB();
|
|---|
| 526 | return (MRESULT)res;
|
|---|
| 527 | }
|
|---|
| 528 | #else
|
|---|
| 529 | dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
|---|
| 530 | RestoreOS2TIB();
|
|---|
| 531 | return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
|---|
| 532 | #endif
|
|---|
| 533 |
|
|---|
| 534 | case WM_VRNENABLED:
|
|---|
| 535 | if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
|
|---|
| 536 | {
|
|---|
| 537 | HWND hwndrelated;
|
|---|
| 538 | Win32BaseWindow *topwindow;
|
|---|
| 539 |
|
|---|
| 540 | win32wnd->setComingToTop(TRUE);
|
|---|
| 541 |
|
|---|
| 542 | hwndrelated = WinQueryWindow(hwnd, QW_PREV);
|
|---|
| 543 | dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
|
|---|
| 544 | topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
|
|---|
| 545 | if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
|
|---|
| 546 | //put window at the top of z order
|
|---|
| 547 | WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
|
|---|
| 548 | }
|
|---|
| 549 |
|
|---|
| 550 | win32wnd->setComingToTop(FALSE);
|
|---|
| 551 | break;
|
|---|
| 552 | }
|
|---|
| 553 | goto RunDefWndProc;
|
|---|
| 554 |
|
|---|
| 555 | case WM_SETFOCUS:
|
|---|
| 556 | {
|
|---|
| 557 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 558 |
|
|---|
| 559 | dprintf(("OS2: WM_SETFOCUS %x %x %d", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 560 | if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
|
|---|
| 561 | //another (non-win32) application's window
|
|---|
| 562 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
|---|
| 563 | hwndFocus = NULL;
|
|---|
| 564 | }
|
|---|
| 565 | if((ULONG)mp2 == TRUE) {
|
|---|
| 566 | HWND hwndFocusWin32 = Win32BaseWindow::OS2ToWin32Handle(hwndFocus);
|
|---|
| 567 | recreateCaret (hwndFocusWin32);
|
|---|
| 568 | win32wnd->MsgSetFocus(hwndFocusWin32);
|
|---|
| 569 | }
|
|---|
| 570 | else win32wnd->MsgKillFocus(Win32BaseWindow::OS2ToWin32Handle(hwndFocus));
|
|---|
| 571 | break;
|
|---|
| 572 | }
|
|---|
| 573 |
|
|---|
| 574 | //**************************************************************************
|
|---|
| 575 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
|---|
| 576 | //**************************************************************************
|
|---|
| 577 | case WM_HITTEST:
|
|---|
| 578 | {
|
|---|
| 579 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 580 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 581 | }
|
|---|
| 582 | if(win32wnd && win32wnd->IsWindowCreated())
|
|---|
| 583 | {
|
|---|
| 584 | MRESULT rc;
|
|---|
| 585 |
|
|---|
| 586 | rc = (MRESULT)win32wnd->MsgHitTest(pWinMsg);
|
|---|
| 587 | RestoreOS2TIB();
|
|---|
| 588 | return rc;
|
|---|
| 589 | }
|
|---|
| 590 | return (MRESULT)HT_NORMAL;
|
|---|
| 591 | }
|
|---|
| 592 |
|
|---|
| 593 | case WM_BUTTON1DOWN:
|
|---|
| 594 | case WM_BUTTON1UP:
|
|---|
| 595 | case WM_BUTTON1DBLCLK:
|
|---|
| 596 | case WM_BUTTON2DOWN:
|
|---|
| 597 | case WM_BUTTON2UP:
|
|---|
| 598 | case WM_BUTTON2DBLCLK:
|
|---|
| 599 | case WM_BUTTON3DOWN:
|
|---|
| 600 | case WM_BUTTON3UP:
|
|---|
| 601 | case WM_BUTTON3DBLCLK:
|
|---|
| 602 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 603 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 604 | }
|
|---|
| 605 | if(win32wnd)
|
|---|
| 606 | win32wnd->MsgButton(pWinMsg);
|
|---|
| 607 | rc = TRUE;
|
|---|
| 608 | break;
|
|---|
| 609 |
|
|---|
| 610 | case WM_BUTTON2MOTIONSTART:
|
|---|
| 611 | case WM_BUTTON2MOTIONEND:
|
|---|
| 612 | case WM_BUTTON2CLICK:
|
|---|
| 613 | case WM_BUTTON1MOTIONSTART:
|
|---|
| 614 | case WM_BUTTON1MOTIONEND:
|
|---|
| 615 | case WM_BUTTON1CLICK:
|
|---|
| 616 | case WM_BUTTON3MOTIONSTART:
|
|---|
| 617 | case WM_BUTTON3MOTIONEND:
|
|---|
| 618 | case WM_BUTTON3CLICK:
|
|---|
| 619 | rc = TRUE;
|
|---|
| 620 | break;
|
|---|
| 621 |
|
|---|
| 622 | case WM_MOUSEMOVE:
|
|---|
| 623 | {
|
|---|
| 624 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 625 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 626 | }
|
|---|
| 627 | if(win32wnd)
|
|---|
| 628 | win32wnd->MsgMouseMove(pWinMsg);
|
|---|
| 629 | break;
|
|---|
| 630 | }
|
|---|
| 631 |
|
|---|
| 632 | case WM_CONTROL:
|
|---|
| 633 | goto RunDefWndProc;
|
|---|
| 634 |
|
|---|
| 635 | case WM_COMMAND:
|
|---|
| 636 | dprintf(("OS2: WM_COMMAND %x %x %x", hwnd, mp1, mp2));
|
|---|
| 637 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 638 | break;
|
|---|
| 639 |
|
|---|
| 640 | case WM_SYSCOMMAND:
|
|---|
| 641 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 642 | break;
|
|---|
| 643 |
|
|---|
| 644 | case WM_CHAR:
|
|---|
| 645 | win32wnd->MsgChar(pWinMsg);
|
|---|
| 646 | break;
|
|---|
| 647 |
|
|---|
| 648 | case WM_TIMER:
|
|---|
| 649 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 650 | goto RunDefWndProc;
|
|---|
| 651 |
|
|---|
| 652 | case WM_SETWINDOWPARAMS:
|
|---|
| 653 | {
|
|---|
| 654 | WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
|
|---|
| 655 |
|
|---|
| 656 | dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
|
|---|
| 657 | if(wndParams->fsStatus & WPM_TEXT) {
|
|---|
| 658 | win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
|
|---|
| 659 | }
|
|---|
| 660 | goto RunDefWndProc;
|
|---|
| 661 | }
|
|---|
| 662 |
|
|---|
| 663 | case WM_QUERYWINDOWPARAMS:
|
|---|
| 664 | {
|
|---|
| 665 | PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
|
|---|
| 666 | ULONG textlen;
|
|---|
| 667 | PSZ wintext;
|
|---|
| 668 |
|
|---|
| 669 | if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
|
|---|
| 670 | {
|
|---|
| 671 | if(wndpars->fsStatus & WPM_TEXT)
|
|---|
| 672 | win32wnd->MsgGetText(wndpars->pszText, wndpars->cchText);
|
|---|
| 673 | if(wndpars->fsStatus & WPM_CCHTEXT)
|
|---|
| 674 | wndpars->cchText = win32wnd->MsgGetTextLength();
|
|---|
| 675 |
|
|---|
| 676 | wndpars->fsStatus = 0;
|
|---|
| 677 | wndpars->cbCtlData = 0;
|
|---|
| 678 | wndpars->cbPresParams = 0;
|
|---|
| 679 | RestoreOS2TIB();
|
|---|
| 680 | return (MRESULT)TRUE;
|
|---|
| 681 | }
|
|---|
| 682 | goto RunDefWndProc;
|
|---|
| 683 | }
|
|---|
| 684 |
|
|---|
| 685 | case WM_PAINT:
|
|---|
| 686 | {
|
|---|
| 687 | RECTL rectl;
|
|---|
| 688 |
|
|---|
| 689 | WinQueryUpdateRect(hwnd, &rectl);
|
|---|
| 690 | dprintf(("OS2: WM_PAINT (%d,%d) (%d,%d)", rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
|
|---|
| 691 | if(win32wnd->IsWindowCreated())
|
|---|
| 692 | {
|
|---|
| 693 | PRECT pClient = win32wnd->getClientRectPtr();
|
|---|
| 694 | PRECT pWindow = win32wnd->getWindowRect();
|
|---|
| 695 |
|
|---|
| 696 | if(!(pClient->left == 0 && pClient->top == 0 &&
|
|---|
| 697 | win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
|
|---|
| 698 | win32wnd->getClientWidth() == win32wnd->getWindowWidth()))
|
|---|
| 699 | {
|
|---|
| 700 | win32wnd->MsgNCPaint();
|
|---|
| 701 | }
|
|---|
| 702 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 703 | }
|
|---|
| 704 | //SvL: Not calling the default window procedure causes all sorts of
|
|---|
| 705 | // strange problems (redraw & hanging app)
|
|---|
| 706 | // -> check what WinBeginPaint does what we're forgetting in BeginPaint
|
|---|
| 707 | // WinQueryUpdateRect(hwnd, &rectl);
|
|---|
| 708 | // if(rectl.xLeft == 0 && rectl.yTop == 0 && rectl.xRight == 0 && rectl.yBottom == 0) {
|
|---|
| 709 | // RestoreOS2TIB();
|
|---|
| 710 | // return (MRESULT)FALSE;
|
|---|
| 711 | // }
|
|---|
| 712 | // dprintf(("Update rectangle (%d,%d)(%d,%d) not empty, msg %x", rectl.xLeft, rectl.yTop, rectl.xRight, rectl.yBottom, pWinMsg->message));
|
|---|
| 713 | goto RunDefWndProc;
|
|---|
| 714 | // break;
|
|---|
| 715 | }
|
|---|
| 716 |
|
|---|
| 717 | case WM_ERASEBACKGROUND:
|
|---|
| 718 | {
|
|---|
| 719 | dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
|---|
| 720 | RestoreOS2TIB();
|
|---|
| 721 | return (MRESULT)FALSE;
|
|---|
| 722 | }
|
|---|
| 723 |
|
|---|
| 724 | #if 0
|
|---|
| 725 | case WM_CONTEXTMENU:
|
|---|
| 726 | {
|
|---|
| 727 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 728 |
|
|---|
| 729 | RestoreOS2TIB();
|
|---|
| 730 | return (MRESULT)TRUE;
|
|---|
| 731 | }
|
|---|
| 732 | #endif
|
|---|
| 733 |
|
|---|
| 734 | case WM_FOCUSCHANGE:
|
|---|
| 735 | dprintf(("OS2: WM_FOCUSCHANGE %x", win32wnd->getWindowHandle()));
|
|---|
| 736 | goto RunDefWndProc;
|
|---|
| 737 |
|
|---|
| 738 | case WM_QUERYTRACKINFO:
|
|---|
| 739 | {
|
|---|
| 740 | PTRACKINFO trackInfo = (PTRACKINFO)mp2;
|
|---|
| 741 |
|
|---|
| 742 | dprintf(("OS2: WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
|
|---|
| 743 | RestoreOS2TIB();
|
|---|
| 744 | PMFrameWindowProc(hwnd,msg,mp1,mp2);
|
|---|
| 745 | SetWin32TIB();
|
|---|
| 746 | trackInfo->cxBorder = 4;
|
|---|
| 747 | trackInfo->cyBorder = 4;
|
|---|
| 748 | win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
|
|---|
| 749 | RestoreOS2TIB();
|
|---|
| 750 | return (MRESULT)TRUE;
|
|---|
| 751 | }
|
|---|
| 752 |
|
|---|
| 753 | case WM_QUERYBORDERSIZE:
|
|---|
| 754 | {
|
|---|
| 755 | PWPOINT size = (PWPOINT)mp1;
|
|---|
| 756 |
|
|---|
| 757 | dprintf(("OS2: WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
|
|---|
| 758 |
|
|---|
| 759 | size->x = 0;
|
|---|
| 760 | size->y = 0;
|
|---|
| 761 | RestoreOS2TIB();
|
|---|
| 762 | return (MRESULT)TRUE;
|
|---|
| 763 | }
|
|---|
| 764 |
|
|---|
| 765 | case WM_FORMATFRAME:
|
|---|
| 766 | dprintf(("OS2: WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
|
|---|
| 767 | break;
|
|---|
| 768 |
|
|---|
| 769 | #if 0
|
|---|
| 770 | case WM_ADJUSTFRAMEPOS:
|
|---|
| 771 | dprintf(("OS2: WM_ADJUSTFRAMEPOS %x", win32wnd->getWindowHandle()));
|
|---|
| 772 | break;
|
|---|
| 773 |
|
|---|
| 774 | case WM_QUERYFRAMEINFO:
|
|---|
| 775 | dprintf(("OS2: WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
|
|---|
| 776 | return (MRESULT)(FI_FRAME|FI_ACTIVATEOK);
|
|---|
| 777 |
|
|---|
| 778 | case WM_QUERYFOCUSCHAIN:
|
|---|
| 779 | {
|
|---|
| 780 | USHORT fsCmd = SHORT1FROMMP(mp1);
|
|---|
| 781 |
|
|---|
| 782 | dprintf(("OS2: WM_QUERYFOCUSCHAIN %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 783 | switch(fsCmd) {
|
|---|
| 784 | case QFC_NEXTINCHAIN:
|
|---|
| 785 | break;
|
|---|
| 786 | case QFC_ACTIVE:
|
|---|
| 787 | case QFC_FRAME:
|
|---|
| 788 | if(win32wnd->GetTopParent()) {
|
|---|
| 789 | dprintf(("Frame = %x", win32wnd->GetTopParent()->getOS2WindowHandle()));
|
|---|
| 790 | return (MRESULT)win32wnd->GetTopParent()->getOS2WindowHandle();
|
|---|
| 791 | }
|
|---|
| 792 | break;
|
|---|
| 793 | case QFC_SELECTACTIVE:
|
|---|
| 794 | break;
|
|---|
| 795 | case QFC_PARTOFCHAIN:
|
|---|
| 796 | return (MRESULT)TRUE;
|
|---|
| 797 | }
|
|---|
| 798 | break;
|
|---|
| 799 | }
|
|---|
| 800 | #endif
|
|---|
| 801 |
|
|---|
| 802 | case WM_INITMENU:
|
|---|
| 803 | case WM_MENUSELECT:
|
|---|
| 804 | case WM_MENUEND:
|
|---|
| 805 | case WM_NEXTMENU:
|
|---|
| 806 | case WM_SYSCOLORCHANGE:
|
|---|
| 807 | case WM_SYSVALUECHANGED:
|
|---|
| 808 | case WM_SETSELECTION:
|
|---|
| 809 | case WM_PPAINT:
|
|---|
| 810 | case WM_PSETFOCUS:
|
|---|
| 811 | case WM_PSYSCOLORCHANGE:
|
|---|
| 812 | case WM_PSIZE:
|
|---|
| 813 | case WM_PACTIVATE:
|
|---|
| 814 | case WM_PCONTROL:
|
|---|
| 815 | case WM_HELP:
|
|---|
| 816 | case WM_APPTERMINATENOTIFY:
|
|---|
| 817 | case WM_PRESPARAMCHANGED:
|
|---|
| 818 | case WM_DRAWITEM:
|
|---|
| 819 | case WM_MEASUREITEM:
|
|---|
| 820 | case WM_CONTROLPOINTER:
|
|---|
| 821 | case WM_QUERYDLGCODE:
|
|---|
| 822 | case WM_SUBSTITUTESTRING:
|
|---|
| 823 | case WM_MATCHMNEMONIC:
|
|---|
| 824 | case WM_SAVEAPPLICATION:
|
|---|
| 825 | case WM_SEMANTICEVENT:
|
|---|
| 826 | default:
|
|---|
| 827 | // dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
|
|---|
| 828 | RestoreOS2TIB();
|
|---|
| 829 | return PMFrameWindowProc(hwnd, msg, mp1, mp2);
|
|---|
| 830 | // return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 831 | }
|
|---|
| 832 | RestoreOS2TIB();
|
|---|
| 833 | return (MRESULT)rc;
|
|---|
| 834 |
|
|---|
| 835 | RunDefFrameProc:
|
|---|
| 836 | RestoreOS2TIB();
|
|---|
| 837 | return PMFrameWindowProc(hwnd, msg, mp1, mp2);
|
|---|
| 838 |
|
|---|
| 839 | RunDefWndProc:
|
|---|
| 840 | // dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
|
|---|
| 841 | RestoreOS2TIB();
|
|---|
| 842 | return PMFrameWindowProc(hwnd, msg, mp1, mp2);
|
|---|
| 843 | // return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 844 | } /* End of Win32WindowProc */
|
|---|
| 845 | //******************************************************************************
|
|---|
| 846 | //TODO: Quickly moving a window two times doesn't force a repaint (1st time)
|
|---|
| 847 | //******************************************************************************
|
|---|
| 848 | VOID FrameTrackFrame(Win32BaseWindow *win32wnd,DWORD flags)
|
|---|
| 849 | {
|
|---|
| 850 | TRACKINFO track;
|
|---|
| 851 | RECTL rcl;
|
|---|
| 852 | PRECT pWindowRect;
|
|---|
| 853 | HWND hwndTracking;
|
|---|
| 854 | HPS hpsTrack;
|
|---|
| 855 | LONG parentHeight, parentWidth;
|
|---|
| 856 |
|
|---|
| 857 | track.cxBorder = 4;
|
|---|
| 858 | track.cyBorder = 4; /* 4 pel wide lines used for rectangle */
|
|---|
| 859 | track.cxGrid = 1;
|
|---|
| 860 | track.cyGrid = 1; /* smooth tracking with mouse */
|
|---|
| 861 | track.cxKeyboard = 8;
|
|---|
| 862 | track.cyKeyboard = 8; /* faster tracking using cursor keys */
|
|---|
| 863 |
|
|---|
| 864 | pWindowRect = win32wnd->getWindowRect();
|
|---|
| 865 | if(win32wnd->getParent()) {
|
|---|
| 866 | parentHeight = win32wnd->getParent()->getWindowHeight();
|
|---|
| 867 | parentWidth = win32wnd->getParent()->getWindowWidth();
|
|---|
| 868 | hwndTracking = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 869 | hpsTrack = WinGetPS(hwndTracking);
|
|---|
| 870 | }
|
|---|
| 871 | else {
|
|---|
| 872 | parentHeight = OSLibQueryScreenHeight();
|
|---|
| 873 | parentWidth = OSLibQueryScreenWidth();
|
|---|
| 874 | hwndTracking = HWND_DESKTOP;
|
|---|
| 875 | hpsTrack = NULL;
|
|---|
| 876 | }
|
|---|
| 877 |
|
|---|
| 878 | rcl.xLeft = pWindowRect->left;
|
|---|
| 879 | rcl.yTop = OSLibQueryScreenHeight() - pWindowRect->top;
|
|---|
| 880 | rcl.xRight = pWindowRect->right;
|
|---|
| 881 | rcl.yBottom = OSLibQueryScreenHeight() - pWindowRect->bottom;
|
|---|
| 882 | if(hwndTracking != HWND_DESKTOP) {
|
|---|
| 883 | WinMapWindowPoints(win32wnd->getOS2WindowHandle(), HWND_DESKTOP, (PPOINTL)&rcl, 2);
|
|---|
| 884 | }
|
|---|
| 885 | WinCopyRect(hab, &track.rclTrack, &rcl); /* starting point */
|
|---|
| 886 |
|
|---|
| 887 | WinSetRect(hab, &track.rclBoundary, 0, 0, parentWidth, parentHeight); /* bounding rectangle */
|
|---|
| 888 |
|
|---|
| 889 | track.ptlMinTrackSize.x = 10;
|
|---|
| 890 | track.ptlMinTrackSize.y = 10; /* set smallest allowed size of rectangle */
|
|---|
| 891 | track.ptlMaxTrackSize.x = parentWidth;
|
|---|
| 892 | track.ptlMaxTrackSize.y = parentHeight; /* set largest allowed size of rectangle */
|
|---|
| 893 |
|
|---|
| 894 | win32wnd->AdjustTrackInfo((PPOINT)&track.ptlMinTrackSize, (PPOINT)&track.ptlMaxTrackSize);
|
|---|
| 895 |
|
|---|
| 896 | track.fs = flags;
|
|---|
| 897 |
|
|---|
| 898 | if(WinTrackRect(HWND_DESKTOP, NULL, &track) )
|
|---|
| 899 | {
|
|---|
| 900 | if(hpsTrack) WinReleasePS(hpsTrack);
|
|---|
| 901 |
|
|---|
| 902 | /* if successful copy final position back */
|
|---|
| 903 | if(!WinEqualRect(0, &rcl, &track.rclTrack)) {
|
|---|
| 904 | if(flags == TF_MOVE) {
|
|---|
| 905 | WinSetWindowPos(win32wnd->getOS2WindowHandle(),
|
|---|
| 906 | 0, track.rclTrack.xLeft, track.rclTrack.yBottom,
|
|---|
| 907 | 0, 0, SWP_MOVE);
|
|---|
| 908 | }
|
|---|
| 909 | else {
|
|---|
| 910 | WinSetWindowPos(win32wnd->getOS2WindowHandle(),
|
|---|
| 911 | 0, track.rclTrack.xLeft, track.rclTrack.yBottom,
|
|---|
| 912 | track.rclTrack.xRight - track.rclTrack.xLeft,
|
|---|
| 913 | track.rclTrack.yTop - track.rclTrack.yBottom,
|
|---|
| 914 | SWP_SIZE|SWP_MOVE);
|
|---|
| 915 | }
|
|---|
| 916 | }
|
|---|
| 917 | return;
|
|---|
| 918 | }
|
|---|
| 919 | if(hpsTrack) WinReleasePS(hpsTrack);
|
|---|
| 920 | return;
|
|---|
| 921 | }
|
|---|
| 922 | //******************************************************************************
|
|---|
| 923 | //******************************************************************************
|
|---|