1 |
/* |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
User interface services - QT Emb System |
User interface services - QT Emb System |
4 |
Copyright (C) Jay Sorg 2004 |
Copyright (C) Jay Sorg 2004-2005 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
25 |
#else |
#else |
26 |
#include <qapplication.h> |
#include <qapplication.h> |
27 |
#endif |
#endif |
28 |
|
#include <qcursor.h> |
29 |
#include <qmainwindow.h> |
#include <qmainwindow.h> |
30 |
#include <qwidget.h> |
#include <qwidget.h> |
31 |
#include <qpainter.h> |
#include <qpainter.h> |
40 |
#include <qfile.h> |
#include <qfile.h> |
41 |
#include <qcheckbox.h> |
#include <qcheckbox.h> |
42 |
#include <qpopupmenu.h> |
#include <qpopupmenu.h> |
43 |
|
|
44 |
#include <stdlib.h> |
#include <stdlib.h> |
45 |
#include <stdarg.h> // va_list va_start va_end |
#include <stdarg.h> // va_list va_start va_end |
46 |
#include <unistd.h> // gethostname |
#include <unistd.h> // gethostname |
49 |
#include "../rdesktop.h" |
#include "../rdesktop.h" |
50 |
#include "qtewin.h" |
#include "qtewin.h" |
51 |
|
|
52 |
/* types */ |
#define QT_OPTI |
|
struct QColorMap |
|
|
{ |
|
|
uint32 RGBColors[256]; |
|
|
uint32 NumColors; |
|
|
}; |
|
|
|
|
|
struct bitmap |
|
|
{ |
|
|
int w; |
|
|
int h; |
|
|
uint8 * data; |
|
|
}; |
|
53 |
|
|
54 |
extern int g_tcp_port_rdp; |
extern int g_tcp_port_rdp; |
|
extern int g_dsp_fd; |
|
|
|
|
|
#ifdef WITH_RDPSND |
|
|
BOOL g_rdpsnd = True; |
|
|
extern int g_dsp_busy; |
|
|
#endif |
|
55 |
int g_encryption = 1; |
int g_encryption = 1; |
56 |
int g_bitmap_cache = 1; |
int g_bitmap_cache = 1; |
57 |
int g_bitmap_cache_persist_enable = 0; |
int g_bitmap_cache_persist_enable = 0; |
59 |
int g_use_rdp5 = 1; |
int g_use_rdp5 = 1; |
60 |
int g_desktop_save = 1; |
int g_desktop_save = 1; |
61 |
int g_bitmap_compression = 1; |
int g_bitmap_compression = 1; |
62 |
int g_rdp5_performanceflags = 0; |
int g_polygon_ellipse_orders = 0; |
63 |
|
int g_rdp5_performanceflags = |
64 |
|
RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS; |
65 |
int g_console_session = 0; |
int g_console_session = 0; |
66 |
int g_keylayout = 0x409; /* Defaults to US keyboard layout */ |
int g_keylayout = 0x409; /* Defaults to US keyboard layout */ |
67 |
|
int g_keyboard_type = 0x4; /* Defaults to US keyboard layout */ |
68 |
|
int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */ |
69 |
|
int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */ |
70 |
int g_width = 640; |
int g_width = 640; |
71 |
int g_height = 480; |
int g_height = 480; |
72 |
int g_server_bpp = 8; |
int g_server_bpp = 8; |
73 |
char g_hostname[16] = ""; |
char g_hostname[16] = ""; |
74 |
char g_username[100] = ""; |
char g_username[100] = ""; |
75 |
|
|
76 |
|
#ifdef WITH_RDPSND |
77 |
|
extern int g_dsp_busy; |
78 |
|
extern int g_dsp_fd; |
79 |
|
int g_rdpsnd = 0; |
80 |
|
static QSocketNotifier * g_SoundNotifier = 0; |
81 |
|
#endif |
82 |
|
|
83 |
|
/* types */ |
84 |
|
struct QColorMap |
85 |
|
{ |
86 |
|
uint32 RGBColors[256]; |
87 |
|
uint32 NumColors; |
88 |
|
}; |
89 |
|
|
90 |
|
struct bitmap |
91 |
|
{ |
92 |
|
int w; |
93 |
|
int h; |
94 |
|
uint8 * data; |
95 |
|
}; |
96 |
|
|
97 |
|
static int g_client_width = 640; |
98 |
|
static int g_client_height = 480; |
99 |
static uint32 g_flags = RDP_LOGON_NORMAL; |
static uint32 g_flags = RDP_LOGON_NORMAL; |
100 |
static char g_server[64] = ""; |
static char g_server[64] = ""; |
101 |
static char g_domain[16] = ""; |
static char g_domain[16] = ""; |
108 |
static uint32 g_ext_disc_reason = 0; |
static uint32 g_ext_disc_reason = 0; |
109 |
|
|
110 |
static QSocketNotifier * g_SocketNotifier = 0; |
static QSocketNotifier * g_SocketNotifier = 0; |
|
static QSocketNotifier * g_SoundNotifier = 0; |
|
111 |
#ifdef SHARP |
#ifdef SHARP |
112 |
static QPEApplication * g_App = 0; |
static QPEApplication * g_App = 0; |
113 |
#else |
#else |
122 |
static int g_clipcx = 0; |
static int g_clipcx = 0; |
123 |
static int g_clipcy = 0; |
static int g_clipcy = 0; |
124 |
|
|
125 |
|
/* Session Directory redirection */ |
126 |
|
BOOL g_redirect = False; |
127 |
|
char g_redirect_server[64]; |
128 |
|
char g_redirect_domain[16]; |
129 |
|
char g_redirect_password[64]; |
130 |
|
char g_redirect_username[64]; |
131 |
|
char g_redirect_cookie[128]; |
132 |
|
uint32 g_redirect_flags = 0; |
133 |
|
|
134 |
#define BPP ((g_server_bpp + 7) / 8) |
#define BPP ((g_server_bpp + 7) / 8) |
135 |
#define GETPIXEL8(d, x, y, w) (*(((uint8*)d) + ((y) * (w) + (x)))) |
#define GETPIXEL8(d, x, y, w) (*(((uint8*)d) + ((y) * (w) + (x)))) |
136 |
#define GETPIXEL16(d, x, y, w) (*(((uint16*)d) + ((y) * (w) + (x)))) |
#define GETPIXEL16(d, x, y, w) (*(((uint16*)d) + ((y) * (w) + (x)))) |
139 |
#define SETPIXEL16(d, x, y, w, v) *(((uint16*)d) + ((y) * (w) + (x))) = v |
#define SETPIXEL16(d, x, y, w, v) *(((uint16*)d) + ((y) * (w) + (x))) = v |
140 |
#define SETPIXEL32(d, x, y, w, v) *(((uint32*)d) + ((y) * (w) + (x))) = v |
#define SETPIXEL32(d, x, y, w, v) *(((uint32*)d) + ((y) * (w) + (x))) = v |
141 |
|
|
142 |
//***************************************************************************** |
/******************************************************************************/ |
143 |
void CleanString(QString * Item) |
void CleanString(QString * Item) |
144 |
{ |
{ |
145 |
int i; |
int i; |
148 |
while (i >= 0) |
while (i >= 0) |
149 |
{ |
{ |
150 |
if (Item->at(i) == 10 || Item->at(i) == 13) |
if (Item->at(i) == 10 || Item->at(i) == 13) |
151 |
|
{ |
152 |
Item->remove(i, 1); |
Item->remove(i, 1); |
153 |
|
} |
154 |
i--; |
i--; |
155 |
} |
} |
156 |
} |
} |
157 |
|
|
158 |
//***************************************************************************** |
/******************************************************************************/ |
159 |
QMyDialog::QMyDialog(QWidget * parent) : QDialog(parent, "Settings", true) |
QMyDialog::QMyDialog(QWidget * parent) : QDialog(parent, "Settings", true) |
160 |
{ |
{ |
161 |
int i, j; |
int i, j; |
269 |
if (home != NULL) |
if (home != NULL) |
270 |
{ |
{ |
271 |
sprintf(Text, "%s/rdesktop.ini", home); |
sprintf(Text, "%s/rdesktop.ini", home); |
272 |
QFile* File = new QFile(Text); |
QFile * File = new QFile(Text); |
273 |
if (File->open(IO_ReadOnly)) |
if (File->open(IO_ReadOnly)) |
274 |
{ |
{ |
275 |
i = -1; |
i = -1; |
306 |
} |
} |
307 |
} |
} |
308 |
|
|
309 |
//***************************************************************************** |
/******************************************************************************/ |
310 |
QMyDialog::~QMyDialog() |
QMyDialog::~QMyDialog() |
311 |
{ |
{ |
312 |
QMyConnectionItem* Item; |
QMyConnectionItem * Item; |
313 |
int i; |
int i; |
314 |
|
|
315 |
for (i = 0; i < 10; i++) |
for (i = 0; i < 10; i++) |
319 |
} |
} |
320 |
} |
} |
321 |
|
|
322 |
//***************************************************************************** |
/******************************************************************************/ |
323 |
void QMyDialog::ComboChanged(int index) |
void QMyDialog::ComboChanged(int index) |
324 |
{ |
{ |
325 |
if (index == 0) |
if (index == 0) |
339 |
} |
} |
340 |
} |
} |
341 |
|
|
342 |
//***************************************************************************** |
/******************************************************************************/ |
343 |
void QMyDialog::OKClicked() |
void QMyDialog::OKClicked() |
344 |
{ |
{ |
345 |
ServerName = ServerNameEdit->text(); |
ServerName = ServerNameEdit->text(); |
351 |
done(1); |
done(1); |
352 |
} |
} |
353 |
|
|
354 |
//***************************************************************************** |
/******************************************************************************/ |
355 |
void QMyDialog::CancelClicked() |
void QMyDialog::CancelClicked() |
356 |
{ |
{ |
357 |
done(0); |
done(0); |
358 |
} |
} |
359 |
|
|
360 |
//***************************************************************************** |
/******************************************************************************/ |
361 |
void QMyDialog::AddClicked() |
void QMyDialog::AddClicked() |
362 |
{ |
{ |
363 |
int i; |
int i; |
377 |
} |
} |
378 |
} |
} |
379 |
|
|
380 |
//***************************************************************************** |
/******************************************************************************/ |
381 |
void QMyDialog::EditClicked() |
void QMyDialog::EditClicked() |
382 |
{ |
{ |
383 |
int i; |
int i; |
397 |
} |
} |
398 |
} |
} |
399 |
|
|
400 |
//***************************************************************************** |
/******************************************************************************/ |
401 |
void WriteString(QFile* File, QString* Line) |
void WriteString(QFile* File, QString* Line) |
402 |
{ |
{ |
403 |
File->writeBlock((const char*)(*Line), Line->length()); |
File->writeBlock((const char*)(*Line), Line->length()); |
404 |
} |
} |
405 |
|
|
406 |
//***************************************************************************** |
/******************************************************************************/ |
407 |
void QMyDialog::SaveClicked() |
void QMyDialog::SaveClicked() |
408 |
{ |
{ |
409 |
int i, j; |
int i, j; |
461 |
} |
} |
462 |
} |
} |
463 |
|
|
464 |
//***************************************************************************** |
/******************************************************************************/ |
465 |
void QMyDialog::RemoveClicked() |
void QMyDialog::RemoveClicked() |
466 |
{ |
{ |
467 |
int i, j, c; |
int i, j, c; |
487 |
} |
} |
488 |
} |
} |
489 |
|
|
490 |
//***************************************************************************** |
/******************************************************************************/ |
491 |
void QMyDialog::ListBoxChanged() |
void QMyDialog::ListBoxChanged() |
492 |
{ |
{ |
493 |
int i; |
int i; |
509 |
} |
} |
510 |
} |
} |
511 |
|
|
512 |
//***************************************************************************** |
/******************************************************************************/ |
513 |
void QMyDialog::ListBoxSelected(int /*index*/) |
void QMyDialog::ListBoxSelected(int /*index*/) |
514 |
{ |
{ |
515 |
} |
} |
516 |
|
|
517 |
//***************************************************************************** |
/******************************************************************************/ |
518 |
void GetScanCode(QKeyEvent * e, int * ScanCode, int * code) |
void GetScanCode(QKeyEvent * e, int * ScanCode, int * code) |
519 |
{ |
{ |
520 |
int key; |
int key; |
682 |
|
|
683 |
} |
} |
684 |
|
|
685 |
//***************************************************************************** |
/******************************************************************************/ |
686 |
QMyScrollView::QMyScrollView() : QScrollView() |
QMyScrollView::QMyScrollView() : QScrollView() |
687 |
{ |
{ |
688 |
} |
} |
689 |
|
|
690 |
//***************************************************************************** |
/******************************************************************************/ |
691 |
QMyScrollView::~QMyScrollView() |
QMyScrollView::~QMyScrollView() |
692 |
{ |
{ |
693 |
} |
} |
694 |
|
|
695 |
//***************************************************************************** |
/******************************************************************************/ |
696 |
void QMyScrollView::keyPressEvent(QKeyEvent* e) |
void QMyScrollView::keyPressEvent(QKeyEvent* e) |
697 |
{ |
{ |
698 |
int ScanCode, code; |
int ScanCode, code; |
710 |
} |
} |
711 |
} |
} |
712 |
|
|
713 |
//***************************************************************************** |
/******************************************************************************/ |
714 |
void QMyScrollView::keyReleaseEvent(QKeyEvent* e) |
void QMyScrollView::keyReleaseEvent(QKeyEvent* e) |
715 |
{ |
{ |
716 |
int ScanCode, code; |
int ScanCode, code; |
728 |
} |
} |
729 |
} |
} |
730 |
|
|
731 |
//***************************************************************************** |
/******************************************************************************/ |
732 |
void QMyScrollView::showEvent(QShowEvent* e) |
void QMyScrollView::showEvent(QShowEvent* e) |
733 |
{ |
{ |
734 |
QScrollView::showEvent(e); |
QScrollView::showEvent(e); |
735 |
} |
} |
736 |
|
|
737 |
//***************************************************************************** |
/******************************************************************************/ |
738 |
void QMyScrollView::show() |
void QMyScrollView::show() |
739 |
{ |
{ |
740 |
QScrollView::show(); |
QScrollView::show(); |
741 |
} |
} |
742 |
|
|
743 |
//***************************************************************************** |
/******************************************************************************/ |
744 |
void QMyScrollView::polish() |
void QMyScrollView::polish() |
745 |
{ |
{ |
746 |
QScrollView::polish(); |
QScrollView::polish(); |
747 |
} |
} |
748 |
|
|
749 |
//***************************************************************************** |
/******************************************************************************/ |
750 |
void QMyScrollView::timerEvent(QTimerEvent * e) |
void QMyScrollView::timerEvent(QTimerEvent * e) |
751 |
{ |
{ |
|
QScrollView::timerEvent(e); |
|
|
killTimer(timer_id); |
|
752 |
QMyDialog * d; |
QMyDialog * d; |
753 |
QWidget * Desktop; |
QWidget * Desktop; |
754 |
int dw; |
int dw; |
755 |
int dh; |
int dh; |
756 |
|
|
757 |
|
QScrollView::timerEvent(e); |
758 |
|
killTimer(timer_id); |
759 |
d = new QMyDialog(this); |
d = new QMyDialog(this); |
760 |
if (d->exec() == 1) // ok clicked |
if (d->exec() == 1) // ok clicked |
761 |
{ |
{ |
762 |
g_width = d->Width; |
g_width = d->Width; |
763 |
g_height = d->Height; |
g_height = d->Height; |
764 |
|
g_client_width = g_width; |
765 |
|
g_client_height = g_height; |
766 |
g_fullscreen = d->FullScreen; |
g_fullscreen = d->FullScreen; |
767 |
sprintf(g_server, "%s", (const char*)d->ServerIP); |
sprintf(g_server, "%s", (const char*)d->ServerIP); |
768 |
sprintf(g_username, "%s", (const char*)d->UserName); |
sprintf(g_username, "%s", (const char*)d->UserName); |
769 |
|
#ifdef WITH_RDPSND |
770 |
|
// init sound |
771 |
|
if (g_rdpsnd) |
772 |
|
{ |
773 |
|
rdpsnd_init(); |
774 |
|
} |
775 |
|
#endif |
776 |
if (!rdp_connect(g_server, g_flags, g_domain, g_password, g_shell, |
if (!rdp_connect(g_server, g_flags, g_domain, g_password, g_shell, |
777 |
g_directory)) |
g_directory)) |
778 |
{ |
{ |
790 |
memset(g_CM, 0, sizeof(struct QColorMap)); |
memset(g_CM, 0, sizeof(struct QColorMap)); |
791 |
g_CM->NumColors = 256; |
g_CM->NumColors = 256; |
792 |
g_MW = new QMyMainWindow(); |
g_MW = new QMyMainWindow(); |
793 |
g_MW->resize(g_width, g_height); |
g_MW->resize(g_client_width, g_client_height); |
794 |
g_MW->show(); |
g_MW->show(); |
795 |
g_SV->addChild(g_MW); |
g_SV->addChild(g_MW); |
796 |
g_MW->setMouseTracking(true); |
g_MW->setMouseTracking(true); |
797 |
|
g_MW->setCursor((int)10); /* Qt::BlankCursor */ |
798 |
g_SocketNotifier = new QSocketNotifier(g_global_sock, |
g_SocketNotifier = new QSocketNotifier(g_global_sock, |
799 |
QSocketNotifier::Read, |
QSocketNotifier::Read, |
800 |
g_MW); |
g_MW); |
805 |
Desktop = g_App->desktop(); |
Desktop = g_App->desktop(); |
806 |
dw = Desktop->width(); |
dw = Desktop->width(); |
807 |
dh = Desktop->height(); |
dh = Desktop->height(); |
808 |
if (dw == g_width && dh == g_height) |
if (dw == g_client_width && dh == g_client_height) |
809 |
g_MW->resize(g_width - 4, g_height - 4); |
{ |
810 |
|
g_MW->resize(g_client_width - 4, g_client_height - 4); |
811 |
|
} |
812 |
g_SV->showFullScreen(); |
g_SV->showFullScreen(); |
813 |
} |
} |
814 |
delete d; |
delete d; |
820 |
} |
} |
821 |
} |
} |
822 |
|
|
823 |
//***************************************************************************** |
/******************************************************************************/ |
824 |
QMyMainWindow::QMyMainWindow() : QWidget(g_SV->viewport()) |
QMyMainWindow::QMyMainWindow() : QWidget(g_SV->viewport()) |
825 |
{ |
{ |
826 |
PopupMenu = new QPopupMenu(this); |
PopupMenu = new QPopupMenu(this); |
831 |
connect(PopupMenu, SIGNAL(activated(int)), this, SLOT(MemuClicked(int))); |
connect(PopupMenu, SIGNAL(activated(int)), this, SLOT(MemuClicked(int))); |
832 |
} |
} |
833 |
|
|
834 |
//***************************************************************************** |
/******************************************************************************/ |
835 |
QMyMainWindow::~QMyMainWindow() |
QMyMainWindow::~QMyMainWindow() |
836 |
{ |
{ |
837 |
delete PopupMenu; |
delete PopupMenu; |
838 |
} |
} |
839 |
|
|
840 |
//***************************************************************************** |
/******************************************************************************/ |
841 |
|
int rd(double in) |
842 |
|
{ |
843 |
|
return (int)(in + 0.50); |
844 |
|
} |
845 |
|
|
846 |
|
/******************************************************************************/ |
847 |
|
int c2sx(int cx) |
848 |
|
{ |
849 |
|
double sx; |
850 |
|
|
851 |
|
sx = (double)g_client_width / (double)g_width; |
852 |
|
return rd(cx / sx); |
853 |
|
} |
854 |
|
|
855 |
|
/******************************************************************************/ |
856 |
|
int c2sy(int cy) |
857 |
|
{ |
858 |
|
double sy; |
859 |
|
|
860 |
|
sy = (double)g_client_height / (double)g_height; |
861 |
|
return rd(cy / sy); |
862 |
|
} |
863 |
|
|
864 |
|
/******************************************************************************/ |
865 |
void QMyMainWindow::timerEvent(QTimerEvent * e) |
void QMyMainWindow::timerEvent(QTimerEvent * e) |
866 |
{ |
{ |
867 |
QWidget::timerEvent(e); |
QWidget::timerEvent(e); |
868 |
if (e->timerId() == timer_id) |
if (e->timerId() == timer_id) |
869 |
{ |
{ |
870 |
// send mouse up |
// send mouse up |
871 |
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); |
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, |
872 |
|
rd(c2sx(mx)), rd(c2sy(my))); |
873 |
// if in fullscreen, take it out or the menu won't work |
// if in fullscreen, take it out or the menu won't work |
874 |
if (g_fullscreen) |
if (g_fullscreen) |
875 |
{ |
{ |
883 |
killTimer(timer_id); |
killTimer(timer_id); |
884 |
} |
} |
885 |
|
|
886 |
//***************************************************************************** |
/******************************************************************************/ |
887 |
void QMyMainWindow::MemuClicked(int MenuID) |
void QMyMainWindow::MemuClicked(int MenuID) |
888 |
{ |
{ |
889 |
QWidget * Desktop; |
QWidget * Desktop; |
892 |
|
|
893 |
if (MenuID == 1) // right click |
if (MenuID == 1) // right click |
894 |
{ |
{ |
895 |
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, |
896 |
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, mx, my); |
rd(c2sx(mx)), rd(c2sy(my))); |
897 |
|
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, |
898 |
|
rd(c2sx(mx)), rd(c2sy(my))); |
899 |
} |
} |
900 |
else if (MenuID == 2) // toggle full screen |
else if (MenuID == 2) // toggle full screen |
901 |
{ |
{ |
905 |
Desktop = g_App->desktop(); |
Desktop = g_App->desktop(); |
906 |
dw = Desktop->width(); |
dw = Desktop->width(); |
907 |
dh = Desktop->height(); |
dh = Desktop->height(); |
908 |
if (dw == g_width && dh == g_height) |
if (dw == g_client_width && dh == g_client_height) |
909 |
g_MW->resize(g_width - 4, g_height - 4); |
g_MW->resize(g_client_width - 4, g_client_height - 4); |
910 |
g_SV->showFullScreen(); |
g_SV->showFullScreen(); |
911 |
} |
} |
912 |
else |
else |
913 |
{ |
{ |
914 |
g_SV->showNormal(); |
g_SV->showNormal(); |
915 |
g_SV->showMaximized(); |
g_SV->showMaximized(); |
916 |
g_MW->resize(g_width, g_height); |
g_MW->resize(g_client_width, g_client_height); |
917 |
} |
} |
918 |
} |
} |
919 |
else if (MenuID == 3) // reset keyboard |
else if (MenuID == 3) // reset keyboard |
924 |
} |
} |
925 |
else if (MenuID == 4) // double click |
else if (MenuID == 4) // double click |
926 |
{ |
{ |
927 |
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, |
928 |
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); |
rd(c2sx(mx)), rd(c2sy(my))); |
929 |
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, |
930 |
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); |
rd(c2sx(mx)), rd(c2sy(my))); |
931 |
|
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, |
932 |
|
rd(c2sx(mx)), rd(c2sy(my))); |
933 |
|
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, |
934 |
|
rd(c2sx(mx)), rd(c2sy(my))); |
935 |
} |
} |
936 |
} |
} |
937 |
|
|
938 |
//***************************************************************************** |
/******************************************************************************/ |
939 |
void QMyMainWindow::mouseMoveEvent(QMouseEvent* e) |
void QMyMainWindow::mouseMoveEvent(QMouseEvent* e) |
940 |
{ |
{ |
941 |
int x; |
int x, y; |
|
int y; |
|
942 |
|
|
943 |
x = e->x(); |
x = e->x(); |
944 |
y = e->y(); |
y = e->y(); |
|
|
|
945 |
if (timer_id) |
if (timer_id) |
946 |
{ |
{ |
947 |
x = x - mx; |
x = x - mx; |
952 |
timer_id = 0; |
timer_id = 0; |
953 |
} |
} |
954 |
} |
} |
955 |
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()), |
956 |
|
c2sy(e->y())); |
957 |
} |
} |
958 |
|
|
959 |
//***************************************************************************** |
/******************************************************************************/ |
960 |
void QMyMainWindow::mousePressEvent(QMouseEvent* e) |
void QMyMainWindow::mousePressEvent(QMouseEvent* e) |
961 |
{ |
{ |
962 |
timer_id = startTimer(1000); |
timer_id = startTimer(1000); |
963 |
mx = e->x(); |
mx = e->x(); |
964 |
my = e->y(); |
my = e->y(); |
965 |
if (e->button() == LeftButton) |
if (e->button() == LeftButton) |
966 |
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, |
967 |
|
c2sx(e->x()), c2sy(e->y())); |
968 |
else if (e->button() == RightButton) |
else if (e->button() == RightButton) |
969 |
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, |
970 |
|
c2sx(e->x()), c2sy(e->y())); |
971 |
else if (e->button() == MidButton) |
else if (e->button() == MidButton) |
972 |
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, |
973 |
|
c2sx(e->x()), c2sy(e->y())); |
974 |
} |
} |
975 |
|
|
976 |
//***************************************************************************** |
/******************************************************************************/ |
977 |
void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e) |
void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e) |
978 |
{ |
{ |
979 |
killTimer(timer_id); |
killTimer(timer_id); |
980 |
timer_id = 0; |
timer_id = 0; |
981 |
if (e->button() == LeftButton) |
if (e->button() == LeftButton) |
982 |
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()), |
983 |
|
c2sy(e->y())); |
984 |
else if (e->button() == RightButton) |
else if (e->button() == RightButton) |
985 |
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()), |
986 |
|
c2sy(e->y())); |
987 |
else if (e->button() == MidButton) |
else if (e->button() == MidButton) |
988 |
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()), |
989 |
|
c2sy(e->y())); |
990 |
} |
} |
991 |
|
|
992 |
//***************************************************************************** |
/******************************************************************************/ |
993 |
void QMyMainWindow::wheelEvent(QWheelEvent* e) |
void QMyMainWindow::wheelEvent(QWheelEvent* e) |
994 |
{ |
{ |
995 |
if (e->delta() > 0) |
if (e->delta() > 0) |
996 |
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()), |
997 |
|
c2sy(e->y())); |
998 |
else if (e->delta() < 0) |
else if (e->delta() < 0) |
999 |
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()), |
1000 |
|
c2sy(e->y())); |
1001 |
} |
} |
1002 |
|
|
1003 |
#define NOT(x) (~x) |
#define NOT(x) (~x) |
1004 |
|
|
1005 |
//***************************************************************************** |
/******************************************************************************/ |
1006 |
int rop(int rop, int src, int dst) |
int rop(int rop, int src, int dst) |
1007 |
{ |
{ |
1008 |
switch (rop) |
switch (rop) |
1033 |
if (x >= 0 && x < g_width && y >= 0 && y < g_height) |
if (x >= 0 && x < g_width && y >= 0 && y < g_height) |
1034 |
{ |
{ |
1035 |
if (g_server_bpp == 8) |
if (g_server_bpp == 8) |
1036 |
return g_BS[y * g_width + x]; |
return GETPIXEL8(g_BS, x, y, g_width); |
1037 |
else if (g_server_bpp == 16) |
else if (g_server_bpp == 16) |
1038 |
return *(((uint16*)g_BS) + (y * g_width + x)); |
return GETPIXEL16(g_BS, x, y, g_width); |
1039 |
|
else if (g_server_bpp == 24) |
1040 |
|
return GETPIXEL32(g_BS, x, y, g_width); |
1041 |
else |
else |
1042 |
return 0; |
return 0; |
1043 |
} |
} |
1045 |
return 0; |
return 0; |
1046 |
} |
} |
1047 |
|
|
1048 |
//***************************************************************************** |
/******************************************************************************/ |
1049 |
void set_pixel(int x, int y, int pixel, int op = 0xc) |
void set_pixel(int x, int y, int pixel, int op = 0xc) |
1050 |
{ |
{ |
1051 |
uint32 p; |
int p; |
1052 |
|
|
1053 |
if (x >= g_clipx && x < (g_clipx + g_clipcx) && |
if (x >= g_clipx && x < (g_clipx + g_clipcx) && |
1054 |
y >= g_clipy && y < (g_clipy + g_clipcy)) |
y >= g_clipy && y < (g_clipy + g_clipcy)) |
1065 |
{ |
{ |
1066 |
SETPIXEL16(g_BS, x, y, g_width, pixel); |
SETPIXEL16(g_BS, x, y, g_width, pixel); |
1067 |
} |
} |
1068 |
|
else if (g_server_bpp == 24) |
1069 |
|
{ |
1070 |
|
SETPIXEL32(g_BS, x, y, g_width, pixel); |
1071 |
|
} |
1072 |
} |
} |
1073 |
else |
else |
1074 |
{ |
{ |
1084 |
p = rop(op, pixel, p); |
p = rop(op, pixel, p); |
1085 |
SETPIXEL16(g_BS, x, y, g_width, p); |
SETPIXEL16(g_BS, x, y, g_width, p); |
1086 |
} |
} |
1087 |
|
else if (g_server_bpp == 24) |
1088 |
|
{ |
1089 |
|
p = GETPIXEL32(g_BS, x, y, g_width); |
1090 |
|
p = rop(op, pixel, p); |
1091 |
|
SETPIXEL32(g_BS, x, y, g_width, p); |
1092 |
|
} |
1093 |
} |
} |
1094 |
} |
} |
1095 |
} |
} |
1096 |
} |
} |
1097 |
|
|
1098 |
//****************************************************************************** |
/******************************************************************************/ |
1099 |
// adjust coordinates for cliping rect |
// adjust coordinates for cliping rect |
1100 |
bool WarpCoords(int * x, int * y, int * cx, int * cy, int * srcx, int * srcy) |
bool WarpCoords(int * x, int * y, int * cx, int * cy, int * srcx, int * srcy) |
1101 |
{ |
{ |
1119 |
return true; |
return true; |
1120 |
} |
} |
1121 |
|
|
1122 |
//***************************************************************************** |
/******************************************************************************/ |
|
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); |
|
|
} |
|
|
|
|
|
//***************************************************************************** |
|
1123 |
void QMyMainWindow::paintEvent(QPaintEvent * pe) |
void QMyMainWindow::paintEvent(QPaintEvent * pe) |
1124 |
{ |
{ |
1125 |
QImage * Image; |
QImage * Image; |
1126 |
QPainter * Painter; |
QPainter * Painter; |
1127 |
QRect Rect; |
QRect Rect; |
1128 |
int i, j, w, h, l, t; |
int i, j, w, h, l, t, pixel, r, g, b; |
1129 |
uint8 * data; |
uint8 * data; |
1130 |
|
double sx, sy; |
1131 |
|
|
1132 |
Image = 0; |
Image = 0; |
1133 |
data = 0; |
data = 0; |
1135 |
setWFlags(WRepaintNoErase); |
setWFlags(WRepaintNoErase); |
1136 |
if (g_CM != NULL || g_server_bpp > 8) |
if (g_CM != NULL || g_server_bpp > 8) |
1137 |
{ |
{ |
1138 |
|
sx = (double)g_client_width / (double)g_width; |
1139 |
|
sy = (double)g_client_height / (double)g_height; |
1140 |
Rect = pe->rect(); |
Rect = pe->rect(); |
1141 |
l = Rect.left(); |
l = rd(Rect.left() / sx); |
1142 |
t = Rect.top(); |
t = rd(Rect.top() / sy); |
1143 |
w = Rect.width(); |
w = rd(Rect.width() / sx); |
1144 |
h = Rect.height(); |
h = rd(Rect.height() / sy); |
1145 |
if (w > 0 && h > 0) |
if (w > 0 && h > 0) |
1146 |
{ |
{ |
1147 |
if (g_server_bpp == 8 && g_CM->NumColors > 0) |
if (g_server_bpp == 8 && g_CM->NumColors > 0) |
1150 |
data = (uint8*)xmalloc(w * h); |
data = (uint8*)xmalloc(w * h); |
1151 |
for (i = 0; i < h; i++) |
for (i = 0; i < h; i++) |
1152 |
for (j = 0; j < w; j++) |
for (j = 0; j < w; j++) |
1153 |
data[i * w + j] = get_pixel(l + j, t + i); |
data[i * w + j] = GETPIXEL8(g_BS, l + j, t + i, g_width); |
1154 |
Image = new QImage(data, w, h, 8,(QRgb*)g_CM->RGBColors, |
Image = new QImage(data, w, h, 8,(QRgb*)g_CM->RGBColors, |
1155 |
g_CM->NumColors, QImage::IgnoreEndian); |
g_CM->NumColors, QImage::IgnoreEndian); |
1156 |
} |
} |
1160 |
data = (uint8*)xmalloc(w * h * 4); |
data = (uint8*)xmalloc(w * h * 4); |
1161 |
for (i = 0; i < h; i++) |
for (i = 0; i < h; i++) |
1162 |
for (j = 0; j < w; j++) |
for (j = 0; j < w; j++) |
1163 |
*(((uint32*)data) + (i * w + j)) = color16to32(get_pixel(l + j, t + i)); |
{ |
1164 |
|
pixel = GETPIXEL16(g_BS, l + j, t + i, g_width); |
1165 |
|
r = ((pixel >> 8) & 0xf8) | ((pixel >> 13) & 0x7); |
1166 |
|
g = ((pixel >> 3) & 0xfc) | ((pixel >> 9) & 0x3); |
1167 |
|
b = ((pixel << 3) & 0xf8) | ((pixel >> 2) & 0x7); |
1168 |
|
pixel = ((r << 16) | (g << 8) | b); |
1169 |
|
SETPIXEL32(data, j, i, w, pixel); |
1170 |
|
} |
1171 |
|
Image = new QImage(data, w, h, 32, NULL, |
1172 |
|
0, QImage::IgnoreEndian); |
1173 |
|
} |
1174 |
|
else if (g_server_bpp == 24) |
1175 |
|
{ |
1176 |
|
w = (w + 3) & ~3; |
1177 |
|
data = (uint8*)xmalloc(w * h * 4); |
1178 |
|
for (i = 0; i < h; i++) |
1179 |
|
for (j = 0; j < w; j++) |
1180 |
|
{ |
1181 |
|
pixel = GETPIXEL32(g_BS, l + j, t + i, g_width); |
1182 |
|
r = (pixel >> 0) & 0xff; |
1183 |
|
g = (pixel >> 8) & 0xff; |
1184 |
|
b = (pixel >> 16) & 0xff; |
1185 |
|
pixel = ((r << 16) | (g << 8) | b); |
1186 |
|
SETPIXEL32(data, j, i, w, pixel); |
1187 |
|
} |
1188 |
Image = new QImage(data, w, h, 32, NULL, |
Image = new QImage(data, w, h, 32, NULL, |
1189 |
0, QImage::IgnoreEndian); |
0, QImage::IgnoreEndian); |
1190 |
} |
} |
1191 |
if (Image != 0) |
if (Image != 0) |
1192 |
{ |
{ |
1193 |
Painter = new QPainter(this); |
Painter = new QPainter(this); |
1194 |
|
Painter->scale(sx, sy); |
1195 |
Painter->drawImage(l, t, *Image, 0, 0, w, h); |
Painter->drawImage(l, t, *Image, 0, 0, w, h); |
1196 |
delete Painter; |
delete Painter; |
1197 |
delete Image; |
delete Image; |
1201 |
} |
} |
1202 |
} |
} |
1203 |
|
|
1204 |
//***************************************************************************** |
/******************************************************************************/ |
1205 |
void QMyMainWindow::closeEvent(QCloseEvent * e) |
void QMyMainWindow::closeEvent(QCloseEvent * e) |
1206 |
{ |
{ |
1207 |
e->accept(); |
e->accept(); |
1208 |
} |
} |
1209 |
|
|
1210 |
//***************************************************************************** |
/******************************************************************************/ |
1211 |
void QMyMainWindow::dataReceived() |
void QMyMainWindow::dataReceived() |
1212 |
{ |
{ |
1213 |
if (!rdp_loop(&g_deactivated, &g_ext_disc_reason)) |
if (!rdp_loop(&g_deactivated, &g_ext_disc_reason)) |
1231 |
#endif |
#endif |
1232 |
} |
} |
1233 |
|
|
1234 |
//***************************************************************************** |
/******************************************************************************/ |
1235 |
void QMyMainWindow::soundSend() |
void QMyMainWindow::soundSend() |
1236 |
{ |
{ |
|
g_SoundNotifier->setEnabled(false); |
|
1237 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
1238 |
|
g_SoundNotifier->setEnabled(false); |
1239 |
wave_out_play(); |
wave_out_play(); |
1240 |
if (g_dsp_busy) |
if (g_dsp_busy) |
1241 |
|
{ |
1242 |
g_SoundNotifier->setEnabled(true); |
g_SoundNotifier->setEnabled(true); |
1243 |
|
} |
1244 |
#endif |
#endif |
1245 |
} |
} |
1246 |
|
|
1247 |
//***************************************************************************** |
/******************************************************************************/ |
1248 |
void redraw(int x, int y, int cx, int cy) |
void redraw(int x, int y, int cx, int cy) |
1249 |
{ |
{ |
1250 |
|
double sx, sy; |
1251 |
|
|
1252 |
if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL)) |
if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL)) |
1253 |
{ |
{ |
1254 |
|
sx = (double)g_client_width / (double)g_width; |
1255 |
|
sy = (double)g_client_height / (double)g_height; |
1256 |
|
x = rd(x * sx); |
1257 |
|
y = rd(y * sy); |
1258 |
|
cx = rd(cx * sx); |
1259 |
|
cy = rd(cy * sy); |
1260 |
g_MW->update(x, y, cx, cy); |
g_MW->update(x, y, cx, cy); |
1261 |
} |
} |
1262 |
} |
} |
1263 |
|
|
1264 |
//***************************************************************************** |
/******************************************************************************/ |
1265 |
/* Returns 0 after user quit, 1 otherwise */ |
/* Returns 0 after user quit, 1 otherwise */ |
1266 |
int ui_select(int rdp_socket) |
int ui_select(int rdp_socket) |
1267 |
{ |
{ |
1270 |
return 1; |
return 1; |
1271 |
} |
} |
1272 |
|
|
1273 |
//***************************************************************************** |
/******************************************************************************/ |
1274 |
void ui_move_pointer(int /*x*/, int /*y*/) |
void ui_move_pointer(int /*x*/, int /*y*/) |
1275 |
{ |
{ |
1276 |
} |
} |
1277 |
|
|
1278 |
/*****************************************************************************/ |
/******************************************************************************/ |
1279 |
void ui_set_null_cursor(void) |
void ui_set_null_cursor(void) |
1280 |
{ |
{ |
1281 |
} |
} |
1282 |
|
|
1283 |
//***************************************************************************** |
/******************************************************************************/ |
1284 |
HBITMAP ui_create_bitmap(int width, int height, uint8 * data) |
HBITMAP ui_create_bitmap(int width, int height, uint8 * data) |
1285 |
{ |
{ |
1286 |
struct bitmap * the_bitmap; |
struct bitmap * the_bitmap; |
1287 |
uint8 * bitmap_data; |
uint8 * bitmap_data; |
1288 |
int i, j; |
int i, j; |
1289 |
|
int r, g, b, pixel; |
1290 |
|
|
1291 |
bitmap_data = (uint8*)xmalloc(width * height * BPP); |
bitmap_data = (uint8*)xmalloc(width * height * 4); |
1292 |
the_bitmap = (struct bitmap*)xmalloc(sizeof(struct bitmap)); |
the_bitmap = (struct bitmap*)xmalloc(sizeof(struct bitmap)); |
1293 |
the_bitmap->w = width; |
the_bitmap->w = width; |
1294 |
the_bitmap->h = height; |
the_bitmap->h = height; |
1303 |
{ |
{ |
1304 |
for (i = 0; i < height; i++) |
for (i = 0; i < height; i++) |
1305 |
for (j = 0; j < width; j++) |
for (j = 0; j < width; j++) |
1306 |
*(((uint16*)bitmap_data) + (i * width + j)) = *(((uint16*)data) + (i * width + j)); |
*(((uint16*)bitmap_data) + (i * width + j)) = |
1307 |
|
*(((uint16*)data) + (i * width + j)); |
1308 |
|
} |
1309 |
|
else if (g_server_bpp == 24) |
1310 |
|
{ |
1311 |
|
for (i = 0; i < height; i++) |
1312 |
|
for (j = 0; j < width; j++) |
1313 |
|
{ |
1314 |
|
r = data[(i * width + j) * 3 + 0]; |
1315 |
|
g = data[(i * width + j) * 3 + 1]; |
1316 |
|
b = data[(i * width + j) * 3 + 2]; |
1317 |
|
pixel = (r << 16) | (g << 8) | b; |
1318 |
|
SETPIXEL32(bitmap_data, j, i, width, pixel); |
1319 |
|
} |
1320 |
} |
} |
1321 |
return the_bitmap; |
return the_bitmap; |
1322 |
} |
} |
1323 |
|
|
1324 |
//***************************************************************************** |
/******************************************************************************/ |
1325 |
void ui_paint_bitmap(int x, int y, int cx, int cy, int width, |
void ui_paint_bitmap(int x, int y, int cx, int cy, int width, |
1326 |
int height, uint8 * data) |
int height, uint8 * data) |
1327 |
{ |
{ |
1328 |
int i, j; |
int i, j; |
1329 |
|
int r, g, b, pixel; |
1330 |
|
|
1331 |
if (g_server_bpp == 8) |
if (g_server_bpp == 8) |
1332 |
{ |
{ |
1344 |
if (j < width) |
if (j < width) |
1345 |
set_pixel(x + j, y + i, *(((uint16*)data) + (i * width + j))); |
set_pixel(x + j, y + i, *(((uint16*)data) + (i * width + j))); |
1346 |
} |
} |
1347 |
|
else if (g_server_bpp == 24) |
1348 |
|
{ |
1349 |
|
for (i = 0; i < cy; i++) |
1350 |
|
for (j = 0; j < cx; j++) |
1351 |
|
if (i < height) |
1352 |
|
if (j < width) |
1353 |
|
{ |
1354 |
|
r = data[(i * width + j) * 3 + 0]; |
1355 |
|
g = data[(i * width + j) * 3 + 1]; |
1356 |
|
b = data[(i * width + j) * 3 + 2]; |
1357 |
|
pixel = (r << 16) | (g << 8) | b; |
1358 |
|
set_pixel(x + j, y + i, pixel); |
1359 |
|
} |
1360 |
|
} |
1361 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1362 |
} |
} |
1363 |
|
|
1364 |
//***************************************************************************** |
/******************************************************************************/ |
1365 |
void ui_destroy_bitmap(HBITMAP bmp) |
void ui_destroy_bitmap(HBITMAP bmp) |
1366 |
{ |
{ |
1367 |
struct bitmap* the_bitmap; |
struct bitmap* the_bitmap; |
1375 |
} |
} |
1376 |
} |
} |
1377 |
|
|
1378 |
//***************************************************************************** |
/******************************************************************************/ |
1379 |
bool is_pixel_on(uint8* data, int x, int y, int width, int bpp) |
bool is_pixel_on(uint8 * data, int x, int y, int width, int bpp) |
1380 |
{ |
{ |
1381 |
int start, shift; |
int start, shift; |
1382 |
|
|
1393 |
return false; |
return false; |
1394 |
} |
} |
1395 |
|
|
1396 |
//***************************************************************************** |
/******************************************************************************/ |
1397 |
void set_pixel_on(uint8* data, int x, int y, int width, int bpp, uint8 pixel) |
void set_pixel_on(uint8 * data, int x, int y, int width, int bpp, uint8 pixel) |
1398 |
{ |
{ |
1399 |
if (bpp == 8) |
if (bpp == 8) |
1400 |
data[y * width + x] = pixel; |
data[y * width + x] = pixel; |
1401 |
} |
} |
1402 |
|
|
1403 |
//***************************************************************************** |
/******************************************************************************/ |
1404 |
HGLYPH ui_create_glyph(int width, int height, uint8 * data) |
HGLYPH ui_create_glyph(int width, int height, uint8 * data) |
1405 |
{ |
{ |
1406 |
int i, j; |
int i, j; |
1420 |
return the_glyph; |
return the_glyph; |
1421 |
} |
} |
1422 |
|
|
1423 |
//***************************************************************************** |
/******************************************************************************/ |
1424 |
void ui_destroy_glyph(HGLYPH glyph) |
void ui_destroy_glyph(HGLYPH glyph) |
1425 |
{ |
{ |
1426 |
struct bitmap* the_glyph; |
struct bitmap* the_glyph; |
1434 |
} |
} |
1435 |
} |
} |
1436 |
|
|
1437 |
//***************************************************************************** |
/******************************************************************************/ |
1438 |
HCURSOR ui_create_cursor(uint32 x, uint32 y, |
HCURSOR ui_create_cursor(uint32 x, uint32 y, |
1439 |
int width, int height, |
int width, int height, |
1440 |
uint8 * andmask, uint8 * xormask) |
uint8 * andmask, uint8 * xormask) |
1442 |
return (void*)1; |
return (void*)1; |
1443 |
} |
} |
1444 |
|
|
1445 |
//***************************************************************************** |
/******************************************************************************/ |
1446 |
void ui_set_cursor(HCURSOR /*cursor*/) |
void ui_set_cursor(HCURSOR /*cursor*/) |
1447 |
{ |
{ |
1448 |
} |
} |
1463 |
void ui_resize_window(void) |
void ui_resize_window(void) |
1464 |
{ |
{ |
1465 |
} |
} |
1466 |
//***************************************************************************** |
|
1467 |
|
/*****************************************************************************/ |
1468 |
|
void ui_polygon(uint8 opcode, uint8 fillmode, POINT * point, int npoints, |
1469 |
|
BRUSH * brush, int bgcolour, int fgcolour) |
1470 |
|
{ |
1471 |
|
} |
1472 |
|
|
1473 |
|
/*****************************************************************************/ |
1474 |
|
/* todo, use qt function for this (QPainter::drawPolyline) */ |
1475 |
|
void ui_polyline(uint8 opcode, POINT * points, int npoints, PEN * pen) |
1476 |
|
{ |
1477 |
|
int i, x, y, dx, dy; |
1478 |
|
|
1479 |
|
if (npoints > 0) |
1480 |
|
{ |
1481 |
|
x = points[0].x; |
1482 |
|
y = points[0].y; |
1483 |
|
for (i = 1; i < npoints; i++) |
1484 |
|
{ |
1485 |
|
dx = points[i].x; |
1486 |
|
dy = points[i].y; |
1487 |
|
ui_line(opcode, x, y, x + dx, y + dy, pen); |
1488 |
|
x = x + dx; |
1489 |
|
y = y + dy; |
1490 |
|
} |
1491 |
|
} |
1492 |
|
} |
1493 |
|
|
1494 |
|
/*****************************************************************************/ |
1495 |
|
void ui_ellipse(uint8 opcode, uint8 fillmode, |
1496 |
|
int x, int y, int cx, int cy, |
1497 |
|
BRUSH * brush, int bgcolour, int fgcolour) |
1498 |
|
{ |
1499 |
|
} |
1500 |
|
|
1501 |
|
/******************************************************************************/ |
1502 |
void ui_destroy_cursor(HCURSOR /*cursor*/) |
void ui_destroy_cursor(HCURSOR /*cursor*/) |
1503 |
{ |
{ |
1504 |
} |
} |
1505 |
|
|
1506 |
//***************************************************************************** |
/******************************************************************************/ |
1507 |
HCOLOURMAP ui_create_colourmap(COLOURMAP * colours) |
HCOLOURMAP ui_create_colourmap(COLOURMAP * colours) |
1508 |
{ |
{ |
1509 |
int i; |
int i; |
1523 |
return g_CM; |
return g_CM; |
1524 |
} |
} |
1525 |
|
|
1526 |
//***************************************************************************** |
/******************************************************************************/ |
1527 |
void ui_set_colourmap(HCOLOURMAP map) |
void ui_set_colourmap(HCOLOURMAP map) |
1528 |
{ |
{ |
1529 |
} |
} |
1530 |
|
|
1531 |
//***************************************************************************** |
/******************************************************************************/ |
1532 |
void ui_destroy_colourmap(HCOLOURMAP map) |
void ui_destroy_colourmap(HCOLOURMAP map) |
1533 |
{ |
{ |
1534 |
} |
} |
1535 |
|
|
1536 |
//***************************************************************************** |
/******************************************************************************/ |
1537 |
void ui_begin_update(void) |
void ui_begin_update(void) |
1538 |
{ |
{ |
1539 |
} |
} |
1540 |
|
|
1541 |
//***************************************************************************** |
/******************************************************************************/ |
1542 |
void ui_end_update(void) |
void ui_end_update(void) |
1543 |
{ |
{ |
1544 |
} |
} |
1545 |
|
|
1546 |
//***************************************************************************** |
/******************************************************************************/ |
1547 |
void ui_set_clip(int x, int y, int cx, int cy) |
void ui_set_clip(int x, int y, int cx, int cy) |
1548 |
{ |
{ |
1549 |
g_clipx = x; |
g_clipx = x; |
1552 |
g_clipcy = cy; |
g_clipcy = cy; |
1553 |
} |
} |
1554 |
|
|
1555 |
//***************************************************************************** |
/******************************************************************************/ |
1556 |
void ui_reset_clip(void) |
void ui_reset_clip(void) |
1557 |
{ |
{ |
1558 |
g_clipx = 0; |
g_clipx = 0; |
1561 |
g_clipcy = g_height; |
g_clipcy = g_height; |
1562 |
} |
} |
1563 |
|
|
1564 |
//***************************************************************************** |
/******************************************************************************/ |
1565 |
void ui_bell(void) |
void ui_bell(void) |
1566 |
{ |
{ |
1567 |
g_App->beep(); |
g_App->beep(); |
1568 |
} |
} |
1569 |
|
|
1570 |
//***************************************************************************** |
/******************************************************************************/ |
1571 |
void ui_destblt(uint8 opcode, int x, int y, int cx, int cy) |
void ui_destblt(uint8 opcode, int x, int y, int cx, int cy) |
1572 |
{ |
{ |
1573 |
int i, j; |
int i, j; |
1574 |
|
|
1575 |
for (i = 0; i < cy; i++) |
|
1576 |
for (j = 0; j < cx; j++) |
if (opcode == 0x0) /* black */ |
1577 |
set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode); |
{ |
1578 |
|
for (i = 0; i < cy; i++) |
1579 |
|
for (j = 0; j < cx; j++) |
1580 |
|
set_pixel(x + j, y + i, 0, 0xc); |
1581 |
|
} |
1582 |
|
else if (opcode == 0xf) /* white */ |
1583 |
|
{ |
1584 |
|
for (i = 0; i < cy; i++) |
1585 |
|
for (j = 0; j < cx; j++) |
1586 |
|
set_pixel(x + j, y + i, 0xffffff, 0xc); |
1587 |
|
} |
1588 |
|
else |
1589 |
|
{ |
1590 |
|
for (i = 0; i < cy; i++) |
1591 |
|
for (j = 0; j < cx; j++) |
1592 |
|
set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode); |
1593 |
|
} |
1594 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1595 |
} |
} |
1596 |
|
|
1597 |
//***************************************************************************** |
/******************************************************************************/ |
1598 |
// does not repaint |
// does not repaint |
1599 |
void fill_rect(int x, int y, int cx, int cy, int colour, int opcode = 0xc) |
void fill_rect(int x, int y, int cx, int cy, int colour, int opcode = 0xc) |
1600 |
{ |
{ |
1604 |
cx = g_width - x; |
cx = g_width - x; |
1605 |
if (y + cy > g_height) |
if (y + cy > g_height) |
1606 |
cy = g_height - y; |
cy = g_height - y; |
1607 |
for (i = 0; i < cy; i++) |
#ifdef QT_OPTI |
1608 |
for (j = 0; j < cx; j++) |
if (opcode == 0xc) /* optimize */ |
1609 |
set_pixel(x + j, y + i, colour, opcode); |
{ |
1610 |
|
if (WarpCoords(&x, &y, &cx, &cy, 0, 0)) |
1611 |
|
{ |
1612 |
|
if (g_server_bpp == 8) |
1613 |
|
{ |
1614 |
|
for (i = 0; i < cy; i++) |
1615 |
|
for (j = 0; j < cx; j++) |
1616 |
|
SETPIXEL8(g_BS, x + j, y + i, g_width, colour); |
1617 |
|
} |
1618 |
|
else if (g_server_bpp == 16) |
1619 |
|
{ |
1620 |
|
for (i = 0; i < cy; i++) |
1621 |
|
for (j = 0; j < cx; j++) |
1622 |
|
SETPIXEL16(g_BS, x + j, y + i, g_width, colour); |
1623 |
|
} |
1624 |
|
else if (g_server_bpp == 24) |
1625 |
|
{ |
1626 |
|
for (i = 0; i < cy; i++) |
1627 |
|
for (j = 0; j < cx; j++) |
1628 |
|
SETPIXEL32(g_BS, x + j, y + i, g_width, colour); |
1629 |
|
} |
1630 |
|
} |
1631 |
|
} |
1632 |
|
else |
1633 |
|
#endif |
1634 |
|
{ |
1635 |
|
for (i = 0; i < cy; i++) |
1636 |
|
for (j = 0; j < cx; j++) |
1637 |
|
set_pixel(x + j, y + i, colour, opcode); |
1638 |
|
} |
1639 |
} |
} |
1640 |
|
|
1641 |
//***************************************************************************** |
/******************************************************************************/ |
1642 |
void ui_rect(int x, int y, int cx, int cy, int colour) |
void ui_rect(int x, int y, int cx, int cy, int colour) |
1643 |
{ |
{ |
1644 |
fill_rect(x, y, cx, cy, colour); |
fill_rect(x, y, cx, cy, colour); |
1645 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1646 |
} |
} |
1647 |
|
|
1648 |
//***************************************************************************** |
/******************************************************************************/ |
1649 |
void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, |
void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, |
1650 |
BRUSH * brush, int bgcolour, int fgcolour) |
BRUSH * brush, int bgcolour, int fgcolour) |
1651 |
{ |
{ |
1672 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1673 |
} |
} |
1674 |
|
|
1675 |
//***************************************************************************** |
/******************************************************************************/ |
1676 |
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, |
1677 |
int srcx, int srcy) |
int srcx, int srcy) |
1678 |
{ |
{ |
1679 |
int i, j; |
int i, j, pixel; |
1680 |
uint8* temp; |
uint8 * temp; |
1681 |
|
|
1682 |
temp = (uint8*)xmalloc(cx * cy * BPP); |
temp = (uint8*)xmalloc(cx * cy * 4); |
1683 |
if (g_server_bpp == 8) |
#ifdef QT_OPTI |
1684 |
|
if (opcode == 0xc) |
1685 |
{ |
{ |
1686 |
for (i = 0; i < cy; i++) |
if (WarpCoords(&x, &y, &cx, &cy, &srcx, &srcy)) |
1687 |
for (j = 0; j < cx; j++) |
{ |
1688 |
temp[i * cx + j] = get_pixel(srcx + j, srcy + i); |
if (g_server_bpp == 8) |
1689 |
for (i = 0; i < cy; i++) |
{ |
1690 |
for (j = 0; j < cx; j++) |
for (i = 0; i < cy; i++) |
1691 |
set_pixel(x + j, y + i, temp[i * cx + j], opcode); |
for (j = 0; j < cx; j++) |
1692 |
|
{ |
1693 |
|
pixel = GETPIXEL8(g_BS, srcx + j, srcy + i, g_width); |
1694 |
|
SETPIXEL8(temp, j, i, cx, pixel); |
1695 |
|
} |
1696 |
|
for (i = 0; i < cy; i++) |
1697 |
|
for (j = 0; j < cx; j++) |
1698 |
|
{ |
1699 |
|
pixel = GETPIXEL8(temp, j, i, cx); |
1700 |
|
SETPIXEL8(g_BS, x + j, y + i, g_width, pixel); |
1701 |
|
} |
1702 |
|
} |
1703 |
|
else if (g_server_bpp == 16) |
1704 |
|
{ |
1705 |
|
for (i = 0; i < cy; i++) |
1706 |
|
for (j = 0; j < cx; j++) |
1707 |
|
{ |
1708 |
|
pixel = GETPIXEL16(g_BS, srcx + j, srcy + i, g_width); |
1709 |
|
SETPIXEL16(temp, j, i, cx, pixel); |
1710 |
|
} |
1711 |
|
for (i = 0; i < cy; i++) |
1712 |
|
for (j = 0; j < cx; j++) |
1713 |
|
{ |
1714 |
|
pixel = GETPIXEL16(temp, j, i, cx); |
1715 |
|
SETPIXEL16(g_BS, x + j, y + i, g_width, pixel); |
1716 |
|
} |
1717 |
|
} |
1718 |
|
else if (g_server_bpp == 24) |
1719 |
|
{ |
1720 |
|
for (i = 0; i < cy; i++) |
1721 |
|
for (j = 0; j < cx; j++) |
1722 |
|
{ |
1723 |
|
pixel = GETPIXEL32(g_BS, srcx + j, srcy + i, g_width); |
1724 |
|
SETPIXEL32(temp, j, i, cx, pixel); |
1725 |
|
} |
1726 |
|
for (i = 0; i < cy; i++) |
1727 |
|
for (j = 0; j < cx; j++) |
1728 |
|
{ |
1729 |
|
pixel = GETPIXEL32(temp, j, i, cx); |
1730 |
|
SETPIXEL32(g_BS, x + j, y + i, g_width, pixel); |
1731 |
|
} |
1732 |
|
} |
1733 |
|
} |
1734 |
} |
} |
1735 |
else if (g_server_bpp == 16) |
else |
1736 |
|
#endif |
1737 |
{ |
{ |
1738 |
for (i = 0; i < cy; i++) |
if (g_server_bpp == 8) |
1739 |
for (j = 0; j < cx; j++) |
{ |
1740 |
*(((uint16*)temp) + (i * cx + j)) = get_pixel(srcx + j, srcy + i); |
for (i = 0; i < cy; i++) |
1741 |
for (i = 0; i < cy; i++) |
for (j = 0; j < cx; j++) |
1742 |
for (j = 0; j < cx; j++) |
temp[i * cx + j] = get_pixel(srcx + j, srcy + i); |
1743 |
set_pixel(x + j, y + i, *(((uint16*)temp) + (i * cx + j)), opcode); |
for (i = 0; i < cy; i++) |
1744 |
|
for (j = 0; j < cx; j++) |
1745 |
|
set_pixel(x + j, y + i, temp[i * cx + j], opcode); |
1746 |
|
} |
1747 |
|
else if (g_server_bpp == 16) |
1748 |
|
{ |
1749 |
|
for (i = 0; i < cy; i++) |
1750 |
|
for (j = 0; j < cx; j++) |
1751 |
|
{ |
1752 |
|
pixel = get_pixel(srcx + j, srcy + i); |
1753 |
|
SETPIXEL16(temp, j, i, cx, pixel); |
1754 |
|
} |
1755 |
|
for (i = 0; i < cy; i++) |
1756 |
|
for (j = 0; j < cx; j++) |
1757 |
|
{ |
1758 |
|
pixel = GETPIXEL16(temp, j, i, cx); |
1759 |
|
set_pixel(x + j, y + i, pixel, opcode); |
1760 |
|
} |
1761 |
|
} |
1762 |
|
else if (g_server_bpp == 24) |
1763 |
|
{ |
1764 |
|
for (i = 0; i < cy; i++) |
1765 |
|
for (j = 0; j < cx; j++) |
1766 |
|
*(((uint32*)temp) + (i * cx + j)) = get_pixel(srcx + j, srcy + i); |
1767 |
|
for (i = 0; i < cy; i++) |
1768 |
|
for (j = 0; j < cx; j++) |
1769 |
|
set_pixel(x + j, y + i, *(((uint32*)temp) + (i * cx + j)), opcode); |
1770 |
|
} |
1771 |
} |
} |
1772 |
xfree(temp); |
xfree(temp); |
1773 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1774 |
} |
} |
1775 |
|
|
1776 |
//***************************************************************************** |
/******************************************************************************/ |
1777 |
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, |
1778 |
HBITMAP src, int srcx, int srcy) |
HBITMAP src, int srcx, int srcy) |
1779 |
{ |
{ |
1780 |
int i, j; |
int i, j, p; |
1781 |
struct bitmap* the_bitmap; |
struct bitmap * the_bitmap; |
1782 |
|
|
1783 |
the_bitmap = (struct bitmap*)src; |
the_bitmap = (struct bitmap*)src; |
1784 |
if (the_bitmap == NULL) |
if (the_bitmap == NULL) |
1785 |
return; |
return; |
1786 |
if (g_server_bpp == 8) |
#ifdef QT_OPTI |
1787 |
|
if (opcode == 0xc) /* optimize */ |
1788 |
{ |
{ |
1789 |
for (i = 0; i < cy; i++) |
if (WarpCoords(&x, &y, &cx, &cy, &srcx, &srcy)) |
1790 |
for (j = 0; j < cx; j++) |
{ |
1791 |
if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w) |
if (g_server_bpp == 8) |
1792 |
set_pixel(x + j, y + i, |
{ |
1793 |
the_bitmap->data[(i + srcy) * the_bitmap->w + (j + srcx)], |
for (i = 0; i < cy; i++) |
1794 |
opcode); |
for (j = 0; j < cx; j++) |
1795 |
|
{ |
1796 |
|
p = GETPIXEL8(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w); |
1797 |
|
SETPIXEL8(g_BS, x + j, y + i, g_width, p); |
1798 |
|
} |
1799 |
|
} |
1800 |
|
else if (g_server_bpp == 16) |
1801 |
|
{ |
1802 |
|
for (i = 0; i < cy; i++) |
1803 |
|
for (j = 0; j < cx; j++) |
1804 |
|
{ |
1805 |
|
p = GETPIXEL16(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w); |
1806 |
|
SETPIXEL16(g_BS, x + j, y + i, g_width, p); |
1807 |
|
} |
1808 |
|
} |
1809 |
|
else if (g_server_bpp == 24) |
1810 |
|
{ |
1811 |
|
for (i = 0; i < cy; i++) |
1812 |
|
for (j = 0; j < cx; j++) |
1813 |
|
{ |
1814 |
|
p = GETPIXEL32(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w); |
1815 |
|
SETPIXEL32(g_BS, x + j, y + i, g_width, p); |
1816 |
|
} |
1817 |
|
} |
1818 |
|
} |
1819 |
} |
} |
1820 |
else if (g_server_bpp == 16) |
else |
1821 |
|
#endif |
1822 |
{ |
{ |
1823 |
for (i = 0; i < cy; i++) |
if (g_server_bpp == 8) |
1824 |
for (j = 0; j < cx; j++) |
{ |
1825 |
if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w) |
for (i = 0; i < cy; i++) |
1826 |
set_pixel(x + j, y + i, |
for (j = 0; j < cx; j++) |
1827 |
*(((uint16*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))), |
if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w) |
1828 |
opcode); |
set_pixel(x + j, y + i, |
1829 |
|
the_bitmap->data[(i + srcy) * the_bitmap->w + (j + srcx)], |
1830 |
|
opcode); |
1831 |
|
} |
1832 |
|
else if (g_server_bpp == 16) |
1833 |
|
{ |
1834 |
|
for (i = 0; i < cy; i++) |
1835 |
|
for (j = 0; j < cx; j++) |
1836 |
|
if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w) |
1837 |
|
set_pixel(x + j, y + i, |
1838 |
|
*(((uint16*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))), |
1839 |
|
opcode); |
1840 |
|
} |
1841 |
|
else if (g_server_bpp == 24) |
1842 |
|
{ |
1843 |
|
for (i = 0; i < cy; i++) |
1844 |
|
for (j = 0; j < cx; j++) |
1845 |
|
if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w) |
1846 |
|
set_pixel(x + j, y + i, |
1847 |
|
*(((uint32*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))), |
1848 |
|
opcode); |
1849 |
|
} |
1850 |
} |
} |
1851 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1852 |
} |
} |
1853 |
|
|
1854 |
//***************************************************************************** |
/******************************************************************************/ |
1855 |
// not used |
// not used |
1856 |
void ui_triblt(uint8 opcode, int x, int y, int cx, int cy, |
void ui_triblt(uint8 opcode, int x, int y, int cx, int cy, |
1857 |
HBITMAP src, int srcx, int srcy, BRUSH * brush, |
HBITMAP src, int srcx, int srcy, BRUSH * brush, |
1859 |
{ |
{ |
1860 |
} |
} |
1861 |
|
|
1862 |
//***************************************************************************** |
/******************************************************************************/ |
1863 |
// Bresenham's line drawing algorithm |
/* Bresenham's line drawing algorithm */ |
1864 |
void ui_line(uint8 opcode, int startx, int starty, int endx, |
void ui_line(uint8 opcode, int startx, int starty, int endx, |
1865 |
int endy, PEN * pen) |
int endy, PEN * pen) |
1866 |
{ |
{ |
1939 |
redraw(left, top, (right - left) + 1, (bottom - top) + 1); |
redraw(left, top, (right - left) + 1, (bottom - top) + 1); |
1940 |
} |
} |
1941 |
|
|
1942 |
//***************************************************************************** |
/******************************************************************************/ |
1943 |
void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour) |
void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour) |
1944 |
{ |
{ |
1945 |
struct bitmap *the_glyph; |
struct bitmap *the_glyph; |
1984 |
}\ |
}\ |
1985 |
} |
} |
1986 |
|
|
1987 |
|
/******************************************************************************/ |
1988 |
//***************************************************************************** |
//***************************************************************************** |
1989 |
void ui_draw_text(uint8 font, uint8 flags, int mixmode, |
void ui_draw_text(uint8 font, uint8 flags, uint8 opcode, int mixmode, |
1990 |
int x, int y, int clipx, int clipy, |
int x, int y, int clipx, int clipy, |
1991 |
int clipcx, int clipcy, int boxx, |
int clipcx, int clipcy, int boxx, |
1992 |
int boxy, int boxcx, int boxcy, int bgcolour, |
int boxy, int boxcx, int boxcy, BRUSH * brush, |
1993 |
int fgcolour, uint8 * text, uint8 length) |
int bgcolour, int fgcolour, uint8 * text, uint8 length) |
1994 |
{ |
{ |
1995 |
FONTGLYPH *glyph; |
FONTGLYPH * glyph; |
1996 |
int i, j, xyoffset; |
int i, j, xyoffset; |
1997 |
DATABLOB *entry; |
DATABLOB * entry; |
1998 |
|
|
1999 |
|
if (boxx + boxcx > g_width) |
2000 |
|
boxcx = g_width - boxx; |
2001 |
|
if (boxy + boxcy > g_height) |
2002 |
|
boxcy = g_height - boxy; |
2003 |
|
|
2004 |
if (boxcx > 1) |
if (boxcx > 1) |
2005 |
fill_rect(boxx, boxy, boxcx, boxcy, bgcolour); |
fill_rect(boxx, boxy, boxcx, boxcy, bgcolour); |
2061 |
redraw(clipx, clipy, clipcx, clipcy); |
redraw(clipx, clipy, clipcx, clipcy); |
2062 |
} |
} |
2063 |
|
|
2064 |
//***************************************************************************** |
/******************************************************************************/ |
2065 |
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) |
2066 |
{ |
{ |
2067 |
uint8* data; |
uint8 * data; |
2068 |
int i, j; |
int i, j, Bpp, pixel; |
2069 |
|
|
2070 |
data = (uint8*)xmalloc(cx * cy * BPP); |
Bpp = 4; |
2071 |
|
switch (g_server_bpp) |
2072 |
|
{ |
2073 |
|
case 8: Bpp = 1; break; |
2074 |
|
case 15: Bpp = 2; break; |
2075 |
|
case 16: Bpp = 2; break; |
2076 |
|
} |
2077 |
|
data = (uint8*)xmalloc(cx * cy * Bpp); |
2078 |
if (g_server_bpp == 8) |
if (g_server_bpp == 8) |
2079 |
{ |
{ |
2080 |
for (i = 0; i < cy; i++) |
for (i = 0; i < cy; i++) |
2081 |
for (j = 0; j < cx; j++) |
for (j = 0; j < cx; j++) |
2082 |
data[i * cx + j] = get_pixel(x + j, y + i); |
{ |
2083 |
|
pixel = get_pixel(x + j, y + i); |
2084 |
|
SETPIXEL8(data, j, i, cx, pixel); |
2085 |
|
} |
2086 |
} |
} |
2087 |
else if (g_server_bpp == 16) |
else if (g_server_bpp == 16) |
2088 |
{ |
{ |
2089 |
for (i = 0; i < cy; i++) |
for (i = 0; i < cy; i++) |
2090 |
for (j = 0; j < cx; j++) |
for (j = 0; j < cx; j++) |
2091 |
*(((uint16*)data) + (i * cx + j)) = get_pixel(x + j, y + i); |
{ |
2092 |
|
pixel = get_pixel(x + j, y + i); |
2093 |
|
SETPIXEL16(data, j, i, cx, pixel); |
2094 |
|
} |
2095 |
|
} |
2096 |
|
else if (g_server_bpp == 24) |
2097 |
|
{ |
2098 |
|
for (i = 0; i < cy; i++) |
2099 |
|
for (j = 0; j < cx; j++) |
2100 |
|
*(((uint32*)data) + (i * cx + j)) = get_pixel(x + j, y + i); |
2101 |
} |
} |
2102 |
offset *= BPP; |
offset *= Bpp; |
2103 |
cache_put_desktop(offset, cx, cy, cx * BPP, BPP, data); |
cache_put_desktop(offset, cx, cy, cx * Bpp, Bpp, data); |
2104 |
xfree(data); |
xfree(data); |
2105 |
} |
} |
2106 |
|
|
2107 |
//***************************************************************************** |
/******************************************************************************/ |
2108 |
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) |
2109 |
{ |
{ |
2110 |
uint8* data; |
uint8 * data; |
2111 |
int i, j; |
int i, j; |
2112 |
|
int Bpp; |
2113 |
|
|
2114 |
offset *= BPP; |
Bpp = 4; |
2115 |
data = cache_get_desktop(offset, cx, cy, BPP); |
switch (g_server_bpp) |
2116 |
|
{ |
2117 |
|
case 8: Bpp = 1; break; |
2118 |
|
case 15: Bpp = 2; break; |
2119 |
|
case 16: Bpp = 2; break; |
2120 |
|
} |
2121 |
|
offset *= Bpp; |
2122 |
|
data = cache_get_desktop(offset, cx, cy, Bpp); |
2123 |
if (g_server_bpp == 8) |
if (g_server_bpp == 8) |
2124 |
{ |
{ |
2125 |
for (i = 0; i < cy; i++) |
for (i = 0; i < cy; i++) |
2132 |
for (j = 0; j < cx; j++) |
for (j = 0; j < cx; j++) |
2133 |
set_pixel(x + j, y + i, *(((uint16*)data) + (i * cx + j))); |
set_pixel(x + j, y + i, *(((uint16*)data) + (i * cx + j))); |
2134 |
} |
} |
2135 |
|
else if (g_server_bpp == 24) |
2136 |
|
{ |
2137 |
|
for (i = 0; i < cy; i++) |
2138 |
|
for (j = 0; j < cx; j++) |
2139 |
|
set_pixel(x + j, y + i, *(((uint32*)data) + (i * cx + j))); |
2140 |
|
} |
2141 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
2142 |
} |
} |
2143 |
|
|
2144 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2145 |
void* xrealloc(void *in_val, int size) |
void * xrealloc(void * in_val, int size) |
2146 |
{ |
{ |
2147 |
if (size < 1) |
if (size < 1) |
2148 |
|
{ |
2149 |
size = 1; |
size = 1; |
2150 |
|
} |
2151 |
return realloc(in_val, size); |
return realloc(in_val, size); |
2152 |
} |
} |
2153 |
|
|
2154 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2155 |
void* xmalloc(int size) |
void * xmalloc(int size) |
2156 |
{ |
{ |
2157 |
return malloc(size); |
return malloc(size); |
2158 |
} |
} |
2161 |
void xfree(void * in_val) |
void xfree(void * in_val) |
2162 |
{ |
{ |
2163 |
if (in_val != NULL) |
if (in_val != NULL) |
2164 |
|
{ |
2165 |
free(in_val); |
free(in_val); |
2166 |
|
} |
2167 |
|
} |
2168 |
|
|
2169 |
|
/*****************************************************************************/ |
2170 |
|
char * xstrdup(const char * s) |
2171 |
|
{ |
2172 |
|
char * mem = strdup(s); |
2173 |
|
if (mem == NULL) |
2174 |
|
{ |
2175 |
|
perror("strdup"); |
2176 |
|
exit(1); |
2177 |
|
} |
2178 |
|
return mem; |
2179 |
} |
} |
2180 |
|
|
2181 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2270 |
QFile File("/dev/random"); |
QFile File("/dev/random"); |
2271 |
File.open(IO_ReadOnly); |
File.open(IO_ReadOnly); |
2272 |
if (File.readBlock((char*)random, 32) == 32) |
if (File.readBlock((char*)random, 32) == 32) |
2273 |
|
{ |
2274 |
return; |
return; |
2275 |
|
} |
2276 |
warning("no /dev/random\n"); |
warning("no /dev/random\n"); |
2277 |
memcpy(random, "12345678901234567890123456789012", 32); |
memcpy(random, "12345678901234567890123456789012", 32); |
2278 |
} |
} |
2290 |
printf("%04x ", offset); |
printf("%04x ", offset); |
2291 |
thisline = len - offset; |
thisline = len - offset; |
2292 |
if (thisline > 16) |
if (thisline > 16) |
2293 |
|
{ |
2294 |
thisline = 16; |
thisline = 16; |
2295 |
|
} |
2296 |
for (i = 0; i < thisline; i++) |
for (i = 0; i < thisline; i++) |
2297 |
|
{ |
2298 |
printf("%02x ", line[i]); |
printf("%02x ", line[i]); |
2299 |
|
} |
2300 |
for (; i < 16; i++) |
for (; i < 16; i++) |
2301 |
|
{ |
2302 |
printf(" "); |
printf(" "); |
2303 |
|
} |
2304 |
for (i = 0; i < thisline; i++) |
for (i = 0; i < thisline; i++) |
2305 |
|
{ |
2306 |
printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.'); |
printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.'); |
2307 |
|
} |
2308 |
printf("\n"); |
printf("\n"); |
2309 |
offset += thisline; |
offset += thisline; |
2310 |
line += thisline; |
line += thisline; |
2315 |
void get_username_and_hostname(void) |
void get_username_and_hostname(void) |
2316 |
{ |
{ |
2317 |
char fullhostname[64]; |
char fullhostname[64]; |
2318 |
char* p; |
char * p; |
2319 |
struct passwd* pw; |
struct passwd * pw; |
2320 |
|
|
2321 |
STRNCPY(g_username, "unknown", sizeof(g_username)); |
STRNCPY(g_username, "unknown", sizeof(g_username)); |
2322 |
STRNCPY(g_hostname, "unknown", sizeof(g_hostname)); |
STRNCPY(g_hostname, "unknown", sizeof(g_hostname)); |
2329 |
{ |
{ |
2330 |
p = strchr(fullhostname, '.'); |
p = strchr(fullhostname, '.'); |
2331 |
if (p != NULL) |
if (p != NULL) |
2332 |
|
{ |
2333 |
*p = 0; |
*p = 0; |
2334 |
|
} |
2335 |
STRNCPY(g_hostname, fullhostname, sizeof(g_hostname)); |
STRNCPY(g_hostname, fullhostname, sizeof(g_hostname)); |
2336 |
} |
} |
2337 |
} |
} |
2348 |
fprintf(stderr, " -5: use RDP version 5 (default)\n"); |
fprintf(stderr, " -5: use RDP version 5 (default)\n"); |
2349 |
fprintf(stderr, " -t: tcp port)\n"); |
fprintf(stderr, " -t: tcp port)\n"); |
2350 |
fprintf(stderr, " -a: connection colour depth\n"); |
fprintf(stderr, " -a: connection colour depth\n"); |
|
|
|
2351 |
fprintf(stderr, " -u: user name\n"); |
fprintf(stderr, " -u: user name\n"); |
2352 |
fprintf(stderr, " -d: domain\n"); |
fprintf(stderr, " -d: domain\n"); |
2353 |
fprintf(stderr, " -s: shell\n"); |
fprintf(stderr, " -s: shell\n"); |
2354 |
fprintf(stderr, " -c: working directory\n"); |
fprintf(stderr, " -c: working directory\n"); |
2355 |
fprintf(stderr, " -p: password (- to prompt)\n"); |
fprintf(stderr, " -p: password (- to prompt)\n"); |
2356 |
fprintf(stderr, " -n: client hostname\n"); |
fprintf(stderr, " -n: client hostname\n"); |
2357 |
|
fprintf(stderr, " -f: full screen\n"); |
2358 |
|
fprintf(stderr, " -r sound: enable sound\n"); |
2359 |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
2360 |
} |
} |
2361 |
|
|
2376 |
else if (strcmp(in_argv[i], "-g") == 0) |
else if (strcmp(in_argv[i], "-g") == 0) |
2377 |
{ |
{ |
2378 |
g_width = strtol(in_argv[i + 1], &p, 10); |
g_width = strtol(in_argv[i + 1], &p, 10); |
2379 |
if (g_width <= 0) |
if (*p == 'x') |
2380 |
{ |
{ |
2381 |
error("invalid geometry\n"); |
g_height = strtol(p + 1, &p, 10); |
2382 |
return 0; |
} |
2383 |
|
if (*p == '-') |
2384 |
|
{ |
2385 |
|
g_client_width = strtol(p + 1, &p, 10); |
2386 |
|
} |
2387 |
|
else |
2388 |
|
{ |
2389 |
|
g_client_width = g_width; |
2390 |
|
g_client_height = g_height; |
2391 |
} |
} |
2392 |
if (*p == 'x') |
if (*p == 'x') |
|
g_height = strtol(p + 1, NULL, 10); |
|
|
if (g_height <= 0) |
|
2393 |
{ |
{ |
2394 |
error("invalid geometry\n"); |
g_client_height = strtol(p + 1, NULL, 10); |
|
return 0; |
|
2395 |
} |
} |
2396 |
g_width = (g_width + 3) & ~3; |
g_width = (g_width + 3) & ~3; |
2397 |
|
g_height = (g_height + 3) & ~3; |
2398 |
|
g_client_width = (g_client_width + 3) & ~3; |
2399 |
|
g_client_height = (g_client_height + 3) & ~3; |
2400 |
|
i++; |
2401 |
} |
} |
2402 |
else if (strcmp(in_argv[i], "-4") == 0) |
else if (strcmp(in_argv[i], "-4") == 0) |
2403 |
|
{ |
2404 |
g_use_rdp5 = 0; |
g_use_rdp5 = 0; |
2405 |
|
} |
2406 |
else if (strcmp(in_argv[i], "-5") == 0) |
else if (strcmp(in_argv[i], "-5") == 0) |
2407 |
|
{ |
2408 |
g_use_rdp5 = 1; |
g_use_rdp5 = 1; |
2409 |
|
} |
2410 |
else if (strcmp(in_argv[i], "-a") == 0) |
else if (strcmp(in_argv[i], "-a") == 0) |
2411 |
{ |
{ |
2412 |
g_server_bpp = strtol(in_argv[i + 1], &p, 10); |
g_server_bpp = strtol(in_argv[i + 1], &p, 10); |
2413 |
if (g_server_bpp != 8 && g_server_bpp != 15 && |
if (g_server_bpp != 8 && |
2414 |
g_server_bpp != 16 && g_server_bpp != 24) |
g_server_bpp != 16 && g_server_bpp != 24) |
2415 |
{ |
{ |
2416 |
error("invalid bpp\n"); |
error("invalid bpp\n"); |
2417 |
return 0; |
return 0; |
2418 |
} |
} |
2419 |
|
i++; |
2420 |
} |
} |
2421 |
else if (strcmp(in_argv[i], "-t") == 0) |
else if (strcmp(in_argv[i], "-t") == 0) |
2422 |
|
{ |
2423 |
g_tcp_port_rdp = strtol(in_argv[i + 1], &p, 10); |
g_tcp_port_rdp = strtol(in_argv[i + 1], &p, 10); |
2424 |
|
i++; |
2425 |
|
} |
2426 |
else if (strcmp(in_argv[i], "-u") == 0) |
else if (strcmp(in_argv[i], "-u") == 0) |
2427 |
{ |
{ |
2428 |
STRNCPY(g_username, in_argv[i + 1], sizeof(g_username)); |
STRNCPY(g_username, in_argv[i + 1], sizeof(g_username)); |
2429 |
|
i++; |
2430 |
} |
} |
2431 |
else if (strcmp(in_argv[i], "-d") == 0) |
else if (strcmp(in_argv[i], "-d") == 0) |
2432 |
{ |
{ |
2433 |
STRNCPY(g_domain, in_argv[i + 1], sizeof(g_domain)); |
STRNCPY(g_domain, in_argv[i + 1], sizeof(g_domain)); |
2434 |
|
i++; |
2435 |
} |
} |
2436 |
else if (strcmp(in_argv[i], "-s") == 0) |
else if (strcmp(in_argv[i], "-s") == 0) |
2437 |
{ |
{ |
2438 |
STRNCPY(g_shell, in_argv[i + 1], sizeof(g_shell)); |
STRNCPY(g_shell, in_argv[i + 1], sizeof(g_shell)); |
2439 |
|
i++; |
2440 |
} |
} |
2441 |
else if (strcmp(in_argv[i], "-c") == 0) |
else if (strcmp(in_argv[i], "-c") == 0) |
2442 |
{ |
{ |
2443 |
STRNCPY(g_directory, in_argv[i + 1], sizeof(g_directory)); |
STRNCPY(g_directory, in_argv[i + 1], sizeof(g_directory)); |
2444 |
|
i++; |
2445 |
} |
} |
2446 |
else if (strcmp(in_argv[i], "-p") == 0) |
else if (strcmp(in_argv[i], "-p") == 0) |
2447 |
{ |
{ |
2448 |
STRNCPY(g_password, in_argv[i + 1], sizeof(g_password)); |
STRNCPY(g_password, in_argv[i + 1], sizeof(g_password)); |
2449 |
g_flags |= RDP_LOGON_AUTO; |
g_flags |= RDP_LOGON_AUTO; |
2450 |
|
i++; |
2451 |
} |
} |
2452 |
else if (strcmp(in_argv[i], "-n") == 0) |
else if (strcmp(in_argv[i], "-n") == 0) |
2453 |
{ |
{ |
2454 |
STRNCPY(g_hostname, in_argv[i + 1], sizeof(g_hostname)); |
STRNCPY(g_hostname, in_argv[i + 1], sizeof(g_hostname)); |
2455 |
|
i++; |
2456 |
|
} |
2457 |
|
else if (strcmp(in_argv[i], "-f") == 0) |
2458 |
|
{ |
2459 |
|
g_fullscreen = 1; |
2460 |
|
} |
2461 |
|
else if (strcmp(in_argv[i], "-r") == 0) |
2462 |
|
{ |
2463 |
|
if (strcmp(in_argv[i + 1], "sound") == 0) |
2464 |
|
{ |
2465 |
|
#ifdef WITH_RDPSND |
2466 |
|
g_rdpsnd = 1; |
2467 |
|
#endif |
2468 |
|
} |
2469 |
|
i++; |
2470 |
} |
} |
2471 |
} |
} |
2472 |
return 1; |
return 1; |
2473 |
} |
} |
2474 |
|
|
2475 |
//***************************************************************************** |
/******************************************************************************/ |
2476 |
int param_connect(void) |
int param_connect(void) |
2477 |
{ |
{ |
2478 |
QWidget * Desktop; |
QWidget * Desktop; |
2479 |
int dw, dh; |
int dw, dh; |
2480 |
|
|
2481 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
2482 |
rdpsnd_init(); |
// init sound |
2483 |
|
if (g_rdpsnd) |
2484 |
|
{ |
2485 |
|
rdpsnd_init(); |
2486 |
|
} |
2487 |
#endif |
#endif |
2488 |
if (rdp_connect(g_server, g_flags, g_domain, g_password, g_shell, |
if (rdp_connect(g_server, g_flags, g_domain, g_password, g_shell, |
2489 |
g_directory)) |
g_directory)) |
2498 |
memset(g_CM, 0, sizeof(struct QColorMap)); |
memset(g_CM, 0, sizeof(struct QColorMap)); |
2499 |
g_CM->NumColors = 256; |
g_CM->NumColors = 256; |
2500 |
g_MW = new QMyMainWindow(); |
g_MW = new QMyMainWindow(); |
2501 |
g_MW->resize(g_width, g_height); |
g_MW->resize(g_client_width, g_client_height); |
2502 |
g_MW->show(); |
g_MW->show(); |
2503 |
g_SV->addChild(g_MW); |
g_SV->addChild(g_MW); |
2504 |
g_MW->setMouseTracking(true); |
g_MW->setMouseTracking(true); |
2512 |
Desktop = g_App->desktop(); |
Desktop = g_App->desktop(); |
2513 |
dw = Desktop->width(); |
dw = Desktop->width(); |
2514 |
dh = Desktop->height(); |
dh = Desktop->height(); |
2515 |
if (dw == g_width && dh == g_height) |
if (dw == g_client_width && dh == g_client_height) |
2516 |
g_MW->resize(g_width - 4, g_height - 4); |
{ |
2517 |
|
g_MW->resize(g_client_width - 4, g_client_height - 4); |
2518 |
|
} |
2519 |
g_SV->showFullScreen(); |
g_SV->showFullScreen(); |
2520 |
} |
} |
2521 |
g_MW->setCursor(BlankCursor); |
g_MW->setCursor((int)10); /* Qt::BlankCursor */ |
2522 |
g_App->exec(); |
g_App->exec(); |
2523 |
} |
} |
2524 |
return 0; |
return 0; |
2525 |
} |
} |
2526 |
|
|
2527 |
//***************************************************************************** |
/******************************************************************************/ |
2528 |
int main(int argc, char ** argv) |
int main(int argc, char ** argv) |
2529 |
{ |
{ |
2530 |
#ifdef SHARP |
#ifdef SHARP |
2531 |
g_App = new QPEApplication(argc, argv); |
g_App = new QPEApplication(argc, argv); |
2532 |
#else |
#else |
2533 |
g_App = new QApplication(argc, argv, QApplication::GuiServer); |
g_App = new QApplication(argc, argv, QApplication::GuiServer); |
2534 |
|
//g_App = new QApplication(argc, argv); |
2535 |
#endif |
#endif |
2536 |
g_SV = new QMyScrollView(); |
g_SV = new QMyScrollView(); |
2537 |
g_App->setMainWidget(g_SV); |
g_App->setMainWidget(g_SV); |
2540 |
{ |
{ |
2541 |
get_username_and_hostname(); |
get_username_and_hostname(); |
2542 |
if (parse_parameters(argc, argv)) |
if (parse_parameters(argc, argv)) |
2543 |
|
{ |
2544 |
param_connect(); |
param_connect(); |
2545 |
|
} |
2546 |
} |
} |
2547 |
else |
else |
2548 |
{ |
{ |
2549 |
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(BlankCursor); |
|
2550 |
g_App->exec(); |
g_App->exec(); |
2551 |
} |
} |
2552 |
delete g_SV; |
delete g_SV; |