/[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 24 by matty, Sat Jan 6 03:12:10 2001 UTC revision 25 by matty, Sat Jan 6 03:47:04 2001 UTC
# Line 32  static GC gc; Line 32  static GC gc;
32  static Visual *visual;  static Visual *visual;
33  static XIM IM;  static XIM IM;
34    
35  BOOL ui_create_window(char *title)  BOOL
36    ui_create_window(char *title)
37  {  {
38          Screen *screen;          Screen *screen;
39          XSetWindowAttributes attribs;          XSetWindowAttributes attribs;
# Line 83  BOOL ui_create_window(char *title) Line 84  BOOL ui_create_window(char *title)
84          return True;          return True;
85  }  }
86    
87  void ui_destroy_window()  void
88    ui_destroy_window()
89  {  {
90          XCloseIM(IM);          XCloseIM(IM);
91          XFreeGC(display, gc);          XFreeGC(display, gc);
# Line 91  void ui_destroy_window() Line 93  void ui_destroy_window()
93          XCloseDisplay(display);          XCloseDisplay(display);
94  }  }
95    
96  static uint8 xwin_translate_key(unsigned long key)  static uint8
97    xwin_translate_key(unsigned long key)
98  {  {
99          DEBUG("KEY(code=0x%lx)\n", key);          DEBUG("KEY(code=0x%lx)\n", key);
100    
# Line 115  static uint8 xwin_translate_key(unsigned Line 118  static uint8 xwin_translate_key(unsigned
118          return 0;          return 0;
119  }  }
120    
121  static uint16 xwin_translate_mouse(unsigned long button)  static uint16
122    xwin_translate_mouse(unsigned long button)
123  {  {
124          switch (button)          switch (button)
125          {          {
# Line 130  static uint16 xwin_translate_mouse(unsig Line 134  static uint16 xwin_translate_mouse(unsig
134          return 0;          return 0;
135  }  }
136    
137  void ui_process_events()  void
138    ui_process_events()
139  {  {
140          XEvent event;          XEvent event;
141          uint8 scancode;          uint8 scancode;
# Line 148  void ui_process_events() Line 153  void ui_process_events()
153                  {                  {
154                          case KeyPress:                          case KeyPress:
155                                  scancode =                                  scancode =
156                                          xwin_translate_key(event.xkey.                                          xwin_translate_key(event.
157                                                             keycode);                                                             xkey.keycode);
158                                  if (scancode == 0)                                  if (scancode == 0)
159                                          break;                                          break;
160    
# Line 159  void ui_process_events() Line 164  void ui_process_events()
164    
165                          case KeyRelease:                          case KeyRelease:
166                                  scancode =                                  scancode =
167                                          xwin_translate_key(event.xkey.                                          xwin_translate_key(event.
168                                                             keycode);                                                             xkey.keycode);
169                                  if (scancode == 0)                                  if (scancode == 0)
170                                          break;                                          break;
171    
# Line 171  void ui_process_events() Line 176  void ui_process_events()
176    
177                          case ButtonPress:                          case ButtonPress:
178                                  button =                                  button =
179                                          xwin_translate_mouse(event.xbutton.                                          xwin_translate_mouse(event.
180                                                               button);                                                               xbutton.button);
181    
182                                  if (button == 0)                                  if (button == 0)
183                                          break;                                          break;
# Line 185  void ui_process_events() Line 190  void ui_process_events()
190    
191                          case ButtonRelease:                          case ButtonRelease:
192                                  button =                                  button =
193                                          xwin_translate_mouse(event.xbutton.                                          xwin_translate_mouse(event.
194                                                               button);                                                               xbutton.button);
195                                  if (button == 0)                                  if (button == 0)
196                                          break;                                          break;
197    
# Line 205  void ui_process_events() Line 210  void ui_process_events()
210          }          }
211  }  }
212    
213  void ui_move_pointer(int x, int y)  void
214    ui_move_pointer(int x, int y)
215  {  {
216          XWarpPointer(display, wnd, wnd, 0, 0, 0, 0, x, y);          XWarpPointer(display, wnd, wnd, 0, 0, 0, 0, x, y);
217  }  }
218    
219  HBITMAP ui_create_bitmap(int width, int height, uint8 *data)  HBITMAP
220    ui_create_bitmap(int width, int height, uint8 *data)
221  {  {
222          XImage *image;          XImage *image;
223          Pixmap bitmap;          Pixmap bitmap;
# Line 226  HBITMAP ui_create_bitmap(int width, int Line 233  HBITMAP ui_create_bitmap(int width, int
233          return (HBITMAP) bitmap;          return (HBITMAP) bitmap;
234  }  }
235    
236  void ui_paint_bitmap(int x, int y, int cx, int cy,  void
237                       int width, int height, uint8 *data)  ui_paint_bitmap(int x, int y, int cx, int cy,
238                    int width, int height, uint8 *data)
239  {  {
240          XImage *image;          XImage *image;
241    
# Line 238  void ui_paint_bitmap(int x, int y, int c Line 246  void ui_paint_bitmap(int x, int y, int c
246          XFree(image);          XFree(image);
247  }  }
248    
249  void ui_destroy_bitmap(HBITMAP bmp)  void
250    ui_destroy_bitmap(HBITMAP bmp)
251  {  {
252          XFreePixmap(display, (Pixmap) bmp);          XFreePixmap(display, (Pixmap) bmp);
253  }  }
254    
255  HGLYPH ui_create_glyph(int width, int height, uint8 *data)  HGLYPH
256    ui_create_glyph(int width, int height, uint8 *data)
257  {  {
258          XImage *image;          XImage *image;
259          Pixmap bitmap;          Pixmap bitmap;
# Line 269  HGLYPH ui_create_glyph(int width, int he Line 279  HGLYPH ui_create_glyph(int width, int he
279          return (HGLYPH) bitmap;          return (HGLYPH) bitmap;
280  }  }
281    
282  void ui_destroy_glyph(HGLYPH glyph)  void
283    ui_destroy_glyph(HGLYPH glyph)
284  {  {
285          XFreePixmap(display, (Pixmap) glyph);          XFreePixmap(display, (Pixmap) glyph);
286  }  }
287    
288  HCOLOURMAP ui_create_colourmap(COLOURMAP *colours)  HCOLOURMAP
289    ui_create_colourmap(COLOURMAP *colours)
290  {  {
291          COLOURENTRY *entry;          COLOURENTRY *entry;
292          XColor *xcolours, *xentry;          XColor *xcolours, *xentry;
# Line 301  HCOLOURMAP ui_create_colourmap(COLOURMAP Line 313  HCOLOURMAP ui_create_colourmap(COLOURMAP
313          return (HCOLOURMAP) map;          return (HCOLOURMAP) map;
314  }  }
315    
316  void ui_destroy_colourmap(HCOLOURMAP map)  void
317    ui_destroy_colourmap(HCOLOURMAP map)
318  {  {
319          XFreeColormap(display, (Colormap) map);          XFreeColormap(display, (Colormap) map);
320  }  }
321    
322  void ui_set_colourmap(HCOLOURMAP map)  void
323    ui_set_colourmap(HCOLOURMAP map)
324  {  {
325          XSetWindowColormap(display, wnd, (Colormap) map);          XSetWindowColormap(display, wnd, (Colormap) map);
326  }  }
327    
328  void ui_set_clip(int x, int y, int cx, int cy)  void
329    ui_set_clip(int x, int y, int cx, int cy)
330  {  {
331          XRectangle rect;          XRectangle rect;
332    
# Line 322  void ui_set_clip(int x, int y, int cx, i Line 337  void ui_set_clip(int x, int y, int cx, i
337          XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);          XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);
338  }  }
339    
340  void ui_reset_clip()  void
341    ui_reset_clip()
342  {  {
343          XRectangle rect;          XRectangle rect;
344    
# Line 333  void ui_reset_clip() Line 349  void ui_reset_clip()
349          XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);          XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);
350  }  }
351    
352  void ui_bell()  void
353    ui_bell()
354  {  {
355          XBell(display, 0);          XBell(display, 0);
356  }  }
# Line 357  static int rop2_map[] = { Line 374  static int rop2_map[] = {
374          GXset                   /* 1 */          GXset                   /* 1 */
375  };  };
376    
377  static void xwin_set_function(uint8 rop2)  static void
378    xwin_set_function(uint8 rop2)
379  {  {
380          XSetFunction(display, gc, rop2_map[rop2]);          XSetFunction(display, gc, rop2_map[rop2]);
381  }  }
382    
383  void ui_destblt(uint8 opcode,  void
384                  /* dest */ int x, int y, int cx, int cy)  ui_destblt(uint8 opcode,
385               /* dest */ int x, int y, int cx, int cy)
386  {  {
387          xwin_set_function(opcode);          xwin_set_function(opcode);
388    
389          XFillRectangle(display, wnd, gc, x, y, cx, cy);          XFillRectangle(display, wnd, gc, x, y, cx, cy);
390  }  }
391    
392  void ui_patblt(uint8 opcode,  void
393                 /* dest */ int x, int y, int cx, int cy,  ui_patblt(uint8 opcode,
394                 /* brush */ BRUSH *brush, int bgcolour, int fgcolour)            /* dest */ int x, int y, int cx, int cy,
395              /* brush */ BRUSH *brush, int bgcolour, int fgcolour)
396  {  {
397          Display *dpy = display;          Display *dpy = display;
398          Pixmap fill;          Pixmap fill;
# Line 405  void ui_patblt(uint8 opcode, Line 425  void ui_patblt(uint8 opcode,
425          }          }
426  }  }
427    
428  void ui_screenblt(uint8 opcode,  void
429                    /* dest */ int x, int y, int cx, int cy,  ui_screenblt(uint8 opcode,
430                    /* src */ int srcx, int srcy)               /* dest */ int x, int y, int cx, int cy,
431                 /* src */ int srcx, int srcy)
432  {  {
433          xwin_set_function(opcode);          xwin_set_function(opcode);
434    
435          XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y);          XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y);
436  }  }
437    
438  void ui_memblt(uint8 opcode,  void
439                 /* dest */ int x, int y, int cx, int cy,  ui_memblt(uint8 opcode,
440                 /* src */ HBITMAP src, int srcx, int srcy)            /* dest */ int x, int y, int cx, int cy,
441              /* src */ HBITMAP src, int srcx, int srcy)
442  {  {
443          xwin_set_function(opcode);          xwin_set_function(opcode);
444    
445          XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y);          XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y);
446  }  }
447    
448  void ui_triblt(uint8 opcode,  void
449                 /* dest */ int x, int y, int cx, int cy,  ui_triblt(uint8 opcode,
450                 /* src */ HBITMAP src, int srcx, int srcy,            /* dest */ int x, int y, int cx, int cy,
451                 /* brush */ BRUSH *brush, int bgcolour, int fgcolour)            /* src */ HBITMAP src, int srcx, int srcy,
452              /* brush */ BRUSH *brush, int bgcolour, int fgcolour)
453  {  {
454          /* This is potentially difficult to do in general. Until someone          /* This is potentially difficult to do in general. Until someone
455             comes up with a more efficient way of doing it I am using cases. */             comes up with a more efficient way of doing it I am using cases. */
# Line 453  void ui_triblt(uint8 opcode, Line 476  void ui_triblt(uint8 opcode,
476          }          }
477  }  }
478    
479  void ui_line(uint8 opcode,  void
480               /* dest */ int startx, int starty, int endx, int endy,  ui_line(uint8 opcode,
481               /* pen */ PEN *pen)          /* dest */ int startx, int starty, int endx, int endy,
482            /* pen */ PEN *pen)
483  {  {
484          xwin_set_function(opcode);          xwin_set_function(opcode);
485    
# Line 463  void ui_line(uint8 opcode, Line 487  void ui_line(uint8 opcode,
487          XDrawLine(display, wnd, gc, startx, starty, endx, endy);          XDrawLine(display, wnd, gc, startx, starty, endx, endy);
488  }  }
489    
490  void ui_rect(  void
491                      /* dest */ int x, int y, int cx, int cy,  ui_rect(
492                      /* brush */ int colour)                 /* dest */ int x, int y, int cx, int cy,
493                   /* brush */ int colour)
494  {  {
495          xwin_set_function(ROP2_COPY);          xwin_set_function(ROP2_COPY);
496    
# Line 473  void ui_rect( Line 498  void ui_rect(
498          XFillRectangle(display, wnd, gc, x, y, cx, cy);          XFillRectangle(display, wnd, gc, x, y, cx, cy);
499  }  }
500    
501  void ui_draw_glyph(int mixmode,  void
502                     /* dest */ int x, int y, int cx, int cy,  ui_draw_glyph(int mixmode,
503                     /* src */ HGLYPH glyph, int srcx, int srcy, int bgcolour,                /* dest */ int x, int y, int cx, int cy,
504                     int fgcolour)                /* src */ HGLYPH glyph, int srcx, int srcy, int bgcolour,
505                  int fgcolour)
506  {  {
507          Pixmap pixmap = (Pixmap) glyph;          Pixmap pixmap = (Pixmap) glyph;
508    
# Line 505  void ui_draw_glyph(int mixmode, Line 531  void ui_draw_glyph(int mixmode,
531          }          }
532  }  }
533    
534  void ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y,  void
535                    int clipx, int clipy, int clipcx, int clipcy,  ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y,
536                    int boxx, int boxy, int boxcx, int boxcy,               int clipx, int clipy, int clipcx, int clipcy,
537                    int bgcolour, int fgcolour, uint8 *text, uint8 length)               int boxx, int boxy, int boxcx, int boxcy,
538                 int bgcolour, int fgcolour, uint8 *text, uint8 length)
539  {  {
540          FONTGLYPH *glyph;          FONTGLYPH *glyph;
541          int i;          int i;
# Line 544  void ui_draw_text(uint8 font, uint8 flag Line 571  void ui_draw_text(uint8 font, uint8 flag
571          }          }
572  }  }
573    
574  void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)  void
575    ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
576  {  {
577          XImage *image;          XImage *image;
578    
# Line 554  void ui_desktop_save(uint32 offset, int Line 582  void ui_desktop_save(uint32 offset, int
582          XFree(image);          XFree(image);
583  }  }
584    
585  void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)  void
586    ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
587  {  {
588          XImage *image;          XImage *image;
589          uint8 *data;          uint8 *data;

Legend:
Removed from v.24  
changed lines
  Added in v.25

  ViewVC Help
Powered by ViewVC 1.1.26