/[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 564 by jsorg71, Fri Jan 16 23:15:33 2004 UTC revision 565 by stargo, Mon Jan 19 21:58:58 2004 UTC
# 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  /* software backing store */  /* software backing store */
65  static BOOL g_ownbackstore;  static BOOL g_ownbackstore;
66  static Pixmap g_backstore;  static Pixmap g_backstore;
67    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 699  ui_init(void) Line 700  ui_init(void)
700          XVisualInfo vi;          XVisualInfo vi;
701          XPixmapFormatValues *pfm;          XPixmapFormatValues *pfm;
702          uint16 test;          uint16 test;
703          int i, screen_num;          int i, screen_num, nvisuals;
704            XVisualInfo *vmatches = NULL;
705            XVisualInfo template;
706            Bool TrueColorVisual = False;
707    
708          g_display = XOpenDisplay(NULL);          g_display = XOpenDisplay(NULL);
709          if (g_display == NULL)          if (g_display == NULL)
# Line 713  ui_init(void) Line 717  ui_init(void)
717          g_screen = ScreenOfDisplay(g_display, screen_num);          g_screen = ScreenOfDisplay(g_display, screen_num);
718          g_depth = DefaultDepthOfScreen(g_screen);          g_depth = DefaultDepthOfScreen(g_screen);
719    
720          if (g_server_bpp == 8)          /* Search for best TrueColor depth */
721            template.class = TrueColor;
722            vmatches = XGetVisualInfo(g_display, VisualClassMask, &template, &nvisuals);
723    
724            nvisuals--;
725            while (nvisuals >= 0)
726            {
727                    if ((vmatches + nvisuals)->depth > g_depth)
728                    {
729                            g_depth = (vmatches + nvisuals)->depth;
730                    }
731                    nvisuals--;
732                    TrueColorVisual = True;
733            }
734    
735            if ((g_server_bpp == 8) && ((! TrueColorVisual) || (g_depth <= 8)))
736          {          {
737                  /* we use a colourmap, so any visual should do */                  /* we use a colourmap, so the default visual should do */
738                  g_visual = DefaultVisualOfScreen(g_screen);                  g_visual = DefaultVisualOfScreen(g_screen);
739                    g_depth = DefaultDepthOfScreen(g_screen);
740    
741                    /* Do not allocate colours on a TrueColor visual */
742                    if (g_visual->class == TrueColor)
743                    {
744                            g_owncolmap = False;
745                    }
746          }          }
747          else          else
748          {          {
# Line 758  ui_init(void) Line 784  ui_init(void)
784    
785          if (!g_owncolmap)          if (!g_owncolmap)
786          {          {
787                  g_xcolmap = DefaultColormapOfScreen(g_screen);                  g_xcolmap = XCreateColormap(g_display,RootWindowOfScreen(g_screen),g_visual,AllocNone);
788                  if (g_depth <= 8)                  if (g_depth <= 8)
789                          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");
790          }          }
791    
         g_gc = XCreateGC(g_display, RootWindowOfScreen(g_screen), 0, NULL);  
   
792          if (DoesBackingStore(g_screen) != Always)          if (DoesBackingStore(g_screen) != Always)
793                  g_ownbackstore = True;                  g_ownbackstore = True;
794    
# Line 807  ui_init(void) Line 831  ui_init(void)
831          /* make sure width is a multiple of 4 */          /* make sure width is a multiple of 4 */
832          g_width = (g_width + 3) & ~3;          g_width = (g_width + 3) & ~3;
833    
         if (g_ownbackstore)  
         {  
                 g_backstore =  
                         XCreatePixmap(g_display, RootWindowOfScreen(g_screen), g_width, g_height,  
                                       g_depth);  
   
                 /* clear to prevent rubbish being exposed at startup */  
                 XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen));  
                 XFillRectangle(g_display, g_backstore, g_gc, 0, 0, g_width, g_height);  
         }  
   
834          g_mod_map = XGetModifierMapping(g_display);          g_mod_map = XGetModifierMapping(g_display);
835    
836          xkeymap_init();          xkeymap_init();
# Line 864  ui_create_window(void) Line 877  ui_create_window(void)
877          wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height;          wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height;
878    
879          attribs.background_pixel = BlackPixelOfScreen(g_screen);          attribs.background_pixel = BlackPixelOfScreen(g_screen);
880            attribs.border_pixel = WhitePixelOfScreen(g_screen);
881          attribs.backing_store = g_ownbackstore ? NotUseful : Always;          attribs.backing_store = g_ownbackstore ? NotUseful : Always;
882          attribs.override_redirect = g_fullscreen;          attribs.override_redirect = g_fullscreen;
883            attribs.colormap = g_xcolmap;
884    
885          g_wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), 0, 0, wndwidth, wndheight,          g_wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), 0, 0, wndwidth, wndheight,
886                                0, CopyFromParent, InputOutput, CopyFromParent,                                0, g_depth, InputOutput, g_visual,
887                                CWBackPixel | CWBackingStore | CWOverrideRedirect, &attribs);                                CWBackPixel | CWBackingStore | CWOverrideRedirect |
888                                  CWColormap | CWBorderPixel, &attribs);
889    
890            g_gc = XCreateGC(g_display, g_wnd, 0, NULL);
891    
892            if ((g_ownbackstore) && (! g_backstore_initialized))
893            {
894                    g_backstore =
895                            XCreatePixmap(g_display, g_wnd, g_width, g_height,
896                                          g_depth);
897    
898                    /* clear to prevent rubbish being exposed at startup */
899                    XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen));
900                    XFillRectangle(g_display, g_backstore, g_gc, 0, 0, g_width, g_height);
901                    g_backstore_initialized = True;
902            }
903    
904          XStoreName(g_display, g_wnd, g_title);          XStoreName(g_display, g_wnd, g_title);
905    

Legend:
Removed from v.564  
changed lines
  Added in v.565

  ViewVC Help
Powered by ViewVC 1.1.26