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