diff options
author | jsorg71 <jsorg71> | 2004-10-11 02:58:27 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2004-10-11 02:58:27 +0000 |
commit | 330a4ffb9877563a8a95b773cc62f2cb8263723b (patch) | |
tree | aa41ac752c7ba54190ab473021415feac3c7c93b | |
parent | 82eb62e0cc149e1bf69217bff8771fa1a57fd577 (diff) | |
download | xrdp-proprietary-330a4ffb9877563a8a95b773cc62f2cb8263723b.tar.gz xrdp-proprietary-330a4ffb9877563a8a95b773cc62f2cb8263723b.zip |
added early keyboard work and some other fixes
-rw-r--r-- | xrdp/constants.h | 5 | ||||
-rw-r--r-- | xrdp/funcs.c | 195 | ||||
-rw-r--r-- | xrdp/os_calls.c | 6 | ||||
-rw-r--r-- | xrdp/xrdp.h | 7 | ||||
-rw-r--r-- | xrdp/xrdp_bitmap.c | 131 | ||||
-rw-r--r-- | xrdp/xrdp_orders.c | 5 | ||||
-rw-r--r-- | xrdp/xrdp_rdp.c | 14 | ||||
-rw-r--r-- | xrdp/xrdp_types.h | 8 | ||||
-rw-r--r-- | xrdp/xrdp_wm.c | 101 |
9 files changed, 417 insertions, 55 deletions
diff --git a/xrdp/constants.h b/xrdp/constants.h index 8fe8b2b7..5fc18107 100644 --- a/xrdp/constants.h +++ b/xrdp/constants.h @@ -410,3 +410,8 @@ /* button states */ #define BUTTON_STATE_UP 0 #define BUTTON_STATE_DOWN 1 + +/* messages */ +#define WM_PAINT 3 +#define WM_KEYDOWN 15 +#define WM_KEYUP 16 diff --git a/xrdp/funcs.c b/xrdp/funcs.c index dfa4abcd..de367201 100644 --- a/xrdp/funcs.c +++ b/xrdp/funcs.c @@ -1,4 +1,3 @@ - /* 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 @@ -62,21 +61,6 @@ int rect_intersect(struct xrdp_rect* in1, struct xrdp_rect* in2, } /*****************************************************************************/ -int color16(int r, int g, int b) -{ - r = r >> 3; - g = g >> 2; - b = b >> 3; - return (r << 11) | (g << 5) | b; -} - -/*****************************************************************************/ -int color24(int r, int g, int b) -{ - return r | (g << 8) | (b << 16); -} - -/*****************************************************************************/ /* adjust the bounds to fit in the bitmap */ /* return false if there is nothing to draw else return true */ int check_bounds(struct xrdp_bitmap* b, int* x, int* y, int* cx, int* cy) @@ -105,3 +89,182 @@ int check_bounds(struct xrdp_bitmap* b, int* x, int* y, int* cx, int* cy) *cy = b->height - *y; return 1; } + +/* scan codes + 1 esc + 2 1 or ? + 3 2 or @ + 4 3 or # + 5 4 or $ + 6 5 or % + 7 6 or ^ + 8 7 or & + 9 8 or * + 10 9 or ( + 11 10 or ) + 12 11 or _ + 13 12 or + + 14 backspace + 15 tab + 16 q or Q + 17 w or W + 18 e or E + 19 r or R + 20 t or T + 21 y or Y + 22 u or U + 23 i or I + 24 o or O + 25 p or P + 26 [ or { + 27 ] or } + 28 enter, keypad if ext + 29 left or right ctrl, ext flag is right + 30 a or A + 31 s or S + 32 d or D + 33 f or F + 34 g or G + 35 h or H + 36 j or J + 37 k or K + 38 l or L + 39 ; or : + 40 ' or " + 41 ~ + 42 left shift + 43 \ + 44 z or Z + 45 x or X + 46 c or C + 47 v or V + 48 b or B + 49 n or N + 50 m or M + 51 , or < + 52 . or > + 53 / can be / on keypad, ext flag is keypad + 54 right shift + 55 * on keypad or print screen if ext + 56 left or right alt, ext flag is right + 57 space + 58 caps lock + 59 F1 + 60 F2 + 61 F3 + 62 F4 + 63 F5 + 64 F6 + 65 F7 + 66 F8 + 67 F9 + 68 F10 + 69 num lock + 70 scroll lock + 71 7 or home on keypad, ext flag is not keypad + 72 8 or arrow up on keypad, ext flag is not keypad + 73 9 or page up + 74 -(minus) on keypad + 75 4 or arrow left on keypad, ext flag is not keypad + 76 middle(5 key) of keypad + 77 6 or arrow right, can be on keypad, ext flag in not keypad + 78 + on keypad + 79 1 or end + 80 2 or arrow down, can be on keypad, ext flag in not keypad + 81 3 or page down + 82 0 or insert on keypad, ext flag is not keypad + 83 . or delete on keypad, ext flag is not keypad + 87 F11 + 88 F12 + 91 left win key ext always on + 92 right win key ext always on + 93 menu key ext always on +*/ + +/* non shift chars */ +char chars1[] = {'\0', '\0', '1', '2', '3', '4', '5', '6', + '7', '8', '9', '0', '-', '=', '\0', '\0', + 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', + 'o', 'p', '[', ']', '\0', '\0', 'a', 's', + 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', + '\'', '`', '\0', '\\', 'z', 'x', 'c', 'v', + 'b', 'n', 'm', ',', '.', '/', '\0', '*', + '\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '7', + '8', '9', '-', '4', '5', '6', '+', '1', + '2', '3', '0', '.', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}; +/* shift chars */ +char chars2[] = {'\0', '\0', '!', '@', '#', '$', '%', '^', + '&', '*', '(', ')', '_', '+', '\0', '\0', + 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', + 'O', 'P', '{', '}', '\0', '\0', 'A', 'S', + 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', + '"', '~', '\0', '|', 'Z', 'X', 'C', 'V', + 'B', 'N', 'M', '<', '>', '?', '\0', '*', + '\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '7', + '8', '9', '-', '4', '5', '6', '+', '1', + '2', '3', '0', '.', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}; + +/*****************************************************************************/ +char get_char_from_scan_code(int device_flags, int scan_code, int* keys, + int caps_lock, int num_lock, int scroll_lock) +{ + char rv; + int shift; + int ext; + + shift = keys[42] || keys[54]; + ext = device_flags & 0x0100; + rv = 0; + if (scan_code >= 128) + { + scan_code = scan_code % 128; + num_lock = 0; + } + if (!num_lock) + { + switch (scan_code) + { + case 71: /* 7 */ + case 72: /* 8 */ + case 73: /* 9 */ + case 75: /* 4 */ + case 76: /* 5 */ + case 77: /* 6 */ + case 79: /* 1 */ + case 80: /* 2 */ + case 81: /* 3 */ + case 82: /* 0 */ + case 83: /* . */ + return rv; + } + } + if (ext) + { + if (scan_code == 53) + rv = '/'; + } + else + { + if (shift) + rv = chars2[scan_code]; + else + rv = chars1[scan_code]; + if (rv >= 'a' && rv <= 'z' && caps_lock) + rv = rv - ('a' - 'A'); + else if (rv >= 'A' && rv <= 'Z' && caps_lock) + rv = rv + ('a' - 'A'); + } + return rv; +} diff --git a/xrdp/os_calls.c b/xrdp/os_calls.c index 66cd4f2e..0bb78e38 100644 --- a/xrdp/os_calls.c +++ b/xrdp/os_calls.c @@ -536,3 +536,9 @@ char* g_strcpy(char* dest, char* src) { return strcpy(dest, src); } + +/*****************************************************************************/ +char* g_strcat(char* dest, char* src) +{ + return strcat(dest, src); +} diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index b3a63c11..7b06b86b 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -120,6 +120,7 @@ int g_file_seek(int fd, int offset); int g_file_lock(int fd, int start, int len); int g_strlen(char* text); char* g_strcpy(char* dest, char* src); +char* g_strcat(char* dest, char* src); /* xrdp_tcp.c */ struct xrdp_tcp* xrdp_tcp_create(struct xrdp_iso* owner); @@ -234,6 +235,8 @@ int xrdp_wm_get_vis_region(struct xrdp_wm* self, struct xrdp_bitmap* bitmap, struct xrdp_region* region); 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); /* xrdp_process.c */ struct xrdp_process* xrdp_process_create(struct xrdp_listen* owner); @@ -269,6 +272,8 @@ int xrdp_bitmap_copy_box(struct xrdp_bitmap* self, struct xrdp_bitmap* dest, int x, int y, int cx, int cy); int xrdp_bitmap_compare(struct xrdp_bitmap* self, struct xrdp_bitmap* b); int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect); +int xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg, + int param1, int param2); /* xrdp_painter.c */ struct xrdp_painter* xrdp_painter_create(struct xrdp_wm* wn); @@ -315,3 +320,5 @@ int rect_contains_pt(struct xrdp_rect* in, int x, int y); int rect_intersect(struct xrdp_rect* in1, struct xrdp_rect* in2, struct xrdp_rect* out); int check_bounds(struct xrdp_bitmap* b, int* x, int* y, int* cx, int* cy); +char get_char_from_scan_code(int device_flags, int scan_code, int* keys, + int caps_lock, int num_lock, int scroll_lock); diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c index 63547dca..bd54570f 100644 --- a/xrdp/xrdp_bitmap.c +++ b/xrdp/xrdp_bitmap.c @@ -56,6 +56,11 @@ void xrdp_bitmap_delete(struct xrdp_bitmap* self) return; if (self->wm != 0) { + if (self->wm->focused_window != 0) + { + if (self->wm->focused_window->focused_control == self) + self->wm->focused_window->focused_control = 0; + } if (self->wm->focused_window == self) self->wm->focused_window = 0; if (self->wm->dragging_window == self) @@ -98,7 +103,7 @@ int xrdp_bitmap_set_focus(struct xrdp_bitmap* self, int focused) xrdp_painter_fill_rect(painter, self, 3, 3, self->width - 5, 18); painter->font->color = self->wm->black; } - xrdp_painter_draw_text(painter, self, 4, 4, self->title); + xrdp_painter_draw_text(painter, self, 4, 4, self->caption); xrdp_painter_end_update(painter); xrdp_painter_delete(painter); return 0; @@ -415,7 +420,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) xrdp_painter_fill_rect(painter, self, 3, 3, self->width - 5, 18); painter->font->color = self->wm->black; } - xrdp_painter_draw_text(painter, self, 4, 4, self->title); + xrdp_painter_draw_text(painter, self, 4, 4, self->caption); } else if (self->type == WND_TYPE_SCREEN) /* 2 */ { @@ -449,11 +454,11 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) /* black right line */ painter->fg_color = self->wm->black; xrdp_painter_fill_rect(painter, self, self->width - 1, 0, 1, self->height); - w = xrdp_painter_text_width(painter, self->title); - h = xrdp_painter_text_height(painter, self->title); + w = xrdp_painter_text_width(painter, self->caption); + h = xrdp_painter_text_height(painter, self->caption); painter->font->color = self->wm->black; xrdp_painter_draw_text(painter, self, self->width / 2 - w / 2, - self->height / 2 - h / 2, self->title); + self->height / 2 - h / 2, self->caption); } else if (self->state == BUTTON_STATE_DOWN) /* 1 */ { @@ -486,11 +491,11 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) /* black right line */ painter->fg_color = self->wm->black; xrdp_painter_fill_rect(painter, self, self->width - 1, 0, 1, self->height); - w = xrdp_painter_text_width(painter, self->title); - h = xrdp_painter_text_height(painter, self->title); + w = xrdp_painter_text_width(painter, self->caption); + h = xrdp_painter_text_height(painter, self->caption); painter->font->color = self->wm->black; xrdp_painter_draw_text(painter, self, (self->width / 2 - w / 2) + 1, - (self->height / 2 - h / 2) + 1, self->title); + (self->height / 2 - h / 2) + 1, self->caption); } } else if (self->type == WND_TYPE_IMAGE) /* 4 */ @@ -525,15 +530,19 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) /* black top line */ painter->fg_color = self->wm->black; xrdp_painter_fill_rect(painter, self, 1, 1, self->width - 2, 1); + /* draw text */ + painter->fg_color = self->wm->black; + xrdp_painter_draw_text(painter, self, 2, 2, self->caption); +// xrdp_painter_draw_text(painter, self, 2, 2, "hi"); } else if (self->type == WND_TYPE_LABEL) /* 6 */ { painter->font->color = self->wm->black; - xrdp_painter_draw_text(painter, self, 0, 0, self->title); + xrdp_painter_draw_text(painter, self, 0, 0, self->caption); } /* notify */ if (self->notify != 0) - self->notify(self, self, 3, (int)painter, 0); + self->notify(self, self, WM_PAINT, (int)painter, 0); /* 3 */ /* draw any child windows in the area */ for (i = 0; i < self->child_list->count; i++) { @@ -554,3 +563,105 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) xrdp_painter_delete(painter); return 0; } + +/*****************************************************************************/ +/* returns error */ +int xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg, + int param1, int param2) +{ + char c; + char a[2]; + int n; + int i; + int shift; + struct xrdp_bitmap* b; + + if (self == 0) + return 0; + if (self->wm == 0) + return 0; + if (self->type == WND_TYPE_WND) + { + if (msg == WM_KEYDOWN) + { + if (param1 == 15) /* tab */ + { + /* move to next tab stop */ + shift = self->wm->keys[42] || self->wm->keys[54]; + i = -1; + if (self->child_list != 0) + i = xrdp_list_index_of(self->child_list, (int)self->focused_control); + if (shift) + { + i--; + if (i < 0) + i = self->child_list->count - 1; + } + else + { + i++; + if (i >= self->child_list->count) + i = 0; + } + n = self->child_list->count; + b = (struct xrdp_bitmap*)xrdp_list_get_item(self->child_list, i); + while (b != self->focused_control && b != 0 && n > 0) + { + n--; + if (b->tab_stop) + { + self->focused_control = b; + break; + } + if (shift) + { + i--; + if (i < 0) + i = self->child_list->count - 1; + } + else + { + i++; + if (i >= self->child_list->count) + i = 0; + } + b = (struct xrdp_bitmap*)xrdp_list_get_item(self->child_list, i); + } + } + } + if (self->focused_control != 0) + { + xrdp_bitmap_def_proc(self->focused_control, msg, param1, param2); + } + } + else if (self->type == WND_TYPE_EDIT) + { + if (msg == WM_KEYDOWN) + { + if (param1 == 14) /* backspace */ + { + n = g_strlen(self->caption); + if (n > 0) + { + self->caption[n - 1] = 0; + xrdp_bitmap_invalidate(self, 0); + } + } + else + { + c = get_char_from_scan_code(param2, param1, self->wm->keys, + self->wm->caps_lock, + self->wm->num_lock, + self->wm->scroll_lock); + if (c != 0) + { + a[0] = c; + a[1] = 0; + g_strcat(self->caption, a); + xrdp_bitmap_invalidate(self, 0); + } + } + } + } + return 0; +} diff --git a/xrdp/xrdp_orders.c b/xrdp/xrdp_orders.c index ab363ec7..c6998252 100644 --- a/xrdp/xrdp_orders.c +++ b/xrdp/xrdp_orders.c @@ -104,6 +104,9 @@ int xrdp_orders_force_send(struct xrdp_orders* self) } /*****************************************************************************/ +/* check if the current order will fix in packet size of 8192, if not */ +/* send what we got and init a new one */ +/* returns error */ int xrdp_orders_check(struct xrdp_orders* self, int max_size) { int size; @@ -127,6 +130,7 @@ int xrdp_orders_check(struct xrdp_orders* self, int max_size) } /*****************************************************************************/ +/* check if rect is the same as the last one sent */ /* returns boolean */ int xrdp_orders_last_bounds(struct xrdp_orders* self, struct xrdp_rect* rect) @@ -140,6 +144,7 @@ int xrdp_orders_last_bounds(struct xrdp_orders* self, } /*****************************************************************************/ +/* check if all coords are withing 256 bytes */ /* returns boolean */ int xrdp_orders_send_delta(struct xrdp_orders* self, int* vals, int count) { diff --git a/xrdp/xrdp_rdp.c b/xrdp/xrdp_rdp.c index e878aaa8..6c9a3bfc 100644 --- a/xrdp/xrdp_rdp.c +++ b/xrdp/xrdp_rdp.c @@ -213,13 +213,13 @@ int xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp* self) /*****************************************************************************/ int xrdp_rdp_incoming(struct xrdp_rdp* self) { - DEBUG(("in xrdp_rdp_incoming\n")); + DEBUG(("in xrdp_rdp_incoming\n\r")); if (xrdp_sec_incoming(self->sec_layer) != 0) return 1; self->mcs_channel = self->sec_layer->mcs_layer->userid + MCS_USERCHANNEL_BASE; xrdp_rdp_parse_client_mcs_data(self); - DEBUG(("out xrdp_rdp_incoming mcs channel %d\n", self->mcs_channel)); + DEBUG(("out xrdp_rdp_incoming mcs channel %d\n\r", self->mcs_channel)); return 0; } @@ -375,9 +375,10 @@ int xrdp_rdp_process_data_pointer(struct xrdp_rdp* self, struct stream* s) int xrdp_rdp_process_input_sync(struct xrdp_rdp* self, int device_flags, int key_flags) { - DEBUG(("sync event flags %d key %d\n\r", device_flags, key_flags)) + DEBUG(("sync event flags %d key %d\n\r", device_flags, key_flags)); if (!self->up_and_running) return 0; + xrdp_wm_key_sync(self->pro_layer->wm, device_flags, key_flags); return 0; } @@ -386,9 +387,10 @@ int xrdp_rdp_process_input_sync(struct xrdp_rdp* self, int device_flags, int xrdp_rdp_process_input_scancode(struct xrdp_rdp* self, int device_flags, int scan_code) { - DEBUG(("key event flags %d scan_code %d\n\r", device_flags, scan_code)) + DEBUG(("key event flags %4.4x scan_code %d\n\r", device_flags, scan_code)); if (!self->up_and_running) return 0; + xrdp_wm_key(self->pro_layer->wm, device_flags, scan_code); return 0; } @@ -397,7 +399,7 @@ int xrdp_rdp_process_input_scancode(struct xrdp_rdp* self, int device_flags, int xrdp_rdp_process_input_mouse(struct xrdp_rdp* self, int device_flags, int x, int y) { - DEBUG(("mouse event flags %4.4x x - %d y - %d\n\r", device_flags, x, y)); + DEBUG(("mouse event flags %4.4x x %d y %d\n\r", device_flags, x, y)); if (!self->up_and_running) return 0; if (device_flags & MOUSE_FLAG_MOVE) /* 0x0800 */ @@ -432,7 +434,7 @@ int xrdp_rdp_process_data_input(struct xrdp_rdp* self, struct stream* s) in_uint16_le(s, num_events); in_uint8s(s, 2); /* pad */ - DEBUG(("xrdp_rdp_process_data_input %d events\n\r", num_events)) + DEBUG(("xrdp_rdp_process_data_input %d events\n\r", num_events)); for (index = 0; index < num_events; index++) { in_uint8s(s, 4); /* time */ diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index c1ec3d91..37ca1b03 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -315,6 +315,10 @@ struct xrdp_wm struct xrdp_bitmap* focused_window; /* cursor */ int current_cursor; + int keys[256]; /* key states 0 up 1 down*/ + int caps_lock; + int scroll_lock; + int num_lock; }; /* rdp process */ @@ -377,8 +381,10 @@ struct xrdp_bitmap int bg_color; int line_size; /* in bytes */ int focused; - char title[256]; + int tab_stop; + char caption[256]; struct xrdp_bitmap* modal_dialog; + struct xrdp_bitmap* focused_control; struct xrdp_bitmap* owner; /* window that created us */ struct xrdp_bitmap* parent; /* window contained in */ struct xrdp_list* child_list; diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 6e755ce2..d4d84415 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -154,7 +154,7 @@ int xrdp_wm_login_help_notify(struct xrdp_bitmap* wnd, } } } - else if (msg == 3) /* paint */ + else if (msg == WM_PAINT) /* 3 */ { p = (struct xrdp_painter*)param1; if (p != 0) @@ -227,7 +227,7 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd, 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->title, "Logon help"); + 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); @@ -237,7 +237,7 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd, but->left = 120; but->top = 260; but->id = 1; - g_strcpy(but->title, "OK"); + g_strcpy(but->caption, "OK"); /* draw it */ xrdp_bitmap_invalidate(help, 0); xrdp_wm_set_focused(wnd->wm, help); @@ -457,7 +457,8 @@ int xrdp_wm_init(struct xrdp_wm* self) self->green = COLOR24(0x00, 0xff, 0x00); } /* draw login window */ - self->login_window = xrdp_bitmap_create(400, 200, self->screen->bpp, 1); + 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; @@ -468,10 +469,10 @@ int xrdp_wm_init(struct xrdp_wm* self) self->login_window->top = self->screen->height / 2 - self->login_window->height / 2; self->login_window->notify = xrdp_wm_login_notify; - strcpy(self->login_window->title, "Logon to xrdp"); + strcpy(self->login_window->caption, "Logon to xrdp"); /* image */ - but = xrdp_bitmap_create(4, 4, self->screen->bpp, 4); + 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; @@ -481,7 +482,7 @@ int xrdp_wm_init(struct xrdp_wm* self) xrdp_list_add_item(self->screen->child_list, (int)but); /* image */ - but = xrdp_bitmap_create(4, 4, self->screen->bpp, 4); + 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; @@ -491,7 +492,7 @@ int xrdp_wm_init(struct xrdp_wm* self) xrdp_list_add_item(self->login_window->child_list, (int)but); /* button */ - but = xrdp_bitmap_create(60, 25, self->screen->bpp, 3); + 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; @@ -499,10 +500,11 @@ int xrdp_wm_init(struct xrdp_wm* self) but->left = 320; but->top = 160; but->id = 1; - g_strcpy(but->title, "Help"); + g_strcpy(but->caption, "Help"); + but->tab_stop = 1; /* button */ - but = xrdp_bitmap_create(60, 25, self->screen->bpp, 3); + 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; @@ -510,10 +512,11 @@ int xrdp_wm_init(struct xrdp_wm* self) but->left = 250; but->top = 160; but->id = 2; - g_strcpy(but->title, "Cancel"); + g_strcpy(but->caption, "Cancel"); + but->tab_stop = 1; /* button */ - but = xrdp_bitmap_create(60, 25, self->screen->bpp, 3); + 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; @@ -521,20 +524,21 @@ int xrdp_wm_init(struct xrdp_wm* self) but->left = 180; but->top = 160; but->id = 3; - g_strcpy(but->title, "OK"); + g_strcpy(but->caption, "OK"); + but->tab_stop = 1; /* label */ - but = xrdp_bitmap_create(60, 20, self->screen->bpp, 6); /* 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->title, "Username"); + g_strcpy(but->caption, "Username"); /* edit */ - but = xrdp_bitmap_create(140, 20, self->screen->bpp, 5); + 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; @@ -543,19 +547,20 @@ int xrdp_wm_init(struct xrdp_wm* self) but->top = 50; but->id = 4; but->cursor = 1; + but->tab_stop = 1; /* label */ - but = xrdp_bitmap_create(60, 20, self->screen->bpp, 6); /* 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->title, "Password"); + g_strcpy(but->caption, "Password"); /* edit */ - but = xrdp_bitmap_create(140, 20, self->screen->bpp, 5); + 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; @@ -564,6 +569,7 @@ int xrdp_wm_init(struct xrdp_wm* self) but->top = 80; but->id = 5; but->cursor = 1; + but->tab_stop = 1; /* clear screen */ self->screen->bg_color = self->black; @@ -893,9 +899,15 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down) if (control != 0) { if (wnd != 0) + { + if (control == wnd) + wnd->focused_control = 0; + else + wnd->focused_control = control; if (wnd->modal_dialog != 0) /* if window has a modal dialog */ return 0; - if (control->type == 3 && but == 1 && + } + if (control->type == WND_TYPE_BUTTON && but == 1 && !down && self->button_down == control) { /* if clicking up on a button that was clicked down */ self->button_down = 0; @@ -906,7 +918,7 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down) /* control can be invalid after this */ control->parent->notify(control->owner, control, 1, x, y); } - else if (control->type == 3 && but == 1 && down) + else if (control->type == WND_TYPE_BUTTON && but == 1 && down) { /* if clicking down on a button */ self->button_down = control; control->state = 1; @@ -915,7 +927,7 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down) else if (but == 1 && down) { xrdp_wm_set_focused(self, wnd); - if (control->type == 1 && y < (control->top + 21)) + if (control->type == WND_TYPE_WND && y < (control->top + 21)) { /* if dragging */ if (self->dragging) /* rarely happens */ { @@ -947,3 +959,48 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down) self->button_down = 0; return 0; } + +/*****************************************************************************/ +int xrdp_wm_key(struct xrdp_wm* self, int device_flags, int scan_code) +{ + int msg; + + if (device_flags & 0x8000) /* key up */ + { + self->keys[scan_code % 128] = 0; + msg = WM_KEYUP; + } + else /* key down */ + { + self->keys[scan_code % 128] = 1; + msg = WM_KEYDOWN; + switch (scan_code) + { + case 58: self->caps_lock = !self->caps_lock; break; /* caps lock */ + case 69: self->num_lock = !self->num_lock; break; /* num lock */ + case 70: self->scroll_lock = !self->scroll_lock; break; /* scroll lock */ + } + } + if (self->focused_window != 0) + { + xrdp_bitmap_def_proc(self->focused_window, + msg, scan_code, device_flags); + } + return 0; +} + +/*****************************************************************************/ +/* happens when client gets focus and sends key modifier info */ +int xrdp_wm_key_sync(struct xrdp_wm* self, int device_flags, int key_flags) +{ + self->num_lock = 0; + self->scroll_lock = 0; + self->caps_lock = 0; + if (key_flags & 1) + self->scroll_lock = 1; + if (key_flags & 2) + self->num_lock = 1; + if (key_flags & 4) + self->caps_lock = 1; + return 0; +} |