/[rdesktop]/sourceforge.net/trunk/seamlessrdp/ServerExe/main.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/main.c

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

revision 1077 by ossman_, Thu Mar 9 15:26:35 2006 UTC revision 1112 by ossman_, Fri Mar 10 16:14:37 2006 UTC
# Line 67  get_token(char **s) Line 67  get_token(char **s)
67          return head;          return head;
68  }  }
69    
70  static BOOL CALLBACK enum_cb(HWND hwnd, LPARAM lparam)  static BOOL CALLBACK
71    enum_cb(HWND hwnd, LPARAM lparam)
72  {  {
73          RECT rect;          RECT rect;
74          char title[150];          char title[150];
75          LONG styles;          LONG styles;
76          int state;          int state;
77            HWND parent;
78    
79          styles = GetWindowLong(hwnd, GWL_STYLE);          styles = GetWindowLong(hwnd, GWL_STYLE);
80    
81          if (!(styles & WS_VISIBLE))          if (!(styles & WS_VISIBLE))
82                  return TRUE;                  return TRUE;
83    
84          vchannel_write("CREATE1,0x%p,0x%x", hwnd, 0);          if (styles & WS_POPUP)
85                    parent = (HWND) GetWindowLong(hwnd, GWL_HWNDPARENT);
86            else
87                    parent = NULL;
88    
89            vchannel_write("CREATE,0x%p,0x%p,0x%x", hwnd, parent, 0);
90    
91          if (!GetWindowRect(hwnd, &rect)) {          if (!GetWindowRect(hwnd, &rect))
92            {
93                  debug("GetWindowRect failed!");                  debug("GetWindowRect failed!");
94                  return TRUE;                  return TRUE;
95          }          }
96    
97          vchannel_write("POSITION1,0x%p,%d,%d,%d,%d,0x%x",          vchannel_write("POSITION,0x%p,%d,%d,%d,%d,0x%x",
98                         hwnd,                         hwnd,
99                         rect.left, rect.top,                         rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0);
                        rect.right - rect.left,  
                        rect.bottom - rect.top,  
                        0);  
100    
101          GetWindowText(hwnd, title, sizeof(title));          GetWindowText(hwnd, title, sizeof(title));
102    
103          /* FIXME: Strip title of dangerous characters */          /* FIXME: Strip title of dangerous characters */
104    
105            vchannel_write("TITLE,0x%x,%s,0x%x", hwnd, title, 0);
106    
107          if (styles & WS_MAXIMIZE)          if (styles & WS_MAXIMIZE)
108                  state = 2;                  state = 2;
109          else if (styles & WS_MINIMIZE)          else if (styles & WS_MINIMIZE)
# Line 104  static BOOL CALLBACK enum_cb(HWND hwnd, Line 111  static BOOL CALLBACK enum_cb(HWND hwnd,
111          else          else
112                  state = 0;                  state = 0;
113    
114          vchannel_write("SETSTATE1,0x%p,%s,0x%x,0x%x",          vchannel_write("STATE,0x%p,0x%x,0x%x", hwnd, state, 0);
                        hwnd, title, state, 0);  
115    
116          return TRUE;          return TRUE;
117  }  }
# Line 125  do_sync(void) Line 131  do_sync(void)
131  }  }
132    
133  static void  static void
134    do_state(HWND hwnd, int state)
135    {
136            if (state == 0)
137                    ShowWindow(hwnd, SW_RESTORE);
138            else if (state == 1)
139                    ShowWindow(hwnd, SW_MINIMIZE);
140            else if (state == 2)
141                    ShowWindow(hwnd, SW_MAXIMIZE);
142            else
143                    debug("Invalid state %d sent.", state);
144    }
145    
146    static void
147    do_position(HWND hwnd, int x, int y, int width, int height)
148    {
149            SetWindowPos(hwnd, NULL, x, y, width, height, SWP_NOACTIVATE | SWP_NOZORDER);
150    }
151    
152    static void
153    do_zchange(HWND hwnd, HWND behind)
154    {
155            if (behind == NULL)
156                    behind = HWND_TOP;
157            SetWindowPos(hwnd, behind, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
158    }
159    
160    static void
161  process_cmds(void)  process_cmds(void)
162  {  {
163          char line[VCHANNEL_MAX_LINE];          char line[VCHANNEL_MAX_LINE];
# Line 132  process_cmds(void) Line 165  process_cmds(void)
165    
166          char *p, *tok1, *tok2, *tok3, *tok4, *tok5, *tok6, *tok7, *tok8;          char *p, *tok1, *tok2, *tok3, *tok4, *tok5, *tok6, *tok7, *tok8;
167    
168          while ((size = vchannel_read(line, sizeof(line))) >= 0) {          while ((size = vchannel_read(line, sizeof(line))) >= 0)
169            {
170                  debug("Got: %s", line);                  debug("Got: %s", line);
171    
172                  p = line;                  p = line;
# Line 148  process_cmds(void) Line 182  process_cmds(void)
182    
183                  if (strcmp(tok1, "SYNC") == 0)                  if (strcmp(tok1, "SYNC") == 0)
184                          do_sync();                          do_sync();
185                    else if (strcmp(tok1, "STATE") == 0)
186                            do_state((HWND) strtol(tok2, NULL, 0), strtol(tok3, NULL, 0));
187                    else if (strcmp(tok1, "POSITION") == 0)
188                            do_position((HWND) strtol(tok2, NULL, 0), strtol(tok3, NULL, 0),
189                                        strtol(tok4, NULL, 0), strtol(tok5, NULL, 0), strtol(tok6, NULL,
190                                                                                             0));
191                    else if (strcmp(tok1, "ZCHANGE") == 0)
192                            do_zchange((HWND) strtol(tok2, NULL, 0), (HWND) strtol(tok3, NULL, 0));
193          }          }
194  }  }
195    
# Line 162  WinMain(HINSTANCE instance, HINSTANCE pr Line 204  WinMain(HINSTANCE instance, HINSTANCE pr
204    
205          g_instance = instance;          g_instance = instance;
206    
207          hookdll = LoadLibrary("hookdll.dll");          hookdll = LoadLibrary("seamlessrdp.dll");
208          if (!hookdll)          if (!hookdll)
209          {          {
210                  message("Could not load hook DLL. Unable to continue.");                  message("Could not load hook DLL. Unable to continue.");
# Line 196  WinMain(HINSTANCE instance, HINSTANCE pr Line 238  WinMain(HINSTANCE instance, HINSTANCE pr
238             immediatly. */             immediatly. */
239          SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, TRUE, NULL, 0);          SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, TRUE, NULL, 0);
240    
241            /* Disable screen saver since we cannot catch its windows. */
242            SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);
243    
244          if (strlen(cmdline) == 0)          if (strlen(cmdline) == 0)
245          {          {
246                  message("No command line specified.");                  message("No command line specified.");

Legend:
Removed from v.1077  
changed lines
  Added in v.1112

  ViewVC Help
Powered by ViewVC 1.1.26