Ignore:
Timestamp:
Aug 25, 1999, 5:08:51 PM (26 years ago)
Author:
dengert
Message:

new window size/move code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/pmwindow.cpp

    r650 r693  
    1 /* $Id: pmwindow.cpp,v 1.20 1999-08-23 15:34:46 dengert Exp $ */
     1/* $Id: pmwindow.cpp,v 1.21 1999-08-25 15:08:50 dengert Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    1313#define INCL_GPI
    1414
    15 #include <os2.h>                        /* PM header file               */
     15#include <os2.h>                        /* PM header file               */
    1616#include <os2wrap.h>
    1717#include <stdlib.h>
    1818#include "win32type.h"
     19#include <winconst.h>
    1920#include <wprocess.h>
    2021#include <misc.h>
     
    2728#include "oslibmsg.h"
    2829
    29 HMQ  hmq = 0;                             /* Message queue handle         */
     30HMQ  hmq = 0;                             /* Message queue handle         */
    3031HAB  hab = 0;
    3132
    3233RECTL desktopRectl = {0};
     34ULONG ScreenWidth  = 0;
     35ULONG ScreenHeight = 0;
    3336
    3437MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     
    4548  if(!hab || !hmq)
    4649  {
    47         UINT error;
    48         //CB: only fail on real error
    49         error = WinGetLastError(hab) & 0xFFFF; //error code
    50         if (!hab || error != PMERR_MSG_QUEUE_ALREADY_EXISTS)
    51         {
    52             dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
    53             dprintf((" Error = %x",error));
    54             return(FALSE);
    55         }
     50        UINT error;
     51        //CB: only fail on real error
     52        error = WinGetLastError(hab) & 0xFFFF; //error code
     53        if (!hab || error != PMERR_MSG_QUEUE_ALREADY_EXISTS)
     54        {
     55            dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
     56            dprintf((" Error = %x",error));
     57            return(FALSE);
     58        }
    5659    else
    57         {
    58         if(!hab) {
    59                 hab = WinQueryAnchorBlock(HWND_DESKTOP);
    60             dprintf(("WinQueryAnchorBlock returned %x", hab));
    61         }
    62         if(!hmq) {
    63             hmq = HMQ_CURRENT;
    64         }
    65         }
     60        {
     61        if(!hab) {
     62                hab = WinQueryAnchorBlock(HWND_DESKTOP);
     63            dprintf(("WinQueryAnchorBlock returned %x", hab));
     64        }
     65        if(!hmq) {
     66            hmq = HMQ_CURRENT;
     67        }
     68        }
    6669  }
    6770  SetThreadHAB(hab);
     
    6972  SetThreadMessageQueue(hmq);
    7073
    71   if(!WinRegisterClass(                 /* Register window class        */
    72      hab,                               /* Anchor block handle          */
    73      (PSZ)WIN32_STDCLASS,               /* Window class name            */
    74      (PFNWP)Win32WindowProc,            /* Address of window procedure  */
     74  if(!WinRegisterClass(                 /* Register window class        */
     75     hab,                               /* Anchor block handle          */
     76     (PSZ)WIN32_STDCLASS,               /* Window class name            */
     77     (PFNWP)Win32WindowProc,            /* Address of window procedure  */
    7578     CS_SIZEREDRAW | CS_HITTEST,
    7679     8)) {
    77         dprintf(("WinRegisterClass Win32Window failed"));
    78         return(FALSE);
     80        dprintf(("WinRegisterClass Win32Window failed"));
     81        return(FALSE);
    7982   }
    8083
    8184   WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
    82    dprintf(("InitPM: Desktop (%d,%d)", desktopRectl.xRight, desktopRectl.yTop));
     85   ScreenWidth  = desktopRectl.xRight;
     86   ScreenHeight = desktopRectl.yTop;
     87
     88   dprintf(("InitPM: Desktop (%d,%d)", ScreenWidth, ScreenHeight));
    8389   return OSLibInitMsgQueue();
    8490} /* End of main */
     
    8995{
    9096 POSTMSG_PACKET *postmsg;
    91  OSLIBPOINT      point, ClientPoint;
    92  Win32Window    *win32wnd;
    93  APIRET         rc;
     97 OSLIBPOINT      point, ClientPoint;
     98 Win32Window    *win32wnd;
     99 APIRET         rc;
    94100
    95101  //Restore our FS selector
     
    99105
    100106  if(msg != WM_CREATE && win32wnd == NULL) {
    101         dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
    102         goto RunDefWndProc;
     107        dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
     108        goto RunDefWndProc;
    103109  }
    104110  switch( msg )
     
    106112    //internal messages
    107113    case WM_WIN32_POSTMESSAGEA:
    108         postmsg = (POSTMSG_PACKET *)mp1;
    109         if(postmsg == NULL) {
    110             dprintf(("WM_WIN32_POSTMESSAGEA, postmsg NULL!!"));
    111             break;
    112         }
    113         win32wnd->SendMessageA(postmsg->Msg, postmsg->wParam, postmsg->lParam);
    114         free(postmsg);
    115         break;
     114        postmsg = (POSTMSG_PACKET *)mp1;
     115        if(postmsg == NULL) {
     116            dprintf(("WM_WIN32_POSTMESSAGEA, postmsg NULL!!"));
     117            break;
     118        }
     119        win32wnd->SendMessageA(postmsg->Msg, postmsg->wParam, postmsg->lParam);
     120        free(postmsg);
     121        break;
    116122
    117123    case WM_WIN32_POSTMESSAGEW:
    118         postmsg = (POSTMSG_PACKET *)mp1;
    119         if(postmsg == NULL) {
    120             dprintf(("WM_WIN32_POSTMESSAGEW, postmsg NULL!!"));
    121             break;
    122         }
    123         win32wnd->SendMessageW(postmsg->Msg, postmsg->wParam, postmsg->lParam);
    124         free(postmsg);
    125         break;
     124        postmsg = (POSTMSG_PACKET *)mp1;
     125        if(postmsg == NULL) {
     126            dprintf(("WM_WIN32_POSTMESSAGEW, postmsg NULL!!"));
     127            break;
     128        }
     129        win32wnd->SendMessageW(postmsg->Msg, postmsg->wParam, postmsg->lParam);
     130        free(postmsg);
     131        break;
    126132
    127133    //OS/2 msgs
    128134    case WM_CREATE:
    129         //Processing is done in after WinCreateWindow returns
    130         dprintf(("OS2: WM_CREATE %x", hwnd));
    131         RestoreOS2TIB();
    132         return (MRESULT)FALSE;
     135        //Processing is done in after WinCreateWindow returns
     136        dprintf(("OS2: WM_CREATE %x", hwnd));
     137        RestoreOS2TIB();
     138        return (MRESULT)FALSE;
    133139
    134140    case WM_QUIT:
    135         dprintf(("OS2: WM_QUIT %x", hwnd));
    136         if(win32wnd->MsgQuit()) {
    137                 goto RunDefWndProc;
    138         }
    139         break;
     141        dprintf(("OS2: WM_QUIT %x", hwnd));
     142        if(win32wnd->MsgQuit()) {
     143                goto RunDefWndProc;
     144        }
     145        break;
    140146
    141147    case WM_CLOSE:
    142         dprintf(("OS2: WM_CLOSE %x", hwnd));
    143         if(win32wnd->MsgClose()) {
    144                 goto RunDefWndProc;
    145         }
    146         break;
     148        dprintf(("OS2: WM_CLOSE %x", hwnd));
     149        if(win32wnd->MsgClose()) {
     150                goto RunDefWndProc;
     151        }
     152        break;
    147153
    148154    case WM_DESTROY:
    149         dprintf(("OS2: WM_DESTROY %x", hwnd));
    150         if(win32wnd->MsgDestroy()) {
    151                 goto RunDefWndProc;
    152         }
    153         break;
     155        dprintf(("OS2: WM_DESTROY %x", hwnd));
     156        if(win32wnd->MsgDestroy()) {
     157                goto RunDefWndProc;
     158        }
     159        break;
    154160
    155161    case WM_ENABLE:
    156         dprintf(("OS2: WM_ENABLE %x", hwnd));
    157         if(win32wnd->MsgEnable((ULONG)mp1)) {
    158                 goto RunDefWndProc;
    159         }
    160         break;
     162        dprintf(("OS2: WM_ENABLE %x", hwnd));
     163        if(win32wnd->MsgEnable((ULONG)mp1)) {
     164                goto RunDefWndProc;
     165        }
     166        break;
    161167
    162168    case WM_SHOW:
    163         dprintf(("OS2: WM_SHOW %x", hwnd));
    164         if(win32wnd->MsgShow((ULONG)mp1)) {
    165                 goto RunDefWndProc;
    166         }
    167         break;
     169        dprintf(("OS2: WM_SHOW %x", hwnd));
     170        if(win32wnd->MsgShow((ULONG)mp1)) {
     171                goto RunDefWndProc;
     172        }
     173        break;
    168174
    169175    case WM_ADJUSTWINDOWPOS:
    170176    {
    171       ULONG    x, y;
    172177      PSWP     pswp = (PSWP)mp1;
    173 
    174         dprintf(("OS2: WM_ADJUSTWINDOWPOS %x", hwnd));
    175 
    176         if(pswp->fl & SWP_MOVE) {
    177             if(win32wnd->isChild()) {
    178                 x = pswp->x;
    179                 y = pswp->cy - y - 1;
    180             }
    181             else {
    182                 OSLIBPOINT point;
    183 
    184                 point.x = pswp->x;
    185                 point.y = pswp->y;
    186 
    187                 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    188                 x = point.x;
    189                 y = point.y;
    190             }
    191             if(win32wnd->MsgMove(x, y)) {
    192                 goto RunDefWndProc;
    193             }
    194             break;
    195         }
    196         goto RunDefWndProc;
     178      SWP      swpOld;
     179      WINDOWPOS wp;
     180      ULONG    parentHeight = 0;
     181
     182        dprintf(("OS2: WM_ADJUSTWINDOWPOS %x %x (%d,%d) (%d,%d)", hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     183
     184        WinQueryWindowPos(hwnd, &swpOld);
     185
     186        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
     187            parentHeight = (win32wnd->isChild()) ?
     188                OSLibGetWindowHeight(win32wnd->getParent()->getOS2WindowHandle())
     189              : OSLibQueryScreenHeight();
     190        }
     191        OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, parentHeight);
     192        wp.hwnd = win32wnd->getWindowHandle();
     193        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     194        {
     195           Win32Window *wndAfter = Win32Window::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     196           wp.hwndInsertAfter = wndAfter->getWindowHandle();
     197        }
     198        win32wnd->MsgPosChanging((LPARAM)&wp);
     199        break;
    197200    }
    198201
    199202    case WM_WINDOWPOSCHANGED:
    200203    {
    201      PSWP pswp = (PSWP)mp1;
    202 
    203         dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    204         goto RunDefWndProc;
     204      PSWP      pswp = (PSWP)mp1;
     205      WINDOWPOS wp;
     206      ULONG     parentHeight = 0;
     207
     208        dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     209        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
     210            parentHeight = (win32wnd->isChild()) ?
     211                OSLibGetWindowHeight(win32wnd->getParent()->getOS2WindowHandle())
     212              : OSLibQueryScreenHeight();
     213        }
     214        OSLibMapSWPtoWINDOWPOS(pswp, &wp, pswp+1, parentHeight);
     215        wp.hwnd = win32wnd->getWindowHandle();
     216        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     217        {
     218           Win32Window *wndAfter = Win32Window::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     219           wp.hwndInsertAfter = wndAfter->getWindowHandle();
     220        }
     221        win32wnd->MsgPosChanged((LPARAM)&wp);
     222        break;
    205223    }
    206224
    207225    case WM_ERASEBACKGROUND:
    208226    {
    209         return (MRESULT) FALSE;
     227        return (MRESULT) FALSE;
    210228    }
    211229    case WM_SIZE:
     
    213231     SWP swp;
    214232
    215         rc = WinQueryWindowPos(hwnd, &swp);
    216         if(rc == FALSE) {
    217                 dprintf(("WM_SIZE: WinQueryWindowPos failed!"));
    218                 break;
    219         }
    220         dprintf(("OS2: WM_SIZE %x %x (%d,%d) (%d,%d) (%d,%d)", hwnd, swp.fl, swp.x, swp.y, swp.cx, swp.cy, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)));
    221         if(win32wnd->MsgSize(SHORT1FROMMP(mp2), SHORT2FROMMP(mp2),
    222                                 (swp.fl & SWP_MINIMIZE) != 0,
    223                                 (swp.fl & SWP_MAXIMIZE) != 0))
    224         {
    225                 goto RunDefWndProc;
    226         }
    227         break;
     233        rc = WinQueryWindowPos(hwnd, &swp);
     234        if(rc == FALSE) {
     235                dprintf(("WM_SIZE: WinQueryWindowPos failed!"));
     236                break;
     237        }
     238        dprintf(("OS2: WM_SIZE %x %x (%d,%d) (%d,%d) (%d,%d)", hwnd, swp.fl, swp.x, swp.y, swp.cx, swp.cy, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)));
     239#if 0
     240        if(win32wnd->MsgSize(SHORT1FROMMP(mp2), SHORT2FROMMP(mp2),
     241                                (swp.fl & SWP_MINIMIZE) != 0,
     242                                (swp.fl & SWP_MAXIMIZE) != 0))
     243        {
     244                goto RunDefWndProc;
     245        }
     246#endif
     247        break;
    228248    }
    229249
     
    232252      HWND hwndActivate = (HWND)mp1;
    233253
    234         dprintf(("OS2: WM_ACTIVATE %x", hwnd));
    235         if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
    236                 //another (non-win32) application's window
    237                 //set to NULL (allowed according to win32 SDK) to avoid problems
    238                 hwndActivate = NULL;
    239         }
    240         if(win32wnd->MsgActivate(1, hwndActivate)) {
    241                 goto RunDefWndProc;
    242         }
    243         break;
     254        dprintf(("OS2: WM_ACTIVATE %x", hwnd));
     255        if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
     256                //another (non-win32) application's window
     257                //set to NULL (allowed according to win32 SDK) to avoid problems
     258                hwndActivate = NULL;
     259        }
     260        if(win32wnd->MsgActivate(1, hwndActivate)) {
     261                goto RunDefWndProc;
     262        }
     263        break;
    244264    }
    245265    case WM_FOCUSCHANGE:
    246         dprintf(("OS2: WM_FOCUSCHANGE %x", hwnd));
    247         goto RunDefWndProc;
     266        dprintf(("OS2: WM_FOCUSCHANGE %x", hwnd));
     267        goto RunDefWndProc;
    248268
    249269    case WM_SETFOCUS:
     
    251271      HWND hwndFocus = (HWND)mp1;
    252272
    253         dprintf(("OS2: WM_SETFOCUS %x %d", hwnd, mp2));
    254         if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
    255                 //another (non-win32) application's window
    256                 //set to NULL (allowed according to win32 SDK) to avoid problems
    257                 hwndFocus = NULL;
    258         }
    259         if((ULONG)mp2 == TRUE) {
    260                 rc = win32wnd->MsgSetFocus(hwndFocus);
    261         }
    262         else    rc = win32wnd->MsgKillFocus(hwndFocus);
    263         if(rc) {
    264                 goto RunDefWndProc;
    265         }
    266         break;
     273        dprintf(("OS2: WM_SETFOCUS %x %d", hwnd, mp2));
     274        if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
     275                //another (non-win32) application's window
     276                //set to NULL (allowed according to win32 SDK) to avoid problems
     277                hwndFocus = NULL;
     278        }
     279        if((ULONG)mp2 == TRUE) {
     280                rc = win32wnd->MsgSetFocus(hwndFocus);
     281        }
     282        else    rc = win32wnd->MsgKillFocus(hwndFocus);
     283        if(rc) {
     284                goto RunDefWndProc;
     285        }
     286        break;
    267287    }
    268288    //**************************************************************************
     
    270290    //**************************************************************************
    271291    case WM_BUTTON1DOWN:
    272         dprintf(("OS2: WM_BUTTON1DOWN %x", hwnd));
    273         point.x = (*(POINTS *)&mp1).x;
    274         point.y = (*(POINTS *)&mp1).y;
    275         ClientPoint.x = point.x;
    276         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    277         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    278         if(win32wnd->MsgButton(BUTTON_LEFTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    279                 goto RunDefWndProc;
    280         }
    281         break;
     292        dprintf(("OS2: WM_BUTTON1DOWN %x", hwnd));
     293        point.x = (*(POINTS *)&mp1).x;
     294        point.y = (*(POINTS *)&mp1).y;
     295        ClientPoint.x = point.x;
     296        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     297        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     298        if(win32wnd->MsgButton(BUTTON_LEFTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     299                goto RunDefWndProc;
     300        }
     301        break;
    282302
    283303    case WM_BUTTON1UP:
    284         dprintf(("OS2: WM_BUTTON1UP %x", hwnd));
    285         point.x = (*(POINTS *)&mp1).x;
    286         point.y = (*(POINTS *)&mp1).y;
    287         ClientPoint.x = point.x;
    288         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    289         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    290         if(win32wnd->MsgButton(BUTTON_LEFTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    291                 goto RunDefWndProc;
    292         }
    293         break;
     304        dprintf(("OS2: WM_BUTTON1UP %x", hwnd));
     305        point.x = (*(POINTS *)&mp1).x;
     306        point.y = (*(POINTS *)&mp1).y;
     307        ClientPoint.x = point.x;
     308        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     309        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     310        if(win32wnd->MsgButton(BUTTON_LEFTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     311                goto RunDefWndProc;
     312        }
     313        break;
    294314    case WM_BUTTON1DBLCLK:
    295         point.x = (*(POINTS *)&mp1).x;
    296         point.y = (*(POINTS *)&mp1).y;
    297         ClientPoint.x = point.x;
    298         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    299         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    300         if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    301                 goto RunDefWndProc;
    302         }
    303         break;
     315        point.x = (*(POINTS *)&mp1).x;
     316        point.y = (*(POINTS *)&mp1).y;
     317        ClientPoint.x = point.x;
     318        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     319        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     320        if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     321                goto RunDefWndProc;
     322        }
     323        break;
    304324    case WM_BUTTON2DOWN:
    305         point.x = (*(POINTS *)&mp1).x;
    306         point.y = (*(POINTS *)&mp1).y;
    307         ClientPoint.x = point.x;
    308         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    309         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    310         if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    311                 goto RunDefWndProc;
    312         }
    313         break;
     325        point.x = (*(POINTS *)&mp1).x;
     326        point.y = (*(POINTS *)&mp1).y;
     327        ClientPoint.x = point.x;
     328        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     329        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     330        if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     331                goto RunDefWndProc;
     332        }
     333        break;
    314334    case WM_BUTTON2UP:
    315         point.x = (*(POINTS *)&mp1).x;
    316         point.y = (*(POINTS *)&mp1).y;
    317         ClientPoint.x = point.x;
    318         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    319         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    320         if(win32wnd->MsgButton(BUTTON_RIGHTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    321                 goto RunDefWndProc;
    322         }
    323         break;
     335        point.x = (*(POINTS *)&mp1).x;
     336        point.y = (*(POINTS *)&mp1).y;
     337        ClientPoint.x = point.x;
     338        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     339        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     340        if(win32wnd->MsgButton(BUTTON_RIGHTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     341                goto RunDefWndProc;
     342        }
     343        break;
    324344    case WM_BUTTON2DBLCLK:
    325         point.x = (*(POINTS *)&mp1).x;
    326         point.y = (*(POINTS *)&mp1).y;
    327         ClientPoint.x = point.x;
    328         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    329         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    330         if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    331                 goto RunDefWndProc;
    332         }
    333         break;
     345        point.x = (*(POINTS *)&mp1).x;
     346        point.y = (*(POINTS *)&mp1).y;
     347        ClientPoint.x = point.x;
     348        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     349        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     350        if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     351                goto RunDefWndProc;
     352        }
     353        break;
    334354    case WM_BUTTON3DOWN:
    335         point.x = (*(POINTS *)&mp1).x;
    336         point.y = (*(POINTS *)&mp1).y;
    337         ClientPoint.x = point.x;
    338         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    339         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    340         if(win32wnd->MsgButton(BUTTON_MIDDLEDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    341                 goto RunDefWndProc;
    342         }
    343         break;
     355        point.x = (*(POINTS *)&mp1).x;
     356        point.y = (*(POINTS *)&mp1).y;
     357        ClientPoint.x = point.x;
     358        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     359        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     360        if(win32wnd->MsgButton(BUTTON_MIDDLEDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     361                goto RunDefWndProc;
     362        }
     363        break;
    344364    case WM_BUTTON3UP:
    345         point.x = (*(POINTS *)&mp1).x;
    346         point.y = (*(POINTS *)&mp1).y;
    347         ClientPoint.x = point.x;
    348         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    349         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    350         if(win32wnd->MsgButton(BUTTON_MIDDLEUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    351                 goto RunDefWndProc;
    352         }
    353         break;
     365        point.x = (*(POINTS *)&mp1).x;
     366        point.y = (*(POINTS *)&mp1).y;
     367        ClientPoint.x = point.x;
     368        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     369        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     370        if(win32wnd->MsgButton(BUTTON_MIDDLEUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     371                goto RunDefWndProc;
     372        }
     373        break;
    354374    case WM_BUTTON3DBLCLK:
    355         point.x = (*(POINTS *)&mp1).x;
    356         point.y = (*(POINTS *)&mp1).y;
    357         ClientPoint.x = point.x;
    358         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    359         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    360         if(win32wnd->MsgButton(BUTTON_MIDDLEDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    361                 goto RunDefWndProc;
    362         }
    363         break;
     375        point.x = (*(POINTS *)&mp1).x;
     376        point.y = (*(POINTS *)&mp1).y;
     377        ClientPoint.x = point.x;
     378        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     379        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     380        if(win32wnd->MsgButton(BUTTON_MIDDLEDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     381                goto RunDefWndProc;
     382        }
     383        break;
    364384
    365385    case WM_BUTTON2MOTIONSTART:
     
    372392    case WM_BUTTON3MOTIONEND:
    373393    case WM_BUTTON3CLICK:
    374         goto RunDefWndProc;
     394        goto RunDefWndProc;
    375395
    376396    case WM_MOUSEMOVE:
    377397    {
    378         ULONG keystate = 0;
    379         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1))
    380             keystate |= WMMOVE_LBUTTON;
    381         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2))
    382             keystate |= WMMOVE_MBUTTON;
    383         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3))
    384             keystate |= WMMOVE_RBUTTON;
    385         if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT))
    386             keystate |= WMMOVE_SHIFT;
    387         if(WinGetKeyState(HWND_DESKTOP, VK_CTRL))
    388             keystate |= WMMOVE_CTRL;
    389 
    390         //OS/2 Window coordinates -> Win32 Window coordinates
    391         //TODO: What do windows apps that handle this messages return?
    392         if(!win32wnd->MsgMouseMove(keystate, SHORT1FROMMP(mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(mp1)))) {
    393                 goto RunDefWndProc;
    394         }
    395         break;
     398        ULONG keystate = 0;
     399        if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1))
     400            keystate |= WMMOVE_LBUTTON;
     401        if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2))
     402            keystate |= WMMOVE_MBUTTON;
     403        if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3))
     404            keystate |= WMMOVE_RBUTTON;
     405        if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT))
     406            keystate |= WMMOVE_SHIFT;
     407        if(WinGetKeyState(HWND_DESKTOP, VK_CTRL))
     408            keystate |= WMMOVE_CTRL;
     409
     410        //OS/2 Window coordinates -> Win32 Window coordinates
     411        //TODO: What do windows apps that handle this messages return?
     412        if(!win32wnd->MsgMouseMove(keystate, SHORT1FROMMP(mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(mp1)))) {
     413                goto RunDefWndProc;
     414        }
     415        break;
    396416    }
    397417
     
    405425
    406426    case WM_COMMAND:
    407         if(SHORT1FROMMP(mp2) == CMDSRC_MENU) {
    408             win32wnd->MsgCommand(CMD_MENU, SHORT1FROMMP(mp1), 0);
    409         }
    410         if(SHORT1FROMMP(mp2) == CMDSRC_ACCELERATOR) {
    411             win32wnd->MsgCommand(CMD_ACCELERATOR, SHORT1FROMMP(mp1), 0);
    412         }
    413         //todo controls + accelerators
    414         break;
     427        if(SHORT1FROMMP(mp2) == CMDSRC_MENU) {
     428            win32wnd->MsgCommand(CMD_MENU, SHORT1FROMMP(mp1), 0);
     429        }
     430        if(SHORT1FROMMP(mp2) == CMDSRC_ACCELERATOR) {
     431            win32wnd->MsgCommand(CMD_ACCELERATOR, SHORT1FROMMP(mp1), 0);
     432        }
     433        //todo controls + accelerators
     434        break;
    415435
    416436    case WM_SYSCOMMAND:
     
    419439      ULONG win32sc;
    420440
    421         if(SHORT2FROMMP(mp2) == TRUE) {//syscommand caused by mouse action
    422             POINTL pointl;
    423             WinQueryPointerPos(HWND_DESKTOP, &pointl);
    424             x = pointl.x;
    425             y = desktopRectl.yTop - y;
    426         }
    427         switch(SHORT1FROMMP(mp1)) {
    428         case SC_MOVE:
    429             win32sc = WIN32SC_MOVE;
    430             break;
    431         case SC_CLOSE:
    432             win32sc = WIN32SC_CLOSE;
    433             break;
    434         case SC_MAXIMIZE:
    435             win32sc = WIN32SC_MAXIMIZE;
    436             break;
    437         case SC_MINIMIZE:
    438             win32sc = WIN32SC_MINIMIZE;
    439             break;
    440         case SC_NEXTFRAME:
    441         case SC_NEXTWINDOW:
    442             win32sc = WIN32SC_NEXTWINDOW;
    443             break;
    444         case SC_RESTORE:
    445             win32sc = WIN32SC_RESTORE;
    446             break;
    447         case SC_TASKMANAGER:
    448             win32sc = WIN32SC_TASKLIST;
    449             break;
    450         default:
    451             goto RunDefWndProc;
    452         }
    453         dprintf(("WM_SYSCOMMAND %x %x (%d,%d)", hwnd, win32sc, x, y));
    454         if(win32wnd->MsgSysCommand(win32sc, x, y)) {
    455             goto RunDefWndProc;
    456         }
    457         break;
     441        if(SHORT2FROMMP(mp2) == TRUE) {//syscommand caused by mouse action
     442            POINTL pointl;
     443            WinQueryPointerPos(HWND_DESKTOP, &pointl);
     444            x = pointl.x;
     445            y = ScreenHeight - y;
     446        }
     447        switch(SHORT1FROMMP(mp1)) {
     448        case SC_MOVE:
     449            win32sc = WIN32SC_MOVE;
     450            break;
     451        case SC_CLOSE:
     452            win32sc = WIN32SC_CLOSE;
     453            break;
     454        case SC_MAXIMIZE:
     455            win32sc = WIN32SC_MAXIMIZE;
     456            break;
     457        case SC_MINIMIZE:
     458            win32sc = WIN32SC_MINIMIZE;
     459            break;
     460        case SC_NEXTFRAME:
     461        case SC_NEXTWINDOW:
     462            win32sc = WIN32SC_NEXTWINDOW;
     463            break;
     464        case SC_RESTORE:
     465            win32sc = WIN32SC_RESTORE;
     466            break;
     467        case SC_TASKMANAGER:
     468            win32sc = WIN32SC_TASKLIST;
     469            break;
     470        default:
     471            goto RunDefWndProc;
     472        }
     473        dprintf(("WM_SYSCOMMAND %x %x (%d,%d)", hwnd, win32sc, x, y));
     474        if(win32wnd->MsgSysCommand(win32sc, x, y)) {
     475            goto RunDefWndProc;
     476        }
     477        break;
    458478    }
    459479    case WM_CHAR:
     
    462482     ULONG fl = SHORT1FROMMP(mp1);
    463483
    464         if(!(fl & KC_CHAR)) {
    465             dprintf(("WM_CHAR: no valid character code"));
    466             goto RunDefWndProc;
    467         }
    468         if(fl & KC_VIRTUALKEY) {
    469             vkey = SHORT2FROMMP(mp2);
    470         }
    471         if(fl & KC_KEYUP) {
    472             keyflags |= KEY_UP;
    473         }
    474         if(fl & KC_ALT) {
    475             keyflags |= KEY_ALTDOWN;
    476         }
    477         if(fl & KC_PREVDOWN) {
    478             keyflags |= KEY_PREVDOWN;
    479         }
    480         if(fl & KC_DEADKEY) {
    481             keyflags |= KEY_DEADKEY;
    482         }
    483         if(win32wnd->MsgChar(SHORT1FROMMP(mp2), CHAR3FROMMP(mp1), CHAR4FROMMP(mp1), vkey, keyflags)) {
    484             goto RunDefWndProc;
    485         }
    486         break;
     484        if(!(fl & KC_CHAR)) {
     485            dprintf(("WM_CHAR: no valid character code"));
     486            goto RunDefWndProc;
     487        }
     488        if(fl & KC_VIRTUALKEY) {
     489            vkey = SHORT2FROMMP(mp2);
     490        }
     491        if(fl & KC_KEYUP) {
     492            keyflags |= KEY_UP;
     493        }
     494        if(fl & KC_ALT) {
     495            keyflags |= KEY_ALTDOWN;
     496        }
     497        if(fl & KC_PREVDOWN) {
     498            keyflags |= KEY_PREVDOWN;
     499        }
     500        if(fl & KC_DEADKEY) {
     501            keyflags |= KEY_DEADKEY;
     502        }
     503        if(win32wnd->MsgChar(SHORT1FROMMP(mp2), CHAR3FROMMP(mp1), CHAR4FROMMP(mp1), vkey, keyflags)) {
     504            goto RunDefWndProc;
     505        }
     506        break;
    487507    }
    488508    case WM_INITMENU:
     
    492512
    493513    case WM_TIMER:
    494         goto RunDefWndProc;
     514        goto RunDefWndProc;
    495515
    496516    case WM_SETWINDOWPARAMS:
     
    498518      WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
    499519
    500         dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
    501         if(wndParams->fsStatus & WPM_TEXT) {
    502             if(win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText)) {
    503                     goto RunDefWndProc;
    504             }
    505         }
    506         goto RunDefWndProc;
     520        dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
     521        if(wndParams->fsStatus & WPM_TEXT) {
     522            if(win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText)) {
     523                    goto RunDefWndProc;
     524            }
     525        }
     526        goto RunDefWndProc;
    507527    }
    508528
     
    513533     PSZ   wintext;
    514534
    515         if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT)) {
    516             if(wndpars->fsStatus & WPM_CCHTEXT)
    517                 wndpars->cchText = win32wnd->MsgGetTextLength();
    518             if(wndpars->fsStatus & WPM_TEXT)
    519                 wndpars->pszText = win32wnd->MsgGetText();
    520             return (MRESULT)TRUE;
    521         }
    522         goto RunDefWndProc;
     535        if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT)) {
     536            if(wndpars->fsStatus & WPM_CCHTEXT)
     537                wndpars->cchText = win32wnd->MsgGetTextLength();
     538            if(wndpars->fsStatus & WPM_TEXT)
     539                wndpars->pszText = win32wnd->MsgGetText();
     540            return (MRESULT)TRUE;
     541        }
     542        goto RunDefWndProc;
    523543    }
    524544
    525545    case WM_PAINT:
    526         dprintf(("OS2: WM_PAINT %x", hwnd));
    527         if(win32wnd->MsgPaint(0, 0)) {
    528                 goto RunDefWndProc;
    529         }
    530         break;
     546        dprintf(("OS2: WM_PAINT %x", hwnd));
     547        if(win32wnd->MsgPaint(0, 0)) {
     548                goto RunDefWndProc;
     549        }
     550        break;
    531551
    532552    case WM_HITTEST:
    533         if(win32wnd->MsgHitTest((*(POINTS *)&mp1).x, MapOS2ToWin32Y(OSLIB_HWND_DESKTOP, hwnd, (*(POINTS *)&mp1).y))) {
    534                 goto RunDefWndProc;
    535         }
    536         break;
     553        if(win32wnd->MsgHitTest((*(POINTS *)&mp1).x, MapOS2ToWin32Y(OSLIB_HWND_DESKTOP, hwnd, (*(POINTS *)&mp1).y))) {
     554                goto RunDefWndProc;
     555        }
     556        break;
    537557
    538558    case WM_SYSCOLORCHANGE:
     
    558578    case WM_SEMANTICEVENT:
    559579    default:
    560 //        dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
    561         RestoreOS2TIB();
    562         return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     580//        dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
     581        RestoreOS2TIB();
     582        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    563583  }
    564584  RestoreOS2TIB();
Note: See TracChangeset for help on using the changeset viewer.