| 1 | /* $Id: pmwindow.cpp,v 1.116 2001-02-18 14:18:38 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(win32wnd->getParent() && win32wnd->getParent()->isOwnDC()) {
|
|---|
| 289 | dprintfOrigin(win32wnd->getParent()->getOwnDC());
|
|---|
| 290 | selectClientArea(win32wnd->getParent(), win32wnd->getParent()->getOwnDC());
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 | if(pswp->fl & SWP_NOADJUST) {
|
|---|
| 294 | //ignore weird messages (TODO: why are they sent?)
|
|---|
| 295 | break;
|
|---|
| 296 | }
|
|---|
| 297 | //CB: show dialog in front of owner
|
|---|
| 298 | if (win32wnd->IsModalDialogOwner())
|
|---|
| 299 | {
|
|---|
| 300 | dprintf(("win32wnd->IsModalDialogOwner %x", win32wnd->getWindowHandle()));
|
|---|
| 301 | pswp->fl |= SWP_ZORDER;
|
|---|
| 302 | pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
|
|---|
| 303 | if (pswp->fl & SWP_ACTIVATE)
|
|---|
| 304 | {
|
|---|
| 305 | pswp->fl &= ~SWP_ACTIVATE;
|
|---|
| 306 | WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
|
|---|
| 307 | }
|
|---|
| 308 | }
|
|---|
| 309 |
|
|---|
| 310 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 311 | goto RunDefWndProc;
|
|---|
| 312 |
|
|---|
| 313 | if(!win32wnd->CanReceiveSizeMsgs())
|
|---|
| 314 | break;
|
|---|
| 315 |
|
|---|
| 316 | WinQueryWindowPos(hwnd, &swpOld);
|
|---|
| 317 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 318 | if (win32wnd->isChild()) {
|
|---|
| 319 | if(win32wnd->getParent()) {
|
|---|
| 320 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 321 | }
|
|---|
| 322 | else goto RunDefWndProc;
|
|---|
| 323 | }
|
|---|
| 324 | }
|
|---|
| 325 | hwndAfter = pswp->hwndInsertBehind;
|
|---|
| 326 | if(win32wnd->getParent()) {
|
|---|
| 327 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
|
|---|
| 328 | win32wnd->getParent()->getClientRectPtr()->left,
|
|---|
| 329 | win32wnd->getParent()->getClientRectPtr()->top,
|
|---|
| 330 | hwnd);
|
|---|
| 331 | }
|
|---|
| 332 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
|---|
| 333 |
|
|---|
| 334 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 335 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 336 | {
|
|---|
| 337 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 338 | if(wndAfter) {
|
|---|
| 339 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 340 | }
|
|---|
| 341 | else wp.hwndInsertAfter = HWND_TOP_W;
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 | wpOld = wp;
|
|---|
| 345 | win32wnd->MsgPosChanging((LPARAM)&wp);
|
|---|
| 346 |
|
|---|
| 347 | if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
|
|---|
| 348 | (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
|
|---|
| 349 | {
|
|---|
| 350 | ULONG flags = pswp->fl; //make a backup copy; OSLibMapWINDOWPOStoSWP will modify it
|
|---|
| 351 |
|
|---|
| 352 | dprintf(("OS2: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
|---|
| 353 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 354 |
|
|---|
| 355 | if(win32wnd->getParent()) {
|
|---|
| 356 | OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getWindowHeight(),
|
|---|
| 357 | win32wnd->getParent()->getClientRectPtr()->left,
|
|---|
| 358 | win32wnd->getParent()->getClientRectPtr()->top,
|
|---|
| 359 | hwnd);
|
|---|
| 360 | }
|
|---|
| 361 | else OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
|---|
| 362 |
|
|---|
| 363 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 364 |
|
|---|
| 365 | //OSLibMapWINDOWPOStoSWP can add flags, but we must not let it remove flags!
|
|---|
| 366 | if(pswp->fl & SWP_SIZE)
|
|---|
| 367 | flags |= SWP_SIZE;
|
|---|
| 368 |
|
|---|
| 369 | if(pswp->fl & SWP_MOVE)
|
|---|
| 370 | flags |= SWP_MOVE;
|
|---|
| 371 |
|
|---|
| 372 | pswp->fl = flags; //restore flags
|
|---|
| 373 |
|
|---|
| 374 | pswp->fl |= SWP_NOADJUST;
|
|---|
| 375 | pswp->hwndInsertBehind = hwndAfter;
|
|---|
| 376 | pswp->hwnd = hwnd;
|
|---|
| 377 |
|
|---|
| 378 | return (MRESULT)0xf;
|
|---|
| 379 | }
|
|---|
| 380 | return (MRESULT)0;
|
|---|
| 381 | }
|
|---|
| 382 |
|
|---|
| 383 | case WM_WINDOWPOSCHANGED:
|
|---|
| 384 | {
|
|---|
| 385 | PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
|
|---|
| 386 | SWP swpOld = *(pswp + 1);
|
|---|
| 387 | WINDOWPOS wp;
|
|---|
| 388 | HWND hParent = NULLHANDLE;
|
|---|
| 389 | RECTL rect;
|
|---|
| 390 |
|
|---|
| 391 | dprintf(("OS2: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 392 |
|
|---|
| 393 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 394 | {
|
|---|
| 395 | if(pswp->fl & SWP_ACTIVATE)
|
|---|
| 396 | {
|
|---|
| 397 | //Only send PM WM_ACTIVATE to top-level windows (frame windows)
|
|---|
| 398 | if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & FF_ACTIVE))
|
|---|
| 399 | {
|
|---|
| 400 | WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
|
|---|
| 401 | }
|
|---|
| 402 | }
|
|---|
| 403 | goto RunDefWndProc;
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 | if(pswp->fl & (SWP_MOVE | SWP_SIZE))
|
|---|
| 407 | {
|
|---|
| 408 | if(win32wnd->isChild())
|
|---|
| 409 | {
|
|---|
| 410 | if(win32wnd->getParent()) {
|
|---|
| 411 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 412 | }
|
|---|
| 413 | else goto PosChangedEnd; //parent has just been destroyed
|
|---|
| 414 | }
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 |
|
|---|
| 418 | if(win32wnd->getParent()) {
|
|---|
| 419 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
|
|---|
| 420 | win32wnd->getParent()->getClientRectPtr()->left,
|
|---|
| 421 | win32wnd->getParent()->getClientRectPtr()->top,
|
|---|
| 422 | hwnd);
|
|---|
| 423 | }
|
|---|
| 424 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
|---|
| 425 |
|
|---|
| 426 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 427 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 428 | {
|
|---|
| 429 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 430 | if(wndAfter) {
|
|---|
| 431 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 432 | }
|
|---|
| 433 | else wp.hwndInsertAfter = HWND_TOP_W;
|
|---|
| 434 | }
|
|---|
| 435 |
|
|---|
| 436 | if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
|
|---|
| 437 | {
|
|---|
| 438 | //CB: todo: use result for WM_CALCVALIDRECTS
|
|---|
| 439 | //Get old client rectangle (for invalidation of frame window parts later on)
|
|---|
| 440 | mapWin32ToOS2Rect(win32wnd->getWindowHeight(), win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
|
|---|
| 441 |
|
|---|
| 442 | //Note: Also updates the new window rectangle
|
|---|
| 443 | win32wnd->MsgFormatFrame(&wp);
|
|---|
| 444 |
|
|---|
| 445 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 446 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 447 |
|
|---|
| 448 | if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
|
|---|
| 449 | {
|
|---|
| 450 | //redraw the frame (to prevent unnecessary client updates)
|
|---|
| 451 | BOOL redrawAll = FALSE;
|
|---|
| 452 |
|
|---|
| 453 | if (win32wnd->getWindowClass())
|
|---|
| 454 | {
|
|---|
| 455 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
|---|
| 456 |
|
|---|
| 457 | if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
|
|---|
| 458 | redrawAll = TRUE;
|
|---|
| 459 | else if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
|
|---|
| 460 | redrawAll = TRUE;
|
|---|
| 461 | } else redrawAll = TRUE;
|
|---|
| 462 |
|
|---|
| 463 | if (redrawAll)
|
|---|
| 464 | {
|
|---|
| 465 | //CB: redraw all children for now
|
|---|
| 466 | // -> problems with update region if we don't do it
|
|---|
| 467 | // todo: rewrite whole handling
|
|---|
| 468 | WinInvalidateRect(hwnd,NULL,TRUE);
|
|---|
| 469 | }
|
|---|
| 470 | else
|
|---|
| 471 | {
|
|---|
| 472 | HPS hps = WinGetPS(hwnd);
|
|---|
| 473 | RECTL frame,client,arcl[4];
|
|---|
| 474 |
|
|---|
| 475 | WinQueryWindowRect(hwnd,&frame);
|
|---|
| 476 | //top
|
|---|
| 477 | arcl[0].xLeft = 0;
|
|---|
| 478 | arcl[0].xRight = frame.xRight;
|
|---|
| 479 | arcl[0].yBottom = rect.yTop;
|
|---|
| 480 | arcl[0].yTop = frame.yTop;
|
|---|
| 481 | //right
|
|---|
| 482 | arcl[1].xLeft = rect.xRight;
|
|---|
| 483 | arcl[1].xRight = frame.xRight;
|
|---|
| 484 | arcl[1].yBottom = 0;
|
|---|
| 485 | arcl[1].yTop = frame.yTop;
|
|---|
| 486 | //left
|
|---|
| 487 | arcl[2].xLeft = 0;
|
|---|
| 488 | arcl[2].xRight = rect.xLeft;
|
|---|
| 489 | arcl[2].yBottom = 0;
|
|---|
| 490 | arcl[2].yTop = frame.yTop;
|
|---|
| 491 | //bottom
|
|---|
| 492 | arcl[3].xLeft = 0;
|
|---|
| 493 | arcl[3].xRight = frame.xRight;
|
|---|
| 494 | arcl[3].yBottom = 0;
|
|---|
| 495 | arcl[3].yTop = rect.yBottom;
|
|---|
| 496 |
|
|---|
| 497 | HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
|
|---|
| 498 |
|
|---|
| 499 | WinInvalidateRegion(hwnd,hrgn,FALSE);
|
|---|
| 500 | GpiDestroyRegion(hps,hrgn);
|
|---|
| 501 | WinReleasePS(hps);
|
|---|
| 502 | }
|
|---|
| 503 | }
|
|---|
| 504 | }
|
|---|
| 505 | else
|
|---|
| 506 | {
|
|---|
| 507 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 508 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 509 | }
|
|---|
| 510 |
|
|---|
| 511 | if(pswp->fl & SWP_ACTIVATE)
|
|---|
| 512 | {
|
|---|
| 513 | //Only send PM WM_ACTIVATE to top-level windows (frame windows)
|
|---|
| 514 | if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & FF_ACTIVE))
|
|---|
| 515 | {
|
|---|
| 516 | if(isFrame) {
|
|---|
| 517 | WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
|
|---|
| 518 | }
|
|---|
| 519 | else
|
|---|
| 520 | if(win32wnd->IsWindowCreated()) {
|
|---|
| 521 | win32wnd->MsgActivate(1, 0, win32wnd->getWindowHandle(), hwnd);
|
|---|
| 522 | }
|
|---|
| 523 | }
|
|---|
| 524 | }
|
|---|
| 525 |
|
|---|
| 526 | PosChangedEnd:
|
|---|
| 527 | return (MRESULT)FALSE;
|
|---|
| 528 | }
|
|---|
| 529 |
|
|---|
| 530 | case WM_ACTIVATE:
|
|---|
| 531 | {
|
|---|
| 532 | USHORT flags = WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS);
|
|---|
| 533 |
|
|---|
| 534 | dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
|
|---|
| 535 |
|
|---|
| 536 | WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
|---|
| 537 | if(win32wnd->IsWindowCreated())
|
|---|
| 538 | {
|
|---|
| 539 | win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
|
|---|
| 540 |
|
|---|
| 541 | //CB: show owner behind the dialog
|
|---|
| 542 | if(win32wnd->IsModalDialog())
|
|---|
| 543 | {
|
|---|
| 544 | Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
|
|---|
| 545 |
|
|---|
| 546 | if(topOwner) WinSetWindowPos(topOwner->getOS2WindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
|
|---|
| 547 | }
|
|---|
| 548 | }
|
|---|
| 549 | return 0;
|
|---|
| 550 | }
|
|---|
| 551 |
|
|---|
| 552 | case WM_SIZE:
|
|---|
| 553 | {
|
|---|
| 554 | dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp2)));
|
|---|
| 555 | goto RunDefWndProc;
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 | case WM_CALCVALIDRECTS:
|
|---|
| 559 | #if 0
|
|---|
| 560 | {
|
|---|
| 561 | PRECTL oldRect = (PRECTL)mp1,newRect = oldRect+1;
|
|---|
| 562 | UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
|
|---|
| 563 |
|
|---|
| 564 | //CB: todo: use WM_NCCALCSIZE result
|
|---|
| 565 | if (win32wnd->getWindowClass())
|
|---|
| 566 | {
|
|---|
| 567 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
|---|
| 568 |
|
|---|
| 569 | if ((dwStyle & CS_HREDRAW_W) && (newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft))
|
|---|
| 570 | res |= CVR_REDRAW;
|
|---|
| 571 | else
|
|---|
| 572 | if ((dwStyle & CS_VREDRAW_W) && (newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom))
|
|---|
| 573 | res |= CVR_REDRAW;
|
|---|
| 574 | }
|
|---|
| 575 | else res |= CVR_REDRAW;
|
|---|
| 576 |
|
|---|
| 577 | return (MRESULT)res;
|
|---|
| 578 | }
|
|---|
| 579 | #else
|
|---|
| 580 | dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
|---|
| 581 | return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
|---|
| 582 | #endif
|
|---|
| 583 |
|
|---|
| 584 | case WM_VRNENABLED:
|
|---|
| 585 | dprintf(("OS2: WM_VRNENABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 586 | if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
|
|---|
| 587 | {
|
|---|
| 588 | HWND hwndrelated;
|
|---|
| 589 | Win32BaseWindow *topwindow;
|
|---|
| 590 |
|
|---|
| 591 | win32wnd->setComingToTop(TRUE);
|
|---|
| 592 |
|
|---|
| 593 | hwndrelated = WinQueryWindow(hwnd, QW_PREV);
|
|---|
| 594 | dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
|
|---|
| 595 | topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
|
|---|
| 596 | if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
|
|---|
| 597 | //put window at the top of z order
|
|---|
| 598 | WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
|
|---|
| 599 | }
|
|---|
| 600 |
|
|---|
| 601 | win32wnd->setComingToTop(FALSE);
|
|---|
| 602 | break;
|
|---|
| 603 | }
|
|---|
| 604 | //test
|
|---|
| 605 | if(win32wnd->isOwnDC()) {
|
|---|
| 606 | dprintfOrigin(win32wnd->getOwnDC());
|
|---|
| 607 | selectClientArea(win32wnd, win32wnd->getOwnDC());
|
|---|
| 608 | }
|
|---|
| 609 | //test
|
|---|
| 610 | goto RunDefWndProc;
|
|---|
| 611 |
|
|---|
| 612 | case WM_VRNDISABLED:
|
|---|
| 613 | dprintf(("OS2: WM_VRNDISABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 614 | if(win32wnd->isOwnDC()) {
|
|---|
| 615 | dprintfOrigin(win32wnd->getOwnDC());
|
|---|
| 616 | }
|
|---|
| 617 | goto RunDefWndProc;
|
|---|
| 618 |
|
|---|
| 619 | case WM_SETFOCUS:
|
|---|
| 620 | {
|
|---|
| 621 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 622 |
|
|---|
| 623 | dprintf(("OS2: WM_SETFOCUS %x %x (%x) %d", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2));
|
|---|
| 624 |
|
|---|
| 625 | //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
|
|---|
| 626 | //must delay this function call
|
|---|
| 627 |
|
|---|
| 628 | teb->o.odin.fWM_SETFOCUS = TRUE;
|
|---|
| 629 | teb->o.odin.hwndFocus = 0;
|
|---|
| 630 | if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
|
|---|
| 631 | //another (non-win32) application's window
|
|---|
| 632 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
|---|
| 633 | hwndFocus = NULL;
|
|---|
| 634 | }
|
|---|
| 635 | if((ULONG)mp2 == TRUE) {
|
|---|
| 636 | HWND hwndFocusWin32 = OS2ToWin32Handle(hwndFocus);
|
|---|
| 637 | recreateCaret (hwndFocusWin32);
|
|---|
| 638 | win32wnd->MsgSetFocus(hwndFocusWin32);
|
|---|
| 639 | }
|
|---|
| 640 | else win32wnd->MsgKillFocus(OS2ToWin32Handle(hwndFocus));
|
|---|
| 641 | teb->o.odin.fWM_SETFOCUS = FALSE;
|
|---|
| 642 |
|
|---|
| 643 | break;
|
|---|
| 644 | }
|
|---|
| 645 |
|
|---|
| 646 | #if 0
|
|---|
| 647 | //is sent to both windows gaining and loosing the focus
|
|---|
| 648 | case WM_FOCUSCHANGE:
|
|---|
| 649 | {
|
|---|
| 650 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 651 | HWND hwndLoseFocus, hwndGainFocus;
|
|---|
| 652 | USHORT usSetFocus = SHORT1FROMMP(mp2);
|
|---|
| 653 | USHORT fsFocusChange = SHORT2FROMMP(mp2);
|
|---|
| 654 |
|
|---|
| 655 | rc = 0;
|
|---|
| 656 | dprintf(("OS2: WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
|
|---|
| 657 | if(usSetFocus) {
|
|---|
| 658 | hwndGainFocus = hwnd;
|
|---|
| 659 | hwndLoseFocus = hwndFocus;
|
|---|
| 660 | }
|
|---|
| 661 | else {
|
|---|
| 662 | hwndGainFocus = hwndFocus;
|
|---|
| 663 | hwndLoseFocus = hwnd;
|
|---|
| 664 | }
|
|---|
| 665 |
|
|---|
| 666 | if(usSetFocus)
|
|---|
| 667 | {
|
|---|
| 668 | Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndLoseFocus);
|
|---|
| 669 | if(!(fsFocusChange & FC_NOSETACTIVE))
|
|---|
| 670 | {
|
|---|
| 671 | if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
|
|---|
| 672 | {
|
|---|
| 673 | if(winfocus)
|
|---|
| 674 | WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
|
|---|
| 675 | else
|
|---|
| 676 | WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
|
|---|
| 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 | if(!(fsFocusChange & FC_NOSETACTIVE))
|
|---|
| 685 | {
|
|---|
| 686 | Win32BaseWindow *topparent = win32wnd->GetTopParent();
|
|---|
| 687 | if(!winfocus || (winfocus->GetTopParent() != topparent))
|
|---|
| 688 | {
|
|---|
| 689 | if(!(fsFocusChange & FC_NOBRINGTOTOP))
|
|---|
| 690 | {
|
|---|
| 691 | if(topparent) {
|
|---|
| 692 | //put window at the top of z order
|
|---|
| 693 | WinSetWindowPos(topparent->getOS2WindowHandle(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
|
|---|
| 694 | }
|
|---|
| 695 | }
|
|---|
| 696 |
|
|---|
| 697 | // PH 2000/09/01 Netscape 4.7
|
|---|
| 698 | // check if topparent is valid
|
|---|
| 699 | if (topparent)
|
|---|
| 700 | WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
|
|---|
| 701 | }
|
|---|
| 702 | }
|
|---|
| 703 | //SvL: Check if window is still valid
|
|---|
| 704 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 705 | if(win32wnd == NULL)
|
|---|
| 706 | return (MRESULT)rc;
|
|---|
| 707 |
|
|---|
| 708 | //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
|
|---|
| 709 | if(!(fsFocusChange & FC_NOSETSELECTION)) {
|
|---|
| 710 | WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
|
|---|
| 711 | }
|
|---|
| 712 |
|
|---|
| 713 | if(!(fsFocusChange & FC_NOSETFOCUS)) {
|
|---|
| 714 | WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
|
|---|
| 715 | }
|
|---|
| 716 | }
|
|---|
| 717 | else /* no usSetFocus */
|
|---|
| 718 | {
|
|---|
| 719 | if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
|
|---|
| 720 | WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
|
|---|
| 721 | }
|
|---|
| 722 | //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
|
|---|
| 723 | if(!(fsFocusChange & FC_NOLOSESELECTION)) {
|
|---|
| 724 | WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
|
|---|
| 725 | }
|
|---|
| 726 | //SvL: Check if window is still valid
|
|---|
| 727 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 728 | if(win32wnd == NULL) {
|
|---|
| 729 | return (MRESULT)rc;
|
|---|
| 730 | }
|
|---|
| 731 |
|
|---|
| 732 | Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
|
|---|
| 733 | if(!(fsFocusChange & FC_NOLOSEACTIVE))
|
|---|
| 734 | {
|
|---|
| 735 | Win32BaseWindow *topparent = win32wnd->GetTopParent();
|
|---|
| 736 |
|
|---|
| 737 | if(!winfocus || (winfocus->GetTopParent() != topparent))
|
|---|
| 738 | {
|
|---|
| 739 | // PH 2000/09/01 Netscape 4.7
|
|---|
| 740 | // check if topparent is valid
|
|---|
| 741 | if (topparent)
|
|---|
| 742 | WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
|
|---|
| 743 | }
|
|---|
| 744 | }
|
|---|
| 745 | //SvL: Check if window is still valid
|
|---|
| 746 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 747 | if(win32wnd == NULL)
|
|---|
| 748 | return (MRESULT)rc;
|
|---|
| 749 |
|
|---|
| 750 | if(!(fsFocusChange & FC_NOSETACTIVE))
|
|---|
| 751 | {
|
|---|
| 752 | if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
|
|---|
| 753 | {
|
|---|
| 754 | if(winfocus)
|
|---|
| 755 | {
|
|---|
| 756 | // PH 2000/09/01 Netscape 4.7
|
|---|
| 757 | // check if topparent is valid
|
|---|
| 758 | Win32BaseWindow *topparent = winfocus->GetTopParent();
|
|---|
| 759 | if (topparent)
|
|---|
| 760 | WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
|
|---|
| 761 | }
|
|---|
| 762 | else
|
|---|
| 763 | WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
|
|---|
| 764 | }
|
|---|
| 765 | }
|
|---|
| 766 | }
|
|---|
| 767 |
|
|---|
| 768 |
|
|---|
| 769 | #ifdef DEBUG
|
|---|
| 770 | SetWin32TIB();
|
|---|
| 771 | dprintf(("OS2: WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 772 | #endif
|
|---|
| 773 | return (MRESULT)rc;
|
|---|
| 774 | }
|
|---|
| 775 | #endif
|
|---|
| 776 |
|
|---|
| 777 | //**************************************************************************
|
|---|
| 778 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
|---|
| 779 | //**************************************************************************
|
|---|
| 780 | case WM_HITTEST:
|
|---|
| 781 | {
|
|---|
| 782 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 783 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 784 | }
|
|---|
| 785 | if(win32wnd && win32wnd->IsWindowCreated())
|
|---|
| 786 | {
|
|---|
| 787 | MRESULT rc;
|
|---|
| 788 |
|
|---|
| 789 | rc = (MRESULT)win32wnd->MsgHitTest(pWinMsg);
|
|---|
| 790 | return rc;
|
|---|
| 791 | }
|
|---|
| 792 | return (MRESULT)HT_NORMAL;
|
|---|
| 793 | }
|
|---|
| 794 |
|
|---|
| 795 | case WM_BUTTON1DOWN:
|
|---|
| 796 | case WM_BUTTON1UP:
|
|---|
| 797 | case WM_BUTTON1DBLCLK:
|
|---|
| 798 | case WM_BUTTON2DOWN:
|
|---|
| 799 | case WM_BUTTON2UP:
|
|---|
| 800 | case WM_BUTTON2DBLCLK:
|
|---|
| 801 | case WM_BUTTON3DOWN:
|
|---|
| 802 | case WM_BUTTON3UP:
|
|---|
| 803 | case WM_BUTTON3DBLCLK:
|
|---|
| 804 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 805 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 806 | }
|
|---|
| 807 | if(win32wnd)
|
|---|
| 808 | win32wnd->MsgButton(pWinMsg);
|
|---|
| 809 |
|
|---|
| 810 | rc = (MRESULT)TRUE;
|
|---|
| 811 | break;
|
|---|
| 812 |
|
|---|
| 813 | case WM_BUTTON2MOTIONSTART:
|
|---|
| 814 | case WM_BUTTON2MOTIONEND:
|
|---|
| 815 | case WM_BUTTON2CLICK:
|
|---|
| 816 | case WM_BUTTON1MOTIONSTART:
|
|---|
| 817 | case WM_BUTTON1MOTIONEND:
|
|---|
| 818 | case WM_BUTTON1CLICK:
|
|---|
| 819 | case WM_BUTTON3MOTIONSTART:
|
|---|
| 820 | case WM_BUTTON3MOTIONEND:
|
|---|
| 821 | case WM_BUTTON3CLICK:
|
|---|
| 822 | rc = (MRESULT)TRUE;
|
|---|
| 823 | break;
|
|---|
| 824 |
|
|---|
| 825 | case WM_MOUSEMOVE:
|
|---|
| 826 | {
|
|---|
| 827 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 828 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 829 | }
|
|---|
| 830 | if(win32wnd)
|
|---|
| 831 | win32wnd->MsgMouseMove(pWinMsg);
|
|---|
| 832 | break;
|
|---|
| 833 | }
|
|---|
| 834 |
|
|---|
| 835 | case WM_CONTROL:
|
|---|
| 836 | goto RunDefWndProc;
|
|---|
| 837 |
|
|---|
| 838 | case WM_COMMAND:
|
|---|
| 839 | dprintf(("OS2: WM_COMMAND %x %x %x", hwnd, mp1, mp2));
|
|---|
| 840 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 841 | break;
|
|---|
| 842 |
|
|---|
| 843 | case WM_SYSCOMMAND:
|
|---|
| 844 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 845 | break;
|
|---|
| 846 |
|
|---|
| 847 | case WM_RENDERFMT:
|
|---|
| 848 | case WM_RENDERALLFMTS:
|
|---|
| 849 | case WM_DESTROYCLIPBOARD:
|
|---|
| 850 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 851 | break;
|
|---|
| 852 |
|
|---|
| 853 | case WM_CHAR:
|
|---|
| 854 | win32wnd->MsgChar(pWinMsg);
|
|---|
| 855 | break;
|
|---|
| 856 |
|
|---|
| 857 | case WM_TIMER:
|
|---|
| 858 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 859 | goto RunDefWndProc;
|
|---|
| 860 |
|
|---|
| 861 | case WM_SETWINDOWPARAMS:
|
|---|
| 862 | {
|
|---|
| 863 | WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
|
|---|
| 864 |
|
|---|
| 865 | dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
|
|---|
| 866 | if(wndParams->fsStatus & WPM_TEXT) {
|
|---|
| 867 | win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
|
|---|
| 868 | }
|
|---|
| 869 | goto RunDefWndProc;
|
|---|
| 870 | }
|
|---|
| 871 |
|
|---|
| 872 | case WM_QUERYWINDOWPARAMS:
|
|---|
| 873 | {
|
|---|
| 874 | PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
|
|---|
| 875 | ULONG textlen;
|
|---|
| 876 | PSZ wintext;
|
|---|
| 877 |
|
|---|
| 878 | if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
|
|---|
| 879 | {
|
|---|
| 880 | if(wndpars->fsStatus & WPM_TEXT)
|
|---|
| 881 | win32wnd->MsgGetText(wndpars->pszText, wndpars->cchText);
|
|---|
| 882 | if(wndpars->fsStatus & WPM_CCHTEXT)
|
|---|
| 883 | wndpars->cchText = win32wnd->MsgGetTextLength();
|
|---|
| 884 |
|
|---|
| 885 | wndpars->fsStatus = 0;
|
|---|
| 886 | wndpars->cbCtlData = 0;
|
|---|
| 887 | wndpars->cbPresParams = 0;
|
|---|
| 888 | return (MRESULT)TRUE;
|
|---|
| 889 | }
|
|---|
| 890 | goto RunDefWndProc;
|
|---|
| 891 | }
|
|---|
| 892 |
|
|---|
| 893 | case WM_PAINT:
|
|---|
| 894 | {
|
|---|
| 895 | RECTL rectl;
|
|---|
| 896 | BOOL rc;
|
|---|
| 897 |
|
|---|
| 898 | rc = WinQueryUpdateRect(hwnd, &rectl);
|
|---|
| 899 | dprintf(("OS2: WM_PAINT %x (%d,%d) (%d,%d) rc=%d", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop, rc));
|
|---|
| 900 |
|
|---|
| 901 | if(rc && win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
|
|---|
| 902 | rectl.yBottom != rectl.yTop))
|
|---|
| 903 | {
|
|---|
| 904 | PRECT pClient = win32wnd->getClientRectPtr();
|
|---|
| 905 | PRECT pWindow = win32wnd->getWindowRect();
|
|---|
| 906 |
|
|---|
| 907 | if(!(pClient->left == 0 && pClient->top == 0 &&
|
|---|
| 908 | win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
|
|---|
| 909 | win32wnd->getClientWidth() == win32wnd->getWindowWidth()))
|
|---|
| 910 | {
|
|---|
| 911 | win32wnd->MsgNCPaint();
|
|---|
| 912 | }
|
|---|
| 913 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 914 | }
|
|---|
| 915 | else goto RunDefWndProc;
|
|---|
| 916 |
|
|---|
| 917 | //SvL: Not calling the default window procedure causes all sorts of
|
|---|
| 918 | // strange problems (redraw & hanging app)
|
|---|
| 919 | // -> check what WinBeginPaint does what we're forgetting in BeginPaint
|
|---|
| 920 | // WinQueryUpdateRect(hwnd, &rectl);
|
|---|
| 921 | // if(rectl.xLeft == 0 && rectl.yTop == 0 && rectl.xRight == 0 && rectl.yBottom == 0) {
|
|---|
| 922 | // RestoreOS2TIB();
|
|---|
| 923 | // return (MRESULT)FALSE;
|
|---|
| 924 | // }
|
|---|
| 925 | // dprintf(("Update rectangle (%d,%d)(%d,%d) not empty, msg %x", rectl.xLeft, rectl.yTop, rectl.xRight, rectl.yBottom, pWinMsg->message));
|
|---|
| 926 | // goto RunDefWndProc;
|
|---|
| 927 | break;
|
|---|
| 928 | }
|
|---|
| 929 |
|
|---|
| 930 | case WM_ERASEBACKGROUND:
|
|---|
| 931 | {
|
|---|
| 932 | dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
|---|
| 933 | return (MRESULT)FALSE;
|
|---|
| 934 | }
|
|---|
| 935 |
|
|---|
| 936 | #if 0
|
|---|
| 937 | case WM_CONTEXTMENU:
|
|---|
| 938 | {
|
|---|
| 939 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 940 |
|
|---|
| 941 | return (MRESULT)TRUE;
|
|---|
| 942 | }
|
|---|
| 943 | #endif
|
|---|
| 944 |
|
|---|
| 945 | case WM_QUERYTRACKINFO:
|
|---|
| 946 | {
|
|---|
| 947 | PTRACKINFO trackInfo = (PTRACKINFO)mp2;
|
|---|
| 948 |
|
|---|
| 949 | dprintf(("OS2: WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
|
|---|
| 950 | trackInfo->cxBorder = 4;
|
|---|
| 951 | trackInfo->cyBorder = 4;
|
|---|
| 952 | win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
|
|---|
| 953 | return (MRESULT)TRUE;
|
|---|
| 954 | }
|
|---|
| 955 |
|
|---|
| 956 | case WM_QUERYBORDERSIZE:
|
|---|
| 957 | {
|
|---|
| 958 | PWPOINT size = (PWPOINT)mp1;
|
|---|
| 959 |
|
|---|
| 960 | dprintf(("OS2: WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
|
|---|
| 961 |
|
|---|
| 962 | size->x = 0;
|
|---|
| 963 | size->y = 0;
|
|---|
| 964 | return (MRESULT)TRUE;
|
|---|
| 965 | }
|
|---|
| 966 |
|
|---|
| 967 | case WM_REALIZEPALETTE:
|
|---|
| 968 | {
|
|---|
| 969 | dprintf(("OS2: WM_REALIZEPALETTE"));
|
|---|
| 970 | goto RunDefWndProc;
|
|---|
| 971 | }
|
|---|
| 972 |
|
|---|
| 973 | case WM_OWNERPOSCHANGE:
|
|---|
| 974 | {
|
|---|
| 975 | dprintf(("OS2: WM_OWNERPOSCHANGE"));
|
|---|
| 976 | goto RunDefWndProc;
|
|---|
| 977 | }
|
|---|
| 978 |
|
|---|
| 979 | case WM_INITMENU:
|
|---|
| 980 | case WM_MENUSELECT:
|
|---|
| 981 | case WM_MENUEND:
|
|---|
| 982 | case WM_NEXTMENU:
|
|---|
| 983 | case WM_SYSCOLORCHANGE:
|
|---|
| 984 | case WM_SYSVALUECHANGED:
|
|---|
| 985 | case WM_SETSELECTION:
|
|---|
| 986 | case WM_PPAINT:
|
|---|
| 987 | case WM_PSETFOCUS:
|
|---|
| 988 | case WM_PSYSCOLORCHANGE:
|
|---|
| 989 | case WM_PSIZE:
|
|---|
| 990 | case WM_PACTIVATE:
|
|---|
| 991 | case WM_PCONTROL:
|
|---|
| 992 | case WM_HELP:
|
|---|
| 993 | case WM_APPTERMINATENOTIFY:
|
|---|
| 994 | case WM_PRESPARAMCHANGED:
|
|---|
| 995 | case WM_DRAWITEM:
|
|---|
| 996 | case WM_MEASUREITEM:
|
|---|
| 997 | case WM_CONTROLPOINTER:
|
|---|
| 998 | case WM_QUERYDLGCODE:
|
|---|
| 999 | case WM_SUBSTITUTESTRING:
|
|---|
| 1000 | case WM_MATCHMNEMONIC:
|
|---|
| 1001 | case WM_SAVEAPPLICATION:
|
|---|
| 1002 | case WM_SEMANTICEVENT:
|
|---|
| 1003 | default:
|
|---|
| 1004 | dprintf2(("OS2: RunDefWndProc hwnd %x msg %x mp1 %x mp2 %x", hwnd, msg, mp1, mp2));
|
|---|
| 1005 | RestoreOS2TIB();
|
|---|
| 1006 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 1007 | }
|
|---|
| 1008 | return (MRESULT)rc;
|
|---|
| 1009 |
|
|---|
| 1010 | RunDefWndProc:
|
|---|
| 1011 | // dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
|
|---|
| 1012 | RestoreOS2TIB();
|
|---|
| 1013 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 1014 | } /* End of Win32WindowProc */
|
|---|
| 1015 | //******************************************************************************
|
|---|
| 1016 | //******************************************************************************
|
|---|
| 1017 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 1018 | {
|
|---|
| 1019 | POSTMSG_PACKET *postmsg;
|
|---|
| 1020 | OSLIBPOINT point, ClientPoint;
|
|---|
| 1021 | Win32BaseWindow *win32wnd;
|
|---|
| 1022 | TEB *teb;
|
|---|
| 1023 | MRESULT rc = 0;
|
|---|
| 1024 | MSG winMsg, *pWinMsg;
|
|---|
| 1025 |
|
|---|
| 1026 | //Restore our FS selector
|
|---|
| 1027 | SetWin32TIB();
|
|---|
| 1028 |
|
|---|
| 1029 | //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
|
|---|
| 1030 | teb = GetThreadTEB();
|
|---|
| 1031 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 1032 |
|
|---|
| 1033 | if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
|
|---|
| 1034 | dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
|
|---|
| 1035 | goto RunDefFrameWndProc;
|
|---|
| 1036 | }
|
|---|
| 1037 | //// if(teb->o.odin.fIgnoreMsgs) {
|
|---|
| 1038 | //// goto RunDefWndProc;
|
|---|
| 1039 | //// }
|
|---|
| 1040 |
|
|---|
| 1041 | if((teb->o.odin.msgstate & 1) == 0)
|
|---|
| 1042 | {//message that was sent directly to our window proc handler; translate it here
|
|---|
| 1043 | QMSG qmsg;
|
|---|
| 1044 |
|
|---|
| 1045 | qmsg.msg = msg;
|
|---|
| 1046 | qmsg.hwnd = hwnd;
|
|---|
| 1047 | qmsg.mp1 = mp1;
|
|---|
| 1048 | qmsg.mp2 = mp2;
|
|---|
| 1049 | qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
|
|---|
| 1050 | WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
|
|---|
| 1051 | qmsg.reserved = 0;
|
|---|
| 1052 |
|
|---|
| 1053 | if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
|---|
| 1054 | {//message was not translated
|
|---|
| 1055 | memset(&winMsg, 0, sizeof(MSG));
|
|---|
| 1056 | }
|
|---|
| 1057 | pWinMsg = &winMsg;
|
|---|
| 1058 | }
|
|---|
| 1059 | else {
|
|---|
| 1060 | pWinMsg = &teb->o.odin.msg;
|
|---|
| 1061 | teb->o.odin.msgstate++;
|
|---|
| 1062 | }
|
|---|
| 1063 | //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
|
|---|
| 1064 |
|
|---|
| 1065 | switch( msg )
|
|---|
| 1066 | {
|
|---|
| 1067 | case WM_CREATE:
|
|---|
| 1068 | {
|
|---|
| 1069 | RestoreOS2TIB();
|
|---|
| 1070 | pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
|---|
| 1071 | SetWin32TIB();
|
|---|
| 1072 | rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
|
|---|
| 1073 | break;
|
|---|
| 1074 | }
|
|---|
| 1075 |
|
|---|
| 1076 | case WM_CALCFRAMERECT:
|
|---|
| 1077 | dprintf(("OS2: WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
|
|---|
| 1078 | rc = (MRESULT)TRUE;
|
|---|
| 1079 | break;
|
|---|
| 1080 |
|
|---|
| 1081 | case WM_QUERYCTLTYPE:
|
|---|
| 1082 | // This is a frame window
|
|---|
| 1083 | dprintf(("OS2: WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
|
|---|
| 1084 | rc = (MRESULT)CCT_FRAME;
|
|---|
| 1085 | break;
|
|---|
| 1086 |
|
|---|
| 1087 | case WM_QUERYFOCUSCHAIN:
|
|---|
| 1088 | dprintf(("OS2: WM_QUERYFOCUSCHAIN %x", win32wnd->getWindowHandle()));
|
|---|
| 1089 | goto RunDefFrameWndProc;
|
|---|
| 1090 |
|
|---|
| 1091 | case WM_FOCUSCHANGE:
|
|---|
| 1092 | {
|
|---|
| 1093 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 1094 | HWND hwndLoseFocus, hwndGainFocus;
|
|---|
| 1095 | USHORT usSetFocus = SHORT1FROMMP(mp2);
|
|---|
| 1096 | USHORT fsFocusChange = SHORT2FROMMP(mp2);
|
|---|
| 1097 |
|
|---|
| 1098 | dprintf(("OS2: WM_FOCUSCHANGE %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
|
|---|
| 1099 | goto RunDefFrameWndProc;
|
|---|
| 1100 | }
|
|---|
| 1101 |
|
|---|
| 1102 | case WM_ACTIVATE:
|
|---|
| 1103 | case WM_SETFOCUS:
|
|---|
| 1104 | {
|
|---|
| 1105 | rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
|
|---|
| 1106 | goto RunDefFrameWndProc;
|
|---|
| 1107 | }
|
|---|
| 1108 |
|
|---|
| 1109 | #if 0
|
|---|
| 1110 | //just a test
|
|---|
| 1111 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 1112 | case WM_WINDOWPOSCHANGED:
|
|---|
| 1113 | {
|
|---|
| 1114 | rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
|
|---|
| 1115 | goto RunDefFrameWndProc;
|
|---|
| 1116 | }
|
|---|
| 1117 | #endif
|
|---|
| 1118 |
|
|---|
| 1119 | case WM_QUERYFRAMEINFO:
|
|---|
| 1120 | dprintf(("OS2: WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
|
|---|
| 1121 | goto RunDefFrameWndProc;
|
|---|
| 1122 |
|
|---|
| 1123 | case WM_FORMATFRAME:
|
|---|
| 1124 | dprintf(("OS2: WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
|
|---|
| 1125 | goto RunDefFrameWndProc;
|
|---|
| 1126 |
|
|---|
| 1127 | case WM_ADJUSTFRAMEPOS:
|
|---|
| 1128 | {
|
|---|
| 1129 | PSWP pswp = (PSWP)mp1;
|
|---|
| 1130 |
|
|---|
| 1131 | 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));
|
|---|
| 1132 | goto RunDefFrameWndProc;
|
|---|
| 1133 | }
|
|---|
| 1134 |
|
|---|
| 1135 | case WM_MINMAXFRAME:
|
|---|
| 1136 | {
|
|---|
| 1137 | PSWP swp = (PSWP)mp1;
|
|---|
| 1138 |
|
|---|
| 1139 | if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
|
|---|
| 1140 |
|
|---|
| 1141 | dprintf(("OS2: WM_MINMAXFRAME %x",hwnd));
|
|---|
| 1142 | if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
|---|
| 1143 | {
|
|---|
| 1144 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MINIMIZE_W) | WS_MAXIMIZE_W);
|
|---|
| 1145 |
|
|---|
| 1146 | RECT rect;
|
|---|
| 1147 |
|
|---|
| 1148 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
|---|
| 1149 | win32wnd->AdjustMaximizedRect(&rect);
|
|---|
| 1150 | swp->x += rect.left;
|
|---|
| 1151 | swp->cx += rect.right-rect.left;
|
|---|
| 1152 | swp->y -= rect.bottom;
|
|---|
| 1153 | swp->cy += rect.bottom-rect.top;
|
|---|
| 1154 | }
|
|---|
| 1155 | else
|
|---|
| 1156 | if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
|
|---|
| 1157 | {
|
|---|
| 1158 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
|
|---|
| 1159 | }
|
|---|
| 1160 | else
|
|---|
| 1161 | if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
|
|---|
| 1162 | {
|
|---|
| 1163 | win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
|
|---|
| 1164 | }
|
|---|
| 1165 | goto RunDefWndProc;
|
|---|
| 1166 | }
|
|---|
| 1167 |
|
|---|
| 1168 | case WM_UPDATEFRAME:
|
|---|
| 1169 | dprintf(("OS2: WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
|
|---|
| 1170 | goto RunDefFrameWndProc;
|
|---|
| 1171 |
|
|---|
| 1172 | default:
|
|---|
| 1173 | rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
|
|---|
| 1174 | break;
|
|---|
| 1175 | }
|
|---|
| 1176 | RestoreOS2TIB();
|
|---|
| 1177 | return (MRESULT)rc;
|
|---|
| 1178 |
|
|---|
| 1179 | RunDefFrameWndProc:
|
|---|
| 1180 | RestoreOS2TIB();
|
|---|
| 1181 | return pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
|---|
| 1182 |
|
|---|
| 1183 | RunDefWndProc:
|
|---|
| 1184 | RestoreOS2TIB();
|
|---|
| 1185 | return Win32WindowProc(hwnd, msg, mp1, mp2);
|
|---|
| 1186 | }
|
|---|
| 1187 | //******************************************************************************
|
|---|
| 1188 | //TODO: Quickly moving a window two times doesn't force a repaint (1st time)
|
|---|
| 1189 | //******************************************************************************
|
|---|
| 1190 | VOID FrameTrackFrame(Win32BaseWindow *win32wnd,DWORD flags)
|
|---|
| 1191 | {
|
|---|
| 1192 | TRACKINFO track;
|
|---|
| 1193 | RECTL rcl;
|
|---|
| 1194 | PRECT pWindowRect, pClientRect;
|
|---|
| 1195 | HWND hwndTracking;
|
|---|
| 1196 | HPS hpsTrack;
|
|---|
| 1197 | LONG parentHeight, parentWidth;
|
|---|
| 1198 |
|
|---|
| 1199 | dprintf(("FrameTrackFrame: %x %x", win32wnd->getWindowHandle(), flags));
|
|---|
| 1200 | track.cxBorder = 4;
|
|---|
| 1201 | track.cyBorder = 4; /* 4 pel wide lines used for rectangle */
|
|---|
| 1202 | track.cxGrid = 1;
|
|---|
| 1203 | track.cyGrid = 1; /* smooth tracking with mouse */
|
|---|
| 1204 | track.cxKeyboard = 8;
|
|---|
| 1205 | track.cyKeyboard = 8; /* faster tracking using cursor keys */
|
|---|
| 1206 |
|
|---|
| 1207 | pWindowRect = win32wnd->getWindowRect();
|
|---|
| 1208 | if(win32wnd->getParent()) {
|
|---|
| 1209 | parentHeight = win32wnd->getParent()->getWindowHeight();
|
|---|
| 1210 | parentWidth = win32wnd->getParent()->getWindowWidth();
|
|---|
| 1211 | hwndTracking = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 1212 | hpsTrack = WinGetPS(hwndTracking);
|
|---|
| 1213 | }
|
|---|
| 1214 | else {
|
|---|
| 1215 | parentHeight = OSLibQueryScreenHeight();
|
|---|
| 1216 | parentWidth = OSLibQueryScreenWidth();
|
|---|
| 1217 | hwndTracking = HWND_DESKTOP;
|
|---|
| 1218 | hpsTrack = NULL;
|
|---|
| 1219 | }
|
|---|
| 1220 |
|
|---|
| 1221 | mapWin32ToOS2Rect(parentHeight, pWindowRect, (PRECTLOS2)&track.rclTrack);
|
|---|
| 1222 | WinQueryWindowRect(hwndTracking, &track.rclBoundary);
|
|---|
| 1223 |
|
|---|
| 1224 | track.ptlMinTrackSize.x = 10;
|
|---|
| 1225 | track.ptlMinTrackSize.y = 10; /* set smallest allowed size of rectangle */
|
|---|
| 1226 | track.ptlMaxTrackSize.x = parentWidth;
|
|---|
| 1227 | track.ptlMaxTrackSize.y = parentHeight; /* set largest allowed size of rectangle */
|
|---|
| 1228 |
|
|---|
| 1229 | win32wnd->AdjustTrackInfo((PPOINT)&track.ptlMinTrackSize, (PPOINT)&track.ptlMaxTrackSize);
|
|---|
| 1230 |
|
|---|
| 1231 | track.fs = flags;
|
|---|
| 1232 |
|
|---|
| 1233 | if(WinTrackRect(hwndTracking, NULL, &track) )
|
|---|
| 1234 | {
|
|---|
| 1235 | if(hpsTrack) WinReleasePS(hpsTrack);
|
|---|
| 1236 |
|
|---|
| 1237 | /* if successful copy final position back */
|
|---|
| 1238 | if(!WinEqualRect(0, &rcl, &track.rclTrack)) {
|
|---|
| 1239 | 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));
|
|---|
| 1240 | if(flags == TF_MOVE) {
|
|---|
| 1241 | WinSetWindowPos(win32wnd->getOS2WindowHandle(),
|
|---|
| 1242 | 0, track.rclTrack.xLeft, track.rclTrack.yBottom,
|
|---|
| 1243 | 0, 0, SWP_MOVE);
|
|---|
| 1244 | }
|
|---|
| 1245 | else {
|
|---|
| 1246 | SetWindowPos(win32wnd->getWindowHandle(), 0, track.rclTrack.xLeft,
|
|---|
| 1247 | parentHeight - track.rclTrack.yTop,
|
|---|
| 1248 | track.rclTrack.xRight - track.rclTrack.xLeft,
|
|---|
| 1249 | track.rclTrack.yTop - track.rclTrack.yBottom,
|
|---|
| 1250 | SWP_NOACTIVATE_W | SWP_NOZORDER_W | SWP_NOACTIVATE_W);
|
|---|
| 1251 | // WinSetWindowPos(win32wnd->getOS2WindowHandle(),
|
|---|
| 1252 | // 0, track.rclTrack.xLeft, track.rclTrack.yBottom,
|
|---|
| 1253 | // track.rclTrack.xRight - track.rclTrack.xLeft,
|
|---|
| 1254 | // track.rclTrack.yTop - track.rclTrack.yBottom,
|
|---|
| 1255 | // SWP_SIZE|SWP_MOVE);
|
|---|
| 1256 | }
|
|---|
| 1257 | }
|
|---|
| 1258 | return;
|
|---|
| 1259 | }
|
|---|
| 1260 | if(hpsTrack) WinReleasePS(hpsTrack);
|
|---|
| 1261 | return;
|
|---|
| 1262 | }
|
|---|
| 1263 | //******************************************************************************
|
|---|
| 1264 | //******************************************************************************
|
|---|