diff options
-rw-r--r-- | common/defines.h | 13 | ||||
-rw-r--r-- | xrdp/xrdp.ini | 10 | ||||
-rw-r--r-- | xrdp/xrdp_bitmap.c | 27 | ||||
-rw-r--r-- | xrdp/xrdp_login_wnd.c | 52 | ||||
-rw-r--r-- | xrdp/xrdp_types.h | 16 | ||||
-rw-r--r-- | xrdp/xrdp_wm.c | 170 |
6 files changed, 208 insertions, 80 deletions
diff --git a/common/defines.h b/common/defines.h index a6f6e303..8e2328a7 100644 --- a/common/defines.h +++ b/common/defines.h @@ -66,6 +66,19 @@ #define COLOR16(r, g, b) ((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3)) #define COLOR24RGB(r, g, b) (((r) << 16) | ((g) << 8) | (b)) #define COLOR24BGR(r, g, b) (((b) << 16) | ((g) << 8) | (r)) +#define HRED(c) ((c & 0xff0000) >> 16) +#define HGREEN(c) ((c & 0x00ff00) >> 8) +#define HBLUE(c) ((c & 0x0000ff)) +#define HCOLOR(bpp,c) \ +( \ + (bpp==8?COLOR8(HRED(c),HGREEN(c),HBLUE(c)): \ + (bpp==15?COLOR15(HRED(c),HGREEN(c),HBLUE(c)): \ + (bpp==16?COLOR16(HRED(c),HGREEN(c),HBLUE(c)): \ + (bpp==24?COLOR24BGR(HRED(c),HGREEN(c),HBLUE(c)):c) \ + ) \ + ) \ + ) \ +) #define SPLITCOLOR15(r, g, b, c) \ { \ r = (((c) >> 7) & 0xf8) | (((c) >> 12) & 0x7); \ diff --git a/xrdp/xrdp.ini b/xrdp/xrdp.ini index 1e4dbe59..e5e6e3d9 100644 --- a/xrdp/xrdp.ini +++ b/xrdp/xrdp.ini @@ -5,6 +5,16 @@ bitmap_compression=yes port=3389 crypt_level=low channel_code=1 +#black=000000 +#grey=d6d3ce +#dark_grey=808080 +#blue=08246b +#dark_blue=08246b +#white=ffffff +#red=ff0000 +#green=00ff00 +#background=626c72 + [xrdp1] name=sesman-Xvnc diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c index 4ed4a230..df2f9e51 100644 --- a/xrdp/xrdp_bitmap.c +++ b/xrdp/xrdp_bitmap.c @@ -1190,10 +1190,10 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) xrdp_painter_fill_rect(painter, self, self->width - 1, 0, 1, self->height); /* black left line */ painter->fg_color = self->wm->black; - xrdp_painter_fill_rect(painter, self, 1, 1, 1, self->height - 2); + xrdp_painter_fill_rect(painter, self, 1, 1, 1, self->height - 3); /* black top line */ painter->fg_color = self->wm->black; - xrdp_painter_fill_rect(painter, self, 1, 1, self->width - 2, 1); + xrdp_painter_fill_rect(painter, self, 1, 1, self->width - 3, 1); /* draw text */ painter->fg_color = self->wm->black; if (self->password_char != 0) @@ -1267,10 +1267,10 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) xrdp_painter_fill_rect(painter, self, self->width - 1, 0, 1, self->height); /* black left line */ painter->fg_color = self->wm->black; - xrdp_painter_fill_rect(painter, self, 1, 1, 1, self->height - 2); + xrdp_painter_fill_rect(painter, self, 1, 1, 1, self->height - 3); /* black top line */ painter->fg_color = self->wm->black; - xrdp_painter_fill_rect(painter, self, 1, 1, self->width - 2, 1); + xrdp_painter_fill_rect(painter, self, 1, 1, self->width - 3, 1); /* draw text */ if (self->parent->focused_control == self) { @@ -1287,13 +1287,28 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) y = 2; w = (self->width - x) - 2; h = self->height - 4; + /* looks better with a background around */ + painter->fg_color = self->wm->grey; + xrdp_painter_fill_rect(painter, self, x, y, w, h); if (self->state == BUTTON_STATE_UP) /* 0 */ { - xrdp_bitmap_draw_button(self, painter, x, y, w, h, 0); + xrdp_bitmap_draw_button(self, painter, x+1, y+1, w-1, h-1, 0); } else { - xrdp_bitmap_draw_button(self, painter, x, y, w, h, 1); + xrdp_bitmap_draw_button(self, painter, x+1, y+1, w-1, h-1, 1); + } + /* draw the arrow */ + w = w / 2; + x = x + (w / 2) + 1; + h = (h / 2) + 2; + y = y + (h / 2) + 1; + painter->fg_color = self->wm->black; + for (i=w; i>0; i=i-2) + { + xrdp_painter_fill_rect(painter, self, x, y, i, 1); + y++; + x = x + 1; } } else if (self->type == WND_TYPE_SPECIAL) /* 8 special */ diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c index 0d8ee1fd..2b394837 100644 --- a/xrdp/xrdp_login_wnd.c +++ b/xrdp/xrdp_login_wnd.c @@ -132,7 +132,7 @@ xrdp_wm_help_clicked(struct xrdp_bitmap* wnd) struct xrdp_bitmap* but; /* create help screen */ - help = xrdp_bitmap_create(340, 300, wnd->wm->screen->bpp, + help = xrdp_bitmap_create(DEFAULT_WND_HELP_W, DEFAULT_WND_HELP_H, wnd->wm->screen->bpp, WND_TYPE_WND, wnd->wm); list_insert_item(wnd->wm->screen->child_list, 0, (long)help); help->parent = wnd->wm->screen; @@ -144,13 +144,13 @@ xrdp_wm_help_clicked(struct xrdp_bitmap* wnd) help->notify = xrdp_wm_login_help_notify; set_string(&help->caption1, "Login help"); /* ok button */ - but = xrdp_bitmap_create(60, 25, wnd->wm->screen->bpp, + but = xrdp_bitmap_create(DEFAULT_BUTTON_W, DEFAULT_BUTTON_H, wnd->wm->screen->bpp, WND_TYPE_BUTTON, wnd->wm); list_insert_item(help->child_list, 0, (long)but); but->parent = help; but->owner = help; - but->left = 140; - but->top = 260; + but->left = ((DEFAULT_WND_HELP_W / 2) - (DEFAULT_BUTTON_W / 2)); /* center */ + but->top = DEFAULT_WND_HELP_H - DEFAULT_BUTTON_H - 15; but->id = 1; but->tab_stop = 1; set_string(&but->caption1, "OK"); @@ -261,28 +261,28 @@ xrdp_wm_show_edits(struct xrdp_wm* self, struct xrdp_bitmap* combo) if (g_strncmp("ask", value, 3) == 0) { /* label */ - b = xrdp_bitmap_create(70, 20, self->screen->bpp, + b = xrdp_bitmap_create(70, DEFAULT_EDIT_H, self->screen->bpp, WND_TYPE_LABEL, self); list_insert_item(self->login_window->child_list, insert_index, (long)b); insert_index++; b->parent = self->login_window; b->owner = self->login_window; - b->left = self->login_window->width >= 400 ? 155 : 5; - b->top = 60 + 25 * count; + b->left = self->login_window->width >= DEFAULT_WND_LOGIN_W ? 155 : 5; + b->top = DEFAULT_ELEMENT_TOP + DEFAULT_COMBO_H + 5 + (DEFAULT_EDIT_H+5) * count; b->id = 100 + 2 * count; name = (char*)list_get_item(mod->names, index); set_string(&b->caption1, name); /* edit */ - b = xrdp_bitmap_create(140, 20, self->screen->bpp, + b = xrdp_bitmap_create(DEFAULT_EDIT_W, DEFAULT_EDIT_H, self->screen->bpp, WND_TYPE_EDIT, self); list_insert_item(self->login_window->child_list, insert_index, (long)b); insert_index++; b->parent = self->login_window; b->owner = self->login_window; - b->left = self->login_window->width >= 400 ? 230 : 70; - b->top = 60 + 25 * count; + b->left = self->login_window->width >= DEFAULT_WND_LOGIN_W ? DEFAULT_WND_LOGIN_W - DEFAULT_EDIT_W - 30 : 70; + b->top = DEFAULT_ELEMENT_TOP + DEFAULT_COMBO_H + 5 + (DEFAULT_EDIT_H+5) * count; b->id = 100 + 2 * count + 1; b->pointer = 1; b->tab_stop = 1; @@ -455,8 +455,8 @@ xrdp_login_wnd_create(struct xrdp_wm* self) int log_height; int regular; - log_width = 400; - log_height = 200; + log_width = DEFAULT_WND_LOGIN_W; + log_height = DEFAULT_WND_LOGIN_H; regular = 1; if (self->screen->width < log_width) { @@ -521,44 +521,44 @@ xrdp_login_wnd_create(struct xrdp_wm* self) } /* label */ - but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL, self); + but = xrdp_bitmap_create(60, DEFAULT_EDIT_H, self->screen->bpp, WND_TYPE_LABEL, self); list_add_item(self->login_window->child_list, (long)but); but->parent = self->login_window; but->owner = self->login_window; but->left = regular ? 155 : 5; - but->top = 35; + but->top = DEFAULT_ELEMENT_TOP; set_string(&but->caption1, "Module"); /* combo */ - combo = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_COMBO, self); + combo = xrdp_bitmap_create(DEFAULT_COMBO_W, DEFAULT_COMBO_H, self->screen->bpp, WND_TYPE_COMBO, self); list_add_item(self->login_window->child_list, (long)combo); combo->parent = self->login_window; combo->owner = self->login_window; - combo->left = regular ? 230 : 70; - combo->top = 35; + combo->left = regular ? DEFAULT_WND_LOGIN_W - DEFAULT_COMBO_W - 30 : 70; + combo->top = DEFAULT_ELEMENT_TOP; combo->id = 6; combo->tab_stop = 1; xrdp_wm_login_fill_in_combo(self, combo); /* button */ - but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON, self); + but = xrdp_bitmap_create(DEFAULT_BUTTON_W, DEFAULT_BUTTON_H, self->screen->bpp, WND_TYPE_BUTTON, self); list_add_item(self->login_window->child_list, (long)but); but->parent = self->login_window; but->owner = self->login_window; - but->left = regular ? 180 : 30; - but->top = 160; + but->left = regular ? DEFAULT_WND_LOGIN_W - ((DEFAULT_BUTTON_W+10)*3) - 10 : 30; + but->top = DEFAULT_WND_LOGIN_H - DEFAULT_BUTTON_H - 15; but->id = 3; set_string(&but->caption1, "OK"); but->tab_stop = 1; self->login_window->default_button = but; /* button */ - but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON, self); + but = xrdp_bitmap_create(DEFAULT_BUTTON_W, DEFAULT_BUTTON_H, self->screen->bpp, WND_TYPE_BUTTON, self); list_add_item(self->login_window->child_list, (long)but); but->parent = self->login_window; but->owner = self->login_window; - but->left = regular ? 250 : ((log_width - 30) - 60); - but->top = 160; + but->left = regular ? DEFAULT_WND_LOGIN_W - ((DEFAULT_BUTTON_W+10)*2) - 10 : ((log_width - 30) - DEFAULT_BUTTON_W); + but->top = DEFAULT_WND_LOGIN_H - DEFAULT_BUTTON_H - 15; but->id = 2; set_string(&but->caption1, "Cancel"); but->tab_stop = 1; @@ -567,12 +567,12 @@ xrdp_login_wnd_create(struct xrdp_wm* self) if (regular) { /* button */ - but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON, self); + but = xrdp_bitmap_create(DEFAULT_BUTTON_W, DEFAULT_BUTTON_H, self->screen->bpp, WND_TYPE_BUTTON, self); list_add_item(self->login_window->child_list, (long)but); but->parent = self->login_window; but->owner = self->login_window; - but->left = 320; - but->top = 160; + but->left = DEFAULT_WND_LOGIN_W - (DEFAULT_BUTTON_W+10) - 10; + but->top = DEFAULT_WND_LOGIN_H - DEFAULT_BUTTON_H - 15; but->id = 1; set_string(&but->caption1, "Help"); but->tab_stop = 1; diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index 7d470e08..eb4d0ad0 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -227,6 +227,7 @@ struct xrdp_wm int white; int red; int green; + int background; /* dragging info */ int dragging; int draggingx; @@ -370,6 +371,21 @@ struct xrdp_bitmap #define NUM_FONTS 0x4e00 #define DEFAULT_FONT_NAME "sans-10.fv1" +#define DEFAULT_ELEMENT_TOP 35 +#define DEFAULT_BUTTON_W 60 +#define DEFAULT_BUTTON_H 23 +#define DEFAULT_COMBO_W 140 +#define DEFAULT_COMBO_H 21 +#define DEFAULT_EDIT_W 140 +#define DEFAULT_EDIT_H 21 +#define DEFAULT_WND_LOGIN_W 400 +#define DEFAULT_WND_LOGIN_H 200 +#define DEFAULT_WND_HELP_W 340 +#define DEFAULT_WND_HELP_H 300 +#define DEFAULT_WND_LOG_W 400 +#define DEFAULT_WND_LOG_H 400 +#define DEFAULT_WND_SPECIAL_H 100 + /* font */ struct xrdp_font { diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 7500f38a..8c36abf2 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -284,6 +284,30 @@ xrdp_wm_set_pointer(struct xrdp_wm* self, int cache_idx) } /*****************************************************************************/ +/* convert hex string to int */ +unsigned int xrdp_wm_htoi (const char *ptr) +{ + unsigned int value = 0; + char ch = *ptr; + + while (ch == ' ' || ch == '\t') + ch = *(++ptr); + + for (;;) + { + if (ch >= '0' && ch <= '9') + value = (value << 4) + (ch - '0'); + else if (ch >= 'A' && ch <= 'F') + value = (value << 4) + (ch - 'A' + 10); + else if (ch >= 'a' && ch <= 'f') + value = (value << 4) + (ch - 'a' + 10); + else + return value; + ch = *(++ptr); + } +} + +/*****************************************************************************/ int APP_CC xrdp_wm_load_static_colors(struct xrdp_wm* self) { @@ -291,6 +315,97 @@ xrdp_wm_load_static_colors(struct xrdp_wm* self) int gindex; int rindex; + int fd; + int index; + char* val; + struct list* names; + struct list* values; + char cfg_file[256]; + + /* initialize with defaults */ + self->black = HCOLOR(self->screen->bpp,0x000000); + self->grey = HCOLOR(self->screen->bpp,0xc0c0c0); + self->dark_grey = HCOLOR(self->screen->bpp,0x808080); + self->blue = HCOLOR(self->screen->bpp,0x0000ff); + self->dark_blue = HCOLOR(self->screen->bpp,0x00007f); + self->white = HCOLOR(self->screen->bpp,0xffffff); + self->red = HCOLOR(self->screen->bpp,0xff0000); + self->green = HCOLOR(self->screen->bpp,0x00ff00); + self->background = HCOLOR(self->screen->bpp,0x000000); + + /* now load them from the globals in xrdp.ini if defined */ + g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH); + fd = g_file_open(cfg_file); + if (fd > 0) + { + names = list_create(); + names->auto_free = 1; + values = list_create(); + values->auto_free = 1; + if (file_read_section(fd, "globals", names, values) == 0) + { + for (index = 0; index < names->count; index++) + { + val = (char*)list_get_item(names, index); + if (val != 0) + { + if (g_strcasecmp(val, "black") == 0) + { + val = (char*)list_get_item(values, index); + self->black = HCOLOR(self->screen->bpp,xrdp_wm_htoi(val)); + } + else if (g_strcasecmp(val, "grey") == 0) + { + val = (char*)list_get_item(values, index); + self->grey = HCOLOR(self->screen->bpp,xrdp_wm_htoi(val)); + } + else if (g_strcasecmp(val, "dark_grey") == 0) + { + val = (char*)list_get_item(values, index); + self->dark_grey = HCOLOR(self->screen->bpp,xrdp_wm_htoi(val)); + } + else if (g_strcasecmp(val, "blue") == 0) + { + val = (char*)list_get_item(values, index); + self->blue = HCOLOR(self->screen->bpp,xrdp_wm_htoi(val)); + } + else if (g_strcasecmp(val, "dark_blue") == 0) + { + val = (char*)list_get_item(values, index); + self->dark_blue = HCOLOR(self->screen->bpp,xrdp_wm_htoi(val)); + } + else if (g_strcasecmp(val, "white") == 0) + { + val = (char*)list_get_item(values, index); + self->white = HCOLOR(self->screen->bpp,xrdp_wm_htoi(val)); + } + else if (g_strcasecmp(val, "red") == 0) + { + val = (char*)list_get_item(values, index); + self->red = HCOLOR(self->screen->bpp,xrdp_wm_htoi(val)); + } + else if (g_strcasecmp(val, "green") == 0) + { + val = (char*)list_get_item(values, index); + self->green = HCOLOR(self->screen->bpp,xrdp_wm_htoi(val)); + } + else if (g_strcasecmp(val, "background") == 0) + { + val = (char*)list_get_item(values, index); + self->background = HCOLOR(self->screen->bpp,xrdp_wm_htoi(val)); + } + } + } + } + list_delete(names); + list_delete(values); + g_file_close(fd); + } + else + { + g_writeln("xrdp_wm_load_static_colors: Could not read xrdp.ini file %s", cfg_file); + } + if (self->screen->bpp == 8) { /* rgb332 */ @@ -307,49 +422,8 @@ xrdp_wm_load_static_colors(struct xrdp_wm* self) } } } - self->black = COLOR8(0, 0, 0); - self->grey = COLOR8(0xc0, 0xc0, 0xc0); - self->dark_grey = COLOR8(0x80, 0x80, 0x80); - self->blue = COLOR8(0x00, 0x00, 0xff); - self->dark_blue = COLOR8(0x00, 0x00, 0x7f); - self->white = COLOR8(0xff, 0xff, 0xff); - self->red = COLOR8(0xff, 0x00, 0x00); - self->green = COLOR8(0x00, 0xff, 0x00); xrdp_wm_send_palette(self); } - else if (self->screen->bpp == 15) - { - self->black = COLOR15(0, 0, 0); - self->grey = COLOR15(0xc0, 0xc0, 0xc0); - self->dark_grey = COLOR15(0x80, 0x80, 0x80); - self->blue = COLOR15(0x00, 0x00, 0xff); - self->dark_blue = COLOR15(0x00, 0x00, 0x7f); - self->white = COLOR15(0xff, 0xff, 0xff); - self->red = COLOR15(0xff, 0x00, 0x00); - self->green = COLOR15(0x00, 0xff, 0x00); - } - else if (self->screen->bpp == 16) - { - self->black = COLOR16(0, 0, 0); - self->grey = COLOR16(0xc0, 0xc0, 0xc0); - self->dark_grey = COLOR16(0x80, 0x80, 0x80); - self->blue = COLOR16(0x00, 0x00, 0xff); - self->dark_blue = COLOR16(0x00, 0x00, 0x7f); - self->white = COLOR16(0xff, 0xff, 0xff); - self->red = COLOR16(0xff, 0x00, 0x00); - self->green = COLOR16(0x00, 0xff, 0x00); - } - else if (self->screen->bpp == 24) - { - self->black = COLOR24BGR(0, 0, 0); - self->grey = COLOR24BGR(0xc0, 0xc0, 0xc0); - self->dark_grey = COLOR24BGR(0x80, 0x80, 0x80); - self->blue = COLOR24BGR(0x00, 0x00, 0xff); - self->dark_blue = COLOR24BGR(0x00, 0x00, 0x7f); - self->white = COLOR24BGR(0xff, 0xff, 0xff); - self->red = COLOR24BGR(0xff, 0x00, 0x00); - self->green = COLOR24BGR(0x00, 0xff, 0x00); - } return 0; } @@ -391,7 +465,7 @@ xrdp_wm_init(struct xrdp_wm* self) xrdp_wm_load_static_colors(self); xrdp_wm_load_static_pointers(self); - self->screen->bg_color = self->black; + self->screen->bg_color = self->background; if (self->session->client_info->rdp_autologin) { g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH); @@ -1200,7 +1274,7 @@ xrdp_wm_pu(struct xrdp_wm* self, struct xrdp_bitmap* control) { return 0; } - self->popup_wnd = xrdp_bitmap_create(control->width, 100, + self->popup_wnd = xrdp_bitmap_create(control->width, DEFAULT_WND_SPECIAL_H, self->screen->bpp, WND_TYPE_SPECIAL, self); self->popup_wnd->popped_from = control; @@ -1455,8 +1529,8 @@ xrdp_wm_log_msg(struct xrdp_wm* self, char* msg) list_add_item(self->log, (long)g_strdup(msg)); if (self->log_wnd == 0) { - w = 400; - h = 400; + w = DEFAULT_WND_LOG_W; + h = DEFAULT_WND_LOG_H; xoffset = 10; yoffset = 10; if (self->screen->width < w) @@ -1480,12 +1554,12 @@ xrdp_wm_log_msg(struct xrdp_wm* self, char* msg) self->log_wnd->top = yoffset; set_string(&(self->log_wnd->caption1), "Connection Log"); /* ok button */ - but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON, self); + but = xrdp_bitmap_create(DEFAULT_BUTTON_W, DEFAULT_BUTTON_H, self->screen->bpp, WND_TYPE_BUTTON, self); list_insert_item(self->log_wnd->child_list, 0, (long)but); but->parent = self->log_wnd; but->owner = self->log_wnd; - but->left = (w - 60) - xoffset; - but->top = (h - 25) - yoffset; + but->left = (w - DEFAULT_BUTTON_W) - xoffset; + but->top = (h - DEFAULT_BUTTON_H) - yoffset; but->id = 1; but->tab_stop = 1; set_string(&but->caption1, "OK"); |