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