/[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 9 by matty, Tue Jul 25 12:34:29 2000 UTC revision 10 by matty, Tue Aug 15 10:23:24 2000 UTC
# Line 18  Line 18 
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */  */
20    
21  #include "includes.h"  #include <X11/Xlib.h>
22    #include <time.h>
23    #include "rdesktop.h"
24    
25    extern int width;
26    extern int height;
27    extern BOOL motion;
28    
29    static Display *display;
30    static Window wnd;
31    static GC gc;
32    static Visual *visual;
33    static XIM IM;
34    
35  HWINDOW ui_create_window(HCONN conn, int width, int height)  BOOL ui_create_window(char *title)
36  {  {
37          struct window *wnd;          Screen *screen;
38          XSetWindowAttributes attribs;          XSetWindowAttributes attribs;
39          Display *display;          unsigned long input_mask;
40          Visual *visual;          int i;
         Window window;  
         int black;  
         GC gc;  
41    
42          display = XOpenDisplay(NULL);          display = XOpenDisplay(NULL);
43          if (display == NULL)          if (display == NULL)
44                  return NULL;                  return False;
45    
46            /* Check the screen supports 8-bit depth. */
47            screen = DefaultScreenOfDisplay(display);
48            for (i = 0; i < screen->ndepths; i++)
49                    if (screen->depths[i].depth == 8)
50                            break;
51    
52            if (i >= screen->ndepths)
53            {
54                    ERROR("8-bit depth required (in this version).\n");
55                    XCloseDisplay(display);
56                    return False;
57            }
58    
59          visual = DefaultVisual(display, DefaultScreen(display));          visual = DefaultVisual(display, DefaultScreen(display));
         black = BlackPixel(display, DefaultScreen(display));  
60    
61          attribs.background_pixel = black;          attribs.background_pixel = BlackPixel(display, DefaultScreen(display));
62          attribs.backing_store = Always;          attribs.backing_store = Always;
63          window = XCreateWindow(display, DefaultRootWindow(display), 0, 0,          wnd = XCreateWindow(display, DefaultRootWindow(display),
64                          width, height, 0, 8, InputOutput, visual,                          0, 0, width, height, 0, 8, InputOutput, visual,
65                          CWBackingStore | CWBackPixel, &attribs);                          CWBackingStore | CWBackPixel, &attribs);
66    
67          XStoreName(display, window, "rdesktop");          XStoreName(display, wnd, title);
68          XMapWindow(display, window);          XMapWindow(display, wnd);
69          XSelectInput(display, window, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask);  
70          XSync(display, True);          input_mask  = KeyPressMask | KeyReleaseMask;
71            input_mask |= ButtonPressMask | ButtonReleaseMask;
72          gc = XCreateGC(display, window, 0, NULL);          if (motion)
73                    input_mask |= PointerMotionMask;
74          wnd = xmalloc(sizeof(struct window));  
75          wnd->conn = conn;          XSelectInput(display, wnd, input_mask);
76          wnd->width = width;          gc = XCreateGC(display, wnd, 0, NULL);
77          wnd->height = height;  
78          wnd->display = display;          IM = XOpenIM(display, NULL, NULL, NULL);
79          wnd->wnd = window;          return True;
80          wnd->gc = gc;  }
81          wnd->visual = visual;  
82    void ui_destroy_window()
83          return wnd;  {
84  }          XCloseIM(IM);
85            XFreeGC(display, gc);
86  void ui_destroy_window(HWINDOW wnd)          XDestroyWindow(display, wnd);
87  {          XCloseDisplay(display);
         XFreeGC(wnd->display, wnd->gc);  
         XDestroyWindow(wnd->display, wnd->wnd);  
         XCloseDisplay(wnd->display);  
88  }  }
89    
90  static uint8 xwin_translate_key(unsigned long key)  static uint8 xwin_translate_key(unsigned long key)
# Line 108  static uint16 xwin_translate_mouse(unsig Line 126  static uint16 xwin_translate_mouse(unsig
126          return 0;          return 0;
127  }  }
128    
129  void ui_process_events(HWINDOW wnd, HCONN conn)  void ui_process_events()
130  {  {
131          XEvent event;          XEvent event;
132          uint8 scancode;          uint8 scancode;
133          uint16 button;          uint16 button;
134            uint32 ev_time;
135    
136          if (wnd == NULL)          if (display == NULL)
137                  return;                  return;
138    
139          while (XCheckWindowEvent(wnd->display, wnd->wnd, 0xffffffff, &event))          while (XCheckWindowEvent(display, wnd, 0xffffffff, &event))
140          {          {
141                    ev_time = time(NULL);
142    
143                  switch (event.type)                  switch (event.type)
144                  {                  {
145                          case KeyPress:                          case KeyPress:
# Line 126  void ui_process_events(HWINDOW wnd, HCON Line 147  void ui_process_events(HWINDOW wnd, HCON
147                                  if (scancode == 0)                                  if (scancode == 0)
148                                          break;                                          break;
149    
150                                  rdp_send_input(conn, RDP_INPUT_SCANCODE, 0,                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE, 0,
151                                                  scancode, 0);                                                  scancode, 0);
152                                  break;                                  break;
153    
# Line 135  void ui_process_events(HWINDOW wnd, HCON Line 156  void ui_process_events(HWINDOW wnd, HCON
156                                  if (scancode == 0)                                  if (scancode == 0)
157                                          break;                                          break;
158    
159                                  rdp_send_input(conn, RDP_INPUT_SCANCODE,                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
160                                                  KBD_FLAG_DOWN | KBD_FLAG_UP,                                                  KBD_FLAG_DOWN | KBD_FLAG_UP,
161                                                  scancode, 0);                                                  scancode, 0);
162                                  break;                                  break;
# Line 146  void ui_process_events(HWINDOW wnd, HCON Line 167  void ui_process_events(HWINDOW wnd, HCON
167                                  if (button == 0)                                  if (button == 0)
168                                          break;                                          break;
169    
170                                  rdp_send_input(conn, RDP_INPUT_MOUSE,                                  rdp_send_input(ev_time, RDP_INPUT_MOUSE,
171                                                  button | MOUSE_FLAG_DOWN,                                                  button | MOUSE_FLAG_DOWN,
172                                                  event.xbutton.x,                                                  event.xbutton.x,
173                                                  event.xbutton.y);                                                  event.xbutton.y);
# Line 157  void ui_process_events(HWINDOW wnd, HCON Line 178  void ui_process_events(HWINDOW wnd, HCON
178                                  if (button == 0)                                  if (button == 0)
179                                          break;                                          break;
180    
181                                  rdp_send_input(conn, RDP_INPUT_MOUSE,                                  rdp_send_input(ev_time, RDP_INPUT_MOUSE,
182                                                  button,                                                  button,
183                                                  event.xbutton.x,                                                  event.xbutton.x,
184                                                  event.xbutton.y);                                                  event.xbutton.y);
185                                    break;
186    
187                            case MotionNotify:
188                                    rdp_send_input(ev_time, RDP_INPUT_MOUSE,
189                                                    MOUSE_FLAG_MOVE,
190                                                    event.xmotion.x,
191                                                    event.xmotion.y);
192                  }                  }
193          }          }
194  }  }
195    
196  void ui_move_pointer(HWINDOW wnd, int x, int y)  void ui_move_pointer(int x, int y)
197  {  {
198          XWarpPointer(wnd->display, wnd->wnd, wnd->wnd, 0, 0, 0, 0, x, y);          XWarpPointer(display, wnd, wnd, 0, 0, 0, 0, x, y);
199  }  }
200    
201  HBITMAP ui_create_bitmap(HWINDOW wnd, int width, int height, uint8 *data)  HBITMAP ui_create_bitmap(int width, int height, uint8 *data)
202  {  {
203          XImage *image;          XImage *image;
204          Pixmap bitmap;          Pixmap bitmap;
205    
206          bitmap = XCreatePixmap(wnd->display, wnd->wnd, width, height, 8);          bitmap = XCreatePixmap(display, wnd, width, height, 8);
207    
208          image = XCreateImage(wnd->display, wnd->visual, 8, ZPixmap, 0,          image = XCreateImage(display, visual, 8, ZPixmap, 0,
209                                  data, width, height, 8, width);                                  data, width, height, 8, width);
210          XSetFunction(wnd->display, wnd->gc, GXcopy);          XSetFunction(display, gc, GXcopy);
211          XPutImage(wnd->display, bitmap, wnd->gc, image, 0, 0, 0, 0,          XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height);
                         width, height);  
212          XFree(image);          XFree(image);
213                    
214          return (HBITMAP)bitmap;          return (HBITMAP)bitmap;
215  }  }
216    
217  void ui_destroy_bitmap(HWINDOW wnd, HBITMAP bmp)  void ui_paint_bitmap(int x, int y, int cx, int cy,
218                            int width, int height, uint8 *data)
219    {
220            XImage *image;
221    
222            image = XCreateImage(display, visual, 8, ZPixmap, 0,
223                                    data, width, height, 8, width);
224            XSetFunction(display, gc, GXcopy);
225            XPutImage(display, wnd, gc, image, 0, 0, x, y, cx, cy);
226            XFree(image);
227    }
228    
229    void ui_destroy_bitmap(HBITMAP bmp)
230  {  {
231          XFreePixmap(wnd->display, (Pixmap)bmp);          XFreePixmap(display, (Pixmap)bmp);
232  }  }
233    
234  HGLYPH ui_create_glyph(HWINDOW wnd, int width, int height, uint8 *data)  HGLYPH ui_create_glyph(int width, int height, uint8 *data)
235  {  {
236          XImage *image;          XImage *image;
237          Pixmap bitmap;          Pixmap bitmap;
# Line 201  HGLYPH ui_create_glyph(HWINDOW wnd, int Line 240  HGLYPH ui_create_glyph(HWINDOW wnd, int
240    
241          scanline = (width + 7) / 8;          scanline = (width + 7) / 8;
242    
243          bitmap = XCreatePixmap(wnd->display, wnd->wnd, width, height, 1);          bitmap = XCreatePixmap(display, wnd, width, height, 1);
244          gc = XCreateGC(wnd->display, bitmap, 0, NULL);          gc = XCreateGC(display, bitmap, 0, NULL);
245    
246          image = XCreateImage(wnd->display, wnd->visual, 1, ZPixmap, 0,          image = XCreateImage(display, visual, 1, ZPixmap, 0,
247                                  data, width, height, 8, scanline);                                  data, width, height, 8, scanline);
248          XSetFunction(wnd->display, wnd->gc, GXcopy);          XSetFunction(display, gc, GXcopy);
249          XPutImage(wnd->display, bitmap, gc, image, 0, 0, 0, 0, width, height);          XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height);
250          XFree(image);          XFree(image);
251          XFreeGC(wnd->display, gc);          XFreeGC(display, gc);
252                    
253          return (HGLYPH)bitmap;          return (HGLYPH)bitmap;
254  }  }
255    
256  void ui_destroy_glyph(HWINDOW wnd, HGLYPH glyph)  void ui_destroy_glyph(HGLYPH glyph)
257  {  {
258          XFreePixmap(wnd->display, (Pixmap)glyph);          XFreePixmap(display, (Pixmap)glyph);
259  }  }
260    
261  HCOLOURMAP ui_create_colourmap(HWINDOW wnd, COLOURMAP *colours)  HCOLOURMAP ui_create_colourmap(COLOURMAP *colours)
262  {  {
263          COLOURENTRY *entry;          COLOURENTRY *entry;
264          XColor *xcolours, *xentry;          XColor *xcolours, *xentry;
265          Colormap map;          Colormap map;
266          int i, ncolours = colours->ncolours;          int i, ncolours = colours->ncolours;
267    
268          xcolours = malloc(sizeof(XColor) * ncolours);          xcolours = xmalloc(sizeof(XColor) * ncolours);
269          for (i = 0; i < ncolours; i++)          for (i = 0; i < ncolours; i++)
270          {          {
271                  entry = &colours->colours[i];                  entry = &colours->colours[i];
# Line 239  HCOLOURMAP ui_create_colourmap(HWINDOW w Line 278  HCOLOURMAP ui_create_colourmap(HWINDOW w
278                  xentry->flags = DoRed | DoBlue | DoGreen;                  xentry->flags = DoRed | DoBlue | DoGreen;
279          }          }
280    
281          map = XCreateColormap(wnd->display, wnd->wnd, wnd->visual, AllocAll);          map = XCreateColormap(display, wnd, visual, AllocAll);
282          XStoreColors(wnd->display, map, xcolours, ncolours);          XStoreColors(display, map, xcolours, ncolours);
283    
284          free(xcolours);          xfree(xcolours);
285          return (HCOLOURMAP)map;          return (HCOLOURMAP)map;
286  }  }
287    
288  void ui_destroy_colourmap(HWINDOW wnd, HCOLOURMAP map)  void ui_destroy_colourmap(HCOLOURMAP map)
289  {  {
290          XFreeColormap(wnd->display, (Colormap)map);          XFreeColormap(display, (Colormap)map);
291  }  }
292    
293  void ui_set_colourmap(HWINDOW wnd, HCOLOURMAP map)  void ui_set_colourmap(HCOLOURMAP map)
294  {  {
295          XSetWindowColormap(wnd->display, wnd->wnd, (Colormap)map);          XSetWindowColormap(display, wnd, (Colormap)map);
296  }  }
297    
298  void ui_set_clip(HWINDOW wnd, int x, int y, int cx, int cy)  void ui_set_clip(int x, int y, int cx, int cy)
299  {  {
300          XRectangle rect;          XRectangle rect;
301    
# Line 264  void ui_set_clip(HWINDOW wnd, int x, int Line 303  void ui_set_clip(HWINDOW wnd, int x, int
303          rect.y = y;          rect.y = y;
304          rect.width = cx;          rect.width = cx;
305          rect.height = cy;          rect.height = cy;
306          XSetClipRectangles(wnd->display, wnd->gc, 0, 0, &rect, 1, YXBanded);          XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);
307  }  }
308    
309  void ui_reset_clip(HWINDOW wnd)  void ui_reset_clip()
310  {  {
311          XRectangle rect;          XRectangle rect;
312    
313          rect.x = 0;          rect.x = 0;
314          rect.y = 0;          rect.y = 0;
315          rect.width = wnd->width;          rect.width = width;
316          rect.height = wnd->height;          rect.height = height;
317          XSetClipRectangles(wnd->display, wnd->gc, 0, 0, &rect, 1, YXBanded);          XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);
318    }
319    
320    void ui_bell()
321    {
322            XBell(display, 0);
323  }  }
324    
325  static int rop2_map[] = {  static int rop2_map[] = {
# Line 297  static int rop2_map[] = { Line 341  static int rop2_map[] = {
341          GXset           /* 1 */          GXset           /* 1 */
342  };  };
343    
344  static void xwin_set_function(HWINDOW wnd, uint8 rop2)  static void xwin_set_function(uint8 rop2)
345  {  {
346          XSetFunction(wnd->display, wnd->gc, rop2_map[rop2]);          XSetFunction(display, gc, rop2_map[rop2]);
347  }  }
348    
349  void ui_destblt(HWINDOW wnd, uint8 opcode,  void ui_destblt(uint8 opcode,
350          /* dest */  int x, int y, int cx, int cy)          /* dest */  int x, int y, int cx, int cy)
351  {  {
352          xwin_set_function(wnd, opcode);          xwin_set_function(opcode);
353    
354          XFillRectangle(wnd->display, wnd->wnd, wnd->gc, x, y, cx, cy);          XFillRectangle(display, wnd, gc, x, y, cx, cy);
355  }  }
356    
357  void ui_patblt(HWINDOW wnd, uint8 opcode,  void ui_patblt(uint8 opcode,
358          /* dest */  int x, int y, int cx, int cy,          /* dest */  int x, int y, int cx, int cy,
359          /* brush */ BRUSH *brush, int bgcolour, int fgcolour)          /* brush */ BRUSH *brush, int bgcolour, int fgcolour)
360  {  {
361          Display *dpy = wnd->display;          Display *dpy = display;
         GC gc = wnd->gc;  
362          Pixmap fill;          Pixmap fill;
363    
364          xwin_set_function(wnd, opcode);          xwin_set_function(opcode);
365    
366          switch (brush->style)          switch (brush->style)
367          {          {
368                  case 0: /* Solid */                  case 0: /* Solid */
369                          XSetForeground(dpy, gc, fgcolour);                          XSetForeground(dpy, gc, fgcolour);
370                          XFillRectangle(dpy, wnd->wnd, gc, x, y, cx, cy);                          XFillRectangle(dpy, wnd, gc, x, y, cx, cy);
371                          break;                          break;
372    
373                  case 3: /* Pattern */                  case 3: /* Pattern */
374                          fill = (Pixmap)ui_create_glyph(wnd, 8, 8, brush->pattern);                          fill = (Pixmap)ui_create_glyph(8, 8, brush->pattern);
375    
376                          XSetForeground(dpy, gc, fgcolour);                          XSetForeground(dpy, gc, fgcolour);
377                          XSetBackground(dpy, gc, bgcolour);                          XSetBackground(dpy, gc, bgcolour);
378                          XSetFillStyle(dpy, gc, FillOpaqueStippled);                          XSetFillStyle(dpy, gc, FillOpaqueStippled);
379                          XSetStipple(dpy, gc, fill);                          XSetStipple(dpy, gc, fill);
380    
381                          XFillRectangle(dpy, wnd->wnd, gc, x, y, cx, cy);                          XFillRectangle(dpy, wnd, gc, x, y, cx, cy);
382    
383                          XSetFillStyle(dpy, gc, FillSolid);                          XSetFillStyle(dpy, gc, FillSolid);
384                          ui_destroy_glyph(wnd, (HGLYPH)fill);                          ui_destroy_glyph((HGLYPH)fill);
385                          break;                          break;
386    
387                  default:                  default:
388                          NOTIMP("brush style %d\n", brush->style);                          NOTIMP("brush %d\n", brush->style);
389          }          }
390  }  }
391    
392  void ui_screenblt(HWINDOW wnd, uint8 opcode,  void ui_screenblt(uint8 opcode,
393                  /* dest */ int x, int y, int cx, int cy,                  /* dest */ int x, int y, int cx, int cy,
394                  /* src */  int srcx, int srcy)                  /* src */  int srcx, int srcy)
395  {  {
396          xwin_set_function(wnd, opcode);          xwin_set_function(opcode);
397    
398          XCopyArea(wnd->display, wnd->wnd, wnd->wnd, wnd->gc, srcx, srcy,          XCopyArea(display, wnd, wnd, gc, srcx, srcy,
399                          cx, cy, x, y);                          cx, cy, x, y);
400  }  }
401    
402  void ui_memblt(HWINDOW wnd, uint8 opcode,  void ui_memblt(uint8 opcode,
403          /* dest */  int x, int y, int cx, int cy,          /* dest */  int x, int y, int cx, int cy,
404          /* src */   HBITMAP src, int srcx, int srcy)          /* src */   HBITMAP src, int srcx, int srcy)
405  {  {
406          xwin_set_function(wnd, opcode);          xwin_set_function(opcode);
407    
408          XCopyArea(wnd->display, (Pixmap)src, wnd->wnd, wnd->gc, srcx, srcy,          XCopyArea(display, (Pixmap)src, wnd, gc, srcx, srcy,
409                          cx, cy, x, y);                          cx, cy, x, y);
410  }  }
411    
412  void ui_triblt(HWINDOW wnd, uint8 opcode,  void ui_triblt(uint8 opcode,
413          /* dest */  int x, int y, int cx, int cy,          /* dest */  int x, int y, int cx, int cy,
414          /* src */   HBITMAP src, int srcx, int srcy,          /* src */   HBITMAP src, int srcx, int srcy,
415          /* brush */ BRUSH *brush, int bgcolour, int fgcolour)          /* brush */ BRUSH *brush, int bgcolour, int fgcolour)
416  {  {
417          /* This is potentially difficult to do in general. Until someone          /* This is potentially difficult to do in general. Until someone
418             comes up with an efficient way of doing that I am using cases. */             comes up with a more efficient way of doing it I am using cases. */
419    
420          switch (opcode)          switch (opcode)
421          {          {
422                  case 0xb8: /* PSDPxax */                  case 0xb8: /* PSDPxax */
423                          ui_patblt(wnd, ROP2_XOR, x, y, cx, cy,                          ui_patblt(ROP2_XOR, x, y, cx, cy,
424                                          brush, bgcolour, fgcolour);                                          brush, bgcolour, fgcolour);
425                          ui_memblt(wnd, ROP2_AND, x, y, cx, cy,                          ui_memblt(ROP2_AND, x, y, cx, cy,
426                                          src, srcx, srcy);                                          src, srcx, srcy);
427                          ui_patblt(wnd, ROP2_XOR, x, y, cx, cy,                          ui_patblt(ROP2_XOR, x, y, cx, cy,
428                                          brush, bgcolour, fgcolour);                                          brush, bgcolour, fgcolour);
429                          break;                          break;
430    
431                  default:                  default:
432                          NOTIMP("triblt opcode 0x%x\n", opcode);                          NOTIMP("triblt 0x%x\n", opcode);
433                          ui_memblt(wnd, ROP2_COPY, x, y, cx, cy,                          ui_memblt(ROP2_COPY, x, y, cx, cy,
434                                          brush, bgcolour, fgcolour);                                          brush, bgcolour, fgcolour);
435          }          }
436  }  }
437    
438  void ui_line(HWINDOW wnd, uint8 opcode,  void ui_line(uint8 opcode,
439          /* dest */  int startx, int starty, int endx, int endy,          /* dest */  int startx, int starty, int endx, int endy,
440          /* pen */   PEN *pen)          /* pen */   PEN *pen)
441  {  {
442          xwin_set_function(wnd, opcode);          xwin_set_function(opcode);
443    
444          XSetForeground(wnd->display, wnd->gc, pen->colour);          XSetForeground(display, gc, pen->colour);
445          XDrawLine(wnd->display, wnd->wnd, wnd->gc, startx, starty, endx, endy);          XDrawLine(display, wnd, gc, startx, starty, endx, endy);
446  }  }
447    
448  void ui_rect(HWINDOW wnd,  void ui_rect(
449          /* dest */  int x, int y, int cx, int cy,          /* dest */  int x, int y, int cx, int cy,
450          /* brush */ int colour)          /* brush */ int colour)
451  {  {
452          xwin_set_function(wnd, ROP2_COPY);          xwin_set_function(ROP2_COPY);
453    
454          XSetForeground(wnd->display, wnd->gc, colour);          XSetForeground(display, gc, colour);
455          XFillRectangle(wnd->display, wnd->wnd, wnd->gc, x, y, cx, cy);          XFillRectangle(display, wnd, gc, x, y, cx, cy);
456  }  }
457    
458  void ui_draw_glyph(HWINDOW wnd, int mixmode,  void ui_draw_glyph(int mixmode,
459          /* dest */ int x, int y, int cx, int cy,          /* dest */ int x, int y, int cx, int cy,
460          /* src */  HGLYPH glyph, int srcx, int srcy, int bgcolour, int fgcolour)          /* src */  HGLYPH glyph, int srcx, int srcy, int bgcolour, int fgcolour)
461  {  {
462          Pixmap pixmap = (Pixmap)glyph;          Pixmap pixmap = (Pixmap)glyph;
463    
464          xwin_set_function(wnd, ROP2_COPY);          xwin_set_function(ROP2_COPY);
465    
466          XSetForeground(wnd->display, wnd->gc, fgcolour);          XSetForeground(display, gc, fgcolour);
467    
468          switch (mixmode)          switch (mixmode)
469          {          {
470                  case MIX_TRANSPARENT:                  case MIX_TRANSPARENT:
471                          XSetStipple(wnd->display, wnd->gc, pixmap);                          XSetStipple(display, gc, pixmap);
472                          XSetFillStyle(wnd->display, wnd->gc, FillStippled);                          XSetFillStyle(display, gc, FillStippled);
473                          XSetTSOrigin(wnd->display, wnd->gc, x, y);                          XSetTSOrigin(display, gc, x, y);
474                          XFillRectangle(wnd->display, wnd->wnd, wnd->gc,                          XFillRectangle(display, wnd, gc,
475                                          x, y, cx, cy);                                          x, y, cx, cy);
476                          XSetFillStyle(wnd->display, wnd->gc, FillSolid);                          XSetFillStyle(display, gc, FillSolid);
477                          break;                          break;
478    
479                  case MIX_OPAQUE:                  case MIX_OPAQUE:
480                          XSetBackground(wnd->display, wnd->gc, bgcolour);                          XSetBackground(display, gc, bgcolour);
481                          XCopyPlane(wnd->display, pixmap, wnd->wnd, wnd->gc,                          XCopyPlane(display, pixmap, wnd, gc,
482                                          srcx, srcy, cx, cy, x, y, 1);                                          srcx, srcy, cx, cy, x, y, 1);
483                          break;                          break;
484    
485                  default:                  default:
486                          NOTIMP("mix mode %d\n", mixmode);                          NOTIMP("mix %d\n", mixmode);
487          }          }
488  }  }
489    
490  void ui_draw_text(HWINDOW wnd, uint8 font, uint8 flags, int mixmode, int x,  void ui_draw_text(uint8 font, uint8 flags, int mixmode, int x,
491                          int y, int boxx, int boxy, int boxcx, int boxcy,                          int y, int boxx, int boxy, int boxcx, int boxcy,
492                          int bgcolour, int fgcolour, uint8 *text, uint8 length)                          int bgcolour, int fgcolour, uint8 *text, uint8 length)
493  {  {
494          FONT_GLYPH *glyph;          FONTGLYPH *glyph;
495          int i;          int i;
496    
497          if (boxcx > 1)          if (boxcx > 1)
498          {          {
499                  ui_rect(wnd, boxx, boxy, boxcx, boxcy, bgcolour);                  ui_rect(boxx, boxy, boxcx, boxcy, bgcolour);
500          }          }
501    
502          /* Paint text, character by character */          /* Paint text, character by character */
503          for (i = 0; i < length; i++)          for (i = 0; i < length; i++)
504          {          {
505                  glyph = cache_get_font(wnd->conn, font, text[i]);                  glyph = cache_get_font(font, text[i]);
506    
507                  if (glyph != NULL)                  if (glyph != NULL)
508                  {                  {
509                          ui_draw_glyph(wnd, mixmode, x,                          ui_draw_glyph(mixmode, x,
510                                          y + (short)glyph->baseline,                                          y + (short)glyph->baseline,
511                                          glyph->width, glyph->height,                                          glyph->width, glyph->height,
512                                          glyph->pixmap, 0, 0,                                          glyph->pixmap, 0, 0,
# Line 477  void ui_draw_text(HWINDOW wnd, uint8 fon Line 520  void ui_draw_text(HWINDOW wnd, uint8 fon
520          }          }
521  }  }
522    
523  void ui_desktop_save(HWINDOW wnd, uint8 *data, int x, int y, int cx, int cy)  void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
524  {  {
525          XImage *image;          XImage *image;
526          int scanline;          int scanline;
527    
528          scanline = (cx + 3) & ~3;          scanline = (cx + 3) & ~3;
529          image = XGetImage(wnd->display, wnd->wnd, x, y, cx, cy,          STATUS("XGetImage(%p,%x,%d,%d,%d,%d,%x,%d)\n", display, wnd, x, y,
530                                  0xffffffff, ZPixmap);                  cx, cy, 0xffffffff, ZPixmap);
531          memcpy(data, image->data, scanline*cy);          image = XGetImage(display, wnd, x, y, cx, cy, 0xffffffff, ZPixmap);
532          XDestroyImage(image);          cache_put_desktop(offset, scanline*cy, image->data);
533            XFree(image->data);
534            XFree(image);
535  }  }
536    
537  void ui_desktop_restore(HWINDOW wnd, uint8 *data, int x, int y, int cx, int cy)  void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
538  {  {
539          XImage *image;          XImage *image;
540          int scanline;          int scanline;
541            uint8 *data;
542    
543          scanline = (cx + 3) & ~3;          scanline = (cx + 3) & ~3;
544          image = XCreateImage(wnd->display, wnd->visual, 8, ZPixmap, 0,          data = cache_get_desktop(offset, scanline*cy);
545            if (data == NULL)
546                    return;
547    
548            image = XCreateImage(display, visual, 8, ZPixmap, 0,
549                                  data, cx, cy, 32, scanline);                                  data, cx, cy, 32, scanline);
550          XSetFunction(wnd->display, wnd->gc, GXcopy);          XSetFunction(display, gc, GXcopy);
551          XPutImage(wnd->display, wnd->wnd, wnd->gc, image, 0, 0, x, y, cx, cy);          XPutImage(display, wnd, gc, image, 0, 0, x, y, cx, cy);
552          XFree(image);          XFree(image);
553  }  }

Legend:
Removed from v.9  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26