/[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 6 by matty, Wed Jul 5 07:44:21 2000 UTC revision 7 by matty, Fri Jul 7 09:40:03 2000 UTC
# Line 45  HWINDOW ui_create_window(int width, int Line 45  HWINDOW ui_create_window(int width, int
45          wnd->display = display;          wnd->display = display;
46          wnd->wnd = window;          wnd->wnd = window;
47          wnd->gc = gc;          wnd->gc = gc;
48            wnd->visual = DefaultVisual(wnd->display, DefaultScreen(wnd->display));
49    
50          return wnd;          return wnd;
51  }  }
52    
# Line 58  void ui_destroy_window(HWINDOW wnd) Line 60  void ui_destroy_window(HWINDOW wnd)
60  HBITMAP ui_create_bitmap(HWINDOW wnd, int width, int height, uint8 *data)  HBITMAP ui_create_bitmap(HWINDOW wnd, int width, int height, uint8 *data)
61  {  {
62          XImage *image;          XImage *image;
         Visual *visual;  
63    
64          visual = DefaultVisual(wnd->display, DefaultScreen(wnd->display));          image = XCreateImage(wnd->display, wnd->visual, 8, ZPixmap, 0,
         image = XCreateImage(wnd->display, visual, 8, ZPixmap, 0,  
65                                  data, width, height, 32, width);                                  data, width, height, 32, width);
66    
67          return (HBITMAP)image;          return (HBITMAP)image;
68  }  }
69    
70  void ui_destroy_bitmap(HBITMAP bmp)  void ui_destroy_bitmap(HWINDOW wnd, HBITMAP bmp)
71  {  {
72          XDestroyImage((XImage *)bmp);          XDestroyImage((XImage *)bmp);
73  }  }
# Line 81  void ui_paint_bitmap(HWINDOW wnd, HBITMA Line 81  void ui_paint_bitmap(HWINDOW wnd, HBITMA
81    
82          XSync(wnd->display, True);          XSync(wnd->display, True);
83  }  }
84    
85    HCOLORMAP ui_create_colormap(HWINDOW wnd, COLORMAP *colors)
86    {
87            COLORENTRY *entry;
88            XColor *xcolors, *xentry;
89            Colormap map;
90            int i, ncolors = colors->ncolors;
91    
92            xcolors = malloc(sizeof(XColor) * ncolors);
93            for (i = 0; i < ncolors; i++)
94            {
95                    entry = &colors->colors[i];
96                    xentry = &xcolors[i];
97    
98                    xentry->pixel = i;
99                    xentry->red = entry->red << 8;
100                    xentry->blue = entry->blue << 8;
101                    xentry->green = entry->green << 8;
102                    xentry->flags = DoRed | DoBlue | DoGreen;
103            }
104    
105            map = XCreateColormap(wnd->display, wnd->wnd, wnd->visual, AllocAll);
106            XStoreColors(wnd->display, map, xcolors, ncolors);
107    
108            free(xcolors);
109            return (HCOLORMAP)map;
110    }
111    
112    void ui_destroy_colormap(HWINDOW wnd, HCOLORMAP map)
113    {
114            XFreeColormap(wnd->display, (Colormap)map);
115    }
116    
117    void ui_set_colormap(HWINDOW wnd, HCOLORMAP map)
118    {
119            XSetWindowColormap(wnd->display, wnd->wnd, (Colormap)map);
120    }
121    
122    void ui_draw_rectangle(HWINDOW wnd, int x, int y, int width, int height)
123    {
124            static int white = 0;
125    
126            XSetForeground(wnd->display, wnd->gc, white);
127            XFillRectangle(wnd->display, wnd->wnd, wnd->gc, x, y, width, height);
128    
129            white++;
130    }
131    
132    void ui_move_pointer(HWINDOW wnd, int x, int y)
133    {
134            XWarpPointer(wnd->display, wnd->wnd, wnd->wnd, 0, 0, 0, 0, x, y);
135    }

Legend:
Removed from v.6  
changed lines
  Added in v.7

  ViewVC Help
Powered by ViewVC 1.1.26