/[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 80 by jsorg71, Tue Jul 30 00:56:48 2002 UTC revision 84 by astrand, Tue Jul 30 07:30:12 2002 UTC
# Line 217  init_inputmethod(void) Line 217  init_inputmethod(void)
217             It seems to work alright anyway, though. */             It seems to work alright anyway, though. */
218          if (IC != NULL)          if (IC != NULL)
219          {          {
220                  if (XGetICValues(IC, XNFilterEvents, &filtered_events, NULL)                  if (XGetICValues(IC, XNFilterEvents, &filtered_events, NULL) != NULL)
                     != NULL)  
221                  {                  {
222                          error("Failed to obtain XNFilterEvents value from IC\n");                          error("Failed to obtain XNFilterEvents value from IC\n");
223                          filtered_events = 0;                          filtered_events = 0;
# Line 241  close_inputmethod(void) Line 240  close_inputmethod(void)
240          }          }
241  }  }
242    
243    BOOL
244    ui_init()
245    {
246            Screen *screen;
247            display = XOpenDisplay(NULL);
248            if (display == NULL)
249            {
250                    error("Failed to open display\n");
251                    return False;
252            }
253            if (fullscreen)
254            {
255                    screen = DefaultScreenOfDisplay(display);
256                    width = WidthOfScreen(screen);
257                    height = HeightOfScreen(screen);
258            }
259            return True;
260    }
261    
262  BOOL  BOOL
263  ui_create_window(char *title)  ui_create_window(char *title)
# Line 254  ui_create_window(char *title) Line 271  ui_create_window(char *title)
271          uint16 test;          uint16 test;
272          int i;          int i;
273    
         display = XOpenDisplay(NULL);  
   
         if (display == NULL)  
         {  
                 error("Failed to open display\n");  
                 return False;  
         }  
   
274          x_socket = ConnectionNumber(display);          x_socket = ConnectionNumber(display);
275          screen = DefaultScreenOfDisplay(display);          screen = DefaultScreenOfDisplay(display);
276          visual = DefaultVisualOfScreen(screen);          visual = DefaultVisualOfScreen(screen);
# Line 274  ui_create_window(char *title) Line 283  ui_create_window(char *title)
283                     desirable, e.g. 24 bits->32 bits. */                     desirable, e.g. 24 bits->32 bits. */
284                  while (i--)                  while (i--)
285                  {                  {
286                          if ((pfm[i].depth == depth)                          if ((pfm[i].depth == depth) && (pfm[i].bits_per_pixel > bpp))
                             && (pfm[i].bits_per_pixel > bpp))  
287                          {                          {
288                                  bpp = pfm[i].bits_per_pixel;                                  bpp = pfm[i].bits_per_pixel;
289                          }                          }
# Line 322  ui_create_window(char *title) Line 330  ui_create_window(char *title)
330          wnd = XCreateWindow(display, RootWindowOfScreen(screen),          wnd = XCreateWindow(display, RootWindowOfScreen(screen),
331                              0, 0, width, height, 0, CopyFromParent,                              0, 0, width, height, 0, CopyFromParent,
332                              InputOutput, CopyFromParent,                              InputOutput, CopyFromParent,
333                              CWBackingStore | CWBackPixel | CWOverrideRedirect,                              CWBackingStore | CWBackPixel | CWOverrideRedirect, &attribs);
                             &attribs);  
334    
335          XStoreName(display, wnd, title);          XStoreName(display, wnd, title);
336    
# Line 347  ui_create_window(char *title) Line 354  ui_create_window(char *title)
354    
355          xkeymap_init2();          xkeymap_init2();
356    
357          input_mask =          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask;
                 KeyPressMask | KeyReleaseMask | ButtonPressMask |  
                 ButtonReleaseMask;  
358          if (grab_keyboard)          if (grab_keyboard)
359                  input_mask |= EnterWindowMask | LeaveWindowMask;                  input_mask |= EnterWindowMask | LeaveWindowMask;
360          if (sendmotion)          if (sendmotion)
# Line 414  xwin_process_events() Line 419  xwin_process_events()
419          {          {
420                  if (enable_compose && (XFilterEvent(&xevent, None) == True))                  if (enable_compose && (XFilterEvent(&xevent, None) == True))
421                  {                  {
422                          DEBUG_KBD("Filtering event\n");                          DEBUG_KBD(("Filtering event\n"));
423                          continue;                          continue;
424                  }                  }
425    
# Line 429  xwin_process_events() Line 434  xwin_process_events()
434                                  {                                  {
435                                          XmbLookupString(IC,                                          XmbLookupString(IC,
436                                                          (XKeyPressedEvent *) &                                                          (XKeyPressedEvent *) &
437                                                          xevent, str,                                                          xevent, str, sizeof(str), &keysym, &status);
438                                                          sizeof(str), &keysym,                                          if (!((status == XLookupKeySym) || (status == XLookupBoth)))
                                                         &status);  
                                         if (!  
                                             ((status == XLookupKeySym)  
                                              || (status == XLookupBoth)))  
439                                          {                                          {
440                                                  error("XmbLookupString failed with status 0x%x\n", status);                                                  error("XmbLookupString failed with status 0x%x\n",
441                                                          status);
442                                                  break;                                                  break;
443                                          }                                          }
444                                  }                                  }
445                                  else                                  else
446                                  {                                  {
447                                          /* Plain old XLookupString */                                          /* Plain old XLookupString */
448                                          DEBUG_KBD                                          DEBUG_KBD(("No input context, using XLookupString\n"));
                                                 ("No input context, using XLookupString\n");  
449                                          XLookupString((XKeyEvent *) & xevent,                                          XLookupString((XKeyEvent *) & xevent,
450                                                        str, sizeof(str),                                                        str, sizeof(str), &keysym, NULL);
                                                       &keysym, NULL);  
451                                  }                                  }
452    
453                                  ksname = get_ksname(keysym);                                  ksname = get_ksname(keysym);
454                                  DEBUG_KBD                                  DEBUG_KBD(("\nKeyPress for (keysym 0x%lx, %s)\n", keysym, ksname));
                                         ("\nKeyPress for (keysym 0x%lx, %s)\n",  
                                          keysym, ksname);  
455    
456                                  if (inhibit_key(keysym))                                  if (inhibit_key(keysym))
457                                  {                                  {
458                                          DEBUG_KBD("Inhibiting key\n");                                          DEBUG_KBD(("Inhibiting key\n"));
459                                          break;                                          break;
460                                  }                                  }
461    
462                                  tr = xkeymap_translate_key(keysym,                                  tr = xkeymap_translate_key(keysym,
463                                                             xevent.xkey.                                                             xevent.xkey.keycode, xevent.xkey.state);
                                                            keycode,  
                                                            xevent.xkey.state);  
464    
465                                  ensure_remote_modifiers(ev_time, tr);                                  ensure_remote_modifiers(ev_time, tr);
466    
467                                  if (tr.scancode == 0)                                  if (tr.scancode == 0)
468                                          break;                                          break;
469    
470                                  rdp_send_scancode(ev_time, RDP_KEYPRESS,                                  rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode);
                                                   tr.scancode);  
471                                  break;                                  break;
472                          case KeyRelease:                          case KeyRelease:
473                                  XLookupString((XKeyEvent *) & xevent, str,                                  XLookupString((XKeyEvent *) & xevent, str,
474                                                sizeof(str), &keysym, NULL);                                                sizeof(str), &keysym, NULL);
475    
476                                  ksname = get_ksname(keysym);                                  ksname = get_ksname(keysym);
477                                  DEBUG_KBD                                  DEBUG_KBD(("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym,
478                                          ("\nKeyRelease for (keysym 0x%lx, %s)\n",                                             ksname));
                                          keysym, ksname);  
479    
480                                  if (inhibit_key(keysym))                                  if (inhibit_key(keysym))
481                                          break;                                          break;
482    
483                                  tr = xkeymap_translate_key(keysym,                                  tr = xkeymap_translate_key(keysym,
484                                                             xevent.xkey.                                                             xevent.xkey.keycode, xevent.xkey.state);
                                                            keycode,  
                                                            xevent.xkey.state);  
485    
486                                  if (tr.scancode == 0)                                  if (tr.scancode == 0)
487                                          break;                                          break;
488    
489                                  rdp_send_scancode(ev_time, RDP_KEYRELEASE,                                  rdp_send_scancode(ev_time, RDP_KEYRELEASE, tr.scancode);
                                                   tr.scancode);  
490                                  break;                                  break;
491    
492                          case ButtonPress:                          case ButtonPress:
# Line 503  xwin_process_events() Line 494  xwin_process_events()
494                                  /* fall through */                                  /* fall through */
495    
496                          case ButtonRelease:                          case ButtonRelease:
497                                  button = xkeymap_translate_button(xevent.                                  button = xkeymap_translate_button(xevent.xbutton.button);
                                                                   xbutton.  
                                                                   button);  
498                                  if (button == 0)                                  if (button == 0)
499                                          break;                                          break;
500    
501                                  rdp_send_input(ev_time, RDP_INPUT_MOUSE,                                  rdp_send_input(ev_time, RDP_INPUT_MOUSE,
502                                                 flags | button,                                                 flags | button, xevent.xbutton.x, xevent.xbutton.y);
                                                xevent.xbutton.x,  
                                                xevent.xbutton.y);  
503                                  break;                                  break;
504    
505                          case MotionNotify:                          case MotionNotify:
506                                  rdp_send_input(ev_time, RDP_INPUT_MOUSE,                                  rdp_send_input(ev_time, RDP_INPUT_MOUSE,
507                                                 MOUSE_FLAG_MOVE,                                                 MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y);
                                                xevent.xmotion.x,  
                                                xevent.xmotion.y);  
508                                  break;                                  break;
509    
510                          case FocusIn:                          case FocusIn:
# Line 527  xwin_process_events() Line 512  xwin_process_events()
512                          case EnterNotify:                          case EnterNotify:
513                                  if (grab_keyboard)                                  if (grab_keyboard)
514                                          XGrabKeyboard(display, wnd, True,                                          XGrabKeyboard(display, wnd, True,
515                                                        GrabModeAsync,                                                        GrabModeAsync, GrabModeAsync, CurrentTime);
                                                       GrabModeAsync,  
                                                       CurrentTime);  
516                                  break;                                  break;
517    
518                          case FocusOut:                          case FocusOut:
519                                  /* reset keys */                                  /* reset keys */
520                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
521                                                 KBD_FLAG_DOWN | KBD_FLAG_UP,                                                 KBD_FLAG_DOWN | KBD_FLAG_UP, SCANCODE_CHAR_LCTRL, 0);
                                                SCANCODE_CHAR_LCTRL, 0);  
522                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,                                  rdp_send_input(ev_time, RDP_INPUT_SCANCODE,
523                                                 KBD_FLAG_DOWN | KBD_FLAG_UP,                                                 KBD_FLAG_DOWN | KBD_FLAG_UP, SCANCODE_CHAR_LALT, 0);
                                                SCANCODE_CHAR_LALT, 0);  
524                                  /* fall through */                                  /* fall through */
525                          case LeaveNotify:                          case LeaveNotify:
526                                  if (grab_keyboard)                                  if (grab_keyboard)
# Line 619  ui_create_bitmap(int width, int height, Line 600  ui_create_bitmap(int width, int height,
600  }  }
601    
602  void  void
603  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)  
604  {  {
605          XImage *image;          XImage *image;
606          uint8 *tdata;          uint8 *tdata;
# Line 904  ui_patblt(uint8 opcode, Line 884  ui_patblt(uint8 opcode,
884                          SET_BACKGROUND(fgcolour);                          SET_BACKGROUND(fgcolour);
885                          XSetFillStyle(display, gc, FillOpaqueStippled);                          XSetFillStyle(display, gc, FillOpaqueStippled);
886                          XSetStipple(display, gc, fill);                          XSetStipple(display, gc, fill);
887                          XSetTSOrigin(display, gc, brush->xorigin,                          XSetTSOrigin(display, gc, brush->xorigin, brush->yorigin);
                                      brush->yorigin);  
888    
889                          FILL_RECTANGLE(x, y, cx, cy);                          FILL_RECTANGLE(x, y, cx, cy);
890    
# Line 929  ui_screenblt(uint8 opcode, Line 908  ui_screenblt(uint8 opcode,
908          SET_FUNCTION(opcode);          SET_FUNCTION(opcode);
909          XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y);          XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y);
910          if (ownbackstore)          if (ownbackstore)
911                  XCopyArea(display, backstore, backstore, gc, srcx, srcy, cx,                  XCopyArea(display, backstore, backstore, gc, srcx, srcy, cx, cy, x, y);
                           cy, x, y);  
912          RESET_FUNCTION(opcode);          RESET_FUNCTION(opcode);
913  }  }
914    
# Line 942  ui_memblt(uint8 opcode, Line 920  ui_memblt(uint8 opcode,
920          SET_FUNCTION(opcode);          SET_FUNCTION(opcode);
921          XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y);          XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y);
922          if (ownbackstore)          if (ownbackstore)
923                  XCopyArea(display, (Pixmap) src, backstore, gc, srcx, srcy,                  XCopyArea(display, (Pixmap) src, backstore, gc, srcx, srcy, cx, cy, x, y);
                           cx, cy, x, y);  
924          RESET_FUNCTION(opcode);          RESET_FUNCTION(opcode);
925  }  }
926    
# Line 960  ui_triblt(uint8 opcode, Line 937  ui_triblt(uint8 opcode,
937          {          {
938                  case 0x69:      /* PDSxxn */                  case 0x69:      /* PDSxxn */
939                          ui_memblt(ROP2_XOR, x, y, cx, cy, src, srcx, srcy);                          ui_memblt(ROP2_XOR, x, y, cx, cy, src, srcx, srcy);
940                          ui_patblt(ROP2_NXOR, x, y, cx, cy, brush, bgcolour,                          ui_patblt(ROP2_NXOR, x, y, cx, cy, brush, bgcolour, fgcolour);
                                   fgcolour);  
941                          break;                          break;
942    
943                  case 0xb8:      /* PSDPxax */                  case 0xb8:      /* PSDPxax */
944                          ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour,                          ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour);
                                   fgcolour);  
945                          ui_memblt(ROP2_AND, x, y, cx, cy, src, srcx, srcy);                          ui_memblt(ROP2_AND, x, y, cx, cy, src, srcx, srcy);
946                          ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour,                          ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour);
                                   fgcolour);  
947                          break;                          break;
948    
949                  case 0xc0:      /* PSa */                  case 0xc0:      /* PSa */
950                          ui_memblt(ROP2_COPY, x, y, cx, cy, src, srcx, srcy);                          ui_memblt(ROP2_COPY, x, y, cx, cy, src, srcx, srcy);
951                          ui_patblt(ROP2_AND, x, y, cx, cy, brush, bgcolour,                          ui_patblt(ROP2_AND, x, y, cx, cy, brush, bgcolour, fgcolour);
                                   fgcolour);  
952                          break;                          break;
953    
954                  default:                  default:
# Line 1016  ui_draw_glyph(int mixmode, Line 989  ui_draw_glyph(int mixmode,
989          SET_BACKGROUND(bgcolour);          SET_BACKGROUND(bgcolour);
990    
991          XSetFillStyle(display, gc,          XSetFillStyle(display, gc,
992                        (mixmode ==                        (mixmode == MIX_TRANSPARENT) ? FillStippled : FillOpaqueStippled);
                        MIX_TRANSPARENT) ? FillStippled : FillOpaqueStippled);  
993          XSetStipple(display, gc, (Pixmap) glyph);          XSetStipple(display, gc, (Pixmap) glyph);
994          XSetTSOrigin(display, gc, x, y);          XSetTSOrigin(display, gc, x, y);
995    
# Line 1087  ui_draw_text(uint8 font, uint8 flags, in Line 1059  ui_draw_text(uint8 font, uint8 flags, in
1059                  {                  {
1060                          case 0xff:                          case 0xff:
1061                                  if (i + 2 < length)                                  if (i + 2 < length)
1062                                          cache_put_text(text[i + 1], text,                                          cache_put_text(text[i + 1], text, text[i + 2]);
                                                        text[i + 2]);  
1063                                  else                                  else
1064                                  {                                  {
1065                                          error("this shouldn't be happening\n");                                          error("this shouldn't be happening\n");
# Line 1105  ui_draw_text(uint8 font, uint8 flags, in Line 1076  ui_draw_text(uint8 font, uint8 flags, in
1076                                  if (entry != NULL)                                  if (entry != NULL)
1077                                  {                                  {
1078                                          if ((((uint8 *) (entry->data))[1] ==                                          if ((((uint8 *) (entry->data))[1] ==
1079                                               0)                                               0) && (!(flags & TEXT2_IMPLICIT_X)))
                                             && (!(flags & TEXT2_IMPLICIT_X)))  
1080                                          {                                          {
1081                                                  if (flags & TEXT2_VERTICAL)                                                  if (flags & TEXT2_VERTICAL)
1082                                                          y += text[i + 2];                                                          y += text[i + 2];
# Line 1122  ui_draw_text(uint8 font, uint8 flags, in Line 1092  ui_draw_text(uint8 font, uint8 flags, in
1092                                          text = &(text[i]);                                          text = &(text[i]);
1093                                          i = 0;                                          i = 0;
1094                                          for (j = 0; j < entry->size; j++)                                          for (j = 0; j < entry->size; j++)
1095                                                  DO_GLYPH(((uint8 *) (entry->                                                  DO_GLYPH(((uint8 *) (entry->data)), j);
                                                                      data)),  
                                                          j);  
1096                                  }                                  }
1097                                  break;                                  break;
1098    
# Line 1146  ui_desktop_save(uint32 offset, int x, in Line 1114  ui_desktop_save(uint32 offset, int x, in
1114    
1115          if (ownbackstore)          if (ownbackstore)
1116          {          {
1117                  image = XGetImage(display, backstore, x, y, cx, cy, AllPlanes,                  image = XGetImage(display, backstore, x, y, cx, cy, AllPlanes, ZPixmap);
                                   ZPixmap);  
1118          }          }
1119          else          else
1120          {          {
1121                  pix = XCreatePixmap(display, wnd, cx, cy, depth);                  pix = XCreatePixmap(display, wnd, cx, cy, depth);
1122                  XCopyArea(display, wnd, pix, gc, x, y, cx, cy, 0, 0);                  XCopyArea(display, wnd, pix, gc, x, y, cx, cy, 0, 0);
1123                  image = XGetImage(display, pix, 0, 0, cx, cy, AllPlanes,                  image = XGetImage(display, pix, 0, 0, cx, cy, AllPlanes, ZPixmap);
                                   ZPixmap);  
1124                  XFreePixmap(display, pix);                  XFreePixmap(display, pix);
1125          }          }
1126    
1127          offset *= bpp / 8;          offset *= bpp / 8;
1128          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);  
1129    
1130          XDestroyImage(image);          XDestroyImage(image);
1131  }  }
# Line 1177  ui_desktop_restore(uint32 offset, int x, Line 1142  ui_desktop_restore(uint32 offset, int x,
1142                  return;                  return;
1143    
1144          image = XCreateImage(display, visual, depth, ZPixmap, 0,          image = XCreateImage(display, visual, depth, ZPixmap, 0,
1145                               (char *) data, cx, cy, BitmapPad(display),                               (char *) data, cx, cy, BitmapPad(display), cx * bpp / 8);
                              cx * bpp / 8);  
1146    
1147          if (ownbackstore)          if (ownbackstore)
1148          {          {

Legend:
Removed from v.80  
changed lines
  Added in v.84

  ViewVC Help
Powered by ViewVC 1.1.26