/[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 373 by jsorg71, Thu May 15 14:26:15 2003 UTC revision 448 by astrand, Wed Aug 27 08:21:53 2003 UTC
# Line 1  Line 1 
1  /*  /* -*- c-basic-offset: 8 -*-
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     User interface services - X Window System     User interface services - X Window System
4     Copyright (C) Matthew Chapman 1999-2002     Copyright (C) Matthew Chapman 1999-2002
# Line 23  Line 23 
23  #include <time.h>  #include <time.h>
24  #include <errno.h>  #include <errno.h>
25  #include "rdesktop.h"  #include "rdesktop.h"
26    #include "xproto.h"
27    
28  extern int width;  extern int g_width;
29  extern int height;  extern int g_height;
30  extern BOOL sendmotion;  extern BOOL g_sendmotion;
31  extern BOOL fullscreen;  extern BOOL g_fullscreen;
32  extern BOOL grab_keyboard;  extern BOOL grab_keyboard;
33  extern BOOL hide_decorations;  extern BOOL hide_decorations;
34  extern char title[];  extern char title[];
35  extern int server_bpp;  extern int g_server_bpp;
36  extern int win_button_size;  extern int win_button_size;
37  BOOL enable_compose = False;  BOOL g_enable_compose = False;
38  BOOL focused;  BOOL g_focused;
39  BOOL mouse_in_wnd;  BOOL g_mouse_in_wnd;
40    
41  Display *display;  Display *display;
42    Time last_gesturetime;
43  static int x_socket;  static int x_socket;
44  static Screen *screen;  static Screen *screen;
45  static Window wnd;  Window wnd;
46  static GC gc;  static GC gc;
47  static Visual *visual;  static Visual *visual;
48  static int depth;  static int depth;
# Line 85  typedef struct Line 87  typedef struct
87  }  }
88  PixelColour;  PixelColour;
89    
90    
91  #define FILL_RECTANGLE(x,y,cx,cy)\  #define FILL_RECTANGLE(x,y,cx,cy)\
92  { \  { \
93          XFillRectangle(display, wnd, gc, x, y, cx, cy); \          XFillRectangle(display, wnd, gc, x, y, cx, cy); \
# Line 100  PixelColour; Line 103  PixelColour;
103  /* colour maps */  /* colour maps */
104  BOOL owncolmap = False;  BOOL owncolmap = False;
105  static Colormap xcolmap;  static Colormap xcolmap;
106  static uint32 *colmap;  static uint32 *colmap = NULL;
107    
108  #define TRANSLATE(col)          ( server_bpp != 8 ? translate_colour(col) : owncolmap ? col : translate_colour(colmap[col]) )  #define TRANSLATE(col)          ( g_server_bpp != 8 ? translate_colour(col) : owncolmap ? col : translate_colour(colmap[col]) )
109  #define SET_FOREGROUND(col)     XSetForeground(display, gc, TRANSLATE(col));  #define SET_FOREGROUND(col)     XSetForeground(display, gc, TRANSLATE(col));
110  #define SET_BACKGROUND(col)     XSetBackground(display, gc, TRANSLATE(col));  #define SET_BACKGROUND(col)     XSetBackground(display, gc, TRANSLATE(col));
111    
# Line 215  make_colour32(PixelColour pc) Line 218  make_colour32(PixelColour pc)
218  static uint32  static uint32
219  translate_colour(uint32 colour)  translate_colour(uint32 colour)
220  {  {
221          switch (server_bpp)          switch (g_server_bpp)
222          {          {
223                  case 15:                  case 15:
224                          switch (bpp)                          switch (bpp)
# Line 413  static uint8 * Line 416  static uint8 *
416  translate_image(int width, int height, uint8 * data)  translate_image(int width, int height, uint8 * data)
417  {  {
418          int size = width * height * bpp / 8;          int size = width * height * bpp / 8;
419          uint8 *out = xmalloc(size);          uint8 *out = (uint8 *) xmalloc(size);
420          uint8 *end = out + size;          uint8 *end = out + size;
421    
422          switch (server_bpp)          switch (g_server_bpp)
423          {          {
424                  case 24:                  case 24:
425                          switch (bpp)                          switch (bpp)
# Line 567  ui_init(void) Line 570  ui_init(void)
570          host_be = !(BOOL) (*(uint8 *) (&test));          host_be = !(BOOL) (*(uint8 *) (&test));
571          xserver_be = (ImageByteOrder(display) == MSBFirst);          xserver_be = (ImageByteOrder(display) == MSBFirst);
572    
573          if ((width == 0) || (height == 0))          if ((g_width == 0) || (g_height == 0))
574          {          {
575                  /* Fetch geometry from _NET_WORKAREA */                  /* Fetch geometry from _NET_WORKAREA */
576                  uint32 x, y, cx, cy;                  uint32 x, y, cx, cy;
577    
578                  if (get_current_workarea(&x, &y, &cx, &cy) == 0)                  if (get_current_workarea(&x, &y, &cx, &cy) == 0)
579                  {                  {
580                          width = cx;                          g_width = cx;
581                          height = cy;                          g_height = cy;
582                  }                  }
583                  else                  else
584                  {                  {
585                          warning("Failed to get workarea: probably your window manager does not support extended hints\n");                          warning("Failed to get workarea: probably your window manager does not support extended hints\n");
586                          width = 800;                          g_width = 800;
587                          height = 600;                          g_height = 600;
588                  }                  }
589          }          }
590    
591          if (fullscreen)          if (g_fullscreen)
592          {          {
593                  width = WidthOfScreen(screen);                  g_width = WidthOfScreen(screen);
594                  height = HeightOfScreen(screen);                  g_height = HeightOfScreen(screen);
595          }          }
596    
597          /* make sure width is a multiple of 4 */          /* make sure width is a multiple of 4 */
598          width = (width + 3) & ~3;          g_width = (g_width + 3) & ~3;
599    
600          if (ownbackstore)          if (ownbackstore)
601          {          {
602                  backstore =                  backstore =
603                          XCreatePixmap(display, RootWindowOfScreen(screen), width, height, depth);                          XCreatePixmap(display, RootWindowOfScreen(screen), g_width, g_height,
604                                          depth);
605    
606                  /* clear to prevent rubbish being exposed at startup */                  /* clear to prevent rubbish being exposed at startup */
607                  XSetForeground(display, gc, BlackPixelOfScreen(screen));                  XSetForeground(display, gc, BlackPixelOfScreen(screen));
608                  XFillRectangle(display, backstore, gc, 0, 0, width, height);                  XFillRectangle(display, backstore, gc, 0, 0, g_width, g_height);
609          }          }
610    
611          mod_map = XGetModifierMapping(display);          mod_map = XGetModifierMapping(display);
612    
613          if (enable_compose)          if (g_enable_compose)
614                  IM = XOpenIM(display, NULL, NULL, NULL);                  IM = XOpenIM(display, NULL, NULL, NULL);
615    
616          xkeymap_init();          xkeymap_init();
617            xclip_init();
618    
619          /* todo take this out when high colour is done */          /* todo take this out when high colour is done */
620          printf("server bpp %d client bpp %d depth %d\n", server_bpp, bpp, depth);          printf("server bpp %d client bpp %d depth %d\n", g_server_bpp, bpp, depth);
621    
622          return True;          return True;
623  }  }
# Line 643  ui_create_window(void) Line 648  ui_create_window(void)
648          long input_mask, ic_input_mask;          long input_mask, ic_input_mask;
649          XEvent xevent;          XEvent xevent;
650    
651          wndwidth = fullscreen ? WidthOfScreen(screen) : width;          wndwidth = g_fullscreen ? WidthOfScreen(screen) : g_width;
652          wndheight = fullscreen ? HeightOfScreen(screen) : height;          wndheight = g_fullscreen ? HeightOfScreen(screen) : g_height;
653    
654          attribs.background_pixel = BlackPixelOfScreen(screen);          attribs.background_pixel = BlackPixelOfScreen(screen);
655          attribs.backing_store = ownbackstore ? NotUseful : Always;          attribs.backing_store = ownbackstore ? NotUseful : Always;
656          attribs.override_redirect = fullscreen;          attribs.override_redirect = g_fullscreen;
657    
658          wnd = XCreateWindow(display, RootWindowOfScreen(screen), 0, 0, wndwidth, wndheight,          wnd = XCreateWindow(display, RootWindowOfScreen(screen), 0, 0, wndwidth, wndheight,
659                              0, CopyFromParent, InputOutput, CopyFromParent,                              0, CopyFromParent, InputOutput, CopyFromParent,
# Line 671  ui_create_window(void) Line 676  ui_create_window(void)
676          if (sizehints)          if (sizehints)
677          {          {
678                  sizehints->flags = PMinSize | PMaxSize;                  sizehints->flags = PMinSize | PMaxSize;
679                  sizehints->min_width = sizehints->max_width = width;                  sizehints->min_width = sizehints->max_width = g_width;
680                  sizehints->min_height = sizehints->max_height = height;                  sizehints->min_height = sizehints->max_height = g_height;
681                  XSetWMNormalHints(display, wnd, sizehints);                  XSetWMNormalHints(display, wnd, sizehints);
682                  XFree(sizehints);                  XFree(sizehints);
683          }          }
# Line 680  ui_create_window(void) Line 685  ui_create_window(void)
685          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
686                  VisibilityChangeMask | FocusChangeMask;                  VisibilityChangeMask | FocusChangeMask;
687    
688          if (sendmotion)          if (g_sendmotion)
689                  input_mask |= PointerMotionMask;                  input_mask |= PointerMotionMask;
690          if (ownbackstore)          if (ownbackstore)
691                  input_mask |= ExposureMask;                  input_mask |= ExposureMask;
692          if (fullscreen || grab_keyboard)          if (g_fullscreen || grab_keyboard)
693                  input_mask |= EnterWindowMask;                  input_mask |= EnterWindowMask;
694          if (grab_keyboard)          if (grab_keyboard)
695                  input_mask |= LeaveWindowMask;                  input_mask |= LeaveWindowMask;
# Line 709  ui_create_window(void) Line 714  ui_create_window(void)
714          }          }
715          while (xevent.type != VisibilityNotify);          while (xevent.type != VisibilityNotify);
716    
717          focused = False;          g_focused = False;
718          mouse_in_wnd = False;          g_mouse_in_wnd = False;
719    
720          /* handle the WM_DELETE_WINDOW protocol */          /* handle the WM_DELETE_WINDOW protocol */
721          protocol_atom = XInternAtom(display, "WM_PROTOCOLS", True);          protocol_atom = XInternAtom(display, "WM_PROTOCOLS", True);
# Line 737  xwin_toggle_fullscreen(void) Line 742  xwin_toggle_fullscreen(void)
742          if (!ownbackstore)          if (!ownbackstore)
743          {          {
744                  /* need to save contents of window */                  /* need to save contents of window */
745                  contents = XCreatePixmap(display, wnd, width, height, depth);                  contents = XCreatePixmap(display, wnd, g_width, g_height, depth);
746                  XCopyArea(display, wnd, contents, gc, 0, 0, width, height, 0, 0);                  XCopyArea(display, wnd, contents, gc, 0, 0, g_width, g_height, 0, 0);
747          }          }
748    
749          ui_destroy_window();          ui_destroy_window();
750          fullscreen = !fullscreen;          g_fullscreen = !g_fullscreen;
751          ui_create_window();          ui_create_window();
752    
753          XDefineCursor(display, wnd, current_cursor);          XDefineCursor(display, wnd, current_cursor);
754    
755          if (!ownbackstore)          if (!ownbackstore)
756          {          {
757                  XCopyArea(display, contents, wnd, gc, 0, 0, width, height, 0, 0);                  XCopyArea(display, contents, wnd, gc, 0, 0, g_width, g_height, 0, 0);
758                  XFreePixmap(display, contents);                  XFreePixmap(display, contents);
759          }          }
760  }  }
761    
762  /* Process all events in Xlib queue  /* Process all events in Xlib queue
763     Returns 0 after user quit, 1 otherwise */     Returns 0 after user quit, 1 otherwise */
764  static int  static int
765  xwin_process_events(void)  xwin_process_events(void)
# Line 787  xwin_process_events(void) Line 792  xwin_process_events(void)
792                          case ClientMessage:                          case ClientMessage:
793                                  /* the window manager told us to quit */                                  /* the window manager told us to quit */
794                                  if ((xevent.xclient.message_type == protocol_atom)                                  if ((xevent.xclient.message_type == protocol_atom)
795                                      && (xevent.xclient.data.l[0] == kill_atom))                                      && ((Atom) xevent.xclient.data.l[0] == kill_atom))
796                                          /* Quit */                                          /* Quit */
797                                          return 0;                                          return 0;
798                                  break;                                  break;
799    
800                          case KeyPress:                          case KeyPress:
801                                    last_gesturetime = xevent.xkey.time;
802                                  if (IC != NULL)                                  if (IC != NULL)
803                                          /* Multi_key compatible version */                                          /* Multi_key compatible version */
804                                  {                                  {
805                                          XmbLookupString(IC,                                          XmbLookupString(IC,
806                                                          (XKeyPressedEvent *) &                                                          &xevent.xkey, str, sizeof(str), &keysym,
807                                                          xevent, str, sizeof(str), &keysym, &status);                                                          &status);
808                                          if (!((status == XLookupKeySym) || (status == XLookupBoth)))                                          if (!((status == XLookupKeySym) || (status == XLookupBoth)))
809                                          {                                          {
810                                                  error("XmbLookupString failed with status 0x%x\n",                                                  error("XmbLookupString failed with status 0x%x\n",
# Line 833  xwin_process_events(void) Line 839  xwin_process_events(void)
839                                  break;                                  break;
840    
841                          case KeyRelease:                          case KeyRelease:
842                                    last_gesturetime = xevent.xkey.time;
843                                  XLookupString((XKeyEvent *) & xevent, str,                                  XLookupString((XKeyEvent *) & xevent, str,
844                                                sizeof(str), &keysym, NULL);                                                sizeof(str), &keysym, NULL);
845    
# Line 857  xwin_process_events(void) Line 864  xwin_process_events(void)
864                                  /* fall through */                                  /* fall through */
865    
866                          case ButtonRelease:                          case ButtonRelease:
867                                    last_gesturetime = xevent.xbutton.time;
868                                  button = xkeymap_translate_button(xevent.xbutton.button);                                  button = xkeymap_translate_button(xevent.xbutton.button);
869                                  if (button == 0)                                  if (button == 0)
870                                          break;                                          break;
# Line 870  xwin_process_events(void) Line 878  xwin_process_events(void)
878    
879                                          /*  Check from right to left: */                                          /*  Check from right to left: */
880    
881                                          if (xevent.xbutton.x >= width - win_button_size)                                          if (xevent.xbutton.x >= g_width - win_button_size)
882                                          {                                          {
883                                                  /* The close button, continue */                                                  /* The close button, continue */
884                                                  ;                                                  ;
885                                          }                                          }
886                                          else if (xevent.xbutton.x >= width - win_button_size * 2)                                          else if (xevent.xbutton.x >= g_width - win_button_size * 2)
887                                          {                                          {
888                                                  /* The maximize/restore button. Do not send to                                                  /* The maximize/restore button. Do not send to
889                                                     server.  It might be a good idea to change the                                                     server.  It might be a good idea to change the
890                                                     cursor or give some other visible indication                                                     cursor or give some other visible indication
891                                                     that rdesktop inhibited this click */                                                     that rdesktop inhibited this click */
892                                                  break;                                                  break;
893                                          }                                          }
894                                          else if (xevent.xbutton.x >= width - win_button_size * 3)                                          else if (xevent.xbutton.x >= g_width - win_button_size * 3)
895                                          {                                          {
896                                                  /* The minimize button. Iconify window. */                                                  /* The minimize button. Iconify window. */
897                                                  XIconifyWindow(display, wnd,                                                  XIconifyWindow(display, wnd,
# Line 898  xwin_process_events(void) Line 906  xwin_process_events(void)
906                                          else                                          else
907                                          {                                          {
908                                                  /* The title bar. */                                                  /* The title bar. */
909                                                  if ((xevent.type == ButtonPress) && !fullscreen                                                  if ((xevent.type == ButtonPress) && !g_fullscreen
910                                                      && hide_decorations)                                                      && hide_decorations)
911                                                  {                                                  {
912                                                          moving_wnd = True;                                                          moving_wnd = True;
# Line 923  xwin_process_events(void) Line 931  xwin_process_events(void)
931                                          break;                                          break;
932                                  }                                  }
933    
934                                  if (fullscreen && !focused)                                  if (g_fullscreen && !g_focused)
935                                          XSetInputFocus(display, wnd, RevertToPointerRoot,                                          XSetInputFocus(display, wnd, RevertToPointerRoot,
936                                                         CurrentTime);                                                         CurrentTime);
937                                  rdp_send_input(time(NULL), RDP_INPUT_MOUSE,                                  rdp_send_input(time(NULL), RDP_INPUT_MOUSE,
# Line 933  xwin_process_events(void) Line 941  xwin_process_events(void)
941                          case FocusIn:                          case FocusIn:
942                                  if (xevent.xfocus.mode == NotifyGrab)                                  if (xevent.xfocus.mode == NotifyGrab)
943                                          break;                                          break;
944                                  focused = True;                                  g_focused = True;
945                                  XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy,                                  XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy,
946                                                &dummy, &dummy, &state);                                                &dummy, &dummy, &state);
947                                  reset_modifier_keys(state);                                  reset_modifier_keys(state);
948                                  if (grab_keyboard && mouse_in_wnd)                                  if (grab_keyboard && g_mouse_in_wnd)
949                                          XGrabKeyboard(display, wnd, True,                                          XGrabKeyboard(display, wnd, True,
950                                                        GrabModeAsync, GrabModeAsync, CurrentTime);                                                        GrabModeAsync, GrabModeAsync, CurrentTime);
951                                  break;                                  break;
# Line 945  xwin_process_events(void) Line 953  xwin_process_events(void)
953                          case FocusOut:                          case FocusOut:
954                                  if (xevent.xfocus.mode == NotifyUngrab)                                  if (xevent.xfocus.mode == NotifyUngrab)
955                                          break;                                          break;
956                                  focused = False;                                  g_focused = False;
957                                  if (xevent.xfocus.mode == NotifyWhileGrabbed)                                  if (xevent.xfocus.mode == NotifyWhileGrabbed)
958                                          XUngrabKeyboard(display, CurrentTime);                                          XUngrabKeyboard(display, CurrentTime);
959                                  break;                                  break;
# Line 953  xwin_process_events(void) Line 961  xwin_process_events(void)
961                          case EnterNotify:                          case EnterNotify:
962                                  /* we only register for this event when in fullscreen mode */                                  /* we only register for this event when in fullscreen mode */
963                                  /* or grab_keyboard */                                  /* or grab_keyboard */
964                                  mouse_in_wnd = True;                                  g_mouse_in_wnd = True;
965                                  if (fullscreen)                                  if (g_fullscreen)
966                                  {                                  {
967                                          XSetInputFocus(display, wnd, RevertToPointerRoot,                                          XSetInputFocus(display, wnd, RevertToPointerRoot,
968                                                         CurrentTime);                                                         CurrentTime);
969                                          break;                                          break;
970                                  }                                  }
971                                  if (focused)                                  if (g_focused)
972                                          XGrabKeyboard(display, wnd, True,                                          XGrabKeyboard(display, wnd, True,
973                                                        GrabModeAsync, GrabModeAsync, CurrentTime);                                                        GrabModeAsync, GrabModeAsync, CurrentTime);
974                                  break;                                  break;
975    
976                          case LeaveNotify:                          case LeaveNotify:
977                                  /* we only register for this event when grab_keyboard */                                  /* we only register for this event when grab_keyboard */
978                                  mouse_in_wnd = False;                                  g_mouse_in_wnd = False;
979                                  XUngrabKeyboard(display, CurrentTime);                                  XUngrabKeyboard(display, CurrentTime);
980                                  break;                                  break;
981    
# Line 993  xwin_process_events(void) Line 1001  xwin_process_events(void)
1001                                  }                                  }
1002                                  break;                                  break;
1003    
1004                                    /* clipboard stuff */
1005                            case SelectionNotify:
1006                                    xclip_handle_SelectionNotify(&xevent.xselection);
1007                                    break;
1008                            case SelectionRequest:
1009                                    xclip_handle_SelectionRequest(&xevent.xselectionrequest);
1010                                    break;
1011                            case SelectionClear:
1012                                    xclip_handle_SelectionClear();
1013                                    break;
1014                            case PropertyNotify:
1015                                    xclip_handle_PropertyNotify(&xevent.xproperty);
1016                                    break;
1017                  }                  }
1018          }          }
1019          /* Keep going */          /* Keep going */
# Line 1049  ui_create_bitmap(int width, int height, Line 1070  ui_create_bitmap(int width, int height,
1070          tdata = (owncolmap ? data : translate_image(width, height, data));          tdata = (owncolmap ? data : translate_image(width, height, data));
1071          bitmap = XCreatePixmap(display, wnd, width, height, depth);          bitmap = XCreatePixmap(display, wnd, width, height, depth);
1072          image = XCreateImage(display, visual, depth, ZPixmap, 0,          image = XCreateImage(display, visual, depth, ZPixmap, 0,
1073                               (char *) tdata, width, height, server_bpp == 8 ? 8 : bpp, 0);                               (char *) tdata, width, height, g_server_bpp == 8 ? 8 : bpp, 0);
1074    
1075          XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height);          XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height);
1076    
# Line 1066  ui_paint_bitmap(int x, int y, int cx, in Line 1087  ui_paint_bitmap(int x, int y, int cx, in
1087          uint8 *tdata;          uint8 *tdata;
1088          tdata = (owncolmap ? data : translate_image(width, height, data));          tdata = (owncolmap ? data : translate_image(width, height, data));
1089          image = XCreateImage(display, visual, depth, ZPixmap, 0,          image = XCreateImage(display, visual, depth, ZPixmap, 0,
1090                               (char *) tdata, width, height, server_bpp == 8 ? 8 : bpp, 0);                               (char *) tdata, width, height, g_server_bpp == 8 ? 8 : bpp, 0);
1091    
1092          if (ownbackstore)          if (ownbackstore)
1093          {          {
# Line 1137  ui_create_cursor(unsigned int x, unsigne Line 1158  ui_create_cursor(unsigned int x, unsigne
1158          scanline = (width + 7) / 8;          scanline = (width + 7) / 8;
1159          offset = scanline * height;          offset = scanline * height;
1160    
1161          cursor = xmalloc(offset);          cursor = (uint8 *) xmalloc(offset);
1162          memset(cursor, 0, offset);          memset(cursor, 0, offset);
1163    
1164          mask = xmalloc(offset);          mask = (uint8 *) xmalloc(offset);
1165          memset(mask, 0, offset);          memset(mask, 0, offset);
1166    
1167          /* approximate AND and XOR masks with a monochrome X pointer */          /* approximate AND and XOR masks with a monochrome X pointer */
# Line 1219  ui_create_colourmap(COLOURMAP * colours) Line 1240  ui_create_colourmap(COLOURMAP * colours)
1240          int i, ncolours = colours->ncolours;          int i, ncolours = colours->ncolours;
1241          if (!owncolmap)          if (!owncolmap)
1242          {          {
1243                  uint32 *map = xmalloc(sizeof(*colmap) * ncolours);                  uint32 *map = (uint32 *) xmalloc(sizeof(*colmap) * ncolours);
1244                  XColor xentry;                  XColor xentry;
1245                  XColor xc_cache[256];                  XColor xc_cache[256];
1246                  uint32 colour;                  uint32 colour;
# Line 1297  ui_create_colourmap(COLOURMAP * colours) Line 1318  ui_create_colourmap(COLOURMAP * colours)
1318                  XColor *xcolours, *xentry;                  XColor *xcolours, *xentry;
1319                  Colormap map;                  Colormap map;
1320    
1321                  xcolours = xmalloc(sizeof(XColor) * ncolours);                  xcolours = (XColor *) xmalloc(sizeof(XColor) * ncolours);
1322                  for (i = 0; i < ncolours; i++)                  for (i = 0; i < ncolours; i++)
1323                  {                  {
1324                          entry = &colours->colours[i];                          entry = &colours->colours[i];
# Line 1327  void Line 1348  void
1348  ui_set_colourmap(HCOLOURMAP map)  ui_set_colourmap(HCOLOURMAP map)
1349  {  {
1350          if (!owncolmap)          if (!owncolmap)
1351                  colmap = map;          {
1352                    if (colmap)
1353                            xfree(colmap);
1354    
1355                    colmap = (uint32 *) map;
1356            }
1357          else          else
1358                  XSetWindowColormap(display, wnd, (Colormap) map);                  XSetWindowColormap(display, wnd, (Colormap) map);
1359  }  }
# Line 1351  ui_reset_clip(void) Line 1377  ui_reset_clip(void)
1377    
1378          rect.x = 0;          rect.x = 0;
1379          rect.y = 0;          rect.y = 0;
1380          rect.width = width;          rect.width = g_width;
1381          rect.height = height;          rect.height = g_height;
1382          XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);          XSetClipRectangles(display, gc, 0, 0, &rect, 1, YXBanded);
1383  }  }
1384    
# Line 1372  ui_destblt(uint8 opcode, Line 1398  ui_destblt(uint8 opcode,
1398  }  }
1399    
1400  static uint8 hatch_patterns[] = {  static uint8 hatch_patterns[] = {
1401          0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0 - bsHorizontal */          0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0 - bsHorizontal */
1402          0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 1 - bsVertical */          0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 1 - bsVertical */
1403          0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, /* 2 - bsFDiagonal */          0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, /* 2 - bsFDiagonal */
1404          0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, /* 3 - bsBDiagonal */          0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, /* 3 - bsBDiagonal */
1405          0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08, /* 4 - bsCross */          0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08, /* 4 - bsCross */
1406          0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81  /* 5 - bsDiagCross */          0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81  /* 5 - bsDiagCross */
1407  };  };
1408    
1409  void  void
# Line 1398  ui_patblt(uint8 opcode, Line 1424  ui_patblt(uint8 opcode,
1424                          break;                          break;
1425    
1426                  case 2: /* Hatch */                  case 2: /* Hatch */
1427                          fill = (Pixmap) ui_create_glyph(8, 8, hatch_patterns + brush->pattern[0] * 8);                          fill = (Pixmap) ui_create_glyph(8, 8,
1428                                                            hatch_patterns + brush->pattern[0] * 8);
1429                          SET_FOREGROUND(bgcolour);                          SET_FOREGROUND(bgcolour);
1430                          SET_BACKGROUND(fgcolour);                          SET_BACKGROUND(fgcolour);
1431                          XSetFillStyle(display, gc, FillOpaqueStippled);                          XSetFillStyle(display, gc, FillOpaqueStippled);

Legend:
Removed from v.373  
changed lines
  Added in v.448

  ViewVC Help
Powered by ViewVC 1.1.26