CVS: seamlessrdp/ServerExe/HookDll hookdll.c,1.22,1.23
Pierre Ossman <[email protected]> Thu, 16 Mar 2006 05:24:20 -0800
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27431/ServerExe/HookDll
Modified Files:
hookdll.c
Log Message:
Prevent moves we do ourself from generating a POSITION. We do this by storing
the coordinate we're moving to in a shared variable. Since SetWindowPos is
synchronous, we know that the variable will have valid data when the hook
is called.
Index: hookdll.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll/hookdll.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** hookdll.c 15 Mar 2006 13:19:54 -0000 1.22
--- hookdll.c 16 Mar 2006 13:24:18 -0000 1.23
***************
*** 33,41 ****
#define DLL_EXPORT __declspec(dllexport)
// Shared DATA
#pragma data_seg ( "SHAREDDATA" )
// this is the total number of processes this dll is currently attached to
! int g_instance_count = 0;
#pragma data_seg ()
--- 33,50 ----
#define DLL_EXPORT __declspec(dllexport)
+ #ifdef __GNUC__
+ #define SHARED __attribute__((section ("SHAREDDATA"), shared))
+ #else
+ #define SHARED
+ #endif
+
// Shared DATA
#pragma data_seg ( "SHAREDDATA" )
// this is the total number of processes this dll is currently attached to
! int g_instance_count SHARED = 0;
!
! // blocks for locally generated events
! RECT g_block_move SHARED = { 0, 0, 0, 0 };
#pragma data_seg ()
***************
*** 54,58 ****
update_position(HWND hwnd)
{
! RECT rect;
if (!GetWindowRect(hwnd, &rect))
--- 63,67 ----
update_position(HWND hwnd)
{
! RECT rect, blocked;
if (!GetWindowRect(hwnd, &rect))
***************
*** 62,65 ****
--- 71,82 ----
}
+ WaitForSingleObject(g_mutex, INFINITE);
+ memcpy(&blocked, &g_block_move, sizeof(RECT));
+ ReleaseMutex(g_mutex);
+
+ if ((rect.left == blocked.left) && (rect.top == blocked.top)
+ && (rect.right == blocked.right) && (rect.bottom == blocked.bottom))
+ return;
+
vchannel_write("POSITION,0x%p,%d,%d,%d,%d,0x%x",
hwnd,
***************
*** 291,294 ****
--- 308,328 ----
}
+ DLL_EXPORT void
+ SafeMoveWindow(HWND hwnd, int x, int y, int width, int height)
+ {
+ WaitForSingleObject(g_mutex, INFINITE);
+ g_block_move.left = x;
+ g_block_move.top = y;
+ g_block_move.right = x + width;
+ g_block_move.bottom = y + height;
+ ReleaseMutex(g_mutex);
+
+ SetWindowPos(hwnd, NULL, x, y, width, height, SWP_NOACTIVATE | SWP_NOZORDER);
+
+ WaitForSingleObject(g_mutex, INFINITE);
+ memset(&g_block_move, 0, sizeof(RECT));
+ ReleaseMutex(g_mutex);
+ }
+
DLL_EXPORT int
GetInstanceCount()
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642