summaryrefslogtreecommitdiffstats
path: root/xrdp
diff options
context:
space:
mode:
Diffstat (limited to 'xrdp')
-rw-r--r--xrdp/Makefile4
-rw-r--r--xrdp/constants.h19
-rw-r--r--xrdp/makefile_win3256
-rw-r--r--xrdp/os_calls.c70
-rw-r--r--xrdp/xrdp.h19
-rw-r--r--xrdp/xrdp.ini20
-rw-r--r--xrdp/xrdp_bitmap.c72
-rw-r--r--xrdp/xrdp_cache.c2
-rw-r--r--xrdp/xrdp_file.c201
-rw-r--r--xrdp/xrdp_login_wnd.c614
-rw-r--r--xrdp/xrdp_painter.c14
-rw-r--r--xrdp/xrdp_process.c40
-rw-r--r--xrdp/xrdp_rdp.c27
-rw-r--r--xrdp/xrdp_tcp.c4
-rw-r--r--xrdp/xrdp_types.h53
-rw-r--r--xrdp/xrdp_wm.c540
16 files changed, 1353 insertions, 402 deletions
diff --git a/xrdp/Makefile b/xrdp/Makefile
index c6f5eafd..c26d1852 100644
--- a/xrdp/Makefile
+++ b/xrdp/Makefile
@@ -2,7 +2,9 @@
XRDPOBJ = xrdp.o os_calls.o xrdp_tcp.o xrdp_iso.o xrdp_mcs.o xrdp_sec.o \
xrdp_rdp.o xrdp_process.o xrdp_listen.o xrdp_orders.o \
xrdp_bitmap.o xrdp_wm.o xrdp_painter.o xrdp_list.o \
- xrdp_region.o xrdp_cache.o xrdp_font.o funcs.o
+ xrdp_region.o xrdp_cache.o xrdp_font.o funcs.o \
+ xrdp_login_wnd.o xrdp_file.o
+
#CFLAGS = -Wall -O2 -DXRDP_DEBUG
CFLAGS = -Wall -O2
LDFLAGS = -L /usr/gnu/lib
diff --git a/xrdp/constants.h b/xrdp/constants.h
index dd5ec02f..dd473ccc 100644
--- a/xrdp/constants.h
+++ b/xrdp/constants.h
@@ -414,8 +414,17 @@
#define BUTTON_STATE_DOWN 1
/* messages */
-#define WM_PAINT 3
-#define WM_KEYDOWN 15
-#define WM_KEYUP 16
-#define WM_MOUSEMOVE 100
-#define WM_LBUTTONUP 101
+#define WM_PAINT 3
+#define WM_KEYDOWN 15
+#define WM_KEYUP 16
+#define WM_MOUSEMOVE 100
+#define WM_LBUTTONUP 101
+#define WM_LBUTTONDOWN 102
+#define WM_RBUTTONUP 103
+#define WM_RBUTTONDOWN 104
+#define WM_BUTTON3UP 105
+#define WM_BUTTON3DOWN 106
+#define WM_BUTTON4UP 107
+#define WM_BUTTON4DOWN 108
+#define WM_BUTTON5UP 109
+#define WM_BUTTON5DOWN 110
diff --git a/xrdp/makefile_win32 b/xrdp/makefile_win32
index 37a76bdf..5f01cbba 100644
--- a/xrdp/makefile_win32
+++ b/xrdp/makefile_win32
@@ -1,28 +1,28 @@
-# borland windows makefile
-#
-# this assumes openssl and borland free command line tools are installed
-# this assumes c:\windows is windows directory
-#
-# run 'set PATH=c:\borland\bcc55\bin' and run 'make all'
-#
-
-XRDPOBJ = xrdp.obj os_calls.obj xrdp_tcp.obj xrdp_iso.obj xrdp_mcs.obj \
- xrdp_sec.obj xrdp_rdp.obj xrdp_process.obj xrdp_listen.obj \
- xrdp_orders.obj xrdp_bitmap.obj xrdp_wm.obj xrdp_painter.obj \
- xrdp_list.obj xrdp_region.obj xrdp_cache.obj xrdp_font.obj \
- funcs.obj
-
-CFLAGS = -w- -O2 -Ic:\borland\bcc55\include -Ic:\openssl\include
-LDFLAGS = -Lc:\borland\bcc55\lib
-
-xrdp: $(XRDPOBJ)
- $(CC) $(LDFLAGS) libeay32.lib $(XRDPOBJ)
-
-all: lib xrdp
-
-clean:
- del *.obj *.o xrdp.exe
-
-lib:
- implib -a -w libeay32.lib c:\windows\system32\libeay32.dll
-
+# borland windows makefile
+#
+# this assumes openssl and borland free command line tools are installed
+# this assumes c:\windows is windows directory
+#
+# run 'set PATH=c:\borland\bcc55\bin' and run 'make all'
+#
+
+XRDPOBJ = xrdp.obj os_calls.obj xrdp_tcp.obj xrdp_iso.obj xrdp_mcs.obj \
+ xrdp_sec.obj xrdp_rdp.obj xrdp_process.obj xrdp_listen.obj \
+ xrdp_orders.obj xrdp_bitmap.obj xrdp_wm.obj xrdp_painter.obj \
+ xrdp_list.obj xrdp_region.obj xrdp_cache.obj xrdp_font.obj \
+ funcs.obj xrdp_login_wnd.obj xrdp_file.obj
+
+CFLAGS = -w- -O2 -Ic:\borland\bcc55\include -Ic:\openssl\include
+LDFLAGS = -Lc:\borland\bcc55\lib
+
+xrdp: $(XRDPOBJ)
+ $(CC) $(LDFLAGS) libeay32.lib $(XRDPOBJ)
+
+all: lib xrdp
+
+clean:
+ del *.obj *.o xrdp.exe
+
+lib:
+ implib -a -w libeay32.lib c:\windows\system32\libeay32.dll
+
diff --git a/xrdp/os_calls.c b/xrdp/os_calls.c
index 164c93f3..cd921f01 100644
--- a/xrdp/os_calls.c
+++ b/xrdp/os_calls.c
@@ -33,6 +33,9 @@
#include <sys/un.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <dlfcn.h>
+#include <arpa/inet.h>
+#include <netdb.h>
#endif
#include <stdlib.h>
#include <string.h>
@@ -74,6 +77,10 @@ int g_init_system(void)
#endif
#ifdef MEMLEAK
g_memlist = xrdp_list_create();
+ printf("some info\n\r");
+ printf("sizeof xrdp_bitmap is %d\n\r", sizeof(struct xrdp_bitmap));
+ printf("sizeof xrdp_wm is %d\n\r", sizeof(struct xrdp_wm));
+ printf("sizeof stream is %d\n\r", sizeof(struct stream));
#endif
return 0;
}
@@ -262,6 +269,28 @@ void g_tcp_close(int sck)
}
/*****************************************************************************/
+int g_tcp_connect(int sck, char* address, char* port)
+{
+ struct sockaddr_in s;
+ struct hostent* h;
+
+ g_memset(&s, 0, sizeof(struct sockaddr_in));
+ s.sin_family = AF_INET;
+ s.sin_port = htons(atoi(port));
+ s.sin_addr.s_addr = inet_addr(address);
+ if (s.sin_addr.s_addr == INADDR_NONE)
+ {
+ h = gethostbyname(address);
+ if (h != 0)
+ if (h->h_name != 0)
+ if (h->h_addr_list != 0)
+ if ((*(h->h_addr_list)) != 0)
+ s.sin_addr.s_addr = *((int*)(*(h->h_addr_list)));
+ }
+ return connect(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
+}
+
+/*****************************************************************************/
int g_tcp_set_non_blocking(int sck)
{
unsigned long i;
@@ -349,6 +378,7 @@ int g_tcp_select(int sck1, int sck2)
fd_set rfds;
struct timeval time;
int max;
+ int rv;
time.tv_sec = 0;
time.tv_usec = 0;
@@ -358,7 +388,16 @@ int g_tcp_select(int sck1, int sck2)
max = sck1;
if (sck2 > max)
max = sck2;
- return select(max + 1, &rfds, 0, 0, &time);
+ rv = select(max + 1, &rfds, 0, 0, &time);
+ if (rv > 0)
+ {
+ rv = 0;
+ if (FD_ISSET(((unsigned int)sck1), &rfds))
+ rv = rv | 1;
+ if (FD_ISSET(((unsigned int)sck2), &rfds))
+ rv = rv | 2;
+ }
+ return rv;
}
/*****************************************************************************/
@@ -692,3 +731,32 @@ char* g_strdup(char* in)
g_strcpy(p, in);
return p;
}
+
+/*****************************************************************************/
+int g_strcmp(char* c1, char* c2)
+{
+ return strcmp(c1, c2);
+}
+
+/*****************************************************************************/
+int g_load_library(char* in)
+{
+ return (int)dlopen(in, RTLD_LOCAL | RTLD_LAZY);
+}
+
+/*****************************************************************************/
+int g_free_library(int lib)
+{
+ if (lib == 0)
+ return 0;
+ return dlclose((void*)lib);
+}
+
+/*****************************************************************************/
+/* returns NULL if not found */
+void* g_get_proc_address(int lib, char* name)
+{
+ if (lib == 0)
+ return 0;
+ return dlsym((void*)lib, name);
+}
diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h
index d5f5f6f6..c8c199ec 100644
--- a/xrdp/xrdp.h
+++ b/xrdp/xrdp.h
@@ -53,6 +53,7 @@ int g_getchar(void);
int g_tcp_socket(void);
int g_tcp_local_socket(void);
void g_tcp_close(int sck);
+int g_tcp_connect(int sck, char* address, char* port);
int g_tcp_set_non_blocking(int sck);
int g_tcp_bind(int sck, char* port);
int g_tcp_local_bind(int sck, char* port);
@@ -95,6 +96,10 @@ char* g_strcpy(char* dest, char* src);
char* g_strncpy(char* dest, char* src, int len);
char* g_strcat(char* dest, char* src);
char* g_strdup(char* in);
+int g_strcmp(char* c1, char* c2);
+int g_load_library(char* in);
+int g_free_library(int lib);
+void* g_get_proc_address(int lib, char* name);
/* xrdp_tcp.c */
struct xrdp_tcp* xrdp_tcp_create(struct xrdp_iso* owner);
@@ -204,14 +209,17 @@ int xrdp_wm_send_palette(struct xrdp_wm* self);
int xrdp_wm_init(struct xrdp_wm* self);
int xrdp_wm_send_bitmap(struct xrdp_wm* self, struct xrdp_bitmap* bitmap,
int x, int y, int cx, int cy);
+int xrdp_wm_set_focused(struct xrdp_wm* self, struct xrdp_bitmap* wnd);
int xrdp_wm_get_vis_region(struct xrdp_wm* self, struct xrdp_bitmap* bitmap,
int x, int y, int cx, int cy,
- struct xrdp_region* region);
+ struct xrdp_region* region, int clip_children);
int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y);
int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down);
int xrdp_wm_key(struct xrdp_wm* self, int device_flags, int scan_code);
int xrdp_wm_key_sync(struct xrdp_wm* self, int device_flags, int key_flags);
int xrdp_wm_pu(struct xrdp_wm* self, struct xrdp_bitmap* control);
+int xrdp_wm_send_cursor(struct xrdp_wm* self, int cache_idx,
+ char* data, char* mask, int x, int y);
/* xrdp_process.c */
struct xrdp_process* xrdp_process_create(struct xrdp_listen* owner);
@@ -238,7 +246,11 @@ int xrdp_region_get_rect(struct xrdp_region* self, int index,
/* xrdp_bitmap.c */
struct xrdp_bitmap* xrdp_bitmap_create(int width, int height, int bpp,
int type);
+struct xrdp_bitmap* xrdp_bitmap_create_with_data(int width, int height,
+ int bpp, char* data);
void xrdp_bitmap_delete(struct xrdp_bitmap* self);
+struct xrdp_bitmap* xrdp_bitmap_get_child_by_id(struct xrdp_bitmap* self,
+ int id);
int xrdp_bitmap_set_focus(struct xrdp_bitmap* self, int focused);
int xrdp_bitmap_load(struct xrdp_bitmap* self, char* filename, int* palette);
int xrdp_bitmap_get_pixel(struct xrdp_bitmap* self, int x, int y);
@@ -305,3 +317,8 @@ int add_char_at(char* text, char ch, int index);
int remove_char_at(char* text, int index);
int set_string(char** in_str, char* in);
+int xrdp_login_wnd_create(struct xrdp_wm* self);
+
+int xrdp_file_read_sections(int fd, struct xrdp_list* names);
+int xrdp_file_read_section(int fd, char* section, struct xrdp_list* names,
+ struct xrdp_list* values);
diff --git a/xrdp/xrdp.ini b/xrdp/xrdp.ini
new file mode 100644
index 00000000..e85f9e6d
--- /dev/null
+++ b/xrdp/xrdp.ini
@@ -0,0 +1,20 @@
+
+[globals]
+
+[vnc1]
+name=vnc test
+lib=../vnc/libvnc.so
+auth=local
+ip=127.0.0.1
+port=5901
+user=n/a
+password=master
+
+[vnc2]
+name=vnc test2
+lib=../vnc/libvnc.so
+auth=local
+ip=205.5.61.3
+port=5900
+user=n/a
+password=ecs
diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c
index b7e18599..21264e6c 100644
--- a/xrdp/xrdp_bitmap.c
+++ b/xrdp/xrdp_bitmap.c
@@ -48,16 +48,34 @@ struct xrdp_bitmap* xrdp_bitmap_create(int width, int height, int bpp,
self->data = (char*)g_malloc(width * height * Bpp, 1);
if (self->type != WND_TYPE_BITMAP)
self->child_list = xrdp_list_create();
- self->line_size = ((width + 3) & ~3) * Bpp;
+ self->line_size = width * Bpp;
if (self->type == WND_TYPE_COMBO)
{
self->string_list = xrdp_list_create();
self->string_list->auto_free = 1;
+ self->data_list = xrdp_list_create();
+ self->data_list->auto_free = 1;
}
return self;
}
/*****************************************************************************/
+struct xrdp_bitmap* xrdp_bitmap_create_with_data(int width, int height,
+ int bpp, char* data)
+{
+ struct xrdp_bitmap* self;
+
+ self = (struct xrdp_bitmap*)g_malloc(sizeof(struct xrdp_bitmap), 1);
+ self->type = WND_TYPE_BITMAP;
+ self->width = width;
+ self->height = height;
+ self->bpp = bpp;
+ self->data = data;
+ self->do_not_free_data = 1;
+ return self;
+}
+
+/*****************************************************************************/
void xrdp_bitmap_delete(struct xrdp_bitmap* self)
{
int i;
@@ -79,19 +97,45 @@ void xrdp_bitmap_delete(struct xrdp_bitmap* self)
self->wm->button_down = 0;
if (self->wm->popup_wnd == self)
self->wm->popup_wnd = 0;
+ if (self->wm->login_window == self)
+ self->wm->login_window = 0;
}
if (self->child_list != 0)
{
- for (i = 0; i < self->child_list->count; i++)
+ for (i = self->child_list->count - 1; i >= 0; i--)
xrdp_bitmap_delete((struct xrdp_bitmap*)self->child_list->items[i]);
xrdp_list_delete(self->child_list);
}
+ if (self->parent != 0)
+ {
+ i = xrdp_list_index_of(self->parent->child_list, (int)self);
+ if (i >= 0)
+ xrdp_list_remove_item(self->parent->child_list, i);
+ }
xrdp_list_delete(self->string_list);
- g_free(self->data);
+ xrdp_list_delete(self->data_list);
+ if (!self->do_not_free_data)
+ g_free(self->data);
g_free(self);
}
/*****************************************************************************/
+struct xrdp_bitmap* xrdp_bitmap_get_child_by_id(struct xrdp_bitmap* self,
+ int id)
+{
+ int i;
+ struct xrdp_bitmap* b;
+
+ for (i = 0; i < self->child_list->count; i++)
+ {
+ b = (struct xrdp_bitmap*)xrdp_list_get_item(self->child_list, i);
+ if (b->id == id)
+ return b;
+ }
+ return 0;
+}
+
+/*****************************************************************************/
/* if focused is true focus this window else unfocus it */
/* returns error */
int xrdp_bitmap_set_focus(struct xrdp_bitmap* self, int focused)
@@ -162,7 +206,7 @@ int xrdp_bitmap_resize(struct xrdp_bitmap* self, int width, int height)
case 16: Bpp = 2; break;
}
self->data = (char*)g_malloc(width * height * Bpp, 1);
- self->line_size = ((width + 3) & ~3) * Bpp;
+ self->line_size = width * Bpp;
return 0;
}
@@ -541,8 +585,24 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
}
else if (self->type == WND_TYPE_SCREEN) /* 2 */
{
- painter->fg_color = self->bg_color;
- xrdp_painter_fill_rect(painter, self, 0, 0, self->width, self->height);
+ if (self->wm->mod != 0)
+ {
+ if (self->wm->mod->mod_invalidate != 0)
+ {
+ if (rect != 0)
+ {
+ self->wm->mod->mod_invalidate((int)self->wm->mod,
+ rect->left, rect->top,
+ rect->right - rect->left,
+ rect->bottom - rect->top);
+ }
+ }
+ }
+ else
+ {
+ painter->fg_color = self->bg_color;
+ xrdp_painter_fill_rect(painter, self, 0, 0, self->width, self->height);
+ }
}
else if (self->type == WND_TYPE_BUTTON) /* 3 */
{
diff --git a/xrdp/xrdp_cache.c b/xrdp/xrdp_cache.c
index f9df7ad5..aab31b57 100644
--- a/xrdp/xrdp_cache.c
+++ b/xrdp/xrdp_cache.c
@@ -69,6 +69,7 @@ int xrdp_cache_add_bitmap(struct xrdp_cache* self, struct xrdp_bitmap* bitmap)
for (i = 0; i < 3; i++)
{
for (j = 0; j < 600; j++)
+ //for (j = 0; (i == 0 && j < 600) || (i == 1 && j < 300); j++)
{
if (xrdp_bitmap_compare(self->bitmap_items[i][j].bitmap, bitmap))
{
@@ -85,6 +86,7 @@ int xrdp_cache_add_bitmap(struct xrdp_cache* self, struct xrdp_bitmap* bitmap)
for (i = 0; i < 3; i++)
{
for (j = 0; j < 600; j++)
+ //for (j = 0; (i == 0 && j < 600) || (i == 1 && j < 300); j++)
{
if (self->bitmap_items[i][j].stamp < oldest)
{
diff --git a/xrdp/xrdp_file.c b/xrdp/xrdp_file.c
new file mode 100644
index 00000000..00948174
--- /dev/null
+++ b/xrdp/xrdp_file.c
@@ -0,0 +1,201 @@
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ xrdp: A Remote Desktop Protocol server.
+ Copyright (C) Jay Sorg 2004
+
+ read a config file
+
+*/
+
+#include "xrdp.h"
+
+/*****************************************************************************/
+int xrdp_file_read_sections(int fd, struct xrdp_list* names)
+{
+ struct stream* s;
+ char text[256];
+ char c;
+ int in_it;
+ int in_it_index;
+ int len;
+ int index;
+
+ g_file_seek(fd, 0);
+ in_it_index = 0;
+ in_it = 0;
+ g_memset(text, 0, 256);
+ xrdp_list_clear(names);
+ make_stream(s);
+ init_stream(s, 8192);
+ len = g_file_read(fd, s->data, 8192);
+ if (len > 0)
+ {
+ s->end = s->p + len;
+ for (index = 0; index < len; index++)
+ {
+ in_uint8(s, c);
+ if (c == '[')
+ in_it = 1;
+ else if (c == ']')
+ {
+ xrdp_list_add_item(names, (int)g_strdup(text));
+ in_it = 0;
+ in_it_index = 0;
+ g_memset(text, 0, 256);
+ }
+ else if (in_it)
+ {
+ text[in_it_index] = c;
+ in_it_index++;
+ }
+ }
+ }
+ free_stream(s);
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_file_read_line(struct stream* s, char* text)
+{
+ int i;
+ char c;
+ char* hold;
+
+ if (!s_check(s))
+ return 1;
+ hold = s->p;
+ i = 0;
+ in_uint8(s, c);
+ while (c != 10 && c != 13 && s_check(s))
+ {
+ text[i] = c;
+ i++;
+ in_uint8(s, c);
+ }
+ if (c == 10 || c == 13)
+ {
+ while ((c == 10 || c == 13) && s_check(s))
+ {
+ in_uint8(s, c);
+ }
+ s->p--;
+ }
+ text[i] = 0;
+ if (text[0] == '[')
+ {
+ s->p = hold;
+ return 1;
+ }
+ if (g_strlen(text) > 0)
+ return 0;
+ else
+ return 1;
+}
+
+/*****************************************************************************/
+int xrdp_file_split_name_value(char* text, char* name, char* value)
+{
+ int len;
+ int i;
+ int value_index;
+ int name_index;
+ int on_to;
+
+ value_index = 0;
+ name_index = 0;
+ on_to = 0;
+ name[0] = 0;
+ value[0] = 0;
+ len = g_strlen(text);
+ for (i = 0; i < len; i++)
+ {
+ if (text[i] == '=')
+ on_to = 1;
+ else if (on_to)
+ {
+ value[value_index] = text[i];
+ value_index++;
+ value[value_index] = 0;
+ }
+ else
+ {
+ name[name_index] = text[i];
+ name_index++;
+ name[name_index] = 0;
+ }
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_file_read_section(int fd, char* section, struct xrdp_list* names,
+ struct xrdp_list* values)
+{
+ struct stream* s;
+ char text[256];
+ char name[256];
+ char value[256];
+ char c;
+ int in_it;
+ int in_it_index;
+ int len;
+ int index;
+
+ g_file_seek(fd, 0);
+ in_it_index = 0;
+ in_it = 0;
+ g_memset(text, 0, 256);
+ xrdp_list_clear(names);
+ xrdp_list_clear(values);
+ make_stream(s);
+ init_stream(s, 8192);
+ len = g_file_read(fd, s->data, 8192);
+ if (len > 0)
+ {
+ s->end = s->p + len;
+ for (index = 0; index < len; index++)
+ {
+ in_uint8(s, c);
+ if (c == '[')
+ in_it = 1;
+ else if (c == ']')
+ {
+ if (g_strcmp(section, text) == 0)
+ {
+ xrdp_file_read_line(s, text);
+ while (xrdp_file_read_line(s, text) == 0)
+ {
+ xrdp_file_split_name_value(text, name, value);
+ xrdp_list_add_item(names, (int)g_strdup(name));
+ xrdp_list_add_item(values, (int)g_strdup(value));
+ }
+ free_stream(s);
+ return 0;
+ }
+ in_it = 0;
+ in_it_index = 0;
+ g_memset(text, 0, 256);
+ }
+ else if (in_it)
+ {
+ text[in_it_index] = c;
+ in_it_index++;
+ }
+ }
+ }
+ free_stream(s);
+ return 0;
+}
diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c
new file mode 100644
index 00000000..b6d873ac
--- /dev/null
+++ b/xrdp/xrdp_login_wnd.c
@@ -0,0 +1,614 @@
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ xrdp: A Remote Desktop Protocol server.
+ Copyright (C) Jay Sorg 2004
+
+ main login window and login help window
+
+*/
+
+#include "xrdp.h"
+
+/*****************************************************************************/
+/* all login help screen events go here */
+int xrdp_wm_login_help_notify(struct xrdp_bitmap* wnd,
+ struct xrdp_bitmap* sender,
+ int msg, int param1, int param2)
+{
+ struct xrdp_painter* p;
+
+ if (wnd == 0)
+ return 0;
+ if (sender == 0)
+ return 0;
+ if (wnd->owner == 0)
+ return 0;
+ if (msg == 1) /* click */
+ {
+ if (sender->id == 1) /* ok button */
+ {
+ if (sender->owner->notify != 0)
+ {
+ wnd->owner->notify(wnd->owner, wnd, 100, 1, 0); /* ok */
+ }
+ }
+ }
+ else if (msg == WM_PAINT) /* 3 */
+ {
+ p = (struct xrdp_painter*)param1;
+ if (p != 0)
+ {
+ p->font->color = wnd->wm->black;
+ xrdp_painter_draw_text(p, wnd, 10, 30, "You must be authenticated \
+before using this");
+ xrdp_painter_draw_text(p, wnd, 10, 46, "session.");
+ xrdp_painter_draw_text(p, wnd, 10, 78, "Enter a valid username in \
+the username edit box.");
+ xrdp_painter_draw_text(p, wnd, 10, 94, "Enter the password in \
+the password edit box.");
+ xrdp_painter_draw_text(p, wnd, 10, 110, "Both the username and \
+password are case");
+ xrdp_painter_draw_text(p, wnd, 10, 126, "sensitive.");
+ xrdp_painter_draw_text(p, wnd, 10, 158, "Contact your system \
+administrator if you are");
+ xrdp_painter_draw_text(p, wnd, 10, 174, "having problems \
+logging on.");
+ }
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+int server_begin_update(int handle)
+{
+ struct xrdp_mod* mod;
+ struct xrdp_wm* wm;
+ struct xrdp_painter* p;
+
+ mod = (struct xrdp_mod*)handle;
+ wm = (struct xrdp_wm*)mod->wm;
+ p = xrdp_painter_create(wm);
+ xrdp_painter_begin_update(p);
+ mod->painter = (int)p;
+ return 0;
+}
+
+/*****************************************************************************/
+int server_end_update(int handle)
+{
+ struct xrdp_mod* mod;
+ struct xrdp_painter* p;
+
+ mod = (struct xrdp_mod*)handle;
+ p = (struct xrdp_painter*)mod->painter;
+ xrdp_painter_end_update(p);
+ xrdp_painter_delete(p);
+ mod->painter = 0;
+ return 0;
+}
+
+/*****************************************************************************/
+int server_fill_rect(int handle, int x, int y, int cx, int cy,
+ int color)
+{
+ struct xrdp_mod* mod;
+ struct xrdp_wm* wm;
+ struct xrdp_painter* p;
+
+ mod = (struct xrdp_mod*)handle;
+ wm = (struct xrdp_wm*)mod->wm;
+ p = (struct xrdp_painter*)mod->painter;
+ p->fg_color = color;
+ xrdp_painter_fill_rect(p, wm->screen, x, y, cx, cy);
+ return 0;
+}
+
+/*****************************************************************************/
+int server_screen_blt(int handle, int x, int y, int cx, int cy,
+ int srcx, int srcy)
+{
+ struct xrdp_mod* mod;
+ struct xrdp_wm* wm;
+
+ mod = (struct xrdp_mod*)handle;
+ wm = (struct xrdp_wm*)mod->wm;
+ xrdp_orders_init(wm->orders);
+ xrdp_orders_screen_blt(wm->orders, x, y, cx, cy, srcx, srcy, 0xcc, 0);
+ xrdp_orders_send(wm->orders);
+ return 0;
+}
+
+/*****************************************************************************/
+int server_paint_rect(int handle, int x, int y, int cx, int cy,
+ char* data)
+{
+ struct xrdp_mod* mod;
+ struct xrdp_wm* wm;
+ struct xrdp_bitmap* b;
+
+ mod = (struct xrdp_mod*)handle;
+ wm = (struct xrdp_wm*)mod->wm;
+ b = xrdp_bitmap_create_with_data(cx, cy, wm->screen->bpp, data);
+ xrdp_wm_send_bitmap(wm, b, x, y, cx, cy);
+ /*xrdp_painter_draw_bitmap((struct xrdp_painter*)mod->painter,
+ wm->screen, b, x, y, cx, cy);*/
+ xrdp_bitmap_delete(b);
+ return 0;
+}
+
+/*****************************************************************************/
+int server_set_cursor(int handle, int x, int y, char* data, char* mask)
+{
+ struct xrdp_mod* mod;
+ struct xrdp_wm* wm;
+
+ mod = (struct xrdp_mod*)handle;
+ wm = (struct xrdp_wm*)mod->wm;
+ xrdp_wm_send_cursor(wm, 2, data, mask, x, y);
+ return 0;
+}
+
+/*****************************************************************************/
+int server_palette(int handle, int* palette)
+{
+ struct xrdp_mod* mod;
+ struct xrdp_wm* wm;
+
+ mod = (struct xrdp_mod*)handle;
+ wm = (struct xrdp_wm*)mod->wm;
+ g_memcpy(wm->palette, palette, 256 * sizeof(int));
+ xrdp_cache_add_palette(wm->cache, palette);
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_wm_popup_notify(struct xrdp_bitmap* wnd,
+ struct xrdp_bitmap* sender,
+ int msg, int param1, int param2)
+{
+ return 0;
+}
+
+/*****************************************************************************/
+int server_error_popup(int handle, char* error, char* caption)
+{
+#ifdef aa0
+ struct xrdp_mod* mod;
+ struct xrdp_wm* wm;
+ struct xrdp_bitmap* wnd;
+ struct xrdp_bitmap* but;
+
+ mod = (struct xrdp_mod*)handle;
+ wm = (struct xrdp_wm*)mod->wm;
+ wnd = xrdp_bitmap_create(400, 200, wm->screen->bpp, WND_TYPE_WND);
+ xrdp_list_add_item(wm->screen->child_list, (int)wnd);
+ wnd->parent = wm->screen;
+ wnd->owner = wm->screen;
+ wnd->wm = wm;
+ wnd->bg_color = wm->grey;
+ wnd->left = wm->screen->width / 2 - wnd->width / 2;
+ wnd->top = wm->screen->height / 2 - wnd->height / 2;
+ wnd->notify = xrdp_wm_popup_notify;
+ g_strcpy(wnd->caption, caption);
+
+ /* button */
+ but = xrdp_bitmap_create(60, 25, wm->screen->bpp, WND_TYPE_BUTTON);
+ xrdp_list_add_item(wnd->child_list, (int)but);
+ but->parent = wnd;
+ but->owner = wnd;
+ but->wm = wm;
+ but->left = 180;
+ but->top = 160;
+ but->id = 1;
+ g_strcpy(but->caption, "OK");
+ but->tab_stop = 1;
+
+ xrdp_bitmap_invalidate(wm->screen, 0);
+ //xrdp_bitmap_invalidate(wnd, 0);
+ g_sleep(2000);
+#endif
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_wm_setup_mod(struct xrdp_wm* self,
+ struct xrdp_mod_data* mod_data)
+{
+ if (self != 0)
+ {
+ if (self->mod_handle == 0)
+ {
+ self->mod_handle = g_load_library(mod_data->lib);
+ if (self->mod_handle != 0)
+ {
+ (void*)self->mod_init =
+ g_get_proc_address(self->mod_handle, "mod_init");
+ (void*)self->mod_exit =
+ g_get_proc_address(self->mod_handle, "mod_exit");
+ if (self->mod_init != 0 && self->mod_exit != 0)
+ {
+ self->mod = (struct xrdp_mod*)self->mod_init();
+ }
+ }
+ if (self->mod != 0)
+ {
+ self->mod->wm = (int)self;
+ self->mod->server_begin_update = server_begin_update;
+ self->mod->server_end_update = server_end_update;
+ self->mod->server_fill_rect = server_fill_rect;
+ self->mod->server_screen_blt = server_screen_blt;
+ self->mod->server_paint_rect = server_paint_rect;
+ self->mod->server_set_cursor = server_set_cursor;
+ self->mod->server_palette = server_palette;
+ self->mod->server_error_popup= server_error_popup;
+ }
+ }
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_wm_delete_all_childs(struct xrdp_wm* self)
+{
+ int i;
+ struct xrdp_bitmap* b;
+
+ for (i = self->screen->child_list->count - 1; i >= 0; i--)
+ {
+ b = (struct xrdp_bitmap*)xrdp_list_get_item(self->screen->child_list, i);
+ xrdp_bitmap_delete(b);
+ }
+ xrdp_bitmap_invalidate(self->screen, 0);
+ return 0;
+}
+
+/*****************************************************************************/
+/* all login screen events go here */
+int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
+ struct xrdp_bitmap* sender,
+ int msg, int param1, int param2)
+{
+ struct xrdp_bitmap* help;
+ struct xrdp_bitmap* but;
+ struct xrdp_bitmap* b;
+ struct xrdp_bitmap* combo;
+ struct xrdp_wm* wm;
+ struct xrdp_rect rect;
+ struct xrdp_mod_data con_mod;
+ struct xrdp_mod_data* mod;
+ int i;
+
+ if (wnd->modal_dialog != 0 && msg != 100)
+ {
+ return 0;
+ }
+ wm = wnd->wm;
+ if (msg == 1) /* click */
+ {
+ if (sender->id == 1) /* help button */
+ {
+ /* create help screen */
+ help = xrdp_bitmap_create(300, 300, wnd->wm->screen->bpp, 1);
+ xrdp_list_insert_item(wnd->wm->screen->child_list, 0, (int)help);
+ help->parent = wnd->wm->screen;
+ help->owner = wnd;
+ wnd->modal_dialog = help;
+ help->wm = wnd->wm;
+ help->bg_color = wnd->wm->grey;
+ help->left = wnd->wm->screen->width / 2 - help->width / 2;
+ help->top = wnd->wm->screen->height / 2 - help->height / 2;
+ help->notify = xrdp_wm_login_help_notify;
+ g_strcpy(help->caption, "Login help");
+ /* ok button */
+ but = xrdp_bitmap_create(60, 25, wnd->wm->screen->bpp, 3);
+ xrdp_list_insert_item(help->child_list, 0, (int)but);
+ but->parent = help;
+ but->owner = help;
+ but->wm = wnd->wm;
+ but->left = 120;
+ but->top = 260;
+ but->id = 1;
+ but->tab_stop = 1;
+ g_strcpy(but->caption, "OK");
+ /* draw it */
+ help->focused_control = but;
+ //wnd->wm->focused_window = help;
+ xrdp_bitmap_invalidate(help, 0);
+ xrdp_wm_set_focused(wnd->wm, help);
+ //xrdp_bitmap_invalidate(wnd->focused_control, 0);
+ }
+ else if (sender->id == 2) /* cancel button */
+ {
+ /*if (wnd != 0)
+ if (wnd->wm != 0)
+ if (wnd->wm->pro_layer != 0)
+ wnd->wm->pro_layer->term = 1;*/
+ }
+ else if (sender->id == 3) /* ok button */
+ {
+ combo = (struct xrdp_bitmap*)xrdp_bitmap_get_child_by_id(wnd, 6);
+ if (combo != 0)
+ {
+ mod = (struct xrdp_mod_data*)xrdp_list_get_item(combo->data_list,
+ combo->item_index);
+ if (mod != 0)
+ {
+ con_mod = *mod;
+ if (xrdp_wm_setup_mod(wm, mod) == 0)
+ {
+ xrdp_wm_delete_all_childs(wm);
+ if (!wm->pro_layer->term)
+ {
+ if (wm->mod->mod_start((int)wm->mod, wm->screen->width,
+ wm->screen->height, wm->screen->bpp) != 0)
+ wm->pro_layer->term = 1; /* kill session */
+ }
+ if (!wm->pro_layer->term)
+ {
+ if (wm->mod->mod_connect((int)wm->mod, con_mod.ip, con_mod.port,
+ con_mod.user, con_mod.password) != 0)
+ wm->pro_layer->term = 1; /* kill session */
+ }
+ if (!wm->pro_layer->term)
+ {
+ if (wm->mod->sck != 0)
+ wm->pro_layer->app_sck = wm->mod->sck;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (msg == 2) /* mouse move */
+ {
+ }
+ else if (msg == 100) /* modal result is done */
+ {
+ i = xrdp_list_index_of(wnd->wm->screen->child_list, (int)sender);
+ if (i >= 0)
+ {
+ b = (struct xrdp_bitmap*)
+ xrdp_list_get_item(wnd->wm->screen->child_list, i);
+ xrdp_list_remove_item(sender->wm->screen->child_list, i);
+ MAKERECT(rect, b->left, b->top, b->width, b->height);
+ xrdp_bitmap_invalidate(wnd->wm->screen, &rect);
+ xrdp_bitmap_delete(sender);
+ wnd->modal_dialog = 0;
+ xrdp_wm_set_focused(wnd->wm, wnd);
+ }
+ }
+ return 0;
+}
+
+/******************************************************************************/
+int xrdp_wm_login_fill_in_combo(struct xrdp_wm* self, struct xrdp_bitmap* b)
+{
+ struct xrdp_list* sections;
+ struct xrdp_list* section_names;
+ struct xrdp_list* section_values;
+ int fd;
+ int i;
+ int j;
+ char* p;
+ char* q;
+ char* r;
+ struct xrdp_mod_data* mod_data;
+
+ sections = xrdp_list_create();
+ sections->auto_free = 1;
+ section_names = xrdp_list_create();
+ section_names->auto_free = 1;
+ section_values = xrdp_list_create();
+ section_values->auto_free = 1;
+ fd = g_file_open("xrdp.ini");
+ xrdp_file_read_sections(fd, sections);
+ for (i = 0; i < sections->count; i++)
+ {
+ p = (char*)xrdp_list_get_item(sections, i);
+ xrdp_file_read_section(fd, p, section_names, section_values);
+ if (g_strcmp(p, "globals") == 0)
+ {
+ }
+ else
+ {
+ mod_data = g_malloc(sizeof(struct xrdp_mod_data), 1);
+ g_strcpy(mod_data->name, p);
+ for (j = 0; j < section_names->count; j++)
+ {
+ q = (char*)xrdp_list_get_item(section_names, j);
+ r = (char*)xrdp_list_get_item(section_values, j);
+ if (g_strcmp("name", q) == 0)
+ {
+ g_strcpy(mod_data->name, r);
+ }
+ else if (g_strcmp("lib", q) == 0)
+ {
+ g_strcpy(mod_data->lib, r);
+ }
+ else if (g_strcmp("ip", q) == 0)
+ {
+ g_strcpy(mod_data->ip, r);
+ }
+ else if (g_strcmp("port", q) == 0)
+ {
+ g_strcpy(mod_data->port, r);
+ }
+ else if (g_strcmp("user", q) == 0)
+ {
+ g_strcpy(mod_data->user, r);
+ }
+ else if (g_strcmp("password", q) == 0)
+ {
+ g_strcpy(mod_data->password, r);
+ }
+ }
+ xrdp_list_add_item(b->string_list, (int)g_strdup(mod_data->name));
+ xrdp_list_add_item(b->data_list, (int)mod_data);
+ }
+ }
+ g_file_close(fd);
+ xrdp_list_delete(sections);
+ xrdp_list_delete(section_names);
+ xrdp_list_delete(section_values);
+ return 0;
+}
+
+/******************************************************************************/
+int xrdp_login_wnd_create(struct xrdp_wm* self)
+{
+ struct xrdp_bitmap* but;
+
+ /* draw login window */
+ self->login_window = xrdp_bitmap_create(400, 200, self->screen->bpp,
+ WND_TYPE_WND);
+ xrdp_list_add_item(self->screen->child_list, (int)self->login_window);
+ self->login_window->parent = self->screen;
+ self->login_window->owner = self->screen;
+ self->login_window->wm = self;
+ self->login_window->bg_color = self->grey;
+ self->login_window->left = self->screen->width / 2 -
+ self->login_window->width / 2;
+ self->login_window->top = self->screen->height / 2 -
+ self->login_window->height / 2;
+ self->login_window->notify = xrdp_wm_login_notify;
+ g_strcpy(self->login_window->caption, "Login to xrdp");
+
+ /* image */
+ but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE);
+ xrdp_bitmap_load(but, "xrdp256.bmp", self->palette);
+ but->parent = self->screen;
+ but->owner = self->screen;
+ but->wm = self;
+ but->left = self->screen->width - but->width;
+ but->top = self->screen->height - but->height;
+ xrdp_list_add_item(self->screen->child_list, (int)but);
+
+ /* image */
+ but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE);
+ xrdp_bitmap_load(but, "ad256.bmp", self->palette);
+ but->parent = self->login_window;
+ but->owner = self->login_window;
+ but->wm = self;
+ but->left = 10;
+ but->top = 30;
+ xrdp_list_add_item(self->login_window->child_list, (int)but);
+
+ /* label */
+ but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL);
+ xrdp_list_add_item(self->login_window->child_list, (int)but);
+ but->parent = self->login_window;
+ but->owner = self->login_window;
+ but->wm = self;
+ but->left = 155;
+ but->top = 50;
+ g_strcpy(but->caption, "Username");
+
+ /* edit */
+ but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT);
+ xrdp_list_add_item(self->login_window->child_list, (int)but);
+ but->parent = self->login_window;
+ but->owner = self->login_window;
+ but->wm = self;
+ but->left = 220;
+ but->top = 50;
+ but->id = 4;
+ but->cursor = 1;
+ but->tab_stop = 1;
+ self->login_window->focused_control = but;
+
+ /* label */
+ but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL);
+ xrdp_list_add_item(self->login_window->child_list, (int)but);
+ but->parent = self->login_window;
+ but->owner = self->login_window;
+ but->wm = self;
+ but->left = 155;
+ but->top = 80;
+ g_strcpy(but->caption, "Password");
+
+ /* edit */
+ but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT);
+ xrdp_list_add_item(self->login_window->child_list, (int)but);
+ but->parent = self->login_window;
+ but->owner = self->login_window;
+ but->wm = self;
+ but->left = 220;
+ but->top = 80;
+ but->id = 5;
+ but->cursor = 1;
+ but->tab_stop = 1;
+ but->password_char = '*';
+
+ /* label */
+ but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL);
+ xrdp_list_add_item(self->login_window->child_list, (int)but);
+ but->parent = self->login_window;
+ but->owner = self->login_window;
+ but->wm = self;
+ but->left = 155;
+ but->top = 110;
+ g_strcpy(but->caption, "Module");
+
+ /* combo */
+ but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_COMBO);
+ xrdp_list_add_item(self->login_window->child_list, (int)but);
+ but->parent = self->login_window;
+ but->owner = self->login_window;
+ but->wm = self;
+ but->left = 220;
+ but->top = 110;
+ but->id = 6;
+ but->tab_stop = 1;
+ xrdp_wm_login_fill_in_combo(self, but);
+
+ /* button */
+ but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON);
+ xrdp_list_add_item(self->login_window->child_list, (int)but);
+ but->parent = self->login_window;
+ but->owner = self->login_window;
+ but->wm = self;
+ but->left = 180;
+ but->top = 160;
+ but->id = 3;
+ g_strcpy(but->caption, "OK");
+ but->tab_stop = 1;
+
+ /* button */
+ but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON);
+ xrdp_list_add_item(self->login_window->child_list, (int)but);
+ but->parent = self->login_window;
+ but->owner = self->login_window;
+ but->wm = self;
+ but->left = 250;
+ but->top = 160;
+ but->id = 2;
+ g_strcpy(but->caption, "Cancel");
+ but->tab_stop = 1;
+
+ /* button */
+ but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON);
+ xrdp_list_add_item(self->login_window->child_list, (int)but);
+ but->parent = self->login_window;
+ but->owner = self->login_window;
+ but->wm = self;
+ but->left = 320;
+ but->top = 160;
+ but->id = 1;
+ g_strcpy(but->caption, "Help");
+ but->tab_stop = 1;
+
+ return 0;
+}
diff --git a/xrdp/xrdp_painter.c b/xrdp/xrdp_painter.c
index b3508fff..6a69e5f3 100644
--- a/xrdp/xrdp_painter.c
+++ b/xrdp/xrdp_painter.c
@@ -32,6 +32,7 @@ struct xrdp_painter* xrdp_painter_create(struct xrdp_wm* wm)
self->orders = wm->orders;
self->rop = 0xcc; /* copy */
self->font = xrdp_font_create(wm);
+ self->clip_children = 1;
return self;
}
@@ -155,7 +156,8 @@ int xrdp_painter_fill_rect(struct xrdp_painter* self,
if (bitmap->type == WND_TYPE_BITMAP) /* 0 */
return 0;
region = xrdp_region_create(self->wm);
- xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region);
+ xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region,
+ self->clip_children);
i = 0;
while (xrdp_region_get_rect(region, i, &rect) == 0)
{
@@ -192,11 +194,12 @@ int xrdp_painter_fill_rect2(struct xrdp_painter* self,
return 0;
/* todo data */
-
+
if (bitmap->type == WND_TYPE_BITMAP) /* 0 */
return 0;
region = xrdp_region_create(self->wm);
- xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region);
+ xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region,
+ self->clip_children);
i = 0;
while (xrdp_region_get_rect(region, i, &rect) == 0)
{
@@ -250,7 +253,8 @@ int xrdp_painter_draw_bitmap(struct xrdp_painter* self,
if (bitmap->type == WND_TYPE_BITMAP)
return 0;
region = xrdp_region_create(self->wm);
- xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region);
+ xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region,
+ self->clip_children);
b = bitmap;
while (b != 0)
{
@@ -424,7 +428,7 @@ int xrdp_painter_draw_text(struct xrdp_painter* self,
}
region = xrdp_region_create(self->wm);
xrdp_wm_get_vis_region(self->wm, bitmap, x, y, total_width, total_height,
- region);
+ region, self->clip_children);
b = bitmap;
while (b != 0)
{
diff --git a/xrdp/xrdp_process.c b/xrdp/xrdp_process.c
index f488cdbe..0f8323da 100644
--- a/xrdp/xrdp_process.c
+++ b/xrdp/xrdp_process.c
@@ -36,7 +36,9 @@ struct xrdp_process* xrdp_process_create(struct xrdp_listen* owner)
void xrdp_process_delete(struct xrdp_process* self)
{
if (self == 0)
+ {
return;
+ }
xrdp_rdp_delete(self->rdp_layer);
xrdp_orders_delete(self->orders);
xrdp_wm_delete(self->wm);
@@ -60,14 +62,16 @@ int xrdp_process_main_loop(struct xrdp_process* self)
while (!g_is_term() && !self->term)
{
i = g_tcp_select(self->sck, self->app_sck);
- if (i == 1)
+ if (i & 1)
{
init_stream(s, 8192);
cont = 1;
while (cont)
{
if (xrdp_rdp_recv(self->rdp_layer, s, &code) != 0)
+ {
break;
+ }
DEBUG(("xrdp_process_main_loop code %d\n\r", code));
switch (code)
{
@@ -76,11 +80,11 @@ int xrdp_process_main_loop(struct xrdp_process* self)
break;
case 0:
break;
- case RDP_PDU_CONFIRM_ACTIVE:
- xrdp_rdp_process_confirm_active(self->rdp_layer, s); /* 3 */
+ case RDP_PDU_CONFIRM_ACTIVE: /* 3 */
+ xrdp_rdp_process_confirm_active(self->rdp_layer, s);
break;
- case RDP_PDU_DATA:
- if (xrdp_rdp_process_data(self->rdp_layer, s) != 0) /* 7 */
+ case RDP_PDU_DATA: /* 7 */
+ if (xrdp_rdp_process_data(self->rdp_layer, s) != 0)
{
DEBUG(("xrdp_rdp_process_data returned non zero\n\r"));
cont = 0;
@@ -92,10 +96,14 @@ int xrdp_process_main_loop(struct xrdp_process* self)
break;
}
if (cont)
+ {
cont = s->next_packet < s->end;
+ }
}
if (cont) /* we must have errored out */
+ {
break;
+ }
if (self->rdp_layer->up_and_running && self->wm == 0)
{
/* only do this once */
@@ -105,13 +113,29 @@ int xrdp_process_main_loop(struct xrdp_process* self)
xrdp_wm_init(self->wm);
}
}
- else if (i == 2)
+ if (i & 2) /* mod socket fired */
{
+ if (self->wm->mod == 0)
+ {
+ break;
+ }
+ if (self->wm->mod->mod_signal == 0)
+ {
+ break;
+ }
+ if (self->wm->mod->mod_signal((int)self->wm->mod) != 0)
+ {
+ break;
+ }
}
- else if (i == 0)
+ if (i == 0) /* no data on any stream */
+ {
g_sleep(10);
- else
+ }
+ else if (i < 0)
+ {
break;
+ }
}
}
xrdp_rdp_disconnect(self->rdp_layer);
diff --git a/xrdp/xrdp_rdp.c b/xrdp/xrdp_rdp.c
index 6c9a3bfc..08c446aa 100644
--- a/xrdp/xrdp_rdp.c
+++ b/xrdp/xrdp_rdp.c
@@ -403,7 +403,9 @@ int xrdp_rdp_process_input_mouse(struct xrdp_rdp* self, int device_flags,
if (!self->up_and_running)
return 0;
if (device_flags & MOUSE_FLAG_MOVE) /* 0x0800 */
+ {
xrdp_wm_mouse_move(self->pro_layer->wm, x, y);
+ }
if (device_flags & MOUSE_FLAG_BUTTON1) /* 0x1000 */
{
if (device_flags & MOUSE_FLAG_DOWN) /* 0x8000 */
@@ -418,6 +420,23 @@ int xrdp_rdp_process_input_mouse(struct xrdp_rdp* self, int device_flags,
else
xrdp_wm_mouse_click(self->pro_layer->wm, x, y, 2, 0);
}
+ if (device_flags & MOUSE_FLAG_BUTTON3) /* 0x4000 */
+ {
+ if (device_flags & MOUSE_FLAG_DOWN) /* 0x8000 */
+ xrdp_wm_mouse_click(self->pro_layer->wm, x, y, 3, 1);
+ else
+ xrdp_wm_mouse_click(self->pro_layer->wm, x, y, 3, 0);
+ }
+ if (device_flags == MOUSE_FLAG_BUTTON4 || /* 0x0280 */
+ device_flags == 0x0278)
+ {
+ xrdp_wm_mouse_click(self->pro_layer->wm, 0, 0, 4, 0);
+ }
+ if (device_flags == MOUSE_FLAG_BUTTON5 || /* 0x0380 */
+ device_flags == 0x0388)
+ {
+ xrdp_wm_mouse_click(self->pro_layer->wm, 0, 0, 5, 0);
+ }
return 0;
}
@@ -541,6 +560,8 @@ int xrdp_rdp_process_screen_update(struct xrdp_rdp* self, struct stream* s)
int top;
int right;
int bottom;
+ int cx;
+ int cy;
struct xrdp_rect rect;
in_uint32_le(s, op);
@@ -548,9 +569,13 @@ int xrdp_rdp_process_screen_update(struct xrdp_rdp* self, struct stream* s)
in_uint16_le(s, top);
in_uint16_le(s, right);
in_uint16_le(s, bottom);
- MAKERECT(rect, left, top, (right - left) + 1, (bottom - top) + 1);
+ cx = (right - left) + 1;
+ cy = (bottom - top) + 1;
if (self->up_and_running && self->pro_layer->wm != 0)
+ {
+ MAKERECT(rect, left, top, cx, cy);
xrdp_bitmap_invalidate(self->pro_layer->wm->screen, &rect);
+ }
return 0;
}
diff --git a/xrdp/xrdp_tcp.c b/xrdp/xrdp_tcp.c
index 23ff2338..fd263dfc 100644
--- a/xrdp/xrdp_tcp.c
+++ b/xrdp/xrdp_tcp.c
@@ -60,12 +60,16 @@ int xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
while (len > 0)
{
if (g_is_term())
+ {
return 1;
+ }
rcvd = g_tcp_recv(self->sck, s->end, len, 0);
if (rcvd == -1)
{
if (g_tcp_last_error_would_block(self->sck))
+ {
g_sleep(1);
+ }
else
{
DEBUG((" error = -1 in xrdp_tcp_recv socket %d\n", self->sck))
diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h
index bf80cb92..4527533c 100644
--- a/xrdp/xrdp_types.h
+++ b/xrdp/xrdp_types.h
@@ -20,6 +20,38 @@
*/
+/* lib */
+struct xrdp_mod
+{
+ int size; /* size of this struct */
+ /* client functions */
+ int (*mod_start)(int handle, int w, int h, int bpp);
+ int (*mod_connect)(int handle, char* ip, char* port,
+ char* username, char* password);
+ int (*mod_event)(int handle, int msg, int param1, int param2);
+ int (*mod_signal)(int handle);
+ int (*mod_invalidate)(int handle, int x, int y, int cx, int cy);
+ int d1[95];
+ /* server functions */
+ int (*server_begin_update)(int handle);
+ int (*server_end_update)(int handle);
+ int (*server_fill_rect)(int handle, int x, int y, int cx, int cy,
+ int color);
+ int (*server_screen_blt)(int handle, int x, int y, int cx, int cy,
+ int srcx, int srcy);
+ int (*server_paint_rect)(int handle, int x, int y, int cx, int cy,
+ char* data);
+ int (*server_set_cursor)(int handle, int x, int y, char* data, char* mask);
+ int (*server_palette)(int handle, int* palette);
+ int (*server_error_popup)(int handle, char* error, char* caption);
+ int d2[92];
+ /* common */
+ int handle; /* pointer to self as int */
+ int wm; /* struct xrdp_wm* */
+ int painter;
+ int sck;
+};
+
/* for memory debugging */
struct xrdp_mem
{
@@ -318,11 +350,18 @@ struct xrdp_wm
struct xrdp_bitmap* focused_window;
/* cursor */
int current_cursor;
+ int mouse_x;
+ int mouse_y;
/* keyboard info */
int keys[256]; /* key states 0 up 1 down*/
int caps_lock;
int scroll_lock;
int num_lock;
+ /* mod vars */
+ int mod_handle;
+ int (*mod_init)();
+ int (*mod_exit)(int);
+ struct xrdp_mod* mod;
};
/* rdp process */
@@ -363,6 +402,7 @@ struct xrdp_painter
int rop;
int use_clip;
struct xrdp_rect clip;
+ int clip_children;
int bg_color;
int fg_color;
struct xrdp_brush brush;
@@ -387,6 +427,7 @@ struct xrdp_bitmap
/* for bitmap */
int bpp;
int line_size; /* in bytes */
+ int do_not_free_data;
char* data;
/* for all but bitmap */
int left;
@@ -409,6 +450,7 @@ struct xrdp_bitmap
int state; /* for button 0 = normal 1 = down */
/* for combo */
struct xrdp_list* string_list;
+ struct xrdp_list* data_list;
/* for combo or popup */
int item_index;
/* for popup */
@@ -426,3 +468,14 @@ struct xrdp_font
int size;
int style;
};
+
+/* modual */
+struct xrdp_mod_data
+{
+ char name[256];
+ char lib[256];
+ char ip[256];
+ char port[256];
+ char user[256];
+ char password[256];
+};
diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c
index 904445dc..f2ab6f64 100644
--- a/xrdp/xrdp_wm.c
+++ b/xrdp/xrdp_wm.c
@@ -48,6 +48,12 @@ void xrdp_wm_delete(struct xrdp_wm* self)
xrdp_cache_delete(self->cache);
xrdp_painter_delete(self->painter);
xrdp_bitmap_delete(self->screen);
+ /* free any modual stuff */
+ if (self->mod != 0 && self->mod_exit != 0)
+ self->mod_exit((int)self->mod);
+ if (self->mod_handle != 0)
+ g_free_library(self->mod_handle);
+ /* free self */
g_free(self);
}
@@ -79,102 +85,66 @@ int xrdp_wm_send_palette(struct xrdp_wm* self)
}
/*****************************************************************************/
-/* todo */
int xrdp_wm_send_bitmap(struct xrdp_wm* self, struct xrdp_bitmap* bitmap,
int x, int y, int cx, int cy)
{
int data_size;
int line_size;
int i;
+ int j;
int total_lines;
int lines_sending;
+ int Bpp;
+ int e;
char* p;
+ char* q;
struct stream* s;
+ lines_sending = 0;
make_stream(s);
init_stream(s, 8192);
- data_size = bitmap->width * bitmap->height * ((bitmap->bpp + 7) / 8);
- line_size = bitmap->width * ((bitmap->bpp + 7) / 8);
- total_lines = data_size / line_size;
+ Bpp = (bitmap->bpp + 7) / 8;
+ data_size = bitmap->width * bitmap->height * Bpp;
+ line_size = bitmap->width * Bpp;
+ total_lines = bitmap->height;
+ e = bitmap->width % 4;
+ if (e != 0)
+ e = 4 - e;
i = 0;
p = bitmap->data;
- lines_sending = 4096 / line_size;
- if (lines_sending > total_lines)
- lines_sending = total_lines;
- while (i < total_lines)
+ if (line_size > 0 && total_lines > 0)
{
- xrdp_rdp_init_data(self->rdp_layer, s);
- out_uint16_le(s, RDP_UPDATE_BITMAP);
- out_uint16_le(s, 1); /* num updates */
- out_uint16_le(s, x);
- out_uint16_le(s, y + i);
- out_uint16_le(s, (x + cx) - 1);
- out_uint16_le(s, (y + i + cy) - 1);
- out_uint16_le(s, bitmap->width);
- out_uint16_le(s, lines_sending);
- out_uint16_le(s, bitmap->bpp); /* bpp */
- out_uint16_le(s, 0); /* compress */
- out_uint16_le(s, line_size * lines_sending); /* bufsize */
- out_uint8a(s, p, line_size * lines_sending);
- s_mark_end(s);
- xrdp_rdp_send_data(self->rdp_layer, s, RDP_DATA_PDU_UPDATE);
- p = p + line_size * lines_sending;
- i = i + lines_sending;
- if (i + lines_sending > total_lines)
- lines_sending = total_lines - i;
- if (lines_sending <= 0)
- break;
- }
- free_stream(s);
- return 0;
-}
-
-/*****************************************************************************/
-/* all login help screen events go here */
-int xrdp_wm_login_help_notify(struct xrdp_bitmap* wnd,
- struct xrdp_bitmap* sender,
- int msg, int param1, int param2)
-{
- struct xrdp_painter* p;
-
- if (wnd == 0)
- return 0;
- if (sender == 0)
- return 0;
- if (wnd->owner == 0)
- return 0;
- if (msg == 1) /* click */
- {
- if (sender->id == 1) /* ok button */
+ while (i < total_lines)
{
- if (sender->owner->notify != 0)
+ lines_sending = 4096 / (line_size + e * Bpp);
+ if (i + lines_sending > total_lines)
+ lines_sending = total_lines - i;
+ p = p + line_size * lines_sending;
+ xrdp_rdp_init_data(self->rdp_layer, s);
+ out_uint16_le(s, RDP_UPDATE_BITMAP);
+ out_uint16_le(s, 1); /* num updates */
+ out_uint16_le(s, x);
+ out_uint16_le(s, y + i);
+ out_uint16_le(s, (x + cx) - 1);
+ out_uint16_le(s, (y + i + lines_sending) - 1);
+ out_uint16_le(s, bitmap->width + e);
+ out_uint16_le(s, lines_sending);
+ out_uint16_le(s, bitmap->bpp); /* bpp */
+ out_uint16_le(s, 0); /* compress */
+ out_uint16_le(s, (line_size + e * Bpp) * lines_sending); /* bufsize */
+ q = p;
+ for (j = 0; j < lines_sending; j++)
{
- wnd->owner->notify(wnd->owner, wnd, 100, 1, 0); /* ok */
+ q = q - line_size;
+ out_uint8a(s, q, line_size)
+ out_uint8s(s, e * Bpp);
}
+ s_mark_end(s);
+ xrdp_rdp_send_data(self->rdp_layer, s, RDP_DATA_PDU_UPDATE);
+ i = i + lines_sending;
}
}
- else if (msg == WM_PAINT) /* 3 */
- {
- p = (struct xrdp_painter*)param1;
- if (p != 0)
- {
- p->font->color = wnd->wm->black;
- xrdp_painter_draw_text(p, wnd, 10, 30, "You must be authenticated \
-before using this");
- xrdp_painter_draw_text(p, wnd, 10, 46, "session.");
- xrdp_painter_draw_text(p, wnd, 10, 78, "Enter a valid username in \
-the username edit box.");
- xrdp_painter_draw_text(p, wnd, 10, 94, "Enter the password in \
-the password edit box.");
- xrdp_painter_draw_text(p, wnd, 10, 110, "Both the username and \
-password are case");
- xrdp_painter_draw_text(p, wnd, 10, 126, "sensitive.");
- xrdp_painter_draw_text(p, wnd, 10, 158, "Contact your system \
-administrator if you are");
- xrdp_painter_draw_text(p, wnd, 10, 174, "having problems \
-logging on.");
- }
- }
+ free_stream(s);
return 0;
}
@@ -207,83 +177,6 @@ int xrdp_wm_set_focused(struct xrdp_wm* self, struct xrdp_bitmap* wnd)
}
/*****************************************************************************/
-/* all login screen events go here */
-int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
- struct xrdp_bitmap* sender,
- int msg, int param1, int param2)
-{
- struct xrdp_bitmap* help;
- struct xrdp_bitmap* but;
- struct xrdp_bitmap* b;
- struct xrdp_rect rect;
- int i;
-
- if (wnd->modal_dialog != 0 && msg != 100)
- return 0;
- if (msg == 1) /* click */
- {
- if (sender->id == 1) /* help button */
- {
- /* create help screen */
- help = xrdp_bitmap_create(300, 300, wnd->wm->screen->bpp, 1);
- xrdp_list_insert_item(wnd->wm->screen->child_list, 0, (int)help);
- help->parent = wnd->wm->screen;
- help->owner = wnd;
- wnd->modal_dialog = help;
- help->wm = wnd->wm;
- help->bg_color = wnd->wm->grey;
- help->left = wnd->wm->screen->width / 2 - help->width / 2;
- help->top = wnd->wm->screen->height / 2 - help->height / 2;
- help->notify = xrdp_wm_login_help_notify;
- g_strcpy(help->caption, "Logon help");
- /* ok button */
- but = xrdp_bitmap_create(60, 25, wnd->wm->screen->bpp, 3);
- xrdp_list_insert_item(help->child_list, 0, (int)but);
- but->parent = help;
- but->owner = help;
- but->wm = wnd->wm;
- but->left = 120;
- but->top = 260;
- but->id = 1;
- but->tab_stop = 1;
- g_strcpy(but->caption, "OK");
- /* draw it */
- help->focused_control = but;
- //wnd->wm->focused_window = help;
- xrdp_bitmap_invalidate(help, 0);
- xrdp_wm_set_focused(wnd->wm, help);
- //xrdp_bitmap_invalidate(wnd->focused_control, 0);
- }
- else if (sender->id == 2) /* cancel button */
- {
- /*if (wnd != 0)
- if (wnd->wm != 0)
- if (wnd->wm->pro_layer != 0)
- wnd->wm->pro_layer->term = 1;*/
- }
- }
- else if (msg == 2) /* mouse move */
- {
- }
- else if (msg == 100) /* modal result is done */
- {
- i = xrdp_list_index_of(wnd->wm->screen->child_list, (int)sender);
- if (i >= 0)
- {
- b = (struct xrdp_bitmap*)
- xrdp_list_get_item(wnd->wm->screen->child_list, i);
- xrdp_list_remove_item(sender->wm->screen->child_list, i);
- MAKERECT(rect, b->left, b->top, b->width, b->height);
- xrdp_bitmap_invalidate(wnd->wm->screen, &rect);
- xrdp_bitmap_delete(sender);
- wnd->modal_dialog = 0;
- xrdp_wm_set_focused(wnd->wm, wnd);
- }
- }
- return 0;
-}
-
-/*****************************************************************************/
int xrdp_set_cursor(struct xrdp_wm* self, int cache_idx)
{
struct stream* s;
@@ -326,28 +219,20 @@ int xrdp_wm_get_pixel(char* data, int x, int y, int width, int bpp)
return 0;
}
-
/*****************************************************************************/
-/* send a cursor from a file */
-int xrdp_send_cursor(struct xrdp_wm* self, char* file_name, int cache_idx)
+int xrdp_wm_load_cursor(struct xrdp_wm* self, char* file_name, char* data,
+ char* mask, int* x, int* y)
{
int fd;
+ int bpp;
int w;
int h;
- int x;
- int y;
- int bpp;
int i;
int j;
- int rv;
int pixel;
int palette[16];
struct stream* fs;
- struct stream* s;
- rv = 1;
- make_stream(s);
- init_stream(s, 8192);
make_stream(fs);
init_stream(fs, 8192);
fd = g_file_open(file_name);
@@ -357,23 +242,13 @@ int xrdp_send_cursor(struct xrdp_wm* self, char* file_name, int cache_idx)
in_uint8(fs, w);
in_uint8(fs, h);
in_uint8s(fs, 2);
- in_uint16_le(fs, x);
- in_uint16_le(fs, y);
+ in_uint16_le(fs, *x);
+ in_uint16_le(fs, *y);
in_uint8s(fs, 22);
in_uint8(fs, bpp);
in_uint8s(fs, 25);
if (w == 32 && h == 32)
{
- xrdp_rdp_init_data(self->rdp_layer, s);
- out_uint16_le(s, RDP_POINTER_COLOR);
- out_uint16_le(s, 0); /* pad */
- out_uint16_le(s, cache_idx); /* cache_idx */
- out_uint16_le(s, x);
- out_uint16_le(s, y);
- out_uint16_le(s, w);
- out_uint16_le(s, h);
- out_uint16_le(s, 128);
- out_uint16_le(s, 3072);
if (bpp == 1)
{
in_uint8a(fs, palette, 8);
@@ -382,9 +257,12 @@ int xrdp_send_cursor(struct xrdp_wm* self, char* file_name, int cache_idx)
for (j = 0; j < 32; j++)
{
pixel = palette[xrdp_wm_get_pixel(fs->p, j, i, 32, 1)];
- out_uint8(s, pixel);
- out_uint8(s, pixel >> 8);
- out_uint8(s, pixel >> 16);
+ *data = pixel;
+ data++;
+ *data = pixel >> 8;
+ data++;
+ *data = pixel >> 16;
+ data++;
}
}
in_uint8s(fs, 128);
@@ -396,28 +274,71 @@ int xrdp_send_cursor(struct xrdp_wm* self, char* file_name, int cache_idx)
{
for (j = 0; j < 32; j++)
{
- pixel = palette[xrdp_wm_get_pixel(fs->p, j, i, 32, 4)];
- out_uint8(s, pixel);
- out_uint8(s, pixel >> 8);
- out_uint8(s, pixel >> 16);
+ pixel = palette[xrdp_wm_get_pixel(fs->p, j, i, 32, 1)];
+ *data = pixel;
+ data++;
+ *data = pixel >> 8;
+ data++;
+ *data = pixel >> 16;
+ data++;
}
}
in_uint8s(fs, 512);
}
- out_uint8a(s, fs->p, 128); /* mask */
- s_mark_end(s);
- xrdp_rdp_send_data(self->rdp_layer, s, RDP_DATA_PDU_POINTER);
- rv = 0;
+ g_memcpy(mask, fs->p, 128); /* mask */
}
- free_stream(s);
free_stream(fs);
- return rv;
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_wm_send_cursor(struct xrdp_wm* self, int cache_idx,
+ char* data, char* mask, int x, int y)
+{
+ struct stream* s;
+ char* p;
+ int i;
+ int j;
+
+ make_stream(s);
+ init_stream(s, 8192);
+ xrdp_rdp_init_data(self->rdp_layer, s);
+ out_uint16_le(s, RDP_POINTER_COLOR);
+ out_uint16_le(s, 0); /* pad */
+ out_uint16_le(s, cache_idx); /* cache_idx */
+ out_uint16_le(s, x);
+ out_uint16_le(s, y);
+ out_uint16_le(s, 32);
+ out_uint16_le(s, 32);
+ out_uint16_le(s, 128);
+ out_uint16_le(s, 3072);
+ p = data;
+ for (i = 0; i < 32; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ out_uint8(s, *p);
+ p++;
+ out_uint8(s, *p);
+ p++;
+ out_uint8(s, *p);
+ p++;
+ }
+ }
+ out_uint8a(s, mask, 128); /* mask */
+ s_mark_end(s);
+ xrdp_rdp_send_data(self->rdp_layer, s, RDP_DATA_PDU_POINTER);
+ free_stream(s);
+ return 0;
}
/*****************************************************************************/
int xrdp_wm_init(struct xrdp_wm* self)
{
- struct xrdp_bitmap* but;
+ char data[32 * (32 * 3)];
+ char mask[32 * (32 / 8)];
+ int x;
+ int y;
if (self->screen->bpp == 8)
{
@@ -473,147 +394,8 @@ int xrdp_wm_init(struct xrdp_wm* self)
self->red = COLOR24(0xff, 0x00, 0x00);
self->green = COLOR24(0x00, 0xff, 0x00);
}
- /* draw login window */
- self->login_window = xrdp_bitmap_create(400, 200, self->screen->bpp,
- WND_TYPE_WND);
- xrdp_list_add_item(self->screen->child_list, (int)self->login_window);
- self->login_window->parent = self->screen;
- self->login_window->owner = self->screen;
- self->login_window->wm = self;
- self->login_window->bg_color = self->grey;
- self->login_window->left = self->screen->width / 2 -
- self->login_window->width / 2;
- self->login_window->top = self->screen->height / 2 -
- self->login_window->height / 2;
- self->login_window->notify = xrdp_wm_login_notify;
- g_strcpy(self->login_window->caption, "Logon to xrdp");
-
- /* image */
- but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE);
- xrdp_bitmap_load(but, "xrdp256.bmp", self->palette);
- but->parent = self->screen;
- but->owner = self->screen;
- but->wm = self;
- but->left = self->screen->width - but->width;
- but->top = self->screen->height - but->height;
- xrdp_list_add_item(self->screen->child_list, (int)but);
-
- /* image */
- but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE);
- xrdp_bitmap_load(but, "ad256.bmp", self->palette);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->wm = self;
- but->left = 10;
- but->top = 30;
- xrdp_list_add_item(self->login_window->child_list, (int)but);
-
- /* label */
- but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL);
- xrdp_list_add_item(self->login_window->child_list, (int)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->wm = self;
- but->left = 155;
- but->top = 50;
- g_strcpy(but->caption, "Username");
-
- /* edit */
- but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT);
- xrdp_list_add_item(self->login_window->child_list, (int)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->wm = self;
- but->left = 220;
- but->top = 50;
- but->id = 4;
- but->cursor = 1;
- but->tab_stop = 1;
- self->login_window->focused_control = but;
- /* label */
- but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL);
- xrdp_list_add_item(self->login_window->child_list, (int)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->wm = self;
- but->left = 155;
- but->top = 80;
- g_strcpy(but->caption, "Password");
-
- /* edit */
- but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT);
- xrdp_list_add_item(self->login_window->child_list, (int)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->wm = self;
- but->left = 220;
- but->top = 80;
- but->id = 5;
- but->cursor = 1;
- but->tab_stop = 1;
- but->password_char = '*';
-
- /* label */
- but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL);
- xrdp_list_add_item(self->login_window->child_list, (int)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->wm = self;
- but->left = 155;
- but->top = 110;
- g_strcpy(but->caption, "Module");
-
- /* combo */
- but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_COMBO);
- xrdp_list_add_item(self->login_window->child_list, (int)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->wm = self;
- but->left = 220;
- but->top = 110;
- but->id = 6;
- but->tab_stop = 1;
- xrdp_list_add_item(but->string_list, (int)g_strdup("Test"));
- xrdp_list_add_item(but->string_list, (int)g_strdup("VNC"));
- xrdp_list_add_item(but->string_list, (int)g_strdup("X11"));
- xrdp_list_add_item(but->string_list, (int)g_strdup("Console"));
-
- /* button */
- but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON);
- xrdp_list_add_item(self->login_window->child_list, (int)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->wm = self;
- but->left = 180;
- but->top = 160;
- but->id = 3;
- g_strcpy(but->caption, "OK");
- but->tab_stop = 1;
-
- /* button */
- but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON);
- xrdp_list_add_item(self->login_window->child_list, (int)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->wm = self;
- but->left = 250;
- but->top = 160;
- but->id = 2;
- g_strcpy(but->caption, "Cancel");
- but->tab_stop = 1;
-
- /* button */
- but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON);
- xrdp_list_add_item(self->login_window->child_list, (int)but);
- but->parent = self->login_window;
- but->owner = self->login_window;
- but->wm = self;
- but->left = 320;
- but->top = 160;
- but->id = 1;
- g_strcpy(but->caption, "Help");
- but->tab_stop = 1;
+ xrdp_login_wnd_create(self);
/* clear screen */
self->screen->bg_color = self->black;
@@ -621,8 +403,10 @@ int xrdp_wm_init(struct xrdp_wm* self)
xrdp_wm_set_focused(self, self->login_window);
- xrdp_send_cursor(self, "cursor1.cur", 1);
- xrdp_send_cursor(self, "cursor0.cur", 0);
+ xrdp_wm_load_cursor(self, "cursor1.cur", data, mask, &x, &y);
+ xrdp_wm_send_cursor(self, 1, data, mask, x, y);
+ xrdp_wm_load_cursor(self, "cursor0.cur", data, mask, &x, &y);
+ xrdp_wm_send_cursor(self, 0, data, mask, x, y);
return 0;
}
@@ -632,7 +416,7 @@ int xrdp_wm_init(struct xrdp_wm* self)
/* putting the rects in region */
int xrdp_wm_get_vis_region(struct xrdp_wm* self, struct xrdp_bitmap* bitmap,
int x, int y, int cx, int cy,
- struct xrdp_region* region)
+ struct xrdp_region* region, int clip_children)
{
int i;
struct xrdp_bitmap* p;
@@ -652,16 +436,17 @@ int xrdp_wm_get_vis_region(struct xrdp_wm* self, struct xrdp_bitmap* bitmap,
a.right = MIN(self->screen->left + self->screen->width, a.right);
a.bottom = MIN(self->screen->top + self->screen->height, a.bottom);
xrdp_region_add_rect(region, &a);
- if (bitmap == self->screen)
- return 0;
- /* loop through all windows in z order */
- for (i = 0; i < self->screen->child_list->count; i++)
+ if (clip_children)
{
- p = (struct xrdp_bitmap*)xrdp_list_get_item(self->screen->child_list, i);
- if (p == bitmap || p == bitmap->parent)
- return 0;
- MAKERECT(b, p->left, p->top, p->width, p->height);
- xrdp_region_subtract_rect(region, &b);
+ /* loop through all windows in z order */
+ for (i = 0; i < self->screen->child_list->count; i++)
+ {
+ p = (struct xrdp_bitmap*)xrdp_list_get_item(self->screen->child_list, i);
+ if (p == bitmap || p == bitmap->parent)
+ return 0;
+ MAKERECT(b, p->left, p->top, p->width, p->height);
+ xrdp_region_subtract_rect(region, &b);
+ }
}
return 0;
}
@@ -697,6 +482,7 @@ struct xrdp_bitmap* xrdp_wm_at_pos(struct xrdp_bitmap* wnd, int x, int y,
/*****************************************************************************/
int xrdp_wm_xor_pat(struct xrdp_wm* self, int x, int y, int cx, int cy)
{
+ self->painter->clip_children = 0;
self->painter->rop = 0x5a;
xrdp_painter_begin_update(self->painter);
self->painter->use_clip = 0;
@@ -724,6 +510,7 @@ int xrdp_wm_xor_pat(struct xrdp_wm* self, int x, int y, int cx, int cy)
cy - 10);
xrdp_painter_end_update(self->painter);
self->painter->rop = 0xcc;
+ self->painter->clip_children = 1;
return 0;
}
@@ -843,7 +630,6 @@ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y)
int boxx;
int boxy;
- DEBUG(("in mouse move\n\r"));
if (self == 0)
return 0;
if (x < 0)
@@ -854,6 +640,8 @@ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y)
x = self->screen->width;
if (y >= self->screen->height)
y = self->screen->height;
+ self->mouse_x = x;
+ self->mouse_y = y;
if (self->dragging)
{
xrdp_painter_begin_update(self->painter);
@@ -868,8 +656,17 @@ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y)
xrdp_wm_xor_pat(self, boxx, boxy, self->draggingcx, self->draggingcy);
self->draggingxorstate = 1;
xrdp_painter_end_update(self->painter);
+ return 0;
}
b = xrdp_wm_at_pos(self->screen, x, y, 0);
+ if (b == 0)
+ {
+ if (self->mod != 0) /* if screen is mod controled */
+ {
+ if (self->mod->mod_event != 0)
+ self->mod->mod_event((int)self->mod, WM_MOUSEMOVE, x, y);
+ }
+ }
if (self->button_down != 0)
{
if (b == self->button_down && self->button_down->state == 0)
@@ -900,7 +697,6 @@ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y)
b->notify(b->owner, b, 2, x, y);
}
}
- DEBUG(("out mouse move\n\r"));
return 0;
}
@@ -966,6 +762,41 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
}
wnd = 0;
control = xrdp_wm_at_pos(self->screen, x, y, &wnd);
+ if (control == 0)
+ {
+ if (self->mod != 0) /* if screen is mod controled */
+ {
+ if (self->mod->mod_event != 0)
+ {
+ if (but == 1 && down)
+ self->mod->mod_event((int)self->mod, WM_LBUTTONDOWN, x, y);
+ else if (but == 1 && !down)
+ self->mod->mod_event((int)self->mod, WM_LBUTTONUP, x, y);
+ if (but == 2 && down)
+ self->mod->mod_event((int)self->mod, WM_RBUTTONDOWN, x, y);
+ else if (but == 2 && !down)
+ self->mod->mod_event((int)self->mod, WM_RBUTTONUP, x, y);
+ if (but == 3 && down)
+ self->mod->mod_event((int)self->mod, WM_BUTTON3DOWN, x, y);
+ else if (but == 3 && !down)
+ self->mod->mod_event((int)self->mod, WM_BUTTON3UP, x, y);
+ if (but == 4)
+ {
+ self->mod->mod_event((int)self->mod, WM_BUTTON4DOWN,
+ self->mouse_x, self->mouse_y);
+ self->mod->mod_event((int)self->mod, WM_BUTTON4UP,
+ self->mouse_x, self->mouse_y);
+ }
+ if (but == 5)
+ {
+ self->mod->mod_event((int)self->mod, WM_BUTTON5DOWN,
+ self->mouse_x, self->mouse_y);
+ self->mod->mod_event((int)self->mod, WM_BUTTON5UP,
+ self->mouse_x, self->mouse_y);
+ }
+ }
+ }
+ }
if (self->popup_wnd != 0)
{
if (self->popup_wnd == control && !down)
@@ -1056,6 +887,7 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
/* no matter what, mouse is up, reset button_down */
if (but == 1 && !down && self->button_down != 0)
self->button_down = 0;
+
return 0;
}
@@ -1063,7 +895,9 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
int xrdp_wm_key(struct xrdp_wm* self, int device_flags, int scan_code)
{
int msg;
+ char c;
+ scan_code = scan_code % 128;
if (self->popup_wnd != 0)
{
xrdp_wm_clear_popup(self);
@@ -1071,12 +905,12 @@ int xrdp_wm_key(struct xrdp_wm* self, int device_flags, int scan_code)
}
if (device_flags & 0x8000) /* key up */
{
- self->keys[scan_code % 128] = 0;
+ self->keys[scan_code] = 0;
msg = WM_KEYUP;
}
else /* key down */
{
- self->keys[scan_code % 128] = 1;
+ self->keys[scan_code] = 1;
msg = WM_KEYDOWN;
switch (scan_code)
{
@@ -1085,7 +919,21 @@ int xrdp_wm_key(struct xrdp_wm* self, int device_flags, int scan_code)
case 70: self->scroll_lock = !self->scroll_lock; break; /* scroll lock */
}
}
- if (self->focused_window != 0)
+ if (self->mod != 0)
+ {
+ if (self->mod->mod_event != 0)
+ {
+ c = get_char_from_scan_code(device_flags, scan_code, self->keys,
+ self->caps_lock,
+ self->num_lock,
+ self->scroll_lock);
+ if (c != 0)
+ self->mod->mod_event((int)self->mod, msg, c, 0xffff);
+ else
+ self->mod->mod_event((int)self->mod, msg, scan_code, device_flags);
+ }
+ }
+ else if (self->focused_window != 0)
{
xrdp_bitmap_def_proc(self->focused_window,
msg, scan_code, device_flags);