Changeset 5973 for trunk/src


Ignore:
Timestamp:
Jun 12, 2001, 7:02:42 PM (24 years ago)
Author:
sandervl
Message:

FillRect & CS_CLASSDC fixes; use critical secions for hooks

Location:
trunk/src/user32
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/HOOK.CPP

    r5935 r5973  
    1 /* $Id: HOOK.CPP,v 1.20 2001-06-09 14:50:15 sandervl Exp $ */
     1/* $Id: HOOK.CPP,v 1.21 2001-06-12 17:02:33 sandervl Exp $ */
    22
    33/*
     
    8686//Global DLL Data
    8787//SvL: Disabled global system hooks for now
    88 ////#pragma data_seg(_GLOBALDATA)
     88//#define GLOBAL_HOOKS
     89#ifdef GLOBAL_HOOKS
     90#pragma data_seg(_GLOBALDATA)
     91#endif
    8992static HANDLE HOOK_systemHooks[WH_NB_HOOKS] = { 0 };
     93#ifdef GLOBAL_HOOKS
    9094static VMutex systemHookMutex(VMUTEX_SHARED, &hGlobalHookMutex);
    91 ////#pragma data_seg()
     95#pragma data_seg()
     96#else
     97static CRITICAL_SECTION systemCritSect = {0};
     98#endif
    9299static HANDLE HOOK_threadHooks[WH_NB_HOOKS] = { 0 };
    93 static VMutex threadHookMutex;
     100static CRITICAL_SECTION threadCritSect = {0};
     101
     102#ifdef GLOBAL_HOOKS
     103#define SYSTEMHOOK_LOCK()       systemHookMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalHookMutex);
     104#define SYSTEMHOOK_UNLOCK()     systemHookMutex.leave(&hGlobalHookMutex);
     105#else
     106#define SYSTEMHOOK_LOCK()       EnterCriticalSection(&systemCritSect);
     107#define SYSTEMHOOK_UNLOCK()     LeaveCriticalSection(&systemCritSect);
     108#endif
    94109
    95110typedef VOID (*HOOK_MapFunc)(INT, INT, WPARAM *, LPARAM *);
     
    324339                return 0;
    325340        }
    326         threadHookMutex.enter();
     341        EnterCriticalSection(&threadCritSect);
    327342        data->next = teb->o.odin.hooks[id - WH_MINHOOK];
    328343        teb->o.odin.hooks[id - WH_MINHOOK] = (DWORD)data;
    329         threadHookMutex.leave();
     344        LeaveCriticalSection(&threadCritSect);
    330345    }
    331346    else
    332347    {
    333         systemHookMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalHookMutex);
     348        SYSTEMHOOK_LOCK();
    334349        data->next = HOOK_systemHooks[id - WH_MINHOOK];
    335350        HOOK_systemHooks[id - WH_MINHOOK] = (HANDLE)data;
    336         systemHookMutex.leave(&hGlobalHookMutex);
     351        SYSTEMHOOK_UNLOCK();
    337352    }
    338353
     
    374389                return FALSE;
    375390        }
    376         threadHookMutex.enter();
     391        EnterCriticalSection(&threadCritSect);
    377392        prevHook = (HOOKDATA **)&teb->o.odin.hooks[data->id - WH_MINHOOK];
    378393    }
    379394    else {
    380         systemHookMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalHookMutex);
     395        SYSTEMHOOK_LOCK();
    381396        prevHook = (HOOKDATA **)&HOOK_systemHooks[data->id - WH_MINHOOK];
    382397    }
     
    386401    if (!prevHook) {
    387402        if (data->ownerThread) {
    388                 threadHookMutex.leave();
     403                LeaveCriticalSection(&threadCritSect);
    389404        }
    390         else    systemHookMutex.leave(&hGlobalHookMutex);
     405        else    SYSTEMHOOK_UNLOCK();
    391406
    392407        return FALSE;
     
    395410
    396411    if (data->ownerThread) {
    397          threadHookMutex.leave();
    398     }
    399     else systemHookMutex.leave(&hGlobalHookMutex);
     412         LeaveCriticalSection(&threadCritSect);
     413    }
     414    else SYSTEMHOOK_UNLOCK();
    400415
    401416    HeapFree(GetProcessHeap(), 0, (LPVOID)data );
  • trunk/src/user32/syscolor.cpp

    r5951 r5973  
    1 /* $Id: syscolor.cpp,v 1.27 2001-06-10 12:05:39 sandervl Exp $ */
     1/* $Id: syscolor.cpp,v 1.28 2001-06-12 17:02:35 sandervl Exp $ */
    22
    33/*
     
    258258  }
    259259  dprintf(("GetSysColorBrush %d returned %x ", nIndex, ((nIndex >= 0) && (nIndex < NUM_SYS_COLORS)) ? SysColorBrushes[nIndex]:0));
    260   return ((nIndex >= 0) && (nIndex < NUM_SYS_COLORS)) ? SysColorBrushes[nIndex]:0;
     260  if( ((nIndex >= 0) && (nIndex < NUM_SYS_COLORS))  )
     261      return SysColorBrushes[nIndex];
     262
     263  //MED calls FillRect with (hardcoded) zero brush -> index -1
     264  dprintf2(("WARNING: Unknown index(%d)", nIndex ));
     265  return GetStockObject(LTGRAY_BRUSH);
    261266}
    262267/***********************************************************************
  • trunk/src/user32/user32.cpp

    r5951 r5973  
    1 /* $Id: user32.cpp,v 1.99 2001-06-10 12:05:40 sandervl Exp $ */
     1/* $Id: user32.cpp,v 1.100 2001-06-12 17:02:36 sandervl Exp $ */
    22
    33/*
     
    14261426/* Filled Shape Functions */
    14271427
     1428  /* Last COLOR id */
     1429#define COLOR_MAX   COLOR_GRADIENTINACTIVECAPTION
    14281430
    14291431int WIN32API FillRect(HDC hDC, const RECT * lprc, HBRUSH hbr)
    14301432{
     1433    if (hbr <= (HBRUSH) (COLOR_MAX + 1)) {
     1434        hbr = GetSysColorBrush( (INT) hbr - 1 );
     1435    }
    14311436    dprintf(("USER32:  FillRect %x (%d,%d)(%d,%d) brush %X", hDC, lprc->left, lprc->top, lprc->right, lprc->bottom, hbr));
    14321437    return O32_FillRect(hDC,lprc,hbr);
  • trunk/src/user32/win32wbase.cpp

    r5968 r5973  
    1 /* $Id: win32wbase.cpp,v 1.264 2001-06-11 20:08:24 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.265 2001-06-12 17:02:41 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    653653    if (windowClass->getStyle() & CS_CLASSDC)  {
    654654        dprintf(("WARNING: Class with CS_CLASSDC style!"));
    655         ownDC = 0;
     655        //not a good solution, but it's a bit difficult to share a single
     656        //DC among different windows... DevOpenDC apparently can't be used
     657        //for window DCs and WinOpenWindowDC must be associated with a window
     658        ownDC = GetDCEx(getWindowHandle(), NULL, DCX_USESTYLE);
    656659    }
    657660    /* Set the window menu */
  • trunk/src/user32/win32wbase.h

    r5935 r5973  
    1 /* $Id: win32wbase.h,v 1.118 2001-06-09 14:50:21 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.119 2001-06-12 17:02:42 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    471471         VOID  AdjustTrackInfo(PPOINT minTrackSize,PPOINT maxTrackSize);
    472472
     473         //Temporary hack for CS_CLASSDC style (do the same as for CS_OWNDC)
    473474#ifndef OS2_INCLUDED
    474          BOOL   isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC); }
     475         BOOL   isOwnDC() { return (windowClass && windowClass->getStyle() & (CS_OWNDC|CS_CLASSDC)); }
    475476#else
    476          BOOL   isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
     477         BOOL   isOwnDC() { return (windowClass && windowClass->getStyle() & (CS_OWNDC_W|CS_CLASSDC_W)); }
    477478#endif
    478479
  • trunk/src/user32/win32wbasenonclient.cpp

    r5951 r5973  
    1 /* $Id: win32wbasenonclient.cpp,v 1.32 2001-06-10 12:05:41 sandervl Exp $ */
     1/* $Id: win32wbasenonclient.cpp,v 1.33 2001-06-12 17:02:42 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (non-client methods)
     
    10301030
    10311031    dprintf(("DoNCPaint %x %x %d", getWindowHandle(), clip, suppress_menupaint));
    1032     DecreaseLogCount();
    10331032
    10341033    rect.top    = rect.left = 0;
     
    10611060                         ((clip > 1) ?(DCX_INTERSECTRGN /*| DCX_KEEPCLIPRGN*/) : 0) ))) return;
    10621061
     1062    DecreaseLogCount();
    10631063    SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
    10641064
     
    11591159    }
    11601160
     1161    IncreaseLogCount();
    11611162    ReleaseDC(getWindowHandle(),hdc);
    1162     IncreaseLogCount();
    11631163    dprintf(("**DoNCPaint %x DONE", getWindowHandle()));
    11641164}
Note: See TracChangeset for help on using the changeset viewer.