/[rdesktop]/sourceforge.net/trunk/rdesktop/uiports/qtewin.cpp
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/uiports/qtewin.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 791 by jsorg71, Sat Oct 30 17:02:54 2004 UTC revision 797 by jsorg71, Fri Nov 5 03:40:52 2004 UTC
# Line 48  Line 48 
48  #include "../rdesktop.h"  #include "../rdesktop.h"
49  #include "qtewin.h"  #include "qtewin.h"
50    
51    #define QT_OPTI
52    
53  /* types */  /* types */
54  struct QColorMap  struct QColorMap
55  {  {
# Line 85  int g_server_bpp = 8; Line 87  int g_server_bpp = 8;
87  char g_hostname[16] = "";  char g_hostname[16] = "";
88  char g_username[100] = "";  char g_username[100] = "";
89    
90    static int g_client_width = 640;
91    static int g_client_height = 480;
92  static uint32 g_flags = RDP_LOGON_NORMAL;  static uint32 g_flags = RDP_LOGON_NORMAL;
93  static char g_server[64] = "";  static char g_server[64] = "";
94  static char g_domain[16] = "";  static char g_domain[16] = "";
# Line 740  void QMyScrollView::timerEvent(QTimerEve Line 744  void QMyScrollView::timerEvent(QTimerEve
744    {    {
745      g_width = d->Width;      g_width = d->Width;
746      g_height = d->Height;      g_height = d->Height;
747        g_client_width = g_width;
748        g_client_height = g_height;
749      g_fullscreen = d->FullScreen;      g_fullscreen = d->FullScreen;
750      sprintf(g_server, "%s", (const char*)d->ServerIP);      sprintf(g_server, "%s", (const char*)d->ServerIP);
751      sprintf(g_username, "%s", (const char*)d->UserName);      sprintf(g_username, "%s", (const char*)d->UserName);
# Line 760  void QMyScrollView::timerEvent(QTimerEve Line 766  void QMyScrollView::timerEvent(QTimerEve
766      memset(g_CM, 0, sizeof(struct QColorMap));      memset(g_CM, 0, sizeof(struct QColorMap));
767      g_CM->NumColors = 256;      g_CM->NumColors = 256;
768      g_MW = new QMyMainWindow();      g_MW = new QMyMainWindow();
769      g_MW->resize(g_width, g_height);      g_MW->resize(g_client_width, g_client_height);
770      g_MW->show();      g_MW->show();
771      g_SV->addChild(g_MW);      g_SV->addChild(g_MW);
772      g_MW->setMouseTracking(true);      g_MW->setMouseTracking(true);
773        g_MW->setCursor((int)10); /* Qt::BlankCursor */
774      g_SocketNotifier = new QSocketNotifier(g_global_sock,      g_SocketNotifier = new QSocketNotifier(g_global_sock,
775                                             QSocketNotifier::Read,                                             QSocketNotifier::Read,
776                                             g_MW);                                             g_MW);
# Line 774  void QMyScrollView::timerEvent(QTimerEve Line 781  void QMyScrollView::timerEvent(QTimerEve
781        Desktop = g_App->desktop();        Desktop = g_App->desktop();
782        dw = Desktop->width();        dw = Desktop->width();
783        dh = Desktop->height();        dh = Desktop->height();
784        if (dw == g_width && dh == g_height)        if (dw == g_client_width && dh == g_client_height)
785          g_MW->resize(g_width - 4, g_height - 4);          g_MW->resize(g_client_width - 4, g_client_height - 4);
786        g_SV->showFullScreen();        g_SV->showFullScreen();
787      }      }
788      delete d;      delete d;
# Line 805  QMyMainWindow::~QMyMainWindow() Line 812  QMyMainWindow::~QMyMainWindow()
812  }  }
813    
814  /******************************************************************************/  /******************************************************************************/
815    int rd(double in)
816    {
817      return (int)(in + 0.50);
818    }
819    
820    /******************************************************************************/
821    int c2sx(int cx)
822    {
823      double sx;
824    
825      sx = (double)g_client_width / (double)g_width;
826      return rd(cx / sx);
827    }
828    
829    /******************************************************************************/
830    int c2sy(int cy)
831    {
832      double sy;
833    
834      sy = (double)g_client_height / (double)g_height;
835      return rd(cy / sy);
836    }
837    
838    /******************************************************************************/
839  void QMyMainWindow::timerEvent(QTimerEvent * e)  void QMyMainWindow::timerEvent(QTimerEvent * e)
840  {  {
841    QWidget::timerEvent(e);    QWidget::timerEvent(e);
842    if (e->timerId() == timer_id)    if (e->timerId() == timer_id)
843    {    {
844      // send mouse up      // send mouse up
845      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my);      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1,
846                       rd(c2sx(mx)), rd(c2sy(my)));
847      // if in fullscreen, take it out or the menu won't work      // if in fullscreen, take it out or the menu won't work
848      if (g_fullscreen)      if (g_fullscreen)
849      {      {
# Line 834  void QMyMainWindow::MemuClicked(int Menu Line 866  void QMyMainWindow::MemuClicked(int Menu
866    
867    if (MenuID == 1) // right click    if (MenuID == 1) // right click
868    {    {
869      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, mx, my);      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2,
870      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, mx, my);                     rd(c2sx(mx)), rd(c2sy(my)));
871        rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2,
872                       rd(c2sx(mx)), rd(c2sy(my)));
873    }    }
874    else if (MenuID == 2) // toggle full screen    else if (MenuID == 2) // toggle full screen
875    {    {
# Line 845  void QMyMainWindow::MemuClicked(int Menu Line 879  void QMyMainWindow::MemuClicked(int Menu
879        Desktop = g_App->desktop();        Desktop = g_App->desktop();
880        dw = Desktop->width();        dw = Desktop->width();
881        dh = Desktop->height();        dh = Desktop->height();
882        if (dw == g_width && dh == g_height)        if (dw == g_client_width && dh == g_client_height)
883          g_MW->resize(g_width - 4, g_height - 4);          g_MW->resize(g_client_width - 4, g_client_height - 4);
884        g_SV->showFullScreen();        g_SV->showFullScreen();
885      }      }
886      else      else
887      {      {
888        g_SV->showNormal();        g_SV->showNormal();
889        g_SV->showMaximized();        g_SV->showMaximized();
890        g_MW->resize(g_width, g_height);        g_MW->resize(g_client_width, g_client_height);
891      }      }
892    }    }
893    else if (MenuID == 3) // reset keyboard    else if (MenuID == 3) // reset keyboard
# Line 864  void QMyMainWindow::MemuClicked(int Menu Line 898  void QMyMainWindow::MemuClicked(int Menu
898    }    }
899    else if (MenuID == 4) // double click    else if (MenuID == 4) // double click
900    {    {
901      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my);      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1,
902      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my);                     rd(c2sx(mx)), rd(c2sy(my)));
903      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my);      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1,
904      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my);                     rd(c2sx(mx)), rd(c2sy(my)));
905        rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1,
906                       rd(c2sx(mx)), rd(c2sy(my)));
907        rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1,
908                       rd(c2sx(mx)), rd(c2sy(my)));
909    }    }
910  }  }
911    
912  /******************************************************************************/  /******************************************************************************/
913  void QMyMainWindow::mouseMoveEvent(QMouseEvent* e)  void QMyMainWindow::mouseMoveEvent(QMouseEvent* e)
914  {  {
915    int x;    int x, y;
   int y;  
916    
917    x = e->x();    x = e->x();
918    y = e->y();    y = e->y();
   
919    if (timer_id)    if (timer_id)
920    {    {
921      x = x - mx;      x = x - mx;
# Line 890  void QMyMainWindow::mouseMoveEvent(QMous Line 926  void QMyMainWindow::mouseMoveEvent(QMous
926        timer_id = 0;        timer_id = 0;
927      }      }
928    }    }
929    rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, e->x(), e->y());    rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, c2sx(e->x()),
930                     c2sy(e->y()));
931  }  }
932    
933  /******************************************************************************/  /******************************************************************************/
# Line 900  void QMyMainWindow::mousePressEvent(QMou Line 937  void QMyMainWindow::mousePressEvent(QMou
937    mx = e->x();    mx = e->x();
938    my = e->y();    my = e->y();
939    if (e->button() == LeftButton)    if (e->button() == LeftButton)
940      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, e->x(), e->y());      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1,
941                       c2sx(e->x()), c2sy(e->y()));
942    else if (e->button() == RightButton)    else if (e->button() == RightButton)
943      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, e->x(), e->y());      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2,
944                       c2sx(e->x()), c2sy(e->y()));
945    else if (e->button() == MidButton)    else if (e->button() == MidButton)
946      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3, e->x(), e->y());      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3,
947                       c2sx(e->x()), c2sy(e->y()));
948  }  }
949    
950  /******************************************************************************/  /******************************************************************************/
# Line 913  void QMyMainWindow::mouseReleaseEvent(QM Line 953  void QMyMainWindow::mouseReleaseEvent(QM
953    killTimer(timer_id);    killTimer(timer_id);
954    timer_id = 0;    timer_id = 0;
955    if (e->button() == LeftButton)    if (e->button() == LeftButton)
956      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, e->x(), e->y());      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, c2sx(e->x()),
957                       c2sy(e->y()));
958    else if (e->button() == RightButton)    else if (e->button() == RightButton)
959      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, e->x(), e->y());      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, c2sx(e->x()),
960                       c2sy(e->y()));
961    else if (e->button() == MidButton)    else if (e->button() == MidButton)
962      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, e->x(), e->y());      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, c2sx(e->x()),
963                       c2sy(e->y()));
964  }  }
965    
966  /******************************************************************************/  /******************************************************************************/
967  void QMyMainWindow::wheelEvent(QWheelEvent* e)  void QMyMainWindow::wheelEvent(QWheelEvent* e)
968  {  {
969    if (e->delta() > 0)    if (e->delta() > 0)
970      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON4, e->x(), e->y());      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON4, c2sx(e->x()),
971                       c2sy(e->y()));
972    else if (e->delta() < 0)    else if (e->delta() < 0)
973      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON5, e->x(), e->y());      rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON5, c2sx(e->x()),
974                       c2sy(e->y()));
975  }  }
976    
977  #define NOT(x) (~x)  #define NOT(x) (~x)
# Line 962  int get_pixel(int x, int y) Line 1007  int get_pixel(int x, int y)
1007    if (x >= 0 && x < g_width && y >= 0 && y < g_height)    if (x >= 0 && x < g_width && y >= 0 && y < g_height)
1008    {    {
1009      if (g_server_bpp == 8)      if (g_server_bpp == 8)
1010        return g_BS[y * g_width + x];        return GETPIXEL8(g_BS, x, y, g_width);
1011      else if (g_server_bpp == 16)      else if (g_server_bpp == 16)
1012        return *(((uint16*)g_BS) + (y * g_width + x));        return GETPIXEL16(g_BS, x, y, g_width);
1013      else if (g_server_bpp == 24)      else if (g_server_bpp == 24)
1014        return *(((uint32*)g_BS) + (y * g_width + x));        return GETPIXEL32(g_BS, x, y, g_width);
1015      else      else
1016        return 0;        return 0;
1017    }    }
# Line 977  int get_pixel(int x, int y) Line 1022  int get_pixel(int x, int y)
1022  /******************************************************************************/  /******************************************************************************/
1023  void set_pixel(int x, int y, int pixel, int op = 0xc)  void set_pixel(int x, int y, int pixel, int op = 0xc)
1024  {  {
1025    uint32 p;    int p;
1026    
1027    if (x >= g_clipx && x < (g_clipx + g_clipcx) &&    if (x >= g_clipx && x < (g_clipx + g_clipcx) &&
1028        y >= g_clipy && y < (g_clipy + g_clipcy))        y >= g_clipy && y < (g_clipy + g_clipcy))
# Line 1049  bool WarpCoords(int * x, int * y, int * Line 1094  bool WarpCoords(int * x, int * y, int *
1094  }  }
1095    
1096  /******************************************************************************/  /******************************************************************************/
 uint32 color16to32(uint32 colour)  
 {  
   uint32 r, g, b;  
   r = ((colour >> 8) & 0xf8) | ((colour >> 13) & 0x7);  
   g = ((colour >> 3) & 0xfc) | ((colour >> 9) & 0x3);  
   b = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7);  
   return ((r << 16) | (g << 8) | b);  
 }  
   
 /******************************************************************************/  
 uint32 color24to32(uint32 colour)  
 {  
   uint32 r, g, b;  
   r = (colour >> 0) & 0xff;  
   g = (colour >> 8) & 0xff;  
   b = (colour >> 16) & 0xff;  
   return ((r << 16) | (g << 8) | b);  
 }  
   
 /******************************************************************************/  
1097  void QMyMainWindow::paintEvent(QPaintEvent * pe)  void QMyMainWindow::paintEvent(QPaintEvent * pe)
1098  {  {
1099    QImage * Image;    QImage * Image;
1100    QPainter * Painter;    QPainter * Painter;
1101    QRect Rect;    QRect Rect;
1102    int i, j, w, h, l, t;    int i, j, w, h, l, t, pixel, r, g, b;
   int pixel;  
1103    uint8 * data;    uint8 * data;
1104      double sx, sy;
1105    
1106    Image = 0;    Image = 0;
1107    data = 0;    data = 0;
# Line 1084  void QMyMainWindow::paintEvent(QPaintEve Line 1109  void QMyMainWindow::paintEvent(QPaintEve
1109      setWFlags(WRepaintNoErase);      setWFlags(WRepaintNoErase);
1110    if (g_CM != NULL || g_server_bpp > 8)    if (g_CM != NULL || g_server_bpp > 8)
1111    {    {
1112        sx = (double)g_client_width / (double)g_width;
1113        sy = (double)g_client_height / (double)g_height;
1114      Rect = pe->rect();      Rect = pe->rect();
1115      l = Rect.left();      l = rd(Rect.left() / sx);
1116      t = Rect.top();      t = rd(Rect.top() / sy);
1117      w = Rect.width();      w = rd(Rect.width() / sx);
1118      h = Rect.height();      h = rd(Rect.height() / sy);
1119      if (w > 0 && h > 0)      if (w > 0 && h > 0)
1120      {      {
1121        if (g_server_bpp == 8 && g_CM->NumColors > 0)        if (g_server_bpp == 8 && g_CM->NumColors > 0)
# Line 1097  void QMyMainWindow::paintEvent(QPaintEve Line 1124  void QMyMainWindow::paintEvent(QPaintEve
1124          data = (uint8*)xmalloc(w * h);          data = (uint8*)xmalloc(w * h);
1125          for (i = 0; i < h; i++)          for (i = 0; i < h; i++)
1126            for (j = 0; j < w; j++)            for (j = 0; j < w; j++)
1127              data[i * w + j] = get_pixel(l + j, t + i);              data[i * w + j] = GETPIXEL8(g_BS, l + j, t + i, g_width);
1128          Image = new QImage(data, w, h, 8,(QRgb*)g_CM->RGBColors,          Image = new QImage(data, w, h, 8,(QRgb*)g_CM->RGBColors,
1129                             g_CM->NumColors, QImage::IgnoreEndian);                             g_CM->NumColors, QImage::IgnoreEndian);
1130        }        }
# Line 1109  void QMyMainWindow::paintEvent(QPaintEve Line 1136  void QMyMainWindow::paintEvent(QPaintEve
1136            for (j = 0; j < w; j++)            for (j = 0; j < w; j++)
1137            {            {
1138              pixel = GETPIXEL16(g_BS, l + j, t + i, g_width);              pixel = GETPIXEL16(g_BS, l + j, t + i, g_width);
1139              pixel = color16to32(pixel);              r = ((pixel >> 8) & 0xf8) | ((pixel >> 13) & 0x7);
1140                g = ((pixel >> 3) & 0xfc) | ((pixel >> 9) & 0x3);
1141                b = ((pixel << 3) & 0xf8) | ((pixel >> 2) & 0x7);
1142                pixel = ((r << 16) | (g << 8) | b);
1143              SETPIXEL32(data, j, i, w, pixel);              SETPIXEL32(data, j, i, w, pixel);
1144            }            }
1145          Image = new QImage(data, w, h, 32, NULL,          Image = new QImage(data, w, h, 32, NULL,
# Line 1123  void QMyMainWindow::paintEvent(QPaintEve Line 1153  void QMyMainWindow::paintEvent(QPaintEve
1153            for (j = 0; j < w; j++)            for (j = 0; j < w; j++)
1154            {            {
1155              pixel = GETPIXEL32(g_BS, l + j, t + i, g_width);              pixel = GETPIXEL32(g_BS, l + j, t + i, g_width);
1156              pixel = color24to32(pixel);              r = (pixel >> 0) & 0xff;
1157                g = (pixel >> 8) & 0xff;
1158                b = (pixel >> 16) & 0xff;
1159                pixel = ((r << 16) | (g << 8) | b);
1160              SETPIXEL32(data, j, i, w, pixel);              SETPIXEL32(data, j, i, w, pixel);
1161            }            }
1162          Image = new QImage(data, w, h, 32, NULL,          Image = new QImage(data, w, h, 32, NULL,
# Line 1132  void QMyMainWindow::paintEvent(QPaintEve Line 1165  void QMyMainWindow::paintEvent(QPaintEve
1165        if (Image != 0)        if (Image != 0)
1166        {        {
1167          Painter = new QPainter(this);          Painter = new QPainter(this);
1168            Painter->scale(sx, sy);
1169          Painter->drawImage(l, t, *Image, 0, 0, w, h);          Painter->drawImage(l, t, *Image, 0, 0, w, h);
1170          delete Painter;          delete Painter;
1171          delete Image;          delete Image;
# Line 1185  void QMyMainWindow::soundSend() Line 1219  void QMyMainWindow::soundSend()
1219  /******************************************************************************/  /******************************************************************************/
1220  void redraw(int x, int y, int cx, int cy)  void redraw(int x, int y, int cx, int cy)
1221  {  {
1222      double sx, sy;
1223    
1224    if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL))    if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL))
1225    {    {
1226        sx = (double)g_client_width / (double)g_width;
1227        sy = (double)g_client_height / (double)g_height;
1228        x = rd(x * sx);
1229        y = rd(y * sy);
1230        cx = rd(cx * sx);
1231        cy = rd(cy * sy);
1232      g_MW->update(x, y, cx, cy);      g_MW->update(x, y, cx, cy);
1233    }    }
1234  }  }
# Line 1468  void ui_destblt(uint8 opcode, int x, int Line 1510  void ui_destblt(uint8 opcode, int x, int
1510  {  {
1511    int i, j;    int i, j;
1512    
1513    for (i = 0; i < cy; i++)  
1514      for (j = 0; j < cx; j++)    if (opcode == 0x0) /* black */
1515        set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode);    {
1516        for (i = 0; i < cy; i++)
1517          for (j = 0; j < cx; j++)
1518            set_pixel(x + j, y + i, 0, 0xc);
1519      }
1520      else if (opcode == 0xf) /* white */
1521      {
1522        for (i = 0; i < cy; i++)
1523          for (j = 0; j < cx; j++)
1524            set_pixel(x + j, y + i, 0xffffff, 0xc);
1525      }
1526      else
1527      {
1528        for (i = 0; i < cy; i++)
1529          for (j = 0; j < cx; j++)
1530            set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode);
1531      }
1532    redraw(x, y, cx, cy);    redraw(x, y, cx, cy);
1533  }  }
1534    
# Line 1484  void fill_rect(int x, int y, int cx, int Line 1542  void fill_rect(int x, int y, int cx, int
1542      cx = g_width - x;      cx = g_width - x;
1543    if (y + cy > g_height)    if (y + cy > g_height)
1544      cy = g_height - y;      cy = g_height - y;
1545    for (i = 0; i < cy; i++)  #ifdef QT_OPTI
1546      for (j = 0; j < cx; j++)    if (opcode == 0xc) /* optimize */
1547        set_pixel(x + j, y + i, colour, opcode);    {
1548        if (WarpCoords(&x, &y, &cx, &cy, 0, 0))
1549        {
1550          if (g_server_bpp == 8)
1551          {
1552            for (i = 0; i < cy; i++)
1553              for (j = 0; j < cx; j++)
1554                SETPIXEL8(g_BS, x + j, y + i, g_width, colour);
1555          }
1556          else if (g_server_bpp == 16)
1557          {
1558            for (i = 0; i < cy; i++)
1559              for (j = 0; j < cx; j++)
1560                SETPIXEL16(g_BS, x + j, y + i, g_width, colour);
1561          }
1562          else if (g_server_bpp == 24)
1563          {
1564            for (i = 0; i < cy; i++)
1565              for (j = 0; j < cx; j++)
1566                SETPIXEL32(g_BS, x + j, y + i, g_width, colour);
1567          }
1568        }
1569      }
1570      else
1571    #endif
1572      {
1573        for (i = 0; i < cy; i++)
1574          for (j = 0; j < cx; j++)
1575            set_pixel(x + j, y + i, colour, opcode);
1576      }
1577  }  }
1578    
1579  /******************************************************************************/  /******************************************************************************/
# Line 1527  void ui_patblt(uint8 opcode, int x, int Line 1614  void ui_patblt(uint8 opcode, int x, int
1614  void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,  void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,
1615                    int srcx, int srcy)                    int srcx, int srcy)
1616  {  {
1617    int i, j;    int i, j, pixel;
1618    uint8 * temp;    uint8 * temp;
1619    
1620    temp = (uint8*)xmalloc(cx * cy * (BPP + 1));    temp = (uint8*)xmalloc(cx * cy * 4);
1621    if (g_server_bpp == 8)  #ifdef QT_OPTI
1622    {    if (opcode == 0xc)
     for (i = 0; i < cy; i++)  
       for (j = 0; j < cx; j++)  
         temp[i * cx + j] = get_pixel(srcx + j, srcy + i);  
     for (i = 0; i < cy; i++)  
       for (j = 0; j < cx; j++)  
         set_pixel(x + j, y + i, temp[i * cx + j], opcode);  
   }  
   else if (g_server_bpp == 16)  
1623    {    {
1624      for (i = 0; i < cy; i++)      if (WarpCoords(&x, &y, &cx, &cy, &srcx, &srcy))
1625        for (j = 0; j < cx; j++)      {
1626          *(((uint16*)temp) + (i * cx + j)) = get_pixel(srcx + j, srcy + i);        if (g_server_bpp == 8)
1627      for (i = 0; i < cy; i++)        {
1628        for (j = 0; j < cx; j++)          for (i = 0; i < cy; i++)
1629          set_pixel(x + j, y + i, *(((uint16*)temp) + (i * cx + j)), opcode);            for (j = 0; j < cx; j++)
1630              {
1631                pixel = GETPIXEL8(g_BS, srcx + j, srcy + i, g_width);
1632                SETPIXEL8(temp, j, i, cx, pixel);
1633              }
1634            for (i = 0; i < cy; i++)
1635              for (j = 0; j < cx; j++)
1636              {
1637                pixel = GETPIXEL8(temp, j, i, cx);
1638                SETPIXEL8(g_BS, x + j, y + i, g_width, pixel);
1639              }
1640          }
1641          else if (g_server_bpp == 16)
1642          {
1643            for (i = 0; i < cy; i++)
1644              for (j = 0; j < cx; j++)
1645              {
1646                pixel = GETPIXEL16(g_BS, srcx + j, srcy + i, g_width);
1647                SETPIXEL16(temp, j, i, cx, pixel);
1648              }
1649            for (i = 0; i < cy; i++)
1650              for (j = 0; j < cx; j++)
1651              {
1652                pixel = GETPIXEL16(temp, j, i, cx);
1653                SETPIXEL16(g_BS, x + j, y + i, g_width, pixel);
1654              }
1655          }
1656          else if (g_server_bpp == 24)
1657          {
1658            for (i = 0; i < cy; i++)
1659              for (j = 0; j < cx; j++)
1660              {
1661                pixel = GETPIXEL32(g_BS, srcx + j, srcy + i, g_width);
1662                SETPIXEL32(temp, j, i, cx, pixel);
1663              }
1664            for (i = 0; i < cy; i++)
1665              for (j = 0; j < cx; j++)
1666              {
1667                pixel = GETPIXEL32(temp, j, i, cx);
1668                SETPIXEL32(g_BS, x + j, y + i, g_width, pixel);
1669              }
1670          }
1671        }
1672    }    }
1673    else if (g_server_bpp == 24)    else
1674    #endif
1675    {    {
1676      for (i = 0; i < cy; i++)      if (g_server_bpp == 8)
1677        for (j = 0; j < cx; j++)      {
1678          *(((uint32*)temp) + (i * cx + j)) = get_pixel(srcx + j, srcy + i);        for (i = 0; i < cy; i++)
1679      for (i = 0; i < cy; i++)          for (j = 0; j < cx; j++)
1680        for (j = 0; j < cx; j++)            temp[i * cx + j] = get_pixel(srcx + j, srcy + i);
1681          set_pixel(x + j, y + i, *(((uint32*)temp) + (i * cx + j)), opcode);        for (i = 0; i < cy; i++)
1682            for (j = 0; j < cx; j++)
1683              set_pixel(x + j, y + i, temp[i * cx + j], opcode);
1684        }
1685        else if (g_server_bpp == 16)
1686        {
1687          for (i = 0; i < cy; i++)
1688            for (j = 0; j < cx; j++)
1689            {
1690              pixel = get_pixel(srcx + j, srcy + i);
1691              SETPIXEL16(temp, j, i, cx, pixel);
1692            }
1693          for (i = 0; i < cy; i++)
1694            for (j = 0; j < cx; j++)
1695            {
1696              pixel = GETPIXEL16(temp, j, i, cx);
1697              set_pixel(x + j, y + i, pixel, opcode);
1698            }
1699        }
1700        else if (g_server_bpp == 24)
1701        {
1702          for (i = 0; i < cy; i++)
1703            for (j = 0; j < cx; j++)
1704              *(((uint32*)temp) + (i * cx + j)) = get_pixel(srcx + j, srcy + i);
1705          for (i = 0; i < cy; i++)
1706            for (j = 0; j < cx; j++)
1707              set_pixel(x + j, y + i, *(((uint32*)temp) + (i * cx + j)), opcode);
1708        }
1709    }    }
1710    xfree(temp);    xfree(temp);
1711    redraw(x, y, cx, cy);    redraw(x, y, cx, cy);
# Line 1566  void ui_screenblt(uint8 opcode, int x, i Line 1715  void ui_screenblt(uint8 opcode, int x, i
1715  void ui_memblt(uint8 opcode, int x, int y, int cx, int cy,  void ui_memblt(uint8 opcode, int x, int y, int cx, int cy,
1716                 HBITMAP src, int srcx, int srcy)                 HBITMAP src, int srcx, int srcy)
1717  {  {
1718    int i, j;    int i, j, p;
1719    struct bitmap * the_bitmap;    struct bitmap * the_bitmap;
1720    
1721    the_bitmap = (struct bitmap*)src;    the_bitmap = (struct bitmap*)src;
1722    if (the_bitmap == NULL)    if (the_bitmap == NULL)
1723      return;      return;
1724    if (g_server_bpp == 8)  #ifdef QT_OPTI
1725      if (opcode == 0xc) /* optimize */
1726    {    {
1727      for (i = 0; i < cy; i++)      if (WarpCoords(&x, &y, &cx, &cy, &srcx, &srcy))
1728        for (j = 0; j < cx; j++)      {
1729          if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)        if (g_server_bpp == 8)
1730            set_pixel(x + j, y + i,        {
1731                      the_bitmap->data[(i + srcy) * the_bitmap->w + (j + srcx)],          for (i = 0; i < cy; i++)
1732                      opcode);            for (j = 0; j < cx; j++)
1733    }            {
1734    else if (g_server_bpp == 16)              p = GETPIXEL8(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w);
1735    {              SETPIXEL8(g_BS, x + j, y + i, g_width, p);
1736      for (i = 0; i < cy; i++)            }
1737        for (j = 0; j < cx; j++)        }
1738          if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)        else if (g_server_bpp == 16)
1739            set_pixel(x + j, y + i,        {
1740                      *(((uint16*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))),          for (i = 0; i < cy; i++)
1741                      opcode);            for (j = 0; j < cx; j++)
1742              {
1743                p = GETPIXEL16(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w);
1744                SETPIXEL16(g_BS, x + j, y + i, g_width, p);
1745              }
1746          }
1747          else if (g_server_bpp == 24)
1748          {
1749            for (i = 0; i < cy; i++)
1750              for (j = 0; j < cx; j++)
1751              {
1752                p = GETPIXEL32(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w);
1753                SETPIXEL32(g_BS, x + j, y + i, g_width, p);
1754              }
1755          }
1756        }
1757    }    }
1758    else if (g_server_bpp == 24)    else
1759    #endif
1760    {    {
1761      for (i = 0; i < cy; i++)      if (g_server_bpp == 8)
1762        for (j = 0; j < cx; j++)      {
1763          if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)        for (i = 0; i < cy; i++)
1764            set_pixel(x + j, y + i,          for (j = 0; j < cx; j++)
1765                      *(((uint32*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))),            if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)
1766                      opcode);              set_pixel(x + j, y + i,
1767                          the_bitmap->data[(i + srcy) * the_bitmap->w + (j + srcx)],
1768                          opcode);
1769        }
1770        else if (g_server_bpp == 16)
1771        {
1772          for (i = 0; i < cy; i++)
1773            for (j = 0; j < cx; j++)
1774              if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)
1775                set_pixel(x + j, y + i,
1776                          *(((uint16*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))),
1777                          opcode);
1778        }
1779        else if (g_server_bpp == 24)
1780        {
1781          for (i = 0; i < cy; i++)
1782            for (j = 0; j < cx; j++)
1783              if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)
1784                set_pixel(x + j, y + i,
1785                          *(((uint32*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))),
1786                          opcode);
1787        }
1788    }    }
1789    redraw(x, y, cx, cy);    redraw(x, y, cx, cy);
1790  }  }
# Line 1742  void ui_draw_text(uint8 font, uint8 flag Line 1929  void ui_draw_text(uint8 font, uint8 flag
1929                    int boxy, int boxcx, int boxcy, int bgcolour,                    int boxy, int boxcx, int boxcy, int bgcolour,
1930                    int fgcolour, uint8 * text, uint8 length)                    int fgcolour, uint8 * text, uint8 length)
1931  {  {
1932    FONTGLYPH *glyph;    FONTGLYPH * glyph;
1933    int i, j, xyoffset;    int i, j, xyoffset;
1934    DATABLOB *entry;    DATABLOB * entry;
1935    
1936      if (boxx + boxcx > g_width)
1937        boxcx = g_width - boxx;
1938      if (boxy + boxcy > g_height)
1939        boxcy = g_height - boxy;
1940    
1941    if (boxcx > 1)    if (boxcx > 1)
1942      fill_rect(boxx, boxy, boxcx, boxcy, bgcolour);      fill_rect(boxx, boxy, boxcx, boxcy, bgcolour);
# Line 1810  void ui_draw_text(uint8 font, uint8 flag Line 2002  void ui_draw_text(uint8 font, uint8 flag
2002  void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)  void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
2003  {  {
2004    uint8 * data;    uint8 * data;
2005    int i, j;    int i, j, Bpp, pixel;
   int Bpp;  
2006    
2007    Bpp = 4;    Bpp = 4;
2008    switch (g_server_bpp)    switch (g_server_bpp)
# Line 1825  void ui_desktop_save(uint32 offset, int Line 2016  void ui_desktop_save(uint32 offset, int
2016    {    {
2017      for (i = 0; i < cy; i++)      for (i = 0; i < cy; i++)
2018        for (j = 0; j < cx; j++)        for (j = 0; j < cx; j++)
2019          data[i * cx + j] = get_pixel(x + j, y + i);        {
2020            pixel = get_pixel(x + j, y + i);
2021            SETPIXEL8(data, j, i, cx, pixel);
2022          }
2023    }    }
2024    else if (g_server_bpp == 16)    else if (g_server_bpp == 16)
2025    {    {
2026      for (i = 0; i < cy; i++)      for (i = 0; i < cy; i++)
2027        for (j = 0; j < cx; j++)        for (j = 0; j < cx; j++)
2028          *(((uint16*)data) + (i * cx + j)) = get_pixel(x + j, y + i);        {
2029            pixel = get_pixel(x + j, y + i);
2030            SETPIXEL16(data, j, i, cx, pixel);
2031          }
2032    }    }
2033    else if (g_server_bpp == 24)    else if (g_server_bpp == 24)
2034    {    {
# Line 1847  void ui_desktop_save(uint32 offset, int Line 2044  void ui_desktop_save(uint32 offset, int
2044  /******************************************************************************/  /******************************************************************************/
2045  void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)  void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
2046  {  {
2047    uint8* data;    uint8 * data;
2048    int i, j;    int i, j;
2049    int Bpp;    int Bpp;
2050    
# Line 1882  void ui_desktop_restore(uint32 offset, i Line 2079  void ui_desktop_restore(uint32 offset, i
2079  }  }
2080    
2081  /*****************************************************************************/  /*****************************************************************************/
2082  void* xrealloc(void *in_val, int size)  void* xrealloc(void * in_val, int size)
2083  {  {
2084    if (size < 1)    if (size < 1)
2085      size = 1;      size = 1;
# Line 2033  void hexdump(uint8 * p, uint32 len) Line 2230  void hexdump(uint8 * p, uint32 len)
2230  void get_username_and_hostname(void)  void get_username_and_hostname(void)
2231  {  {
2232    char fullhostname[64];    char fullhostname[64];
2233    char* p;    char * p;
2234    struct passwd* pw;    struct passwd * pw;
2235    
2236    STRNCPY(g_username, "unknown", sizeof(g_username));    STRNCPY(g_username, "unknown", sizeof(g_username));
2237    STRNCPY(g_hostname, "unknown", sizeof(g_hostname));    STRNCPY(g_hostname, "unknown", sizeof(g_hostname));
# Line 2071  void out_params(void) Line 2268  void out_params(void)
2268    fprintf(stderr, "   -c: working directory\n");    fprintf(stderr, "   -c: working directory\n");
2269    fprintf(stderr, "   -p: password (- to prompt)\n");    fprintf(stderr, "   -p: password (- to prompt)\n");
2270    fprintf(stderr, "   -n: client hostname\n");    fprintf(stderr, "   -n: client hostname\n");
2271      fprintf(stderr, "   -f: full screen\n");
2272    
2273    fprintf(stderr, "\n");    fprintf(stderr, "\n");
2274  }  }
# Line 2092  int parse_parameters(int in_argc, char * Line 2290  int parse_parameters(int in_argc, char *
2290      else if (strcmp(in_argv[i], "-g") == 0)      else if (strcmp(in_argv[i], "-g") == 0)
2291      {      {
2292        g_width = strtol(in_argv[i + 1], &p, 10);        g_width = strtol(in_argv[i + 1], &p, 10);
       if (g_width <= 0)  
       {  
         error("invalid geometry\n");  
         return 0;  
       }  
2293        if (*p == 'x')        if (*p == 'x')
2294          g_height = strtol(p + 1, NULL, 10);          g_height = strtol(p + 1, &p, 10);
2295        if (g_height <= 0)        if (*p == '-')
2296            g_client_width = strtol(p + 1, &p, 10);
2297          else
2298        {        {
2299          error("invalid geometry\n");          g_client_width = g_width;
2300          return 0;          g_client_height = g_height;
2301        }        }
2302          if (*p == 'x')
2303            g_client_height = strtol(p + 1, NULL, 10);
2304        g_width = (g_width + 3) & ~3;        g_width = (g_width + 3) & ~3;
2305          g_height = (g_height + 3) & ~3;
2306          g_client_width = (g_client_width + 3) & ~3;
2307          g_client_height = (g_client_height + 3) & ~3;
2308          //printf("%d %d %d %d\n", g_width, g_height, g_client_width, g_client_height);
2309      }      }
2310      else if (strcmp(in_argv[i], "-4") == 0)      else if (strcmp(in_argv[i], "-4") == 0)
2311        g_use_rdp5 = 0;        g_use_rdp5 = 0;
# Line 2113  int parse_parameters(int in_argc, char * Line 2314  int parse_parameters(int in_argc, char *
2314      else if (strcmp(in_argv[i], "-a") == 0)      else if (strcmp(in_argv[i], "-a") == 0)
2315      {      {
2316        g_server_bpp = strtol(in_argv[i + 1], &p, 10);        g_server_bpp = strtol(in_argv[i + 1], &p, 10);
2317        if (g_server_bpp != 8 && g_server_bpp != 15 &&        if (g_server_bpp != 8 &&
2318            g_server_bpp != 16 && g_server_bpp != 24)            g_server_bpp != 16 && g_server_bpp != 24)
2319        {        {
2320          error("invalid bpp\n");          error("invalid bpp\n");
# Line 2148  int parse_parameters(int in_argc, char * Line 2349  int parse_parameters(int in_argc, char *
2349      {      {
2350        STRNCPY(g_hostname, in_argv[i + 1], sizeof(g_hostname));        STRNCPY(g_hostname, in_argv[i + 1], sizeof(g_hostname));
2351      }      }
2352        else if (strcmp(in_argv[i], "-f") == 0)
2353        {
2354          g_fullscreen = 1;
2355        }
2356    }    }
2357    return 1;    return 1;
2358  }  }
# Line 2174  int param_connect(void) Line 2379  int param_connect(void)
2379      memset(g_CM, 0, sizeof(struct QColorMap));      memset(g_CM, 0, sizeof(struct QColorMap));
2380      g_CM->NumColors = 256;      g_CM->NumColors = 256;
2381      g_MW = new QMyMainWindow();      g_MW = new QMyMainWindow();
2382      g_MW->resize(g_width, g_height);      g_MW->resize(g_client_width, g_client_height);
2383      g_MW->show();      g_MW->show();
2384      g_SV->addChild(g_MW);      g_SV->addChild(g_MW);
2385      g_MW->setMouseTracking(true);      g_MW->setMouseTracking(true);
# Line 2188  int param_connect(void) Line 2393  int param_connect(void)
2393        Desktop = g_App->desktop();        Desktop = g_App->desktop();
2394        dw = Desktop->width();        dw = Desktop->width();
2395        dh = Desktop->height();        dh = Desktop->height();
2396        if (dw == g_width && dh == g_height)        if (dw == g_client_width && dh == g_client_height)
2397          g_MW->resize(g_width - 4, g_height - 4);          g_MW->resize(g_client_width - 4, g_client_height - 4);
2398        g_SV->showFullScreen();        g_SV->showFullScreen();
2399      }      }
2400      g_MW->setCursor((int)10); /* Qt::BlankCursor */      g_MW->setCursor((int)10); /* Qt::BlankCursor */
# Line 2204  int main(int argc, char ** argv) Line 2409  int main(int argc, char ** argv)
2409  #ifdef SHARP  #ifdef SHARP
2410    g_App = new QPEApplication(argc, argv);    g_App = new QPEApplication(argc, argv);
2411  #else  #else
2412    g_App = new QApplication(argc, argv, QApplication::GuiServer);    //g_App = new QApplication(argc, argv, QApplication::GuiServer);
2413      g_App = new QApplication(argc, argv);
2414  #endif  #endif
2415    g_SV = new QMyScrollView();    g_SV = new QMyScrollView();
2416    g_App->setMainWidget(g_SV);    g_App->setMainWidget(g_SV);
# Line 2218  int main(int argc, char ** argv) Line 2424  int main(int argc, char ** argv)
2424    else    else
2425    {    {
2426      g_SV->timer_id = g_SV->startTimer(1000); /* one sec delay, then dialog */      g_SV->timer_id = g_SV->startTimer(1000); /* one sec delay, then dialog */
     g_MW->setCursor((int)10); /* Qt::BlankCursor */  
2427      g_App->exec();      g_App->exec();
2428    }    }
2429    delete g_SV;    delete g_SV;

Legend:
Removed from v.791  
changed lines
  Added in v.797

  ViewVC Help
Powered by ViewVC 1.1.26