/[rdesktop]/sourceforge.net/trunk/seamlessrdp/ServerExe/HookDll/hookdll.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/seamlessrdp/ServerExe/HookDll/hookdll.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1153 by ossman_, Fri Mar 17 09:55:35 2006 UTC revision 1158 by ossman_, Fri Mar 17 13:11:20 2006 UTC
# Line 46  int g_instance_count SHARED = 0; Line 46  int g_instance_count SHARED = 0;
46    
47  // blocks for locally generated events  // blocks for locally generated events
48  RECT g_block_move SHARED = { 0, 0, 0, 0 };  RECT g_block_move SHARED = { 0, 0, 0, 0 };
49    HWND g_blocked_zchange[2] SHARED = { NULL, NULL };
50    HWND g_blocked_focus SHARED = NULL;
51    
52  #pragma data_seg ()  #pragma data_seg ()
53    
# Line 162  wndproc_hook_proc(int code, WPARAM cur_t Line 164  wndproc_hook_proc(int code, WPARAM cur_t
164    
165                                  if (!(wp->flags & SWP_NOZORDER))                                  if (!(wp->flags & SWP_NOZORDER))
166                                  {                                  {
167                                          vchannel_write("ZCHANGE,0x%p,0x%p,0x%x",                                          HWND block_hwnd, block_behind;
168                                                         hwnd,                                          WaitForSingleObject(g_mutex, INFINITE);
169                                                         wp->flags & SWP_NOACTIVATE ? wp->                                          block_hwnd = g_blocked_zchange[0];
170                                                         hwndInsertAfter : 0, 0);                                          block_behind = g_blocked_zchange[1];
171                                            ReleaseMutex(g_mutex);
172    
173                                            if ((hwnd != block_hwnd)
174                                                || (wp->hwndInsertAfter != block_behind))
175                                            {
176                                                    vchannel_write("ZCHANGE,0x%p,0x%p,0x%x",
177                                                                   hwnd,
178                                                                   wp->flags & SWP_NOACTIVATE ? wp->
179                                                                   hwndInsertAfter : 0, 0);
180                                            }
181                                  }                                  }
182    
183                                  break;                                  break;
# Line 222  wndprocret_hook_proc(int code, WPARAM cu Line 234  wndprocret_hook_proc(int code, WPARAM cu
234          if ((style & WS_CHILD) && !(style & WS_POPUP))          if ((style & WS_CHILD) && !(style & WS_POPUP))
235                  goto end;                  goto end;
236    
237            if (style & WS_POPUP)
238            {
239                    parent = (HWND) GetWindowLong(hwnd, GWL_HWNDPARENT);
240                    if (!parent)
241                            parent = (HWND) - 1;
242            }
243            else
244                    parent = NULL;
245    
246          switch (msg)          switch (msg)
247          {          {
248                  case WM_SETTEXT:                  case WM_SETTEXT:
# Line 242  wndprocret_hook_proc(int code, WPARAM cu Line 263  wndprocret_hook_proc(int code, WPARAM cu
263          }          }
264    
265          if (msg == g_wm_seamless_focus)          if (msg == g_wm_seamless_focus)
266                  SetFocus(hwnd);          {
267                    /* FIXME: SetActiveWindow() kills menus. Need to find a clean
268                       way to solve this. */
269                    if ((GetActiveWindow() != hwnd) && !parent)
270                            SetActiveWindow(hwnd);
271            }
272    
273        end:        end:
274          return CallNextHookEx(g_wndprocret_hook, code, cur_thread, details);          return CallNextHookEx(g_wndprocret_hook, code, cur_thread, details);
# Line 330  SafeMoveWindow(HWND hwnd, int x, int y, Line 356  SafeMoveWindow(HWND hwnd, int x, int y,
356          ReleaseMutex(g_mutex);          ReleaseMutex(g_mutex);
357  }  }
358    
359    DLL_EXPORT void
360    SafeZChange(HWND hwnd, HWND behind)
361    {
362            if (behind == NULL)
363                    behind = HWND_TOP;
364    
365            WaitForSingleObject(g_mutex, INFINITE);
366            g_blocked_zchange[0] = hwnd;
367            g_blocked_zchange[1] = behind;
368            ReleaseMutex(g_mutex);
369    
370            SetWindowPos(hwnd, behind, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
371    
372            WaitForSingleObject(g_mutex, INFINITE);
373            g_blocked_zchange[0] = NULL;
374            g_blocked_zchange[1] = NULL;
375            ReleaseMutex(g_mutex);
376    }
377    
378    DLL_EXPORT void
379    SafeFocus(HWND hwnd)
380    {
381            WaitForSingleObject(g_mutex, INFINITE);
382            g_blocked_focus = hwnd;
383            ReleaseMutex(g_mutex);
384    
385            SendMessage(hwnd, g_wm_seamless_focus, 0, 0);
386    
387            WaitForSingleObject(g_mutex, INFINITE);
388            g_blocked_focus = NULL;
389            ReleaseMutex(g_mutex);
390    }
391    
392  DLL_EXPORT int  DLL_EXPORT int
393  GetInstanceCount()  GetInstanceCount()
394  {  {

Legend:
Removed from v.1153  
changed lines
  Added in v.1158

  ViewVC Help
Powered by ViewVC 1.1.26