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

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

WM_ADJUSTWINDOWPOS bugfix (if app changes size/position)

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