diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index 63276ebb..c595c642 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -283,11 +283,13 @@ rect_contained_by(struct xrdp_rect* in1, int left, int top, int APP_CC check_bounds(struct xrdp_bitmap* b, int* x, int* y, int* cx, int* cy); int APP_CC -add_char_at(char* text, char ch, int index); +add_char_at(char* text, int text_size, twchar ch, int index); int APP_CC -remove_char_at(char* text, int index); +remove_char_at(char* text, int text_size, int index); int APP_CC set_string(char** in_str, const char* in); +int APP_CC +wchar_repeat(twchar* dest, int dest_size_in_wchars, twchar ch, int repeat); /* in lang.c */ int APP_CC diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c index 69dd7e69..a31d3071 100644 --- a/xrdp/xrdp_bitmap.c +++ b/xrdp/xrdp_bitmap.c @@ -888,6 +888,7 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) struct xrdp_rect r1; struct xrdp_rect r2; struct xrdp_painter* painter; + twchar wtext[256]; char text[256]; char* p; @@ -1009,10 +1010,16 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) xrdp_painter_draw_text(painter, self, self->width / 2 - w / 2, self->height / 2 - h / 2, self->caption1); if (self->parent != 0) + { if (self->wm->focused_window == self->parent) + { if (self->parent->focused_control == self) + { xrdp_bitmap_draw_focus_box(self, painter, 4, 4, self->width - 8, self->height - 8); + } + } + } } else if (self->state == BUTTON_STATE_DOWN) /* 1 */ { @@ -1066,13 +1073,15 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) painter->fg_color = self->wm->black; if (self->password_char != 0) { - i = g_strlen(self->caption1); + i = g_mbstowcs(0, self->caption1, 0); g_memset(text, self->password_char, i); text[i] = 0; xrdp_painter_draw_text(painter, self, 4, 2, text); } else + { xrdp_painter_draw_text(painter, self, 4, 2, self->caption1); + } /* draw xor box(cursor) */ if (self->parent != 0) { @@ -1080,11 +1089,16 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) { if (self->password_char != 0) { - g_memset(text, self->password_char, self->edit_pos); - text[self->edit_pos] = 0; + wchar_repeat(wtext, 255, self->password_char, self->edit_pos); + wtext[self->edit_pos] = 0; + g_wcstombs(text, wtext, 255); } else - g_strncpy(text, self->caption1, self->edit_pos); + { + g_mbstowcs(wtext, self->caption1, 255); + wtext[self->edit_pos] = 0; + g_wcstombs(text, wtext, 255); + } w = xrdp_painter_text_width(painter, text); painter->fg_color = self->wm->white; painter->rop = 0x5a; @@ -1134,9 +1148,13 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) xrdp_painter_fill_rect(painter, self, 1, 1, self->width - 2, 1); /* draw text */ if (self->parent->focused_control == self) + { painter->font->color = self->wm->white; + } else + { painter->font->color = self->wm->black; + } xrdp_painter_draw_text(painter, self, 4, 2, (char*)list_get_item(self->string_list, self->item_index)); /* draw button on right */ @@ -1145,9 +1163,13 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) w = (self->width - x) - 2; h = self->height - 4; if (self->state == BUTTON_STATE_UP) /* 0 */ + { xrdp_bitmap_draw_button(self, painter, x, y, w, h, 0); + } else + { xrdp_bitmap_draw_button(self, painter, x, y, w, h, 1); + } } else if (self->type == WND_TYPE_SPECIAL) /* 8 special */ { @@ -1169,7 +1191,9 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) painter->font->color = self->wm->white; } else + { painter->font->color = self->wm->black; + } xrdp_painter_draw_text(painter, self, 2, y, p); y = y + h; } @@ -1177,13 +1201,17 @@ xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) } /* notify */ if (self->notify != 0) + { self->notify(self, self, WM_PAINT, (long)painter, 0); /* 3 */ + } /* draw any child windows in the area */ for (i = 0; i < self->child_list->count; i++) { b = (struct xrdp_bitmap*)list_get_item(self->child_list, i); if (rect == 0) + { xrdp_bitmap_invalidate(b, 0); + } else { MAKERECT(r1, b->left, b->top, b->width, b->height); @@ -1205,7 +1233,7 @@ int APP_CC xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg, int param1, int param2) { - char c; + twchar c; int n; int i; int shift; @@ -1334,7 +1362,7 @@ xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg, else if ((scan_code == 77 || scan_code == 80) && (ext || self->wm->num_lock == 0)) { - if (self->edit_pos < g_strlen(self->caption1)) + if (self->edit_pos < g_mbstowcs(0, self->caption1, 0)) { self->edit_pos++; xrdp_bitmap_invalidate(self, 0); @@ -1343,13 +1371,13 @@ xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg, /* backspace */ else if (scan_code == 14) { - n = g_strlen(self->caption1); + n = g_mbstowcs(0, self->caption1, 0); if (n > 0) { if (self->edit_pos > 0) { self->edit_pos--; - remove_char_at(self->caption1, self->edit_pos); + remove_char_at(self->caption1, 255, self->edit_pos); xrdp_bitmap_invalidate(self, 0); } } @@ -1358,12 +1386,12 @@ xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg, else if (scan_code == 83 && (ext || self->wm->num_lock == 0)) { - n = g_strlen(self->caption1); + n = g_mbstowcs(0, self->caption1, 0); if (n > 0) { if (self->edit_pos < n) { - remove_char_at(self->caption1, self->edit_pos); + remove_char_at(self->caption1, 255, self->edit_pos); xrdp_bitmap_invalidate(self, 0); } } @@ -1372,7 +1400,7 @@ xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg, else if (scan_code == 79 && (ext || self->wm->num_lock == 0)) { - n = g_strlen(self->caption1); + n = g_mbstowcs(0, self->caption1, 0); if (self->edit_pos < n) { self->edit_pos = n; @@ -1380,8 +1408,8 @@ xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg, } } /* home */ - else if (scan_code == 71 && - (ext || self->wm->num_lock == 0)) + else if ((scan_code == 71) && + (ext || (self->wm->num_lock == 0))) { if (self->edit_pos > 0) { @@ -1391,14 +1419,13 @@ xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg, } else { - c = get_char_from_scan_code(param2, scan_code, self->wm->keys, - self->wm->caps_lock, - self->wm->num_lock, - self->wm->scroll_lock, - self->wm->session->client_info->keylayout); - if ((unsigned char)c >= 32) + c = get_char_from_scan_code + (param2, scan_code, self->wm->keys, self->wm->caps_lock, + self->wm->num_lock, self->wm->scroll_lock, + self->wm->session->client_info->keylayout); + if (c >= 32) { - add_char_at(self->caption1, c, self->edit_pos); + add_char_at(self->caption1, 255, c, self->edit_pos); self->edit_pos++; xrdp_bitmap_invalidate(self, 0); } @@ -1412,8 +1439,8 @@ xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg, scan_code = param1 % 128; ext = param2 & 0x0100; /* left or up arrow */ - if ((scan_code == 75 || scan_code == 72) && - (ext || self->wm->num_lock == 0)) + if (((scan_code == 75) || (scan_code == 72)) && + (ext || (self->wm->num_lock == 0))) { if (self->item_index > 0) {