source: trunk/src/user32/pmwindow.cpp@ 5146

Last change on this file since 5146 was 5146, checked in by sandervl, 25 years ago

activate, tab and ischild bugfixes

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