Author: fireball Date: Wed Jan 12 10:34:41 2011 New Revision: 50364
URL: http://svn.reactos.org/svn/reactos?rev=50364&view=rev Log: - Change SWM API to use window id's instead of hwnds. - Deprecate RosGdiReleaseDC, the DC always have a window selected (either root one if it's released, or the one passed via GetDC). - Use "good" version of code in RosDrv_GetDC, getting rid of old GetAncestor hack. - Change include order of ntrosgdi.h and rosuser.h. The latter one must always be included before ntrosgdi one. - Kernelmode DC-related changes: * Save DC type, because clipping will be different for memory and window DCs. * Always select a window for OBJ_DC. In the default mode a root window is selected. * Simplify clipping calculations, make them transparent and understandable, remove dummy window hack. - SWM changes: * Add an always existing root_window, which is used now instead of a number of dynamically created desktop windows. * Add SWM window events structures and definitions. Unused now, and future usage is still subject for further experiments. - One problem is introduced, which leads to inability to get a full screen DC (it will be clipped by children). To be fixed by next commits introducing clipping properties.
Modified: branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c branches/arwinss/reactos/dll/win32/winent.drv/window.c branches/arwinss/reactos/dll/win32/winent.drv/winent.h branches/arwinss/reactos/include/reactos/wine/ntrosgdi.h branches/arwinss/reactos/include/reactos/wine/rosuser.h branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c branches/arwinss/reactos/subsystems/win32/win32k/include/dc.h branches/arwinss/reactos/subsystems/win32/win32k/include/swm.h branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c branches/arwinss/reactos/subsystems/win32/win32k/win32k.rbuild
Modified: branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent... ============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -213,10 +213,7 @@ physDev->dc_rect = data->dc_rect; RosGdiSetDcRects(physDev->hKernelDC, NULL, (RECT*)&data->drawable_rect);
- if (!data->release) - RosGdiGetDC(physDev->hKernelDC, data->hwnd, data->clip_children); - else - RosGdiReleaseDC(physDev->hKernelDC); + RosGdiGetDC(physDev->hKernelDC, data->drawable, data->clip_children);
TRACE( "SET_DRAWABLE hdc %p dc_rect %s drawable_rect %s\n", physDev->hdc, wine_dbgstr_rect(&data->dc_rect), wine_dbgstr_rect(&data->drawable_rect) );
Modified: branches/arwinss/reactos/dll/win32/winent.drv/window.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent... ============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/window.c [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/window.c [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -355,7 +355,7 @@ //GrRaiseWindow(data->whole_window); //changes.stack_mode = Above; //mask |= CWStackMode; - SwmSetForeground(data->hwnd); + SwmSetForeground(data->whole_window); } /* should use stack_mode Below but most window managers don't get it right */ /* and Above with a sibling doesn't work so well either, so we ignore it */ @@ -491,38 +491,31 @@ { int cx, cy; GR_WINDOW_ID client; - - /*attr.bit_gravity = NorthWestGravity; - attr.win_gravity = NorthWestGravity; - attr.backing_store = NotUseful; - attr.event_mask = (ExposureMask | PointerMotionMask | - ButtonPressMask | ButtonReleaseMask | EnterWindowMask); - mask = CWEventMask | CWBitGravity | CWWinGravity | CWBackingStore;*/ + RECT winRect;
if ((cx = data->client_rect.right - data->client_rect.left) <= 0) cx = 1; else if (cx > 65535) cx = 65535; if ((cy = data->client_rect.bottom - data->client_rect.top) <= 0) cy = 1; else if (cy > 65535) cy = 65535;
- client = (GR_WINDOW_ID)1;//GrNewWindow( data->whole_window, - // data->client_rect.left - data->whole_rect.left, - // data->client_rect.top - data->whole_rect.top, - // cx, cy, 0, RGB(255,255,255), 0 ); - + winRect.left = data->client_rect.left - data->whole_rect.left; + winRect.top = data->client_rect.top - data->whole_rect.top; + winRect.right = winRect.left + cx; + winRect.bottom = winRect.top + cy; + + client = data->whole_window;//SwmNewWindow( data->whole_window, &winRect, data->hwnd, 0 ); if (!client) { return 0; }
- //GrSelectEvents(client, GR_EVENT_MASK_EXPOSURE); - if (data->client_window) { - //GrDestroyWindow( data->client_window ); + //SwmDestroyWindow( data->client_window ); } data->client_window = client;
- //GrMapWindow( data->client_window ); + //SwmShowWindow( data->client_window, TRUE, 0 );
SetPropA( data->hwnd, client_window_prop, (HANDLE)data->client_window ); return data->client_window; @@ -571,11 +564,6 @@
if (!data->whole_window) goto done;
- /* Set override_redirect */ - //props.props = GR_WM_PROPS_NODECORATE; - //props.flags = GR_WM_FLAGS_PROPS; - //GrSetWMProperties(data->whole_window, &props); - if (!create_client_window( data )) { SwmDestroyWindow( data->whole_window ); @@ -625,9 +613,8 @@ /*********************************************************************** * NTDRV_get_client_window * - * Return the X window associated with the client area of a window - */ -#if 0 + * Return the SWM window associated with the client area of a window + */ static GR_WINDOW_ID NTDRV_get_client_window( HWND hwnd ) { struct ntdrv_win_data *data = NTDRV_get_win_data( hwnd ); @@ -639,7 +626,7 @@ } return data->client_window; } -#endif + /*********************************************************************** * NTDRV_GetDC (NTDRV.@) */ @@ -647,8 +634,8 @@ const RECT *top_rect, DWORD flags ) { struct ntdrv_escape_set_drawable escape; - //struct ntdrv_win_data *data = NTDRV_get_win_data( hwnd ); - //HWND parent; + struct ntdrv_win_data *data = NTDRV_get_win_data( hwnd ); + HWND parent;
escape.code = NTDRV_SET_DRAWABLE; escape.clip_children = FALSE; @@ -664,7 +651,7 @@ escape.drawable_rect.top = top_rect->top; escape.drawable_rect.right = top_rect->right; escape.drawable_rect.bottom = top_rect->bottom; -#if GOOD_VERSION + if (top == hwnd) { if (flags & DCX_WINDOW) @@ -692,9 +679,6 @@
if (flags & DCX_CLIPCHILDREN) escape.clip_children = TRUE; } -#else - escape.hwnd = GetAncestor(hwnd, GA_ROOT); -#endif
TRACE("hdc %x, hwnd %x, top %x\n win_rect %s, top_rect %s\n", hdc, hwnd, top, wine_dbgstr_rect(win_rect), wine_dbgstr_rect(top_rect)); @@ -788,8 +772,7 @@ TRACE("SetFocus %x, desk %x\n", hwnd, GetDesktopWindow());
/* Bring this window to foreground */ - SwmSetForeground(hwnd); - //GrRaiseWindow(data->whole_window); + SwmSetForeground(data->whole_window); }
/***********************************************************************
Modified: branches/arwinss/reactos/dll/win32/winent.drv/winent.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent... ============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/winent.h [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/winent.h [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -31,8 +31,8 @@ #include <ndk/ntndk.h> #include <winddi.h> #include <win32k/ntgdityp.h> -#include "ntrosgdi.h" #include "wine/rosuser.h" +#include "wine/ntrosgdi.h" #include "wine/list.h" #include "wine/unicode.h" #include "wine/server.h"
Modified: branches/arwinss/reactos/include/reactos/wine/ntrosgdi.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/include/reactos/... ============================================================================== --- branches/arwinss/reactos/include/reactos/wine/ntrosgdi.h [iso-8859-1] (original) +++ branches/arwinss/reactos/include/reactos/wine/ntrosgdi.h [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -110,7 +110,7 @@ const PIXELFORMATDESCRIPTOR *ppfd); COLORREF APIENTRY RosGdiSetTextColor( HDC physDev, COLORREF color ); VOID APIENTRY RosGdiSetDcRects( HDC physDev, RECT *rcDcRect, RECT *rcVport ); -VOID APIENTRY RosGdiGetDC( HDC physDev, HWND hwnd, BOOL clipChildren ); +VOID APIENTRY RosGdiGetDC( HDC physDev, GR_WINDOW_ID Wid, BOOL clipChildren ); VOID APIENTRY RosGdiReleaseDC( HDC physDev );
/* enum.c */
Modified: branches/arwinss/reactos/include/reactos/wine/rosuser.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/include/reactos/... ============================================================================== --- branches/arwinss/reactos/include/reactos/wine/rosuser.h [iso-8859-1] (original) +++ branches/arwinss/reactos/include/reactos/wine/rosuser.h [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -15,11 +15,49 @@
#define SWM_ROOT_WINDOW_ID 1
+#define SWM_EVENT_TYPE_NONE 0 +#define SWM_EVENT_TYPE_EXPOSURE 1 + +/* Event masks */ +#define SWM_EVENTMASK(n) (((ULONG) 1) << (n)) + +#define SWM_EVENT_MASK_NONE SWM_EVENTMASK(SWM_EVENT_TYPE_NONE) +#define SWM_EVENT_MASK_EXPOSURE SWM_EVENTMASK(SWM_EVENT_TYPE_EXPOSURE) + /* ENUMERATIONS **************************************************************/
/* TYPES *********************************************************************/
typedef ULONG_PTR GR_WINDOW_ID; +typedef ULONG SWM_EVENT_TYPE; + +typedef struct +{ + SWM_EVENT_TYPE type; /**< event type */ + GR_WINDOW_ID wid; /**< window id */ + GR_WINDOW_ID otherid; /**< new/old focus id for focus events*/ + /**< for mouse enter only the following are valid:*/ + LONG rootx; /**< root window x coordinate */ + LONG rooty; /**< root window y coordinate */ + LONG x; /**< window x coordinate of mouse */ + LONG y; /**< window y coordinate of mouse */ +} SWM_EVENT_GENERAL; + +typedef struct { + SWM_EVENT_TYPE type; /**< event type */ + GR_WINDOW_ID wid; /**< window id */ + LONG x; /**< window x coordinate of exposure */ + LONG y; /**< window y coordinate of exposure */ + LONG width; /**< width of exposure */ + LONG height; /**< height of exposure */ +} SWM_EVENT_EXPOSURE; + +typedef union +{ + SWM_EVENT_TYPE type; /**< event type */ + SWM_EVENT_GENERAL general; /**< general window events */ + SWM_EVENT_EXPOSURE exposure; /**< exposure events */ +} SWM_EVENT;
/* FUNCTIONS *****************************************************************/
@@ -187,7 +225,7 @@ SwmDestroyWindow(GR_WINDOW_ID Wid);
VOID NTAPI -SwmSetForeground(HWND hWnd); +SwmSetForeground(GR_WINDOW_ID Wid);
VOID NTAPI SwmPosChanged(GR_WINDOW_ID Wid, const RECT *WindowRect, const RECT *OldRect, HWND hWndAfter, UINT SwpFlags); @@ -198,4 +236,10 @@ VOID NTAPI SwmShowWindow(GR_WINDOW_ID Wid, BOOLEAN Show, UINT SwpFlags);
+int NTAPI +SwmPeekEvent(SWM_EVENT *ep); + +VOID NTAPI +SwmGetNextEvent(SWM_EVENT *ep); + #endif /* __WIN32K_NTUSER_H */
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -303,6 +303,8 @@ { BOOLEAN bRet; PDC pDst; + + DPRINT("PatBlt hdc %x, offs (%d,%d), w %d, h %d\n", physDev, left, top, width, height);
/* Get a pointer to the DCs */ pDst = DC_LockDc(physDev);
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -97,6 +97,8 @@ pNewDC->dclevel.hpal = StockObjects[DEFAULT_PALETTE]; pNewDC->dclevel.ppal = PALETTE_ShareLockPalette(pNewDC->dclevel.hpal);
+ pNewDC->type = dcType; + if (dcType == OBJ_MEMDC) { DPRINT("Creating a memory DC %x\n", hNewDC); @@ -105,6 +107,8 @@ /* Set DC rectangles */ pNewDC->rcVport.left = 0; pNewDC->rcVport.top = 0; pNewDC->rcVport.right = 1; pNewDC->rcVport.bottom = 1; + + pNewDC->pWindow = NULL; } else { @@ -116,15 +120,19 @@ pNewDC->rcVport.top = 0; pNewDC->rcVport.right = PrimarySurface.gdiinfo.ulHorzRes; pNewDC->rcVport.bottom = PrimarySurface.gdiinfo.ulVertRes; + + pNewDC->pWindow = &SwmRoot; }
/* Create an empty combined clipping region */ pNewDC->CombinedClip = EngCreateClip(); - pNewDC->Clipping = create_empty_region(); - pNewDC->pWindow = NULL; + pNewDC->Clipping = NULL;
/* Set default palette */ pNewDC->dclevel.hpal = StockObjects[DEFAULT_PALETTE]; + + /* Calculate new combined clipping region */ + RosGdiUpdateClipping(pNewDC, FALSE);
/* Give handle to the caller */ *pdev = hNewDC; @@ -407,34 +415,72 @@ return 0; }
-VOID APIENTRY RosGdiUpdateClipping(PDC pDC) -{ - struct region *inter; - if (!pDC->pWindow) - { - /* Easy case, just copy the existing clipping region */ +VOID APIENTRY RosGdiUpdateClipping(PDC pDC, BOOLEAN IgnoreVisibility) +{ + struct region *window, *surface; + rectangle_t surfrect = {0,0,0,0}; + + surface = create_empty_region(); + surfrect.right = pDC->dclevel.pSurface->SurfObj.sizlBitmap.cx; + surfrect.bottom = pDC->dclevel.pSurface->SurfObj.sizlBitmap.cy; + set_region_rect(surface, &surfrect); + + if (pDC->type == OBJ_MEMDC) + { + /* underlying surface rect X user clipping (if any) */ if (pDC->CombinedClip) EngDeleteClip(pDC->CombinedClip); - pDC->CombinedClip = IntEngCreateClipRegionFromRegion(pDC->Clipping); + + if (pDC->Clipping) + intersect_region(surface, surface, pDC->Clipping); + + pDC->CombinedClip = IntEngCreateClipRegionFromRegion(surface); } else { - /* Intersect with window's visibility */ - inter = create_empty_region(); - copy_region(inter, pDC->Clipping); + if (!pDC->pWindow) + { + /* Drawing is forbidden */ + if (pDC->CombinedClip) EngDeleteClip(pDC->CombinedClip); + pDC->CombinedClip = EngCreateClip(); + return; + } + + /* window visibility X user clipping (if any) X underlying surface */
/* Acquire SWM lock */ SwmAcquire();
- /* Intersect current clipping region and window's visible region */ - intersect_region(inter, inter, pDC->pWindow->Visible); - - /* Release SWM lock */ - SwmRelease(); - - if (pDC->CombinedClip) EngDeleteClip(pDC->CombinedClip); - pDC->CombinedClip = IntEngCreateClipRegionFromRegion(inter); - free_region(inter); - } + //window = SwmSetClipWindow(pDC->pWindow, NULL, pDC->ExcludeChildren); + window = pDC->pWindow->Visible; + + if (window) + { + /* Intersect window's visible region X underlying surface */ + if (!IgnoreVisibility) + intersect_region(surface, surface, window); + + /* Intersect result X user clipping (if any) */ + if (pDC->Clipping) + intersect_region(surface, surface, pDC->Clipping); + + /* Release SWM lock */ + SwmRelease(); + + if (pDC->CombinedClip) EngDeleteClip(pDC->CombinedClip); + pDC->CombinedClip = IntEngCreateClipRegionFromRegion(surface); + } + else + { + /* Release SWM lock */ + SwmRelease(); + + /* Drawing is forbidden */ + if (pDC->CombinedClip) EngDeleteClip(pDC->CombinedClip); + pDC->CombinedClip = EngCreateClip(); + } + } + + free_region(surface); }
void APIENTRY RosGdiSetDeviceClipping( HDC physDev, UINT count, PRECTL pRects, PRECTL rcBounds ) @@ -442,7 +488,7 @@ PDC pDC; RECTL pStackBuf[8]; RECTL *pSafeRects = pStackBuf; - RECTL rcSafeBounds; + RECTL rcSafeBounds = {0}; ULONG i; NTSTATUS Status = STATUS_SUCCESS;
@@ -503,19 +549,9 @@ if (pDC->Clipping) free_region(pDC->Clipping);
- if (count == 0) - { - /* Set unclipped mode (underlying surface rectangle) */ - RECTL_vSetRect(&rcSafeBounds, - 0, - 0, - pDC->dclevel.pSurface->SurfObj.sizlBitmap.cx, - pDC->dclevel.pSurface->SurfObj.sizlBitmap.cy); - - /* Set the clipping object */ - pDC->Clipping = create_region_from_rects(&rcSafeBounds, 1); - } - else + pDC->Clipping = NULL; + + if (count) { /* Set the clipping object */ pDC->Clipping = create_region_from_rects(pSafeRects, count); @@ -531,7 +567,7 @@ }
/* Update the combined clipping */ - RosGdiUpdateClipping(pDC); + RosGdiUpdateClipping(pDC, FALSE);
/* Release the object */ DC_UnlockDc(pDC); @@ -593,7 +629,7 @@ DC_UnlockDc(pDC); }
-VOID APIENTRY RosGdiGetDC(HDC physDev, HWND hwnd, BOOL clipChildren) +VOID APIENTRY RosGdiGetDC(HDC physDev, GR_WINDOW_ID Wid, BOOL clipChildren) { PDC pDC;
@@ -604,16 +640,16 @@ pDC = DC_LockDc(physDev);
/* Get a pointer to this window */ - if (hwnd) - pDC->pWindow = SwmFindByHwnd(hwnd); - - /* Handle situation when drawing is forbidden */ - if (!hwnd || !pDC->pWindow) - { - /* Make up a dummy window object which will have empty visibility */ - pDC->pWindow = ExAllocatePool(PagedPool, sizeof(SWM_WINDOW)); - RtlZeroMemory(pDC->pWindow, sizeof(SWM_WINDOW)); - pDC->pWindow->Visible = create_empty_region(); + if (Wid) + { + pDC->pWindow = SwmGetWindowById(Wid); + DPRINT("hdc %x set window hwnd %x\n", physDev, pDC->pWindow->hwnd); + } + else + { + /* Handle situation when drawing is forbidden */ + pDC->pWindow = NULL; + DPRINT("hdc %x, restricting any drawing\n", physDev); }
/* Release the object */ @@ -623,6 +659,7 @@ SwmRelease(); }
+//FIXME: to be deleted! VOID APIENTRY RosGdiReleaseDC(HDC physDev) { PDC pDC;
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/dc.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -21,6 +21,7 @@ PPDEVOBJ ppdev;
DCLEVEL dclevel; + ULONG type;
COLORREF crForegroundClr; COLORREF crBackgroundClr; @@ -42,7 +43,7 @@ #define DC_UnlockDc(pDC) \ GDIOBJ_UnlockObjByPtr ((PBASEOBJECT)pDC)
-VOID APIENTRY RosGdiUpdateClipping(PDC pDC); +VOID APIENTRY RosGdiUpdateClipping(PDC pDC, BOOLEAN IgnoreVisibility);
BOOL INTERNAL_CALL DC_Cleanup(PVOID ObjectBody);
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/swm.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/swm.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/swm.h [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -1,5 +1,11 @@ #ifndef SWM__H #define SWM__H + +typedef struct _SWM_EVENT_LIST SWM_EVENT_LIST; +struct _SWM_EVENT_LIST { + SWM_EVENT_LIST *next; /* next element in list */ + SWM_EVENT event; /* event */ +};
typedef struct _SWM_WINDOW { @@ -12,6 +18,7 @@ LIST_ENTRY Entry; } SWM_WINDOW, *PSWM_WINDOW;
+extern SWM_WINDOW SwmRoot;
VOID NTAPI SwmInitialize(); VOID NTAPI GrContextInit(); @@ -19,5 +26,6 @@ VOID NTAPI SwmAcquire(VOID); VOID NTAPI SwmRelease(VOID); HDC SwmGetScreenDC(); +PSWM_WINDOW NTAPI SwmGetWindowById(GR_WINDOW_ID Wid);
#endif
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -24,8 +24,8 @@ #include <wine/list.h>
/* RosGdi syscalls */ +#include <wine/rosuser.h> #include <wine/ntrosgdi.h> -#include <wine/rosuser.h>
/* CSR interaction */ #include <csr.h>
Modified: branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -31,6 +31,7 @@ LIST_ENTRY SwmWindows; ERESOURCE SwmLock; HDC SwmDc; /* Screen DC for copying operations */ +SWM_WINDOW SwmRoot;
/* FUNCTIONS *****************************************************************/
@@ -56,24 +57,11 @@ NTAPI SwmCreateScreenDc() { - PDC pDC; - RECTL rcBounds; - /* Create the display DC */ SwmDc = (HDC)0; RosGdiCreateDC(&SwmDc, NULL, NULL, NULL, NULL, OBJ_DC);
- /* Set clipping to full screen */ - pDC = DC_LockDc(SwmDc); - RECTL_vSetRect(&rcBounds, - 0, - 0, - pDC->rcVport.right, - pDC->rcVport.bottom); - IntEngDeleteClipRegion(pDC->CombinedClip); - pDC->CombinedClip = IntEngCreateClipRegion(1, &rcBounds, &rcBounds); - DC_UnlockDc(pDC); - //RosGdiSetDeviceClipping(SwmDc, 1, &rcBounds, &rcBounds); + DPRINT1("Screen hdc is %x\n", SwmDc);
/* Make it global */ GDIOBJ_SetOwnership(SwmDc, NULL); @@ -85,6 +73,16 @@ if (!SwmDc) SwmCreateScreenDc();
return SwmDc; +} + +PSWM_WINDOW +NTAPI +SwmGetWindowById(GR_WINDOW_ID Wid) +{ + /* Right now, Wid is a pointer to SWM_WINDOW structure, + except for SWM_ROOT_WINDOW_ID which maps to a root window */ + if (Wid == SWM_ROOT_WINDOW_ID) return &SwmRoot; + return (PSWM_WINDOW)Wid; }
VOID @@ -389,6 +387,7 @@ NTAPI SwmAddDesktopWindow(HWND hWnd, UINT Width, UINT Height) { +#if 0 PSWM_WINDOW Desktop;
/* Acquire the lock */ @@ -429,6 +428,10 @@
/* Release the lock */ SwmRelease(); +#endif + + SwmRoot.hwnd = hWnd; + SwmInvalidateRegion(&SwmRoot, SwmRoot.Visible, &SwmRoot.Window); }
PSWM_WINDOW @@ -470,8 +473,8 @@ /* Acquire the lock */ SwmAcquire();
- /* Allocate entry */ - Win = (PSWM_WINDOW)Wid; + /* Get window pointer */ + Win = SwmGetWindowById(Wid);
DPRINT("SwmRemoveWindow %x\n", Win->hwnd);
@@ -565,37 +568,31 @@
VOID NTAPI -SwmSetForeground(HWND hWnd) +SwmSetForeground(GR_WINDOW_ID Wid) { PSWM_WINDOW SwmWin; extern struct window *shell_window;
+ /* Acquire the lock */ + SwmAcquire(); + + /* Get the window pointer */ + SwmWin = SwmGetWindowById(Wid); + /* Check for a shell window */ UserEnterExclusive();
/* Don't allow the shell window to become foreground */ if(shell_window && - (get_window((UINT_PTR)hWnd) == shell_window)) - { + (get_window((UINT_PTR)SwmWin->hwnd) == shell_window)) + { + SwmRelease(); UserLeave(); return; }
UserLeave();
- /* Acquire the lock */ - SwmAcquire(); - - /* Allocate entry */ - SwmWin = SwmFindByHwnd(hWnd); - //ASSERT(SwmWin != NULL); - if (!SwmWin) - { - /* Release the lock */ - SwmRelease(); - return; - } - SwmBringToFront(SwmWin);
/* Release the lock */ @@ -606,7 +603,7 @@ NTAPI SwmCopyBits(const PSWM_WINDOW SwmWin, const RECT *OldRect) { - RECTL rcBounds; + //RECTL rcBounds; PDC pDC; PLIST_ENTRY Current; struct region *TempRegion, *ParentRegion, *WinRegion = NULL; @@ -627,7 +624,10 @@ rcScreen.top = 0; rcScreen.right = pDC->rcVport.right; rcScreen.bottom = pDC->rcVport.bottom; - set_region_rect(pDC->Clipping, &rcScreen); + + /* Free user clipping, if any */ + if (pDC->Clipping) free_region(pDC->Clipping); + pDC->Clipping = NULL;
ParentRegion = create_empty_region();
@@ -659,12 +659,17 @@ Current = Current->Blink; }
- /* Remove parts clipped by parents from the window region */ + /* Remove parts clipped by parents from the window region, and set result as a user clipping region */ if (!is_region_empty(ParentRegion)) - subtract_region(pDC->Clipping, pDC->Clipping, ParentRegion); + { + TempRegion = create_empty_region(); + set_region_rect(TempRegion, &rcScreen); + subtract_region(TempRegion, TempRegion, ParentRegion); + pDC->Clipping = TempRegion; + }
/* Set DC clipping */ - RosGdiUpdateClipping(pDC); + RosGdiUpdateClipping(pDC, TRUE);
/* Get the part which was previously hidden by parent area */ WinRegion = create_empty_region(); @@ -691,14 +696,13 @@ } else { - /* Simple case, use whole viewport as a clipping rect */ - RECTL_vSetRect(&rcBounds, - 0, - 0, - pDC->rcVport.right, - pDC->rcVport.bottom); - IntEngDeleteClipRegion(pDC->CombinedClip); - pDC->CombinedClip = IntEngCreateClipRegion(1, &rcBounds, &rcBounds); + /* Simple case, no clipping */ + + if (pDC->Clipping) free_region(pDC->Clipping); + pDC->Clipping = NULL; + + /* Set DC clipping */ + RosGdiUpdateClipping(pDC, TRUE); }
DC_UnlockDc(pDC); @@ -724,7 +728,7 @@ /* Acquire the lock */ SwmAcquire();
- SwmWin = (PSWM_WINDOW)Wid; + SwmWin = SwmGetWindowById(Wid);
/* Save parameters */ OldRectSafe.left = OldRect->left; OldRectSafe.top = OldRect->top; @@ -826,7 +830,7 @@ /* Acquire the lock */ SwmAcquire();
- Win = (PSWM_WINDOW)Wid; + Win = SwmGetWindowById(Wid);
DPRINT("SwmShowWindow %x, Show %d\n", Win->hwnd, Show);
@@ -935,6 +939,18 @@ { DPRINT1("Failure initializing SWM resource!\n"); } + + /* Initialize a root window */ + SwmRoot.Window.left = 0; + SwmRoot.Window.top = 0; + SwmRoot.Window.right = 800; //FIXME! + SwmRoot.Window.bottom = 600; //FIXME! + SwmRoot.Hidden = FALSE; + SwmRoot.Topmost = FALSE; + SwmRoot.Visible = create_empty_region(); + set_region_rect(SwmRoot.Visible, &SwmRoot.Window); + + InsertHeadList(&SwmWindows, &SwmRoot.Entry); }
/* EOF */
Modified: branches/arwinss/reactos/subsystems/win32/win32k/win32k.rbuild URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/win32k.rbuild [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/win32k.rbuild [iso-8859-1] Wed Jan 12 10:34:41 2011 @@ -133,6 +133,7 @@ </if> </directory> <directory name="swm"> + <file>swmevent.c</file> <file>winman.c</file> </directory> <directory name="wine">