diff options
-rw-r--r-- | xrdp/xrdp_bitmap.c | 47 | ||||
-rw-r--r-- | xrdp/xrdp_types.h | 1 | ||||
-rw-r--r-- | xrdp/xrdp_wm.c | 96 |
3 files changed, 100 insertions, 44 deletions
diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c index 2b5b9a50..8988e30a 100644 --- a/xrdp/xrdp_bitmap.c +++ b/xrdp/xrdp_bitmap.c @@ -86,7 +86,6 @@ int xrdp_bitmap_set_focus(struct xrdp_bitmap* self, int focused) return 0; if (self->type != WND_TYPE_WND) /* 1 */ return 0; - self->focused = focused; painter = xrdp_painter_create(self->wm); xrdp_painter_begin_update(painter); if (focused) @@ -348,6 +347,40 @@ int xrdp_bitmap_compare(struct xrdp_bitmap* self, struct xrdp_bitmap* b) } /*****************************************************************************/ +int xrdp_bitmap_draw_focus_box(struct xrdp_bitmap* self, + struct xrdp_painter* painter, + int x, int y, int cx, int cy) +{ + painter->rop = 0xf0; + xrdp_painter_begin_update(painter); + painter->use_clip = 0; + painter->brush.pattern[0] = 0xaa; + painter->brush.pattern[1] = 0x55; + painter->brush.pattern[2] = 0xaa; + painter->brush.pattern[3] = 0x55; + painter->brush.pattern[4] = 0xaa; + painter->brush.pattern[5] = 0x55; + painter->brush.pattern[6] = 0xaa; + painter->brush.pattern[7] = 0x55; + painter->brush.x_orgin = x; + painter->brush.x_orgin = x; + painter->brush.style = 3; + painter->bg_color = self->wm->black; + painter->fg_color = self->wm->white; + /* top */ + xrdp_painter_fill_rect2(painter, self, x, y, cx, 1); + /* bottom */ + xrdp_painter_fill_rect2(painter, self, x, y + (cy - 1), cx, 1); + /* left */ + xrdp_painter_fill_rect2(painter, self, x, y + 1, 1, cy - 2); + /* right */ + xrdp_painter_fill_rect2(painter, self, x + (cx - 1), y + 1, 1, cy - 2); + xrdp_painter_end_update(painter); + painter->rop = 0xcc; + return 0; +} + +/*****************************************************************************/ /* nil for rect means the whole thing */ /* returns error */ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) @@ -407,7 +440,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) painter->fg_color = self->wm->black; xrdp_painter_fill_rect(painter, self, self->width - 1, 0, 1, self->height); - if (self->focused) + if (self->wm->focused_window == self) { /* active title bar */ painter->fg_color = self->wm->blue; @@ -460,6 +493,11 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) painter->font->color = self->wm->black; xrdp_painter_draw_text(painter, self, self->width / 2 - w / 2, self->height / 2 - h / 2, self->caption); + 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 */ { @@ -497,6 +535,11 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) 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->caption); + 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->type == WND_TYPE_IMAGE) /* 4 */ diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index 41757b11..9fac5d78 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -389,7 +389,6 @@ struct xrdp_bitmap int cursor; int bg_color; int tab_stop; - int focused; int id; char caption[256]; /* for window or screen */ diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 5c07fd55..4c394f84 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -181,19 +181,28 @@ logging on."); /*****************************************************************************/ int xrdp_wm_set_focused(struct xrdp_wm* self, struct xrdp_bitmap* wnd) { + struct xrdp_bitmap* focus_out_control; + struct xrdp_bitmap* focus_in_control; + if (self == 0) return 0; if (self->focused_window == wnd) return 0; + focus_out_control = 0; + focus_in_control = 0; if (self->focused_window != 0) { xrdp_bitmap_set_focus(self->focused_window, 0); + focus_out_control = self->focused_window->focused_control; } self->focused_window = wnd; if (self->focused_window != 0) { xrdp_bitmap_set_focus(self->focused_window, 1); + focus_in_control = self->focused_window->focused_control; } + xrdp_bitmap_invalidate(focus_out_control, 0); + xrdp_bitmap_invalidate(focus_in_control, 0); return 0; } @@ -236,10 +245,14 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd, 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 */ { @@ -490,42 +503,6 @@ int xrdp_wm_init(struct xrdp_wm* self) but->top = 30; xrdp_list_add_item(self->login_window->child_list, (int)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 = 320; - but->top = 160; - but->id = 1; - g_strcpy(but->caption, "Help"); - 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 = 180; - but->top = 160; - but->id = 3; - g_strcpy(but->caption, "OK"); - but->tab_stop = 1; - /* label */ but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL); xrdp_list_add_item(self->login_window->child_list, (int)but); @@ -547,6 +524,7 @@ int xrdp_wm_init(struct xrdp_wm* self) 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); @@ -570,6 +548,42 @@ int xrdp_wm_init(struct xrdp_wm* self) but->cursor = 1; 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 = 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; + /* clear screen */ self->screen->bg_color = self->black; xrdp_bitmap_invalidate(self->screen, 0); @@ -900,17 +914,17 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down) { if (wnd != 0) { + if (wnd->modal_dialog != 0) /* if window has a modal dialog */ + return 0; if (control == wnd) - wnd->focused_control = 0; - else + ; + else if (control->tab_stop) { focus_out_control = wnd->focused_control; wnd->focused_control = control; xrdp_bitmap_invalidate(focus_out_control, 0); + xrdp_bitmap_invalidate(control, 0); } - xrdp_bitmap_invalidate(control, 0); - if (wnd->modal_dialog != 0) /* if window has a modal dialog */ - return 0; } if (control->type == WND_TYPE_BUTTON && but == 1 && !down && self->button_down == control) |