/[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 70 by astrand, Sat Jul 27 23:09:32 2002 UTC revision 182 by astrand, Tue Sep 17 16:55:43 2002 UTC
# Line 25  Line 25 
25  #define XK_MISCELLANY  #define XK_MISCELLANY
26  #include <X11/keysymdef.h>  #include <X11/keysymdef.h>
27  #include "rdesktop.h"  #include "rdesktop.h"
28    #include "scancodes.h"
29    
30  extern int width;  extern int width;
31  extern int height;  extern int height;
32  extern BOOL sendmotion;  extern BOOL sendmotion;
33  extern BOOL fullscreen;  extern BOOL fullscreen;
34    extern BOOL grab_keyboard;
35    extern char title[];
36    
37  Display *display = NULL;  Display *display;
38  static int x_socket;  static int x_socket;
39    static Screen *screen;
40  static Window wnd;  static Window wnd;
41  static GC gc;  static GC gc;
42  static Visual *visual;  static Visual *visual;
# Line 57  static Pixmap backstore; Line 61  static Pixmap backstore;
61  /* colour maps */  /* colour maps */
62  static BOOL owncolmap;  static BOOL owncolmap;
63  static Colormap xcolmap;  static Colormap xcolmap;
 static uint32 white;  
64  static uint32 *colmap;  static uint32 *colmap;
 static XIM IM = NULL;  
 static XIC IC = NULL;  
65    
66  /* Compose support */  /* Compose support */
67  BOOL enable_compose = False;  BOOL enable_compose = False;
68    static XIM IM = NULL;
69    static XIC IC = NULL;
70    
71    /* toggle fullscreen globals */
72    static unsigned long input_mask;
73    
74  #define TRANSLATE(col)          ( owncolmap ? col : translate_colour(colmap[col]) )  #define TRANSLATE(col)          ( owncolmap ? col : translate_colour(colmap[col]) )
75  #define SET_FOREGROUND(col)     XSetForeground(display, gc, TRANSLATE(col));  #define SET_FOREGROUND(col)     XSetForeground(display, gc, TRANSLATE(col));
# Line 215  init_inputmethod(void) Line 221  init_inputmethod(void)
221             It seems to work alright anyway, though. */             It seems to work alright anyway, though. */
222          if (IC != NULL)          if (IC != NULL)
223          {          {
224                  if (XGetICValues(IC, XNFilterEvents, &filtered_events, NULL)                  if (XGetICValues(IC, XNFilterEvents, &filtered_events, NULL) != NULL)
                     != NULL)  
225                  {                  {
226                          error("Failed to obtain XNFilterEvents value from IC\n");                          error("Failed to obtain XNFilterEvents value from IC\n");
227                          filtered_events = 0;                          filtered_events = 0;
# Line 239  close_inputmethod(void) Line 244  close_inputmethod(void)
244          }          }
245  }  }
246    
247    BOOL
248    get_key_state(int keysym)
249    {
250            int keysymMask = 0, modifierpos, key;
251            Window wDummy1, wDummy2;
252            int iDummy3, iDummy4, iDummy5, iDummy6;
253            unsigned int current_state;
254            int offset;
255    
256            XModifierKeymap *map = XGetModifierMapping(display);
257            KeyCode keycode = XKeysymToKeycode(display, keysym);
258    
259            if (keycode == NoSymbol)
260                    return False;
261    
262            for (modifierpos = 0; modifierpos < 8; modifierpos++)
263            {
264                    offset = map->max_keypermod * modifierpos;
265    
266                    for (key = 0; key < map->max_keypermod; key++)
267                    {
268                            if (map->modifiermap[offset + key] == keycode)
269                                    keysymMask = 1 << modifierpos;
270                    }
271            }
272    
273            XQueryPointer(display, DefaultRootWindow(display), &wDummy1,
274                          &wDummy2, &iDummy3, &iDummy4, &iDummy5, &iDummy6, &current_state);
275    
276            XFreeModifiermap(map);
277    
278            return (current_state & keysymMask) ? True : False;
279    }
280    
281    static void
282    xwin_map_window()
283    {
284            XEvent xevent;
285    
286            XMapWindow(display, wnd);
287    
288            /* wait for VisibilityChange */
289            XMaskEvent(display, VisibilityChangeMask, &xevent);
290    
291            if (fullscreen)
292                    XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime);
293    }
294    
295  BOOL  BOOL
296  ui_create_window(char *title)  ui_init()
297  {  {
         XSetWindowAttributes attribs;  
         XClassHint *classhints;  
         XSizeHints *sizehints;  
         unsigned long input_mask;  
298          XPixmapFormatValues *pfm;          XPixmapFormatValues *pfm;
         Screen *screen;  
299          uint16 test;          uint16 test;
300          int i;          int i;
301    
302          display = XOpenDisplay(NULL);          display = XOpenDisplay(NULL);
   
303          if (display == NULL)          if (display == NULL)
304          {          {
305                  error("Failed to open display\n");                  error("Failed to open display\n");
# Line 272  ui_create_window(char *title) Line 318  ui_create_window(char *title)
318                     desirable, e.g. 24 bits->32 bits. */                     desirable, e.g. 24 bits->32 bits. */
319                  while (i--)                  while (i--)
320                  {                  {
321                          if ((pfm[i].depth == depth)                          if ((pfm[i].depth == depth) && (pfm[i].bits_per_pixel > bpp))
                             && (pfm[i].bits_per_pixel > bpp))  
322                          {                          {
323                                  bpp = pfm[i].bits_per_pixel;                                  bpp = pfm[i].bits_per_pixel;
324                          }                          }
# Line 293  ui_create_window(char *title) Line 338  ui_create_window(char *title)
338          else          else
339                  xcolmap = DefaultColormapOfScreen(screen);                  xcolmap = DefaultColormapOfScreen(screen);
340    
341            if (DoesBackingStore(screen) == NotUseful)
342                    ownbackstore = True;
343    
344          test = 1;          test = 1;
345          host_be = !(BOOL) (*(uint8 *) (&test));          host_be = !(BOOL) (*(uint8 *) (&test));
346          xserver_be = (ImageByteOrder(display) == MSBFirst);          xserver_be = (ImageByteOrder(display) == MSBFirst);
347    
         white = WhitePixelOfScreen(screen);  
         attribs.background_pixel = BlackPixelOfScreen(screen);  
         attribs.backing_store = DoesBackingStore(screen);  
   
         if (attribs.backing_store == NotUseful)  
                 ownbackstore = True;  
   
348          if (fullscreen)          if (fullscreen)
349          {          {
                 attribs.override_redirect = True;  
350                  width = WidthOfScreen(screen);                  width = WidthOfScreen(screen);
351                  height = HeightOfScreen(screen);                  height = HeightOfScreen(screen);
352          }          }
         else  
         {  
                 attribs.override_redirect = False;  
         }  
353    
354          width = (width + 3) & ~3;       /* make width a multiple of 32 bits */          /* make sure width is a multiple of 4 */
355            width = (width + 3) & ~3;
356    
357            xkeymap_init();
358            return True;
359    }
360    
361    BOOL
362    ui_create_window()
363    {
364            XSetWindowAttributes attribs;
365            XClassHint *classhints;
366            XSizeHints *sizehints;
367            XEvent xevent;
368    
369            attribs.background_pixel = BlackPixelOfScreen(screen);
370            attribs.backing_store = ownbackstore ? NotUseful : Always;
371            attribs.override_redirect = fullscreen;
372            wnd = XCreateWindow(display, RootWindowOfScreen(screen), 0, 0, width, height,
373                                0, CopyFromParent, InputOutput, CopyFromParent,
374                                CWBackPixel | CWBackingStore | CWOverrideRedirect, &attribs);
375    
376          wnd = XCreateWindow(display, RootWindowOfScreen(screen),          if (ownbackstore)
377                              0, 0, width, height, 0, CopyFromParent,                  backstore = XCreatePixmap(display, wnd, width, height, depth);
                             InputOutput, CopyFromParent,  
                             CWBackingStore | CWBackPixel | CWOverrideRedirect,  
                             &attribs);  
378    
379          XStoreName(display, wnd, title);          XStoreName(display, wnd, title);
380    
# Line 343  ui_create_window(char *title) Line 396  ui_create_window(char *title)
396                  XFree(sizehints);                  XFree(sizehints);
397          }          }
398    
399          xkeymap_init2();          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
400                    VisibilityChangeMask | FocusChangeMask;
401    
402          input_mask =          if (grab_keyboard)
403                  KeyPressMask | KeyReleaseMask | ButtonPressMask |                  input_mask |= EnterWindowMask | LeaveWindowMask;
                 ButtonReleaseMask | EnterWindowMask | LeaveWindowMask;  
404          if (sendmotion)          if (sendmotion)
405                  input_mask |= PointerMotionMask;                  input_mask |= PointerMotionMask;
   
406          if (ownbackstore)          if (ownbackstore)
407                  input_mask |= ExposureMask;                  input_mask |= ExposureMask;
   
408          if (enable_compose)          if (enable_compose)
409                  input_mask |= init_inputmethod();                  input_mask |= init_inputmethod();
410    
411          XSelectInput(display, wnd, input_mask);          XSelectInput(display, wnd, input_mask);
412    
413          gc = XCreateGC(display, wnd, 0, NULL);          xwin_map_window();
   
         if (ownbackstore)  
                 backstore = XCreatePixmap(display, wnd, width, height, depth);  
414    
415          XMapWindow(display, wnd);          /* clear the window so that cached data is not seen */
416            gc = XCreateGC(display, wnd, 0, NULL);
417            XSetForeground(display, gc, 0);
418            FILL_RECTANGLE(0, 0, width, height);
419    
420          return True;          return True;
421  }  }
# Line 384  ui_destroy_window() Line 435  ui_destroy_window()
435          display = NULL;          display = NULL;
436  }  }
437    
438    
439    void
440    xwin_toggle_fullscreen()
441    {
442            XEvent xevent;
443            XSetWindowAttributes attribs;
444            int newwidth, newheight;
445    
446            fullscreen = !fullscreen;
447            newwidth = fullscreen ? WidthOfScreen(screen) : width;
448            newheight = fullscreen ? HeightOfScreen(screen) : height;
449    
450            XUnmapWindow(display, wnd);
451            attribs.override_redirect = fullscreen;
452            XMoveResizeWindow(display, wnd, 0, 0, newwidth, newheight);
453            XChangeWindowAttributes(display, wnd, CWOverrideRedirect, &attribs);
454            xwin_map_window();
455    }
456    
457    /* Process all events in Xlib queue */
458  static void  static void
459  xwin_process_events()  xwin_process_events()
460  {  {
461          XEvent xevent;          XEvent xevent;
   
462          KeySym keysym;          KeySym keysym;
463          uint16 button, flags;          uint16 button, flags;
464          uint32 ev_time;          uint32 ev_time;
# Line 397  xwin_process_events() Line 467  xwin_process_events()
467          char str[256];          char str[256];
468          Status status;          Status status;
469    
470          /* Refresh keyboard mapping if it has changed. This is important for          while (XPending(display) > 0)
            Xvnc, since it allocates keycodes dynamically */  
         if (XCheckTypedEvent(display, MappingNotify, &xevent))  
471          {          {
472                  if (xevent.xmapping.request == MappingKeyboard                  XNextEvent(display, &xevent);
                     || xevent.xmapping.request == MappingModifier)  
                         XRefreshKeyboardMapping(&xevent.xmapping);  
         }  
473    
         while (XCheckMaskEvent(display, ~0, &xevent))  
         {  
474                  if (enable_compose && (XFilterEvent(&xevent, None) == True))                  if (enable_compose && (XFilterEvent(&xevent, None) == True))
475                  {                  {
476                          DEBUG_KBD("Filtering event\n");                          DEBUG_KBD(("Filtering event\n"));
477                          continue;                          continue;
478                  }                  }
479    
# Line 425  xwin_process_events() Line 488  xwin_process_events()
488                                  {                                  {
489                                          XmbLookupString(IC,                                          XmbLookupString(IC,
490                                                          (XKeyPressedEvent *) &                                                          (XKeyPressedEvent *) &
491                                                          xevent, str,                                                          xevent, str, sizeof(str), &keysym, &status);
492                                                          sizeof(str), &keysym,                                          if (!((status == XLookupKeySym) || (status == XLookupBoth)))
                                                         &status);  
                                         if (!  
                                             ((status == XLookupKeySym)  
                                              || (status == XLookupBoth)))  
493                                          {                                          {
494                                                  error("XmbLookupString failed with status 0x%x\n", status);                                                  error("XmbLookupString failed with status 0x%x\n",
495                                                          status);
496                                                  break;                                                  break;
497                                          }                                          }
498                                  }                                  }
499                                  else                                  else
500                                  {                                  {
501                                          /* Plain old XLookupString */                                          /* Plain old XLookupString */
502                                          DEBUG_KBD                                          DEBUG_KBD(("\nNo input context, using XLookupString\n"));
                                                 ("No input context, using XLookupString\n");  
503                                          XLookupString((XKeyEvent *) & xevent,                                          XLookupString((XKeyEvent *) & xevent,
504                                                        str, sizeof(str),                                                        str, sizeof(str), &keysym, NULL);
                                                       &keysym, NULL);  
505                                  }                                  }
506    
507                                  ksname = get_ksname(keysym);                                  ksname = get_ksname(keysym);
508                                  DEBUG_KBD                                  DEBUG_KBD(("KeyPress for (keysym 0x%lx, %s)\n", keysym, ksname));
                                         ("\nKeyPress for (keysym 0x%lx, %s)\n",  
                                          keysym, ksname);  
509    
510                                  if (inhibit_key(keysym))                                  if (handle_special_keys(keysym, ev_time, True))
                                 {  
                                         DEBUG_KBD("Inhibiting key\n");  
511                                          break;                                          break;
                                 }  
512    
513                                  tr = xkeymap_translate_key(keysym,                                  tr = xkeymap_translate_key(keysym,
514                                                             xevent.xkey.                                                             xevent.xkey.keycode, xevent.xkey.state);
                                                            keycode,  
                                                            xevent.xkey.state);  
   
                                 ensure_remote_modifiers(ev_time, tr);  
515    
516                                  if (tr.scancode == 0)                                  if (tr.scancode == 0)
517                                          break;                                          break;
518    
519                                  rdp_send_scancode(ev_time, RDP_KEYPRESS,                                  ensure_remote_modifiers(ev_time, tr);
520                                                    tr.scancode);  
521                                    rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode);
522                                  break;                                  break;
523                          case KeyRelease:                          case KeyRelease:
524                                  XLookupString((XKeyEvent *) & xevent, str,                                  XLookupString((XKeyEvent *) & xevent, str,
525                                                sizeof(str), &keysym, NULL);                                                sizeof(str), &keysym, NULL);
526    
527                                  ksname = get_ksname(keysym);                                  ksname = get_ksname(keysym);
528                                  DEBUG_KBD                                  DEBUG_KBD(("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym,
529                                          ("\nKeyRelease for (keysym 0x%lx, %s)\n",                                             ksname));
                                          keysym, ksname);  
530    
531                                  if (inhibit_key(keysym))                                  if (handle_special_keys(keysym, ev_time, False))
532                                          break;                                          break;
533    
534                                  tr = xkeymap_translate_key(keysym,                                  tr = xkeymap_translate_key(keysym,
535                                                             xevent.xkey.                                                             xevent.xkey.keycode, xevent.xkey.state);
                                                            keycode,  
                                                            xevent.xkey.state);  
536    
537                                  if (tr.scancode == 0)                                  if (tr.scancode == 0)
538                                          break;                                          break;
539    
540                                  rdp_send_scancode(ev_time, RDP_KEYRELEASE,                                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, tr.scancode);
                                                   tr.scancode);  
541                                  break;                                  break;
542    
543                          case ButtonPress:                          case ButtonPress:
# Line 499  xwin_process_events() Line 545  xwin_process_events()
545                                  /* fall through */                                  /* fall through */
546    
547                          case ButtonRelease:                          case ButtonRelease:
548                                  button = xkeymap_translate_button(xevent.                                  button = xkeymap_translate_button(xevent.xbutton.button);
                                                                   xbutton.  
                                                                   button);  
549                                  if (button == 0)                                  if (button == 0)
550                                          break;                                          break;
551    
552                                  rdp_send_input(ev_time, RDP_INPUT_MOUSE,                                  rdp_send_input(ev_time, RDP_INPUT_MOUSE,
553                                                 flags | button,                                                 flags | button, xevent.xbutton.x, xevent.xbutton.y);
                                                xevent.xbutton.x,  
                                                xevent.xbutton.y);  
554                                  break;                                  break;
555    
556                          case MotionNotify:                          case MotionNotify:
557                                  rdp_send_input(ev_time, RDP_INPUT_MOUSE,                                  rdp_send_input(ev_time, RDP_INPUT_MOUSE,
558                                                 MOUSE_FLAG_MOVE,                                                 MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y);
                                                xevent.xmotion.x,  
                                                xevent.xmotion.y);  
559                                  break;                                  break;
560    
561                          case EnterNotify:                          case EnterNotify:
562                                  XGrabKeyboard(display, wnd, True,                                  if (grab_keyboard)
563                                                GrabModeAsync, GrabModeAsync,                                          XGrabKeyboard(display, wnd, True,
564                                                CurrentTime);                                                        GrabModeAsync, GrabModeAsync, CurrentTime);
565                                  break;                                  break;
566    
567                          case LeaveNotify:                          case LeaveNotify:
568                                  XUngrabKeyboard(display, CurrentTime);                                  if (grab_keyboard)
569                                            XUngrabKeyboard(display, CurrentTime);
570                                    break;
571    
572                            case FocusIn:
573                                    reset_modifier_keys();
574                                  break;                                  break;
575    
576                          case Expose:                          case Expose:
# Line 535  xwin_process_events() Line 580  xwin_process_events()
580                                            xevent.xexpose.height,                                            xevent.xexpose.height,
581                                            xevent.xexpose.x, xevent.xexpose.y);                                            xevent.xexpose.x, xevent.xexpose.y);
582                                  break;                                  break;
583    
584                            case MappingNotify:
585                                    /* Refresh keyboard mapping if it has changed. This is important for
586                                       Xvnc, since it allocates keycodes dynamically */
587                                    if (xevent.xmapping.request == MappingKeyboard
588                                        || xevent.xmapping.request == MappingModifier)
589                                            XRefreshKeyboardMapping(&xevent.xmapping);
590                                    break;
591    
592                  }                  }
593          }          }
594  }  }
# Line 549  ui_select(int rdp_socket) Line 603  ui_select(int rdp_socket)
603    
604          while (True)          while (True)
605          {          {
606                    /* Process any events already waiting */
607                    xwin_process_events();
608    
609                  FD_ZERO(&rfds);                  FD_ZERO(&rfds);
610                  FD_SET(rdp_socket, &rfds);                  FD_SET(rdp_socket, &rfds);
611                  if (display != NULL)                  FD_SET(x_socket, &rfds);
                 {  
                         FD_SET(x_socket, &rfds);  
                         XFlush(display);  
                 }  
612    
613                  switch (select(n, &rfds, NULL, NULL, NULL))                  switch (select(n, &rfds, NULL, NULL, NULL))
614                  {                  {
# Line 566  ui_select(int rdp_socket) Line 619  ui_select(int rdp_socket)
619                                  continue;                                  continue;
620                  }                  }
621    
                 if (FD_ISSET(x_socket, &rfds))  
                         xwin_process_events();  
   
622                  if (FD_ISSET(rdp_socket, &rfds))                  if (FD_ISSET(rdp_socket, &rfds))
623                          return;                          return;
624          }          }
# Line 589  ui_create_bitmap(int width, int height, Line 639  ui_create_bitmap(int width, int height,
639    
640          tdata = (owncolmap ? data : translate_image(width, height, data));          tdata = (owncolmap ? data : translate_image(width, height, data));
641          bitmap = XCreatePixmap(display, wnd, width, height, depth);          bitmap = XCreatePixmap(display, wnd, width, height, depth);
642          image = XCreateImage(display, visual, depth, ZPixmap, 0, tdata, width,          image = XCreateImage(display, visual, depth, ZPixmap, 0,
643                               height, 8, 0);                               (char *) tdata, width, height, 8, 0);
644    
645          XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height);          XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height);
646    
# Line 601  ui_create_bitmap(int width, int height, Line 651  ui_create_bitmap(int width, int height,
651  }  }
652    
653  void  void
654  ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height,  ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 * data)
                 uint8 * data)  
655  {  {
656          XImage *image;          XImage *image;
657          uint8 *tdata;          uint8 *tdata;
658    
659          tdata = (owncolmap ? data : translate_image(width, height, data));          tdata = (owncolmap ? data : translate_image(width, height, data));
660          image = XCreateImage(display, visual, depth, ZPixmap, 0, tdata, width,          image = XCreateImage(display, visual, depth, ZPixmap, 0,
661                               height, 8, 0);                               (char *) tdata, width, height, 8, 0);
662    
663          if (ownbackstore)          if (ownbackstore)
664          {          {
# Line 645  ui_create_glyph(int width, int height, u Line 694  ui_create_glyph(int width, int height, u
694          bitmap = XCreatePixmap(display, wnd, width, height, 1);          bitmap = XCreatePixmap(display, wnd, width, height, 1);
695          gc = XCreateGC(display, bitmap, 0, NULL);          gc = XCreateGC(display, bitmap, 0, NULL);
696    
697          image = XCreateImage(display, visual, 1, ZPixmap, 0, data, width,          image = XCreateImage(display, visual, 1, ZPixmap, 0, (char *) data,
698                               height, 8, scanline);                               width, height, 8, scanline);
699          image->byte_order = MSBFirst;          image->byte_order = MSBFirst;
700          image->bitmap_bit_order = MSBFirst;          image->bitmap_bit_order = MSBFirst;
701          XInitImage(image);          XInitImage(image);
# Line 793  ui_create_colourmap(COLOURMAP * colours) Line 842  ui_create_colourmap(COLOURMAP * colours)
842                          if (XAllocColor(display, xcolmap, &xentry) != 0)                          if (XAllocColor(display, xcolmap, &xentry) != 0)
843                                  colour = xentry.pixel;                                  colour = xentry.pixel;
844                          else                          else
845                                  colour = white;                                  colour = WhitePixelOfScreen(screen);
846    
847                          /* byte swap here to make translate_image faster */                          /* byte swap here to make translate_image faster */
848                          map[i] = translate_colour(colour);                          map[i] = translate_colour(colour);
# Line 886  ui_patblt(uint8 opcode, Line 935  ui_patblt(uint8 opcode,
935                          SET_BACKGROUND(fgcolour);                          SET_BACKGROUND(fgcolour);
936                          XSetFillStyle(display, gc, FillOpaqueStippled);                          XSetFillStyle(display, gc, FillOpaqueStippled);
937                          XSetStipple(display, gc, fill);                          XSetStipple(display, gc, fill);
938                          XSetTSOrigin(display, gc, brush->xorigin,                          XSetTSOrigin(display, gc, brush->xorigin, brush->yorigin);
                                      brush->yorigin);  
939    
940                          FILL_RECTANGLE(x, y, cx, cy);                          FILL_RECTANGLE(x, y, cx, cy);
941    
942                          XSetFillStyle(display, gc, FillSolid);                          XSetFillStyle(display, gc, FillSolid);
943                            XSetTSOrigin(display, gc, 0, 0);
944                          ui_destroy_glyph((HGLYPH) fill);                          ui_destroy_glyph((HGLYPH) fill);
945                          break;                          break;
946    
# Line 910  ui_screenblt(uint8 opcode, Line 959  ui_screenblt(uint8 opcode,
959          SET_FUNCTION(opcode);          SET_FUNCTION(opcode);
960          XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y);          XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y);
961          if (ownbackstore)          if (ownbackstore)
962                  XCopyArea(display, backstore, backstore, gc, srcx, srcy, cx,                  XCopyArea(display, backstore, backstore, gc, srcx, srcy, cx, cy, x, y);
                           cy, x, y);  
963          RESET_FUNCTION(opcode);          RESET_FUNCTION(opcode);
964  }  }
965    
# Line 923  ui_memblt(uint8 opcode, Line 971  ui_memblt(uint8 opcode,
971          SET_FUNCTION(opcode);          SET_FUNCTION(opcode);
972          XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y);          XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y);
973          if (ownbackstore)          if (ownbackstore)
974                  XCopyArea(display, (Pixmap) src, backstore, gc, srcx, srcy,                  XCopyArea(display, (Pixmap) src, backstore, gc, srcx, srcy, cx, cy, x, y);
                           cx, cy, x, y);  
975          RESET_FUNCTION(opcode);          RESET_FUNCTION(opcode);
976  }  }
977    
# Line 941  ui_triblt(uint8 opcode, Line 988  ui_triblt(uint8 opcode,
988          {          {
989                  case 0x69:      /* PDSxxn */                  case 0x69:      /* PDSxxn */
990                          ui_memblt(ROP2_XOR, x, y, cx, cy, src, srcx, srcy);                          ui_memblt(ROP2_XOR, x, y, cx, cy, src, srcx, srcy);
991                          ui_patblt(ROP2_NXOR, x, y, cx, cy, brush, bgcolour,                          ui_patblt(ROP2_NXOR, x, y, cx, cy, brush, bgcolour, fgcolour);
                                   fgcolour);  
992                          break;                          break;
993    
994                  case 0xb8:      /* PSDPxax */                  case 0xb8:      /* PSDPxax */
995                          ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour,                          ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour);
                                   fgcolour);  
996                          ui_memblt(ROP2_AND, x, y, cx, cy, src, srcx, srcy);                          ui_memblt(ROP2_AND, x, y, cx, cy, src, srcx, srcy);
997                          ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour,                          ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour);
                                   fgcolour);  
998                          break;                          break;
999    
1000                  case 0xc0:      /* PSa */                  case 0xc0:      /* PSa */
1001                          ui_memblt(ROP2_COPY, x, y, cx, cy, src, srcx, srcy);                          ui_memblt(ROP2_COPY, x, y, cx, cy, src, srcx, srcy);
1002                          ui_patblt(ROP2_AND, x, y, cx, cy, brush, bgcolour,                          ui_patblt(ROP2_AND, x, y, cx, cy, brush, bgcolour, fgcolour);
                                   fgcolour);  
1003                          break;                          break;
1004    
1005                  default:                  default:
# Line 997  ui_draw_glyph(int mixmode, Line 1040  ui_draw_glyph(int mixmode,
1040          SET_BACKGROUND(bgcolour);          SET_BACKGROUND(bgcolour);
1041    
1042          XSetFillStyle(display, gc,          XSetFillStyle(display, gc,
1043                        (mixmode ==                        (mixmode == MIX_TRANSPARENT) ? FillStippled : FillOpaqueStippled);
                        MIX_TRANSPARENT) ? FillStippled : FillOpaqueStippled);  
1044          XSetStipple(display, gc, (Pixmap) glyph);          XSetStipple(display, gc, (Pixmap) glyph);
1045          XSetTSOrigin(display, gc, x, y);          XSetTSOrigin(display, gc, x, y);
1046    
# Line 1016  ui_draw_glyph(int mixmode, Line 1058  ui_draw_glyph(int mixmode,
1058        if ((xyoffset & 0x80))\        if ((xyoffset & 0x80))\
1059          {\          {\
1060            if (flags & TEXT2_VERTICAL) \            if (flags & TEXT2_VERTICAL) \
1061              y += ttext[++idx] | (ttext[++idx] << 8);\              y += ttext[idx+1] | (ttext[idx+2] << 8);\
1062            else\            else\
1063              x += ttext[++idx] | (ttext[++idx] << 8);\              x += ttext[idx+1] | (ttext[idx+2] << 8);\
1064              idx += 2;\
1065          }\          }\
1066        else\        else\
1067          {\          {\
# Line 1067  ui_draw_text(uint8 font, uint8 flags, in Line 1110  ui_draw_text(uint8 font, uint8 flags, in
1110                  {                  {
1111                          case 0xff:                          case 0xff:
1112                                  if (i + 2 < length)                                  if (i + 2 < length)
1113                                          cache_put_text(text[i + 1], text,                                          cache_put_text(text[i + 1], text, text[i + 2]);
                                                        text[i + 2]);  
1114                                  else                                  else
1115                                  {                                  {
1116                                          error("this shouldn't be happening\n");                                          error("this shouldn't be happening\n");
# Line 1085  ui_draw_text(uint8 font, uint8 flags, in Line 1127  ui_draw_text(uint8 font, uint8 flags, in
1127                                  if (entry != NULL)                                  if (entry != NULL)
1128                                  {                                  {
1129                                          if ((((uint8 *) (entry->data))[1] ==                                          if ((((uint8 *) (entry->data))[1] ==
1130                                               0)                                               0) && (!(flags & TEXT2_IMPLICIT_X)))
                                             && (!(flags & TEXT2_IMPLICIT_X)))  
1131                                          {                                          {
1132                                                  if (flags & TEXT2_VERTICAL)                                                  if (flags & TEXT2_VERTICAL)
1133                                                          y += text[i + 2];                                                          y += text[i + 2];
# Line 1102  ui_draw_text(uint8 font, uint8 flags, in Line 1143  ui_draw_text(uint8 font, uint8 flags, in
1143                                          text = &(text[i]);                                          text = &(text[i]);
1144                                          i = 0;                                          i = 0;
1145                                          for (j = 0; j < entry->size; j++)                                          for (j = 0; j < entry->size; j++)
1146                                                  DO_GLYPH(((uint8 *) (entry->                                                  DO_GLYPH(((uint8 *) (entry->data)), j);
                                                                      data)),  
                                                          j);  
1147                                  }                                  }
1148                                  break;                                  break;
1149    
# Line 1126  ui_desktop_save(uint32 offset, int x, in Line 1165  ui_desktop_save(uint32 offset, int x, in
1165    
1166          if (ownbackstore)          if (ownbackstore)
1167          {          {
1168                  image = XGetImage(display, backstore, x, y, cx, cy, AllPlanes,                  image = XGetImage(display, backstore, x, y, cx, cy, AllPlanes, ZPixmap);
                                   ZPixmap);  
1169          }          }
1170          else          else
1171          {          {
1172                  pix = XCreatePixmap(display, wnd, cx, cy, depth);                  pix = XCreatePixmap(display, wnd, cx, cy, depth);
1173                  XCopyArea(display, wnd, pix, gc, x, y, cx, cy, 0, 0);                  XCopyArea(display, wnd, pix, gc, x, y, cx, cy, 0, 0);
1174                  image = XGetImage(display, pix, 0, 0, cx, cy, AllPlanes,                  image = XGetImage(display, pix, 0, 0, cx, cy, AllPlanes, ZPixmap);
                                   ZPixmap);  
1175                  XFreePixmap(display, pix);                  XFreePixmap(display, pix);
1176          }          }
1177    
1178          offset *= bpp / 8;          offset *= bpp / 8;
1179          cache_put_desktop(offset, cx, cy, image->bytes_per_line, bpp / 8,          cache_put_desktop(offset, cx, cy, image->bytes_per_line, bpp / 8, (uint8 *) image->data);
                           (uint8 *) image->data);  
1180    
1181          XDestroyImage(image);          XDestroyImage(image);
1182  }  }
# Line 1156  ui_desktop_restore(uint32 offset, int x, Line 1192  ui_desktop_restore(uint32 offset, int x,
1192          if (data == NULL)          if (data == NULL)
1193                  return;                  return;
1194    
1195          image = XCreateImage(display, visual, depth, ZPixmap, 0, data, cx, cy,          image = XCreateImage(display, visual, depth, ZPixmap, 0,
1196                               BitmapPad(display), cx * bpp / 8);                               (char *) data, cx, cy, BitmapPad(display), cx * bpp / 8);
1197    
1198          if (ownbackstore)          if (ownbackstore)
1199          {          {

Legend:
Removed from v.70  
changed lines
  Added in v.182

  ViewVC Help
Powered by ViewVC 1.1.26