Author: fireball Date: Thu Aug 6 10:51:18 2009 New Revision: 42415
URL: http://svn.reactos.org/svn/reactos?rev=42415&view=rev Log: - Add a private window data storage support associated with each window via window properties. Could be improved in the future if using SetProp/GetProp proves to be very slow (it is in wine, but not in arwinss).
Added: branches/arwinss/reactos/dll/win32/winent.drv/wnd.c (with props) Modified: branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c branches/arwinss/reactos/dll/win32/winent.drv/winent.h branches/arwinss/reactos/dll/win32/winent.drv/winent.rbuild
Modified: branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent... ============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c [iso-8859-1] Thu Aug 6 10:51:18 2009 @@ -467,7 +467,8 @@
void CDECL RosDrv_DestroyWindow( HWND hwnd ) { - UNIMPLEMENTED; + /* Destroy its window data */ + NTDRV_destroy_win_data( hwnd ); }
void CDECL RosDrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect, @@ -665,7 +666,16 @@ const RECT *window_rect, const RECT *client_rect, RECT *visible_rect ) { - //UNIMPLEMENTED; + DWORD style = GetWindowLongW( hwnd, GWL_STYLE ); + struct ntdrv_win_data *data = NTDRV_get_win_data(hwnd); + + if (!data) + { + /* create the win data if the window is being made visible */ + if (!(style & WS_VISIBLE) && !(swp_flags & SWP_SHOWWINDOW)) return; + if (!(data = NTDRV_create_win_data( hwnd ))) return; + } + *visible_rect = *window_rect; }
@@ -681,12 +691,21 @@ old_whole_rect = whole_rect; old_client_rect = client_rect; #endif + RECT old_whole_rect; + + struct ntdrv_win_data *data = NTDRV_get_win_data(hwnd);
if (valid_rects) { TRACE("valid_rects[0] (%d, %d)-(%d,%d)\n", valid_rects[0].top, valid_rects[0].left, valid_rects[0].bottom, valid_rects[0].right); } + + if (!data) return; + + ERR("old rect %s, new rect %s\n", + wine_dbgstr_rect(&data->whole_rect), wine_dbgstr_rect(window_rect)); + #if 0 if (!IsRectEmpty( &valid_rects[0] )) {
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] Thu Aug 6 10:51:18 2009 @@ -29,6 +29,15 @@ int gl_copy; /* whether the GL contents need explicit copying */ };
+/* ntdrv private window data */ +struct ntdrv_win_data +{ + HWND hwnd; /* hwnd that this private data belongs to */ + RECT window_rect; /* USER window rectangle relative to parent */ + RECT whole_rect; /* X window rectangle for the whole window relative to parent */ + RECT client_rect; /* client area relative to parent */ +}; + /* font.c */ VOID FeSelectFont(NTDRV_PDEVICE *physDev, HFONT hFont); @@ -49,3 +58,8 @@ LRESULT HOOK_CallHooks( INT id, INT code, WPARAM wparam, LPARAM lparam, BOOL unicode );
BOOL CDECL RosDrv_GetCursorPos( LPPOINT pt ); + +/* wnd.c */ +struct x11drv_win_data *X11DRV_get_win_data( HWND hwnd ); +struct x11drv_win_data *X11DRV_create_win_data( HWND hwnd ); +void NTDRV_destroy_win_data( HWND hwnd );
Modified: branches/arwinss/reactos/dll/win32/winent.drv/winent.rbuild URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent... ============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/winent.rbuild [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/winent.rbuild [iso-8859-1] Thu Aug 6 10:51:18 2009 @@ -10,6 +10,7 @@ <file>main.c</file> <file>userdrv.c</file> <file>mouse.c</file> + <file>wnd.c</file>
<file>winent.rc</file>
Added: branches/arwinss/reactos/dll/win32/winent.drv/wnd.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent... ============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/wnd.c (added) +++ branches/arwinss/reactos/dll/win32/winent.drv/wnd.c [iso-8859-1] Thu Aug 6 10:51:18 2009 @@ -1,0 +1,119 @@ +/* + * PROJECT: ReactOS + * LICENSE: LGPL + * FILE: dll/win32/winent.drv/wnd.c + * PURPOSE: Windows related functions + * PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org) + */ + +/* INCLUDES ***************************************************************/ + +#include <stdarg.h> +#include <stdio.h> +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "wingdi.h" +#define NTOS_USER_MODE +#include <ndk/ntndk.h> +#include "ntrosgdi.h" +#include "winent.h" +#include "wine/server.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(rosuserdrv); + +static const char window_data_prop[] = "__ros_nt_window_data"; + +/* FUNCTIONS **************************************************************/ + +VOID CDECL RosDrv_UpdateZOrder(HWND hwnd, RECT *rect) +{ + FIXME("hwnd %x rect (%d, %d)-(%d,%d)\n", hwnd, + rect->top, rect->left, rect->bottom, rect->right); + + SERVER_START_REQ( update_window_zorder ) + { + req->window = wine_server_user_handle( hwnd ); + req->rect.left = rect->left; + req->rect.top = rect->top; + req->rect.right = rect->right; + req->rect.bottom = rect->bottom; + wine_server_call( req ); + } + SERVER_END_REQ; +} + +/*********************************************************************** + * NTDRV_get_win_data + * + * Return the private data structure associated with a window. + */ +struct ntdrv_win_data *NTDRV_get_win_data( HWND hwnd ) +{ + struct ntdrv_win_data *data; + + if (!hwnd) return NULL; + + data = (struct ntdrv_win_data *)GetPropA( hwnd, window_data_prop ); + + return data; +} + + +/*********************************************************************** + * NTDRV_create_win_data + * + * Create a private data window structure for an existing window. + */ +struct ntdrv_win_data *NTDRV_create_win_data( HWND hwnd ) +{ + struct ntdrv_win_data *data; + HWND parent; + + if (!(parent = GetAncestor( hwnd, GA_PARENT ))) return NULL; /* desktop */ + + /* don't create win data for HWND_MESSAGE windows */ + if (parent != GetDesktopWindow() && !GetAncestor( parent, GA_PARENT )) return NULL; + + data = HeapAlloc(GetProcessHeap(), 0, sizeof(struct ntdrv_win_data)); + if (!data) return NULL; + + /* Add it as a property to the window */ + SetPropA( hwnd, window_data_prop, (HANDLE)data ); + + GetWindowRect( hwnd, &data->window_rect ); + MapWindowPoints( 0, parent, (POINT *)&data->window_rect, 2 ); + data->whole_rect = data->window_rect; + GetClientRect( hwnd, &data->client_rect ); + MapWindowPoints( hwnd, parent, (POINT *)&data->client_rect, 2 ); + + if (parent == GetDesktopWindow()) + { + TRACE( "win %p window %s whole %s client %s\n", + hwnd, wine_dbgstr_rect( &data->window_rect ), + wine_dbgstr_rect( &data->whole_rect ), wine_dbgstr_rect( &data->client_rect )); + } + return data; +} + +/*********************************************************************** + * NTDRV_destroy_win_data + * + * Deletes a private data window structure for an existing window. + */ +void NTDRV_destroy_win_data( HWND hwnd ) +{ + struct ntdrv_win_data *data = NTDRV_get_win_data(hwnd); + if (!data) return; + + /* Remove property */ + RemovePropA( hwnd, window_data_prop ); + + /* Free window data */ + HeapFree( GetProcessHeap(), 0, data ); +} + + +/* EOF */
Propchange: branches/arwinss/reactos/dll/win32/winent.drv/wnd.c ------------------------------------------------------------------------------ svn:eol-style = native