| 1 | /* $Id: pmwindow.cpp,v 1.113 2001-02-15 00:33:01 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 Window Managment Code for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1998-2000 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 <win32api.h>
|
|---|
| 24 | #include <winconst.h>
|
|---|
| 25 | #include <winuser32.h>
|
|---|
| 26 | #include <wprocess.h>
|
|---|
| 27 | #include <misc.h>
|
|---|
| 28 | #include <win32wbase.h>
|
|---|
| 29 | #include <win32dlg.h>
|
|---|
| 30 | #include "win32wdesktop.h"
|
|---|
| 31 | #include "pmwindow.h"
|
|---|
| 32 | #include "oslibwin.h"
|
|---|
| 33 | #include "oslibutil.h"
|
|---|
| 34 | #include "oslibgdi.h"
|
|---|
| 35 | #include "oslibmsg.h"
|
|---|
| 36 | #include "dc.h"
|
|---|
| 37 | #include <thread.h>
|
|---|
| 38 | #include <wprocess.h>
|
|---|
| 39 | #include "caret.h"
|
|---|
| 40 | #include "timer.h"
|
|---|
| 41 | #include <codepage.h>
|
|---|
| 42 |
|
|---|
| 43 | #define DBG_LOCALLOG DBG_pmwindow
|
|---|
| 44 | #include "dbglocal.h"
|
|---|
| 45 |
|
|---|
| 46 | HMQ hmq = 0; /* Message queue handle */
|
|---|
| 47 | HAB hab = 0;
|
|---|
| 48 |
|
|---|
| 49 | RECTL desktopRectl = {0};
|
|---|
| 50 | ULONG ScreenWidth = 0;
|
|---|
| 51 | ULONG ScreenHeight = 0;
|
|---|
| 52 | ULONG ScreenBitsPerPel = 0;
|
|---|
| 53 |
|
|---|
| 54 | static PFNWP pfnFrameWndProc = NULL;
|
|---|
| 55 |
|
|---|
| 56 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
|---|
| 57 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
|---|
| 58 | MRESULT ProcessPMMessage(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, Win32BaseWindow *win32wnd,
|
|---|
| 59 | MSG *pWinMsg, TEB *teb, BOOL isFrame);
|
|---|
| 60 |
|
|---|
| 61 | //******************************************************************************
|
|---|
| 62 | //Initialize PM; create hab, message queue and register special Win32 window classes
|
|---|
| 63 | //******************************************************************************
|
|---|
| 64 | BOOL InitPM()
|
|---|
| 65 | {
|
|---|
| 66 |
|
|---|
| 67 | hab = WinInitialize(0);
|
|---|
| 68 | dprintf(("Winitialize returned %x", hab));
|
|---|
| 69 | hmq = WinCreateMsgQueue(hab, 0);
|
|---|
| 70 |
|
|---|
| 71 | if(!hab || !hmq)
|
|---|
| 72 | {
|
|---|
| 73 | UINT error;
|
|---|
| 74 | //CB: only fail on real error
|
|---|
| 75 | error = WinGetLastError(hab) & 0xFFFF; //error code
|
|---|
| 76 | if (!hab || (error != PMERR_MSG_QUEUE_ALREADY_EXISTS))
|
|---|
| 77 | {
|
|---|
| 78 | dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
|
|---|
| 79 | dprintf((" Error = %x",error));
|
|---|
| 80 | return(FALSE);
|
|---|
| 81 | }
|
|---|
| 82 | else
|
|---|
| 83 | {
|
|---|
| 84 | if(!hab) {
|
|---|
| 85 | hab = WinQueryAnchorBlock(HWND_DESKTOP);
|
|---|
| 86 | dprintf(("WinQueryAnchorBlock returned %x", hab));
|
|---|
| 87 | }
|
|---|
| 88 | if(!hmq) {
|
|---|
| 89 | hmq = HMQ_CURRENT;
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|
| 92 | }
|
|---|
| 93 | SetThreadHAB(hab);
|
|---|
| 94 | dprintf(("InitPM: hmq = %x", hmq));
|
|---|
| 95 | SetThreadMessageQueue(hmq);
|
|---|
| 96 |
|
|---|
| 97 | BOOL rc = WinSetCp(hmq, GetDisplayCodepage());
|
|---|
| 98 | dprintf(("InitPM: WinSetCP was %sOK", rc ? "" : "not "));
|
|---|
| 99 |
|
|---|
| 100 | if(!WinRegisterClass( /* Register window class */
|
|---|
| 101 | hab, /* Anchor block handle */
|
|---|
| 102 | (PSZ)WIN32_STDCLASS, /* Window class name */
|
|---|
| 103 | (PFNWP)Win32WindowProc, /* Address of window procedure */
|
|---|
| 104 | CS_HITTEST,
|
|---|
| 105 | NROF_WIN32WNDBYTES))
|
|---|
| 106 | {
|
|---|
| 107 | dprintf(("WinRegisterClass Win32BaseWindow failed"));
|
|---|
| 108 | return(FALSE);
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | CLASSINFO FrameClassInfo;
|
|---|
| 112 | if(!WinQueryClassInfo (hab, WC_FRAME, &FrameClassInfo)) {
|
|---|
| 113 | dprintf (("WinQueryClassInfo WC_FRAME failed"));
|
|---|
| 114 | return (FALSE);
|
|---|
| 115 | }
|
|---|
| 116 | pfnFrameWndProc = FrameClassInfo.pfnWindowProc;
|
|---|
| 117 |
|
|---|
| 118 | dprintf(("WC_FRAME style %x", FrameClassInfo.flClassStyle));
|
|---|
| 119 |
|
|---|
| 120 | if(!WinRegisterClass( /* Register window class */
|
|---|
| 121 | hab, /* Anchor block handle */
|
|---|
| 122 | (PSZ)WIN32_STDFRAMECLASS, /* Window class name */
|
|---|
| 123 | (PFNWP)Win32FrameWindowProc, /* Address of window procedure */
|
|---|
| 124 | CS_HITTEST | CS_FRAME,
|
|---|
| 125 | FrameClassInfo.cbWindowData+NROF_WIN32WNDBYTES))
|
|---|
| 126 | {
|
|---|
| 127 | dprintf(("WinRegisterClass Win32BaseWindow failed %x", WinGetLastError(hab)));
|
|---|
| 128 | return(FALSE);
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
|
|---|
| 132 | ScreenWidth = desktopRectl.xRight;
|
|---|
| 133 | ScreenHeight = desktopRectl.yTop;
|
|---|
| 134 |
|
|---|
| 135 | HDC hdc; /* Device-context handle */
|
|---|
| 136 | /* context data structure */
|
|---|
| 137 | DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
|
|---|
| 138 | NULL, NULL, NULL};
|
|---|
| 139 |
|
|---|
| 140 | /* create memory device context */
|
|---|
| 141 | hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
|
|---|
| 142 | DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, (PLONG)&ScreenBitsPerPel);
|
|---|
| 143 | DevCloseDC(hdc);
|
|---|
| 144 |
|
|---|
| 145 | dprintf(("InitPM: Desktop (%d,%d)", ScreenWidth, ScreenHeight));
|
|---|
| 146 | return TRUE;
|
|---|
| 147 | } /* End of main */
|
|---|
| 148 | //******************************************************************************
|
|---|
| 149 | //Win32 window message handler
|
|---|
| 150 | //******************************************************************************
|
|---|
| 151 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 152 | {
|
|---|
| 153 | Win32BaseWindow *win32wnd;
|
|---|
| 154 | TEB *teb;
|
|---|
| 155 | MSG winMsg, *pWinMsg;
|
|---|
| 156 | MRESULT rc = 0;
|
|---|
| 157 |
|
|---|
| 158 | //Restore our FS selector
|
|---|
| 159 | SetWin32TIB();
|
|---|
| 160 |
|
|---|
| 161 | //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
|
|---|
| 162 | teb = GetThreadTEB();
|
|---|
| 163 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 164 |
|
|---|
| 165 | if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
|
|---|
| 166 | dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
|
|---|
| 167 | goto RunDefWndProc;
|
|---|
| 168 | }
|
|---|
| 169 | //// if(teb->o.odin.fIgnoreMsgs) {
|
|---|
| 170 | //// goto RunDefWndProc;
|
|---|
| 171 | //// }
|
|---|
| 172 |
|
|---|
| 173 | if((teb->o.odin.msgstate & 1) == 0)
|
|---|
| 174 | {//message that was sent directly to our window proc handler; translate it here
|
|---|
| 175 | QMSG qmsg;
|
|---|
| 176 |
|
|---|
| 177 | qmsg.msg = msg;
|
|---|
| 178 | qmsg.hwnd = hwnd;
|
|---|
| 179 | qmsg.mp1 = mp1;
|
|---|
| 180 | qmsg.mp2 = mp2;
|
|---|
| 181 | qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
|
|---|
| 182 | WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
|
|---|
| 183 | qmsg.reserved = 0;
|
|---|
| 184 |
|
|---|
| 185 | if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
|---|
| 186 | {//message was not translated
|
|---|
| 187 | memset(&winMsg, 0, sizeof(MSG));
|
|---|
| 188 | }
|
|---|
| 189 | pWinMsg = &winMsg;
|
|---|
| 190 | }
|
|---|
| 191 | else {
|
|---|
| 192 | pWinMsg = &teb->o.odin.msg;
|
|---|
| 193 | teb->o.odin.msgstate++;
|
|---|
| 194 | }
|
|---|
| 195 | //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
|
|---|
| 196 | rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, FALSE);
|
|---|
| 197 | RestoreOS2TIB();
|
|---|
| 198 | return rc;
|
|---|
| 199 |
|
|---|
| 200 | RunDefWndProc:
|
|---|
| 201 | RestoreOS2TIB();
|
|---|
| 202 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 203 | }
|
|---|
| 204 | //******************************************************************************
|
|---|
| 205 | //******************************************************************************
|
|---|
| 206 | MRESULT ProcessPMMessage(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, Win32BaseWindow *win32wnd, MSG *pWinMsg, TEB *teb, BOOL isFrame)
|
|---|
| 207 | {
|
|---|
| 208 | POSTMSG_PACKET *postmsg;
|
|---|
| 209 | OSLIBPOINT point, ClientPoint;
|
|---|
| 210 | MRESULT rc = 0;
|
|---|
| 211 |
|
|---|
| 212 | if(msg == WIN32APP_POSTMSG) {
|
|---|
| 213 | //probably win32 app user message
|
|---|
| 214 | if((ULONG)mp1 == WIN32MSG_MAGICA) {
|
|---|
| 215 | return (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 216 | }
|
|---|
| 217 | else
|
|---|
| 218 | if((ULONG)mp1 == WIN32MSG_MAGICW) {
|
|---|
| 219 | return (MRESULT)win32wnd->DispatchMsgW(pWinMsg);
|
|---|
| 220 | }
|
|---|
| 221 | }
|
|---|
| 222 | else
|
|---|
| 223 | if(msg == WIN32APP_SETFOCUSMSG) {
|
|---|
| 224 | //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
|
|---|
| 225 | //must delay this function call
|
|---|
| 226 | //mp1 = win32 window handle
|
|---|
| 227 | //mp2 = activate flag
|
|---|
| 228 | dprintf(("USER32: Delayed SetFocus %x call!", mp1));
|
|---|
| 229 | teb->o.odin.hwndFocus = 0;
|
|---|
| 230 | WinFocusChange(HWND_DESKTOP, hwnd, mp2 ? FC_NOLOSEACTIVE : 0);
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | switch( msg )
|
|---|
| 234 | {
|
|---|
| 235 | //OS/2 msgs
|
|---|
| 236 | case WM_CREATE:
|
|---|
| 237 | {
|
|---|
| 238 | if(teb->o.odin.newWindow == 0)
|
|---|
| 239 | goto createfail;
|
|---|
| 240 |
|
|---|
| 241 | //Processing is done in after WinCreateWindow returns
|
|---|
| 242 | dprintf(("OS2: WM_CREATE %x", hwnd));
|
|---|
| 243 | win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
|
|---|
| 244 | teb->o.odin.newWindow = 0;
|
|---|
| 245 | if(win32wnd->MsgCreate(hwnd) == FALSE)
|
|---|
| 246 | {
|
|---|
| 247 | return (MRESULT)TRUE; //discontinue window creation
|
|---|
| 248 | }
|
|---|
| 249 | createfail:
|
|---|
| 250 | return (MRESULT)FALSE;
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | case WM_QUIT:
|
|---|
| 254 | dprintf(("OS2: WM_QUIT %x", hwnd));
|
|---|
| 255 | win32wnd->MsgQuit();
|
|---|
| 256 | break;
|
|---|
| 257 |
|
|---|
| 258 | case WM_CLOSE:
|
|---|
| 259 | dprintf(("OS2: WM_CLOSE %x", hwnd));
|
|---|
| 260 | win32wnd->MsgClose();
|
|---|
| 261 | break;
|
|---|
| 262 |
|
|---|
| 263 | case WM_DESTROY:
|
|---|
| 264 | dprintf(("OS2: WM_DESTROY %x", hwnd));
|
|---|
| 265 | win32wnd->MsgDestroy();
|
|---|
| 266 | WinSetVisibleRegionNotify(hwnd, FALSE);
|
|---|
| 267 | goto RunDefWndProc;
|
|---|
| 268 |
|
|---|
| 269 | case WM_ENABLE:
|
|---|
| 270 | dprintf(("OS2: WM_ENABLE %x", hwnd));
|
|---|
| 271 | win32wnd->MsgEnable(SHORT1FROMMP(mp1));
|
|---|
| 272 | break;
|
|---|
| 273 |
|
|---|
| 274 | case WM_SHOW:
|
|---|
| 275 | dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
|
|---|
| 276 | win32wnd->MsgShow((ULONG)mp1);
|
|---|
| 277 | break;
|
|---|
| 278 |
|
|---|
| 279 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 280 | {
|
|---|
| 281 | PSWP pswp = (PSWP)mp1;
|
|---|
| 282 | SWP swpOld;
|
|---|
| 283 | WINDOWPOS wp,wpOld;
|
|---|
| 284 | HWND hParent = NULLHANDLE, hwndAfter;
|
|---|
| 285 |
|
|---|
| 286 | 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));
|
|---|
| 287 |
|
|---|
| 288 | if(pswp->fl & SWP_NOADJUST) {
|
|---|
| 289 | //ignore weird messages (TODO: why are they sent?)
|
|---|
| 290 | break;
|
|---|
| 291 | }
|
|---|
| 292 | //CB: show dialog in front of owner
|
|---|
| 293 | if (win32wnd->IsModalDialogOwner())
|
|---|
| 294 | {
|
|---|
| 295 | dprintf(("win32wnd->IsModalDialogOwner %x", win32wnd->getWindowHandle()));
|
|---|
| 296 | pswp->fl |= SWP_ZORDER;
|
|---|
| 297 | pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
|
|---|
| 298 | if (pswp->fl & SWP_ACTIVATE)
|
|---|
| 299 | {
|
|---|
| 300 | pswp->fl &= ~SWP_ACTIVATE;
|
|---|
| 301 | WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
|
|---|
| 302 | }
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 306 | goto RunDefWndProc;
|
|---|
| 307 |
|
|---|
| 308 | if(!win32wnd->CanReceiveSizeMsgs())
|
|---|
| 309 | break;
|
|---|
| 310 |
|
|---|
| 311 | WinQueryWindowPos(hwnd, &swpOld);
|
|---|
| 312 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 313 | if (win32wnd->isChild()) {
|
|---|
| 314 | if(win32wnd->getParent()) {
|
|---|
| 315 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 316 | }
|
|---|
| 317 | else goto RunDefWndProc;
|
|---|
| 318 | }
|
|---|
| 319 | }
|
|---|
| 320 | hwndAfter = pswp->hwndInsertBehind;
|
|---|
| 321 | if(win32wnd->getParent()) {
|
|---|
| 322 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
|
|---|
| 323 | win32wnd->getParent()->getClientRectPtr()->left,
|
|---|
| 324 | win32wnd->getParent()->getClientRectPtr()->top,
|
|---|
| 325 | hwnd);
|
|---|
| 326 | }
|
|---|
| 327 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
|---|
| 328 |
|
|---|
| 329 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 330 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 331 | {
|
|---|
| 332 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 333 | if(wndAfter) {
|
|---|
| 334 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 335 | }
|
|---|
| 336 | else wp.hwndInsertAfter = HWND_TOP_W;
|
|---|
| 337 | }
|
|---|
| 338 |
|
|---|
| 339 | wpOld = wp;
|
|---|
| 340 | win32wnd->MsgPosChanging((LPARAM)&wp);
|
|---|
| 341 |
|
|---|
| 342 | if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
|
|---|
| 343 | (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
|
|---|
| 344 | {
|
|---|
| 345 | dprintf(("OS2: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
|---|
| 346 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 347 |
|
|---|
| 348 | if(win32wnd->getParent()) {
|
|---|
| 349 | OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getWindowHeight(),
|
|---|
| 350 | win32wnd->getParent()->getClientRectPtr()->left,
|
|---|
| 351 | win32wnd->getParent()->getClientRectPtr()->top,
|
|---|
| 352 | hwnd);
|
|---|
| 353 | }
|
|---|
| 354 | else OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
|---|
| 355 |
|
|---|
| 356 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 357 | pswp->fl |= SWP_NOADJUST;
|
|---|
| 358 | pswp->hwndInsertBehind = hwndAfter;
|
|---|
| 359 | pswp->hwnd = hwnd;
|
|---|
| 360 |
|
|---|
| 361 | return (MRESULT)0xf;
|
|---|
| 362 | }
|
|---|
| 363 | return (MRESULT)0;
|
|---|
| 364 | }
|
|---|
| 365 |
|
|---|
| 366 | case WM_WINDOWPOSCHANGED:
|
|---|
| 367 | {
|
|---|
| 368 | PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
|
|---|
| 369 | SWP swpOld = *(pswp + 1);
|
|---|
| 370 | WINDOWPOS wp;
|
|---|
| 371 | HWND hParent = NULLHANDLE;
|
|---|
| 372 | RECTL rect;
|
|---|
| 373 |
|
|---|
| 374 | dprintf(("OS2: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 375 |
|
|---|
| 376 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 377 | {
|
|---|
| 378 | if(pswp->fl & SWP_ACTIVATE)
|
|---|
| 379 | {
|
|---|
| 380 | //Only send PM WM_ACTIVATE to top-level windows (frame windows)
|
|---|
| 381 | if(!(WinQueryWindowUShort(hwnd,QWS_FLAGS) & FF_ACTIVE))
|
|---|
| 382 | {
|
|---|
| 383 | if(isFrame) {
|
|---|
| 384 | WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
|
|---|
| 385 | }
|
|---|
| 386 | else
|
|---|
| 387 | if(win32wnd->IsWindowCreated()) {
|
|---|
| 388 | win32wnd->MsgActivate(1, 0, win32wnd->getWindowHandle(), hwnd);
|
|---|
| 389 | }
|
|---|
| 390 | }
|
|---|
| 391 | }
|
|---|
| 392 | goto RunDefWndProc;
|
|---|
| 393 | }
|
|---|
| 394 |
|
|---|
| 395 | if(pswp->fl & (SWP_MOVE | SWP_SIZE))
|
|---|
| 396 | {
|
|---|
| 397 | if(win32wnd->isChild())
|
|---|
| 398 | {
|
|---|
| 399 | if(win32wnd->getParent()) {
|
|---|
| 400 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 401 | }
|
|---|
| 402 | else goto PosChangedEnd; //parent has just been destroyed
|
|---|
| 403 | }
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 |
|
|---|
| 407 | if(win32wnd->getParent()) {
|
|---|
| 408 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
|
|---|
| 409 | win32wnd->getParent()->getClientRectPtr()->left,
|
|---|
| 410 | win32wnd->getParent()->getClientRectPtr()->top,
|
|---|
| 411 | hwnd);
|
|---|
| 412 | }
|
|---|
| 413 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
|---|
| 414 |
|
|---|
| 415 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 416 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 417 | {
|
|---|
| 418 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 419 | if(wndAfter) {
|
|---|
| 420 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 421 | }
|
|---|
| 422 | else wp.hwndInsertAfter = HWND_TOP_W;
|
|---|
| 423 | }
|
|---|
| 424 |
|
|---|
| 425 | if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
|
|---|
| 426 | {
|
|---|
| 427 | //CB: todo: use result for WM_CALCVALIDRECTS
|
|---|
| 428 | //Get old client rectangle (for invalidation of frame window parts later on)
|
|---|
| 429 | mapWin32ToOS2Rect(win32wnd->getWindowHeight(), win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
|
|---|
| 430 |
|
|---|
| 431 | //Note: Also updates the new window rectangle
|
|---|
| 432 | win32wnd->MsgFormatFrame(&wp);
|
|---|
| 433 |
|
|---|
| 434 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 435 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 436 |
|
|---|
| 437 | if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
|
|---|
| 438 | {
|
|---|
| 439 | //redraw the frame (to prevent unnecessary client updates)
|
|---|
| 440 | BOOL redrawAll = FALSE;
|
|---|
| 441 |
|
|---|
| 442 | if (win32wnd->getWindowClass())
|
|---|
| 443 | {
|
|---|
| 444 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
|---|
| 445 |
|
|---|
| 446 | if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
|
|---|
| 447 | redrawAll = TRUE;
|
|---|
| 448 | else if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
|
|---|
| 449 | redrawAll = TRUE;
|
|---|
| 450 | } else redrawAll = TRUE;
|
|---|
| 451 |
|
|---|
| 452 | if (redrawAll)
|
|---|
| 453 | {
|
|---|
| 454 | //CB: redraw all children for now
|
|---|
| 455 | // -> problems with update region if we don't do it
|
|---|
| 456 | // todo: rewrite whole handling
|
|---|
| 457 | WinInvalidateRect(hwnd,NULL,TRUE);
|
|---|
| 458 | }
|
|---|
| 459 | else
|
|---|
| 460 | {
|
|---|
| 461 | HPS hps = WinGetPS(hwnd);
|
|---|
| 462 | RECTL frame,client,arcl[4];
|
|---|
| 463 |
|
|---|
| 464 | WinQueryWindowRect(hwnd,&frame);
|
|---|
| 465 | //top
|
|---|
| 466 | arcl[0].xLeft = 0;
|
|---|
| 467 | arcl[0].xRight = frame.xRight;
|
|---|
| 468 | arcl[0].yBottom = rect.yTop;
|
|---|
| 469 | arcl[0].yTop = frame.yTop;
|
|---|
| 470 | //right
|
|---|
| 471 | arcl[1].xLeft = rect.xRight;
|
|---|
| 472 | arcl[1].xRight = frame.xRight;
|
|---|
| 473 | arcl[1].yBottom = 0;
|
|---|
| 474 | arcl[1].yTop = frame.yTop;
|
|---|
| 475 | //left
|
|---|
| 476 | arcl[2].xLeft = 0;
|
|---|
| 477 | arcl[2].xRight = rect.xLeft;
|
|---|
| 478 | arcl[2].yBottom = 0;
|
|---|
| 479 | arcl[2].yTop = frame.yTop;
|
|---|
| 480 | //bottom
|
|---|
| 481 | arcl[3].xLeft = 0;
|
|---|
| 482 | arcl[3].xRight = frame.xRight;
|
|---|
| 483 | arcl[3].yBottom = 0;
|
|---|
| 484 | arcl[3].yTop = rect.yBottom;
|
|---|
| 485 |
|
|---|
| 486 | HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
|
|---|
| 487 |
|
|---|
| 488 | WinInvalidateRegion(hwnd,hrgn,FALSE);
|
|---|
| 489 | GpiDestroyRegion(hps,hrgn);
|
|---|
| 490 | WinReleasePS(hps);
|
|---|
| 491 | }
|
|---|
| 492 | }
|
|---|
| 493 | }
|
|---|
| 494 | else
|
|---|
| 495 | {
|
|---|
| 496 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 497 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 | if(pswp->fl & SWP_ACTIVATE)
|
|---|
| 501 | {
|
|---|
| 502 | //Only send PM WM_ACTIVATE to top-level windows (frame windows)
|
|---|
| 503 | if(!(WinQueryWindowUShort(hwnd,QWS_FLAGS) & FF_ACTIVE))
|
|---|
| 504 | {
|
|---|
| 505 | if(isFrame) {
|
|---|
| 506 | WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
|
|---|
| 507 | }
|
|---|
| 508 | else
|
|---|
| 509 | if(win32wnd->IsWindowCreated()) {
|
|---|
| 510 | win32wnd->MsgActivate(1, 0, win32wnd->getWindowHandle(), hwnd);
|
|---|
| 511 | }
|
|---|
| 512 | }
|
|---|
| 513 | }
|
|---|
| 514 |
|
|---|
| 515 | PosChangedEnd:
|
|---|
| 516 | return (MRESULT)FALSE;
|
|---|
| 517 | }
|
|---|
| 518 |
|
|---|
| 519 | case WM_ACTIVATE:
|
|---|
| 520 | {
|
|---|
| 521 | USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
|
|---|
| 522 |
|
|---|
| 523 | dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
|
|---|
| 524 |
|
|---|
| 525 | WinSetWindowUShort(hwnd,QWS_FLAGS, SHORT1FROMMP(mp1) ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
|---|
| 526 | if(win32wnd->IsWindowCreated())
|
|---|
| 527 | {
|
|---|
| 528 | win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
|
|---|
| 529 |
|
|---|
| 530 | //CB: show owner behind the dialog
|
|---|
| 531 | if(win32wnd->IsModalDialog())
|
|---|
| 532 | {
|
|---|
| 533 | Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
|
|---|
| 534 |
|
|---|
| 535 | if(topOwner) WinSetWindowPos(topOwner->getOS2WindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
|
|---|
| 536 | }
|
|---|
| 537 | }
|
|---|
| 538 | return 0;
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | case WM_SIZE:
|
|---|
| 542 | {
|
|---|
| 543 | dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp2)));
|
|---|
| 544 | goto RunDefWndProc;
|
|---|
| 545 | }
|
|---|
| 546 |
|
|---|
| 547 | case WM_CALCVALIDRECTS:
|
|---|
| 548 | #if 0
|
|---|
| 549 | {
|
|---|
| 550 | PRECTL oldRect = (PRECTL)mp1,newRect = oldRect+1;
|
|---|
| 551 | UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
|
|---|
| 552 |
|
|---|
| 553 | //CB: todo: use WM_NCCALCSIZE result
|
|---|
| 554 | if (win32wnd->getWindowClass())
|
|---|
| 555 | {
|
|---|
| 556 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
|---|
| 557 |
|
|---|
| 558 | if ((dwStyle & CS_HREDRAW_W) && (newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft))
|
|---|
| 559 | res |= CVR_REDRAW;
|
|---|
| 560 | else
|
|---|
| 561 | if ((dwStyle & CS_VREDRAW_W) && (newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom))
|
|---|
| 562 | res |= CVR_REDRAW;
|
|---|
| 563 | }
|
|---|
| 564 | else res |= CVR_REDRAW;
|
|---|
| 565 |
|
|---|
| 566 | return (MRESULT)res;
|
|---|
| 567 | }
|
|---|
| 568 | #else
|
|---|
| 569 | dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
|---|
| 570 | return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
|---|
| 571 | #endif
|
|---|
| 572 |
|
|---|
| 573 | case WM_VRNENABLED:
|
|---|
| 574 | dprintf(("OS2: WM_VRNENABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 575 | if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
|
|---|
| 576 | {
|
|---|
| 577 | HWND hwndrelated;
|
|---|
| 578 | Win32BaseWindow *topwindow;
|
|---|
| 579 |
|
|---|
| 580 | win32wnd->setComingToTop(TRUE);
|
|---|
| 581 |
|
|---|
| 582 | hwndrelated = WinQueryWindow(hwnd, QW_PREV);
|
|---|
| 583 | dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
|
|---|
| 584 | topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
|
|---|
| 585 | if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
|
|---|
| 586 | //put window at the top of z order
|
|---|
| 587 | WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
|
|---|
| 588 | }
|
|---|
| 589 |
|
|---|
| 590 | win32wnd->setComingToTop(FALSE);
|
|---|
| 591 | break;
|
|---|
| 592 | }
|
|---|
| 593 | goto RunDefWndProc;
|
|---|
| 594 |
|
|---|
| 595 | case WM_SETFOCUS:
|
|---|
| 596 | {
|
|---|
| 597 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 598 |
|
|---|
| 599 | dprintf(("OS2: WM_SETFOCUS %x %x (%x) %d", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2));
|
|---|
| 600 |
|
|---|
| 601 | //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
|
|---|
| 602 | //must delay this function call
|
|---|
| 603 |
|
|---|
| 604 | teb->o.odin.fWM_SETFOCUS = TRUE;
|
|---|
| 605 | teb->o.odin.hwndFocus = 0;
|
|---|
| 606 | if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
|
|---|
| 607 | //another (non-win32) application's window
|
|---|
| 608 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
|---|
| 609 | hwndFocus = NULL;
|
|---|
| 610 | }
|
|---|
| 611 | if((ULONG)mp2 == TRUE) {
|
|---|
| 612 | HWND hwndFocusWin32 = OS2ToWin32Handle(hwndFocus);
|
|---|
| 613 | recreateCaret (hwndFocusWin32);
|
|---|
| 614 | win32wnd->MsgSetFocus(hwndFocusWin32);
|
|---|
| 615 | }
|
|---|
| 616 | else win32wnd->MsgKillFocus(OS2ToWin32Handle(hwndFocus));
|
|---|
| 617 | teb->o.odin.fWM_SETFOCUS = FALSE;
|
|---|
| 618 |
|
|---|
| 619 | break;
|
|---|
| 620 | }
|
|---|
| 621 |
|
|---|
| 622 | #if 0
|
|---|
| 623 | //is sent to both windows gaining and loosing the focus
|
|---|
| 624 | case WM_FOCUSCHANGE:
|
|---|
| 625 | {
|
|---|
| 626 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 627 | HWND hwndLoseFocus, hwndGainFocus;
|
|---|
| 628 | USHORT usSetFocus = SHORT1FROMMP(mp2);
|
|---|
| 629 | USHORT fsFocusChange = SHORT2FROMMP(mp2);
|
|---|
| 630 |
|
|---|
| 631 | rc = 0;
|
|---|
| 632 | dprintf(("OS2: WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
|
|---|
| 633 | if(usSetFocus) {
|
|---|
| 634 | hwndGainFocus = hwnd;
|
|---|
| 635 | hwndLoseFocus = hwndFocus;
|
|---|
| 636 | }
|
|---|
| 637 | else {
|
|---|
| 638 | hwndGainFocus = hwndFocus;
|
|---|
| 639 | hwndLoseFocus = hwnd;
|
|---|
| 640 | }
|
|---|
| 641 |
|
|---|
| 642 | if(usSetFocus)
|
|---|
| 643 | {
|
|---|
| 644 | Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndLoseFocus);
|
|---|
| 645 | if(!(fsFocusChange & FC_NOSETACTIVE))
|
|---|
| 646 | {
|
|---|
| 647 | if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
|
|---|
| 648 | {
|
|---|
| 649 | if(winfocus)
|
|---|
| 650 | WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
|
|---|
| 651 | else
|
|---|
| 652 | WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
|
|---|
| 653 | }
|
|---|
| 654 | }
|
|---|
| 655 | //SvL: Check if window is still valid
|
|---|
| 656 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 657 | if(win32wnd == NULL)
|
|---|
| 658 | return (MRESULT)rc;
|
|---|
| 659 |
|
|---|
| 660 | if(!(fsFocusChange & FC_NOSETACTIVE))
|
|---|
| 661 | {
|
|---|
| 662 | Win32BaseWindow *topparent = win32wnd->GetTopParent();
|
|---|
| 663 | if(!winfocus || (winfocus->GetTopParent() != topparent))
|
|---|
| 664 | {
|
|---|
| 665 | if(!(fsFocusChange & FC_NOBRINGTOTOP))
|
|---|
| 666 | {
|
|---|
| 667 | if(topparent) {
|
|---|
| 668 | //put window at the top of z order
|
|---|
| 669 | WinSetWindowPos(topparent->getOS2WindowHandle(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
|
|---|
| 670 | }
|
|---|
| 671 | }
|
|---|
| 672 |
|
|---|
| 673 | // PH 2000/09/01 Netscape 4.7
|
|---|
| 674 | // check if topparent is valid
|
|---|
| 675 | if (topparent)
|
|---|
| 676 | WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
|
|---|
| 677 | }
|
|---|
| 678 | }
|
|---|
| 679 | //SvL: Check if window is still valid
|
|---|
| 680 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 681 | if(win32wnd == NULL)
|
|---|
| 682 | return (MRESULT)rc;
|
|---|
| 683 |
|
|---|
| 684 | //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
|
|---|
| 685 | if(!(fsFocusChange & FC_NOSETSELECTION)) {
|
|---|
| 686 | WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
|
|---|
| 687 | }
|
|---|
| 688 |
|
|---|
| 689 | if(!(fsFocusChange & FC_NOSETFOCUS)) {
|
|---|
| 690 | WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
|
|---|
| 691 | }
|
|---|
| 692 | }
|
|---|
| 693 | else /* no usSetFocus */
|
|---|
| 694 | {
|
|---|
| 695 | if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
|
|---|
| 696 | WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
|
|---|
| 697 | }
|
|---|
| 698 | //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
|
|---|
| 699 | if(!(fsFocusChange & FC_NOLOSESELECTION)) {
|
|---|
| 700 | WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
|
|---|
| 701 | }
|
|---|
| 702 | //SvL: Check if window is still valid
|
|---|
| 703 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 704 | if(win32wnd == NULL) {
|
|---|
| 705 | return (MRESULT)rc;
|
|---|
| 706 | }
|
|---|
| 707 |
|
|---|
| 708 | Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
|
|---|
| 709 | if(!(fsFocusChange & FC_NOLOSEACTIVE))
|
|---|
| 710 | {
|
|---|
| 711 | Win32BaseWindow *topparent = win32wnd->GetTopParent();
|
|---|
| 712 |
|
|---|
| 713 | if(!winfocus || (winfocus->GetTopParent() != topparent))
|
|---|
| 714 | {
|
|---|
| 715 | // PH 2000/09/01 Netscape 4.7
|
|---|
| 716 | // check if topparent is valid
|
|---|
| 717 | if (topparent)
|
|---|
| 718 | WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
|
|---|
| 719 | }
|
|---|
| 720 | }
|
|---|
| 721 | //SvL: Check if window is still valid
|
|---|
| 722 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 723 | if(win32wnd == NULL)
|
|---|
| 724 | return (MRESULT)rc;
|
|---|
| 725 |
|
|---|
| 726 | if(!(fsFocusChange & FC_NOSETACTIVE))
|
|---|
| 727 | {
|
|---|
| 728 | if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
|
|---|
| 729 | {
|
|---|
| 730 | if(winfocus)
|
|---|
| 731 | {
|
|---|
| 732 | // PH 2000/09/01 Netscape 4.7
|
|---|
| 733 | // check if topparent is valid
|
|---|
| 734 | Win32BaseWindow *topparent = winfocus->GetTopParent();
|
|---|
| 735 | if (topparent)
|
|---|
| 736 | WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
|
|---|
| 737 | }
|
|---|
| 738 | else
|
|---|
| 739 | WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
|
|---|
| 740 | }
|
|---|
| 741 | }
|
|---|
| 742 | }
|
|---|
| 743 |
|
|---|
| 744 |
|
|---|
| 745 | #ifdef DEBUG
|
|---|
| 746 | SetWin32TIB();
|
|---|
| 747 | dprintf(("OS2: WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 748 | #endif
|
|---|
| 749 | return (MRESULT)rc;
|
|---|
| 750 | }
|
|---|
| 751 | #endif
|
|---|
| 752 |
|
|---|
| 753 | //**************************************************************************
|
|---|
| 754 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
|---|
| 755 | //**************************************************************************
|
|---|
| 756 | case WM_HITTEST:
|
|---|
| 757 | {
|
|---|
| 758 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 759 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 760 | }
|
|---|
| 761 | if(win32wnd && win32wnd->IsWindowCreated())
|
|---|
| 762 | {
|
|---|
| 763 | MRESULT rc;
|
|---|
| 764 |
|
|---|
| 765 | rc = (MRESULT)win32wnd->MsgHitTest(pWinMsg);
|
|---|
| 766 | return rc;
|
|---|
| 767 | }
|
|---|
| 768 | return (MRESULT)HT_NORMAL;
|
|---|
| 769 | }
|
|---|
| 770 |
|
|---|
| 771 | case WM_BUTTON1DOWN:
|
|---|
| 772 | case WM_BUTTON1UP:
|
|---|
| 773 | case WM_BUTTON1DBLCLK:
|
|---|
| 774 | case WM_BUTTON2DOWN:
|
|---|
| 775 | case WM_BUTTON2UP:
|
|---|
| 776 | case WM_BUTTON2DBLCLK:
|
|---|
| 777 | case WM_BUTTON3DOWN:
|
|---|
| 778 | case WM_BUTTON3UP:
|
|---|
| 779 | case WM_BUTTON3DBLCLK:
|
|---|
| 780 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 781 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 782 | }
|
|---|
| 783 | if(win32wnd)
|
|---|
| 784 | win32wnd->MsgButton(pWinMsg);
|
|---|
| 785 |
|
|---|
| 786 | rc = (MRESULT)TRUE;
|
|---|
| 787 | break;
|
|---|
| 788 |
|
|---|
| 789 | case WM_BUTTON2MOTIONSTART:
|
|---|
| 790 | case WM_BUTTON2MOTIONEND:
|
|---|
| 791 | case WM_BUTTON2CLICK:
|
|---|
| 792 | case WM_BUTTON1MOTIONSTART:
|
|---|
| 793 | case WM_BUTTON1MOTIONEND:
|
|---|
| 794 | case WM_BUTTON1CLICK:
|
|---|
| 795 | case WM_BUTTON3MOTIONSTART:
|
|---|
| 796 | case WM_BUTTON3MOTIONEND:
|
|---|
| 797 | case WM_BUTTON3CLICK:
|
|---|
| 798 | rc = (MRESULT)TRUE;
|
|---|
| 799 | break;
|
|---|
| 800 |
|
|---|
| 801 | case WM_MOUSEMOVE:
|
|---|
| 802 | {
|
|---|
| 803 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 804 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 805 | }
|
|---|
| 806 | if(win32wnd)
|
|---|
| 807 | win32wnd->MsgMouseMove(pWinMsg);
|
|---|
| 808 | break;
|
|---|
| 809 | }
|
|---|
| 810 |
|
|---|
| 811 | case WM_CONTROL:
|
|---|
| 812 | goto RunDefWndProc;
|
|---|
| 813 |
|
|---|
| 814 | case WM_COMMAND:
|
|---|
| 815 | dprintf(("OS2: WM_COMMAND %x %x %x", hwnd, mp1, mp2));
|
|---|
| 816 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 817 | break;
|
|---|
| 818 |
|
|---|
| 819 | case WM_SYSCOMMAND:
|
|---|
| 820 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 821 | break;
|
|---|
| 822 |
|
|---|
| 823 | case WM_RENDERFMT:
|
|---|
| 824 | case WM_RENDERALLFMTS:
|
|---|
| 825 | case WM_DESTROYCLIPBOARD:
|
|---|
| 826 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 827 | break;
|
|---|
| 828 |
|
|---|
| 829 | case WM_CHAR:
|
|---|
| 830 | win32wnd->MsgChar(pWinMsg);
|
|---|
| 831 | break;
|
|---|
| 832 |
|
|---|
| 833 | case WM_TIMER:
|
|---|
| 834 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 835 | goto RunDefWndProc;
|
|---|
| 836 |
|
|---|
| 837 | case WM_SETWINDOWPARAMS:
|
|---|
| 838 | {
|
|---|
| 839 | WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
|
|---|
| 840 |
|
|---|
| 841 | dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
|
|---|
| 842 | if(wndParams->fsStatus & WPM_TEXT) {
|
|---|
| 843 | win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
|
|---|
| 844 | }
|
|---|
| 845 | goto RunDefWndProc;
|
|---|
| 846 | }
|
|---|
| 847 |
|
|---|
| 848 | case WM_QUERYWINDOWPARAMS:
|
|---|
| 849 | {
|
|---|
| 850 | PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
|
|---|
| 851 | ULONG textlen;
|
|---|
| 852 | PSZ wintext;
|
|---|
| 853 |
|
|---|
| 854 | if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
|
|---|
| 855 | {
|
|---|
| 856 | if(wndpars->fsStatus & WPM_TEXT)
|
|---|
| 857 | win32wnd->MsgGetText(wndpars->pszText, wndpars->cchText);
|
|---|
| 858 | if(wndpars->fsStatus & WPM_CCHTEXT)
|
|---|
| 859 | wndpars->cchText = win32wnd->MsgGetTextLength();
|
|---|
| 860 |
|
|---|
| 861 | wndpars->fsStatus = 0;
|
|---|
| 862 | wndpars->cbCtlData = 0;
|
|---|
| 863 | wndpars->cbPresParams = 0;
|
|---|
| 864 | return (MRESULT)TRUE;
|
|---|
| 865 | }
|
|---|
| 866 | goto RunDefWndProc;
|
|---|
| 867 | }
|
|---|
| 868 |
|
|---|
| 869 | case WM_PAINT:
|
|---|
| 870 | {
|
|---|
| 871 | RECTL rectl;
|
|---|
| 872 | BOOL rc;
|
|---|
| 873 |
|
|---|
| 874 | rc = WinQueryUpdateRect(hwnd, &rectl);
|
|---|
| 875 | dprintf(("OS2: WM_PAINT %x (%d,%d) (%d,%d) rc=%d", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop, rc));
|
|---|
| 876 |
|
|---|
| 877 | if(rc && win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
|
|---|
| 878 | rectl.yBottom != rectl.yTop))
|
|---|
| 879 | {
|
|---|
| 880 | PRECT pClient = win32wnd->getClientRectPtr();
|
|---|
| 881 | PRECT pWindow = win32wnd->getWindowRect();
|
|---|
| 882 |
|
|---|
| 883 | if(!(pClient->left == 0 && pClient->top == 0 &&
|
|---|
| 884 | win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
|
|---|
| 885 | win32wnd->getClientWidth() == win32wnd->getWindowWidth()))
|
|---|
| 886 | {
|
|---|
| 887 | win32wnd->MsgNCPaint();
|
|---|
| 888 | }
|
|---|
| 889 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 890 | }
|
|---|
| 891 | else goto RunDefWndProc;
|
|---|
| 892 |
|
|---|
| 893 | //SvL: Not calling the default window procedure causes all sorts of
|
|---|
| 894 | // strange problems (redraw & hanging app)
|
|---|
| 895 | // -> check what WinBeginPaint does what we're forgetting in BeginPaint
|
|---|
| 896 | // WinQueryUpdateRect(hwnd, &rectl);
|
|---|
| 897 | // if(rectl.xLeft == 0 && rectl.yTop == 0 && rectl.xRight == 0 && rectl.yBottom == 0) {
|
|---|
| 898 | // RestoreOS2TIB();
|
|---|
| 899 | // return (MRESULT)FALSE;
|
|---|
| 900 | // }
|
|---|
| 901 | // dprintf(("Update rectangle (%d,%d)(%d,%d) not empty, msg %x", rectl.xLeft, rectl.yTop, rectl.xRight, rectl.yBottom, pWinMsg->message));
|
|---|
| 902 | // goto RunDefWndProc;
|
|---|
| 903 | break;
|
|---|
| 904 | }
|
|---|
| 905 |
|
|---|
| 906 | case WM_ERASEBACKGROUND:
|
|---|
| 907 | {
|
|---|
| 908 | dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
|---|
| 909 | return (MRESULT)FALSE;
|
|---|
| 910 | }
|
|---|
| 911 |
|
|---|
| 912 | #if 0
|
|---|
| 913 | case WM_CONTEXTMENU:
|
|---|
| 914 | {
|
|---|
| 915 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 916 |
|
|---|
| 917 | return (MRESULT)TRUE;
|
|---|
| 918 | }
|
|---|
| 919 | #endif
|
|---|
| 920 |
|
|---|
| 921 | case WM_QUERYTRACKINFO:
|
|---|
| 922 | {
|
|---|
| 923 | PTRACKINFO trackInfo = (PTRACKINFO)mp2;
|
|---|
| 924 |
|
|---|
| 925 | dprintf(("OS2: WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
|
|---|
| 926 | trackInfo->cxBorder = 4;
|
|---|
| 927 | trackInfo->cyBorder = 4;
|
|---|
| 928 | win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
|
|---|
| 929 | return (MRESULT)TRUE;
|
|---|
| 930 | }
|
|---|
| 931 |
|
|---|
| 932 | case WM_QUERYBORDERSIZE:
|
|---|
| 933 | {
|
|---|
| 934 | PWPOINT size = (PWPOINT)mp1;
|
|---|
| 935 |
|
|---|
| 936 | dprintf(("OS2: WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
|
|---|
| 937 |
|
|---|
| 938 | size->x = 0;
|
|---|
| 939 | size->y = 0;
|
|---|
| 940 | return (MRESULT)TRUE;
|
|---|
| 941 | }
|
|---|
| 942 |
|
|---|
| 943 | case WM_REALIZEPALETTE:
|
|---|
| 944 | {
|
|---|
| 945 | dprintf(("OS2: WM_REALIZEPALETTE"));
|
|---|
| 946 | goto RunDefWndProc;
|
|---|
| 947 | }
|
|---|
| 948 |
|
|---|
| 949 | case WM_OWNERPOSCHANGE:
|
|---|
| 950 | {
|
|---|
| 951 | dprintf(("OS2: WM_OWNERPOSCHANGE"));
|
|---|
| 952 | goto RunDefWndProc;
|
|---|
| 953 | }
|
|---|
| 954 |
|
|---|
| 955 | case WM_INITMENU:
|
|---|
| 956 | case WM_MENUSELECT:
|
|---|
| 957 | case WM_MENUEND:
|
|---|
| 958 | case WM_NEXTMENU:
|
|---|
| 959 | case WM_SYSCOLORCHANGE:
|
|---|
| 960 | case WM_SYSVALUECHANGED:
|
|---|
| 961 | case WM_SETSELECTION:
|
|---|
| 962 | case WM_PPAINT:
|
|---|
| 963 | case WM_PSETFOCUS:
|
|---|
| 964 | case WM_PSYSCOLORCHANGE:
|
|---|
| 965 | case WM_PSIZE:
|
|---|
| 966 | case WM_PACTIVATE:
|
|---|
| 967 | case WM_PCONTROL:
|
|---|
| 968 | case WM_HELP:
|
|---|
| 969 | case WM_APPTERMINATENOTIFY:
|
|---|
| 970 | case WM_PRESPARAMCHANGED:
|
|---|
| 971 | case WM_DRAWITEM:
|
|---|
| 972 | case WM_MEASUREITEM:
|
|---|
| 973 | case WM_CONTROLPOINTER:
|
|---|
| 974 | case WM_QUERYDLGCODE:
|
|---|
| 975 | case WM_SUBSTITUTESTRING:
|
|---|
| 976 | case WM_MATCHMNEMONIC:
|
|---|
| 977 | case WM_SAVEAPPLICATION:
|
|---|
| 978 | case WM_SEMANTICEVENT:
|
|---|
| 979 | default:
|
|---|
| 980 | dprintf2(("OS2: RunDefWndProc hwnd %x msg %x mp1 %x mp2 %x", hwnd, msg, mp1, mp2));
|
|---|
| 981 | RestoreOS2TIB();
|
|---|
| 982 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 983 | }
|
|---|
| 984 | return (MRESULT)rc;
|
|---|
| 985 |
|
|---|
| 986 | RunDefWndProc:
|
|---|
| 987 | // dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
|
|---|
| 988 | RestoreOS2TIB();
|
|---|
| 989 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 990 | } /* End of Win32WindowProc */
|
|---|
| 991 | //******************************************************************************
|
|---|
| 992 | //******************************************************************************
|
|---|
| 993 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 994 | {
|
|---|
| 995 | POSTMSG_PACKET *postmsg;
|
|---|
| 996 | OSLIBPOINT point, ClientPoint;
|
|---|
| 997 | Win32BaseWindow *win32wnd;
|
|---|
| 998 | TEB *teb;
|
|---|
| 999 | MRESULT rc = 0;
|
|---|
| 1000 | MSG winMsg, *pWinMsg;
|
|---|
| 1001 |
|
|---|
| 1002 | //Restore our FS selector
|
|---|
| 1003 | SetWin32TIB();
|
|---|
| 1004 |
|
|---|
| 1005 | //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
|
|---|
| 1006 | teb = GetThreadTEB();
|
|---|
| 1007 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 1008 |
|
|---|
| 1009 | if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
|
|---|
| 1010 | dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
|
|---|
| 1011 | goto RunDefFrameWndProc;
|
|---|
| 1012 | }
|
|---|
| 1013 | //// if(teb->o.odin.fIgnoreMsgs) {
|
|---|
| 1014 | //// goto RunDefWndProc;
|
|---|
| 1015 | //// }
|
|---|
| 1016 |
|
|---|
| 1017 | if((teb->o.odin.msgstate & 1) == 0)
|
|---|
| 1018 | {//message that was sent directly to our window proc handler; translate it here
|
|---|
| 1019 | QMSG qmsg;
|
|---|
| 1020 |
|
|---|
| 1021 | qmsg.msg = msg;
|
|---|
| 1022 | qmsg.hwnd = hwnd;
|
|---|
| 1023 | qmsg.mp1 = mp1;
|
|---|
| 1024 | qmsg.mp2 = mp2;
|
|---|
| 1025 | qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
|
|---|
| 1026 | WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
|
|---|
| 1027 | qmsg.reserved = 0;
|
|---|
| 1028 |
|
|---|
| 1029 | if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
|---|
| 1030 | {//message was not translated
|
|---|
| 1031 | memset(&winMsg, 0, sizeof(MSG));
|
|---|
| 1032 | }
|
|---|
| 1033 | pWinMsg = &winMsg;
|
|---|
| 1034 | }
|
|---|
| 1035 | else {
|
|---|
| 1036 | pWinMsg = &teb->o.odin.msg;
|
|---|
| 1037 | teb->o.odin.msgstate++;
|
|---|
| 1038 | }
|
|---|
| 1039 | //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
|
|---|
| 1040 |
|
|---|
| 1041 | switch( msg )
|
|---|
| 1042 | {
|
|---|
| 1043 | case WM_CREATE:
|
|---|
| 1044 | {
|
|---|
| 1045 | RestoreOS2TIB();
|
|---|
| 1046 | pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
|---|
| 1047 | SetWin32TIB();
|
|---|
| 1048 | rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
|
|---|
| 1049 | break;
|
|---|
| 1050 | }
|
|---|
| 1051 |
|
|---|
| 1052 | case WM_CALCFRAMERECT:
|
|---|
| 1053 | dprintf(("OS2: WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
|
|---|
| 1054 | rc = (MRESULT)TRUE;
|
|---|
| 1055 | break;
|
|---|
| 1056 |
|
|---|
| 1057 | case WM_QUERYCTLTYPE:
|
|---|
| 1058 | // This is a frame window
|
|---|
| 1059 | dprintf(("OS2: WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
|
|---|
| 1060 | rc = (MRESULT)CCT_FRAME;
|
|---|
| 1061 | break;
|
|---|
| 1062 |
|
|---|
| 1063 | case WM_QUERYFOCUSCHAIN:
|
|---|
| 1064 | dprintf(("OS2: WM_QUERYFOCUSCHAIN %x", win32wnd->getWindowHandle()));
|
|---|
| 1065 | goto RunDefFrameWndProc;
|
|---|
| 1066 |
|
|---|
| 1067 | case WM_FOCUSCHANGE:
|
|---|
| 1068 | {
|
|---|
| 1069 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 1070 | HWND hwndLoseFocus, hwndGainFocus;
|
|---|
| 1071 | USHORT usSetFocus = SHORT1FROMMP(mp2);
|
|---|
| 1072 | USHORT fsFocusChange = SHORT2FROMMP(mp2);
|
|---|
| 1073 |
|
|---|
| 1074 | dprintf(("OS2: WM_FOCUSCHANGE %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
|
|---|
| 1075 | goto RunDefFrameWndProc;
|
|---|
| 1076 | }
|
|---|
| 1077 |
|
|---|
| 1078 | case WM_ACTIVATE:
|
|---|
| 1079 | case WM_SETFOCUS:
|
|---|
| 1080 | {
|
|---|
| 1081 | rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
|
|---|
| 1082 | goto RunDefFrameWndProc;
|
|---|
| 1083 | }
|
|---|
| 1084 |
|
|---|
| 1085 | #if 0
|
|---|
| 1086 | //just a test
|
|---|
| 1087 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 1088 | case WM_WINDOWPOSCHANGED:
|
|---|
| 1089 | {
|
|---|
| 1090 | rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
|
|---|
| 1091 | goto RunDefFrameWndProc;
|
|---|
| 1092 | }
|
|---|
| 1093 | #endif
|
|---|
| 1094 |
|
|---|
| 1095 | case WM_QUERYFRAMEINFO:
|
|---|
| 1096 | dprintf(("OS2: WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
|
|---|
| 1097 | goto RunDefFrameWndProc;
|
|---|
| 1098 |
|
|---|
| 1099 | case WM_FORMATFRAME:
|
|---|
| 1100 | dprintf(("OS2: WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
|
|---|
| 1101 | goto RunDefFrameWndProc;
|
|---|
| 1102 |
|
|---|
| 1103 | case WM_ADJUSTFRAMEPOS:
|
|---|
| 1104 | {
|
|---|
| 1105 | PSWP pswp = (PSWP)mp1;
|
|---|
| 1106 |
|
|---|
| 1107 | dprintf(("OS2: WM_ADJUSTFRAMEPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 1108 | goto RunDefFrameWndProc;
|
|---|
| 1109 | }
|
|---|
| 1110 |
|
|---|
| 1111 | case WM_MINMAXFRAME:
|
|---|
| 1112 | {
|
|---|
| 1113 | PSWP swp = (PSWP)mp1;
|
|---|
| 1114 |
|
|---|
| 1115 | if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
|
|---|
| 1116 |
|
|---|
| 1117 | dprintf(("OS2: WM_MINMAXFRAME %x",hwnd));
|
|---|
| 1118 | if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
|---|
| 1119 | {
|
|---|
| 1120 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MINIMIZE_W) | WS_MAXIMIZE_W);
|
|---|
| 1121 |
|
|---|
| 1122 | RECT rect;
|
|---|
| 1123 |
|
|---|
| 1124 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
|---|
| 1125 | win32wnd->AdjustMaximizedRect(&rect);
|
|---|
| 1126 | swp->x += rect.left;
|
|---|
| 1127 | swp->cx += rect.right-rect.left;
|
|---|
| 1128 | swp->y -= rect.bottom;
|
|---|
| 1129 | swp->cy += rect.bottom-rect.top;
|
|---|
| 1130 | }
|
|---|
| 1131 | else
|
|---|
| 1132 | if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
|
|---|
| 1133 | {
|
|---|
| 1134 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
|
|---|
| 1135 | }
|
|---|
| 1136 | else
|
|---|
| 1137 | if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
|
|---|
| 1138 | {
|
|---|
| 1139 | win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
|
|---|
| 1140 | }
|
|---|
| 1141 | goto RunDefWndProc;
|
|---|
| 1142 | }
|
|---|
| 1143 |
|
|---|
| 1144 | case WM_UPDATEFRAME:
|
|---|
| 1145 | dprintf(("OS2: WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
|
|---|
| 1146 | goto RunDefFrameWndProc;
|
|---|
| 1147 |
|
|---|
| 1148 | default:
|
|---|
| 1149 | rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
|
|---|
| 1150 | break;
|
|---|
| 1151 | }
|
|---|
| 1152 | RestoreOS2TIB();
|
|---|
| 1153 | return (MRESULT)rc;
|
|---|
| 1154 |
|
|---|
| 1155 | RunDefFrameWndProc:
|
|---|
| 1156 | RestoreOS2TIB();
|
|---|
| 1157 | return pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
|---|
| 1158 |
|
|---|
| 1159 | RunDefWndProc:
|
|---|
| 1160 | RestoreOS2TIB();
|
|---|
| 1161 | return Win32WindowProc(hwnd, msg, mp1, mp2);
|
|---|
| 1162 | }
|
|---|
| 1163 | //******************************************************************************
|
|---|
| 1164 | //TODO: Quickly moving a window two times doesn't force a repaint (1st time)
|
|---|
| 1165 | //******************************************************************************
|
|---|
| 1166 | VOID FrameTrackFrame(Win32BaseWindow *win32wnd,DWORD flags)
|
|---|
| 1167 | {
|
|---|
| 1168 | TRACKINFO track;
|
|---|
| 1169 | RECTL rcl;
|
|---|
| 1170 | PRECT pWindowRect, pClientRect;
|
|---|
| 1171 | HWND hwndTracking;
|
|---|
| 1172 | HPS hpsTrack;
|
|---|
| 1173 | LONG parentHeight, parentWidth;
|
|---|
| 1174 |
|
|---|
| 1175 | dprintf(("FrameTrackFrame: %x %x", win32wnd->getWindowHandle(), flags));
|
|---|
| 1176 | track.cxBorder = 4;
|
|---|
| 1177 | track.cyBorder = 4; /* 4 pel wide lines used for rectangle */
|
|---|
| 1178 | track.cxGrid = 1;
|
|---|
| 1179 | track.cyGrid = 1; /* smooth tracking with mouse */
|
|---|
| 1180 | track.cxKeyboard = 8;
|
|---|
| 1181 | track.cyKeyboard = 8; /* faster tracking using cursor keys */
|
|---|
| 1182 |
|
|---|
| 1183 | pWindowRect = win32wnd->getWindowRect();
|
|---|
| 1184 | if(win32wnd->getParent()) {
|
|---|
| 1185 | parentHeight = win32wnd->getParent()->getWindowHeight();
|
|---|
| 1186 | parentWidth = win32wnd->getParent()->getWindowWidth();
|
|---|
| 1187 | hwndTracking = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 1188 | hpsTrack = WinGetPS(hwndTracking);
|
|---|
| 1189 | }
|
|---|
| 1190 | else {
|
|---|
| 1191 | parentHeight = OSLibQueryScreenHeight();
|
|---|
| 1192 | parentWidth = OSLibQueryScreenWidth();
|
|---|
| 1193 | hwndTracking = HWND_DESKTOP;
|
|---|
| 1194 | hpsTrack = NULL;
|
|---|
| 1195 | }
|
|---|
| 1196 |
|
|---|
| 1197 | mapWin32ToOS2Rect(parentHeight, pWindowRect, (PRECTLOS2)&track.rclTrack);
|
|---|
| 1198 | WinQueryWindowRect(hwndTracking, &track.rclBoundary);
|
|---|
| 1199 |
|
|---|
| 1200 | track.ptlMinTrackSize.x = 10;
|
|---|
| 1201 | track.ptlMinTrackSize.y = 10; /* set smallest allowed size of rectangle */
|
|---|
| 1202 | track.ptlMaxTrackSize.x = parentWidth;
|
|---|
| 1203 | track.ptlMaxTrackSize.y = parentHeight; /* set largest allowed size of rectangle */
|
|---|
| 1204 |
|
|---|
| 1205 | win32wnd->AdjustTrackInfo((PPOINT)&track.ptlMinTrackSize, (PPOINT)&track.ptlMaxTrackSize);
|
|---|
| 1206 |
|
|---|
| 1207 | track.fs = flags;
|
|---|
| 1208 |
|
|---|
| 1209 | if(WinTrackRect(hwndTracking, NULL, &track) )
|
|---|
| 1210 | {
|
|---|
| 1211 | if(hpsTrack) WinReleasePS(hpsTrack);
|
|---|
| 1212 |
|
|---|
| 1213 | /* if successful copy final position back */
|
|---|
| 1214 | if(!WinEqualRect(0, &rcl, &track.rclTrack)) {
|
|---|
| 1215 | dprintf(("FrameTrackFrame: new (os/2) window rect: (%d,%d)(%d,%d)", track.rclTrack.xLeft, track.rclTrack.yBottom, track.rclTrack.xRight - track.rclTrack.xLeft, track.rclTrack.yTop - track.rclTrack.yBottom));
|
|---|
| 1216 | if(flags == TF_MOVE) {
|
|---|
| 1217 | WinSetWindowPos(win32wnd->getOS2WindowHandle(),
|
|---|
| 1218 | 0, track.rclTrack.xLeft, track.rclTrack.yBottom,
|
|---|
| 1219 | 0, 0, SWP_MOVE);
|
|---|
| 1220 | }
|
|---|
| 1221 | else {
|
|---|
| 1222 | SetWindowPos(win32wnd->getWindowHandle(), 0, track.rclTrack.xLeft,
|
|---|
| 1223 | parentHeight - track.rclTrack.yTop,
|
|---|
| 1224 | track.rclTrack.xRight - track.rclTrack.xLeft,
|
|---|
| 1225 | track.rclTrack.yTop - track.rclTrack.yBottom,
|
|---|
| 1226 | SWP_NOACTIVATE_W | SWP_NOZORDER_W | SWP_NOACTIVATE_W);
|
|---|
| 1227 | // WinSetWindowPos(win32wnd->getOS2WindowHandle(),
|
|---|
| 1228 | // 0, track.rclTrack.xLeft, track.rclTrack.yBottom,
|
|---|
| 1229 | // track.rclTrack.xRight - track.rclTrack.xLeft,
|
|---|
| 1230 | // track.rclTrack.yTop - track.rclTrack.yBottom,
|
|---|
| 1231 | // SWP_SIZE|SWP_MOVE);
|
|---|
| 1232 | }
|
|---|
| 1233 | }
|
|---|
| 1234 | return;
|
|---|
| 1235 | }
|
|---|
| 1236 | if(hpsTrack) WinReleasePS(hpsTrack);
|
|---|
| 1237 | return;
|
|---|
| 1238 | }
|
|---|
| 1239 | //******************************************************************************
|
|---|
| 1240 | //******************************************************************************
|
|---|