Changeset 10316 for trunk/src


Ignore:
Timestamp:
Nov 12, 2003, 3:13:26 PM (22 years ago)
Author:
sandervl
Message:

Visible & Clip region changes

Location:
trunk/src
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/gdi32.DEF

    r8871 r10316  
    1 ; $Id: gdi32.DEF,v 1.22 2002-07-15 10:02:28 sandervl Exp $
     1; $Id: gdi32.DEF,v 1.23 2003-11-12 14:10:55 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    1616
    1717EXPORTS
    18     _GDI_CallDevInstall16@20                                 @100
    19     _GDI_CallExtDeviceModePropSheet16@16                     @101
    20     _GDI_CallExtDeviceMode16@28                              @102
    21     _GDI_CallAdvancedSetupDialog16@16                        @103
    22     _GDI_CallDeviceCapabilities16@20                         @104
     18    _GDI_CallDevInstall16@20                                 @100 NONAME
     19    _GDI_CallExtDeviceModePropSheet16@16                     @101 NONAME
     20    _GDI_CallExtDeviceMode16@28                              @102 NONAME
     21    _GDI_CallAdvancedSetupDialog16@16                        @103 NONAME
     22    _GDI_CallDeviceCapabilities16@20                         @104 NONAME
    2323
    2424    AbortDoc                   = _AbortDoc@4                 @105
     
    207207    GetPolyFillMode            = _GetPolyFillMode@4          @288
    208208    GetROP2                    = _GetROP2@4                  @289
    209 ;    GetRandomRgn               = _GetRandomRgn@??            @290
     209    GetRandomRgn               = _GetRandomRgn@12            @290
    210210    GetRasterizerCaps          = _GetRasterizerCaps@8        @291
    211211    GetRegionData              = _GetRegionData@12           @292
     
    352352;    pfnRealizePalette          = _pfnRealizePalette@??       @433
    353353;    pfnSelectPalette           = _pfnSelectPalette@??        @434
    354 
     354    GetGlyphIndicesA           = _GetGlyphIndicesA@20         @435
     355    GetGlyphIndicesW           = _GetGlyphIndicesW@20         @436
     356
     357;
     358; ENDOFEXPORTS
     359; Internal function marker
     360;
    355361
    356362;
     
    374380    OSLibGpiSetCp__FUlT1                                        @1213 NONAME
    375381    _ConvertRGB555to565@12                                      @1214 NONAME
     382
     383    _FillRect@12                                                @1215 NONAME
     384    _FrameRect@12                                               @1216 NONAME
     385    _InvertRect@8                                               @1217 NONAME
     386
     387    _GdiCombineVisRgn@12                                        @1218 NONAME
     388    _GdiSetVisRgn@8                                             @1219 NONAME
     389    _GdiCombineVisRgnClipRgn@12                                 @1220 NONAME
     390
  • trunk/src/gdi32/gdi32.cpp

    r9554 r10316  
    1 /* $Id: gdi32.cpp,v 1.87 2002-12-28 10:16:20 sandervl Exp $ */
     1/* $Id: gdi32.cpp,v 1.88 2003-11-12 14:12:01 sandervl Exp $ */
    22
    33/*
     
    3535//******************************************************************************
    3636//******************************************************************************
     37int WIN32API FillRect(HDC hDC, const RECT * lprc, HBRUSH hbr)
     38{
     39    int ret;
     40
     41    //SvL: brush 0 means current selected brush (verified in NT4)
     42    if(hbr == 0) {
     43        hbr = GetCurrentObject(hDC, OBJ_BRUSH);
     44    }
     45    else
     46    if (hbr <= (HBRUSH) (COLOR_MAX + 1)) {
     47        hbr = GetSysColorBrush( (INT) hbr - 1 );
     48    }
     49    dprintf(("USER32:  FillRect %x (%d,%d)(%d,%d) brush %X", hDC, lprc->left, lprc->top, lprc->right, lprc->bottom, hbr));
     50    ret = O32_FillRect(hDC,lprc,hbr);
     51    return ret;
     52}
     53//******************************************************************************
     54//******************************************************************************
     55int WIN32API FrameRect( HDC hDC, const RECT * lprc, HBRUSH  hbr)
     56{
     57    int ret;
     58
     59    dprintf(("USER32: FrameRect %x (%d,%d)(%d,%d) brush %x", hDC, lprc->top, lprc->left, lprc->bottom, lprc->right, hbr));
     60    ret = O32_FrameRect(hDC,lprc,hbr);
     61    return ret;
     62}
     63//******************************************************************************
     64//******************************************************************************
     65BOOL WIN32API InvertRect( HDC hDC, const RECT * lprc)
     66{
     67    int ret;
     68
     69    if(lprc) {
     70         dprintf(("USER32: InvertRect %x (%d,%d)(%d,%d)", hDC, lprc->left, lprc->top, lprc->right, lprc->bottom));
     71    }
     72    else dprintf(("USER32: InvertRect %x NULL", hDC));
     73    ret = O32_InvertRect(hDC,lprc);
     74    return ret;
     75}
    3776//******************************************************************************
    3877//******************************************************************************
  • trunk/src/gdi32/gdi32dbg.def

    r9429 r10316  
    1 ; $Id: gdi32dbg.def,v 1.1 2002-11-26 10:53:09 sandervl Exp $
     1; $Id: gdi32dbg.def,v 1.2 2003-11-12 14:10:55 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    1616
    1717EXPORTS
    18     _GDI_CallDevInstall16@20                                 @100
    19     _GDI_CallExtDeviceModePropSheet16@16                     @101
    20     _GDI_CallExtDeviceMode16@28                              @102
    21     _GDI_CallAdvancedSetupDialog16@16                        @103
    22     _GDI_CallDeviceCapabilities16@20                         @104
     18    _GDI_CallDevInstall16@20                                 @100 NONAME
     19    _GDI_CallExtDeviceModePropSheet16@16                     @101 NONAME
     20    _GDI_CallExtDeviceMode16@28                              @102 NONAME
     21    _GDI_CallAdvancedSetupDialog16@16                        @103 NONAME
     22    _GDI_CallDeviceCapabilities16@20                         @104 NONAME
    2323
    2424    AbortDoc                   = _DbgAbortDoc@4                 @105
     
    207207    GetPolyFillMode            = _DbgGetPolyFillMode@4          @288
    208208    GetROP2                    = _DbgGetROP2@4                  @289
    209 ;    GetRandomRgn               = _DbgGetRandomRgn@??            @290
     209    GetRandomRgn               = _DbgGetRandomRgn@12            @290
    210210    GetRasterizerCaps          = _DbgGetRasterizerCaps@8        @291
    211211    GetRegionData              = _DbgGetRegionData@12           @292
     
    352352;    pfnRealizePalette          = _DbgpfnRealizePalette@??       @433
    353353;    pfnSelectPalette           = _DbgpfnSelectPalette@??        @434
     354    GetGlyphIndicesA           = _GetGlyphIndicesA@20            @435
     355    GetGlyphIndicesW           = _GetGlyphIndicesW@20            @436
     356
     357;
     358; ENDOFEXPORTS
     359; Internal function marker
     360;
    354361
    355362
     
    374381    OSLibGpiSetCp__FUlT1                                        @1213 NONAME
    375382    _ConvertRGB555to565@12                                      @1214 NONAME
     383
     384    _DbgFillRect@12                                             @1215 NONAME
     385    _DbgFrameRect@12                                            @1216 NONAME
     386    _DbgInvertRect@8                                            @1217 NONAME
     387
     388    _GdiCombineVisRgn@12                                        @1218 NONAME
     389    _GdiSetVisRgn@8                                             @1219 NONAME
     390    _GdiCombineVisRgnClipRgn@12                                 @1220 NONAME
  • trunk/src/gdi32/region.cpp

    r10140 r10316  
    1 /* $Id: region.cpp,v 1.32 2003-06-03 13:48:13 sandervl Exp $ */
     1/* $Id: region.cpp,v 1.33 2003-11-12 14:10:55 sandervl Exp $ */
    22
    33/*
     
    66 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
    77 * Copyright 1998 Patrick Haller
     8 * Copyright 2002-2003 Innotek Systemberatung GmbH (sandervl@innotek.de)
    89 *
    910 * TODO: Metafile recording
    1011 * TODO: Do we need to translate & set the last error for Gpi operations?
     12 *
     13 *
     14 * NOTE: In windows there is a clip and a visible region (just like in PM)
     15 *       We do not map the Win32 visible region to the PM visible region
     16 *       as that's rather annoying.
     17 *       Instead we use the intersection of the win32 visible and win32 clip
     18 *       region for the PM clip region.
     19 *       The original Win32 clip region is saved in pHps->hrgnWin32Clip.
     20 *       The Win32 visible region is saved in pHps->hrgnWinVis.
     21 *
     22 *
    1123 *
    1224 * Project Odin Software License can be found in LICENSE.TXT
     
    3143#include <stats.h>
    3244#include "dibsect.h"
     45#include <wingdi32.h>
    3346
    3447#define DBG_LOCALLOG    DBG_region
    3548#include "dbglocal.h"
     49
     50//GPI and Windows use the same values
     51#define GPI_TO_WIN_COMPLEXITY(a)        a
    3652
    3753typedef enum
     
    4258
    4359#define MEM_HPS_MAX 768
     60
     61int WIN32API OffsetRgn( HRGN  hrgn, int  xOffset, int  yOffset);
    4462
    4563static void convertDeviceRect(HWND hwnd, pDCData pHps, PRECTL pRectl, ULONG count);
     
    107125        LONG y = 0;
    108126
    109         if(pHps == 0 || pHps->isClient) //client area
     127        if(pHps && pHps->isClient) //client area
    110128        {
    111129            if(GetClientRect(OS2ToWin32Handle(hwnd), &rect) == TRUE) {
     
    132150   if(pHps->isPrinter)
    133151   {
    134       return pHps->printPageHeight;
     152      return GetDeviceCaps(pHps->hps, VERTRES_W);
    135153   }
    136154   else
     
    152170        LONG x = 0;
    153171
    154         if(pHps == 0 || pHps->isClient) //client area
     172        if(pHps && pHps->isClient) //client area
    155173        {
    156174            if(GetClientRect(OS2ToWin32Handle(hwnd), &rect) == TRUE) {
     
    164182        return x;
    165183   }
     184   else
     185   if(pHps->bitmapHandle)
     186   {
     187      return pHps->bitmapWidth;
     188   }
     189   else
     190   if(pHps->isMetaPS)
     191   {
     192      return 0;
     193   }
     194   else
     195   if(pHps->isPrinter)
     196   {
     197      return GetDeviceCaps(pHps->hps, HORZRES_W);
     198   }
    166199//   else
    167200//     DebugInt3();
     
    211244    if(pHps)
    212245    {
    213          wHeight += pHps->HPStoHDCInversionHeight;
     246        wHeight += pHps->HPStoHDCInversionHeight;
    214247    }
    215248
     
    388421}
    389422//******************************************************************************
    390 //******************************************************************************
    391 int WIN32API SelectClipRgn(HDC hdc, HRGN hrgn)
    392 {
    393  LONG lComplexity = RGN_NULL;
    394  HRGN hrgnNewClip;
    395  HRGN hrgnOldClip;
     423// GdiSetVisRgn
     424//
     425// Change the Win32 visible region to the specified region
     426//
     427// Parameters:
     428//
     429// pDCData pHps         - presentation space structure
     430// HRGN hrgn            - region handle (GPI)
     431//
     432//
     433// Returns:     - ERROR_W         -> failure
     434//              - NULLREGION_W    -> empty region
     435//              - SIMPLEREGION_W  -> rectangular region
     436//              - COMPLEXREGION_W -> complex region
     437//
     438// NOTE: In windows there is a clip and a visible region (just like in PM)
     439//       We do not map the Win32 visible region to the PM visible region
     440//       as that's rather annoying.
     441//       Instead we use the intersection of the win32 visible and win32 clip
     442//       region for the PM clip region.
     443//       The Win32 clip region is saved in pHps->hrgnWin32Clip.
     444//       The Win32 visible region is saved in pHps->hrgnWinVis.
     445//
     446//******************************************************************************
     447INT WIN32API GdiSetVisRgn(pDCData pHps, HRGN hrgn)
     448{
     449    HRGN hrgnNewClip = NULLHANDLE, hrgnOldClip = NULLHANDLE;
     450    LONG lComplexity = RGN_NULL;
     451    RECTL rectl = {0, 0, 1, 1};
     452
     453    if(pHps == NULL) {
     454        DebugInt3();
     455        return ERROR_W;
     456    }
     457
     458    if(hrgn != NULLHANDLE)
     459    {
     460        hrgnNewClip = GpiCreateRegion(pHps->hps, 1, &rectl);
     461        if(hrgnNewClip == NULLHANDLE) {
     462            dprintf(("ERROR: GdiCombineVisRgn: GpiCreateRegion failed!!"));
     463            DebugInt3();
     464            goto failure;
     465        }
     466        //make a copy of the new visible region
     467        lComplexity = GpiCombineRegion(pHps->hps, hrgnNewClip, hrgn, NULLHANDLE, CRGN_COPY);
     468    }
     469    else {
     470        hrgnNewClip = NULLHANDLE;
     471    }
     472
     473    //and set that as the GPI clip region
     474    lComplexity = GpiSetClipRegion(pHps->hps, hrgnNewClip, &hrgnOldClip);
     475    if (lComplexity != RGN_ERROR)
     476    {
     477        //SvL: Must check if origin changed here. Sometimes happens when
     478        //     window looses focus. (don't know why....)
     479        checkOrigin(pHps);
     480
     481        if(hrgnOldClip) GpiDestroyRegion(pHps->hps, hrgnOldClip);
     482
     483        dprintf(("New visible region %x", hrgn));
     484        pHps->hrgnWinVis = hrgn;
     485        return GPI_TO_WIN_COMPLEXITY(lComplexity);
     486    }
     487failure:
     488    if(hrgnNewClip) GpiDestroyRegion(pHps->hps, hrgnNewClip);
     489
     490    return ERROR_W;
     491}
     492//******************************************************************************
     493// GdiCombineVisRgn
     494//
     495// Combine the specified region with the visible region according to the operation
     496//
     497// Parameters:
     498//
     499// pDCData pHps         - presentation space structure
     500// HRGN hrgn            - region handle (Win32)
     501// INT operation        - combine operation (RGN_*)
     502//
     503//
     504// Returns:     - ERROR_W         -> failure
     505//              - NULLREGION_W    -> empty region
     506//              - SIMPLEREGION_W  -> rectangular region
     507//              - COMPLEXREGION_W -> complex region
     508//
     509// NOTE: In windows there is a clip and a visible region (just like in PM)
     510//       We do not map the Win32 visible region to the PM visible region
     511//       as that's rather annoying.
     512//       Instead we use the intersection of the win32 visible and win32 clip
     513//       region for the PM clip region.
     514//       The Win32 clip region is saved in pHps->hrgnWin32Clip.
     515//       The Win32 visible region is saved in pHps->hrgnWinVis.
     516//
     517//******************************************************************************
     518INT WIN32API GdiCombineVisRgn(pDCData pHps, HRGN hrgn, INT operation)
     519{
    396520#ifdef DEBUG
    397  HRGN hrgn1 = hrgn;
     521    HRGN hrgn1 = hrgn;
    398522#endif
    399 
    400     pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
    401     if(!pHps)
    402     {
    403         dprintf(("WARNING: SelectClipRgn: invalid hdc!", hdc, hrgn));
    404         SetLastError(ERROR_INVALID_HANDLE_W);
     523    LONG lComplexity = RGN_NULL;
     524
     525    if(pHps == NULL) {
     526        DebugInt3();
    405527        return ERROR_W;
    406528    }
    407529
    408     if(hrgn)
    409     {
    410         hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
    411         if(hrgn == HANDLE_OBJ_ERROR) {
    412             dprintf(("WARNING: SelectClipRgn: invalid region!", hdc, hrgn1));
    413             SetLastError(ERROR_INVALID_HANDLE_W);
    414             return ERROR_W;
    415         }
    416     }
    417 
    418     if(hrgn)
    419     {
    420         RECTL rectl = {0,0,1,1};
    421         hrgnNewClip = GpiCreateRegion(pHps->hps, 1, &rectl);
    422         if(interpretRegionAs(pHps, hrgnNewClip, hrgn, AS_DEVICE) == 0)
     530    hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
     531    if(hrgn == HANDLE_OBJ_ERROR || !pHps) {
     532        dprintf(("ERROR: GdiCombineVisRgn %x invalid handle", hrgn1));
     533        return ERROR_W;
     534    }
     535    //interpretRegionAs converts the region and saves it in pHps->hrgnHDC
     536    if(!interpretRegionAs(pHps, 0, hrgn, AS_DEVICE) )
     537    {
     538        dprintf(("ERROR: interpretRegionAs failed!!"));
     539        return ERROR_W;
     540    }
     541
     542    //If there is no visible region, then create one that covers the whole DC
     543    if(pHps->hrgnWinVis == NULLHANDLE)
     544    {
     545         RECTL rectl = {0, 0, hdcWidth(0, pHps), hdcHeight(0, pHps)};
     546         dprintf(("No visible region: create one (0,0)(%d,%d)", rectl.xRight, rectl.yTop));
     547         pHps->hrgnWinVis = GpiCreateRegion(pHps->hps, 1, &rectl);
     548         if(pHps->hrgnWinVis == NULLHANDLE) {
     549             dprintf(("ERROR: GdiCombineVisRgn: GpiCreateRegion failed!!"));
     550             DebugInt3();
     551             goto failure;
     552         }
     553    }
     554
     555    LONG lMode;
     556    switch (operation)
     557    {
     558    case  RGN_AND_W  : lMode = CRGN_AND ; break;
     559    case  RGN_DIFF_W : lMode = CRGN_DIFF; break;
     560    default:
     561        dprintf(("ERROR: GdiCombineVisRgn %d invalid parameter", operation));
     562        DebugInt3();
     563        goto failure;
     564    }
     565    lComplexity = GpiCombineRegion(pHps->hps, pHps->hrgnWinVis, pHps->hrgnWinVis, pHps->hrgnHDC, lMode);
     566    if (lComplexity != RGN_ERROR)
     567    {
     568        return GdiSetVisRgn(pHps, pHps->hrgnWinVis);
     569    }
     570    dprintf(("ERROR: GdiCombineVisRgn: GpiCombineRegion failed"));
     571    DebugInt3();
     572
     573failure:
     574    return ERROR_W;
     575}
     576//******************************************************************************
     577// GdiCombineVisRgnClipRgn
     578//
     579// Combine the specified clip region with the visible region according to the operation
     580//
     581// Parameters:
     582//
     583// pDCData pHps         - presentation space structure
     584// HRGN hrgn            - region handle (GPI)
     585// INT operation        - combine operation (RGN_*)
     586//
     587//
     588// Returns:     - ERROR_W         -> failure
     589//              - NULLREGION_W    -> empty region
     590//              - SIMPLEREGION_W  -> rectangular region
     591//              - COMPLEXREGION_W -> complex region
     592//
     593// NOTE: In windows there is a clip and a visible region (just like in PM)
     594//       We do not map the Win32 visible region to the PM visible region
     595//       as that's rather annoying.
     596//       Instead we use the intersection of the win32 visible and win32 clip
     597//       region for the PM clip region.
     598//       The Win32 clip region is saved in pHps->hrgnWin32Clip.
     599//       The Win32 visible region is saved in pHps->hrgnWinVis.
     600//
     601//******************************************************************************
     602INT WIN32API GdiCombineVisRgnClipRgn(pDCData pHps, HRGN hrgn, INT operation)
     603{
     604    HRGN hrgnClip = NULL, hrgnOldClip, hrgnNewClip;
     605    LONG lComplexity = RGN_NULL;
     606
     607    //Create a region that will be used for the new GPI clip region
     608    RECTL rectl = {0, 0, 1, 1};
     609    hrgnNewClip = GpiCreateRegion(pHps->hps, 1, &rectl);
     610    if(hrgnNewClip == NULLHANDLE) {
     611        dprintf(("ERROR: GdiCombineVisRgnClipRgn: GpiCreateRegion failed!!"));
     612        DebugInt3();
     613        return ERROR_W;
     614    }
     615
     616    if(hrgn == NULLHANDLE)
     617    {
     618        if(pHps->hrgnWin32Clip != NULL)
    423619        {
    424             lComplexity = RGN_ERROR;
    425         }
    426     }
    427     else
    428         hrgnNewClip = 0;
    429 
    430     if(lComplexity != RGN_ERROR)
    431     {
    432         if(hrgnNewClip == 0) {
    433             GpiSetClipPath(pHps->hps, 0, SCP_RESET);
    434         }
    435         lComplexity = GpiSetClipRegion(pHps->hps, hrgnNewClip, &hrgnOldClip);
    436         if (lComplexity != RGN_ERROR )
    437         {
    438             if(hrgnOldClip)
    439                 GpiDestroyRegion(pHps->hps, hrgnOldClip);
    440 
    441             //todo: metafile recording
    442             SetLastError(ERROR_SUCCESS_W);
     620            //Only reset the path if both the visible and clip regions are zero
     621            if(!pHps->hrgnWinVis) {
     622                GpiSetClipPath(pHps->hps, 0, SCP_RESET);
     623
     624                GpiDestroyRegion(pHps->hps, hrgnNewClip);
     625                hrgnNewClip = NULLHANDLE;
     626            }
     627            else
     628            {//set PM clip region to Win32 visible region
     629                lComplexity = GpiCombineRegion(pHps->hps, hrgnNewClip, pHps->hrgnWinVis, NULLHANDLE, CRGN_COPY);
     630                if(lComplexity == RGN_ERROR) {
     631                    dprintf(("ERROR: GdiCombineVisRgnClipRgn: GpiSetClipRegion failed!!"));
     632                    DebugInt3();
     633                    goto failure;
     634                }
     635            }
     636            dprintfRegion(pHps->hps, hrgnNewClip);
     637            lComplexity = GpiSetClipRegion(pHps->hps, hrgnNewClip, &hrgnOldClip);
     638            if(lComplexity == RGN_ERROR) {
     639                dprintf(("ERROR: GdiCombineVisRgnClipRgn: GpiSetClipRegion failed!!"));
     640                DebugInt3();
     641            }
    443642
    444643            //SvL: Must check if origin changed here. Sometimes happens when
    445644            //     window looses focus. (don't know why....)
    446645            checkOrigin(pHps);
    447             return lComplexity;
    448         }
    449     }
    450 
    451     dprintf(("WARNING: SelectClipRgn: RGN_ERROR!", hdc, hrgn1));
    452     if(hrgnNewClip)
    453         GpiDestroyRegion(pHps->hps, hrgnNewClip);
    454 
    455     SetLastError(ERROR_SUCCESS_W);
    456     return lComplexity;
     646            if(hrgnOldClip) GpiDestroyRegion(pHps->hps, hrgnOldClip);
     647        }
     648        //else already NULL, so nothing to do.
     649
     650        pHps->hrgnWin32Clip = hrgn;
     651        return NULLREGION_W;
     652    }
     653
     654    LONG lMode;
     655    switch (operation)
     656    {
     657    case  RGN_AND_W  : lMode = CRGN_AND ; break;  //intersect clip & visible region
     658    default:
     659        dprintf(("ERROR: GdiCombineVisRgnClipRgn %d invalid parameter", operation));
     660        DebugInt3();
     661        goto failure;
     662    }
     663    // If there's no visible region (meaning entire DC is visible), then just set
     664    // the GPI clip region to the win32 clip region
     665    if (pHps->hrgnWinVis == NULLHANDLE)
     666    {
     667         lComplexity = GpiCombineRegion(pHps->hps, hrgnNewClip, hrgn, NULLHANDLE, CRGN_COPY);
     668    }
     669    else lComplexity = GpiCombineRegion(pHps->hps, hrgnNewClip, pHps->hrgnWinVis, hrgn, lMode);
     670
     671    if (lComplexity != RGN_ERROR)
     672    {
     673        dprintfRegion(pHps->hps, hrgnNewClip);
     674        //And activate the new clip region
     675        lComplexity = GpiSetClipRegion(pHps->hps, hrgnNewClip, &hrgnOldClip);
     676        if (lComplexity == RGN_ERROR )
     677        {
     678            dprintf(("ERROR: GdiCombineVisRgnClipRgn: GpiSetClipRegion failed"));
     679            DebugInt3();
     680            goto failure;
     681        }
     682        //SvL: Must check if origin changed here. Sometimes happens when
     683        //     window looses focus. (don't know why....)
     684        checkOrigin(pHps);
     685
     686        if(hrgnOldClip) GpiDestroyRegion(pHps->hps, hrgnOldClip);
     687
     688        pHps->hrgnWin32Clip = hrgn;
     689
     690        return GPI_TO_WIN_COMPLEXITY(lComplexity);
     691    }
     692    dprintf(("ERROR: GdiCombineVisRgnClipRgn: GpiCombineRegion failed"));
     693    DebugInt3();
     694
     695failure:
     696    if(hrgnNewClip) GpiDestroyRegion(pHps->hps, hrgnNewClip);
     697
     698    return ERROR_W;
    457699}
    458700//******************************************************************************
     
    464706#endif
    465707
    466    pDCData    pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     708   pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
    467709   if (!pHps)
    468710   {
     
    473715
    474716   LONG lComplexity;
    475    HRGN hrgnCurrent = NULLHANDLE;
     717   HRGN hrgnCurrent = NULLHANDLE, hrgnOld = NULLHANDLE;
    476718
    477719   if(!hrgn && mode != RGN_COPY_W)
     
    506748            return 0;
    507749        }
     750        dprintfRegion(hdc, hrgn);
    508751   }
    509752
     
    511754   if(hrgn)
    512755   {
     756        //interpretRegionAs converts the region and saves it in pHps->hrgnHDC
    513757        if(!interpretRegionAs(pHps, 0, hrgn, AS_DEVICE) )
    514758        {
     
    518762   else
    519763   {
    520         //remove clip region
    521         GpiSetClipPath(pHps->hps, 0, SCP_RESET);
    522         GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnCurrent);
    523 
    524         if(hrgnCurrent)
    525             GpiDestroyRegion(pHps->hps, hrgnCurrent);
     764        //Intersect the Windows clip region with the current visible region
     765        lComplexity = GdiCombineVisRgnClipRgn(pHps, NULLHANDLE, RGN_AND_W);
    526766
    527767        return NULLREGION_W;
    528768   }
    529769
    530    GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnCurrent);
     770   // get current clipping region
     771   hrgnOld     = pHps->hrgnWin32Clip;
     772   hrgnCurrent = hrgnOld;
    531773
    532774   if(hrgnCurrent == NULLHANDLE)
    533    {
     775   {//if none, then create one
    534776        lMode = CRGN_COPY;
    535777        RECTL rectl = {0, 0, 1, 1};
     
    554796   {
    555797        HRGN hrgnOld;
    556         lComplexity = GpiSetClipRegion(pHps->hps, hrgnCurrent, &hrgnOld);
     798
     799        //Intersect the Windows clip region with the current visible region
     800        lComplexity = GdiCombineVisRgnClipRgn(pHps, hrgnCurrent, RGN_AND_W);
     801
    557802        SetLastError(ERROR_SUCCESS_W);
    558803
    559         //SvL: Must check if origin changed here. Sometimes happens when
    560         //     window looses focus. (don't know why....)
    561         checkOrigin(pHps);
    562 
    563         if (lComplexity != RGN_ERROR)
     804        if (lComplexity != RGN_ERROR) {
    564805            return lComplexity;
    565    }
    566    SetLastError(ERROR_SUCCESS_W);
     806        }
     807   }
     808   GpiDestroyRegion(pHps->hps, hrgnCurrent); //delete newly created region
     809
     810   SetLastError(ERROR_INVALID_PARAMETER_W); //TODO
    567811   return ERROR_W;
    568812}
    569813//******************************************************************************
     814//******************************************************************************
     815int WIN32API SelectClipRgn(HDC hdc, HRGN hrgn)
     816{
     817    return ExtSelectClipRgn(hdc, hrgn, RGN_COPY_W);
     818}
     819//******************************************************************************
     820// The GetClipBox function retrieves the dimensions of the tightest bounding
     821// rectangle that can be drawn around the current visible area on the device.
     822// The visible area is defined by the current clipping region or clip path, as well
     823// as any overlapping windows.
     824//
     825// NOTE: We simply call GpiQueryClipBox as it behaves just like GetClipBox
     826//
    570827//******************************************************************************
    571828int WIN32API GetClipBox(HDC hdc, PRECT lpRect)
     
    583840    if(pHps->isPrinter)
    584841    {
     842        //Some printers return the wrong clip box. Return the full page instead.
     843        //(TODO: which is incorrect!)
    585844        lpRect->left   = 0;
    586845        lpRect->top    = 0;
     
    608867            //Convert coordinates from PM to win32
    609868            if (pHps->yInvert > 0) {
    610              LONG temp     = pHps->yInvert - rectl.yBottom;
    611                  rectl.yBottom = pHps->yInvert - rectl.yTop;
    612              rectl.yTop    = temp;
     869                LONG temp     = pHps->yInvert - rectl.yBottom;
     870                rectl.yBottom = pHps->yInvert - rectl.yTop;
     871                rectl.yTop    = temp;
    613872            }
    614873#endif
     
    628887            }
    629888
    630             rc = (lComplexity == RGN_RECT) ? SIMPLEREGION_W : COMPLEXREGION_W;
     889            rc = GPI_TO_WIN_COMPLEXITY(lComplexity);
    631890        }
    632891    }
     
    655914    }
    656915
    657     if(GpiSetClipRegion(pHps->hps, NULL, &hrgnClip) == RGN_ERROR) {
    658         dprintf(("WARNING: GetClipRgn GpiSetClipRegion failed! (%x)", WinGetLastError(0)));
    659         SetLastError(ERROR_INVALID_PARAMETER_W); //todo right errror
    660         return 0;
    661     }
    662     if(hrgnClip) {
    663         if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, hrgnClip, pHps, NULL)) {
    664                 dprintf(("WARNING: GetClipRgn setWinDeviceRegionFromPMDeviceRegion failed!"));
    665                 GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnTemp);
    666                 SetLastError(ERROR_INVALID_PARAMETER_W); //todo right errror
    667                 return 0;
    668         }
    669         if(GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnTemp) == RGN_ERROR )
    670         {
    671             dprintf(("WARNING: GetClipRgn GpiSetClipRegion failed %x!", WinGetLastError(0)));
     916    if(pHps->hrgnWin32Clip) {
     917        dprintfRegion(hdc, pHps->hrgnWin32Clip);
     918        if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, pHps->hrgnWin32Clip, pHps, NULL)) {
     919            dprintf(("WARNING: GetClipRgn setWinDeviceRegionFromPMDeviceRegion failed!"));
     920            GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnTemp);
    672921            SetLastError(ERROR_INVALID_PARAMETER_W); //todo right errror
    673922            return 0;
    674923        }
    675924    }
    676     else lComplexity = RGN_NULL;
     925    else {
     926       //no clip region; return NULL
     927       lComplexity = RGN_NULL;
     928    }
    677929
    678930    SetLastError(ERROR_SUCCESS_W);
     
    682934}
    683935//******************************************************************************
     936// The GetRandomRgn function copies the system clipping region of a specified
     937// device context to a specific region.
     938// It returns the visible region of the specified device context in screen
     939// coordinates (if it belongs to a window).
     940//
     941// VALUE = 1: This undocumented value will return the current Clip Region contained in the DC.
     942// VALUE = 2: This undocumented value will return the current Meta Region contained in the DC.
     943// VALUE = 3: This undocumented value will return the intersection of the Clip Region and Meta Region.
     944// VALUE = 4, SYSRGN: The only value that is documented and defined for this function.
     945//                    This value returns the System Region
     946//******************************************************************************
     947INT WIN32API GetRandomRgn(HDC hdc, HRGN hrgn, INT iNum)
     948{
     949    HWND hwnd;
     950    INT  ret;
     951
     952    if(iNum != SYSRGN_W) {
     953        dprintf(("WARNING: GetRandomRgn: invalid parameter %x", iNum));
     954        SetLastError(ERROR_INVALID_PARAMETER_W);
     955        return ERROR_W;
     956    }
     957    ret = GetClipRgn(hdc, hrgn);
     958
     959    hwnd = WindowFromDC(hdc);
     960    if(hwnd) {
     961        POINT pt = {0,0};
     962        //map from client to desktop coordinates
     963        MapWindowPoints(hwnd, 0, &pt, 1);
     964
     965        OffsetRgn(hrgn, pt.x, pt.y);
     966    }
     967    return ret;
     968}
     969//******************************************************************************
    684970//******************************************************************************
    685971int WIN32API ExcludeClipRect(HDC  hdc, int  left, int  top, int  right, int bottom)
     
    688974    if(!pHps)
    689975    {
    690         dprintf(("WARNING: ExcludeClipRgn %x (%d,%d)(%d,%d) invalid hdc", hdc, left, top, right, bottom));
     976        dprintf(("ERROR: ExcludeClipRgn %x (%d,%d)(%d,%d) invalid hdc", hdc, left, top, right, bottom));
    691977        SetLastError(ERROR_INVALID_HANDLE_W);
    692978        return ERROR_W;
     
    712998
    713999    dprintf(("ExcludeClipRgn %x (%d,%d)(%d,%d)", hdc, left, top, right, bottom));
     1000
    7141001    lComplexity = GpiExcludeClipRectangle(pHps->hps, &rectl);
    7151002    if (lComplexity == RGN_ERROR) {
     1003        dprintf(("ERROR: ExcludeClipRgn: GpiExcludeClipRectangle failed!!"));
    7161004        SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
    7171005        return ERROR_W;
     1006    }
     1007
     1008    //Ok, success. Now update the cached win32 clip region
     1009    if(pHps->hrgnWin32Clip != NULLHANDLE)
     1010    {
     1011        HRGN hrgnClipRect = GpiCreateRegion(pHps->hps, 1, &rectl);
     1012        if(hrgnClipRect == NULLHANDLE) {
     1013            dprintf(("ERROR: ExcludeClipRgn GpiCreateRegion failed!!"));
     1014            DebugInt3();
     1015            SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
     1016            return ERROR_W;
     1017        }
     1018        //subtract rect region from clip region
     1019        lComplexity = GpiCombineRegion(pHps->hps, pHps->hrgnWin32Clip, pHps->hrgnWin32Clip, hrgnClipRect, CRGN_DIFF);
     1020        GpiDestroyRegion(pHps->hps, hrgnClipRect);
     1021
     1022        if (lComplexity == RGN_ERROR) {
     1023            dprintf(("ERROR: ExcludeClipRgn GpiCombineRegion failed!!"));
     1024            DebugInt3();
     1025            SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
     1026            return ERROR_W;
     1027        }
    7181028    }
    7191029
     
    7561066    dprintf(("IntersectClipRect %x (%d,%d)(%d,%d)", hdc, left, top, right, bottom));
    7571067    lComplexity = GpiIntersectClipRectangle(pHps->hps, &rectl);
     1068    if (lComplexity == RGN_ERROR) {
     1069        dprintf(("ERROR: IntersectClipRect: GpiIntersectClipRectangle failed!!"));
     1070        SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
     1071        return ERROR_W;
     1072    }
     1073
     1074    //Ok, success. Now update the cached win32 clip region
     1075    if(pHps->hrgnWin32Clip != NULLHANDLE)
     1076    {
     1077        HRGN hrgnClipRect = GpiCreateRegion(pHps->hps, 1, &rectl);
     1078        if(hrgnClipRect == NULLHANDLE) {
     1079            dprintf(("ERROR: IntersectClipRect GpiCreateRegion failed!!"));
     1080            DebugInt3();
     1081            SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
     1082            return ERROR_W;
     1083        }
     1084        //intersect rect region with clip region
     1085        lComplexity = GpiCombineRegion(pHps->hps, pHps->hrgnWin32Clip, pHps->hrgnWin32Clip, hrgnClipRect, CRGN_AND);
     1086        GpiDestroyRegion(pHps->hps, hrgnClipRect);
     1087
     1088        if (lComplexity == RGN_ERROR) {
     1089            dprintf(("ERROR: IntersectClipRect GpiCombineRegion failed!!"));
     1090            DebugInt3();
     1091            SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
     1092            return ERROR_W;
     1093        }
     1094    }
    7581095
    7591096    //todo metafile recording
     
    7841121#endif
    7851122
    786    lComplexity = GpiOffsetClipRegion(pHps->hps, &pointl);
     1123   if(pHps->hrgnWin32Clip == NULLHANDLE) {
     1124       lComplexity = NULLREGION_W;
     1125   }
     1126   else {
     1127       lComplexity = GpiOffsetRegion(pHps->hps, pHps->hrgnWin32Clip, &pointl);
     1128       if (lComplexity == RGN_ERROR) {
     1129           dprintf(("ERROR: OffsetClipRgn: GpiOffsetRegion failed!!"));
     1130           SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
     1131           return ERROR_W;
     1132       }
     1133
     1134       //Intersect the Windows clip region with the current visible region
     1135       lComplexity = GdiCombineVisRgnClipRgn(pHps, pHps->hrgnWin32Clip, RGN_AND_W);
     1136
     1137       lComplexity = GPI_TO_WIN_COMPLEXITY(lComplexity);
     1138   }
    7871139
    7881140   //todo metafile recording
     
    10381390    dprintf(("CreateEllipticRgn (%d,%d)(%d,%d)", left, top, right, bottom));
    10391391    hrgn = GpiCreateEllipticRegion(hpsRegion, &rectl);
     1392    if(hrgn == RGN_ERROR) {
     1393        SetLastError(ERROR_INVALID_PARAMETER_W); //todo: not right
     1394        dprintf(("WARNING: CreateEllipticRgn: GpiCreateEllipticRegion failed! %x", WinGetLastError(0)));
     1395        return 0;
     1396    }
    10401397
    10411398    if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) {
     
    10861443    polygon.aPointl  = (PPOINTL)(lppt + 1);
    10871444
     1445#ifdef DEBUG
     1446    for(int i=0;i<cPoints;i++) {
     1447        dprintf(("Point %d: (%d,%d)", i, lppt[i].x, lppt[i].y));
     1448    }
     1449#endif
    10881450    GpiMove(hpsRegion, (PPOINTL)lppt);
    10891451    hrgn = GpiCreatePolygonRegion(hpsRegion, 1, &polygon, POLYGON_BOUNDARY | flMode);
     1452    if(hrgn == RGN_ERROR) {
     1453        SetLastError(ERROR_INVALID_PARAMETER_W); //todo: not right
     1454        dprintf(("WARNING: CreatePolygonRgn: GpiCreatePolygonRegion failed! %x", WinGetLastError(0)));
     1455        return 0;
     1456    }
    10901457
    10911458    if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) {
     
    12841651        dprintf(("WARNING: GetRgnBox %x %x invalid region!", hrgn1, pRect));
    12851652        SetLastError(ERROR_INVALID_HANDLE_W);
    1286         return FALSE;
     1653        return ERROR_W;
    12871654    }
    12881655
     
    13561723    }
    13571724
     1725    DIBSECTION_MARK_INVALID(hdc);
    13581726    return TRUE;
    13591727}
     
    14481816        SelectObject(hdc, hbrushRestore);
    14491817
     1818    if(lHits != GPI_ERROR)
     1819        DIBSECTION_MARK_INVALID(hdc);
     1820
    14501821    //todo metafile recording
    14511822    return (lHits != GPI_ERROR);
     
    14581829 HBRUSH hbrushRestore = 0;
    14591830#ifdef DEBUG
    1460  HRGN   hrgn1 = hrgn;
     1831    HRGN   hrgn1 = hrgn;
    14611832#endif
    1462 
    14631833
    14641834    pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     
    14831853    dprintf(("FillRgn %x %x %x", hdc, hrgn1, hBrush));
    14841854
     1855    DIBSECTION_CHECK_IF_DIRTY(hdc);
    14851856    interpretRegionAs(pHps, NULL, hrgn, AS_WORLD);
    14861857
     
    14951866        SelectObject(hdc, hbrushRestore);
    14961867
    1497     /* PF Sync DIBSection as well */
    1498     if(DIBSection::getSection() != NULL)
    1499     {
    1500         DIBSection *dsect = DIBSection::findHDC(hdc);
    1501         if(dsect)
    1502         {
    1503             dsect->sync(hdc, 0, dsect->GetHeight());
    1504         }
    1505     }
    1506 
     1868    if(success)
     1869        DIBSECTION_MARK_INVALID(hdc);
    15071870
    15081871    return(success);
     
    15121875BOOL WIN32API PaintRgn( HDC  hdc, HRGN  hrgn)
    15131876{
    1514    pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
    1515    if(!pHps)
    1516    {
    1517       SetLastError(ERROR_INVALID_HANDLE_W);
    1518       return FALSE;
    1519    }
    1520 
    1521    return FillRgn(hdc, hrgn, (HBRUSH) pHps->lastBrushKey);
     1877   return FillRgn(hdc, hrgn, (HBRUSH) GetCurrentObject(hdc, OBJ_BRUSH_W));
    15221878}
    15231879//******************************************************************************
  • trunk/src/user32/USER32.DEF

    r10256 r10316  
    1 ; $Id: USER32.DEF,v 1.81 2003-10-02 10:35:59 sandervl Exp $
     1; $Id: USER32.DEF,v 1.82 2003-11-12 14:10:18 sandervl Exp $
    22
    33LIBRARY USER32 INITINSTANCE TERMINSTANCE
     
    642642    SetWinEventHook            = _SetWinEventHook@28         @608
    643643
     644    GetAncestor                = _GetAncestor@8              @609
     645    GetWindowModuleFileNameA   = _GetWindowModuleFileNameA@12 @610
     646
    644647;------------
    645648; Windows 98
  • trunk/src/user32/dbgwrap.cpp

    r10190 r10316  
    698698DEBUGWRAP0(GetForegroundWindow)
    699699DEBUGWRAP4(GetLastActivePopup)
     700DEBUGWRAP12(GetWindowModuleFileNameA)
    700701DEBUGWRAP8(GetNextQueueWindow)
    701702DEBUGWRAP4(GetParent)
    702703DEBUGWRAP4(GetTopWindow)
    703704DEBUGWRAP8(GetWindow)
     705DEBUGWRAP8(GetAncestor)
    704706DEBUGWRAP4(GetWindowContextHelpId)
    705707DEBUGWRAP8(GetWindowRect)
     
    754756DEBUGWRAP4(GetDC)
    755757DEBUGWRAP12(GetDCEx)
    756 DEBUGWRAP12(FillRect)
    757 DEBUGWRAP12(FrameRect)
    758758DEBUGWRAP4(GetWindowDC)
    759759DEBUGWRAP8(ReleaseDC)
     
    764764DEBUGWRAP12(InvalidateRect)
    765765DEBUGWRAP12(InvalidateRgn)
    766 DEBUGWRAP8(InvertRect)
    767766DEBUGWRAP8(ValidateRect)
    768767DEBUGWRAP8(ValidateRgn)
  • trunk/src/user32/dc.cpp

    r10093 r10316  
    1 /* $Id: dc.cpp,v 1.121 2003-05-15 13:12:52 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.122 2003-11-12 14:10:18 sandervl Exp $ */
    22
    33/*
     
    594594   HDC   hdc;
    595595   HPS   hps;
    596    HRGN  hrgnUpdate, hrgnOld, hrgnClip, hrgnCombined;
     596   HRGN  hrgnUpdate;
    597597   RECTL rectl = { 1, 1, 2, 2 };
     598   pDCData pHps = NULLHANDLE;
    598599
    599600   hwnd = wnd->getOS2WindowHandle();
     
    602603   hrgnUpdate = GpiCreateRegion (hps, 1, &rectl);
    603604   WinQueryUpdateRegion (hwnd, hrgnUpdate);
    604    hrgnClip = GpiQueryClipRegion (hps);
    605 
    606    if (hrgnClip == NULLHANDLE)
    607    {
    608       GpiSetClipRegion (hps, hrgnUpdate, &hrgnOld);
    609    }
    610    else
    611    {
    612       hrgnCombined = GpiCreateRegion (hps, 1, &rectl);
    613       GpiCombineRegion (hps, hrgnCombined, hrgnClip, hrgnUpdate, CRGN_AND);
    614       GpiSetClipRegion (hps, hrgnCombined, &hrgnOld);
    615       GpiDestroyRegion (hps, hrgnUpdate);
    616       GpiDestroyRegion (hps, hrgnClip);
    617    }
    618    if (hrgnOld != NULLHANDLE)
    619       GpiDestroyRegion (hps, hrgnOld);
    620605
    621606   hdc = HPSToHDC (hwnd, hps, NULL, NULL);
     607
     608   pHps = (pDCData)GpiQueryDCData(hps);
     609   GdiSetVisRgn(pHps, hrgnUpdate);
    622610
    623611   erased = wnd->MsgEraseBackGround (hdc);
     
    676664        return (HDC)0;
    677665    }
    678 //    bIcon = (IsIconic(hwnd) && GetClassLongA(hWnd, GCL_HICON_W));
    679666    bIcon = IsIconic(hwnd);
    680667
     
    725712        }
    726713
    727         HRGN hrgnClip = GpiCreateRegion(pHps->hps, 1, &rectl);
    728         GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnOldClip);
     714        //save old clip and visible regions (restored for CS_OWNDC windows in EndPaint)
     715        dprintf(("Old visible region %x; old clip region %x", pHps->hrgnWinVis, pHps->hrgnWin32Clip));
     716        wnd->SaveClipRegion(pHps->hrgnWin32Clip);
     717        wnd->SaveVisRegion(pHps->hrgnWinVis);
     718
     719        //clear visible and clip regions
     720        pHps->hrgnWin32Clip = NULLHANDLE;
     721        pHps->hrgnWinVis    = NULLHANDLE;
     722
     723        HRGN hrgnVis = GpiCreateRegion(pHps->hps, 1, &rectl);
     724        GdiSetVisRgn(pHps, hrgnVis);
    729725
    730726        selectClientArea(wnd, pHps);
    731727
    732         //save old clip region (restored for CS_OWNDC windows in EndPaint)
    733         wnd->SetClipRegion(hrgnOldClip);
    734728        if(bIcon) {
    735729              lComplexity = RGN_RECT;
     
    742736
    743737        //Query update region
    744         HRGN hrgnClip = GpiCreateRegion(pHps->hps, 1, &rectlClip);
    745         WinQueryUpdateRegion(hwndClient, hrgnClip);
    746         WinValidateRegion(hwndClient, hrgnClip, FALSE);
    747 
    748         dprintfRegion(pHps->hps, wnd->getWindowHandle(), hrgnClip);
     738        HRGN hrgnVis = GpiCreateRegion(pHps->hps, 1, &rectlClip);
     739        WinQueryUpdateRegion(hwndClient, hrgnVis);
     740        WinValidateRegion(hwndClient, hrgnVis, FALSE);
     741
     742        dprintfRegion(pHps->hps, wnd->getWindowHandle(), hrgnVis);
    749743
    750744#ifdef DEBUG
     
    754748#endif
    755749
     750        //save old clip and visible regions (restored for CS_OWNDC windows in EndPaint)
     751        dprintf(("Old visible region %x; old clip region %x", pHps->hrgnWinVis, pHps->hrgnWin32Clip));
     752        wnd->SaveClipRegion(pHps->hrgnWin32Clip);
     753        wnd->SaveVisRegion(pHps->hrgnWinVis);
     754
     755        //clear visible and clip regions
     756        pHps->hrgnWin32Clip = NULLHANDLE;
     757        pHps->hrgnWinVis    = NULLHANDLE;
     758
    756759        //set clip region
    757         lComplexity = GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnOldClip);
    758 
    759         if(lComplexity == RGN_NULL) {
     760        lComplexity = GdiSetVisRgn(pHps, hrgnVis);
     761
     762        if(lComplexity == NULLREGION_W) {
    760763            dprintf (("BeginPaint %x: EMPTY update rectangle (vis=%d/%d show=%d/%d", hWnd,  WinIsWindowVisible(wnd->getOS2FrameWindowHandle()), WinIsWindowVisible(wnd->getOS2WindowHandle()),  WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle())));
    761764        }
     
    769772        dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectlClip.xLeft, rectlClip.yBottom, rectlClip.xRight, rectlClip.yTop));
    770773#endif
    771         //save old clip region (restored for CS_OWNDC windows in EndPaint)
    772         wnd->SetClipRegion(hrgnOldClip);
    773774    }
    774775
     
    783784    WinShowTrackRect(wnd->getOS2WindowHandle(), FALSE);
    784785
    785     if((wnd->needsEraseBkgnd() || wnd->IsVisibleRegionChanged()) && lComplexity != RGN_NULL) {
    786         wnd->setEraseBkgnd(FALSE);
    787         wnd->SetVisibleRegionChanged(FALSE);
    788         lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) == 0);
     786    if((wnd->needsEraseBkgnd() || wnd->hasPMUpdateRegionChanged()) && lComplexity != RGN_NULL) {
     787         wnd->setEraseBkgnd(FALSE);
     788         wnd->SetPMUpdateRegionChanged(FALSE);
     789         lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) == 0);
    789790    }
    790791    else lpps->fErase = TRUE;
     
    817818{
    818819  HWND    hwnd = hWnd ? hWnd : HWND_DESKTOP;
    819   HRGN    hrgnOld;
    820820  pDCData pHps;
    821821
     
    832832    if (pHps && (pHps->hdcType == TYPE_3))
    833833    {
    834         GpiSetClipRegion(pHps->hps, wnd->GetClipRegion(), &hrgnOld);
    835         wnd->SetClipRegion(0);
    836         if(hrgnOld) {
    837             GpiDestroyRegion(pHps->hps, hrgnOld);
    838         }
     834        //restore previous visible and clip regions
     835        pHps->hrgnWin32Clip = NULLHANDLE;
     836        pHps->hrgnWinVis    = NULLHANDLE;
     837
     838        GdiSetVisRgn(pHps, wnd->GetVisRegion());
     839        GdiCombineVisRgnClipRgn(pHps, wnd->GetClipRegion(), RGN_AND_W);
     840
     841        wnd->SaveClipRegion(0);
     842        wnd->SaveVisRegion(0);
     843
    839844        pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails
    840845        ReleaseDC(hwnd, pPaint->hdc);
     
    879884            if(pHps && pHps->psType == MICRO_CACHED) {
    880885                removeClientArea(wnd, pHps);
    881                 if(pHps->hrgnVis) {
    882                     GreDestroyRegion(pHps->hps, pHps->hrgnVis);
    883                     pHps->hrgnVis = 0;
     886                if(pHps->hrgnWinVis) {
     887                    GreDestroyRegion(pHps->hps, pHps->hrgnWinVis);
     888                    pHps->hrgnWinVis = 0;
     889                }
     890                if(pHps->hrgnWin32Clip) {
     891                    GreDestroyRegion(pHps->hps, pHps->hrgnWin32Clip);
     892                    pHps->hrgnWin32Clip = 0;
    884893                }
    885894            }
     
    912921}
    913922//******************************************************************************
    914 // This implementation of GetDCEx supports
     923// This implementation of GetDCEx supports:
     924//
    915925// DCX_WINDOW
    916926// DCX_CACHE
     
    922932// DCX_PARENTCLIP
    923933//
     934// Not supported:
     935//
     936// DCX_NORESETATTRS_W
     937// DCX_INTERSECTUPDATE_W
     938// DCX_LOCKWINDOWUPDATE_W
     939// DCX_VALIDATE_W
     940// DCX_EXCLUDEUPDATE_W
     941//
    924942//TODO: WM_SETREDRAW affects drawingAllowed flag!!
    925943//******************************************************************************
     
    935953   BOOL     creatingOwnDC = FALSE;
    936954   PS_Type  psType;
     955
     956    if(flags & (DCX_NORESETATTRS_W | DCX_INTERSECTUPDATE_W | DCX_LOCKWINDOWUPDATE_W | DCX_VALIDATE_W | DCX_EXCLUDEUPDATE_W)) {
     957        dprintf(("ERROR: GetDCEx: unsupported flags %x!!", flags));
     958        DebugInt3();
     959    }
    937960
    938961    if(hwnd == 0) {
     
    10661089        success = TRUE;
    10671090        if (flags & DCX_EXCLUDERGN_W)
    1068         {
    1069 #if 0 //CB: todo
    1070          long height;
    1071 
    1072          BytesNeeded = GetRegionData (hrgn, 0, NULL);
    1073          RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
    1074          if (RgnData == NULL)
    1075                 goto error;
    1076          GetRegionData (hrgn, BytesNeeded, RgnData);
    1077 
    1078          i = RgnData->rdh.nCount;
    1079          pr = (PRECT)(RgnData->Buffer);
    1080 
    1081          if (flags & DCX_WINDOW_W)
    1082                 height = wnd->getWindowHeight();
    1083          else   height = wnd->getClientHeight();
    1084 
    1085          for (; (i > 0) && success; i--, pr++) {
    1086             LONG y = pr->yBottom;
    1087 
    1088             pr->yBottom = height - pr->yTop;
    1089             pr->yTop    = height - y;
    1090             success &= GpiExcludeClipRectangle (pHps->hps, pr);
    1091          }
    1092 #endif
     1091        {//exclude specified region from visible region
     1092            success = (GdiCombineVisRgn(pHps, hrgn, RGN_DIFF_W) != ERROR_W);
    10931093        }
    10941094        else //DCX_INTERSECTRGN_W
    1095         {
    1096             //SvL: I'm getting paint problems when clipping a dc created in GetDCEx
    1097             //     with a region that covers the entire window (RealPlayer 7 Update 1)
    1098             //     Using SelectClipRgn here doesn't make any difference.
    1099             if(ExtSelectClipRgn(pHps->hps, hrgn, RGN_AND_W) == ERROR_W) {
    1100                 dprintf(("ExtSelectClipRgn failed!!"));
    1101             }
     1095        {//intersect visible region with specified region
     1096            success = (GdiCombineVisRgn(pHps, hrgn, RGN_AND_W) != ERROR_W);
    11021097        }
    11031098        if (!success)
     
    12921287        //already (partly) invalidated
    12931288        if (!WinQueryUpdateRect (hwnd, NULL)) {
     1289            dprintf(("RDW_INVALIDATE: no update rectangle, disable %x WM_ERASEBKGND", wnd->getWindowHandle()));
    12941290            wnd->setEraseBkgnd(FALSE);
    12951291        }
     
    13321328    else if (redraw & RDW_VALIDATE_W)
    13331329    {
    1334         if (redraw & RDW_NOERASE_W)
     1330        if (redraw & RDW_NOERASE_W) {
     1331            dprintf(("RDW_NOERASE: disable %x WM_ERASEBKGND", wnd->getWindowHandle()));
    13351332            wnd->setEraseBkgnd(FALSE);
    1336 
     1333        }
    13371334        if (WinQueryUpdateRect (hwnd, NULL))
    13381335        {
  • trunk/src/user32/dc.h

    r5685 r10316  
    1 /* $Id: dc.h,v 1.17 2001-05-11 08:39:42 sandervl Exp $ */
     1/* $Id: dc.h,v 1.18 2003-11-12 14:10:19 sandervl Exp $ */
    22/*
    33 * public dc functions
     
    2222BOOL GetOS2UpdateRect(Win32BaseWindow *window,LPRECT pRect);
    2323
     24int WIN32API GetUpdateRgnFrame(HWND hwnd, HRGN hrgn);
     25
    2426#ifdef DEBUG
    2527void dprintfOrigin(HDC hdc);
     
    3032#ifdef INCLUDED_BY_DC
    3133/*********************/
    32 typedef struct
    33 {
    34     HDC   hdc;
    35     BOOL  fErase;
    36     RECT  rcPaint;
    37     BOOL  fRestore;
    38     BOOL  IncUpdate;
    39     BYTE  rgbReserved[32];
    40 } PAINTSTRUCT_W, *PPAINTSTRUCT_W, *LPPAINTSTRUCT_W;
    41 
    42 #define PS_SOLID_W         0x00000000
    43 #define PS_DASH_W          0x00000001
    44 #define PS_DOT_W           0x00000002
    45 #define PS_DASHDOT_W       0x00000003
    46 #define PS_DASHDOTDOT_W    0x00000004
    47 #define PS_NULL_W          0x00000005
    48 #define PS_INSIDEFRAME_W   0x00000006
    49 #define PS_USERSTYLE_W     0x00000007
    50 #define PS_ALTERNATE_W     0x00000008
    51 #define PS_STYLE_MASK_W    0x0000000f
    52 
    53 typedef struct
    54 {
    55     UINT   lopnStyle;
    56     POINT  lopnWidth;
    57     ULONG  lopnColor;
    58 } LOGPEN_W, *LPLOGPEN_W;
    59 
    60 typedef struct tagEXTLOGPEN
    61 {
    62     DWORD elpPenStyle;
    63     DWORD elpWidth;
    64     DWORD elpBrushStyle;
    65     DWORD elpColor;
    66     DWORD elpNumEntries;
    67     DWORD elpStyleEntry[1];
    68 } EXTLOGPEN_W, *PEXTLOGPEN_W, *NPEXTLOGPEN_W, *LPEXTLOGPEN_W;
    69 
    70 typedef struct
    71 {
    72     UINT   lbStyle;
    73     ULONG  lbColor;
    74     INT    lbHatch;
    75 } LOGBRUSH_W, *LPLOGBRUSH_W;
    7634
    7735typedef struct _penobject
     
    9048} tPenObject, *pPenObject;
    9149
    92 /* DC Graphics Mode */
    93 #define GM_COMPATIBLE_W     1
    94 #define GM_ADVANCED_W       2
    95 
    96 #define DCX_WINDOW_W                    0x00000001L
    97 #define DCX_CACHE_W                     0x00000002L
    98 #define DCX_NORESETATTRS_W              0x00000004L
    99 #define DCX_CLIPCHILDREN_W              0x00000008L
    100 #define DCX_CLIPSIBLINGS_W              0x00000010L
    101 #define DCX_PARENTCLIP_W                0x00000020L
    102 #define DCX_EXCLUDERGN_W                0x00000040L
    103 #define DCX_INTERSECTRGN_W              0x00000080L
    104 #define DCX_EXCLUDEUPDATE_W             0x00000100L
    105 #define DCX_INTERSECTUPDATE_W           0x00000200L
    106 #define DCX_LOCKWINDOWUPDATE_W          0x00000400L
    107 #define DCX_USESTYLE_W                  0x00010000L
    108 #define DCX_VALIDATE_W                  0x00200000L
    109 
    110 #define RDW_INVALIDATE_W       0x0001
    111 #define RDW_INTERNALPAINT_W    0x0002
    112 #define RDW_ERASE_W            0x0004
    113 #define RDW_VALIDATE_W         0x0008
    114 #define RDW_NOINTERNALPAINT_W  0x0010
    115 #define RDW_NOERASE_W          0x0020
    116 #define RDW_NOCHILDREN_W       0x0040
    117 #define RDW_ALLCHILDREN_W      0x0080
    118 #define RDW_UPDATENOW_W        0x0100
    119 #define RDW_ERASENOW_W         0x0200
    120 #define RDW_FRAME_W            0x0400
    121 #define RDW_NOFRAME_W          0x0800
    122 /* Xform FLAGS */
    123 #define MWT_IDENTITY_W        1
    124 #define MWT_LEFTMULTIPLY_W    2
    125 #define MWT_RIGHTMULTIPLY_W   3
    126 
    127 /* Mapping Modes */
    128 #define MM_TEXT_W             1
    129 #define MM_LOMETRIC_W         2
    130 #define MM_HIMETRIC_W         3
    131 #define MM_LOENGLISH_W        4
    132 #define MM_HIENGLISH_W        5
    133 #define MM_TWIPS_W            6
    134 #define MM_ISOTROPIC_W        7
    135 #define MM_ANISOTROPIC_W      8
    136 
    137 #define RGN_OR_W              2
    138 
    139 /* Window scrolling */
    140 #define SW_SCROLLCHILDREN_W    0x0001
    141 #define SW_INVALIDATE_W        0x0002
    142 #define SW_ERASE_W             0x0004
    143 #define SW_SMOOTHSCROLL_W      0x0010
    14450
    14551/*********************/
  • trunk/src/user32/dcrgn.cpp

    r9933 r10316  
    1 /* $Id: dcrgn.cpp,v 1.8 2003-03-22 20:27:11 sandervl Exp $ */
     1/* $Id: dcrgn.cpp,v 1.9 2003-11-12 14:10:19 sandervl Exp $ */
    22
    33/*
     
    4242#include "dbglocal.h"
    4343
     44#ifdef DEBUG
     45//#define dprintfRegion(a,b,c) if(DbgEnabledLvl2USER32[DBG_LOCALLOG] == 1) dprintfRegion1(a,b,c)
     46//#define dprintfRegion(a,b,c) dprintfRegion1(a,b,c)
     47
     48static void dprintfRegion(HWND hWnd, HRGN hrgnClip)
     49{
     50 RGNRECT rgnRect = {0, 16, 0, RECTDIR_LFRT_TOPBOT};
     51 RECTL   rectRegion[16];
     52 APIRET  rc;
     53 HDC     hdc;
     54   
     55   hdc = GetDCEx(hWnd, NULL, DCX_CACHE_W|DCX_USESTYLE_W);
     56   dprintf(("dprintfRegion %x %x", hWnd, hdc));
     57   rc = GpiQueryRegionRects(hdc, hrgnClip, NULL, &rgnRect, &rectRegion[0]);
     58   for(int i=0;i<rgnRect.crcReturned;i++) {
     59        dprintf(("(%d,%d)(%d,%d)", rectRegion[i].xLeft, rectRegion[i].yBottom, rectRegion[i].xRight, rectRegion[i].yTop));
     60   }
     61   ReleaseDC(hWnd, hdc);
     62}
     63#else
     64#define dprintfRegion(b,c)
     65#endif
     66
    4467//******************************************************************************
    4568//******************************************************************************
     
    134157    if(lComplexity != RGN_NULL)
    135158    {
     159        dprintfRegion(hwnd, hrgn);
    136160        if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, hrgn, NULL, wnd->getOS2WindowHandle()))
    137161        {
     
    142166        }
    143167        if(erase) sendEraseBkgnd(wnd);
     168    }
     169    RELEASE_WNDOBJ(wnd);
     170    return lComplexity;
     171}
     172//******************************************************************************
     173//TODO: Seems to return region in window coordinates instead of client coordinates
     174//******************************************************************************
     175int WIN32API GetUpdateRgnFrame(HWND hwnd, HRGN hrgn)
     176{
     177    LONG lComplexity;
     178    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     179
     180    hrgn = ObjWinToOS2Region(hrgn);
     181    if(!wnd || !hrgn)
     182    {
     183        dprintf(("WARNING: GetUpdateRgnFrame %x %x invalid handle", hwnd, hrgn));
     184        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     185        if(wnd) RELEASE_WNDOBJ(wnd);
     186        return ERROR_W;
     187    }
     188    lComplexity = WinQueryUpdateRegion(wnd->getOS2FrameWindowHandle(), hrgn);
     189    if(lComplexity == RGN_ERROR) {
     190        dprintf(("WARNING: GetUpdateRgnFrame %x %x RGN_ERROR", hwnd, hrgn));
     191        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     192        RELEASE_WNDOBJ(wnd);
     193        return ERROR_W;
     194    }
     195
     196    if(lComplexity != RGN_NULL)
     197    {
     198        dprintfRegion(hwnd, hrgn);
     199        if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, hrgn, NULL, wnd->getOS2FrameWindowHandle()))
     200        {
     201            dprintf(("WARNING: GetUpdateRgnFrame %x %x; setWinDeviceRegionFromPMDeviceRegion failed!", hwnd, hrgn));
     202            SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     203            RELEASE_WNDOBJ(wnd);
     204            return ERROR_W;
     205        }
    144206    }
    145207    RELEASE_WNDOBJ(wnd);
  • trunk/src/user32/inituser32.cpp

    r10284 r10316  
    1 /* $Id: inituser32.cpp,v 1.16 2003-10-22 12:43:13 sandervl Exp $ */
     1/* $Id: inituser32.cpp,v 1.17 2003-11-12 14:10:19 sandervl Exp $ */
    22/*
    33 * USER32 DLL entry point
     
    7171extern INT __cdecl wsnprintfA(LPSTR,UINT,LPCSTR,...);
    7272
    73 static char PMKBDHK_MODULE[16] = STD_PMKBDHK_MODULE;
    74 
    75 static BOOL pmkbdhk_installed = FALSE;
    76 static HMODULE hmodPMKBDHK;
    77 
    78 static PFN_HOOKINIT pfnHookInit = NULL;
    79 static PFN_HOOKTERM pfnHookTerm = NULL;
    80 
    81 // defined initialized in pmwindow.cpp: InitPM()
    82 extern HAB hab;
    83 
    84 //******************************************************************************
    85 //******************************************************************************
    86 void WIN32API SetCustomPMHookDll(LPSTR pszKbdDllName)
    87 {
    88    strcpy(PMKBDHK_MODULE, pszKbdDllName);
    89 }
    90 //******************************************************************************
    91 //******************************************************************************
    92 void pmkbdhk_initialize(HAB _hab)
    93 {
    94   APIRET rc;
    95 
    96   if ((pmkbdhk_installed == FALSE) && PMKBDHK_MODULE[0])
    97   {
    98     CHAR szBuf[260];
    99 
    100     // load the DLL
    101     rc = DosLoadModule(szBuf,
    102                        sizeof(szBuf),
    103                        PMKBDHK_MODULE,
    104                        &hmodPMKBDHK);
    105     if (NO_ERROR != rc)
    106     {
    107       dprintf(("USER32: pmkbdhk_initalize(%08xh) failed rc=%d\n",
    108                _hab,
    109                rc));
    110 
    111       return;
    112     }
    113 
    114     // get the entry points
    115     rc = DosQueryProcAddr(hmodPMKBDHK,
    116                           0,
    117                           PMKBDHK_HOOK_INIT,
    118                           (PFN*)&pfnHookInit);
    119     if (NO_ERROR == rc)
    120       rc = DosQueryProcAddr(hmodPMKBDHK,
    121                             0,
    122                             PMKBDHK_HOOK_TERM,
    123                             (PFN*)&pfnHookTerm);
    124 
    125     if (NO_ERROR != rc)
    126     {
    127       dprintf(("USER32: pmkbdhk_initalize(%08xh) failed importing functions, rc=%d\n",
    128                _hab,
    129                rc));
    130 
    131       // free the DLL again
    132       DosFreeModule(hmodPMKBDHK);
    133       hmodPMKBDHK = NULLHANDLE;
    134 
    135       return;
    136     }
    137 
    138     // now finally call the initializer function
    139     if(pfnHookInit(_hab, WIN32_STDCLASS) == FALSE) DebugInt3();
    140 
    141     // OK, hook is armed
    142     pmkbdhk_installed = TRUE;
    143   }
    144 }
    145 //******************************************************************************
    146 //******************************************************************************
    147 void pmkbdhk_terminate(void)
    148 {
    149   if (pmkbdhk_installed == TRUE)
    150   {
    151     // call the terminator function
    152     pfnHookTerm();
    153 
    154     // OK, hook is disarmed
    155     pmkbdhk_installed = FALSE;
    156   }
    157 
    158   // unload the dll
    159   if (NULLHANDLE != hmodPMKBDHK)
    160   {
    161     APIRET rc = DosFreeModule(hmodPMKBDHK);
    162     if (NO_ERROR != rc)
    163     {
    164       dprintf(("USER32: pmkbdhk_terminate() failed rc=%d\n",
    165                rc));
    166 
    167       hmodPMKBDHK = NULLHANDLE;
    168     }
    169   }
    170 }
    17173//******************************************************************************
    17274#define FONTSDIRECTORY "Fonts"
     
    261163           return 0UL;
    262164
    263          // try to install the keyboard hook
    264          pmkbdhk_initialize(hab);
    265 
    266165         InitializeWindowHandles();
    267166
     
    298197{
    299198  dprintf(("user32 exit\n"));
    300 
    301   // try to unistall the keyboard hook
    302   pmkbdhk_terminate();
    303199
    304200//SvL: Causes PM hangs on some (a lot?) machines. Reason unknown.
  • trunk/src/user32/pmwindow.cpp

    r10285 r10316  
    1 /* $Id: pmwindow.cpp,v 1.223 2003-10-22 12:43:51 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.224 2003-11-12 14:10:19 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    5959#include "menu.h"
    6060#include "user32api.h"
     61#include <kbdhook.h>
    6162
    6263#define DBG_LOCALLOG    DBG_pmwindow
    6364#include "dbglocal.h"
    6465
     66
    6567#define ODIN_SetExceptionHandler(a)
    6668#define ODIN_UnsetExceptionHandler(a)
    67 
    6869
    6970// Notification that focus change has completed (UNDOCUMENTED)
     
    8485BOOL    fDragDropDisabled = FALSE;
    8586
    86 const char WIN32_CDCLASS[]       = "Win32CDWindowClass";
    87       char WIN32_STDCLASS[255]   = "Win32WindowClass";
     87const char WIN32_CDCLASS[]       = ODIN_WIN32_CDCLASS;
     88      char WIN32_STDCLASS[255]   = ODIN_WIN32_STDCLASS;
    8889
    8990#define PMMENU_MINBUTTON           0
     
    190191    SetThreadMessageQueue(hmq);
    191192
     193    //initialize keyboard hook for first thread 
     194    hookInit(hab);
     195
    192196    BOOL rc = WinSetCp(hmq, GetDisplayCodepage());
    193197    dprintf(("InitPM: WinSetCP was %sOK", rc ? "" : "not "));
     
    255259    // query the font height to find out whether we have small or large fonts
    256260    DevQueryCaps(hdc, CAPS_GRAPHICS_CHAR_HEIGHT, 1, (PLONG)&CapsCharHeight);
     261    dprintf(("CAPS_GRAPHICS_CHAR_HEIGHT = %d", CapsCharHeight));
     262    if(CapsCharHeight > 16) {
     263       CapsCharHeight = 16;
     264    }
     265
     266#ifdef DEBUG
     267    ULONG temp;
     268    DevQueryCaps(hdc, CAPS_GRAPHICS_CHAR_WIDTH, 1, (PLONG)&temp);
     269    dprintf(("CAPS_GRAPHICS_CHAR_WIDTH = %d", temp));
     270    DevQueryCaps(hdc, CAPS_CHAR_HEIGHT, 1, (PLONG)&temp);
     271    dprintf(("CAPS_CHAR_HEIGTH = %d", temp));
     272    DevQueryCaps(hdc, CAPS_CHAR_WIDTH, 1, (PLONG)&temp);
     273    dprintf(("CAPS_CHAR_WIDTH = %d", temp));
     274    DevQueryCaps(hdc, CAPS_SMALL_CHAR_HEIGHT, 1, (PLONG)&temp);
     275    dprintf(("CAPS_SMALL_CHAR_HEIGTH = %d", temp));
     276    DevQueryCaps(hdc, CAPS_SMALL_CHAR_WIDTH, 1, (PLONG)&temp);
     277    dprintf(("CAPS_SMALL_CHAR_WIDTH = %d", temp));
     278    DevQueryCaps(hdc, CAPS_VERTICAL_FONT_RES, 1,(PLONG)&temp);
     279    dprintf(("CAPS_VERTICAL_FONT_RES = %d", temp));
     280    DevQueryCaps(hdc, CAPS_HORIZONTAL_FONT_RES, 1,(PLONG)&temp);
     281    dprintf(("CAPS_HORIZONTAL_FONT_RES = %d", temp));
     282#endif
    257283
    258284    DevCloseDC(hdc);
    259285
    260     dprintf(("InitPM: Desktop (%d,%d) bpp %d", ScreenWidth, ScreenHeight, ScreenBitsPerPel));
     286    dprintf(("InitPM: Desktop (%d,%d) bpp %d font size %d", ScreenWidth, ScreenHeight, ScreenBitsPerPel, CapsCharHeight));
    261287    return TRUE;
    262288} /* End of main */
     
    638664
    639665    case WM_SHOW:
     666    {
    640667        dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
    641668        win32wnd->MsgShow((ULONG)mp1);
    642         break;
     669 
     670        //if a child window is hidden, then the update region of the
     671        //parent changes and a WM_ERASEBKGND is required during the next
     672        //BeginPaint call.
     673        if((ULONG)mp1 == FALSE)
     674        {
     675            Win32BaseWindow *parent = win32wnd->getParent();
     676            if(parent) {
     677                dprintf(("PM Update region changed for parent %x", win32wnd->getWindowHandle()));
     678                parent->SetPMUpdateRegionChanged(TRUE);
     679            }
     680        }
     681        break;
     682    }
    643683
    644684    case WM_ACTIVATE:
     
    658698    {
    659699        dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)));
    660         win32wnd->SetVisibleRegionChanged(TRUE);
     700        win32wnd->SetPMUpdateRegionChanged(TRUE);
    661701        goto RunDefWndProc;
    662702    }
     
    12671307    case WM_PAINT:
    12681308    {
    1269       RECTL rectl;
     1309        RECTL rectl;
     1310        HRGN  hrgn;
     1311
     1312        hrgn = CreateRectRgn(0, 0, 0, 0);
     1313        GetUpdateRgnFrame(win32wnd->getWindowHandle(), hrgn);
    12701314
    12711315        HPS hps = WinBeginPaint(hwnd, NULL, &rectl);
     
    12851329
    12861330                mapOS2ToWin32Rect(win32wnd->getWindowHeight(), (PRECTLOS2)&rectl, &rectUpdate);
    1287                 win32wnd->MsgNCPaint(&rectUpdate);
     1331                win32wnd->MsgNCPaint(&rectUpdate, hrgn);
    12881332            }
    12891333        }
    12901334        WinEndPaint(hps);
     1335
     1336        DeleteObject(hrgn);
    12911337        break;
    12921338    }
     
    15991645        if ((pswp->fl & SWP_MAXIMIZE) && (win32wnd->getExStyle() & WS_EX_MDICHILD_W))
    16001646        {
    1601          SendMessageA(win32wnd->getWindowHandle(), WM_SYSCOMMAND_W, SC_MAXIMIZE_W, 0);
    1602          goto PosChangedEnd;
     1647            SendMessageA(win32wnd->getWindowHandle(), WM_SYSCOMMAND_W, SC_MAXIMIZE_W, 0);
     1648            goto PosChangedEnd;
    16031649        }
    16041650
     
    24782524//******************************************************************************
    24792525//******************************************************************************
     2526char *WIN32API QueryCustomStdClassName()
     2527{
     2528   return WIN32_STDCLASS;
     2529}
     2530//******************************************************************************
     2531//******************************************************************************
    24802532
    24812533#ifdef DEBUG
  • trunk/src/user32/user32.cpp

    r10275 r10316  
    1 /* $Id: user32.cpp,v 1.129 2003-10-20 17:17:23 sandervl Exp $ */
     1/* $Id: user32.cpp,v 1.130 2003-11-12 14:10:20 sandervl Exp $ */
    22
    33/*
     
    11441144/* Filled Shape Functions */
    11451145
    1146   /* Last COLOR id */
    1147 #define COLOR_MAX   COLOR_GRADIENTINACTIVECAPTION
    1148 
    1149 int WIN32API FillRect(HDC hDC, const RECT * lprc, HBRUSH hbr)
    1150 {
    1151     //SvL: brush 0 means current selected brush (verified in NT4)
    1152     if(hbr == 0) {
    1153         hbr = GetCurrentObject(hDC, OBJ_BRUSH);
    1154     }
    1155     else
    1156     if (hbr <= (HBRUSH) (COLOR_MAX + 1)) {
    1157         hbr = GetSysColorBrush( (INT) hbr - 1 );
    1158     }
    1159     dprintf(("USER32:  FillRect %x (%d,%d)(%d,%d) brush %X", hDC, lprc->left, lprc->top, lprc->right, lprc->bottom, hbr));
    1160     return O32_FillRect(hDC,lprc,hbr);
    1161 }
    1162 //******************************************************************************
    1163 //******************************************************************************
    1164 int WIN32API FrameRect( HDC hDC, const RECT * lprc, HBRUSH  hbr)
    1165 {
    1166     dprintf(("USER32: FrameRect %x (%d,%d)(%d,%d) brush %x", hDC, lprc->top, lprc->left, lprc->bottom, lprc->right, hbr));
    1167     return O32_FrameRect(hDC,lprc,hbr);
    1168 }
    1169 //******************************************************************************
    1170 //******************************************************************************
    1171 BOOL WIN32API InvertRect( HDC hDC, const RECT * lprc)
    1172 {
    1173     if(lprc) {
    1174          dprintf(("USER32: InvertRect %x (%d,%d)(%d,%d)", hDC, lprc->left, lprc->top, lprc->right, lprc->bottom));
    1175     }
    1176     else dprintf(("USER32: InvertRect %x NULL", hDC));
    1177     return O32_InvertRect(hDC,lprc);
    1178 }
     1146
    11791147
    11801148/* System Information Functions */
  • trunk/src/user32/user32api.h

    r9791 r10316  
    1 /* $Id: user32api.h,v 1.2 2003-02-13 10:12:25 sandervl Exp $ */
     1/* $Id: user32api.h,v 1.3 2003-11-12 14:10:20 sandervl Exp $ */
    22//Internal user32 functions
    33
    44#ifndef __USER32API_H_
    55#define __USER32API_H_
    6 
    7 HWND WINAPI GetAncestor( HWND hwnd, UINT type );
    86
    97//Notify that focus has changed (necessary for SetFocus(0) handling)
  • trunk/src/user32/user32dbg.def

    r10256 r10316  
    1 ; $Id: user32dbg.def,v 1.14 2003-10-02 10:36:00 sandervl Exp $
     1; $Id: user32dbg.def,v 1.15 2003-11-12 14:10:20 sandervl Exp $
    22
    33LIBRARY USER32 INITINSTANCE TERMINSTANCE
     
    237237    ExcludeUpdateRgn           = _DbgExcludeUpdateRgn@8         @194
    238238    ExitWindowsEx              = _DbgExitWindowsEx@8            @195
    239     FillRect                   = _DbgFillRect@12                @196
     239    FillRect                   = _FillRect@12                   @196
    240240    FindWindowA                = _DbgFindWindowA@8              @197
    241241    FindWindowExA              = _DbgFindWindowExA@16           @198
     
    243243    FindWindowW                = _DbgFindWindowW@8              @200
    244244    FlashWindow                = _DbgFlashWindow@8              @201
    245     FrameRect                  = _DbgFrameRect@12               @202
     245    FrameRect                  = _FrameRect@12                  @202
    246246    FreeDDElParam              = _DbgFreeDDElParam@8            @203
    247247    GetActiveWindow            = _DbgGetActiveWindow@0          @204
     
    374374    InvalidateRect             = _DbgInvalidateRect@12          @328
    375375    InvalidateRgn              = _DbgInvalidateRgn@12           @329
    376     InvertRect                 = _DbgInvertRect@8               @330
     376    InvertRect                 = _InvertRect@8                  @330
    377377    IsCharAlphaA               = _IsCharAlphaA@4             @331
    378378    IsCharAlphaNumericA        = _IsCharAlphaNumericA@4      @332
     
    642642    SetWinEventHook            = _DbgSetWinEventHook@28         @608
    643643
     644    GetAncestor                = _DbgGetAncestor@8              @609
     645    GetWindowModuleFileNameA   = _DbgGetWindowModuleFileNameA@12 @610
     646
    644647;------------
    645648; Windows 98
  • trunk/src/user32/win32wbase.cpp

    r10275 r10316  
    1 /* $Id: win32wbase.cpp,v 1.379 2003-10-20 17:17:23 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.380 2003-11-12 14:10:20 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    117117  fComingToTop     = FALSE;
    118118  fMinMaxChange    = FALSE;
    119   fVisibleRegionChanged = FALSE;
     119  fPMUpdateRegionChanged = FALSE;
    120120  fEraseBkgndFlag  = TRUE;
    121121  fIsDragDropActive= FALSE;
     
    178178  hWindowRegion      = 0;
    179179  hClipRegion        = 0;
     180  hVisRegion         = 0;
    180181  hUpdateRegion      = 0;
    181182
     
    12191220    HDC   hdcErase = hdc;
    12201221
    1221     if (hdcErase == 0)
    1222         hdcErase = GetDC(getWindowHandle());
     1222    if (hdcErase == 0) {
     1223        DebugInt3();
     1224        return 0;
     1225    }
    12231226
    12241227    if(IsWindowIconic())
     
    12261229    else
    12271230        rc = SendMessageA(getWindowHandle(),WM_ERASEBKGND, hdcErase, 0);
    1228     if (hdc == 0)
    1229         ReleaseDC(getWindowHandle(), hdcErase);
     1231
    12301232    return (rc);
    12311233}
     
    12501252}
    12511253//******************************************************************************
    1252 //TODO: Should use update region, not rectangle
    1253 //******************************************************************************
    1254 ULONG Win32BaseWindow::MsgNCPaint(PRECT pUpdateRect)
    1255 {
    1256     HRGN hrgn;
     1254//******************************************************************************
     1255ULONG Win32BaseWindow::MsgNCPaint(PRECT pUpdateRect, HRGN hrgnUpdate)
     1256{
    12571257    ULONG rc;
    12581258    RECT client = rectClient;
     
    12671267    }
    12681268
    1269     dprintf(("MsgNCPaint (%d,%d)(%d,%d)", pUpdateRect->left, pUpdateRect->top, pUpdateRect->right, pUpdateRect->bottom));
    1270     hrgn = CreateRectRgnIndirect(pUpdateRect);
    1271 
    1272     rc = SendMessageA(getWindowHandle(),WM_NCPAINT, hrgn, 0);
     1269    rc = SendMessageA(getWindowHandle(),WM_NCPAINT, hrgnUpdate, 0);
    12731270    //Send WM_PAINTICON here if minimized, because client window will
    12741271    //not receive a (valid) WM_PAINT message
     
    12771274        rc = SendMessageA(getWindowHandle(),WM_PAINTICON, 1, 0);
    12781275    }
    1279 
    1280     DeleteObject(hrgn);
    12811276
    12821277    return rc;
     
    29192914}
    29202915//******************************************************************************
    2921 //Note: does not set last error if no parent (verified in NT4, SP6)
     2916// Win32BaseWindow::GetParent
     2917//
     2918// If the window is a child window, then return the parent window handle.
     2919// If it's a popup window, then return the owner
     2920//
     2921// Returns window handle of parent or owner window
     2922//
     2923// Note: does not set last error if no parent (verified in NT4, SP6)
    29222924//******************************************************************************
    29232925HWND Win32BaseWindow::GetParent()
  • trunk/src/user32/win32wbase.h

    r10190 r10316  
    1 /* $Id: win32wbase.h,v 1.155 2003-07-31 15:56:47 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.156 2003-11-12 14:10:21 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    136136         ULONG  MsgPaint(ULONG tmp1, BOOL select = TRUE);
    137137         ULONG  MsgEraseBackGround(HDC hdc);
    138          ULONG  MsgNCPaint(PRECT pUpdateRect);
     138         ULONG  MsgNCPaint(PRECT pUpdateRect, HRGN hrgnUpdate);
    139139         ULONG  MsgFormatFrame(WINDOWPOS *lpWndPos);
    140140         ULONG  DispatchMsgA(MSG *msg);
     
    231231         //Save old clip region for CS_OWNDC windows (in BeginPaint)
    232232         HRGN   GetClipRegion()                   { return hClipRegion; };
    233          void   SetClipRegion(HRGN hRegion)       { hClipRegion = hRegion; };
     233         HRGN   GetVisRegion()                    { return hVisRegion; };
     234         void   SaveClipRegion(HRGN hrgnClip)     { hClipRegion = hrgnClip; };
     235         void   SaveVisRegion(HRGN hrgnVis)       { hVisRegion = hrgnVis; };
    234236
    235237         void   saveAndValidateUpdateRegion();
     
    286288         BOOL   IsMixMaxStateChanging()       { return fMinMaxChange; };
    287289
    288          void   SetVisibleRegionChanged(BOOL changed) { fVisibleRegionChanged = changed; };
    289          BOOL   IsVisibleRegionChanged()              { return fVisibleRegionChanged; };
    290290         BOOL   setVisibleRgnNotifyProc(VISRGN_NOTIFY_PROC lpNotifyProc, DWORD dwUserData);
    291291         void   callVisibleRgnNotifyProc(BOOL fDrawingAllowed);
     
    415415                 fCXDefault:1,
    416416                 fParentDC:1,
    417              fComingToTop:1,
     417                 fComingToTop:1,
    418418                 isUnicode:1,
    419419                 fMinMaxChange:1,        //set when switching between min/max/restored state
    420                  fVisibleRegionChanged:1, //set when visible region has changed -> erase background must be sent during next BeginPaint
     420                 fPMUpdateRegionChanged:1, //set when PM update has changed -> erase background must be sent during next BeginPaint
    421421                 fEraseBkgndFlag:1,
    422422                 fIsDragDropActive:1,
     
    426426        ULONG   state;
    427427        HRGN    hWindowRegion;
    428         HRGN    hClipRegion;
     428        HRGN    hClipRegion, hVisRegion;
    429429        HRGN    hUpdateRegion;
    430430
     
    533533         VOID   setEraseBkgnd (BOOL erase)      { fEraseBkgndFlag = erase; }
    534534         BOOL   needsEraseBkgnd()               { return fEraseBkgndFlag; }
     535
     536         void   SetPMUpdateRegionChanged(BOOL changed)  { fPMUpdateRegionChanged = changed; };
     537         BOOL   hasPMUpdateRegionChanged()              { return fPMUpdateRegionChanged; };
    535538};
    536539
  • trunk/src/user32/win32wmisc.h

    r9598 r10316  
    1 /* $Id: win32wmisc.h,v 1.2 2003-01-03 16:35:58 sandervl Exp $ */
     1/* $Id: win32wmisc.h,v 1.3 2003-11-12 14:10:21 sandervl Exp $ */
    22/*
    33 * Misc. functions for window management
     
    3232INT  NC_HandleNCHitTest( HWND hwnd, POINT pt);
    3333
    34 HWND WINAPI GetAncestor( HWND hwnd, UINT type );
    35 
    3634#ifdef __cplusplus
    3735}
  • trunk/src/user32/window.cpp

    r10145 r10316  
    1 /* $Id: window.cpp,v 1.136 2003-06-25 17:02:04 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.137 2003-11-12 14:10:21 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    4444#include <winuser32.h>
    4545#include "hook.h"
     46#include <wprocess.h>
    4647
    4748#define DBG_LOCALLOG    DBG_window
     
    711712{
    712713    HWND hwndAncestor = 0;
     714    Win32BaseWindow *window;
     715
     716    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     717    if(!window) {
     718        dprintf(("GetAncestor, window %x not found", hwnd));
     719        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     720        return FALSE;
     721    }
    713722
    714723    if (type == GA_PARENT)
     
    719728        }
    720729        //else no child -> no parent (GetParent returns owner otherwise!)
    721         return hwndAncestor;
    722     }
    723     dprintf(("Unsupported type %d", type));
    724     return 0;
     730    }
     731    else
     732    if (type == GA_ROOT)
     733    {
     734         hwndAncestor = window->GetTopParent();
     735    }
     736    else
     737    if (type == GA_ROOTOWNER)
     738    {
     739         if(hwnd != GetDesktopWindow())
     740         {
     741             hwndAncestor = hwnd;
     742             for(;;)
     743             {
     744                HWND parent = GetParent( hwndAncestor );
     745                if (!parent) break;
     746                hwndAncestor = parent;
     747             }
     748         }
     749    }
     750    else dprintf(("Unsupported type %d", type));
     751
     752    RELEASE_WNDOBJ(window);
     753    return hwndAncestor;
    725754}
    726755//******************************************************************************
     
    760789            return 0;
    761790        }
     791        fIgnoreKeystrokes = TRUE;
    762792        SendMessageA(lastFocus_W, WM_KILLFOCUS, 0, 0);
    763 
    764         fIgnoreKeystrokes = TRUE;
    765793
    766794        return lastFocus_W;
     
    21512179}
    21522180//******************************************************************************
     2181//The GetWindowModuleFileName function retrieves the full path and file name of
     2182//the module associated with the specified window handle.
     2183//******************************************************************************
     2184UINT WIN32API GetWindowModuleFileNameA(HWND hwnd, LPTSTR lpszFileName, UINT cchFileNameMax)
     2185{
     2186    WNDPROC lpfnWindowProc;
     2187
     2188    if (!IsWindow(hwnd)) {
     2189        dprintf(("warning: GetWindowModuleFileName: window %x not found!", hwnd));
     2190        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     2191        return 0;
     2192    }
     2193    lpfnWindowProc = (WNDPROC)GetWindowLongA(hwnd, GWL_WNDPROC);
     2194    return GetProcModuleFileNameA((ULONG)lpfnWindowProc, lpszFileName, cchFileNameMax);
     2195}
     2196//******************************************************************************
    21532197//******************************************************************************
    21542198
Note: See TracChangeset for help on using the changeset viewer.