/[rdesktop]/sourceforge.net/branches/seamlessrdp-branch/rdesktop/xwin.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/branches/seamlessrdp-branch/rdesktop/xwin.c

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

revision 1155 by ossman_, Fri Mar 17 10:48:11 2006 UTC revision 1157 by astrand, Fri Mar 17 12:39:09 2006 UTC
# Line 60  typedef struct _seamless_window Line 60  typedef struct _seamless_window
60          int width, height;          int width, height;
61          int state;              /* normal/minimized/maximized. */          int state;              /* normal/minimized/maximized. */
62          unsigned int desktop;          unsigned int desktop;
63            struct timeval *position_timer;
64          struct _seamless_window *next;          struct _seamless_window *next;
65  } seamless_window;  } seamless_window;
66  static seamless_window *g_seamless_windows = NULL;  static seamless_window *g_seamless_windows = NULL;
# Line 325  seamless_all_to_desktop(Window wnd, unsi Line 326  seamless_all_to_desktop(Window wnd, unsi
326  }  }
327    
328    
329    /* Send our position */
330    static void
331    seamless_update_position(seamless_window * sw)
332    {
333            XWindowAttributes wa;
334            int x, y;
335            Window child_return;
336    
337            XGetWindowAttributes(g_display, sw->wnd, &wa);
338            XTranslateCoordinates(g_display, sw->wnd, wa.root,
339                                  -wa.border_width, -wa.border_width, &x, &y, &child_return);
340    
341            seamless_send_position(sw->id, x, y, wa.width, wa.height, 0);
342            sw->xoffset = x;
343            sw->yoffset = y;
344            sw->width = wa.width;
345            sw->height = wa.height;
346    }
347    
348    
349    /* Check if it's time to send our position */
350    static void
351    seamless_check_timers()
352    {
353            seamless_window *sw;
354            struct timeval now;
355    
356            gettimeofday(&now, NULL);
357            for (sw = g_seamless_windows; sw; sw = sw->next)
358            {
359                    if (timerisset(sw->position_timer) && timercmp(sw->position_timer, &now, <))
360                    {
361                            timerclear(sw->position_timer);
362                            seamless_update_position(sw);
363                    }
364            }
365    }
366    
367    
368  static void  static void
369  seamless_restack_window(seamless_window * sw, unsigned long behind)  seamless_restack_window(seamless_window * sw, unsigned long behind)
370  {  {
# Line 2085  xwin_process_events(void) Line 2125  xwin_process_events(void)
2125                                          rdp_send_client_window_status(0);                                          rdp_send_client_window_status(0);
2126                                  break;                                  break;
2127                          case ConfigureNotify:                          case ConfigureNotify:
2128                                  /* seamless */                                  if (!g_seamless_active)
2129                                            break;
2130    
2131                                  sw = seamless_get_window_by_wnd(xevent.xconfigure.window);                                  sw = seamless_get_window_by_wnd(xevent.xconfigure.window);
2132                                  if (!sw)                                  if (!sw)
2133                                          break;                                  {
2134                                            error("ConfigureNotify for unknown window 0x%lx\n",
2135                                                  xevent.xconfigure.window);
2136                                    }
2137    
2138                                    gettimeofday(sw->position_timer, NULL);
2139                                    if (sw->position_timer->tv_usec + SEAMLESSRDP_POSITION_TIMER >=
2140                                        1000000)
2141                                    {
2142                                            sw->position_timer->tv_usec +=
2143                                                    SEAMLESSRDP_POSITION_TIMER - 1000000;
2144                                            sw->position_timer->tv_sec += 1;
2145                                    }
2146                                    else
2147                                    {
2148                                            sw->position_timer->tv_usec += SEAMLESSRDP_POSITION_TIMER;
2149                                    }
2150    
2151                                  ui_seamless_handle_restack(sw);                                  ui_seamless_handle_restack(sw);
2152                                    break;
2153                  }                  }
2154          }          }
2155          /* Keep going */          /* Keep going */
# Line 2114  ui_select(int rdp_socket) Line 2173  ui_select(int rdp_socket)
2173                          /* User quit */                          /* User quit */
2174                          return 0;                          return 0;
2175    
2176                    if (g_seamless_active)
2177                            seamless_check_timers();
2178    
2179                  FD_ZERO(&rfds);                  FD_ZERO(&rfds);
2180                  FD_ZERO(&wfds);                  FD_ZERO(&wfds);
2181                  FD_SET(rdp_socket, &rfds);                  FD_SET(rdp_socket, &rfds);
# Line 2133  ui_select(int rdp_socket) Line 2195  ui_select(int rdp_socket)
2195    
2196                  /* add redirection handles */                  /* add redirection handles */
2197                  rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout);                  rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout);
2198                    seamless_select_timeout(&tv);
2199    
2200                  n++;                  n++;
2201    
# Line 3216  ui_seamless_create_window(unsigned long Line 3279  ui_seamless_create_window(unsigned long
3279             serverside, instead of terminating rdesktop */             serverside, instead of terminating rdesktop */
3280          XSetWMProtocols(g_display, wnd, &g_kill_atom, 1);          XSetWMProtocols(g_display, wnd, &g_kill_atom, 1);
3281    
3282          sw = malloc(sizeof(seamless_window));          sw = xmalloc(sizeof(seamless_window));
3283          sw->wnd = wnd;          sw->wnd = wnd;
3284          sw->id = id;          sw->id = id;
3285          sw->parent = parent;          sw->parent = parent;
# Line 3227  ui_seamless_create_window(unsigned long Line 3290  ui_seamless_create_window(unsigned long
3290          sw->height = 0;          sw->height = 0;
3291          sw->state = SEAMLESSRDP_NOTYETMAPPED;          sw->state = SEAMLESSRDP_NOTYETMAPPED;
3292          sw->desktop = 0;          sw->desktop = 0;
3293            sw->position_timer = xmalloc(sizeof(struct timeval));
3294            timerclear(sw->position_timer);
3295          sw->next = g_seamless_windows;          sw->next = g_seamless_windows;
3296          g_seamless_windows = sw;          g_seamless_windows = sw;
3297  }  }
# Line 3271  ui_seamless_move_window(unsigned long id Line 3336  ui_seamless_move_window(unsigned long id
3336                  /* X11 windows must be at least 1x1 */                  /* X11 windows must be at least 1x1 */
3337                  return;                  return;
3338    
3339          /* About MAX and MIN: Windows allows moving a window outside          sw->xoffset = x;
3340             the desktop. This happens, for example, when maximizing an          sw->yoffset = y;
3341             application. In this case, the position is set to something          sw->width = width;
3342             like -4,-4,1288,1032. Many WMs does not allow windows          sw->height = height;
            outside the desktop, however. Therefore, clip the window  
            ourselves. */  
         sw->xoffset = MAX(0, x);  
         sw->yoffset = MAX(0, y);  
         sw->width = MIN(MIN(width, width + x), g_width - sw->xoffset);  
         sw->height = MIN(MIN(height, height + y), g_height - sw->yoffset);  
3343    
3344          /* If we move the window in a maximized state, then KDE won't          /* If we move the window in a maximized state, then KDE won't
3345             accept restoration */             accept restoration */

Legend:
Removed from v.1155  
changed lines
  Added in v.1157

  ViewVC Help
Powered by ViewVC 1.1.26