/[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 318 by astrand, Mon Feb 10 12:58:51 2003 UTC revision 376 by jsorg71, Mon May 19 21:36:33 2003 UTC
# Line 32  extern BOOL grab_keyboard; Line 32  extern BOOL grab_keyboard;
32  extern BOOL hide_decorations;  extern BOOL hide_decorations;
33  extern char title[];  extern char title[];
34  extern int server_bpp;  extern int server_bpp;
35    extern int win_button_size;
36  BOOL enable_compose = False;  BOOL enable_compose = False;
37  BOOL focused;  BOOL focused;
38  BOOL mouse_in_wnd;  BOOL mouse_in_wnd;
# Line 58  static BOOL xserver_be; Line 59  static BOOL xserver_be;
59  static BOOL ownbackstore;  static BOOL ownbackstore;
60  static Pixmap backstore;  static Pixmap backstore;
61    
62    /* Moving in single app mode */
63    static BOOL moving_wnd;
64    static int move_x_offset = 0;
65    static int move_y_offset = 0;
66    
67  /* MWM decorations */  /* MWM decorations */
68  #define MWM_HINTS_DECORATIONS   (1L << 1)  #define MWM_HINTS_DECORATIONS   (1L << 1)
69  #define PROP_MOTIF_WM_HINTS_ELEMENTS    5  #define PROP_MOTIF_WM_HINTS_ELEMENTS    5
# Line 122  static int rop2_map[] = { Line 128  static int rop2_map[] = {
128  #define SET_FUNCTION(rop2)      { if (rop2 != ROP2_COPY) XSetFunction(display, gc, rop2_map[rop2]); }  #define SET_FUNCTION(rop2)      { if (rop2 != ROP2_COPY) XSetFunction(display, gc, rop2_map[rop2]); }
129  #define RESET_FUNCTION(rop2)    { if (rop2 != ROP2_COPY) XSetFunction(display, gc, GXcopy); }  #define RESET_FUNCTION(rop2)    { if (rop2 != ROP2_COPY) XSetFunction(display, gc, GXcopy); }
130    
131  void  static void
132  mwm_hide_decorations(void)  mwm_hide_decorations(void)
133  {  {
134          PropMotifWmHints motif_hints;          PropMotifWmHints motif_hints;
# Line 144  mwm_hide_decorations(void) Line 150  mwm_hide_decorations(void)
150                          (unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS);                          (unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
151  }  }
152    
153  PixelColour  static PixelColour
154  split_colour15(uint32 colour)  split_colour15(uint32 colour)
155  {  {
156          PixelColour rv;          PixelColour rv;
# Line 157  split_colour15(uint32 colour) Line 163  split_colour15(uint32 colour)
163          return rv;          return rv;
164  }  }
165    
166  PixelColour  static PixelColour
167  split_colour16(uint32 colour)  split_colour16(uint32 colour)
168  {  {
169          PixelColour rv;          PixelColour rv;
# Line 170  split_colour16(uint32 colour) Line 176  split_colour16(uint32 colour)
176          return rv;          return rv;
177  }  }
178    
179  PixelColour  static PixelColour
180  split_colour24(uint32 colour)  split_colour24(uint32 colour)
181  {  {
182          PixelColour rv;          PixelColour rv;
# Line 180  split_colour24(uint32 colour) Line 186  split_colour24(uint32 colour)
186          return rv;          return rv;
187  }  }
188    
189  uint32  static uint32
190  make_colour16(PixelColour pc)  make_colour16(PixelColour pc)
191  {  {
192          pc.red = (pc.red * 0x1f) / 0xff;          pc.red = (pc.red * 0x1f) / 0xff;
# Line 189  make_colour16(PixelColour pc) Line 195  make_colour16(PixelColour pc)
195          return (pc.red << 11) | (pc.green << 5) | pc.blue;          return (pc.red << 11) | (pc.green << 5) | pc.blue;
196  }  }
197    
198  uint32  static uint32
199  make_colour24(PixelColour pc)  make_colour24(PixelColour pc)
200  {  {
201          return (pc.red << 16) | (pc.green << 8) | pc.blue;          return (pc.red << 16) | (pc.green << 8) | pc.blue;
202  }  }
203    
204  uint32  static uint32
205  make_colour32(PixelColour pc)  make_colour32(PixelColour pc)
206  {  {
207          return (pc.red << 16) | (pc.green << 8) | pc.blue;          return (pc.red << 16) | (pc.green << 8) | pc.blue;
# Line 396  translate24to32(uint8 * data, uint32 * o Line 402  translate24to32(uint8 * data, uint32 * o
402          uint32 pixel = 0;          uint32 pixel = 0;
403          while (out < end)          while (out < end)
404          {          {
405                  memcpy(&pixel, data, 3);                  pixel = *(data++);
406                  data += 3;                  pixel |= *(data++) << 8;
407                    pixel |= *(data++) << 16;
408                  *(out++) = pixel;                  *(out++) = pixel;
409          }          }
410  }  }
# Line 406  static uint8 * Line 413  static uint8 *
413  translate_image(int width, int height, uint8 * data)  translate_image(int width, int height, uint8 * data)
414  {  {
415          int size = width * height * bpp / 8;          int size = width * height * bpp / 8;
416          uint8 *out = xmalloc(size);          uint8 *out = (uint8*)xmalloc(size);
417          uint8 *end = out + size;          uint8 *end = out + size;
418    
419          switch (server_bpp)          switch (server_bpp)
# Line 780  xwin_process_events(void) Line 787  xwin_process_events(void)
787                          case ClientMessage:                          case ClientMessage:
788                                  /* the window manager told us to quit */                                  /* the window manager told us to quit */
789                                  if ((xevent.xclient.message_type == protocol_atom)                                  if ((xevent.xclient.message_type == protocol_atom)
790                                      && (xevent.xclient.data.l[0] == kill_atom))                                      && ((Atom)xevent.xclient.data.l[0] == kill_atom))
791                                          /* Quit */                                          /* Quit */
792                                          return 0;                                          return 0;
793                                  break;                                  break;
# Line 854  xwin_process_events(void) Line 861  xwin_process_events(void)
861                                  if (button == 0)                                  if (button == 0)
862                                          break;                                          break;
863    
864                                    /* If win_button_size is nonzero, enable single app mode */
865                                    if (xevent.xbutton.y < win_button_size)
866                                    {
867                                            /* Stop moving window when button is released, regardless of cursor position */
868                                            if (moving_wnd && (xevent.type == ButtonRelease))
869                                                    moving_wnd = False;
870    
871                                            /*  Check from right to left: */
872    
873                                            if (xevent.xbutton.x >= width - win_button_size)
874                                            {
875                                                    /* The close button, continue */
876                                                    ;
877                                            }
878                                            else if (xevent.xbutton.x >= width - win_button_size * 2)
879                                            {
880                                                    /* The maximize/restore button. Do not send to
881                                                       server.  It might be a good idea to change the
882                                                       cursor or give some other visible indication
883                                                       that rdesktop inhibited this click */
884                                                    break;
885                                            }
886                                            else if (xevent.xbutton.x >= width - win_button_size * 3)
887                                            {
888                                                    /* The minimize button. Iconify window. */
889                                                    XIconifyWindow(display, wnd,
890                                                                   DefaultScreen(display));
891                                                    break;
892                                            }
893                                            else if (xevent.xbutton.x <= win_button_size)
894                                            {
895                                                    /* The system menu. Ignore. */
896                                                    break;
897                                            }
898                                            else
899                                            {
900                                                    /* The title bar. */
901                                                    if ((xevent.type == ButtonPress) && !fullscreen
902                                                        && hide_decorations)
903                                                    {
904                                                            moving_wnd = True;
905                                                            move_x_offset = xevent.xbutton.x;
906                                                            move_y_offset = xevent.xbutton.y;
907                                                    }
908                                                    break;
909    
910                                            }
911                                    }
912    
913                                  rdp_send_input(time(NULL), RDP_INPUT_MOUSE,                                  rdp_send_input(time(NULL), RDP_INPUT_MOUSE,
914                                                 flags | button, xevent.xbutton.x, xevent.xbutton.y);                                                 flags | button, xevent.xbutton.x, xevent.xbutton.y);
915                                  break;                                  break;
916    
917                          case MotionNotify:                          case MotionNotify:
918                                    if (moving_wnd)
919                                    {
920                                            XMoveWindow(display, wnd,
921                                                        xevent.xmotion.x_root - move_x_offset,
922                                                        xevent.xmotion.y_root - move_y_offset);
923                                            break;
924                                    }
925    
926                                  if (fullscreen && !focused)                                  if (fullscreen && !focused)
927                                          XSetInputFocus(display, wnd, RevertToPointerRoot,                                          XSetInputFocus(display, wnd, RevertToPointerRoot,
928                                                         CurrentTime);                                                         CurrentTime);
# Line 1073  ui_create_cursor(unsigned int x, unsigne Line 1137  ui_create_cursor(unsigned int x, unsigne
1137          scanline = (width + 7) / 8;          scanline = (width + 7) / 8;
1138          offset = scanline * height;          offset = scanline * height;
1139    
1140          cursor = xmalloc(offset);          cursor = (uint8*)xmalloc(offset);
1141          memset(cursor, 0, offset);          memset(cursor, 0, offset);
1142    
1143          mask = xmalloc(offset);          mask = (uint8*)xmalloc(offset);
1144          memset(mask, 0, offset);          memset(mask, 0, offset);
1145    
1146          /* approximate AND and XOR masks with a monochrome X pointer */          /* approximate AND and XOR masks with a monochrome X pointer */
# Line 1155  ui_create_colourmap(COLOURMAP * colours) Line 1219  ui_create_colourmap(COLOURMAP * colours)
1219          int i, ncolours = colours->ncolours;          int i, ncolours = colours->ncolours;
1220          if (!owncolmap)          if (!owncolmap)
1221          {          {
1222                  uint32 *map = xmalloc(sizeof(*colmap) * ncolours);                  uint32 *map = (uint32*)xmalloc(sizeof(*colmap) * ncolours);
1223                  XColor xentry;                  XColor xentry;
1224                  XColor xc_cache[256];                  XColor xc_cache[256];
1225                  uint32 colour;                  uint32 colour;
# Line 1233  ui_create_colourmap(COLOURMAP * colours) Line 1297  ui_create_colourmap(COLOURMAP * colours)
1297                  XColor *xcolours, *xentry;                  XColor *xcolours, *xentry;
1298                  Colormap map;                  Colormap map;
1299    
1300                  xcolours = xmalloc(sizeof(XColor) * ncolours);                  xcolours = (XColor*)xmalloc(sizeof(XColor) * ncolours);
1301                  for (i = 0; i < ncolours; i++)                  for (i = 0; i < ncolours; i++)
1302                  {                  {
1303                          entry = &colours->colours[i];                          entry = &colours->colours[i];
# Line 1263  void Line 1327  void
1327  ui_set_colourmap(HCOLOURMAP map)  ui_set_colourmap(HCOLOURMAP map)
1328  {  {
1329          if (!owncolmap)          if (!owncolmap)
1330                  colmap = map;                  colmap = (uint32*)map;
1331          else          else
1332                  XSetWindowColormap(display, wnd, (Colormap) map);                  XSetWindowColormap(display, wnd, (Colormap) map);
1333  }  }
# Line 1307  ui_destblt(uint8 opcode, Line 1371  ui_destblt(uint8 opcode,
1371          RESET_FUNCTION(opcode);          RESET_FUNCTION(opcode);
1372  }  }
1373    
1374    static uint8 hatch_patterns[] = {
1375            0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0 - bsHorizontal */
1376            0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 1 - bsVertical */
1377            0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, /* 2 - bsFDiagonal */
1378            0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, /* 3 - bsBDiagonal */
1379            0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08, /* 4 - bsCross */
1380            0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81  /* 5 - bsDiagCross */
1381    };
1382    
1383  void  void
1384  ui_patblt(uint8 opcode,  ui_patblt(uint8 opcode,
1385            /* dest */ int x, int y, int cx, int cy,            /* dest */ int x, int y, int cx, int cy,
# Line 1324  ui_patblt(uint8 opcode, Line 1397  ui_patblt(uint8 opcode,
1397                          FILL_RECTANGLE(x, y, cx, cy);                          FILL_RECTANGLE(x, y, cx, cy);
1398                          break;                          break;
1399    
1400                    case 2: /* Hatch */
1401                            fill = (Pixmap) ui_create_glyph(8, 8, hatch_patterns + brush->pattern[0] * 8);
1402                            SET_FOREGROUND(bgcolour);
1403                            SET_BACKGROUND(fgcolour);
1404                            XSetFillStyle(display, gc, FillOpaqueStippled);
1405                            XSetStipple(display, gc, fill);
1406                            XSetTSOrigin(display, gc, brush->xorigin, brush->yorigin);
1407                            FILL_RECTANGLE(x, y, cx, cy);
1408                            XSetFillStyle(display, gc, FillSolid);
1409                            XSetTSOrigin(display, gc, 0, 0);
1410                            ui_destroy_glyph((HGLYPH) fill);
1411                            break;
1412    
1413                  case 3: /* Pattern */                  case 3: /* Pattern */
1414                          for (i = 0; i != 8; i++)                          for (i = 0; i != 8; i++)
1415                                  ipattern[7 - i] = brush->pattern[i];                                  ipattern[7 - i] = brush->pattern[i];

Legend:
Removed from v.318  
changed lines
  Added in v.376

  ViewVC Help
Powered by ViewVC 1.1.26