| 1 | /* $Id: pmwindow.cpp,v 1.230 2004-05-24 09:01:59 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_DOSMODULEMGR
|
|---|
| 18 | #define INCL_DOSDEVICES
|
|---|
| 19 | #define INCL_DOSDEVIOCTL
|
|---|
| 20 | #define INCL_WINTRACKRECT
|
|---|
| 21 | #define INCL_BASE
|
|---|
| 22 |
|
|---|
| 23 | #include <os2wrap.h>
|
|---|
| 24 | #include <odinwrap.h>
|
|---|
| 25 | #include <stdlib.h>
|
|---|
| 26 | #include <string.h>
|
|---|
| 27 | #include <win32type.h>
|
|---|
| 28 | #include <win32api.h>
|
|---|
| 29 | #include <winconst.h>
|
|---|
| 30 | #include <winuser32.h>
|
|---|
| 31 | #include <wprocess.h>
|
|---|
| 32 | #include <dbglog.h>
|
|---|
| 33 | #include <win32wbase.h>
|
|---|
| 34 | #include <win32wfake.h>
|
|---|
| 35 | #include <win32dlg.h>
|
|---|
| 36 | #include "win32wdesktop.h"
|
|---|
| 37 | #include "pmwindow.h"
|
|---|
| 38 | #include "oslibwin.h"
|
|---|
| 39 | #include "oslibutil.h"
|
|---|
| 40 | #include "oslibgdi.h"
|
|---|
| 41 | #include "oslibmsg.h"
|
|---|
| 42 | #define INCLUDED_BY_DC
|
|---|
| 43 | #include "dc.h"
|
|---|
| 44 | #include <thread.h>
|
|---|
| 45 | #include <wprocess.h>
|
|---|
| 46 | #include <objhandle.h>
|
|---|
| 47 | #include "caret.h"
|
|---|
| 48 | #include "timer.h"
|
|---|
| 49 | #include <codepage.h>
|
|---|
| 50 | #include "syscolor.h"
|
|---|
| 51 | #include "options.h"
|
|---|
| 52 | #include "menu.h"
|
|---|
| 53 | #include <pmkbdhk.h>
|
|---|
| 54 | #include <pmscan.h>
|
|---|
| 55 | #include <winscan.h>
|
|---|
| 56 | #include <oslibdnd.h>
|
|---|
| 57 | #include <custombuild.h>
|
|---|
| 58 | #include <win\dbt.h>
|
|---|
| 59 | #include "dragdrop.h"
|
|---|
| 60 | #include "menu.h"
|
|---|
| 61 | #include "user32api.h"
|
|---|
| 62 | #include <kbdhook.h>
|
|---|
| 63 | #include <heapstring.h>
|
|---|
| 64 |
|
|---|
| 65 | #include <os2im.h>
|
|---|
| 66 | #include <im32.h>
|
|---|
| 67 |
|
|---|
| 68 | #define DBG_LOCALLOG DBG_pmwindow
|
|---|
| 69 | #include "dbglocal.h"
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 | // Notification that focus change has completed (UNDOCUMENTED)
|
|---|
| 73 | #define WM_FOCUSCHANGED 0x000e
|
|---|
| 74 |
|
|---|
| 75 | //define this to use the new code for WM_CALCVALIDRECT handling
|
|---|
| 76 | //#define USE_CALCVALIDRECT
|
|---|
| 77 |
|
|---|
| 78 | HMQ hmq = 0; /* Message queue handle */
|
|---|
| 79 | HAB hab = 0;
|
|---|
| 80 | RECTL desktopRectl = {0};
|
|---|
| 81 | ULONG ScreenWidth = 0;
|
|---|
| 82 | ULONG ScreenHeight = 0;
|
|---|
| 83 | ULONG ScreenBitsPerPel = 0;
|
|---|
| 84 | BOOL fOS2Look = FALSE;
|
|---|
| 85 | BOOL fForceMonoCursor = FALSE;
|
|---|
| 86 | BOOL fDragDropActive = FALSE;
|
|---|
| 87 | BOOL fDragDropDisabled = FALSE;
|
|---|
| 88 |
|
|---|
| 89 | const char WIN32_CDCLASS[] = ODIN_WIN32_CDCLASS;
|
|---|
| 90 | char WIN32_STDCLASS[255] = ODIN_WIN32_STDCLASS;
|
|---|
| 91 |
|
|---|
| 92 | #define PMMENU_MINBUTTON 0
|
|---|
| 93 | #define PMMENU_MAXBUTTON 1
|
|---|
| 94 | #define PMMENU_RESTOREBUTTON 2
|
|---|
| 95 | #define PMMENU_CLOSEBUTTON 3
|
|---|
| 96 | #define PMMENU_MINBUTTONDOWN 4
|
|---|
| 97 | #define PMMENU_MAXBUTTONDOWN 5
|
|---|
| 98 | #define PMMENU_RESTOREBUTTONDOWN 6
|
|---|
| 99 | #define PMMENU_CLOSEBUTTONDOWN 7
|
|---|
| 100 |
|
|---|
| 101 | HBITMAP hbmFrameMenu[8] = {0};
|
|---|
| 102 |
|
|---|
| 103 | //Win32 bitmap handles of the OS/2 min, max and restore buttons
|
|---|
| 104 | HBITMAP hBmpMinButton = 0;
|
|---|
| 105 | HBITMAP hBmpMaxButton = 0;
|
|---|
| 106 | HBITMAP hBmpRestoreButton = 0;
|
|---|
| 107 | HBITMAP hBmpCloseButton = 0;
|
|---|
| 108 | HBITMAP hBmpMinButtonDown = 0;
|
|---|
| 109 | HBITMAP hBmpMaxButtonDown = 0;
|
|---|
| 110 | HBITMAP hBmpRestoreButtonDown = 0;
|
|---|
| 111 | HBITMAP hBmpCloseButtonDown = 0;
|
|---|
| 112 |
|
|---|
| 113 | PFNWP pfnFrameWndProc = NULL;
|
|---|
| 114 | static HWND hwndFocusChange = 0;
|
|---|
| 115 | HWND hwndCD = 0;
|
|---|
| 116 |
|
|---|
| 117 | // this holds the font height that the display driver returns using DevQueryCaps
|
|---|
| 118 | // 13 would be small fonts, 16 medium fonts and 20 large fonts
|
|---|
| 119 | LONG CapsCharHeight = 0;
|
|---|
| 120 |
|
|---|
| 121 | // Note:
|
|---|
| 122 | // For a "lonekey"-press of AltGr, we only receive WM_KEYUP
|
|---|
| 123 | // messages. If the key is pressed longer and starts to repeat,
|
|---|
| 124 | // WM_KEYDOWN messages come in properly.
|
|---|
| 125 | static BOOL fKeyAltGrDown = FALSE;
|
|---|
| 126 | static BOOL fEnableCDPolling = FALSE;
|
|---|
| 127 |
|
|---|
| 128 | static char *PMDragExtractFiles(PDRAGINFO pDragInfo, ULONG *pcItems, ULONG *pulBytes);
|
|---|
| 129 | static BOOL PMDragValidate(PDRAGINFO pDragInfo);
|
|---|
| 130 | static void QueryPMMenuBitmaps();
|
|---|
| 131 |
|
|---|
| 132 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
|---|
| 133 | MRESULT EXPENTRY Win32CDWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
|---|
| 134 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
|---|
| 135 | void FrameReplaceMenuItem(HWND hwndMenu, ULONG nIndex, ULONG idOld, ULONG idNew,
|
|---|
| 136 | HBITMAP hbmNew);
|
|---|
| 137 | void FrameSetFocus(HWND hwnd);
|
|---|
| 138 |
|
|---|
| 139 | VOID APIENTRY DspInitSystemDriverName(PSZ pszDriverName, ULONG lenDriverName);
|
|---|
| 140 |
|
|---|
| 141 | #ifdef DEBUG_LOGGING
|
|---|
| 142 | static char *DbgGetStringSWPFlags(ULONG flags);
|
|---|
| 143 | static char *DbgPrintQFCFlags(ULONG flags);
|
|---|
| 144 | #endif
|
|---|
| 145 |
|
|---|
| 146 | extern "C" ULONG OSLibImSetMsgQueueProperty( ULONG, ULONG );
|
|---|
| 147 |
|
|---|
| 148 | //******************************************************************************
|
|---|
| 149 | // Initialize PM; create hab, message queue and register special Win32 window classes
|
|---|
| 150 | //
|
|---|
| 151 | // This is called from the initterm, so we call it only once for each process.
|
|---|
| 152 | // We make sure PM is up and running for our purposes and init the existing
|
|---|
| 153 | // thread 0.
|
|---|
| 154 | //******************************************************************************
|
|---|
| 155 | BOOL InitPM()
|
|---|
| 156 | {
|
|---|
| 157 | hab = WinInitialize(0);
|
|---|
| 158 | dprintf(("Winitialize returned %x", hab));
|
|---|
| 159 | hmq = WinCreateMsgQueue(hab, 0);
|
|---|
| 160 |
|
|---|
| 161 | if(!hab || !hmq)
|
|---|
| 162 | {
|
|---|
| 163 | UINT error;
|
|---|
| 164 | //CB: only fail on real error
|
|---|
| 165 | error = WinGetLastError(hab) & 0xFFFF; //error code
|
|---|
| 166 | if (!hab || (error != PMERR_MSG_QUEUE_ALREADY_EXISTS))
|
|---|
| 167 | {
|
|---|
| 168 | dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
|
|---|
| 169 | dprintf((" Error = %x",error));
|
|---|
| 170 | if(error == PMERR_NOT_IN_A_PM_SESSION) return TRUE;
|
|---|
| 171 |
|
|---|
| 172 | return(FALSE);
|
|---|
| 173 | }
|
|---|
| 174 | else
|
|---|
| 175 | {
|
|---|
| 176 | if(!hab) {
|
|---|
| 177 | hab = WinQueryAnchorBlock(HWND_DESKTOP);
|
|---|
| 178 | dprintf(("WinQueryAnchorBlock returned %x", hab));
|
|---|
| 179 | }
|
|---|
| 180 | if(!hmq) {
|
|---|
| 181 | PTIB ptib;
|
|---|
| 182 | PPIB ppib;
|
|---|
| 183 |
|
|---|
| 184 | DosGetInfoBlocks(&ptib, &ppib);
|
|---|
| 185 |
|
|---|
| 186 | hmq = WinQueueFromID(hab, ppib->pib_ulpid, ptib->tib_ptib2->tib2_ultid);
|
|---|
| 187 | }
|
|---|
| 188 | }
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | // store our HAB and HMQ in the TEB - we need it quite often
|
|---|
| 192 | // and they don't map 1:1 to Windows entities
|
|---|
| 193 | SetThreadHAB(hab);
|
|---|
| 194 | dprintf(("InitPM: hmq = %x", hmq));
|
|---|
| 195 | SetThreadMessageQueue(hmq);
|
|---|
| 196 |
|
|---|
| 197 | //initialize keyboard hook for first thread
|
|---|
| 198 | hookInit(hab);
|
|---|
| 199 |
|
|---|
| 200 | BOOL rc = WinSetCp(hmq, GetDisplayCodepage());
|
|---|
| 201 | dprintf(("InitPM: WinSetCP was %sOK", rc ? "" : "not "));
|
|---|
| 202 |
|
|---|
| 203 | /* IM instace is created per message queue, that is, thread */
|
|---|
| 204 | if( IsDBCSEnv())
|
|---|
| 205 | OSLibImSetMsgQueueProperty( hmq, MQP_INSTANCE_PERMQ );
|
|---|
| 206 |
|
|---|
| 207 | //CD polling window class
|
|---|
| 208 | if(!WinRegisterClass( /* Register window class */
|
|---|
| 209 | hab, /* Anchor block handle */
|
|---|
| 210 | (PSZ)WIN32_CDCLASS, /* Window class name */
|
|---|
| 211 | (PFNWP)Win32CDWindowProc, /* Address of window procedure */
|
|---|
| 212 | 0,
|
|---|
| 213 | 0))
|
|---|
| 214 | {
|
|---|
| 215 | dprintf(("WinRegisterClass Win32BaseWindow failed"));
|
|---|
| 216 | return(FALSE);
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | //Standard Odin window class
|
|---|
| 220 | if(!WinRegisterClass( /* Register window class */
|
|---|
| 221 | hab, /* Anchor block handle */
|
|---|
| 222 | (PSZ)WIN32_STDCLASS, /* Window class name */
|
|---|
| 223 | (PFNWP)Win32WindowProc, /* Address of window procedure */
|
|---|
| 224 | 0,
|
|---|
| 225 | NROF_WIN32WNDBYTES))
|
|---|
| 226 | {
|
|---|
| 227 | dprintf(("WinRegisterClass Win32BaseWindow failed"));
|
|---|
| 228 | return(FALSE);
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 | //We no longer register our own frame window class as there is code in PM
|
|---|
| 232 | //that makes assumptions about frame window class names.
|
|---|
| 233 | //Instead we subclass the frame window right after creating it.
|
|---|
| 234 | CLASSINFO FrameClassInfo;
|
|---|
| 235 | if(!WinQueryClassInfo (hab, WC_FRAME, &FrameClassInfo)) {
|
|---|
| 236 | dprintf (("WinQueryClassInfo WC_FRAME failed"));
|
|---|
| 237 | return (FALSE);
|
|---|
| 238 | }
|
|---|
| 239 | pfnFrameWndProc = FrameClassInfo.pfnWindowProc;
|
|---|
| 240 |
|
|---|
| 241 | dprintf(("WC_FRAME style %x", FrameClassInfo.flClassStyle));
|
|---|
| 242 |
|
|---|
| 243 | // get the screen dimensions and store them
|
|---|
| 244 | WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
|
|---|
| 245 | ScreenWidth = desktopRectl.xRight;
|
|---|
| 246 | ScreenHeight = desktopRectl.yTop;
|
|---|
| 247 |
|
|---|
| 248 | HDC hdc; /* Device-context handle */
|
|---|
| 249 | /* context data structure */
|
|---|
| 250 | DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
|
|---|
| 251 | NULL, NULL, NULL};
|
|---|
| 252 |
|
|---|
| 253 | /* create memory device context - it's temporary to query some information */
|
|---|
| 254 | hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
|
|---|
| 255 |
|
|---|
| 256 | // check if we have the OS/2 Look and Feel enabled
|
|---|
| 257 | fOS2Look = PROFILE_GetOdinIniBool(ODINSYSTEM_SECTION, "OS2Look", TRUE);
|
|---|
| 258 | if(fOS2Look)
|
|---|
| 259 | {
|
|---|
| 260 | SYSCOLOR_Init(FALSE); //use OS/2 colors
|
|---|
| 261 | QueryPMMenuBitmaps();
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 | // find out which colordepth we're running
|
|---|
| 265 | DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, (PLONG)&ScreenBitsPerPel);
|
|---|
| 266 |
|
|---|
| 267 | // query the font height to find out whether we have small or large fonts
|
|---|
| 268 | DevQueryCaps(hdc, CAPS_GRAPHICS_CHAR_HEIGHT, 1, (PLONG)&CapsCharHeight);
|
|---|
| 269 | dprintf(("CAPS_GRAPHICS_CHAR_HEIGHT = %d", CapsCharHeight));
|
|---|
| 270 | if(CapsCharHeight > 16) {
|
|---|
| 271 | CapsCharHeight = 16;
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 | #ifdef DEBUG
|
|---|
| 275 | ULONG temp;
|
|---|
| 276 | DevQueryCaps(hdc, CAPS_GRAPHICS_CHAR_WIDTH, 1, (PLONG)&temp);
|
|---|
| 277 | dprintf(("CAPS_GRAPHICS_CHAR_WIDTH = %d", temp));
|
|---|
| 278 | DevQueryCaps(hdc, CAPS_CHAR_HEIGHT, 1, (PLONG)&temp);
|
|---|
| 279 | dprintf(("CAPS_CHAR_HEIGTH = %d", temp));
|
|---|
| 280 | DevQueryCaps(hdc, CAPS_CHAR_WIDTH, 1, (PLONG)&temp);
|
|---|
| 281 | dprintf(("CAPS_CHAR_WIDTH = %d", temp));
|
|---|
| 282 | DevQueryCaps(hdc, CAPS_SMALL_CHAR_HEIGHT, 1, (PLONG)&temp);
|
|---|
| 283 | dprintf(("CAPS_SMALL_CHAR_HEIGTH = %d", temp));
|
|---|
| 284 | DevQueryCaps(hdc, CAPS_SMALL_CHAR_WIDTH, 1, (PLONG)&temp);
|
|---|
| 285 | dprintf(("CAPS_SMALL_CHAR_WIDTH = %d", temp));
|
|---|
| 286 | DevQueryCaps(hdc, CAPS_VERTICAL_FONT_RES, 1,(PLONG)&temp);
|
|---|
| 287 | dprintf(("CAPS_VERTICAL_FONT_RES = %d", temp));
|
|---|
| 288 | DevQueryCaps(hdc, CAPS_HORIZONTAL_FONT_RES, 1,(PLONG)&temp);
|
|---|
| 289 | dprintf(("CAPS_HORIZONTAL_FONT_RES = %d", temp));
|
|---|
| 290 | #endif
|
|---|
| 291 |
|
|---|
| 292 | DevCloseDC(hdc);
|
|---|
| 293 |
|
|---|
| 294 | dprintf(("InitPM: Desktop (%d,%d) bpp %d font size %d", ScreenWidth, ScreenHeight, ScreenBitsPerPel, CapsCharHeight));
|
|---|
| 295 | return TRUE;
|
|---|
| 296 | } /* End of main */
|
|---|
| 297 | //******************************************************************************
|
|---|
| 298 | HBITMAP OPEN32API _O32_CreateBitmapFromPMHandle(HBITMAP hPMBitmap);
|
|---|
| 299 |
|
|---|
| 300 | inline HBITMAP O32_CreateBitmapFromPMHandle(HBITMAP hPMBitmap)
|
|---|
| 301 | {
|
|---|
| 302 | HBITMAP yyrc;
|
|---|
| 303 | USHORT sel = RestoreOS2FS();
|
|---|
| 304 |
|
|---|
| 305 | yyrc = _O32_CreateBitmapFromPMHandle(hPMBitmap);
|
|---|
| 306 | SetFS(sel);
|
|---|
| 307 |
|
|---|
| 308 | return yyrc;
|
|---|
| 309 | }
|
|---|
| 310 | //******************************************************************************
|
|---|
| 311 | static void QueryPMMenuBitmaps()
|
|---|
| 312 | {
|
|---|
| 313 | CHAR szDisplay[30];
|
|---|
| 314 | HMODULE hModDisplay;
|
|---|
| 315 |
|
|---|
| 316 | if(hbmFrameMenu[0] == 0)
|
|---|
| 317 | {
|
|---|
| 318 | CHAR szDisplay[30];
|
|---|
| 319 | HMODULE hModDisplay;
|
|---|
| 320 | HDC hdc; /* Device-context handle */
|
|---|
| 321 | DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
|
|---|
| 322 | NULL, NULL, NULL};
|
|---|
| 323 |
|
|---|
| 324 | /* create memory device context */
|
|---|
| 325 | hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
|
|---|
| 326 |
|
|---|
| 327 | DspInitSystemDriverName(szDisplay, sizeof(szDisplay));
|
|---|
| 328 | DosQueryModuleHandle(szDisplay, &hModDisplay);
|
|---|
| 329 |
|
|---|
| 330 | hbmFrameMenu[PMMENU_MINBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MINBUTTON, 0, 0);
|
|---|
| 331 | hbmFrameMenu[PMMENU_MINBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MINBUTTONDEP, 0, 0);
|
|---|
| 332 | hbmFrameMenu[PMMENU_MAXBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MAXBUTTON, 0, 0);
|
|---|
| 333 | hbmFrameMenu[PMMENU_MAXBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MAXBUTTONDEP, 0, 0);
|
|---|
| 334 | hbmFrameMenu[PMMENU_RESTOREBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_RESTOREBUTTON, 0, 0);
|
|---|
| 335 | hbmFrameMenu[PMMENU_RESTOREBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_RESTOREBUTTONDEP, 0, 0);
|
|---|
| 336 | hbmFrameMenu[PMMENU_CLOSEBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_CLOSE, 0, 0);
|
|---|
| 337 | hbmFrameMenu[PMMENU_CLOSEBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_CLOSEDEP, 0, 0);
|
|---|
| 338 |
|
|---|
| 339 | //Create win32 bitmap handles of the OS/2 min, max and restore buttons
|
|---|
| 340 | hBmpMinButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MINBUTTON]);
|
|---|
| 341 | ObjSetHandleFlag(hBmpMinButton, OBJHANDLE_FLAG_NODELETE, 1);
|
|---|
| 342 | hBmpMinButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MINBUTTONDOWN]);
|
|---|
| 343 | ObjSetHandleFlag(hBmpMinButtonDown, OBJHANDLE_FLAG_NODELETE, 1);
|
|---|
| 344 | hBmpMaxButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MAXBUTTON]);
|
|---|
| 345 | ObjSetHandleFlag(hBmpMaxButton, OBJHANDLE_FLAG_NODELETE, 1);
|
|---|
| 346 | hBmpMaxButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MAXBUTTONDOWN]);
|
|---|
| 347 | ObjSetHandleFlag(hBmpMaxButtonDown, OBJHANDLE_FLAG_NODELETE, 1);
|
|---|
| 348 | hBmpRestoreButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_RESTOREBUTTON]);
|
|---|
| 349 | ObjSetHandleFlag(hBmpRestoreButton, OBJHANDLE_FLAG_NODELETE, 1);
|
|---|
| 350 | hBmpRestoreButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_RESTOREBUTTONDOWN]);
|
|---|
| 351 | ObjSetHandleFlag(hBmpRestoreButtonDown, OBJHANDLE_FLAG_NODELETE, 1);
|
|---|
| 352 | hBmpCloseButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_CLOSEBUTTON]);
|
|---|
| 353 | ObjSetHandleFlag(hBmpCloseButton, OBJHANDLE_FLAG_NODELETE, 1);
|
|---|
| 354 | hBmpCloseButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_CLOSEBUTTONDOWN]);
|
|---|
| 355 | ObjSetHandleFlag(hBmpCloseButtonDown, OBJHANDLE_FLAG_NODELETE, 1);
|
|---|
| 356 | DevCloseDC(hdc);
|
|---|
| 357 | }
|
|---|
| 358 | }
|
|---|
| 359 | //******************************************************************************
|
|---|
| 360 | //******************************************************************************
|
|---|
| 361 | void WIN32API SetWindowAppearance(int fLooks)
|
|---|
| 362 | {
|
|---|
| 363 | if(fLooks == OS2_APPEARANCE || fLooks == OS2_APPEARANCE_SYSMENU)
|
|---|
| 364 | {
|
|---|
| 365 | SYSCOLOR_Init(FALSE); //use OS/2 colors
|
|---|
| 366 | QueryPMMenuBitmaps();
|
|---|
| 367 | }
|
|---|
| 368 | fOS2Look = fLooks;
|
|---|
| 369 | MENU_Init();
|
|---|
| 370 | }
|
|---|
| 371 | //******************************************************************************
|
|---|
| 372 | //******************************************************************************
|
|---|
| 373 | void WIN32API CustForceMonoCursor()
|
|---|
| 374 | {
|
|---|
| 375 | fForceMonoCursor = TRUE;
|
|---|
| 376 | }
|
|---|
| 377 | //******************************************************************************
|
|---|
| 378 | //******************************************************************************
|
|---|
| 379 | void WIN32API DisableDragDrop(BOOL fDisabled)
|
|---|
| 380 | {
|
|---|
| 381 | fDragDropDisabled = fDisabled;
|
|---|
| 382 | }
|
|---|
| 383 | //******************************************************************************
|
|---|
| 384 | // Turn on CD Polling (window with 2 second timer to check CD disk presence)
|
|---|
| 385 | //
|
|---|
| 386 | // NOTE: This can cause PM hangs when executing a program for a very long time
|
|---|
| 387 | // (block in IOCtl)
|
|---|
| 388 | //******************************************************************************
|
|---|
| 389 | void WIN32API CustEnableCDPolling()
|
|---|
| 390 | {
|
|---|
| 391 | fEnableCDPolling = TRUE;
|
|---|
| 392 | }
|
|---|
| 393 | //******************************************************************************
|
|---|
| 394 | //CD notification window class
|
|---|
| 395 | //******************************************************************************
|
|---|
| 396 | MRESULT EXPENTRY Win32CDWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 397 | {
|
|---|
| 398 | #pragma pack(1)
|
|---|
| 399 | typedef struct
|
|---|
| 400 | {
|
|---|
| 401 | BYTE ucCommandInfo;
|
|---|
| 402 | WORD usDriveUnit;
|
|---|
| 403 | } ParameterBlock;
|
|---|
| 404 | #pragma pack()
|
|---|
| 405 |
|
|---|
| 406 | MRESULT rc = 0;
|
|---|
| 407 | static ULONG drives[26] = {0};
|
|---|
| 408 | static int drivestatus[26] = {0};
|
|---|
| 409 |
|
|---|
| 410 | switch( msg )
|
|---|
| 411 | {
|
|---|
| 412 | //OS/2 msgs
|
|---|
| 413 | case WM_CREATE:
|
|---|
| 414 | {
|
|---|
| 415 | char drive[4];
|
|---|
| 416 |
|
|---|
| 417 | //skip floppy drives
|
|---|
| 418 | drive[0] = 'C';
|
|---|
| 419 | drive[1] = ':';
|
|---|
| 420 | drive[2] = '\0';
|
|---|
| 421 |
|
|---|
| 422 | for(int i=2;i<26;i++) {
|
|---|
| 423 | drives[i] = GetDriveTypeA(drive);
|
|---|
| 424 | if(drives[i] == DRIVE_CDROM_W)
|
|---|
| 425 | {
|
|---|
| 426 | DWORD parsize = sizeof(ParameterBlock);
|
|---|
| 427 | DWORD datasize = 2;
|
|---|
| 428 | WORD status = 0;
|
|---|
| 429 | DWORD rc;
|
|---|
| 430 | ParameterBlock parm;
|
|---|
| 431 |
|
|---|
| 432 | parm.ucCommandInfo = 0;
|
|---|
| 433 | parm.usDriveUnit = i;
|
|---|
| 434 | rc = DosDevIOCtl(-1, IOCTL_DISK, DSK_GETLOCKSTATUS, &parm, sizeof(parm), &parsize,
|
|---|
| 435 | &status, sizeof(status), &datasize);
|
|---|
| 436 | if(rc != NO_ERROR) {
|
|---|
| 437 | dprintf(("DosDevIOCtl failed with rc %d", rc));
|
|---|
| 438 | drives[i] = 0;
|
|---|
| 439 | continue;
|
|---|
| 440 | }
|
|---|
| 441 | //if no disk present, return FALSE
|
|---|
| 442 | if(status & 4) {
|
|---|
| 443 | drivestatus[i] = status & 4;
|
|---|
| 444 | }
|
|---|
| 445 | }
|
|---|
| 446 | drive[0]++;
|
|---|
| 447 | }
|
|---|
| 448 | WinStartTimer(hab, hwnd, TIMERID_DRIVEPOLL, 32*60);
|
|---|
| 449 | //// WinStartTimer(hab, hwnd, TIMERID_DRIVEPOLL, 32*3);
|
|---|
| 450 | //// WinStartTimer(hab, hwnd, TIMERID_DRIVEPOLL, 5000);
|
|---|
| 451 | rc = (MRESULT)FALSE;
|
|---|
| 452 | break;
|
|---|
| 453 | }
|
|---|
| 454 | case WM_TIMER:
|
|---|
| 455 | {
|
|---|
| 456 | for(int i=0;i<26;i++)
|
|---|
| 457 | {
|
|---|
| 458 | //for now only cdrom/dvd drives
|
|---|
| 459 | if(drives[i] == DRIVE_CDROM_W)
|
|---|
| 460 | {
|
|---|
| 461 | DWORD parsize = sizeof(ParameterBlock);
|
|---|
| 462 | DWORD datasize = 2;
|
|---|
| 463 | WORD status = 0;
|
|---|
| 464 | DWORD rc;
|
|---|
| 465 | ParameterBlock parm;
|
|---|
| 466 |
|
|---|
| 467 | parm.ucCommandInfo = 0;
|
|---|
| 468 | parm.usDriveUnit = i;
|
|---|
| 469 | rc = DosDevIOCtl(-1, IOCTL_DISK, DSK_GETLOCKSTATUS, &parm, sizeof(parm), &parsize,
|
|---|
| 470 | &status, sizeof(status), &datasize);
|
|---|
| 471 | if(rc != NO_ERROR) {
|
|---|
| 472 | dprintf(("DosDevIOCtl failed with rc %d", rc));
|
|---|
| 473 | return FALSE;
|
|---|
| 474 | }
|
|---|
| 475 | //Send WM_DEVICECHANGE message when CD status changes
|
|---|
| 476 | if((status & 4) != drivestatus[i])
|
|---|
| 477 | {
|
|---|
| 478 | PID pidThis, pidTemp;
|
|---|
| 479 | HENUM henum;
|
|---|
| 480 | HWND hwndEnum;
|
|---|
| 481 | DEV_BROADCAST_VOLUME volchange;
|
|---|
| 482 |
|
|---|
| 483 | dprintf(("Disk status 0x%x", status));
|
|---|
| 484 |
|
|---|
| 485 | volchange.dbcv_size = sizeof(volchange);
|
|---|
| 486 | volchange.dbcv_devicetype = DBT_DEVTYP_VOLUME;
|
|---|
| 487 | volchange.dbcv_reserved = 0;
|
|---|
| 488 | volchange.dbcv_unitmask = (1 << i);
|
|---|
| 489 | volchange.dbcv_flags = DBTF_MEDIA;
|
|---|
| 490 |
|
|---|
| 491 | WinQueryWindowProcess(hwnd, &pidThis, NULL);
|
|---|
| 492 |
|
|---|
| 493 | //Iterate over all child windows of the desktop
|
|---|
| 494 | henum = WinBeginEnumWindows(HWND_DESKTOP);
|
|---|
| 495 |
|
|---|
| 496 | SetWin32TIB();
|
|---|
| 497 | while(hwndEnum = WinGetNextWindow(henum))
|
|---|
| 498 | {
|
|---|
| 499 | WinQueryWindowProcess(hwndEnum, &pidTemp, NULL);
|
|---|
| 500 | if(pidTemp == pidThis)
|
|---|
| 501 | {
|
|---|
| 502 | HWND hwndWin32 = OS2ToWin32Handle(hwndEnum);
|
|---|
| 503 | if(hwndWin32) {
|
|---|
| 504 | SendMessageA(hwndWin32,
|
|---|
| 505 | WM_DEVICECHANGE_W,
|
|---|
| 506 | (status & 4) ? DBT_DEVICEARRIVAL : DBT_DEVICEREMOVECOMPLETE,
|
|---|
| 507 | (LPARAM)&volchange);
|
|---|
| 508 | }
|
|---|
| 509 | }
|
|---|
| 510 | }
|
|---|
| 511 | RestoreOS2TIB();
|
|---|
| 512 | WinEndEnumWindows(henum);
|
|---|
| 513 |
|
|---|
| 514 | drivestatus[i] = (status & 4);
|
|---|
| 515 | }
|
|---|
| 516 | }
|
|---|
| 517 | }
|
|---|
| 518 | break;
|
|---|
| 519 | }
|
|---|
| 520 |
|
|---|
| 521 | case WM_DESTROY:
|
|---|
| 522 | dprintf(("WM_DESTROY for CD notification window"));
|
|---|
| 523 | WinStopTimer(hab, hwnd, TIMERID_DRIVEPOLL);
|
|---|
| 524 | break;
|
|---|
| 525 |
|
|---|
| 526 | default:
|
|---|
| 527 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 528 | }
|
|---|
| 529 | return (MRESULT)rc;
|
|---|
| 530 | }
|
|---|
| 531 | //******************************************************************************
|
|---|
| 532 | // Win32 window message handler
|
|---|
| 533 | // The PM window procedure for our client window class (non frame)
|
|---|
| 534 | //******************************************************************************
|
|---|
| 535 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 536 | {
|
|---|
| 537 | Win32BaseWindow *win32wnd;
|
|---|
| 538 | TEB *teb;
|
|---|
| 539 | MSG winMsg, *pWinMsg;
|
|---|
| 540 | MRESULT rc = 0;
|
|---|
| 541 | POSTMSG_PACKET *postmsg;
|
|---|
| 542 | OSLIBPOINT point, ClientPoint;
|
|---|
| 543 | EXCEPTIONREGISTRATIONRECORD exceptRegRec = {0,0};
|
|---|
| 544 |
|
|---|
| 545 | ODIN_SetExceptionHandler(&exceptRegRec);
|
|---|
| 546 | // restore our FS selector
|
|---|
| 547 | SetWin32TIB();
|
|---|
| 548 |
|
|---|
| 549 | #ifdef DEBUG
|
|---|
| 550 | dbg_ThreadPushCall("Win32WindowProc");
|
|---|
| 551 | #endif
|
|---|
| 552 |
|
|---|
| 553 | // BEGIN NOTE-------------->>>>>> If this is changed, also change Win32FrameWindowProc!! <<<<<<<<<<<-------------------- BEGIN
|
|---|
| 554 | teb = GetThreadTEB();
|
|---|
| 555 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 556 |
|
|---|
| 557 | //// dprintf(("window %x msg %x", (win32wnd) ? win32wnd->getWindowHandle() : 0, msg));
|
|---|
| 558 |
|
|---|
| 559 | // do some sanity checking here:
|
|---|
| 560 | // - we need to have a TEB handle
|
|---|
| 561 | // - unless this is WM_CREATE (the very first message), there has to be
|
|---|
| 562 | // a USER32 window object for this window handle
|
|---|
| 563 | // - thread must not be suspended in WaitMessage
|
|---|
| 564 | if(!teb || (msg != WM_CREATE && win32wnd == NULL) || teb->o.odin.fWaitMessageSuspend) {
|
|---|
| 565 | if(teb && teb->o.odin.fWaitMessageSuspend)
|
|---|
| 566 | dprintf(("OS2: fWaitMessageSuspend window %x msg %x -> run default frame proc", hwnd, msg));
|
|---|
| 567 | else dprintf(("OS2: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
|
|---|
| 568 | goto RunDefWndProc;
|
|---|
| 569 | }
|
|---|
| 570 | //// if(teb->o.odin.fIgnoreMsgs) {
|
|---|
| 571 | //// goto RunDefWndProc;
|
|---|
| 572 | //// }
|
|---|
| 573 |
|
|---|
| 574 | // check if the message state counter in the TEB is odd
|
|---|
| 575 | // This means the message has been sent directly from PM to our message
|
|---|
| 576 | // handler (so it is the first time we know about this PM message).
|
|---|
| 577 | // If this is the case, we have to translate it here to a Win32
|
|---|
| 578 | // message first. The other case is that the message is the result of a
|
|---|
| 579 | // WinDispatchMsg call and therefore has already been translated.
|
|---|
| 580 | if((teb->o.odin.msgstate & 1) == 0)
|
|---|
| 581 | {
|
|---|
| 582 | // message that was sent directly to our window proc handler; translate it here
|
|---|
| 583 | QMSG qmsg;
|
|---|
| 584 |
|
|---|
| 585 | qmsg.msg = msg;
|
|---|
| 586 | qmsg.hwnd = hwnd;
|
|---|
| 587 | qmsg.mp1 = mp1;
|
|---|
| 588 | qmsg.mp2 = mp2;
|
|---|
| 589 | qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
|
|---|
| 590 | WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
|
|---|
| 591 | qmsg.reserved = 0;
|
|---|
| 592 |
|
|---|
| 593 | if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
|---|
| 594 | {//message was not translated
|
|---|
| 595 | memset(&winMsg, 0, sizeof(MSG));
|
|---|
| 596 | }
|
|---|
| 597 | pWinMsg = &winMsg;
|
|---|
| 598 | }
|
|---|
| 599 | else {
|
|---|
| 600 | // message has already been translated before (GetMessage/PeekMessage).
|
|---|
| 601 | // Use the translated information. Flip the translation flag.
|
|---|
| 602 | pWinMsg = &teb->o.odin.msg;
|
|---|
| 603 | teb->o.odin.msgstate++;
|
|---|
| 604 | }
|
|---|
| 605 | // END NOTE-------------->>>>>> If this is changed, also change Win32FrameWindowProc!! <<<<<<<<<<<-------------------- END
|
|---|
| 606 |
|
|---|
| 607 | if(msg >= WIN32APP_POSTMSG) {
|
|---|
| 608 | //probably win32 app user message
|
|---|
| 609 | dprintf2(("Posted message %x->%x", msg, msg-WIN32APP_POSTMSG));
|
|---|
| 610 | if((ULONG)mp1 == WIN32MSG_MAGICA) {
|
|---|
| 611 | rc = (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 612 | }
|
|---|
| 613 | else
|
|---|
| 614 | if((ULONG)mp1 == WIN32MSG_MAGICW) {
|
|---|
| 615 | rc = (MRESULT)win32wnd->DispatchMsgW(pWinMsg);
|
|---|
| 616 | }
|
|---|
| 617 | else {//broadcasted message
|
|---|
| 618 | rc = (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 619 | }
|
|---|
| 620 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 621 | RestoreOS2TIB();
|
|---|
| 622 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 623 |
|
|---|
| 624 | #ifdef DEBUG
|
|---|
| 625 | dbg_ThreadPopCall();
|
|---|
| 626 | #endif
|
|---|
| 627 | return rc;
|
|---|
| 628 | }
|
|---|
| 629 |
|
|---|
| 630 | switch( msg )
|
|---|
| 631 | {
|
|---|
| 632 | //OS/2 msgs
|
|---|
| 633 | case WM_CREATE:
|
|---|
| 634 | {
|
|---|
| 635 | if(teb->o.odin.newWindow == 0)
|
|---|
| 636 | goto createfail;
|
|---|
| 637 |
|
|---|
| 638 | //Processing is done in after WinCreateWindow returns
|
|---|
| 639 | dprintf(("OS2: WM_CREATE %x", hwnd));
|
|---|
| 640 | win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
|
|---|
| 641 | win32wnd->addRef();
|
|---|
| 642 | teb->o.odin.newWindow = 0;
|
|---|
| 643 | if(win32wnd->MsgCreate(hwnd) == FALSE)
|
|---|
| 644 | {
|
|---|
| 645 | rc = (MRESULT)TRUE; //discontinue window creation
|
|---|
| 646 | break;
|
|---|
| 647 | }
|
|---|
| 648 |
|
|---|
| 649 | //Create CD notification window
|
|---|
| 650 | if(hwndCD == 0 && fEnableCDPolling) {
|
|---|
| 651 | hwndCD = WinCreateWindow(HWND_DESKTOP, WIN32_CDCLASS,
|
|---|
| 652 | NULL, 0, 0, 0, 0, 0,
|
|---|
| 653 | HWND_DESKTOP, HWND_TOP, 0, NULL, NULL);
|
|---|
| 654 | }
|
|---|
| 655 |
|
|---|
| 656 | createfail:
|
|---|
| 657 | rc = (MRESULT)FALSE;
|
|---|
| 658 | break;
|
|---|
| 659 | }
|
|---|
| 660 |
|
|---|
| 661 | case WM_QUIT:
|
|---|
| 662 | dprintf(("OS2: WM_QUIT %x", hwnd));
|
|---|
| 663 | win32wnd->MsgQuit();
|
|---|
| 664 | break;
|
|---|
| 665 |
|
|---|
| 666 | case WM_CLOSE:
|
|---|
| 667 | dprintf(("OS2: WM_CLOSE %x", hwnd));
|
|---|
| 668 | win32wnd->MsgClose();
|
|---|
| 669 | break;
|
|---|
| 670 |
|
|---|
| 671 | case WM_DESTROY:
|
|---|
| 672 | dprintf(("OS2: WM_DESTROY %x", hwnd));
|
|---|
| 673 | win32wnd->MsgDestroy();
|
|---|
| 674 | WinSetVisibleRegionNotify(hwnd, FALSE);
|
|---|
| 675 | goto RunDefWndProc;
|
|---|
| 676 |
|
|---|
| 677 | case WM_ENABLE:
|
|---|
| 678 | dprintf(("OS2: WM_ENABLE %x", hwnd));
|
|---|
| 679 | break;
|
|---|
| 680 |
|
|---|
| 681 | case WM_SHOW:
|
|---|
| 682 | {
|
|---|
| 683 | dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
|
|---|
| 684 | win32wnd->MsgShow((ULONG)mp1);
|
|---|
| 685 |
|
|---|
| 686 | //if a child window is hidden, then the update region of the
|
|---|
| 687 | //parent changes and a WM_ERASEBKGND is required during the next
|
|---|
| 688 | //BeginPaint call.
|
|---|
| 689 | if((ULONG)mp1 == FALSE)
|
|---|
| 690 | {
|
|---|
| 691 | Win32BaseWindow *parent = win32wnd->getParent();
|
|---|
| 692 | if(parent) {
|
|---|
| 693 | dprintf(("PM Update region changed for parent %x", win32wnd->getWindowHandle()));
|
|---|
| 694 | parent->SetPMUpdateRegionChanged(TRUE);
|
|---|
| 695 | }
|
|---|
| 696 | }
|
|---|
| 697 | break;
|
|---|
| 698 | }
|
|---|
| 699 |
|
|---|
| 700 | case WM_ACTIVATE:
|
|---|
| 701 | {
|
|---|
| 702 | ULONG flags = WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS);
|
|---|
| 703 |
|
|---|
| 704 | dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
|
|---|
| 705 | WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | WINDOWFLAG_ACTIVE):(flags & ~WINDOWFLAG_ACTIVE));
|
|---|
| 706 | if(win32wnd->IsWindowCreated())
|
|---|
| 707 | {
|
|---|
| 708 | win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
|
|---|
| 709 | }
|
|---|
| 710 | break;
|
|---|
| 711 | }
|
|---|
| 712 |
|
|---|
| 713 | case WM_SIZE:
|
|---|
| 714 | {
|
|---|
| 715 | dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)));
|
|---|
| 716 | win32wnd->SetPMUpdateRegionChanged(TRUE);
|
|---|
| 717 |
|
|---|
| 718 | goto RunDefWndProc;
|
|---|
| 719 | }
|
|---|
| 720 |
|
|---|
| 721 |
|
|---|
| 722 | case WM_VRNENABLED:
|
|---|
| 723 | {
|
|---|
| 724 | dprintf(("OS2: WM_VRNENABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 725 | //Always call handler; even if mp1 is 0. If we don't do this, the
|
|---|
| 726 | //DivX 4 player will never be allowed to draw after putting another window
|
|---|
| 727 | //on top of it.
|
|---|
| 728 |
|
|---|
| 729 | win32wnd->callVisibleRgnNotifyProc(TRUE);
|
|---|
| 730 |
|
|---|
| 731 | //Workaround for PM/GPI bug when moving/sizing a window with open DCs
|
|---|
| 732 | //
|
|---|
| 733 | //Windows applictions often get a DC and keep it open for the duration
|
|---|
| 734 | //of the application. When the DC's window is moved (full window dragging on)
|
|---|
| 735 | //PM/GPI doesn't seem to update the DC properly/in time.
|
|---|
| 736 | //This can result is visible distortions on the screen.
|
|---|
| 737 | //Debugging showed that querying the visible region of a DC will cure
|
|---|
| 738 | //this problem (GPI probably recalculates the visible region). (#334)
|
|---|
| 739 |
|
|---|
| 740 | int nrdcs = 0;
|
|---|
| 741 | HDC hdcWindow[MAX_OPENDCS];
|
|---|
| 742 |
|
|---|
| 743 | if(win32wnd->queryOpenDCs(hdcWindow, MAX_OPENDCS, &nrdcs))
|
|---|
| 744 | {
|
|---|
| 745 | RECTL rcl = {0,0,1,1};
|
|---|
| 746 | HRGN hrgnRect;
|
|---|
| 747 |
|
|---|
| 748 | for(int i=0;i<nrdcs;i++) {
|
|---|
| 749 | dprintf(("Recalc visible region of DC %x for window %x", hdcWindow[i], win32wnd->getWindowHandle()));
|
|---|
| 750 |
|
|---|
| 751 | hrgnRect = GreCreateRectRegion(hdcWindow[i], &rcl, 1);
|
|---|
| 752 | GreCopyClipRegion(hdcWindow[i], hrgnRect, 0, COPYCRGN_VISRGN);
|
|---|
| 753 | GreDestroyRegion(hdcWindow[i], hrgnRect);
|
|---|
| 754 | }
|
|---|
| 755 | }
|
|---|
| 756 | //Workaround END
|
|---|
| 757 |
|
|---|
| 758 | if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
|
|---|
| 759 | {
|
|---|
| 760 | HWND hwndrelated;
|
|---|
| 761 | Win32BaseWindow *topwindow;
|
|---|
| 762 |
|
|---|
| 763 | win32wnd->setComingToTop(TRUE);
|
|---|
| 764 |
|
|---|
| 765 | hwndrelated = WinQueryWindow(hwnd, QW_PREV);
|
|---|
| 766 | dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
|
|---|
| 767 | topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
|
|---|
| 768 | if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
|
|---|
| 769 | //put window at the top of z order
|
|---|
| 770 | WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
|
|---|
| 771 | }
|
|---|
| 772 | if(topwindow) RELEASE_WNDOBJ(topwindow);
|
|---|
| 773 |
|
|---|
| 774 | win32wnd->setComingToTop(FALSE);
|
|---|
| 775 | break;
|
|---|
| 776 | }
|
|---|
| 777 | goto RunDefWndProc;
|
|---|
| 778 | }
|
|---|
| 779 |
|
|---|
| 780 | case WM_VRNDISABLED:
|
|---|
| 781 | {
|
|---|
| 782 | dprintf(("OS2: WM_VRNDISABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 783 | //visible region is about to change or WinLockWindowUpdate called
|
|---|
| 784 | //suspend window drawing
|
|---|
| 785 |
|
|---|
| 786 | win32wnd->callVisibleRgnNotifyProc(FALSE);
|
|---|
| 787 | goto RunDefWndProc;
|
|---|
| 788 | }
|
|---|
| 789 |
|
|---|
| 790 | case WIN32APP_DDRAWFULLSCREEN:
|
|---|
| 791 | //Changing the size of the win32 window in SetCooperativeLevel can
|
|---|
| 792 | //fail if this happens during WM_ADJUSTWINDOWPOS
|
|---|
| 793 | //NOTE: This is not a good solution, but a proper fix is more difficult
|
|---|
| 794 | // with the current window mess
|
|---|
| 795 | dprintf(("WIN32APP_DDRAWFULLSCREEN %x (%d,%d)", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 796 | SetWindowPos(win32wnd->getWindowHandle(), HWND_TOP_W, 0, 0, (DWORD)mp1, (DWORD)mp2, 0);
|
|---|
| 797 | ShowWindow(win32wnd->getWindowHandle(), SW_SHOW_W);
|
|---|
| 798 | break;
|
|---|
| 799 |
|
|---|
| 800 | case WIN32APP_CHNGEFRAMECTRLS:
|
|---|
| 801 | {
|
|---|
| 802 | dprintf(("OS2: WIN32APP_CHANGEFRAMECTRLS"));
|
|---|
| 803 | OSLibSetWindowStyle(win32wnd->getOS2FrameWindowHandle(), win32wnd->getOS2WindowHandle(), (ULONG)mp1, win32wnd->getExStyle(), (ULONG)mp2);
|
|---|
| 804 | break;
|
|---|
| 805 | }
|
|---|
| 806 |
|
|---|
| 807 | #ifdef DEBUG
|
|---|
| 808 | case WM_SETFOCUS:
|
|---|
| 809 | {
|
|---|
| 810 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 811 | dprintf(("OS2: WM_SETFOCUS %x %x (%x) %d cur focus %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2, WinQueryFocus(HWND_DESKTOP)));
|
|---|
| 812 | if(WinQueryFocus(HWND_DESKTOP) == win32wnd->getOS2FrameWindowHandle()) {
|
|---|
| 813 | dprintf(("WARNING: Focus set to frame window"));
|
|---|
| 814 | }
|
|---|
| 815 | break;
|
|---|
| 816 | }
|
|---|
| 817 | #endif
|
|---|
| 818 |
|
|---|
| 819 | //Handle all focus processed during WM_FOCUSCHANGED; PM doesn't like focus
|
|---|
| 820 | //changes during focus processing (WM_SETFOCUS). This message is sent
|
|---|
| 821 | //after all focus work has been completed.
|
|---|
| 822 | case WM_FOCUSCHANGED:
|
|---|
| 823 | {
|
|---|
| 824 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 825 | HWND hwndFocusWin32 = OS2ToWin32Handle(hwndFocus);
|
|---|
| 826 |
|
|---|
| 827 | dprintf(("OS2: WM_FOCUSCHANGED %x %x (%x) %d cur focus %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2, WinQueryFocus(HWND_DESKTOP)));
|
|---|
| 828 |
|
|---|
| 829 | //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
|
|---|
| 830 | //must delay this function call
|
|---|
| 831 |
|
|---|
| 832 | if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC)
|
|---|
| 833 | {
|
|---|
| 834 | //another (non-win32) application's window
|
|---|
| 835 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
|---|
| 836 | hwndFocus = 0;
|
|---|
| 837 | hwndFocusWin32 = 0;
|
|---|
| 838 | }
|
|---|
| 839 | if((ULONG)mp2 == TRUE) {
|
|---|
| 840 | recreateCaret(hwndFocusWin32);
|
|---|
| 841 | win32wnd->MsgSetFocus(hwndFocusWin32);
|
|---|
| 842 | }
|
|---|
| 843 | else {
|
|---|
| 844 | //If SetFocus(0) was called, then the window has already received
|
|---|
| 845 | //a WM_KILLFOCUS; don't send another one
|
|---|
| 846 | if(!fIgnoreKeystrokes) {
|
|---|
| 847 | win32wnd->MsgKillFocus(OS2ToWin32Handle(hwndFocus));
|
|---|
| 848 | }
|
|---|
| 849 | else dprintf(("Window has already received a WM_KILLFOCUS (SetFocus(0)); ignore"));
|
|---|
| 850 | }
|
|---|
| 851 | break;
|
|---|
| 852 | }
|
|---|
| 853 |
|
|---|
| 854 | //**************************************************************************
|
|---|
| 855 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
|---|
| 856 | //**************************************************************************
|
|---|
| 857 |
|
|---|
| 858 | case WM_BUTTON1DOWN:
|
|---|
| 859 | case WM_BUTTON1UP:
|
|---|
| 860 | case WM_BUTTON1DBLCLK:
|
|---|
| 861 | case WM_BUTTON2DOWN:
|
|---|
| 862 | case WM_BUTTON2UP:
|
|---|
| 863 | case WM_BUTTON2DBLCLK:
|
|---|
| 864 | case WM_BUTTON3DOWN:
|
|---|
| 865 | case WM_BUTTON3UP:
|
|---|
| 866 | case WM_BUTTON3DBLCLK:
|
|---|
| 867 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 868 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 869 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 870 | }
|
|---|
| 871 | if(win32wnd)
|
|---|
| 872 | win32wnd->MsgButton(pWinMsg);
|
|---|
| 873 |
|
|---|
| 874 | rc = (MRESULT)TRUE;
|
|---|
| 875 | break;
|
|---|
| 876 |
|
|---|
| 877 | case WM_BUTTON2MOTIONSTART:
|
|---|
| 878 | case WM_BUTTON2MOTIONEND:
|
|---|
| 879 | case WM_BUTTON2CLICK:
|
|---|
| 880 | case WM_BUTTON1MOTIONSTART:
|
|---|
| 881 | case WM_BUTTON1MOTIONEND:
|
|---|
| 882 | case WM_BUTTON1CLICK:
|
|---|
| 883 | case WM_BUTTON3MOTIONSTART:
|
|---|
| 884 | case WM_BUTTON3MOTIONEND:
|
|---|
| 885 | case WM_BUTTON3CLICK:
|
|---|
| 886 | rc = (MRESULT)TRUE;
|
|---|
| 887 | break;
|
|---|
| 888 |
|
|---|
| 889 | case WM_MOUSEMOVE:
|
|---|
| 890 | {
|
|---|
| 891 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 892 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 893 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 894 | }
|
|---|
| 895 | if(win32wnd)
|
|---|
| 896 | win32wnd->MsgMouseMove(pWinMsg);
|
|---|
| 897 | break;
|
|---|
| 898 | }
|
|---|
| 899 |
|
|---|
| 900 | case WM_CONTROL:
|
|---|
| 901 | goto RunDefWndProc;
|
|---|
| 902 |
|
|---|
| 903 | case WM_COMMAND:
|
|---|
| 904 | dprintf(("OS2: WM_COMMAND %x %x %x", hwnd, mp1, mp2));
|
|---|
| 905 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 906 | break;
|
|---|
| 907 |
|
|---|
| 908 | case WM_SYSCOMMAND:
|
|---|
| 909 | dprintf(("OS2: WM_SYSCOMMAND %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 910 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 911 | break;
|
|---|
| 912 |
|
|---|
| 913 | case WM_RENDERFMT:
|
|---|
| 914 | case WM_RENDERALLFMTS:
|
|---|
| 915 | case WM_DESTROYCLIPBOARD:
|
|---|
| 916 | case WM_DRAWCLIPBOARD:
|
|---|
| 917 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 918 | break;
|
|---|
| 919 |
|
|---|
| 920 | case WM_CHAR_SPECIAL:
|
|---|
| 921 | /* NO BREAK! FALLTHRU CASE! */
|
|---|
| 922 |
|
|---|
| 923 | case WM_CHAR:
|
|---|
| 924 | dprintf(("OS2: WM_CHAR %x %x %x, %x %x focus wnd %x", win32wnd->getWindowHandle(), mp1, mp2, pWinMsg->wParam, pWinMsg->lParam, WinQueryFocus(HWND_DESKTOP)));
|
|---|
| 925 | win32wnd->MsgChar(pWinMsg);
|
|---|
| 926 | break;
|
|---|
| 927 |
|
|---|
| 928 | case WM_TIMER:
|
|---|
| 929 | dprintf(("OS2: WM_TIMER %x %x time %x", win32wnd->getWindowHandle(), pWinMsg->wParam, GetTickCount()));
|
|---|
| 930 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 931 | goto RunDefWndProc;
|
|---|
| 932 |
|
|---|
| 933 | case WM_SETWINDOWPARAMS:
|
|---|
| 934 | {
|
|---|
| 935 | WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
|
|---|
| 936 |
|
|---|
| 937 | dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
|
|---|
| 938 | if(wndParams->fsStatus & WPM_TEXT) {
|
|---|
| 939 | win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
|
|---|
| 940 | }
|
|---|
| 941 | goto RunDefWndProc;
|
|---|
| 942 | }
|
|---|
| 943 |
|
|---|
| 944 | case WM_QUERYWINDOWPARAMS:
|
|---|
| 945 | {
|
|---|
| 946 | PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
|
|---|
| 947 | ULONG textlen;
|
|---|
| 948 | PSZ wintext;
|
|---|
| 949 |
|
|---|
| 950 | if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
|
|---|
| 951 | {
|
|---|
| 952 | if(wndpars->fsStatus & WPM_TEXT)
|
|---|
| 953 | win32wnd->MsgGetText(wndpars->pszText, wndpars->cchText);
|
|---|
| 954 | if(wndpars->fsStatus & WPM_CCHTEXT)
|
|---|
| 955 | wndpars->cchText = win32wnd->MsgGetTextLength();
|
|---|
| 956 |
|
|---|
| 957 | wndpars->fsStatus = 0;
|
|---|
| 958 | wndpars->cbCtlData = 0;
|
|---|
| 959 | wndpars->cbPresParams = 0;
|
|---|
| 960 | rc = (MRESULT)TRUE;
|
|---|
| 961 | break;
|
|---|
| 962 | }
|
|---|
| 963 | goto RunDefWndProc;
|
|---|
| 964 | }
|
|---|
| 965 |
|
|---|
| 966 | case WM_PAINT:
|
|---|
| 967 | {
|
|---|
| 968 | RECTL rectl;
|
|---|
| 969 | BOOL rc;
|
|---|
| 970 |
|
|---|
| 971 | win32wnd->checkForDirtyUpdateRegion();
|
|---|
| 972 |
|
|---|
| 973 | rc = WinQueryUpdateRect(hwnd, &rectl);
|
|---|
| 974 | dprintf(("OS2: WM_PAINT %x (%d,%d) (%d,%d) rc=%d", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop, rc));
|
|---|
| 975 |
|
|---|
| 976 | if(rc && win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
|
|---|
| 977 | rectl.yBottom != rectl.yTop) && !IsIconic(win32wnd->GetTopParent()))
|
|---|
| 978 | {
|
|---|
| 979 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 980 | if(WinQueryUpdateRect(hwnd, NULL) == TRUE)
|
|---|
| 981 | {//the application didn't validate the update region; Windows
|
|---|
| 982 | //will only send a WM_PAINT once until another part of the
|
|---|
| 983 | //window is invalidated. Unfortunately PM keeps on sending
|
|---|
| 984 | //WM_PAINT messages until we validate the update region.
|
|---|
| 985 |
|
|---|
| 986 | win32wnd->saveAndValidateUpdateRegion();
|
|---|
| 987 | }
|
|---|
| 988 | }
|
|---|
| 989 | else goto RunDefWndProc;
|
|---|
| 990 | break;
|
|---|
| 991 | }
|
|---|
| 992 |
|
|---|
| 993 | case WM_ERASEBACKGROUND:
|
|---|
| 994 | {
|
|---|
| 995 | dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
|---|
| 996 | rc = (MRESULT)FALSE;
|
|---|
| 997 | break;
|
|---|
| 998 | }
|
|---|
| 999 |
|
|---|
| 1000 | case WM_CALCVALIDRECTS:
|
|---|
| 1001 | dprintf(("OS2: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
|---|
| 1002 | rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
|---|
| 1003 | break;
|
|---|
| 1004 |
|
|---|
| 1005 | case WM_REALIZEPALETTE:
|
|---|
| 1006 | {
|
|---|
| 1007 | dprintf(("OS2: WM_REALIZEPALETTE %x", win32wnd->getWindowHandle()));
|
|---|
| 1008 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 1009 | break;
|
|---|
| 1010 | }
|
|---|
| 1011 |
|
|---|
| 1012 | case WM_HSCROLL:
|
|---|
| 1013 | case WM_VSCROLL:
|
|---|
| 1014 | dprintf(("OS2: %s %x %x %x", (msg == WM_HSCROLL) ? "WM_HSCROLL" : "WM_VSCROLL", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 1015 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 1016 | break;
|
|---|
| 1017 |
|
|---|
| 1018 | case WM_IMEREQUEST:
|
|---|
| 1019 | case WM_IMECONTROL:
|
|---|
| 1020 | case WM_IMENOTIFY:
|
|---|
| 1021 | if( pWinMsg->message )
|
|---|
| 1022 | {
|
|---|
| 1023 | win32wnd->DispatchMsgA( pWinMsg );
|
|---|
| 1024 |
|
|---|
| 1025 | if(( pWinMsg->message = WM_IME_NOTIFY_W ) &&
|
|---|
| 1026 | ( pWinMsg->wParam == IMN_SETOPENSTATUS_W ))
|
|---|
| 1027 | {
|
|---|
| 1028 | MSG m;
|
|---|
| 1029 |
|
|---|
| 1030 | m.message = WM_IME_NOTIFY_W;
|
|---|
| 1031 | m.wParam = IMN_SETCONVERSIONMODE_W;
|
|---|
| 1032 | m.lParam = 0;
|
|---|
| 1033 |
|
|---|
| 1034 | win32wnd->DispatchMsgA( &m );
|
|---|
| 1035 | }
|
|---|
| 1036 | }
|
|---|
| 1037 | else
|
|---|
| 1038 | goto RunDefWndProc;
|
|---|
| 1039 | break;
|
|---|
| 1040 |
|
|---|
| 1041 | case DM_DRAGOVER:
|
|---|
| 1042 | {
|
|---|
| 1043 | PDRAGINFO pDragInfo = (PDRAGINFO)mp1;
|
|---|
| 1044 | PDRAGITEM pDragItem;
|
|---|
| 1045 | USHORT sxDrop = SHORT1FROMMP(mp2);
|
|---|
| 1046 | USHORT syDrop = SHORT2FROMMP(mp2);
|
|---|
| 1047 |
|
|---|
| 1048 | dprintf(("OS2: DM_DRAGOVER %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop));
|
|---|
| 1049 |
|
|---|
| 1050 | if(fDragDropDisabled) {
|
|---|
| 1051 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1052 | break;
|
|---|
| 1053 | }
|
|---|
| 1054 |
|
|---|
| 1055 | //does this window accept dropped files?
|
|---|
| 1056 | if(!DragDropAccept(win32wnd->getWindowHandle())) {
|
|---|
| 1057 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1058 | break;
|
|---|
| 1059 | }
|
|---|
| 1060 |
|
|---|
| 1061 | if(PMDragValidate(pDragInfo) == FALSE) {
|
|---|
| 1062 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1063 | break;
|
|---|
| 1064 | }
|
|---|
| 1065 | if(win32wnd->isDragDropActive() == FALSE) {
|
|---|
| 1066 | ULONG ulBytes, cItems;
|
|---|
| 1067 | char *pszFiles;
|
|---|
| 1068 |
|
|---|
| 1069 | pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes);
|
|---|
| 1070 | if(pszFiles) {
|
|---|
| 1071 | POINT point = {sxDrop, syDrop};
|
|---|
| 1072 | if(DragDropDragEnter(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes, DROPEFFECT_COPY_W) == FALSE) {
|
|---|
| 1073 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1074 | }
|
|---|
| 1075 | else {
|
|---|
| 1076 | fDragDropActive = TRUE;
|
|---|
| 1077 | rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
|
|---|
| 1078 | win32wnd->setDragDropActive(TRUE);
|
|---|
| 1079 | }
|
|---|
| 1080 | free(pszFiles);
|
|---|
| 1081 | }
|
|---|
| 1082 | else {
|
|---|
| 1083 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1084 | }
|
|---|
| 1085 | }
|
|---|
| 1086 | else {
|
|---|
| 1087 | if(DragDropDragOver(win32wnd->getWindowHandle(), DROPEFFECT_COPY_W) == FALSE) {
|
|---|
| 1088 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1089 | }
|
|---|
| 1090 | else rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
|
|---|
| 1091 | }
|
|---|
| 1092 | break;
|
|---|
| 1093 | }
|
|---|
| 1094 |
|
|---|
| 1095 | case DM_DRAGLEAVE:
|
|---|
| 1096 | {
|
|---|
| 1097 | dprintf(("OS2: DM_DRAGLEAVE %x", win32wnd->getWindowHandle()));
|
|---|
| 1098 |
|
|---|
| 1099 | if(fDragDropDisabled) {
|
|---|
| 1100 | break;
|
|---|
| 1101 | }
|
|---|
| 1102 |
|
|---|
| 1103 | fDragDropActive = FALSE;
|
|---|
| 1104 |
|
|---|
| 1105 | //does this window accept dropped files?
|
|---|
| 1106 | if(!DragDropAccept(win32wnd->getWindowHandle())) {
|
|---|
| 1107 | break;
|
|---|
| 1108 | }
|
|---|
| 1109 |
|
|---|
| 1110 | DragDropDragLeave(win32wnd->getWindowHandle());
|
|---|
| 1111 | win32wnd->setDragDropActive(FALSE);
|
|---|
| 1112 | break;
|
|---|
| 1113 | }
|
|---|
| 1114 |
|
|---|
| 1115 | case DM_DROP:
|
|---|
| 1116 | {
|
|---|
| 1117 | PDRAGINFO pDragInfo = (PDRAGINFO)mp1;
|
|---|
| 1118 | PDRAGITEM pDragItem;
|
|---|
| 1119 | USHORT sxDrop = SHORT1FROMMP(mp2);
|
|---|
| 1120 | USHORT syDrop = SHORT2FROMMP(mp2);
|
|---|
| 1121 | USHORT usIndicator, usOp;
|
|---|
| 1122 |
|
|---|
| 1123 | dprintf(("OS2: DM_DROP %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop));
|
|---|
| 1124 |
|
|---|
| 1125 | fDragDropActive = FALSE;
|
|---|
| 1126 | rc = (MRFROM2SHORT (DOR_NODROP, 0));
|
|---|
| 1127 |
|
|---|
| 1128 | if(fDragDropDisabled) {
|
|---|
| 1129 | rc = (MRFROM2SHORT (DOR_NODROP, 0));
|
|---|
| 1130 | break;
|
|---|
| 1131 | }
|
|---|
| 1132 |
|
|---|
| 1133 | //does this window accept dropped files?
|
|---|
| 1134 | if(!DragDropAccept(win32wnd->getWindowHandle())) {
|
|---|
| 1135 | break;
|
|---|
| 1136 | }
|
|---|
| 1137 |
|
|---|
| 1138 | ULONG ulBytes, cItems;
|
|---|
| 1139 | char *pszFiles;
|
|---|
| 1140 |
|
|---|
| 1141 | pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes);
|
|---|
| 1142 | if(pszFiles) {
|
|---|
| 1143 | POINT point = {sxDrop, syDrop};
|
|---|
| 1144 | if(DragDropFiles(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes) == FALSE) {
|
|---|
| 1145 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1146 | }
|
|---|
| 1147 | else {
|
|---|
| 1148 | rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
|
|---|
| 1149 | win32wnd->setDragDropActive(FALSE);
|
|---|
| 1150 | }
|
|---|
| 1151 | free(pszFiles);
|
|---|
| 1152 | }
|
|---|
| 1153 | else {
|
|---|
| 1154 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1155 | }
|
|---|
| 1156 | break;
|
|---|
| 1157 | }
|
|---|
| 1158 |
|
|---|
| 1159 | case DM_RENDER:
|
|---|
| 1160 | {
|
|---|
| 1161 | PDRAGTRANSFER pDragTransfer = (PDRAGTRANSFER)mp1;
|
|---|
| 1162 |
|
|---|
| 1163 | dprintf(("OS2: DM_RENDER %x", pDragTransfer));
|
|---|
| 1164 |
|
|---|
| 1165 | rc = (MRESULT)OSLibRenderFormat(pDragTransfer);
|
|---|
| 1166 | break;
|
|---|
| 1167 | }
|
|---|
| 1168 |
|
|---|
| 1169 | case DM_RENDERPREPARE:
|
|---|
| 1170 | {
|
|---|
| 1171 | PDRAGTRANSFER pDragTransfer = (PDRAGTRANSFER)mp1;
|
|---|
| 1172 |
|
|---|
| 1173 | dprintf(("OS2: DM_RENDERPREPARE %x", pDragTransfer));
|
|---|
| 1174 | break;
|
|---|
| 1175 | }
|
|---|
| 1176 |
|
|---|
| 1177 | case DM_ENDCONVERSATION:
|
|---|
| 1178 | {
|
|---|
| 1179 | dprintf(("OS2: DM_ENDCONVERSATION"));
|
|---|
| 1180 | rc = (MRESULT)OSLibEndConversation();
|
|---|
| 1181 | break;
|
|---|
| 1182 | }
|
|---|
| 1183 |
|
|---|
| 1184 | case DM_RENDERFILE:
|
|---|
| 1185 | {
|
|---|
| 1186 | dprintf(("OS2: DM_ENDCONVERSATION"));
|
|---|
| 1187 | rc = FALSE;
|
|---|
| 1188 | break;
|
|---|
| 1189 | }
|
|---|
| 1190 |
|
|---|
| 1191 | case WM_DDE_INITIATE:
|
|---|
| 1192 | case WM_DDE_INITIATEACK:
|
|---|
| 1193 | case WM_DDE_REQUEST:
|
|---|
| 1194 | case WM_DDE_ACK:
|
|---|
| 1195 | case WM_DDE_DATA:
|
|---|
| 1196 | case WM_DDE_ADVISE:
|
|---|
| 1197 | case WM_DDE_UNADVISE:
|
|---|
| 1198 | case WM_DDE_POKE:
|
|---|
| 1199 | case WM_DDE_EXECUTE:
|
|---|
| 1200 | case WM_DDE_TERMINATE:
|
|---|
| 1201 | dprintf(("OS2: WM_DDE %x %x", msg, win32wnd->getWindowHandle()));
|
|---|
| 1202 | goto RunDefWndProc;
|
|---|
| 1203 |
|
|---|
| 1204 | case WM_INITMENU:
|
|---|
| 1205 | case WM_MENUSELECT:
|
|---|
| 1206 | case WM_MENUEND:
|
|---|
| 1207 | case WM_NEXTMENU:
|
|---|
| 1208 | case WM_SYSCOLORCHANGE:
|
|---|
| 1209 | case WM_SYSVALUECHANGED:
|
|---|
| 1210 | case WM_SETSELECTION:
|
|---|
| 1211 | case WM_PPAINT:
|
|---|
| 1212 | case WM_PSETFOCUS:
|
|---|
| 1213 | case WM_PSYSCOLORCHANGE:
|
|---|
| 1214 | case WM_PSIZE:
|
|---|
| 1215 | case WM_PACTIVATE:
|
|---|
| 1216 | case WM_PCONTROL:
|
|---|
| 1217 | case WM_HELP:
|
|---|
| 1218 | case WM_APPTERMINATENOTIFY:
|
|---|
| 1219 | case WM_PRESPARAMCHANGED:
|
|---|
| 1220 | case WM_DRAWITEM:
|
|---|
| 1221 | case WM_MEASUREITEM:
|
|---|
| 1222 | case WM_CONTROLPOINTER:
|
|---|
| 1223 | case WM_QUERYDLGCODE:
|
|---|
| 1224 | case WM_SUBSTITUTESTRING:
|
|---|
| 1225 | case WM_MATCHMNEMONIC:
|
|---|
| 1226 | case WM_SAVEAPPLICATION:
|
|---|
| 1227 | case WM_SEMANTICEVENT:
|
|---|
| 1228 | default:
|
|---|
| 1229 | dprintf2(("OS2: RunDefWndProc hwnd %x msg %x mp1 %x mp2 %x", hwnd, msg, mp1, mp2));
|
|---|
| 1230 | goto RunDefWndProc;
|
|---|
| 1231 | }
|
|---|
| 1232 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 1233 | RestoreOS2TIB();
|
|---|
| 1234 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 1235 |
|
|---|
| 1236 | #ifdef DEBUG
|
|---|
| 1237 | dbg_ThreadPopCall();
|
|---|
| 1238 | #endif
|
|---|
| 1239 | return (MRESULT)rc;
|
|---|
| 1240 |
|
|---|
| 1241 | RunDefWndProc:
|
|---|
| 1242 | // dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
|
|---|
| 1243 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 1244 |
|
|---|
| 1245 | RestoreOS2TIB();
|
|---|
| 1246 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 1247 |
|
|---|
| 1248 | #ifdef DEBUG
|
|---|
| 1249 | dbg_ThreadPopCall();
|
|---|
| 1250 | #endif
|
|---|
| 1251 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 1252 | } /* End of Win32WindowProc */
|
|---|
| 1253 | //******************************************************************************
|
|---|
| 1254 | //******************************************************************************
|
|---|
| 1255 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 1256 | {
|
|---|
| 1257 | POSTMSG_PACKET *postmsg;
|
|---|
| 1258 | OSLIBPOINT point, ClientPoint;
|
|---|
| 1259 | Win32BaseWindow *win32wnd;
|
|---|
| 1260 | TEB *teb;
|
|---|
| 1261 | MRESULT rc = 0;
|
|---|
| 1262 | MSG winMsg, *pWinMsg;
|
|---|
| 1263 | EXCEPTIONREGISTRATIONRECORD exceptRegRec = {0,0};
|
|---|
| 1264 |
|
|---|
| 1265 | #ifdef DEBUG
|
|---|
| 1266 | dbg_ThreadPushCall("Win32FrameWindowProc");
|
|---|
| 1267 | #endif
|
|---|
| 1268 |
|
|---|
| 1269 | ODIN_SetExceptionHandler(&exceptRegRec);
|
|---|
| 1270 | //Restore our FS selector
|
|---|
| 1271 | SetWin32TIB();
|
|---|
| 1272 |
|
|---|
| 1273 | // BEGIN NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
|
|---|
| 1274 | teb = GetThreadTEB();
|
|---|
| 1275 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
|
|---|
| 1276 |
|
|---|
| 1277 | // do some sanity checking here:
|
|---|
| 1278 | // - we need to have a TEB handle
|
|---|
| 1279 | // - unless this is WM_CREATE (the very first message), there has to be
|
|---|
| 1280 | // a USER32 window object for this window handle
|
|---|
| 1281 | // - thread must not be suspended in WaitMessage
|
|---|
| 1282 | if(!teb || (msg != WM_CREATE && win32wnd == NULL) || teb->o.odin.fWaitMessageSuspend) {
|
|---|
| 1283 | if(teb && teb->o.odin.fWaitMessageSuspend)
|
|---|
| 1284 | dprintf(("PMFRAME: fWaitMessageSuspend window %x msg %x -> run default frame proc", hwnd, msg));
|
|---|
| 1285 | else dprintf(("PMFRAME: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
|
|---|
| 1286 | goto RunDefFrameWndProc;
|
|---|
| 1287 | }
|
|---|
| 1288 | //// if(teb->o.odin.fIgnoreMsgs) {
|
|---|
| 1289 | //// goto RunDefWndProc;
|
|---|
| 1290 | //// }
|
|---|
| 1291 |
|
|---|
| 1292 | // check if the message state counter in the TEB is odd
|
|---|
| 1293 | // This means the message has been sent directly from PM to our message
|
|---|
| 1294 | // handler (so it is the first time we know about this PM message).
|
|---|
| 1295 | // If this is the case, we have to translate it here to a Win32
|
|---|
| 1296 | // message first. The other case is that the message is the result of a
|
|---|
| 1297 | // WinDispatchMsg call and therefore has already been translated.
|
|---|
| 1298 | if((teb->o.odin.msgstate & 1) == 0)
|
|---|
| 1299 | {//message that was sent directly to our window proc handler; translate it here
|
|---|
| 1300 | QMSG qmsg;
|
|---|
| 1301 |
|
|---|
| 1302 | qmsg.msg = msg;
|
|---|
| 1303 | qmsg.hwnd = hwnd;
|
|---|
| 1304 | qmsg.mp1 = mp1;
|
|---|
| 1305 | qmsg.mp2 = mp2;
|
|---|
| 1306 | qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
|
|---|
| 1307 | WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
|
|---|
| 1308 | qmsg.reserved = 0;
|
|---|
| 1309 |
|
|---|
| 1310 | if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
|---|
| 1311 | {//message was not translated
|
|---|
| 1312 | memset(&winMsg, 0, sizeof(MSG));
|
|---|
| 1313 | }
|
|---|
| 1314 | pWinMsg = &winMsg;
|
|---|
| 1315 | }
|
|---|
| 1316 | else {
|
|---|
| 1317 | // message has already been translated before (GetMessage/PeekMessage).
|
|---|
| 1318 | // Use the translated information. Flip the translation flag.
|
|---|
| 1319 | pWinMsg = &teb->o.odin.msg;
|
|---|
| 1320 | teb->o.odin.msgstate++;
|
|---|
| 1321 | }
|
|---|
| 1322 | // END NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
|
|---|
| 1323 |
|
|---|
| 1324 | switch( msg )
|
|---|
| 1325 | {
|
|---|
| 1326 | case WM_CREATE:
|
|---|
| 1327 | {
|
|---|
| 1328 | //WM_CREATE handled during client window creation
|
|---|
| 1329 | dprintf(("PMFRAME: WM_CREATE %x", hwnd));
|
|---|
| 1330 | goto RunDefFrameWndProc;
|
|---|
| 1331 | }
|
|---|
| 1332 |
|
|---|
| 1333 | //hack alert; PM crashes if child calls DestroyWindow for parent/owner in WM_DESTROY
|
|---|
| 1334 | // handler; must postpone it, so do it here
|
|---|
| 1335 | case WIN32APP_POSTPONEDESTROY:
|
|---|
| 1336 | OSLibWinDestroyWindow(hwnd);
|
|---|
| 1337 | break;
|
|---|
| 1338 | //hack end
|
|---|
| 1339 |
|
|---|
| 1340 | #ifdef DEBUG
|
|---|
| 1341 | case WM_CLOSE:
|
|---|
| 1342 | {
|
|---|
| 1343 | dprintf(("PMFRAME: WM_CLOSE %x", hwnd));
|
|---|
| 1344 | goto RunDefFrameWndProc;
|
|---|
| 1345 | }
|
|---|
| 1346 | #endif
|
|---|
| 1347 |
|
|---|
| 1348 | case WM_PAINT:
|
|---|
| 1349 | {
|
|---|
| 1350 | RECTL rectl;
|
|---|
| 1351 | HRGN hrgn;
|
|---|
| 1352 |
|
|---|
| 1353 | hrgn = CreateRectRgn(0, 0, 0, 0);
|
|---|
| 1354 | GetUpdateRgnFrame(win32wnd->getWindowHandle(), hrgn);
|
|---|
| 1355 |
|
|---|
| 1356 | HPS hps = WinBeginPaint(hwnd, NULL, &rectl);
|
|---|
| 1357 | dprintf(("PMFRAME: WM_PAINT %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
|
|---|
| 1358 |
|
|---|
| 1359 | if(win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
|
|---|
| 1360 | rectl.yBottom != rectl.yTop))
|
|---|
| 1361 | {
|
|---|
| 1362 | PRECT pClient = win32wnd->getClientRectPtr();
|
|---|
| 1363 | PRECT pWindow = win32wnd->getWindowRect();
|
|---|
| 1364 |
|
|---|
| 1365 | if(!(pClient->left == 0 && pClient->top == 0 &&
|
|---|
| 1366 | win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
|
|---|
| 1367 | win32wnd->getClientWidth() == win32wnd->getWindowWidth()))
|
|---|
| 1368 | {
|
|---|
| 1369 | RECT rectUpdate;
|
|---|
| 1370 |
|
|---|
| 1371 | mapOS2ToWin32Rect(win32wnd->getWindowHeight(), (PRECTLOS2)&rectl, &rectUpdate);
|
|---|
| 1372 | win32wnd->MsgNCPaint(&rectUpdate, hrgn);
|
|---|
| 1373 | }
|
|---|
| 1374 | }
|
|---|
| 1375 | WinEndPaint(hps);
|
|---|
| 1376 |
|
|---|
| 1377 | DeleteObject(hrgn);
|
|---|
| 1378 | break;
|
|---|
| 1379 | }
|
|---|
| 1380 |
|
|---|
| 1381 | case WM_ERASEBACKGROUND:
|
|---|
| 1382 | {
|
|---|
| 1383 | dprintf(("PMFRAME:WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
|---|
| 1384 | rc = (MRESULT)FALSE;
|
|---|
| 1385 | break;
|
|---|
| 1386 | }
|
|---|
| 1387 |
|
|---|
| 1388 | //**************************************************************************
|
|---|
| 1389 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
|---|
| 1390 | //**************************************************************************
|
|---|
| 1391 |
|
|---|
| 1392 | case WM_BUTTON1DOWN:
|
|---|
| 1393 | case WM_BUTTON1UP:
|
|---|
| 1394 | case WM_BUTTON1DBLCLK:
|
|---|
| 1395 | case WM_BUTTON2DOWN:
|
|---|
| 1396 | case WM_BUTTON2UP:
|
|---|
| 1397 | case WM_BUTTON2DBLCLK:
|
|---|
| 1398 | case WM_BUTTON3DOWN:
|
|---|
| 1399 | case WM_BUTTON3UP:
|
|---|
| 1400 | case WM_BUTTON3DBLCLK:
|
|---|
| 1401 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 1402 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 1403 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 1404 | }
|
|---|
| 1405 | if(win32wnd)
|
|---|
| 1406 | win32wnd->MsgButton(pWinMsg);
|
|---|
| 1407 |
|
|---|
| 1408 | rc = (MRESULT)TRUE;
|
|---|
| 1409 | break;
|
|---|
| 1410 |
|
|---|
| 1411 | case WM_BUTTON2MOTIONSTART:
|
|---|
| 1412 | case WM_BUTTON2MOTIONEND:
|
|---|
| 1413 | case WM_BUTTON2CLICK:
|
|---|
| 1414 | case WM_BUTTON1MOTIONSTART:
|
|---|
| 1415 | case WM_BUTTON1MOTIONEND:
|
|---|
| 1416 | case WM_BUTTON1CLICK:
|
|---|
| 1417 | case WM_BUTTON3MOTIONSTART:
|
|---|
| 1418 | case WM_BUTTON3MOTIONEND:
|
|---|
| 1419 | case WM_BUTTON3CLICK:
|
|---|
| 1420 | rc = (MRESULT)TRUE;
|
|---|
| 1421 | break;
|
|---|
| 1422 |
|
|---|
| 1423 | case WM_MOUSEMOVE:
|
|---|
| 1424 | {
|
|---|
| 1425 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 1426 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 1427 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 1428 | }
|
|---|
| 1429 | if(win32wnd)
|
|---|
| 1430 | win32wnd->MsgMouseMove(pWinMsg);
|
|---|
| 1431 | break;
|
|---|
| 1432 | }
|
|---|
| 1433 |
|
|---|
| 1434 | case WM_CHAR_SPECIAL_CONSOLE_BREAK:
|
|---|
| 1435 | {
|
|---|
| 1436 | //ignore this message. don't forward it to the default PM frame window handler
|
|---|
| 1437 | //as that one sends it to the client. as a result we end up translating
|
|---|
| 1438 | //it twice
|
|---|
| 1439 | break;
|
|---|
| 1440 | }
|
|---|
| 1441 |
|
|---|
| 1442 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 1443 | {
|
|---|
| 1444 | PSWP pswp = (PSWP)mp1;
|
|---|
| 1445 | SWP swpOld;
|
|---|
| 1446 | WINDOWPOS wp,wpOld;
|
|---|
| 1447 | ULONG ulFlags;
|
|---|
| 1448 | ULONG ret = 0;
|
|---|
| 1449 | HWND hParent = NULLHANDLE, hwndAfter;
|
|---|
| 1450 |
|
|---|
| 1451 | dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS %x %x %x (%s) (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 1452 |
|
|---|
| 1453 | ulFlags = pswp->fl;
|
|---|
| 1454 |
|
|---|
| 1455 | if(win32wnd->IsParentChanging()) {
|
|---|
| 1456 | rc = 0;
|
|---|
| 1457 | break;
|
|---|
| 1458 | }
|
|---|
| 1459 |
|
|---|
| 1460 | //@@PF all commands from minimized window viewer or from Ctrl-Esc
|
|---|
| 1461 | //are 'pure' and should be handled only by DeFrameProc - this is weird
|
|---|
| 1462 | //but without them we will not have results. Pure = plain flag of restore/minimize/maximize
|
|---|
| 1463 | if((pswp->fl == SWP_MINIMIZE) || (pswp->fl & SWP_RESTORE)) {
|
|---|
| 1464 | // note the purity of SWP no other SWP_FLAGS allowed
|
|---|
| 1465 | goto RunDefFrameWndProc;
|
|---|
| 1466 | }
|
|---|
| 1467 |
|
|---|
| 1468 | if(pswp->fl & SWP_NOADJUST) {
|
|---|
| 1469 | //ignore weird messages (TODO: why are they sent?)
|
|---|
| 1470 | dprintf(("WARNING: WM_ADJUSTWINDOWPOS with SWP_NOADJUST flag!!"));
|
|---|
| 1471 | break;
|
|---|
| 1472 |
|
|---|
| 1473 | }
|
|---|
| 1474 |
|
|---|
| 1475 | //PF Pure flags should not cause any subsequent messages to win32 windows
|
|---|
| 1476 | //we should route them to DefFrameWndProc and check highlight.
|
|---|
| 1477 |
|
|---|
| 1478 | if ((pswp->fl == SWP_FOCUSACTIVATE) || (pswp->fl == SWP_FOCUSDEACTIVATE))
|
|---|
| 1479 | {
|
|---|
| 1480 | if (fOS2Look)
|
|---|
| 1481 | {
|
|---|
| 1482 | if(pswp->fl == SWP_FOCUSACTIVATE)
|
|---|
| 1483 | {
|
|---|
| 1484 | dprintf2(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
|---|
| 1485 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, (MPARAM)1, 0);
|
|---|
| 1486 | }
|
|---|
| 1487 | else
|
|---|
| 1488 | {
|
|---|
| 1489 | dprintf2(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
|---|
| 1490 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, 0, 0);
|
|---|
| 1491 | }
|
|---|
| 1492 | }
|
|---|
| 1493 | goto RunDefFrameWndProc;
|
|---|
| 1494 | }
|
|---|
| 1495 |
|
|---|
| 1496 | //CB: show dialog in front of owner
|
|---|
| 1497 | if (win32wnd->IsModalDialogOwner())
|
|---|
| 1498 | {
|
|---|
| 1499 | dprintf(("win32wnd->IsModalDialogOwner %x", win32wnd->getWindowHandle()));
|
|---|
| 1500 | pswp->fl |= SWP_ZORDER;
|
|---|
| 1501 | pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
|
|---|
| 1502 | if (pswp->fl & SWP_ACTIVATE)
|
|---|
| 1503 | {
|
|---|
| 1504 | pswp->fl &= ~SWP_ACTIVATE;
|
|---|
| 1505 | WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
|
|---|
| 1506 | }
|
|---|
| 1507 | }
|
|---|
| 1508 |
|
|---|
| 1509 | if(!win32wnd->CanReceiveSizeMsgs())
|
|---|
| 1510 | break;
|
|---|
| 1511 |
|
|---|
| 1512 | WinQueryWindowPos(hwnd, &swpOld);
|
|---|
| 1513 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 1514 | if (win32wnd->isChild()) {
|
|---|
| 1515 | if(win32wnd->getParent()) {
|
|---|
| 1516 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 1517 | }
|
|---|
| 1518 | else goto RunDefFrameWndProc;
|
|---|
| 1519 | }
|
|---|
| 1520 | }
|
|---|
| 1521 | hwndAfter = pswp->hwndInsertBehind;
|
|---|
| 1522 | if(win32wnd->getParent()) {
|
|---|
| 1523 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(), hwnd);
|
|---|
| 1524 | }
|
|---|
| 1525 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
|---|
| 1526 |
|
|---|
| 1527 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 1528 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 1529 | {
|
|---|
| 1530 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 1531 | dprintf2(("SWP_ZORDER: %x %x", pswp->hwndInsertBehind, (wndAfter) ? wndAfter->getWindowHandle() : 0));
|
|---|
| 1532 | if(wndAfter) {
|
|---|
| 1533 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 1534 | RELEASE_WNDOBJ(wndAfter);
|
|---|
| 1535 | }
|
|---|
| 1536 | else wp.hwndInsertAfter = HWND_TOP_W;
|
|---|
| 1537 | }
|
|---|
| 1538 |
|
|---|
| 1539 | wpOld = wp;
|
|---|
| 1540 | win32wnd->MsgPosChanging((LPARAM)&wp);
|
|---|
| 1541 |
|
|---|
| 1542 | if(win32wnd->getOldStyle() != win32wnd->getStyle())
|
|---|
| 1543 | {
|
|---|
| 1544 | OSLibSetWindowStyle(win32wnd->getOS2FrameWindowHandle(), win32wnd->getOS2WindowHandle(), win32wnd->getStyle(), win32wnd->getExStyle(), win32wnd->getStyle());
|
|---|
| 1545 | if(fOS2Look) {
|
|---|
| 1546 | DWORD dwOldStyle = win32wnd->getOldStyle();
|
|---|
| 1547 | DWORD dwStyle = win32wnd->getStyle();
|
|---|
| 1548 |
|
|---|
| 1549 | win32wnd->setOldStyle(dwStyle);
|
|---|
| 1550 | if((dwOldStyle & WS_MINIMIZE_W) && !(dwStyle & WS_MINIMIZE_W)) {
|
|---|
| 1551 | //SC_RESTORE -> SC_MINIMIZE
|
|---|
| 1552 | dprintf(("%x -> SC_RESTORE -> SC_MINIMIZE", win32wnd->getWindowHandle()));
|
|---|
| 1553 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), 0, SC_RESTORE, SC_MINIMIZE, hbmFrameMenu[PMMENU_MINBUTTON]);
|
|---|
| 1554 | if(dwStyle & WS_MAXIMIZE_W) {
|
|---|
| 1555 | //SC_MAXIMIZE -> SC_RESTORE
|
|---|
| 1556 | dprintf(("%x -> SC_MAXIMIZE -> SC_RESTORE (1)", win32wnd->getWindowHandle()));
|
|---|
| 1557 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_MAXIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
|
|---|
| 1558 | }
|
|---|
| 1559 | }
|
|---|
| 1560 | else
|
|---|
| 1561 | if((dwOldStyle & WS_MAXIMIZE_W) && !(dwStyle & WS_MAXIMIZE_W)) {
|
|---|
| 1562 | //SC_RESTORE -> SC_MAXIMIZE
|
|---|
| 1563 | dprintf(("%x -> SC_RESTORE -> SC_MAXIMIZE", win32wnd->getWindowHandle()));
|
|---|
| 1564 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_RESTORE, SC_MAXIMIZE, hbmFrameMenu[PMMENU_MAXBUTTON]);
|
|---|
| 1565 | }
|
|---|
| 1566 | else
|
|---|
| 1567 | if(!(dwOldStyle & WS_MINIMIZE_W) && (dwStyle & WS_MINIMIZE_W)) {
|
|---|
| 1568 | //SC_MINIMIZE -> SC_RESTORE
|
|---|
| 1569 | dprintf(("%x -> SC_MINIMIZE -> SC_RESTORE", win32wnd->getWindowHandle()));
|
|---|
| 1570 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), 0, SC_MINIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
|
|---|
| 1571 | }
|
|---|
| 1572 | else
|
|---|
| 1573 | if(!(dwOldStyle & WS_MAXIMIZE_W) && (dwStyle & WS_MAXIMIZE_W)) {
|
|---|
| 1574 | //SC_MAXIMIZE -> SC_RESTORE
|
|---|
| 1575 | dprintf(("%x -> SC_MAXIMIZE -> SC_RESTORE (2)", win32wnd->getWindowHandle()));
|
|---|
| 1576 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_MAXIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
|
|---|
| 1577 | }
|
|---|
| 1578 | }
|
|---|
| 1579 | }
|
|---|
| 1580 |
|
|---|
| 1581 | if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
|
|---|
| 1582 | (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
|
|---|
| 1583 | {
|
|---|
| 1584 | ULONG flags = pswp->fl; //make a backup copy; OSLibMapWINDOWPOStoSWP will modify it
|
|---|
| 1585 |
|
|---|
| 1586 | dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
|---|
| 1587 | dprintf(("%x (%s) (%d,%d), (%d,%d)", pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 1588 |
|
|---|
| 1589 | if(win32wnd->getParent()) {
|
|---|
| 1590 | OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
|---|
| 1591 | hwnd);
|
|---|
| 1592 | }
|
|---|
| 1593 | else OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
|---|
| 1594 |
|
|---|
| 1595 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 1596 |
|
|---|
| 1597 | //OSLibMapWINDOWPOStoSWP can add flags, but we must not let it remove flags!
|
|---|
| 1598 | if(pswp->fl & SWP_SIZE)
|
|---|
| 1599 | flags |= SWP_SIZE;
|
|---|
| 1600 |
|
|---|
| 1601 | if(pswp->fl & SWP_MOVE)
|
|---|
| 1602 | flags |= SWP_MOVE;
|
|---|
| 1603 |
|
|---|
| 1604 | pswp->fl = flags; //restore flags
|
|---|
| 1605 |
|
|---|
| 1606 | pswp->fl |= SWP_NOADJUST;
|
|---|
| 1607 | pswp->hwndInsertBehind = hwndAfter;
|
|---|
| 1608 | pswp->hwnd = hwnd;
|
|---|
| 1609 |
|
|---|
| 1610 | ret = 0xf;
|
|---|
| 1611 | }
|
|---|
| 1612 | adjustend:
|
|---|
| 1613 | //The next part needs to be done for top-level windows only
|
|---|
| 1614 | if(!((win32wnd->getStyle() & (WS_POPUP_W|WS_CHILD_W)) == WS_CHILD_W))
|
|---|
| 1615 | {
|
|---|
| 1616 | //Setting these flags is necessary to avoid activation/focus problems
|
|---|
| 1617 | if(ulFlags & SWP_DEACTIVATE) {
|
|---|
| 1618 | ret |= AWP_DEACTIVATE;
|
|---|
| 1619 | }
|
|---|
| 1620 | if(ulFlags & SWP_ACTIVATE)
|
|---|
| 1621 | {
|
|---|
| 1622 | if(ulFlags & SWP_ZORDER) {
|
|---|
| 1623 | dprintf(("Set FF_NOACTIVATESWP"));
|
|---|
| 1624 | ULONG ulFrameFlags = WinQueryWindowUShort(hwnd, QWS_FLAGS);
|
|---|
| 1625 | WinSetWindowUShort(hwnd, QWS_FLAGS, ulFrameFlags | FF_NOACTIVATESWP);
|
|---|
| 1626 | }
|
|---|
| 1627 |
|
|---|
| 1628 | if(!(ulFlags & SWP_SHOW))
|
|---|
| 1629 | {
|
|---|
| 1630 | ret |= AWP_ACTIVATE;
|
|---|
| 1631 | }
|
|---|
| 1632 | else
|
|---|
| 1633 | {
|
|---|
| 1634 | FrameSetFocus(hwnd);
|
|---|
| 1635 | }
|
|---|
| 1636 | }
|
|---|
| 1637 | }
|
|---|
| 1638 | else {
|
|---|
| 1639 | if(ulFlags & (SWP_ACTIVATE|SWP_FOCUSACTIVATE))
|
|---|
| 1640 | {
|
|---|
| 1641 | win32wnd->MsgChildActivate(TRUE);
|
|---|
| 1642 | if(fOS2Look) {
|
|---|
| 1643 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
|---|
| 1644 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, (MPARAM)1, 0);
|
|---|
| 1645 | }
|
|---|
| 1646 | }
|
|---|
| 1647 | else
|
|---|
| 1648 | if(ulFlags & (SWP_DEACTIVATE|SWP_FOCUSDEACTIVATE))
|
|---|
| 1649 | {
|
|---|
| 1650 | win32wnd->MsgChildActivate(FALSE);
|
|---|
| 1651 | if(fOS2Look) {
|
|---|
| 1652 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
|---|
| 1653 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, 0, 0);
|
|---|
| 1654 | }
|
|---|
| 1655 | }
|
|---|
| 1656 | }
|
|---|
| 1657 | #ifdef DEBUG
|
|---|
| 1658 | dprintf(("WM_ADJUSTWINDOWPOS ret %x flags %x", ret, WinQueryWindowUShort(hwnd, QWS_FLAGS)));
|
|---|
| 1659 | if(ret == 0x0f) {
|
|---|
| 1660 | dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
|---|
| 1661 | dprintf(("%x (%s) (%d,%d), (%d,%d)", pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 1662 | }
|
|---|
| 1663 | #endif
|
|---|
| 1664 | rc = (MRESULT)ret;
|
|---|
| 1665 | break;
|
|---|
| 1666 | }
|
|---|
| 1667 |
|
|---|
| 1668 | case WM_WINDOWPOSCHANGED:
|
|---|
| 1669 | {
|
|---|
| 1670 | PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
|
|---|
| 1671 | SWP swpOld = *(pswp + 1);
|
|---|
| 1672 | WINDOWPOS wp;
|
|---|
| 1673 | ULONG flAfp = (ULONG)mp2;
|
|---|
| 1674 | HWND hParent = NULLHANDLE;
|
|---|
| 1675 | RECTL rect;
|
|---|
| 1676 |
|
|---|
| 1677 | dprintf(("PMFRAME:WM_WINDOWPOSCHANGED (%x) %x %x (%s) (%d,%d) (%d,%d) z %x", mp2, win32wnd->getWindowHandle(), pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy, Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind)));
|
|---|
| 1678 | if(win32wnd->IsParentChanging()) {
|
|---|
| 1679 | goto PosChangedEnd;
|
|---|
| 1680 | }
|
|---|
| 1681 |
|
|---|
| 1682 | // PF: MDI window is not a common OS/2 frame window so we just skipped all
|
|---|
| 1683 | // PM default processing for it that basicly moved this window to 0,0 point
|
|---|
| 1684 | // and changed frame controls. Now do our own processing.
|
|---|
| 1685 |
|
|---|
| 1686 | if ((pswp->fl & SWP_MAXIMIZE) && (win32wnd->getExStyle() & WS_EX_MDICHILD_W))
|
|---|
| 1687 | {
|
|---|
| 1688 | SendMessageA(win32wnd->getWindowHandle(), WM_SYSCOMMAND_W, SC_MAXIMIZE_W, 0);
|
|---|
| 1689 | goto PosChangedEnd;
|
|---|
| 1690 | }
|
|---|
| 1691 |
|
|---|
| 1692 | //SvL: When a window is made visible, then we don't receive a
|
|---|
| 1693 | // WM_VRNENABLED message (for some weird reason)
|
|---|
| 1694 | if(pswp->fl & SWP_SHOW) {
|
|---|
| 1695 | win32wnd->callVisibleRgnNotifyProc(TRUE);
|
|---|
| 1696 | }
|
|---|
| 1697 | else
|
|---|
| 1698 | if(pswp->fl & SWP_HIDE) {
|
|---|
| 1699 | win32wnd->callVisibleRgnNotifyProc(FALSE);
|
|---|
| 1700 | }
|
|---|
| 1701 |
|
|---|
| 1702 | if(pswp->fl & (SWP_MOVE | SWP_SIZE))
|
|---|
| 1703 | {
|
|---|
| 1704 | if(win32wnd->isChild())
|
|---|
| 1705 | {
|
|---|
| 1706 | if(win32wnd->getParent()) {
|
|---|
| 1707 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 1708 | }
|
|---|
| 1709 | else goto PosChangedEnd; //parent has just been destroyed
|
|---|
| 1710 | }
|
|---|
| 1711 | }
|
|---|
| 1712 |
|
|---|
| 1713 |
|
|---|
| 1714 | if(win32wnd->getParent()) {
|
|---|
| 1715 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
|---|
| 1716 | hwnd);
|
|---|
| 1717 | }
|
|---|
| 1718 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
|---|
| 1719 |
|
|---|
| 1720 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 1721 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 1722 | {
|
|---|
| 1723 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 1724 | dprintf2(("SWP_ZORDER: %x %x", pswp->hwndInsertBehind, (wndAfter) ? wndAfter->getWindowHandle() : 0));
|
|---|
| 1725 | if(wndAfter) {
|
|---|
| 1726 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 1727 | RELEASE_WNDOBJ(wndAfter);
|
|---|
| 1728 | }
|
|---|
| 1729 | else wp.hwndInsertAfter = HWND_TOP_W;
|
|---|
| 1730 | }
|
|---|
| 1731 |
|
|---|
| 1732 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 1733 | {
|
|---|
| 1734 | if(pswp->fl & SWP_RESTORE && win32wnd->getStyle() & WS_MINIMIZE_W) {
|
|---|
| 1735 | dprintf(("Restoring minimized window %x", win32wnd->getWindowHandle()));
|
|---|
| 1736 | win32wnd->ShowWindow(SW_RESTORE_W);
|
|---|
| 1737 | }
|
|---|
| 1738 | if(pswp->fl & SWP_SHOW) {
|
|---|
| 1739 | WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
|
|---|
| 1740 | }
|
|---|
| 1741 | else
|
|---|
| 1742 | if(pswp->fl & SWP_HIDE) {
|
|---|
| 1743 | WinShowWindow(win32wnd->getOS2WindowHandle(), 0);
|
|---|
| 1744 | }
|
|---|
| 1745 | if(pswp->fl & (SWP_SHOW|SWP_HIDE))
|
|---|
| 1746 | {//TODO: necessary for more options? (activate?)
|
|---|
| 1747 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 1748 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 1749 | }
|
|---|
| 1750 |
|
|---|
| 1751 | //MUST call the old frame window proc!
|
|---|
| 1752 | goto RunDefFrameWndProc;
|
|---|
| 1753 | }
|
|---|
| 1754 |
|
|---|
| 1755 | if(pswp->fl & SWP_SHOW) {
|
|---|
| 1756 | WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
|
|---|
| 1757 | }
|
|---|
| 1758 | else
|
|---|
| 1759 | if(pswp->fl & SWP_HIDE) {
|
|---|
| 1760 | WinShowWindow(win32wnd->getOS2WindowHandle(), 0);
|
|---|
| 1761 | }
|
|---|
| 1762 |
|
|---|
| 1763 | if(flAfp & AWP_ACTIVATE)
|
|---|
| 1764 | {
|
|---|
| 1765 | FrameSetFocus(hwnd);
|
|---|
| 1766 | }
|
|---|
| 1767 |
|
|---|
| 1768 | #ifndef USE_CALCVALIDRECT
|
|---|
| 1769 | if((pswp->fl & (SWP_MOVE | SWP_SIZE)))
|
|---|
| 1770 | {
|
|---|
| 1771 | //CB: todo: use result for WM_CALCVALIDRECTS
|
|---|
| 1772 | //Get old client rectangle (for invalidation of frame window parts later on)
|
|---|
| 1773 | //Use new window height to calculate the client area
|
|---|
| 1774 | mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
|
|---|
| 1775 |
|
|---|
| 1776 | //Note: Also updates the new window rectangle
|
|---|
| 1777 | win32wnd->MsgFormatFrame(&wp);
|
|---|
| 1778 |
|
|---|
| 1779 | if(win32wnd->isOwnDC()) {
|
|---|
| 1780 | setPageXForm(win32wnd, (pDCData)GpiQueryDCData(win32wnd->getOwnDC()));
|
|---|
| 1781 | }
|
|---|
| 1782 |
|
|---|
| 1783 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 1784 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 1785 |
|
|---|
| 1786 | if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
|
|---|
| 1787 | {
|
|---|
| 1788 | //redraw the frame (to prevent unnecessary client updates)
|
|---|
| 1789 | BOOL redrawAll = FALSE;
|
|---|
| 1790 |
|
|---|
| 1791 | dprintf2(("WM_WINDOWPOSCHANGED: redraw frame"));
|
|---|
| 1792 | if (win32wnd->getWindowClass())
|
|---|
| 1793 | {
|
|---|
| 1794 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
|---|
| 1795 |
|
|---|
| 1796 | if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
|
|---|
| 1797 | redrawAll = TRUE;
|
|---|
| 1798 | else
|
|---|
| 1799 | if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
|
|---|
| 1800 | redrawAll = TRUE;
|
|---|
| 1801 | }
|
|---|
| 1802 | else redrawAll = TRUE;
|
|---|
| 1803 |
|
|---|
| 1804 | if(win32wnd->IsMixMaxStateChanging()) {
|
|---|
| 1805 | dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
|
|---|
| 1806 | redrawAll = TRUE;
|
|---|
| 1807 | }
|
|---|
| 1808 |
|
|---|
| 1809 | if (redrawAll)
|
|---|
| 1810 | {
|
|---|
| 1811 | //CB: redraw all children for now
|
|---|
| 1812 | // -> problems with update region if we don't do it
|
|---|
| 1813 | // todo: rewrite whole handling
|
|---|
| 1814 | dprintf(("PMFRAME: WM_WINDOWPOSCHANGED invalidate all"));
|
|---|
| 1815 | WinInvalidateRect(hwnd,NULL,TRUE);
|
|---|
| 1816 | }
|
|---|
| 1817 | else
|
|---|
| 1818 | {
|
|---|
| 1819 | HPS hps = WinGetPS(hwnd);
|
|---|
| 1820 | RECTL frame,client,arcl[4];
|
|---|
| 1821 |
|
|---|
| 1822 | WinQueryWindowRect(hwnd,&frame);
|
|---|
| 1823 |
|
|---|
| 1824 | //top
|
|---|
| 1825 | arcl[0].xLeft = 0;
|
|---|
| 1826 | arcl[0].xRight = frame.xRight;
|
|---|
| 1827 | arcl[0].yBottom = rect.yTop;
|
|---|
| 1828 | arcl[0].yTop = frame.yTop;
|
|---|
| 1829 | //right
|
|---|
| 1830 | arcl[1].xLeft = rect.xRight;
|
|---|
| 1831 | arcl[1].xRight = frame.xRight;
|
|---|
| 1832 | arcl[1].yBottom = 0;
|
|---|
| 1833 | arcl[1].yTop = frame.yTop;
|
|---|
| 1834 | //left
|
|---|
| 1835 | arcl[2].xLeft = 0;
|
|---|
| 1836 | arcl[2].xRight = rect.xLeft;
|
|---|
| 1837 | arcl[2].yBottom = 0;
|
|---|
| 1838 | arcl[2].yTop = frame.yTop;
|
|---|
| 1839 | //bottom
|
|---|
| 1840 | arcl[3].xLeft = 0;
|
|---|
| 1841 | arcl[3].xRight = frame.xRight;
|
|---|
| 1842 | arcl[3].yBottom = 0;
|
|---|
| 1843 | arcl[3].yTop = rect.yBottom;
|
|---|
| 1844 |
|
|---|
| 1845 | HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
|
|---|
| 1846 |
|
|---|
| 1847 | WinInvalidateRegion(hwnd,hrgn,FALSE);
|
|---|
| 1848 | GpiDestroyRegion(hps,hrgn);
|
|---|
| 1849 | WinReleasePS(hps);
|
|---|
| 1850 | }
|
|---|
| 1851 | }
|
|---|
| 1852 | }
|
|---|
| 1853 | else
|
|---|
| 1854 | {
|
|---|
| 1855 | #endif //USE_CALCVALIDRECT
|
|---|
| 1856 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 1857 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 1858 | #ifndef USE_CALCVALIDRECT
|
|---|
| 1859 | }
|
|---|
| 1860 | #endif
|
|---|
| 1861 | //PF This is the final step of PM restoration - should end up
|
|---|
| 1862 | //in default handler.
|
|---|
| 1863 | if (win32wnd->getOldStyle() & WS_MINIMIZE_W && pswp->fl & SWP_RESTORE)
|
|---|
| 1864 | goto RunDefFrameWndProc;
|
|---|
| 1865 |
|
|---|
| 1866 | //PF This is the final step of PM minimization - shoukd end up
|
|---|
| 1867 | //in default handler
|
|---|
| 1868 | if (win32wnd->getStyle() & WS_MINIMIZE_W && pswp->fl & SWP_MINIMIZE)
|
|---|
| 1869 | goto RunDefFrameWndProc;
|
|---|
| 1870 |
|
|---|
| 1871 | PosChangedEnd:
|
|---|
| 1872 | rc = (MRESULT)FALSE;
|
|---|
| 1873 | break;
|
|---|
| 1874 | }
|
|---|
| 1875 |
|
|---|
| 1876 | case WM_CALCVALIDRECTS:
|
|---|
| 1877 | #ifdef USE_CALCVALIDRECT
|
|---|
| 1878 | {
|
|---|
| 1879 | PRECTL oldRect = (PRECTL)mp1, newRect = oldRect+1;
|
|---|
| 1880 | PSWP pswp = (PSWP)mp2;
|
|---|
| 1881 | SWP swpOld;
|
|---|
| 1882 | WINDOWPOS wp;
|
|---|
| 1883 | RECTL newClientRect, oldClientRect;
|
|---|
| 1884 | ULONG nccalcret;
|
|---|
| 1885 | // UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
|
|---|
| 1886 | UINT res = 0;
|
|---|
| 1887 |
|
|---|
| 1888 | dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
|---|
| 1889 |
|
|---|
| 1890 | //Get old position info
|
|---|
| 1891 | WinQueryWindowPos(hwnd, &swpOld);
|
|---|
| 1892 |
|
|---|
| 1893 | if(win32wnd->getParent()) {
|
|---|
| 1894 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
|---|
| 1895 | win32wnd->getParent()->getClientRectPtr()->left,
|
|---|
| 1896 | win32wnd->getParent()->getClientRectPtr()->top,
|
|---|
| 1897 | hwnd);
|
|---|
| 1898 | }
|
|---|
| 1899 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
|---|
| 1900 |
|
|---|
| 1901 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 1902 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 1903 | {
|
|---|
| 1904 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 1905 | if(wndAfter) {
|
|---|
| 1906 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 1907 | RELEASE_WNDOBJ(wndAfter);
|
|---|
| 1908 | }
|
|---|
| 1909 | else wp.hwndInsertAfter = HWND_TOP_W;
|
|---|
| 1910 | }
|
|---|
| 1911 |
|
|---|
| 1912 | //Get old client rectangle
|
|---|
| 1913 | mapWin32ToOS2Rect(oldRect->yTop - oldRect->yBottom, win32wnd->getClientRectPtr(), (PRECTLOS2)&oldClientRect);
|
|---|
| 1914 |
|
|---|
| 1915 | //Note: Also updates the new window rectangle
|
|---|
| 1916 | nccalcret = win32wnd->MsgFormatFrame(&wp);
|
|---|
| 1917 |
|
|---|
| 1918 | //Get new client rectangle
|
|---|
| 1919 | mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&newClientRect);
|
|---|
| 1920 |
|
|---|
| 1921 | if(nccalcret == 0) {
|
|---|
| 1922 | res = CVR_ALIGNTOP | CVR_ALIGNLEFT;
|
|---|
| 1923 | }
|
|---|
| 1924 | else {
|
|---|
| 1925 | if(nccalcret & WVR_ALIGNTOP_W) {
|
|---|
| 1926 | res |= CVR_ALIGNTOP;
|
|---|
| 1927 | }
|
|---|
| 1928 | else
|
|---|
| 1929 | if(nccalcret & WVR_ALIGNBOTTOM_W) {
|
|---|
| 1930 | res |= CVR_ALIGNBOTTOM;
|
|---|
| 1931 | }
|
|---|
| 1932 |
|
|---|
| 1933 | if(nccalcret & WVR_ALIGNLEFT_W) {
|
|---|
| 1934 | res |= CVR_ALIGNLEFT;
|
|---|
| 1935 | }
|
|---|
| 1936 | else
|
|---|
| 1937 | if(nccalcret & WVR_ALIGNRIGHT_W) {
|
|---|
| 1938 | res |= CVR_ALIGNRIGHT;
|
|---|
| 1939 | }
|
|---|
| 1940 |
|
|---|
| 1941 | if(nccalcret & WVR_REDRAW_W) {//WVR_REDRAW_W = (WVR_HREDRAW | WVR_VREDRAW)
|
|---|
| 1942 | res |= CVR_REDRAW;
|
|---|
| 1943 | }
|
|---|
| 1944 | else
|
|---|
| 1945 | if(nccalcret & WVR_VALIDRECTS_W) {
|
|---|
| 1946 | //TODO:
|
|---|
| 1947 | //res = 0;
|
|---|
| 1948 | }
|
|---|
| 1949 | }
|
|---|
| 1950 | if(win32wnd->IsMixMaxStateChanging()) {
|
|---|
| 1951 | dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
|
|---|
| 1952 | res |= CVR_REDRAW;
|
|---|
| 1953 | }
|
|---|
| 1954 | if(res == (CVR_ALIGNTOP|CVR_ALIGNLEFT)) {
|
|---|
| 1955 | oldRect->xRight -= oldClientRect.xLeft;
|
|---|
| 1956 | oldRect->yBottom += oldClientRect.yBottom;
|
|---|
| 1957 | newRect->xRight -= newClientRect.xLeft;
|
|---|
| 1958 | newRect->yBottom += newClientRect.yBottom;
|
|---|
| 1959 | }
|
|---|
| 1960 | rc = res;
|
|---|
| 1961 | break;
|
|---|
| 1962 | }
|
|---|
| 1963 | #else
|
|---|
| 1964 | dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
|---|
| 1965 | rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
|---|
| 1966 | break;
|
|---|
| 1967 | #endif
|
|---|
| 1968 |
|
|---|
| 1969 | case WM_CALCFRAMERECT:
|
|---|
| 1970 | dprintf(("PMFRAME:WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
|
|---|
| 1971 | rc = (MRESULT)TRUE;
|
|---|
| 1972 | break;
|
|---|
| 1973 |
|
|---|
| 1974 | case WM_QUERYCTLTYPE:
|
|---|
| 1975 | // This is a frame window
|
|---|
| 1976 | dprintf(("PMFRAME:WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
|
|---|
| 1977 | rc = (MRESULT)CCT_FRAME;
|
|---|
| 1978 | break;
|
|---|
| 1979 |
|
|---|
| 1980 | #ifdef DEBUG
|
|---|
| 1981 | case WM_QUERYFOCUSCHAIN:
|
|---|
| 1982 | dprintf2(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x (%s) parent %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), DbgPrintQFCFlags(SHORT1FROMMP(mp1)), (mp2) ? OS2ToWin32Handle((DWORD)mp2) : 0));
|
|---|
| 1983 |
|
|---|
| 1984 | RestoreOS2TIB();
|
|---|
| 1985 | rc = pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
|---|
| 1986 | SetWin32TIB();
|
|---|
| 1987 | dprintf2(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x returned %x (%x)", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), (mp2) ? OS2ToWin32Handle((DWORD)mp2) : 0, (rc) ? OS2ToWin32Handle((DWORD)rc) : 0, rc));
|
|---|
| 1988 | break;
|
|---|
| 1989 | // goto RunDefFrameWndProc;
|
|---|
| 1990 | #endif
|
|---|
| 1991 |
|
|---|
| 1992 | case WM_FOCUSCHANGE:
|
|---|
| 1993 | {
|
|---|
| 1994 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 1995 | HWND hwndLoseFocus, hwndGainFocus;
|
|---|
| 1996 | USHORT usSetFocus = SHORT1FROMMP(mp2);
|
|---|
| 1997 | USHORT fsFocusChange = SHORT2FROMMP(mp2);
|
|---|
| 1998 |
|
|---|
| 1999 | //Save window that gains focus so we can determine which
|
|---|
| 2000 | //process we lose activation to
|
|---|
| 2001 | hwndFocusChange = (HWND)mp1;
|
|---|
| 2002 |
|
|---|
| 2003 | dprintf(("PMFRAME:WM_FOCUSCHANGE %x %x (%x) %x %x", win32wnd->getWindowHandle(), OS2ToWin32Handle(hwndFocus), hwndFocus, usSetFocus, fsFocusChange));
|
|---|
| 2004 | goto RunDefFrameWndProc;
|
|---|
| 2005 | }
|
|---|
| 2006 |
|
|---|
| 2007 | #ifdef DEBUG
|
|---|
| 2008 | case WM_SETFOCUS:
|
|---|
| 2009 | {
|
|---|
| 2010 | dprintf(("PMFRAME: WM_SETFOCUS %x %x %d -> %x", win32wnd->getWindowHandle(), hwnd, mp2, mp1));
|
|---|
| 2011 | goto RunDefFrameWndProc;
|
|---|
| 2012 | }
|
|---|
| 2013 | #endif
|
|---|
| 2014 |
|
|---|
| 2015 | case WM_ACTIVATE:
|
|---|
| 2016 | {
|
|---|
| 2017 | HWND hwndTitle;
|
|---|
| 2018 | USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
|
|---|
| 2019 |
|
|---|
| 2020 | dprintf(("PMFRAME: WM_ACTIVATE %x %x %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle((DWORD)mp2)));
|
|---|
| 2021 | if (win32wnd->IsWindowCreated())
|
|---|
| 2022 | {
|
|---|
| 2023 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
|---|
| 2024 | if(fOS2Look) {
|
|---|
| 2025 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
|---|
| 2026 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, mp1, 0);
|
|---|
| 2027 | }
|
|---|
| 2028 | if(SHORT1FROMMP(mp1) == 0) {
|
|---|
| 2029 | //deactivate
|
|---|
| 2030 | WinSendDlgItemMsg(hwnd, FID_CLIENT, WM_ACTIVATE, mp1, mp2);
|
|---|
| 2031 | }
|
|---|
| 2032 | PID pidThis, pidPartner, pidTemp;
|
|---|
| 2033 | TID tidPartner;
|
|---|
| 2034 | HENUM henum;
|
|---|
| 2035 | HWND hwndEnum;
|
|---|
| 2036 |
|
|---|
| 2037 | WinQueryWindowProcess(hwnd, &pidThis, NULL);
|
|---|
| 2038 | WinQueryWindowProcess(hwndFocusChange, &pidPartner, &tidPartner);
|
|---|
| 2039 |
|
|---|
| 2040 | if(pidThis != pidPartner) {
|
|---|
| 2041 | //Gain or lose activation to window in other process
|
|---|
| 2042 | //must send WM_ACTIVATEAPP to top-level windows
|
|---|
| 2043 |
|
|---|
| 2044 | //Iterate over all child windows of the desktop
|
|---|
| 2045 | henum = WinBeginEnumWindows(HWND_DESKTOP);
|
|---|
| 2046 |
|
|---|
| 2047 | while(hwndEnum = WinGetNextWindow(henum))
|
|---|
| 2048 | {
|
|---|
| 2049 | WinQueryWindowProcess(hwndEnum, &pidTemp, NULL);
|
|---|
| 2050 | if(pidTemp == pidThis)
|
|---|
| 2051 | {
|
|---|
| 2052 | SendMessageA(OS2ToWin32Handle(hwndEnum), WM_ACTIVATEAPP_W, (WPARAM)SHORT1FROMMP(mp1), (LPARAM)tidPartner);
|
|---|
| 2053 | }
|
|---|
| 2054 | }
|
|---|
| 2055 | WinEndEnumWindows(henum);
|
|---|
| 2056 | }
|
|---|
| 2057 | if(SHORT1FROMMP(mp1)) {
|
|---|
| 2058 | //activate
|
|---|
| 2059 | WinSendDlgItemMsg(hwnd, FID_CLIENT, WM_ACTIVATE, mp1, mp2);
|
|---|
| 2060 | }
|
|---|
| 2061 |
|
|---|
| 2062 | //CB: show owner behind the dialog
|
|---|
| 2063 | if (win32wnd->IsModalDialog())
|
|---|
| 2064 | {
|
|---|
| 2065 | if(win32wnd->getOwner()) {
|
|---|
| 2066 | Win32BaseWindow *topOwner = Win32BaseWindow::GetWindowFromHandle(win32wnd->getOwner()->GetTopParent());
|
|---|
| 2067 |
|
|---|
| 2068 | if (topOwner) {
|
|---|
| 2069 | WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
|
|---|
| 2070 | RELEASE_WNDOBJ(topOwner);
|
|---|
| 2071 | }
|
|---|
| 2072 | }
|
|---|
| 2073 | }
|
|---|
| 2074 | }
|
|---|
| 2075 | else
|
|---|
| 2076 | {
|
|---|
| 2077 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
|---|
| 2078 | }
|
|---|
| 2079 | rc = 0;
|
|---|
| 2080 | break;
|
|---|
| 2081 | }
|
|---|
| 2082 |
|
|---|
| 2083 | case WM_ENABLE:
|
|---|
| 2084 | dprintf(("PMFRAME: WM_ENABLE %x", hwnd));
|
|---|
| 2085 | win32wnd->MsgEnable(SHORT1FROMMP(mp1));
|
|---|
| 2086 | break;
|
|---|
| 2087 |
|
|---|
| 2088 | case WM_SHOW:
|
|---|
| 2089 | dprintf(("PMFRAME: WM_SHOW %x %d", hwnd, mp1));
|
|---|
| 2090 | //show client window
|
|---|
| 2091 | WinShowWindow(win32wnd->getOS2WindowHandle(), (BOOL)mp1);
|
|---|
| 2092 | break;
|
|---|
| 2093 |
|
|---|
| 2094 | case WM_QUERYTRACKINFO:
|
|---|
| 2095 | {
|
|---|
| 2096 | PTRACKINFO trackInfo = (PTRACKINFO)mp2;
|
|---|
| 2097 |
|
|---|
| 2098 | dprintf(("PMFRAME:WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
|
|---|
| 2099 | trackInfo->cxBorder = 4;
|
|---|
| 2100 | trackInfo->cyBorder = 4;
|
|---|
| 2101 | win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
|
|---|
| 2102 | rc = (MRESULT)TRUE;
|
|---|
| 2103 | break;
|
|---|
| 2104 | }
|
|---|
| 2105 |
|
|---|
| 2106 | case WM_QUERYBORDERSIZE:
|
|---|
| 2107 | {
|
|---|
| 2108 | PWPOINT size = (PWPOINT)mp1;
|
|---|
| 2109 |
|
|---|
| 2110 | dprintf(("PMFRAME:WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
|
|---|
| 2111 |
|
|---|
| 2112 | size->x = 0;
|
|---|
| 2113 | size->y = 0;
|
|---|
| 2114 | rc = (MRESULT)TRUE;
|
|---|
| 2115 | break;
|
|---|
| 2116 | }
|
|---|
| 2117 |
|
|---|
| 2118 | #ifdef DEBUG
|
|---|
| 2119 | case WM_QUERYFRAMEINFO:
|
|---|
| 2120 | dprintf(("PMFRAME:WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
|
|---|
| 2121 | goto RunDefFrameWndProc;
|
|---|
| 2122 | #endif
|
|---|
| 2123 |
|
|---|
| 2124 | case WM_FORMATFRAME:
|
|---|
| 2125 | dprintf(("PMFRAME:WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
|
|---|
| 2126 | break;
|
|---|
| 2127 |
|
|---|
| 2128 | case WM_ADJUSTFRAMEPOS:
|
|---|
| 2129 | {
|
|---|
| 2130 | PSWP pswp = (PSWP)mp1;
|
|---|
| 2131 |
|
|---|
| 2132 | dprintf(("PMFRAME:WM_ADJUSTFRAMEPOS %x %x %x (%s) (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 2133 | //hack alert: the PM frame control changes the z-order of a child window
|
|---|
| 2134 | // if it receives focus after a window has been destroyed
|
|---|
| 2135 | // We can't let this happen as this messes up assumptions
|
|---|
| 2136 | // elsewhere (e.g. GetNextDlgGroupItem)
|
|---|
| 2137 | // By returning 0 here, we prevent the default frame handler
|
|---|
| 2138 | // from messing things up. (one example is a group of radio buttons)
|
|---|
| 2139 | //NOTE: We really need to get rid of frame & client windows for each
|
|---|
| 2140 | // win32 window
|
|---|
| 2141 | if(pswp->fl == SWP_FOCUSACTIVATE && win32wnd->isChild()) {
|
|---|
| 2142 | rc = 0;
|
|---|
| 2143 | break;
|
|---|
| 2144 | }
|
|---|
| 2145 | //hack alert: as we return zero as border size (check handler) we need
|
|---|
| 2146 | //to do adjustments here as well or PM will calculate it for us and
|
|---|
| 2147 | //result will be illegal. Btw we do not honour PM border size settings
|
|---|
| 2148 | //and never will. I was unable to figure out why only X coordinate
|
|---|
| 2149 | //is being broken but not Y as well.
|
|---|
| 2150 |
|
|---|
| 2151 | if ((pswp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
|---|
| 2152 | {
|
|---|
| 2153 | RECT rect;
|
|---|
| 2154 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
|---|
| 2155 | win32wnd->AdjustMaximizedRect(&rect);
|
|---|
| 2156 |
|
|---|
| 2157 | pswp->x += rect.left;
|
|---|
| 2158 | }
|
|---|
| 2159 | goto RunDefFrameWndProc;
|
|---|
| 2160 | }
|
|---|
| 2161 |
|
|---|
| 2162 | #ifdef DEBUG
|
|---|
| 2163 | case WM_OWNERPOSCHANGE:
|
|---|
| 2164 | {
|
|---|
| 2165 | PSWP pswp = (PSWP)mp1;
|
|---|
| 2166 |
|
|---|
| 2167 | dprintf(("PMFRAME:WM_OWNERPOSCHANGE %x %x %x (%s) (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 2168 | RestoreOS2TIB();
|
|---|
| 2169 | rc = pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
|---|
| 2170 | SetWin32TIB();
|
|---|
| 2171 | dprintf(("PMFRAME: DEF WM_OWNERPOSCHANGE %x %x %x (%s) (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 2172 | break;
|
|---|
| 2173 | }
|
|---|
| 2174 | #endif
|
|---|
| 2175 |
|
|---|
| 2176 | case WM_MINMAXFRAME:
|
|---|
| 2177 | {
|
|---|
| 2178 | PSWP swp = (PSWP)mp1;
|
|---|
| 2179 |
|
|---|
| 2180 | if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
|
|---|
| 2181 |
|
|---|
| 2182 | dprintf(("PMFRAME:WM_MINMAXFRAME %x",hwnd));
|
|---|
| 2183 | if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
|---|
| 2184 | {
|
|---|
| 2185 | // MDI frame windows are not common PM windows so we need to
|
|---|
| 2186 | // drop-out WHOLE chain of WM_X commands with SWP_MAXIMIZE flag
|
|---|
| 2187 | // finally last WM_WINDOWPOSCHANGED will take care of maximization
|
|---|
| 2188 |
|
|---|
| 2189 | if (win32wnd->getExStyle() & WS_EX_MDICHILD_W) {
|
|---|
| 2190 | rc = 0;
|
|---|
| 2191 | break;
|
|---|
| 2192 | }
|
|---|
| 2193 |
|
|---|
| 2194 | RECT rect;
|
|---|
| 2195 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
|---|
| 2196 | win32wnd->AdjustMaximizedRect(&rect);
|
|---|
| 2197 |
|
|---|
| 2198 | swp->x += rect.left;
|
|---|
| 2199 | swp->cx += rect.right-rect.left;
|
|---|
| 2200 | swp->y -= rect.bottom;
|
|---|
| 2201 | swp->cy += rect.bottom-rect.top;
|
|---|
| 2202 |
|
|---|
| 2203 | win32wnd->ShowWindow(SW_RESTORE_W);
|
|---|
| 2204 | }
|
|---|
| 2205 | else
|
|---|
| 2206 | if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
|
|---|
| 2207 | {
|
|---|
| 2208 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
|
|---|
| 2209 | }
|
|---|
| 2210 | else
|
|---|
| 2211 | if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
|
|---|
| 2212 | {
|
|---|
| 2213 | win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
|
|---|
| 2214 | }
|
|---|
| 2215 | goto RunDefWndProc;
|
|---|
| 2216 | }
|
|---|
| 2217 |
|
|---|
| 2218 | #ifdef DEBUG
|
|---|
| 2219 | case WM_UPDATEFRAME:
|
|---|
| 2220 | dprintf(("PMFRAME:WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
|
|---|
| 2221 | goto RunDefFrameWndProc;
|
|---|
| 2222 | #endif
|
|---|
| 2223 |
|
|---|
| 2224 | case WM_TRACKFRAME:
|
|---|
| 2225 | dprintf(("PMFRAME: WM_TRACKFRAME %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 2226 | if(fOS2Look) {//sent by titlebar control
|
|---|
| 2227 | Frame_SysCommandSizeMove(win32wnd, SC_MOVE_W+HTCAPTION_W);
|
|---|
| 2228 | }
|
|---|
| 2229 | rc = 0;
|
|---|
| 2230 | break;
|
|---|
| 2231 |
|
|---|
| 2232 | case WM_SYSCOMMAND:
|
|---|
| 2233 | dprintf(("PMFRAME: WM_SYSCOMMAND %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 2234 | if (fOS2Look == OS2_APPEARANCE_SYSMENU && mp1 == (MPARAM)OSSC_SYSMENU)
|
|---|
| 2235 | goto RunDefFrameWndProc;
|
|---|
| 2236 |
|
|---|
| 2237 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 2238 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 2239 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 2240 | }
|
|---|
| 2241 | if(win32wnd)
|
|---|
| 2242 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 2243 | break;
|
|---|
| 2244 |
|
|---|
| 2245 | case WM_IMEREQUEST:
|
|---|
| 2246 | case WM_IMECONTROL:
|
|---|
| 2247 | case WM_IMENOTIFY:
|
|---|
| 2248 | if( pWinMsg->message )
|
|---|
| 2249 | {
|
|---|
| 2250 | dprintf(("Frame window received IME message"));
|
|---|
| 2251 | win32wnd->DispatchMsgA( pWinMsg );
|
|---|
| 2252 |
|
|---|
| 2253 | if(( pWinMsg->message = WM_IME_NOTIFY_W ) &&
|
|---|
| 2254 | ( pWinMsg->wParam == IMN_SETOPENSTATUS_W ))
|
|---|
| 2255 | {
|
|---|
| 2256 | MSG m;
|
|---|
| 2257 |
|
|---|
| 2258 | m.message = WM_IME_NOTIFY_W;
|
|---|
| 2259 | m.wParam = IMN_SETCONVERSIONMODE_W;
|
|---|
| 2260 | m.lParam = 0;
|
|---|
| 2261 |
|
|---|
| 2262 | win32wnd->DispatchMsgA( &m );
|
|---|
| 2263 | }
|
|---|
| 2264 | }
|
|---|
| 2265 | else
|
|---|
| 2266 | goto RunDefWndProc;
|
|---|
| 2267 | break;
|
|---|
| 2268 |
|
|---|
| 2269 | #ifdef DEBUG
|
|---|
| 2270 | case WM_DDE_INITIATE:
|
|---|
| 2271 | case WM_DDE_INITIATEACK:
|
|---|
| 2272 | case WM_DDE_REQUEST:
|
|---|
| 2273 | case WM_DDE_ACK:
|
|---|
| 2274 | case WM_DDE_DATA:
|
|---|
| 2275 | case WM_DDE_ADVISE:
|
|---|
| 2276 | case WM_DDE_UNADVISE:
|
|---|
| 2277 | case WM_DDE_POKE:
|
|---|
| 2278 | case WM_DDE_EXECUTE:
|
|---|
| 2279 | case WM_DDE_TERMINATE:
|
|---|
| 2280 | dprintf(("PMFRAME: WM_DDE %x %x", msg, win32wnd->getWindowHandle()));
|
|---|
| 2281 | break;
|
|---|
| 2282 | #endif
|
|---|
| 2283 |
|
|---|
| 2284 | default:
|
|---|
| 2285 | goto RunDefFrameWndProc;
|
|---|
| 2286 | }
|
|---|
| 2287 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 2288 | RestoreOS2TIB();
|
|---|
| 2289 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 2290 |
|
|---|
| 2291 | #ifdef DEBUG
|
|---|
| 2292 | dbg_ThreadPopCall();
|
|---|
| 2293 | #endif
|
|---|
| 2294 | return (MRESULT)rc;
|
|---|
| 2295 |
|
|---|
| 2296 | RunDefFrameWndProc:
|
|---|
| 2297 | dprintf2(("RunDefFrameWndProc"));
|
|---|
| 2298 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 2299 | RestoreOS2TIB();
|
|---|
| 2300 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 2301 |
|
|---|
| 2302 | #ifdef DEBUG
|
|---|
| 2303 | dbg_ThreadPopCall();
|
|---|
| 2304 | #endif
|
|---|
| 2305 | return pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
|---|
| 2306 |
|
|---|
| 2307 | RunDefWndProc:
|
|---|
| 2308 | dprintf2(("RunDefWndProc"));
|
|---|
| 2309 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 2310 | RestoreOS2TIB();
|
|---|
| 2311 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 2312 |
|
|---|
| 2313 | //calling WinDefWindowProc here breaks Opera hotlist window (WM_ADJUSTWINDOWPOS)
|
|---|
| 2314 | // return pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
|---|
| 2315 |
|
|---|
| 2316 | #ifdef DEBUG
|
|---|
| 2317 | dbg_ThreadPopCall();
|
|---|
| 2318 | #endif
|
|---|
| 2319 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 2320 | }
|
|---|
| 2321 | //******************************************************************************
|
|---|
| 2322 | //******************************************************************************
|
|---|
| 2323 | MRESULT EXPENTRY Win32FakeWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 2324 | {
|
|---|
| 2325 | PFNWP pfnOldWindowProc;
|
|---|
| 2326 | Win32BaseWindow *win32wnd, *win32wndchild;
|
|---|
| 2327 | TEB *teb;
|
|---|
| 2328 | MRESULT rc = 0;
|
|---|
| 2329 | EXCEPTIONREGISTRATIONRECORD exceptRegRec = {0,0};
|
|---|
| 2330 |
|
|---|
| 2331 | //Restore our FS selector
|
|---|
| 2332 | SetWin32TIB();
|
|---|
| 2333 |
|
|---|
| 2334 | win32wnd = Win32FakeWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 2335 | if(win32wnd == NULL) {
|
|---|
| 2336 | DebugInt3();
|
|---|
| 2337 | goto RunDefWndProc;
|
|---|
| 2338 | }
|
|---|
| 2339 |
|
|---|
| 2340 | pfnOldWindowProc = (PFNWP)win32wnd->getOldPMWindowProc();
|
|---|
| 2341 | if(pfnOldWindowProc == NULL) {
|
|---|
| 2342 | DebugInt3();
|
|---|
| 2343 | goto RunDefWndProc;
|
|---|
| 2344 | }
|
|---|
| 2345 |
|
|---|
| 2346 | RestoreOS2TIB();
|
|---|
| 2347 | rc = pfnOldWindowProc(hwnd, msg, mp1, mp2);
|
|---|
| 2348 |
|
|---|
| 2349 | ODIN_SetExceptionHandler(&exceptRegRec);
|
|---|
| 2350 | SetWin32TIB();
|
|---|
| 2351 | switch(msg) {
|
|---|
| 2352 | case WM_WINDOWPOSCHANGED:
|
|---|
| 2353 | {
|
|---|
| 2354 | PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
|
|---|
| 2355 | SWP swpOld = *(pswp + 1);
|
|---|
| 2356 | WINDOWPOS wp;
|
|---|
| 2357 |
|
|---|
| 2358 | if(win32wnd->getParent()) {
|
|---|
| 2359 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
|---|
| 2360 | hwnd);
|
|---|
| 2361 | }
|
|---|
| 2362 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
|---|
| 2363 |
|
|---|
| 2364 | win32wnd->SetWindowPos(wp.hwndInsertAfter, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
|
|---|
| 2365 | break;
|
|---|
| 2366 | }
|
|---|
| 2367 |
|
|---|
| 2368 | }
|
|---|
| 2369 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 2370 | RestoreOS2TIB();
|
|---|
| 2371 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 2372 | return rc;
|
|---|
| 2373 |
|
|---|
| 2374 | RunDefWndProc:
|
|---|
| 2375 | RestoreOS2TIB();
|
|---|
| 2376 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 2377 | }
|
|---|
| 2378 | //******************************************************************************
|
|---|
| 2379 | // PMWinSubclassFakeWindow
|
|---|
| 2380 | //
|
|---|
| 2381 | // Subclass a fake window (converted PM window)
|
|---|
| 2382 | //
|
|---|
| 2383 | // Parameters
|
|---|
| 2384 | //
|
|---|
| 2385 | // HWND hwndOS2 - PM handle of fake window
|
|---|
| 2386 | //
|
|---|
| 2387 | // Returns
|
|---|
| 2388 | // NULL - Failure
|
|---|
| 2389 | // else - Old PM window procedure
|
|---|
| 2390 | //
|
|---|
| 2391 | //******************************************************************************
|
|---|
| 2392 | PVOID PMWinSubclassFakeWindow(HWND hwndOS2)
|
|---|
| 2393 | {
|
|---|
| 2394 | return WinSubclassWindow(hwndOS2, Win32FakeWindowProc);
|
|---|
| 2395 | }
|
|---|
| 2396 | //******************************************************************************
|
|---|
| 2397 | //******************************************************************************
|
|---|
| 2398 | void FrameSetFocus(HWND hwnd)
|
|---|
| 2399 | {
|
|---|
| 2400 | HWND hwndFocusSave = WinQueryWindowULong(hwnd, QWL_HWNDFOCUSSAVE);
|
|---|
| 2401 | if(!WinIsWindow(hab, hwndFocusSave)) {
|
|---|
| 2402 | hwndFocusSave = WinWindowFromID(hwnd, FID_CLIENT);
|
|---|
| 2403 | WinSetWindowULong(hwnd, QWL_HWNDFOCUSSAVE, hwndFocusSave);
|
|---|
| 2404 | }
|
|---|
| 2405 | dprintf(("FrameSetFocus: hwndFocusSave %x %x", OS2ToWin32Handle(hwndFocusSave), hwndFocusSave));
|
|---|
| 2406 | dprintf(("FrameSetFocus: cur focus=%x (%x) cur active=%x (%x)\n",
|
|---|
| 2407 | WinQueryFocus(HWND_DESKTOP), OS2ToWin32Handle(WinQueryFocus(HWND_DESKTOP)),
|
|---|
| 2408 | WinQueryActiveWindow(HWND_DESKTOP), OS2ToWin32Handle(WinQueryActiveWindow(HWND_DESKTOP))));
|
|---|
| 2409 | WinSetFocus(HWND_DESKTOP, hwndFocusSave);
|
|---|
| 2410 |
|
|---|
| 2411 | ULONG ulFrameFlags = WinQueryWindowUShort(hwnd, QWS_FLAGS);
|
|---|
| 2412 | ulFrameFlags &= ~FF_NOACTIVATESWP;
|
|---|
| 2413 | WinSetWindowUShort(hwnd, QWS_FLAGS, ulFrameFlags);
|
|---|
| 2414 | }
|
|---|
| 2415 | //******************************************************************************
|
|---|
| 2416 | //******************************************************************************
|
|---|
| 2417 | void FrameReplaceMenuItem(HWND hwndMenu, ULONG nIndex, ULONG idOld, ULONG idNew,
|
|---|
| 2418 | HBITMAP hbmNew)
|
|---|
| 2419 | {
|
|---|
| 2420 | MENUITEM mi;
|
|---|
| 2421 |
|
|---|
| 2422 | if (!hwndMenu)
|
|---|
| 2423 | return;
|
|---|
| 2424 |
|
|---|
| 2425 | WinEnableWindowUpdate(hwndMenu, FALSE);
|
|---|
| 2426 |
|
|---|
| 2427 | if (WinSendMsg(hwndMenu, MM_QUERYITEM, MPFROM2SHORT(idOld, TRUE), MPFROMP(&mi)))
|
|---|
| 2428 | {
|
|---|
| 2429 | WinSendMsg(hwndMenu, MM_REMOVEITEM, (MPARAM)idOld, 0);
|
|---|
| 2430 | mi.afStyle = MIS_BITMAP | MIS_SYSCOMMAND;
|
|---|
| 2431 | mi.afAttribute = 0;
|
|---|
| 2432 | mi.hwndSubMenu = 0;
|
|---|
| 2433 | mi.id = idNew;
|
|---|
| 2434 | mi.hItem = (ULONG)hbmNew;
|
|---|
| 2435 | WinSendMsg(hwndMenu, MM_INSERTITEM, (MPARAM)&mi, 0);
|
|---|
| 2436 | }
|
|---|
| 2437 | else
|
|---|
| 2438 | dprintf(("WARNING: FrameReplaceMenuItem control %x not found",idOld));
|
|---|
| 2439 |
|
|---|
| 2440 | WinEnableWindowUpdate(hwndMenu, TRUE);
|
|---|
| 2441 |
|
|---|
| 2442 | WinInvalidateRect(hwndMenu, NULL, TRUE);
|
|---|
| 2443 | }
|
|---|
| 2444 | //******************************************************************************
|
|---|
| 2445 | //******************************************************************************
|
|---|
| 2446 | void RecalcVisibleRegion(Win32BaseWindow *win32wnd)
|
|---|
| 2447 | {
|
|---|
| 2448 | //Workaround for PM/GPI bug when moving/sizing a window with open DCs
|
|---|
| 2449 | //
|
|---|
| 2450 | //Windows applictions often get a DC and keep it open for the duration
|
|---|
| 2451 | //of the application. When the DC's window is moved (full window dragging on)
|
|---|
| 2452 | //PM/GPI doesn't seem to update the DC properly/in time.
|
|---|
| 2453 | //This can result is visible distortions on the screen.
|
|---|
| 2454 |
|
|---|
| 2455 | //We need to reset our DC (transformation & y-inversion) (#945)
|
|---|
| 2456 | //Debugging showed that querying the visible region of a DC will cure
|
|---|
| 2457 | //this problem (GPI probably recalculates the visible region). (#334)
|
|---|
| 2458 |
|
|---|
| 2459 | int nrdcs = 0;
|
|---|
| 2460 | HDC hdcWindow[MAX_OPENDCS];
|
|---|
| 2461 |
|
|---|
| 2462 | if(win32wnd->queryOpenDCs(hdcWindow, MAX_OPENDCS, &nrdcs))
|
|---|
| 2463 | {
|
|---|
| 2464 | for(int i=0;i<nrdcs;i++)
|
|---|
| 2465 | {
|
|---|
| 2466 | dprintf(("Recalc visible region of DC %x for window %x", hdcWindow[i], win32wnd->getWindowHandle()));
|
|---|
| 2467 |
|
|---|
| 2468 | pDCData pHps = (pDCData)GpiQueryDCData (hdcWindow[i]);
|
|---|
| 2469 |
|
|---|
| 2470 | if(pHps) setPageXForm (win32wnd, pHps);
|
|---|
| 2471 | else DebugInt3();
|
|---|
| 2472 | }
|
|---|
| 2473 | }
|
|---|
| 2474 | //Workaround END
|
|---|
| 2475 | }
|
|---|
| 2476 | //******************************************************************************
|
|---|
| 2477 | //******************************************************************************
|
|---|
| 2478 | static char *PMDragExtractFiles(PDRAGINFO pDragInfo, ULONG *pcItems, ULONG *pulBytes)
|
|---|
| 2479 | {
|
|---|
| 2480 | PDRAGITEM pDragItem;
|
|---|
| 2481 | int i, cItems;
|
|---|
| 2482 | BOOL ret;
|
|---|
| 2483 | char szFileName[CCHMAXPATH];
|
|---|
| 2484 | char szContainerName[CCHMAXPATH];
|
|---|
| 2485 | ULONG ulBytes;
|
|---|
| 2486 | char *pszCurFile = NULL;
|
|---|
| 2487 |
|
|---|
| 2488 | /* Get access to the DRAGINFO data structure */
|
|---|
| 2489 | if(!DrgAccessDraginfo(pDragInfo)) {
|
|---|
| 2490 | return NULL;
|
|---|
| 2491 | }
|
|---|
| 2492 |
|
|---|
| 2493 | cItems = DrgQueryDragitemCount(pDragInfo);
|
|---|
| 2494 |
|
|---|
| 2495 | //compute memory required to hold all filenames
|
|---|
| 2496 | int bufsize = 0;
|
|---|
| 2497 | for (i = 0; i < cItems; i++) {
|
|---|
| 2498 | pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
|
|---|
| 2499 |
|
|---|
| 2500 | bufsize += DrgQueryStrNameLen(pDragItem->hstrContainerName) + DrgQueryStrNameLen(pDragItem->hstrSourceName);
|
|---|
| 2501 | bufsize++; //0 terminator
|
|---|
| 2502 | bufsize++; //+ potential missing backslash
|
|---|
| 2503 | }
|
|---|
| 2504 | bufsize++; //extra 0 terminator
|
|---|
| 2505 | char *pszFiles = (char *)malloc(bufsize);
|
|---|
| 2506 | if(pszFiles == NULL) {
|
|---|
| 2507 | dprintf(("Out of memory!!"));
|
|---|
| 2508 | DebugInt3();
|
|---|
| 2509 | goto failure;
|
|---|
| 2510 | }
|
|---|
| 2511 | memset(pszFiles, 0, bufsize);
|
|---|
| 2512 |
|
|---|
| 2513 | pszCurFile = pszFiles;
|
|---|
| 2514 |
|
|---|
| 2515 | //copy all filenames
|
|---|
| 2516 | for (i = 0; i < cItems; i++) {
|
|---|
| 2517 | char *pszTemp = pszCurFile;
|
|---|
| 2518 |
|
|---|
| 2519 | pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
|
|---|
| 2520 |
|
|---|
| 2521 | ulBytes = DrgQueryStrNameLen(pDragItem->hstrContainerName);
|
|---|
| 2522 | ulBytes = DrgQueryStrName(pDragItem->hstrContainerName,
|
|---|
| 2523 | ulBytes, pszCurFile);
|
|---|
| 2524 | if(pszCurFile[ulBytes-1] != '\\') {
|
|---|
| 2525 | pszCurFile[ulBytes] = '\\';
|
|---|
| 2526 | pszCurFile++;
|
|---|
| 2527 | }
|
|---|
| 2528 | pszCurFile += ulBytes;
|
|---|
| 2529 |
|
|---|
| 2530 | ulBytes = DrgQueryStrNameLen(pDragItem->hstrSourceName);
|
|---|
| 2531 | ulBytes = DrgQueryStrName(pDragItem->hstrSourceName,
|
|---|
| 2532 | ulBytes+1, pszCurFile);
|
|---|
| 2533 | pszCurFile += ulBytes + 1; //+ terminator
|
|---|
| 2534 |
|
|---|
| 2535 | dprintf(("dropped file %s", pszTemp));
|
|---|
| 2536 | }
|
|---|
| 2537 |
|
|---|
| 2538 | /* Release the draginfo data structure */
|
|---|
| 2539 | DrgFreeDraginfo(pDragInfo);
|
|---|
| 2540 |
|
|---|
| 2541 | *pulBytes = bufsize;
|
|---|
| 2542 | *pcItems = cItems;
|
|---|
| 2543 |
|
|---|
| 2544 | return pszFiles;
|
|---|
| 2545 |
|
|---|
| 2546 | failure:
|
|---|
| 2547 | /* Release the draginfo data structure */
|
|---|
| 2548 | DrgFreeDraginfo(pDragInfo);
|
|---|
| 2549 | if(pszFiles) {
|
|---|
| 2550 | free(pszFiles);
|
|---|
| 2551 | }
|
|---|
| 2552 | return NULL;
|
|---|
| 2553 | }
|
|---|
| 2554 | //******************************************************************************
|
|---|
| 2555 | //******************************************************************************
|
|---|
| 2556 | static BOOL PMDragValidate(PDRAGINFO pDragInfo)
|
|---|
| 2557 | {
|
|---|
| 2558 | PDRAGITEM pDragItem;
|
|---|
| 2559 | ULONG ulBytes;
|
|---|
| 2560 | int i, cItems;
|
|---|
| 2561 | BOOL ret;
|
|---|
| 2562 | char szFileName[CCHMAXPATH];
|
|---|
| 2563 | char szContainerName[CCHMAXPATH];
|
|---|
| 2564 | USHORT usOp = DO_MOVE;
|
|---|
| 2565 |
|
|---|
| 2566 | /* Get access to the DRAGINFO data structure */
|
|---|
| 2567 | if(!DrgAccessDraginfo(pDragInfo)) {
|
|---|
| 2568 | return FALSE;
|
|---|
| 2569 | }
|
|---|
| 2570 |
|
|---|
| 2571 | /* Can we accept this drop? */
|
|---|
| 2572 | switch (pDragInfo->usOperation) {
|
|---|
| 2573 | /* Return DOR_NODROPOP if current operation */
|
|---|
| 2574 | /* is link or unknown */
|
|---|
| 2575 | case DO_LINK:
|
|---|
| 2576 | case DO_COPY:
|
|---|
| 2577 | case DO_UNKNOWN:
|
|---|
| 2578 | goto failure;
|
|---|
| 2579 |
|
|---|
| 2580 | /* Our default operation is Move */
|
|---|
| 2581 | case DO_MOVE:
|
|---|
| 2582 | case DO_DEFAULT:
|
|---|
| 2583 | pDragItem = DrgQueryDragitemPtr(pDragInfo, 0);
|
|---|
| 2584 | ulBytes = DrgQueryStrName(pDragItem->hstrContainerName,
|
|---|
| 2585 | sizeof(szContainerName),
|
|---|
| 2586 | szContainerName);
|
|---|
| 2587 | ulBytes = DrgQueryStrName(pDragItem->hstrSourceName,
|
|---|
| 2588 | sizeof(szFileName),
|
|---|
| 2589 | szFileName);
|
|---|
| 2590 | if (!ulBytes) {
|
|---|
| 2591 | goto failure;
|
|---|
| 2592 | }
|
|---|
| 2593 |
|
|---|
| 2594 | dprintf(("dropped file %s%s", szContainerName, szFileName));
|
|---|
| 2595 | break;
|
|---|
| 2596 | }
|
|---|
| 2597 |
|
|---|
| 2598 | cItems = DrgQueryDragitemCount(pDragInfo);
|
|---|
| 2599 |
|
|---|
| 2600 | /* Now, we need to look at each item in turn */
|
|---|
| 2601 | for (i = 0; i < cItems; i++) {
|
|---|
| 2602 | pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
|
|---|
| 2603 |
|
|---|
| 2604 | /* Make sure we can move for a Move request */
|
|---|
| 2605 | if (!((pDragItem->fsSupportedOps & DO_MOVEABLE) &&
|
|---|
| 2606 | (usOp == (USHORT)DO_MOVE)))
|
|---|
| 2607 | {
|
|---|
| 2608 | dprintf(("item %d not accepted", i));
|
|---|
| 2609 | goto failure;
|
|---|
| 2610 | }
|
|---|
| 2611 | }
|
|---|
| 2612 | /* Release the draginfo data structure */
|
|---|
| 2613 | DrgFreeDraginfo(pDragInfo);
|
|---|
| 2614 | return TRUE;
|
|---|
| 2615 |
|
|---|
| 2616 | failure:
|
|---|
| 2617 | DrgFreeDraginfo(pDragInfo);
|
|---|
| 2618 | return FALSE;
|
|---|
| 2619 | }
|
|---|
| 2620 |
|
|---|
| 2621 | //******************************************************************************
|
|---|
| 2622 | // Override std class names we use in Odin (necessary for keyboard hook)
|
|---|
| 2623 | //******************************************************************************
|
|---|
| 2624 | void WIN32API SetCustomStdClassName(LPSTR pszStdClassName)
|
|---|
| 2625 | {
|
|---|
| 2626 | strcpy(WIN32_STDCLASS, pszStdClassName);
|
|---|
| 2627 | }
|
|---|
| 2628 | //******************************************************************************
|
|---|
| 2629 | //******************************************************************************
|
|---|
| 2630 | char *WIN32API QueryCustomStdClassName()
|
|---|
| 2631 | {
|
|---|
| 2632 | return WIN32_STDCLASS;
|
|---|
| 2633 | }
|
|---|
| 2634 | //******************************************************************************
|
|---|
| 2635 | //******************************************************************************
|
|---|
| 2636 |
|
|---|
| 2637 | #ifdef DEBUG_LOGGING
|
|---|
| 2638 | static char *DbgGetStringSWPFlags(ULONG flags)
|
|---|
| 2639 | {
|
|---|
| 2640 | static char szSWPFlags[512];
|
|---|
| 2641 |
|
|---|
| 2642 | szSWPFlags[0] = 0;
|
|---|
| 2643 |
|
|---|
| 2644 | if(flags & SWP_SIZE) {
|
|---|
| 2645 | strcat(szSWPFlags, "SWP_SIZE ");
|
|---|
| 2646 | }
|
|---|
| 2647 | if(flags & SWP_MOVE) {
|
|---|
| 2648 | strcat(szSWPFlags, "SWP_MOVE ");
|
|---|
| 2649 | }
|
|---|
| 2650 | if(flags & SWP_ZORDER) {
|
|---|
| 2651 | strcat(szSWPFlags, "SWP_ZORDER ");
|
|---|
| 2652 | }
|
|---|
| 2653 | if(flags & SWP_SHOW) {
|
|---|
| 2654 | strcat(szSWPFlags, "SWP_SHOW ");
|
|---|
| 2655 | }
|
|---|
| 2656 | if(flags & SWP_HIDE) {
|
|---|
| 2657 | strcat(szSWPFlags, "SWP_HIDE ");
|
|---|
| 2658 | }
|
|---|
| 2659 | if(flags & SWP_NOREDRAW) {
|
|---|
| 2660 | strcat(szSWPFlags, "SWP_NOREDRAW ");
|
|---|
| 2661 | }
|
|---|
| 2662 | if(flags & SWP_NOADJUST) {
|
|---|
| 2663 | strcat(szSWPFlags, "SWP_NOADJUST ");
|
|---|
| 2664 | }
|
|---|
| 2665 | if(flags & SWP_ACTIVATE) {
|
|---|
| 2666 | strcat(szSWPFlags, "SWP_ACTIVATE ");
|
|---|
| 2667 | }
|
|---|
| 2668 | if(flags & SWP_DEACTIVATE) {
|
|---|
| 2669 | strcat(szSWPFlags, "SWP_DEACTIVATE ");
|
|---|
| 2670 | }
|
|---|
| 2671 | if(flags & SWP_EXTSTATECHANGE) {
|
|---|
| 2672 | strcat(szSWPFlags, "SWP_EXTSTATECHANGE ");
|
|---|
| 2673 | }
|
|---|
| 2674 | if(flags & SWP_MINIMIZE) {
|
|---|
| 2675 | strcat(szSWPFlags, "SWP_MINIMIZE ");
|
|---|
| 2676 | }
|
|---|
| 2677 | if(flags & SWP_MAXIMIZE) {
|
|---|
| 2678 | strcat(szSWPFlags, "SWP_MAXIMIZE ");
|
|---|
| 2679 | }
|
|---|
| 2680 | if(flags & SWP_RESTORE) {
|
|---|
| 2681 | strcat(szSWPFlags, "SWP_RESTORE ");
|
|---|
| 2682 | }
|
|---|
| 2683 | if(flags & SWP_FOCUSACTIVATE) {
|
|---|
| 2684 | strcat(szSWPFlags, "SWP_FOCUSACTIVATE ");
|
|---|
| 2685 | }
|
|---|
| 2686 | if(flags & SWP_FOCUSDEACTIVATE) {
|
|---|
| 2687 | strcat(szSWPFlags, "SWP_FOCUSDEACTIVATE ");
|
|---|
| 2688 | }
|
|---|
| 2689 | if(flags & SWP_NOAUTOCLOSE) {
|
|---|
| 2690 | strcat(szSWPFlags, "SWP_NOAUTOCLOSE ");
|
|---|
| 2691 | }
|
|---|
| 2692 | return szSWPFlags;
|
|---|
| 2693 | }
|
|---|
| 2694 | static char *DbgPrintQFCFlags(ULONG flags)
|
|---|
| 2695 | {
|
|---|
| 2696 | static char szQFCFlags[64];
|
|---|
| 2697 |
|
|---|
| 2698 | szQFCFlags[0] = 0;
|
|---|
| 2699 |
|
|---|
| 2700 | if(flags & QFC_NEXTINCHAIN) {
|
|---|
| 2701 | strcat(szQFCFlags, "QFC_NEXTINCHAIN");
|
|---|
| 2702 | }
|
|---|
| 2703 | else
|
|---|
| 2704 | if(flags & QFC_ACTIVE) {
|
|---|
| 2705 | strcat(szQFCFlags, "QFC_ACTIVE");
|
|---|
| 2706 | }
|
|---|
| 2707 | else
|
|---|
| 2708 | if(flags & QFC_FRAME) {
|
|---|
| 2709 | strcat(szQFCFlags, "QFC_FRAME");
|
|---|
| 2710 | }
|
|---|
| 2711 | else
|
|---|
| 2712 | if(flags & QFC_SELECTACTIVE) {
|
|---|
| 2713 | strcat(szQFCFlags, "QFC_SELECTACTIVE");
|
|---|
| 2714 | }
|
|---|
| 2715 | else
|
|---|
| 2716 | if(flags & QFC_PARTOFCHAIN) {
|
|---|
| 2717 | strcat(szQFCFlags, "QFC_PARTOFCHAIN");
|
|---|
| 2718 | }
|
|---|
| 2719 |
|
|---|
| 2720 | return szQFCFlags;
|
|---|
| 2721 | }
|
|---|
| 2722 | #endif
|
|---|
| 2723 |
|
|---|