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

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

revision 566 by stargo, Mon Jan 19 23:45:26 2004 UTC revision 606 by stargo, Sat Feb 14 23:20:24 2004 UTC
# Line 23  Line 23 
23  #include <unistd.h>  #include <unistd.h>
24  #include <time.h>  #include <time.h>
25  #include <errno.h>  #include <errno.h>
26    #include <strings.h>
27  #include "rdesktop.h"  #include "rdesktop.h"
28  #include "xproto.h"  #include "xproto.h"
29    
# Line 42  static int g_x_socket; Line 43  static int g_x_socket;
43  static Screen *g_screen;  static Screen *g_screen;
44  Window g_wnd;  Window g_wnd;
45  BOOL g_enable_compose = False;  BOOL g_enable_compose = False;
46  static GC g_gc;  static GC g_gc = NULL;
 static BOOL g_gc_initialized = False;  
47  static Visual *g_visual;  static Visual *g_visual;
48  static int g_depth;  static int g_depth;
49  static int g_bpp;  static int g_bpp;
# Line 51  static XIM g_IM; Line 51  static XIM g_IM;
51  static XIC g_IC;  static XIC g_IC;
52  static XModifierKeymap *g_mod_map;  static XModifierKeymap *g_mod_map;
53  static Cursor g_current_cursor;  static Cursor g_current_cursor;
54  static HCURSOR g_null_cursor;  static HCURSOR g_null_cursor = NULL;
55  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
56  static BOOL g_focused;  static BOOL g_focused;
57  static BOOL g_mouse_in_wnd;  static BOOL g_mouse_in_wnd;
# Line 64  static int g_red_shift_l, g_blue_shift_l Line 64  static int g_red_shift_l, g_blue_shift_l
64    
65  /* software backing store */  /* software backing store */
66  static BOOL g_ownbackstore;  static BOOL g_ownbackstore;
67  static Pixmap g_backstore;  static Pixmap g_backstore = 0;
 static BOOL g_backstore_initialized = False;  
68    
69  /* Moving in single app mode */  /* Moving in single app mode */
70  static BOOL g_moving_wnd;  static BOOL g_moving_wnd;
# Line 733  ui_init(void) Line 732  ui_init(void)
732                  TrueColorVisual = True;                  TrueColorVisual = True;
733          }          }
734    
735          if ((g_server_bpp == 8) && ((! TrueColorVisual) || (g_depth <= 8)))          if ((g_server_bpp == 8) && ((!TrueColorVisual) || (g_depth <= 8)))
736          {          {
737                  /* we use a colourmap, so the default visual should do */                  /* we use a colourmap, so the default visual should do */
738                  g_visual = DefaultVisualOfScreen(g_screen);                  g_visual = DefaultVisualOfScreen(g_screen);
# Line 785  ui_init(void) Line 784  ui_init(void)
784    
785          if (!g_owncolmap)          if (!g_owncolmap)
786          {          {
787                  g_xcolmap = XCreateColormap(g_display,RootWindowOfScreen(g_screen),g_visual,AllocNone);                  g_xcolmap =
788                            XCreateColormap(g_display, RootWindowOfScreen(g_screen), g_visual,
789                                            AllocNone);
790                  if (g_depth <= 8)                  if (g_depth <= 8)
791                          warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n");                          warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n");
792          }          }
# Line 852  ui_deinit(void) Line 853  ui_deinit(void)
853          if (g_IM != NULL)          if (g_IM != NULL)
854                  XCloseIM(g_IM);                  XCloseIM(g_IM);
855    
856            if (g_null_cursor != NULL)
857                    ui_destroy_cursor(g_null_cursor);
858    
859          XFreeModifiermap(g_mod_map);          XFreeModifiermap(g_mod_map);
860    
861          if (g_ownbackstore)          if (g_ownbackstore)
# Line 888  ui_create_window(void) Line 892  ui_create_window(void)
892                                CWBackPixel | CWBackingStore | CWOverrideRedirect |                                CWBackPixel | CWBackingStore | CWOverrideRedirect |
893                                CWColormap | CWBorderPixel, &attribs);                                CWColormap | CWBorderPixel, &attribs);
894    
895          if ( ! g_gc_initialized )          if (g_gc == NULL)
         {  
896                  g_gc = XCreateGC(g_display, g_wnd, 0, NULL);                  g_gc = XCreateGC(g_display, g_wnd, 0, NULL);
                 g_gc_initialized = True;  
         }  
897    
898          if ((g_ownbackstore) && (! g_backstore_initialized))          if ((g_ownbackstore) && (g_backstore == 0))
899          {          {
900                  g_backstore =                  g_backstore = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth);
                         XCreatePixmap(g_display, g_wnd, g_width, g_height,  
                                       g_depth);  
901    
902                  /* clear to prevent rubbish being exposed at startup */                  /* clear to prevent rubbish being exposed at startup */
903                  XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen));                  XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen));
904                  XFillRectangle(g_display, g_backstore, g_gc, 0, 0, g_width, g_height);                  XFillRectangle(g_display, g_backstore, g_gc, 0, 0, g_width, g_height);
                 g_backstore_initialized = True;  
905          }          }
906    
907          XStoreName(g_display, g_wnd, g_title);          XStoreName(g_display, g_wnd, g_title);
# Line 970  ui_create_window(void) Line 968  ui_create_window(void)
968          XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1);          XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1);
969    
970          /* create invisible 1x1 cursor to be used as null cursor */          /* create invisible 1x1 cursor to be used as null cursor */
971          g_null_cursor = ui_create_cursor(0, 0, 1, 1, null_pointer_mask, null_pointer_data);          if (g_null_cursor == NULL)
972                    g_null_cursor = ui_create_cursor(0, 0, 1, 1, null_pointer_mask, null_pointer_data);
973    
974          return True;          return True;
975  }  }
# Line 1273  xwin_process_events(void) Line 1272  xwin_process_events(void)
1272  int  int
1273  ui_select(int rdp_socket)  ui_select(int rdp_socket)
1274  {  {
1275          int n = (rdp_socket > g_x_socket) ? rdp_socket + 1 : g_x_socket + 1;          int n;
1276          fd_set rfds, wfds;          fd_set rfds, wfds;
1277            struct timeval tv;
1278            BOOL s_timeout = False;
1279    
1280          while (True)          while (True)
1281          {          {
1282                    n = (rdp_socket > g_x_socket) ? rdp_socket : g_x_socket;
1283                  /* Process any events already waiting */                  /* Process any events already waiting */
1284                  if (!xwin_process_events())                  if (!xwin_process_events())
1285                          /* User quit */                          /* User quit */
# Line 1293  ui_select(int rdp_socket) Line 1295  ui_select(int rdp_socket)
1295                  if (g_dsp_busy)                  if (g_dsp_busy)
1296                  {                  {
1297                          FD_SET(g_dsp_fd, &wfds);                          FD_SET(g_dsp_fd, &wfds);
1298                          n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;                          n = (g_dsp_fd > n) ? g_dsp_fd : n;
1299                  }                  }
1300  #endif  #endif
1301                    /* default timeout */
1302                    tv.tv_sec = 60;
1303                    tv.tv_usec = 0;
1304    
1305                  switch (select(n, &rfds, &wfds, NULL, NULL))                  /* add redirection handles */
1306                    rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout);
1307    
1308                    n++;
1309    
1310                    switch (select(n, &rfds, &wfds, NULL, &tv))
1311                  {                  {
1312                          case -1:                          case -1:
1313                                  error("select: %s\n", strerror(errno));                                  error("select: %s\n", strerror(errno));
1314    
1315                          case 0:                          case 0:
1316                                    /* TODO: if tv.tv_sec just times out
1317                                     * we will segfault.
1318                                     * FIXME:
1319                                     */
1320                                    //s_timeout = True;
1321                                    //rdpdr_check_fds(&rfds, &wfds, (BOOL) True);
1322                                  continue;                                  continue;
1323                  }                  }
1324    
1325                    rdpdr_check_fds(&rfds, &wfds, (BOOL) False);
1326    
1327                  if (FD_ISSET(rdp_socket, &rfds))                  if (FD_ISSET(rdp_socket, &rfds))
1328                          return 1;                          return 1;
1329    

Legend:
Removed from v.566  
changed lines
  Added in v.606

  ViewVC Help
Powered by ViewVC 1.1.26