1 |
/* |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
User interface services - X Window System |
User interface services - 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 |
47 |
|
#include <pwd.h> // getpwuid |
48 |
|
|
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]; |
|
|
int NumColors; |
|
|
}; |
|
53 |
|
|
54 |
struct bitmap |
extern int g_tcp_port_rdp; |
|
{ |
|
|
int w; |
|
|
int h; |
|
|
uint8* data; |
|
|
}; |
|
|
|
|
|
uint32 g_flags = 0; |
|
|
char g_server[64] = ""; |
|
|
char g_domain[16] = ""; |
|
|
char g_password[16] = ""; |
|
|
char g_shell[128] = ""; |
|
|
char g_directory[32] = ""; |
|
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; |
|
int g_fullscreen = 0; |
|
73 |
char g_hostname[16] = ""; |
char g_hostname[16] = ""; |
74 |
char g_username[100] = ""; |
char g_username[100] = ""; |
|
int g_global_sock = 0; |
|
75 |
|
|
76 |
int g_deactivated = 0; |
#ifdef WITH_RDPSND |
77 |
uint32 g_ext_disc_reason = 0; |
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 |
QSocketNotifier* g_SocketNotifier = 0; |
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; |
100 |
|
static char g_server[64] = ""; |
101 |
|
static char g_domain[16] = ""; |
102 |
|
static char g_password[16] = ""; |
103 |
|
static char g_shell[128] = ""; |
104 |
|
static char g_directory[32] = ""; |
105 |
|
static int g_fullscreen = 0; |
106 |
|
static int g_global_sock = 0; |
107 |
|
static int g_deactivated = 0; |
108 |
|
static uint32 g_ext_disc_reason = 0; |
109 |
|
|
110 |
|
static QSocketNotifier * g_SocketNotifier = 0; |
111 |
#ifdef SHARP |
#ifdef SHARP |
112 |
QPEApplication* g_App = 0; |
static QPEApplication * g_App = 0; |
113 |
#else |
#else |
114 |
QApplication* g_App = 0; |
static QApplication * g_App = 0; |
115 |
#endif |
#endif |
116 |
static QMyMainWindow *g_MW = 0; |
static QMyMainWindow * g_MW = 0; |
117 |
static QMyScrollView *g_SV = 0; |
static QMyScrollView * g_SV = 0; |
118 |
static struct QColorMap *g_CM = 0; |
static struct QColorMap * g_CM = 0; |
119 |
static uint8 *g_BS = 0; |
static uint8 * g_BS = 0; /* the screen data */ |
|
|
|
120 |
static int g_clipx = 0; |
static int g_clipx = 0; |
121 |
static int g_clipy = 0; |
static int g_clipy = 0; |
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 |
void CleanString(QString* Item) |
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) |
135 |
|
#define GETPIXEL8(d, x, y, w) (*(((uint8*)d) + ((y) * (w) + (x)))) |
136 |
|
#define GETPIXEL16(d, x, y, w) (*(((uint16*)d) + ((y) * (w) + (x)))) |
137 |
|
#define GETPIXEL32(d, x, y, w) (*(((uint32*)d) + ((y) * (w) + (x)))) |
138 |
|
#define SETPIXEL8(d, x, y, w, v) *(((uint8*)d) + ((y) * (w) + (x))) = v |
139 |
|
#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 |
141 |
|
|
142 |
|
/******************************************************************************/ |
143 |
|
void CleanString(QString * Item) |
144 |
{ |
{ |
145 |
int i; |
int i; |
146 |
|
|
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; |
162 |
char* home; |
char * home; |
163 |
char Text[256]; |
char Text[256]; |
164 |
QString Line; |
QString Line; |
165 |
QString ItemName; |
QString ItemName; |
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; |
364 |
QMyConnectionItem* Item; |
QMyConnectionItem * Item; |
365 |
|
|
366 |
i = ListBox->count(); |
i = ListBox->count(); |
367 |
if (i < 10) |
if (i < 10) |
377 |
} |
} |
378 |
} |
} |
379 |
|
|
380 |
//***************************************************************************** |
/******************************************************************************/ |
381 |
void QMyDialog::EditClicked() |
void QMyDialog::EditClicked() |
382 |
{ |
{ |
383 |
int i; |
int i; |
384 |
QMyConnectionItem* Item; |
QMyConnectionItem * Item; |
385 |
|
|
386 |
i = ListBox->currentItem(); |
i = ListBox->currentItem(); |
387 |
if (i >= 0) |
if (i >= 0) |
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; |
410 |
QMyConnectionItem* Item; |
QMyConnectionItem * Item; |
411 |
QString Line; |
QString Line; |
412 |
char* home; |
char * home; |
413 |
char Text[256]; |
char Text[256]; |
414 |
QFile* File; |
QFile* File; |
415 |
|
|
461 |
} |
} |
462 |
} |
} |
463 |
|
|
464 |
//***************************************************************************** |
/******************************************************************************/ |
465 |
void QMyDialog::RemoveClicked() |
void QMyDialog::RemoveClicked() |
466 |
{ |
{ |
467 |
int i, j, c; |
int i, j, c; |
468 |
QMyConnectionItem* Item1; |
QMyConnectionItem * Item1; |
469 |
QMyConnectionItem* Item2; |
QMyConnectionItem * Item2; |
470 |
|
|
471 |
i = ListBox->currentItem(); |
i = ListBox->currentItem(); |
472 |
if (i >= 0) |
if (i >= 0) |
487 |
} |
} |
488 |
} |
} |
489 |
|
|
490 |
//***************************************************************************** |
/******************************************************************************/ |
491 |
void QMyDialog::ListBoxChanged() |
void QMyDialog::ListBoxChanged() |
492 |
{ |
{ |
493 |
int i; |
int i; |
494 |
QMyConnectionItem* Item; |
QMyConnectionItem * Item; |
495 |
char Text[100]; |
char Text[100]; |
496 |
|
|
497 |
i = ListBox->currentItem(); |
i = ListBox->currentItem(); |
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; |
521 |
int mod; |
int mod; |
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 |
{ |
{ |
752 |
QScrollView::timerEvent(e); |
QMyDialog * d; |
753 |
killTimer(timer_id); |
QWidget * Desktop; |
|
QMyDialog* d; |
|
|
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 |
{ |
{ |
|
g_flags = RDP_LOGON_NORMAL; |
|
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 |
{ |
{ |
780 |
g_SV->close(); |
g_SV->close(); |
781 |
return; |
return; |
782 |
} |
} |
783 |
g_BS = (uint8*)xmalloc(g_width * g_height); |
g_BS = (uint8*)xmalloc(g_width * g_height * 4); |
784 |
memset(g_BS, 0, g_width * g_height); |
memset(g_BS, 0, g_width * g_height * 4); |
785 |
g_clipx = 0; |
g_clipx = 0; |
786 |
g_clipy = 0; |
g_clipy = 0; |
787 |
g_clipcx = g_width; |
g_clipcx = g_width; |
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 |
void QMyMainWindow::timerEvent(QTimerEvent* e) |
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) |
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; |
890 |
int dw; |
int dw; |
891 |
int dh; |
int dh; |
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) (255-(x)) |
#define NOT(x) (~x) |
1004 |
|
|
1005 |
//***************************************************************************** |
/******************************************************************************/ |
1006 |
uint8 rop(int rop, uint8 src, uint8 dst) |
int rop(int rop, int src, int dst) |
1007 |
{ |
{ |
1008 |
switch (rop) |
switch (rop) |
1009 |
{ |
{ |
1028 |
} |
} |
1029 |
|
|
1030 |
/*****************************************************************************/ |
/*****************************************************************************/ |
1031 |
uint8 get_pixel(int x, int y) |
int get_pixel(int x, int y) |
1032 |
{ |
{ |
1033 |
if (x >= 0 && x < g_width && y >= 0 && y < g_height) |
if (x >= 0 && x < g_width && y >= 0 && y < g_height) |
1034 |
return g_BS[y * g_width + x]; |
{ |
1035 |
|
if (g_server_bpp == 8) |
1036 |
|
return GETPIXEL8(g_BS, x, y, g_width); |
1037 |
|
else if (g_server_bpp == 16) |
1038 |
|
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 |
1042 |
|
return 0; |
1043 |
|
} |
1044 |
else |
else |
1045 |
return 0; |
return 0; |
1046 |
} |
} |
1047 |
|
|
1048 |
//***************************************************************************** |
/******************************************************************************/ |
1049 |
void set_pixel(int x, int y, uint8 pixel, int op = 0xc) |
void set_pixel(int x, int y, int pixel, int op = 0xc) |
1050 |
{ |
{ |
1051 |
|
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)) |
1055 |
|
{ |
1056 |
if (x >= 0 && x < g_width && y >= 0 && y < g_height) |
if (x >= 0 && x < g_width && y >= 0 && y < g_height) |
1057 |
|
{ |
1058 |
if (op == 0xc) |
if (op == 0xc) |
1059 |
g_BS[y * g_width + x] = pixel; |
{ |
1060 |
|
if (g_server_bpp == 8) |
1061 |
|
{ |
1062 |
|
SETPIXEL8(g_BS, x, y, g_width, pixel); |
1063 |
|
} |
1064 |
|
else if (g_server_bpp == 16) |
1065 |
|
{ |
1066 |
|
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 |
g_BS[y * g_width + x] = rop(op, pixel, g_BS[y * g_width + x]); |
{ |
1075 |
|
if (g_server_bpp == 8) |
1076 |
|
{ |
1077 |
|
p = GETPIXEL8(g_BS, x, y, g_width); |
1078 |
|
p = rop(op, pixel, p); |
1079 |
|
SETPIXEL8(g_BS, x, y, g_width, p); |
1080 |
|
} |
1081 |
|
else if (g_server_bpp == 16) |
1082 |
|
{ |
1083 |
|
p = GETPIXEL16(g_BS, x, y, g_width); |
1084 |
|
p = rop(op, pixel, p); |
1085 |
|
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 |
{ |
{ |
1102 |
int dx, dy; |
int dx, dy; |
1103 |
QRect InRect(*x, *y, *cx, *cy); |
QRect InRect(*x, *y, *cx, *cy); |
1119 |
return true; |
return true; |
1120 |
} |
} |
1121 |
|
|
1122 |
//***************************************************************************** |
/******************************************************************************/ |
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; |
1133 |
|
data = 0; |
1134 |
if (!testWFlags(WRepaintNoErase)) |
if (!testWFlags(WRepaintNoErase)) |
1135 |
setWFlags(WRepaintNoErase); |
setWFlags(WRepaintNoErase); |
1136 |
if (g_CM != NULL) |
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 && g_CM->NumColors > 0) |
if (w > 0 && h > 0) |
1146 |
{ |
{ |
1147 |
w = (w + 3) & ~3; |
if (g_server_bpp == 8 && g_CM->NumColors > 0) |
1148 |
data = (uint8*)xmalloc(w * h); |
{ |
1149 |
for (i = 0; i < h; i++) |
w = (w + 3) & ~3; |
1150 |
for (j = 0; j < w; j++) |
data = (uint8*)xmalloc(w * h); |
1151 |
data[i * w + j] = get_pixel(l + j, t + i); |
for (i = 0; i < h; i++) |
1152 |
Image = new QImage(data, w, h, 8,(QRgb*)g_CM->RGBColors, |
for (j = 0; j < w; j++) |
1153 |
g_CM->NumColors, QImage::IgnoreEndian); |
data[i * w + j] = GETPIXEL8(g_BS, l + j, t + i, g_width); |
1154 |
Painter = new QPainter(this); |
Image = new QImage(data, w, h, 8,(QRgb*)g_CM->RGBColors, |
1155 |
Painter->drawImage(l, t, *Image, 0, 0, w, h); |
g_CM->NumColors, QImage::IgnoreEndian); |
1156 |
|
} |
1157 |
|
else if (g_server_bpp == 16) |
1158 |
|
{ |
1159 |
|
w = (w + 3) & ~3; |
1160 |
|
data = (uint8*)xmalloc(w * h * 4); |
1161 |
|
for (i = 0; i < h; i++) |
1162 |
|
for (j = 0; j < w; j++) |
1163 |
|
{ |
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, |
1189 |
|
0, QImage::IgnoreEndian); |
1190 |
|
} |
1191 |
|
if (Image != 0) |
1192 |
|
{ |
1193 |
|
Painter = new QPainter(this); |
1194 |
|
Painter->scale(sx, sy); |
1195 |
|
Painter->drawImage(l, t, *Image, 0, 0, w, h); |
1196 |
|
delete Painter; |
1197 |
|
delete Image; |
1198 |
|
} |
1199 |
xfree(data); |
xfree(data); |
|
delete Painter; |
|
|
delete Image; |
|
1200 |
} |
} |
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)) |
1214 |
g_SV->close(); |
g_SV->close(); |
1215 |
|
#ifdef WITH_RDPSND |
1216 |
|
if (g_dsp_busy) |
1217 |
|
{ |
1218 |
|
if (g_SoundNotifier == 0) |
1219 |
|
{ |
1220 |
|
g_SoundNotifier = new QSocketNotifier(g_dsp_fd, QSocketNotifier::Write, |
1221 |
|
g_MW); |
1222 |
|
g_MW->connect(g_SoundNotifier, SIGNAL(activated(int)), g_MW, |
1223 |
|
SLOT(soundSend())); |
1224 |
|
} |
1225 |
|
else |
1226 |
|
{ |
1227 |
|
if (!g_SoundNotifier->isEnabled()) |
1228 |
|
g_SoundNotifier->setEnabled(true); |
1229 |
|
} |
1230 |
|
} |
1231 |
|
#endif |
1232 |
} |
} |
1233 |
|
|
1234 |
//***************************************************************************** |
/******************************************************************************/ |
1235 |
|
void QMyMainWindow::soundSend() |
1236 |
|
{ |
1237 |
|
#ifdef WITH_RDPSND |
1238 |
|
g_SoundNotifier->setEnabled(false); |
1239 |
|
wave_out_play(); |
1240 |
|
if (g_dsp_busy) |
1241 |
|
{ |
1242 |
|
g_SoundNotifier->setEnabled(true); |
1243 |
|
} |
1244 |
|
#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 |
{ |
{ |
1268 |
g_global_sock = rdp_socket; |
if (g_global_sock == 0) |
1269 |
|
g_global_sock = rdp_socket; |
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); |
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; |
1295 |
the_bitmap->data = bitmap_data; |
the_bitmap->data = bitmap_data; |
1296 |
for (i = 0; i < height; i++) |
if (g_server_bpp == 8) |
1297 |
for (j = 0; j < width; j++) |
{ |
1298 |
bitmap_data[i * width + j] = data[i * width + j]; |
for (i = 0; i < height; i++) |
1299 |
|
for (j = 0; j < width; j++) |
1300 |
|
bitmap_data[i * width + j] = data[i * width + j]; |
1301 |
|
} |
1302 |
|
else if (g_server_bpp == 16) |
1303 |
|
{ |
1304 |
|
for (i = 0; i < height; i++) |
1305 |
|
for (j = 0; j < width; j++) |
1306 |
|
*(((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 |
for (i = 0; i < cy; i++) |
if (g_server_bpp == 8) |
1332 |
for (j = 0; j < cx; j++) |
{ |
1333 |
if (i < height) |
for (i = 0; i < cy; i++) |
1334 |
if (j < width) |
for (j = 0; j < cx; j++) |
1335 |
set_pixel(x + j, y + i, data[i * width + j]); |
if (i < height) |
1336 |
|
if (j < width) |
1337 |
|
set_pixel(x + j, y + i, data[i * width + j]); |
1338 |
|
} |
1339 |
|
else if (g_server_bpp == 16) |
1340 |
|
{ |
1341 |
|
for (i = 0; i < cy; i++) |
1342 |
|
for (j = 0; j < cx; j++) |
1343 |
|
if (i < height) |
1344 |
|
if (j < width) |
1345 |
|
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(unsigned int x, unsigned int y, |
HCURSOR ui_create_cursor(uint32 x, uint32 y, |
1439 |
int width, int height, uint8 * andmask, |
int width, int height, |
1440 |
uint8 * xormask) |
uint8 * andmask, uint8 * xormask) |
1441 |
{ |
{ |
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 |
} |
} |
1449 |
|
|
1450 |
/*****************************************************************************/ |
/*****************************************************************************/ |
1451 |
uint16 ui_get_numlock_state(unsigned int state) |
uint16 ui_get_numlock_state(uint32 state) |
1452 |
{ |
{ |
1453 |
return 0; |
return 0; |
1454 |
} |
} |
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_destroy_colourmap(HCOLOURMAP /*map*/) |
void ui_set_colourmap(HCOLOURMAP map) |
1528 |
{ |
{ |
1529 |
} |
} |
1530 |
|
|
1531 |
//***************************************************************************** |
/******************************************************************************/ |
1532 |
void ui_set_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 |
{ |
{ |
1601 |
int i, j; |
int i, j; |
1602 |
|
|
1603 |
for (i = 0; i < cy; i++) |
if (x + cx > g_width) |
1604 |
for (j = 0; j < cx; j++) |
cx = g_width - x; |
1605 |
set_pixel(x + j, y + i, colour, opcode); |
if (y + cy > g_height) |
1606 |
|
cy = g_height - y; |
1607 |
|
#ifdef QT_OPTI |
1608 |
|
if (opcode == 0xc) /* optimize */ |
1609 |
|
{ |
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); |
temp = (uint8*)xmalloc(cx * cy * 4); |
1683 |
for (i = 0; i < cy; i++) |
#ifdef QT_OPTI |
1684 |
for (j = 0; j < cx; j++) |
if (opcode == 0xc) |
1685 |
temp[i * cx + j] = get_pixel(srcx + j, srcy + i); |
{ |
1686 |
for (i = 0; i < cy; i++) |
if (WarpCoords(&x, &y, &cx, &cy, &srcx, &srcy)) |
1687 |
for (j = 0; j < cx; j++) |
{ |
1688 |
set_pixel(x + j, y + i, temp[i * cx + j], opcode); |
if (g_server_bpp == 8) |
1689 |
|
{ |
1690 |
|
for (i = 0; i < cy; i++) |
1691 |
|
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 |
1736 |
|
#endif |
1737 |
|
{ |
1738 |
|
if (g_server_bpp == 8) |
1739 |
|
{ |
1740 |
|
for (i = 0; i < cy; i++) |
1741 |
|
for (j = 0; j < cx; j++) |
1742 |
|
temp[i * cx + j] = get_pixel(srcx + j, srcy + i); |
1743 |
|
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 |
for (i = 0; i < cy; i++) |
#ifdef QT_OPTI |
1787 |
for (j = 0; j < cx; j++) |
if (opcode == 0xc) /* optimize */ |
1788 |
if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w) |
{ |
1789 |
set_pixel(x + j, y + i, |
if (WarpCoords(&x, &y, &cx, &cy, &srcx, &srcy)) |
1790 |
the_bitmap->data[(i + srcy) * the_bitmap->w + (j + srcx)], |
{ |
1791 |
opcode); |
if (g_server_bpp == 8) |
1792 |
|
{ |
1793 |
|
for (i = 0; i < cy; i++) |
1794 |
|
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 |
1821 |
|
#endif |
1822 |
|
{ |
1823 |
|
if (g_server_bpp == 8) |
1824 |
|
{ |
1825 |
|
for (i = 0; i < cy; i++) |
1826 |
|
for (j = 0; j < cx; j++) |
1827 |
|
if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w) |
1828 |
|
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; |
1946 |
int i, j; |
int i, j; |
1947 |
|
|
1948 |
the_glyph = (struct bitmap*)glyph; |
the_glyph = (struct bitmap*)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 = 4; |
2071 |
for (i = 0; i < cy; i++) |
switch (g_server_bpp) |
2072 |
for (j = 0; j < cx; j++) |
{ |
2073 |
data[i * cx + j] = get_pixel(x + j, y + i); |
case 8: Bpp = 1; break; |
2074 |
cache_put_desktop(offset, cx, cy, cx, 1, data); |
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) |
2079 |
|
{ |
2080 |
|
for (i = 0; i < cy; i++) |
2081 |
|
for (j = 0; j < cx; j++) |
2082 |
|
{ |
2083 |
|
pixel = get_pixel(x + j, y + i); |
2084 |
|
SETPIXEL8(data, j, i, cx, pixel); |
2085 |
|
} |
2086 |
|
} |
2087 |
|
else if (g_server_bpp == 16) |
2088 |
|
{ |
2089 |
|
for (i = 0; i < cy; i++) |
2090 |
|
for (j = 0; j < cx; j++) |
2091 |
|
{ |
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; |
2103 |
|
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 |
data = cache_get_desktop(offset, cx, cy, 1); |
Bpp = 4; |
2115 |
for (i = 0; i < cy; i++) |
switch (g_server_bpp) |
2116 |
for (j = 0; j < cx; j++) |
{ |
2117 |
set_pixel(x + j, y + i, data[i * cx + j]); |
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) |
2124 |
|
{ |
2125 |
|
for (i = 0; i < cy; i++) |
2126 |
|
for (j = 0; j < cx; j++) |
2127 |
|
set_pixel(x + j, y + i, data[i * cx + j]); |
2128 |
|
} |
2129 |
|
else if (g_server_bpp == 16) |
2130 |
|
{ |
2131 |
|
for (i = 0; i < cy; i++) |
2132 |
|
for (j = 0; j < cx; j++) |
2133 |
|
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) |
2148 |
|
{ |
2149 |
|
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 |
} |
} |
2159 |
|
|
2160 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2161 |
void xfree(void* in_val) |
void xfree(void * in_val) |
2162 |
{ |
{ |
2163 |
free(in_val); |
if (in_val != NULL) |
2164 |
|
{ |
2165 |
|
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 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2182 |
void warning(char* format, ...) |
void warning(char * format, ...) |
2183 |
{ |
{ |
2184 |
va_list ap; |
va_list ap; |
2185 |
|
|
2190 |
} |
} |
2191 |
|
|
2192 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2193 |
void unimpl(char* format, ...) |
void unimpl(char * format, ...) |
2194 |
{ |
{ |
2195 |
va_list ap; |
va_list ap; |
2196 |
|
|
2201 |
} |
} |
2202 |
|
|
2203 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2204 |
void error(char* format, ...) |
void error(char * format, ...) |
2205 |
{ |
{ |
2206 |
va_list ap; |
va_list ap; |
2207 |
|
|
2218 |
} |
} |
2219 |
|
|
2220 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2221 |
int rd_open_file(char *filename) |
int rd_open_file(char * filename) |
2222 |
{ |
{ |
2223 |
return 0; |
return 0; |
2224 |
} |
} |
2230 |
} |
} |
2231 |
|
|
2232 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2233 |
int rd_read_file(int fd, void *ptr, int len) |
int rd_read_file(int fd, void * ptr, int len) |
2234 |
{ |
{ |
2235 |
return 0; |
return 0; |
2236 |
} |
} |
2237 |
|
|
2238 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2239 |
int rd_write_file(int fd, void* ptr, int len) |
int rd_write_file(int fd, void * ptr, int len) |
2240 |
{ |
{ |
2241 |
return 0; |
return 0; |
2242 |
} |
} |
2254 |
} |
} |
2255 |
|
|
2256 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2257 |
void save_licence(uint8* data, int length) |
int load_licence(uint8 ** data) |
2258 |
{ |
{ |
2259 |
|
return 0; |
2260 |
} |
} |
2261 |
|
|
2262 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2263 |
void generate_random(uint8* random) |
void save_licence(uint8 * data, int length) |
2264 |
|
{ |
2265 |
|
} |
2266 |
|
|
2267 |
|
/*****************************************************************************/ |
2268 |
|
void generate_random(uint8 * random) |
2269 |
{ |
{ |
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 |
} |
} |
2279 |
|
|
2280 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2281 |
int load_licence(uint8** data) |
/* produce a hex dump */ |
2282 |
|
void hexdump(uint8 * p, uint32 len) |
2283 |
{ |
{ |
2284 |
|
uint8 * line = p; |
2285 |
|
int i, thisline; |
2286 |
|
uint32 offset = 0; |
2287 |
|
|
2288 |
|
while (offset < len) |
2289 |
|
{ |
2290 |
|
printf("%04x ", offset); |
2291 |
|
thisline = len - offset; |
2292 |
|
if (thisline > 16) |
2293 |
|
{ |
2294 |
|
thisline = 16; |
2295 |
|
} |
2296 |
|
for (i = 0; i < thisline; i++) |
2297 |
|
{ |
2298 |
|
printf("%02x ", line[i]); |
2299 |
|
} |
2300 |
|
for (; i < 16; i++) |
2301 |
|
{ |
2302 |
|
printf(" "); |
2303 |
|
} |
2304 |
|
for (i = 0; i < thisline; i++) |
2305 |
|
{ |
2306 |
|
printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.'); |
2307 |
|
} |
2308 |
|
printf("\n"); |
2309 |
|
offset += thisline; |
2310 |
|
line += thisline; |
2311 |
|
} |
2312 |
|
} |
2313 |
|
|
2314 |
|
/*****************************************************************************/ |
2315 |
|
void get_username_and_hostname(void) |
2316 |
|
{ |
2317 |
|
char fullhostname[64]; |
2318 |
|
char * p; |
2319 |
|
struct passwd * pw; |
2320 |
|
|
2321 |
|
STRNCPY(g_username, "unknown", sizeof(g_username)); |
2322 |
|
STRNCPY(g_hostname, "unknown", sizeof(g_hostname)); |
2323 |
|
pw = getpwuid(getuid()); |
2324 |
|
if (pw != NULL && pw->pw_name != NULL) |
2325 |
|
{ |
2326 |
|
STRNCPY(g_username, pw->pw_name, sizeof(g_username)); |
2327 |
|
} |
2328 |
|
if (gethostname(fullhostname, sizeof(fullhostname)) != -1) |
2329 |
|
{ |
2330 |
|
p = strchr(fullhostname, '.'); |
2331 |
|
if (p != NULL) |
2332 |
|
{ |
2333 |
|
*p = 0; |
2334 |
|
} |
2335 |
|
STRNCPY(g_hostname, fullhostname, sizeof(g_hostname)); |
2336 |
|
} |
2337 |
|
} |
2338 |
|
|
2339 |
|
/*****************************************************************************/ |
2340 |
|
void out_params(void) |
2341 |
|
{ |
2342 |
|
fprintf(stderr, "qterdesktop: A Remote Desktop Protocol client.\n"); |
2343 |
|
fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2004 Matt Chapman.\n"); |
2344 |
|
fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n"); |
2345 |
|
fprintf(stderr, "Usage: qterdesktop [options] server\n"); |
2346 |
|
fprintf(stderr, " -g: desktop geometry (WxH)\n"); |
2347 |
|
fprintf(stderr, " -4: use RDP version 4\n"); |
2348 |
|
fprintf(stderr, " -5: use RDP version 5 (default)\n"); |
2349 |
|
fprintf(stderr, " -t: tcp port)\n"); |
2350 |
|
fprintf(stderr, " -a: connection colour depth\n"); |
2351 |
|
fprintf(stderr, " -u: user name\n"); |
2352 |
|
fprintf(stderr, " -d: domain\n"); |
2353 |
|
fprintf(stderr, " -s: shell\n"); |
2354 |
|
fprintf(stderr, " -c: working directory\n"); |
2355 |
|
fprintf(stderr, " -p: password (- to prompt)\n"); |
2356 |
|
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"); |
2360 |
|
} |
2361 |
|
|
2362 |
|
/*****************************************************************************/ |
2363 |
|
int parse_parameters(int in_argc, char ** in_argv) |
2364 |
|
{ |
2365 |
|
int i; |
2366 |
|
char * p; |
2367 |
|
|
2368 |
|
for (i = 1; i < in_argc; i++) |
2369 |
|
{ |
2370 |
|
strcpy(g_server, in_argv[i]); |
2371 |
|
if (strcmp(in_argv[i], "-h") == 0) |
2372 |
|
{ |
2373 |
|
out_params(); |
2374 |
|
return 0; |
2375 |
|
} |
2376 |
|
else if (strcmp(in_argv[i], "-g") == 0) |
2377 |
|
{ |
2378 |
|
g_width = strtol(in_argv[i + 1], &p, 10); |
2379 |
|
if (*p == 'x') |
2380 |
|
{ |
2381 |
|
g_height = strtol(p + 1, &p, 10); |
2382 |
|
} |
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') |
2393 |
|
{ |
2394 |
|
g_client_height = strtol(p + 1, NULL, 10); |
2395 |
|
} |
2396 |
|
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) |
2403 |
|
{ |
2404 |
|
g_use_rdp5 = 0; |
2405 |
|
} |
2406 |
|
else if (strcmp(in_argv[i], "-5") == 0) |
2407 |
|
{ |
2408 |
|
g_use_rdp5 = 1; |
2409 |
|
} |
2410 |
|
else if (strcmp(in_argv[i], "-a") == 0) |
2411 |
|
{ |
2412 |
|
g_server_bpp = strtol(in_argv[i + 1], &p, 10); |
2413 |
|
if (g_server_bpp != 8 && |
2414 |
|
g_server_bpp != 16 && g_server_bpp != 24) |
2415 |
|
{ |
2416 |
|
error("invalid bpp\n"); |
2417 |
|
return 0; |
2418 |
|
} |
2419 |
|
i++; |
2420 |
|
} |
2421 |
|
else if (strcmp(in_argv[i], "-t") == 0) |
2422 |
|
{ |
2423 |
|
g_tcp_port_rdp = strtol(in_argv[i + 1], &p, 10); |
2424 |
|
i++; |
2425 |
|
} |
2426 |
|
else if (strcmp(in_argv[i], "-u") == 0) |
2427 |
|
{ |
2428 |
|
STRNCPY(g_username, in_argv[i + 1], sizeof(g_username)); |
2429 |
|
i++; |
2430 |
|
} |
2431 |
|
else if (strcmp(in_argv[i], "-d") == 0) |
2432 |
|
{ |
2433 |
|
STRNCPY(g_domain, in_argv[i + 1], sizeof(g_domain)); |
2434 |
|
i++; |
2435 |
|
} |
2436 |
|
else if (strcmp(in_argv[i], "-s") == 0) |
2437 |
|
{ |
2438 |
|
STRNCPY(g_shell, in_argv[i + 1], sizeof(g_shell)); |
2439 |
|
i++; |
2440 |
|
} |
2441 |
|
else if (strcmp(in_argv[i], "-c") == 0) |
2442 |
|
{ |
2443 |
|
STRNCPY(g_directory, in_argv[i + 1], sizeof(g_directory)); |
2444 |
|
i++; |
2445 |
|
} |
2446 |
|
else if (strcmp(in_argv[i], "-p") == 0) |
2447 |
|
{ |
2448 |
|
STRNCPY(g_password, in_argv[i + 1], sizeof(g_password)); |
2449 |
|
g_flags |= RDP_LOGON_AUTO; |
2450 |
|
i++; |
2451 |
|
} |
2452 |
|
else if (strcmp(in_argv[i], "-n") == 0) |
2453 |
|
{ |
2454 |
|
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; |
2473 |
|
} |
2474 |
|
|
2475 |
|
/******************************************************************************/ |
2476 |
|
int param_connect(void) |
2477 |
|
{ |
2478 |
|
QWidget * Desktop; |
2479 |
|
int dw, dh; |
2480 |
|
|
2481 |
|
#ifdef WITH_RDPSND |
2482 |
|
// init sound |
2483 |
|
if (g_rdpsnd) |
2484 |
|
{ |
2485 |
|
rdpsnd_init(); |
2486 |
|
} |
2487 |
|
#endif |
2488 |
|
if (rdp_connect(g_server, g_flags, g_domain, g_password, g_shell, |
2489 |
|
g_directory)) |
2490 |
|
{ |
2491 |
|
g_BS = (uint8*)xmalloc(g_width * g_height * 4); |
2492 |
|
memset(g_BS, 0, g_width * g_height * 4); |
2493 |
|
g_clipx = 0; |
2494 |
|
g_clipy = 0; |
2495 |
|
g_clipcx = g_width; |
2496 |
|
g_clipcy = g_height; |
2497 |
|
g_CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); |
2498 |
|
memset(g_CM, 0, sizeof(struct QColorMap)); |
2499 |
|
g_CM->NumColors = 256; |
2500 |
|
g_MW = new QMyMainWindow(); |
2501 |
|
g_MW->resize(g_client_width, g_client_height); |
2502 |
|
g_MW->show(); |
2503 |
|
g_SV->addChild(g_MW); |
2504 |
|
g_MW->setMouseTracking(true); |
2505 |
|
g_SocketNotifier = new QSocketNotifier(g_global_sock, |
2506 |
|
QSocketNotifier::Read, |
2507 |
|
g_MW); |
2508 |
|
g_MW->connect(g_SocketNotifier, SIGNAL(activated(int)), g_MW, |
2509 |
|
SLOT(dataReceived())); |
2510 |
|
if (g_fullscreen) |
2511 |
|
{ |
2512 |
|
Desktop = g_App->desktop(); |
2513 |
|
dw = Desktop->width(); |
2514 |
|
dh = Desktop->height(); |
2515 |
|
if (dw == g_client_width && dh == g_client_height) |
2516 |
|
{ |
2517 |
|
g_MW->resize(g_client_width - 4, g_client_height - 4); |
2518 |
|
} |
2519 |
|
g_SV->showFullScreen(); |
2520 |
|
} |
2521 |
|
g_MW->setCursor((int)10); /* Qt::BlankCursor */ |
2522 |
|
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 |
{ |
{ |
|
g_CM = NULL; |
|
|
g_BS = NULL; |
|
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); |
2538 |
g_SV->showMaximized(); |
g_SV->showMaximized(); |
2539 |
g_SV->timer_id = g_SV->startTimer(1000); |
if (argc > 1) |
2540 |
g_App->exec(); |
{ |
2541 |
|
get_username_and_hostname(); |
2542 |
|
if (parse_parameters(argc, argv)) |
2543 |
|
{ |
2544 |
|
param_connect(); |
2545 |
|
} |
2546 |
|
} |
2547 |
|
else |
2548 |
|
{ |
2549 |
|
g_SV->timer_id = g_SV->startTimer(1000); /* one sec delay, then dialog */ |
2550 |
|
g_App->exec(); |
2551 |
|
} |
2552 |
delete g_SV; |
delete g_SV; |
2553 |
delete g_App; |
delete g_App; |
2554 |
if (g_CM != NULL) |
xfree(g_CM); |
2555 |
xfree(g_CM); |
xfree(g_BS); |
|
if (g_BS !=NULL) |
|
|
xfree(g_BS); |
|
2556 |
return 0; |
return 0; |
2557 |
} |
} |