From 20ec9ee34ec2ec23261bd0442f663ae7a7361b09 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sun, 30 Jun 2013 12:36:01 -0700 Subject: [PATCH 01/31] Hand-apply patches (rail improvements) from Authentic8 branch: 507694d, 0e21d45, 44447d5, e452e4f, 3d05576, dd69d8f --- sesman/chansrv/chansrv.c | 41 ++++++++++ sesman/chansrv/chansrv.h | 1 + sesman/chansrv/rail.c | 164 +++++++++++++++++++++++++++++++++---- sesman/chansrv/rail.h | 1 + sesman/chansrv/xcommon.c | 4 + xorg/X11R7.6/rdp/rdpdraw.c | 13 ++- xorg/X11R7.6/rdp/rdpup.c | 23 +++++- xrdp/xrdp_mm.c | 82 +++++++++++++++++++ xup/xup.c | 22 +++++ 9 files changed, 335 insertions(+), 16 deletions(-) diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index bd9c27c5..cef7812b 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -227,6 +227,31 @@ send_channel_data(int chan_id, char *data, int size) return 1; } +/*****************************************************************************/ +/* returns error */ +int APP_CC +send_rail_drawing_orders(char* data, int size) +{ + LOGM((LOG_LEVEL_DEBUG, "chansrv::send_rail_drawing_orders: size %d", size)); + + struct stream* s; + int error; + + s = trans_get_out_s(g_con_trans, 8192); + out_uint32_le(s, 0); /* version */ + out_uint32_le(s, 8 + 8 + size); /* size */ + out_uint32_le(s, 10); /* msg id */ + out_uint32_le(s, 8 + size); /* size */ + out_uint8a(s, data, size); + s_mark_end(s); + error = trans_force_write(g_con_trans); + if (error != 0) + { + return 1; + } + return 0; +} + /*****************************************************************************/ /* returns error */ static int APP_CC @@ -500,6 +525,19 @@ process_message_channel_data(struct stream *s) return rv; } +/*****************************************************************************/ +/* returns error */ +static int APP_CC +process_message_channel_rail_title_request(struct stream* s) +{ + int window_id; + LOG(10, ("process_message_channel_rail_title_request:")); + + in_uint32_le(s, window_id); + rail_request_title(window_id); + return 0; +} + /*****************************************************************************/ /* returns error */ static int APP_CC @@ -557,6 +595,9 @@ process_message(void) case 7: /* channel data response */ rv = process_message_channel_data_response(s); break; + case 9: + rv = process_message_channel_rail_title_request(s); + break; default: LOGM((LOG_LEVEL_ERROR, "process_message: error in process_message ", "unknown msg %d", id)); diff --git a/sesman/chansrv/chansrv.h b/sesman/chansrv/chansrv.h index a6b88a35..61b62e4e 100644 --- a/sesman/chansrv/chansrv.h +++ b/sesman/chansrv/chansrv.h @@ -55,6 +55,7 @@ struct xrdp_api_data }; int APP_CC send_channel_data(int chan_id, char *data, int size); +int APP_CC send_rail_drawing_orders(char* data, int size); int APP_CC main_cleanup(void); int APP_CC find_empty_slot_in_dvc_channels(); struct xrdp_api_data *APP_CC struct_from_dvc_chan_id(tui32 dvc_chan_id); diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index 1ea8d73a..cc6c8feb 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -41,6 +41,8 @@ extern Screen *g_screen; /* in xcommon.c */ extern Window g_root_window; /* in xcommon.c */ extern Atom g_wm_delete_window_atom; /* in xcommon.c */ extern Atom g_wm_protocols_atom; /* in xcommon.c */ +extern Atom g_utf8_string; /* in xcommon.c */ +extern Atom g_net_wm_name; /* in xcommon.c */ int g_rail_up = 0; @@ -298,6 +300,25 @@ rail_process_exec(struct stream *s, int size) return 0; } +/******************************************************************************/ +static int APP_CC +rail_close_window(int window_id) +{ + XEvent ce; + + LOG(0, ("chansrv::rail_close_window:")); + g_memset(&ce, 0, sizeof(ce)); + ce.xclient.type = ClientMessage; + ce.xclient.message_type = g_wm_protocols_atom; + ce.xclient.display = g_display; + ce.xclient.window = window_id; + ce.xclient.format = 32; + ce.xclient.data.l[0] = g_wm_delete_window_atom; + ce.xclient.data.l[1] = CurrentTime; + XSendEvent(g_display, window_id, False, NoEventMask, &ce); + return 0; +} + /*****************************************************************************/ static int APP_CC rail_process_activate(struct stream *s, int size) @@ -316,8 +337,15 @@ rail_process_activate(struct stream *s, int size) XRaiseWindow(g_display, window_id); LOG(10, ("chansrv::rail_process_activate: calling XSetInputFocus 0x%8.8x", window_id)); XSetInputFocus(g_display, window_id, RevertToParent, CurrentTime); - } + } else { + XWindowAttributes window_attributes; + XGetWindowAttributes(g_display, window_id, &window_attributes); + if (window_attributes.override_redirect) { + LOG(10, (" dismiss popup window 0x%8.8x", window_id)); + rail_close_window(window_id); + } + } return 0; } @@ -335,21 +363,25 @@ rail_process_system_param(struct stream *s, int size) /******************************************************************************/ static int APP_CC -rail_close_window(int window_id) +rail_minmax_window(int window_id, int max) { - XEvent ce; + LOG(10, ("chansrv::rail_minmax_window 0x%8.8x:", window_id)); + if (max) + { + + } else { + XUnmapWindow(g_display, window_id); + LOG(10, (" XUnmapWindow")); + } +} - LOG(0, ("chansrv::rail_close_window:")); - g_memset(&ce, 0, sizeof(ce)); - ce.xclient.type = ClientMessage; - ce.xclient.message_type = g_wm_protocols_atom; - ce.xclient.display = g_display; - ce.xclient.window = window_id; - ce.xclient.format = 32; - ce.xclient.data.l[0] = g_wm_delete_window_atom; - ce.xclient.data.l[1] = CurrentTime; - XSendEvent(g_display, window_id, False, NoEventMask, &ce); - return 0; +/*****************************************************************************/ +static int APP_CC +rail_restore_window(int window_id) +{ + LOG(10, ("chansrv::rail_restore_window 0x%8.8x:", window_id)); + LOG(10, (" XMapWindow")); + XMapWindow(g_display, window_id); } /*****************************************************************************/ @@ -373,6 +405,7 @@ rail_process_system_command(struct stream *s, int size) break; case SC_MINIMIZE: LOG(10, (" window_id 0x%8.8x SC_MINIMIZE", window_id)); + rail_minmax_window(window_id, 0); break; case SC_MAXIMIZE: LOG(10, (" window_id 0x%8.8x SC_MAXIMIZE", window_id)); @@ -386,6 +419,7 @@ rail_process_system_command(struct stream *s, int size) break; case SC_RESTORE: LOG(10, (" window_id 0x%8.8x SC_RESTORE", window_id)); + rail_restore_window(window_id); break; case SC_DEFAULT: LOG(10, (" window_id 0x%8.8x SC_DEFAULT", window_id)); @@ -616,6 +650,89 @@ rail_data_in(struct stream *s, int chan_id, int chan_flags, int length, return 0; } +/*****************************************************************************/ +int APP_CC +rail_get_property(Display *display, Window target, Atom type, Atom property, + unsigned char** data, unsigned long* count) { + Atom atom_return; + int size; + unsigned long nitems, bytes_left; + + int ret = XGetWindowProperty(display, target, property, + 0l, 1l, False, + type, &atom_return, &size, + &nitems, &bytes_left, data); + if (ret != Success || nitems < 1) + { + return 0; + } + + if (bytes_left != 0) + { + XFree(*data); + unsigned long remain = ((size / 8) * nitems) + bytes_left; + ret = XGetWindowProperty(g_display, target, + property, 0l, remain, False, + type, &atom_return, &size, + &nitems, &bytes_left, data); + if (ret != Success) + { + return 1; + } + } + + *count = nitems; + return 0; +} + +/*****************************************************************************/ +const int APP_CC +rail_send_win_text(Display *disp, Window win) { + unsigned char *data = 0; + unsigned long nitems = 0; + struct stream* s; + + rail_get_property(disp, win, g_utf8_string, g_net_wm_name, + &data, &nitems); + if (nitems == 0) + { + /* _NET_WM_NAME isn't set, use WM_NAME (XFetchName) instead */ + XFetchName(disp, win, (char **)&data); + } + + if (data) + { + int i = 0; + for (;;i++) + { + if (data[i] == '\0') + { + break; + } + } + LOG(10, ("rail_send_win_text: 0x%8.8x text 0x%x size %d", win, data, i)); + make_stream(s); + init_stream(s, 1024); + + out_uint32_le(s, 2); /* update title info */ + out_uint32_le(s, win); /* window id */ + out_uint32_le(s, i); /* title size */ + out_uint8a(s, data, i); /* title */ + s_mark_end(s); + send_rail_drawing_orders(s->data, (int)(s->end - s->data)); + free_stream(s); + XFree(data); + } + return 0; +} + +/*****************************************************************************/ +int APP_CC +rail_request_title(int window_id) +{ + return rail_send_win_text(g_display, (Window)window_id); +} + /*****************************************************************************/ /* returns 0, event handled, 1 unhandled */ int APP_CC @@ -631,6 +748,7 @@ rail_xevent(void *xevent) Window wreturn; int revert_to; XWindowAttributes wnd_attributes; + char* prop_name; LOG(10, ("chansrv::rail_xevent:")); @@ -644,6 +762,17 @@ rail_xevent(void *xevent) switch (lxevent->type) { + case PropertyNotify: + prop_name = XGetAtomName(g_display, lxevent->xproperty.atom); + LOG(10, (" got PropertyNotify window_id 0x%8.8x %s", + lxevent->xproperty.window, prop_name)); + if (strcmp(prop_name, "WM_NAME") == 0 || + strcmp(prop_name, "_NEW_WM_NAME") == 0) + { + rail_send_win_text(g_display, lxevent->xproperty.window); + rv = 0; + } + break; case ConfigureRequest: LOG(10, (" got ConfigureRequest window_id 0x%8.8x", lxevent->xconfigurerequest.window)); g_memset(&xwc, 0, sizeof(xwc)); @@ -661,6 +790,13 @@ rail_xevent(void *xevent) rv = 0; break; + case CreateNotify: + LOG(10, (" got CreateNotify")); + XSelectInput(g_display, lxevent->xcreatewindow.window, + PropertyChangeMask | StructureNotifyMask); + v = 0; + break; + case MapRequest: LOG(10, (" got MapRequest")); XMapWindow(g_display, lxevent->xmaprequest.window); diff --git a/sesman/chansrv/rail.h b/sesman/chansrv/rail.h index 7dbcbc5a..50bbfd36 100644 --- a/sesman/chansrv/rail.h +++ b/sesman/chansrv/rail.h @@ -31,5 +31,6 @@ rail_data_in(struct stream* s, int chan_id, int chan_flags, int length, int total_length); int APP_CC rail_xevent(void* xevent); +int APP_CC rail_request_title(int window_id); #endif diff --git a/sesman/chansrv/xcommon.c b/sesman/chansrv/xcommon.c index c5a91cae..8fd8e741 100644 --- a/sesman/chansrv/xcommon.c +++ b/sesman/chansrv/xcommon.c @@ -40,6 +40,8 @@ int g_screen_num = 0; Window g_root_window = 0; Atom g_wm_delete_window_atom = 0; Atom g_wm_protocols_atom = 0; +Atom g_utf8_string = 0; +Atom g_net_wm_name = 0; /*****************************************************************************/ static int DEFAULT_CC @@ -117,6 +119,8 @@ xcommon_init(void) g_wm_delete_window_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", 0); g_wm_protocols_atom = XInternAtom(g_display, "WM_PROTOCOLS", 0); + g_utf8_string = XInternAtom(g_display, "UTF8_STRIING", 0); + g_net_wm_name = XInternAtom(g_display, "_NET_WM_NAME", 0); return 0; } diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index 839854af..1235edf6 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -824,6 +824,8 @@ rdpDestroyWindow(WindowPtr pWindow) if (g_use_rail) { + LLOGLN(10, (" rdpup_delete_window")); + rdpup_delete_window(pWindow, priv); } return rv; @@ -914,7 +916,16 @@ rdpUnrealizeWindow(WindowPtr pWindow) { LLOGLN(10, ("rdpUnrealizeWindow:")); priv->status = 0; - rdpup_delete_window(pWindow, priv); + if (pWindow->overrideRedirect) { + /* + * Popups are unmapped by X server, so probably + * they will be mapped again. Thereby we should + * just hide those popups instead of destroying + * them. + */ + LLOGLN(10, (" rdpup_show_window")); + rdpup_show_window(pWindow, priv, 0x0); /* 0x0 - do not show the window */ + } } } diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index 61ed302a..620b53c4 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -1771,7 +1771,7 @@ rdpup_create_window(WindowPtr pWindow, rdpWindowRec *priv) out_uint32_le(g_out_s, style); /* style */ out_uint32_le(g_out_s, ext_style); /* extended_style */ flags |= WINDOW_ORDER_FIELD_STYLE; - out_uint32_le(g_out_s, 0); /* show_state */ + out_uint32_le(g_out_s, 0x05); /* show_state */ flags |= WINDOW_ORDER_FIELD_SHOW; out_uint16_le(g_out_s, title_bytes); /* title_info */ out_uint8a(g_out_s, title, title_bytes); @@ -1841,6 +1841,27 @@ rdpup_delete_window(WindowPtr pWindow, rdpWindowRec *priv) } } +/******************************************************************************/ +void +rdpup_show_window(WindowPtr pWindow, rdpWindowRec* priv, int showState) +{ + LLOGLN(10, ("rdpup_show_window: id 0x%8.8x state 0x%x", pWindow->drawable.id, + showState)); + if (g_connected) + { + int flags = WINDOW_ORDER_TYPE_WINDOW; + + rdpup_pre_check(16); + out_uint16_le(g_out_s, 27); + out_uint16_le(g_out_s, 16); + g_count++; + out_uint32_le(g_out_s, pWindow->drawable.id); + flags |= WINDOW_ORDER_FIELD_SHOW; + out_uint32_le(g_out_s, flags); + out_uint32_le(g_out_s, showState); + } +} + /******************************************************************************/ int rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec *pDirtyPriv) diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 0a79810b..aeac2868 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -675,6 +675,79 @@ xrdp_mm_trans_process_channel_data(struct xrdp_mm *self, struct trans *trans) return rv; } +/*****************************************************************************/ +/* returns error */ +static int APP_CC +xrdp_mm_trans_send_channel_rail_title_request(struct xrdp_mm* self, + int window_id) +{ + struct stream* s; + + s = trans_get_out_s(self->chan_trans, 8192); + g_writeln("xrdp_mm_trans_send_channel_rail_title_request: 0x%8.8x", + window_id); + + if (s == 0) + { + return 1; + } + out_uint32_le(s, 0); /* version */ + out_uint32_le(s, 8 + 8 + 4); /* size */ + out_uint32_le(s, 9); /* msg id */ + out_uint32_le(s, 8 + 4); /* size */ + out_uint32_le(s, window_id); + s_mark_end(s); + return trans_force_write(self->chan_trans); +} + +/*****************************************************************************/ +/* returns error + process alternate secondary drawing orders for rail channel */ +static int APP_CC +xrdp_mm_process_rail_drawing_orders(struct xrdp_mm* self, struct trans* trans) +{ + struct stream* s; + int size; + int order_type; + int window_id; + int flags; + int rv = 0; + struct rail_window_state_order rwso; + + g_writeln("xrdp_mm_process_rail_drawing_orders:"); + + s = trans_get_in_s(trans); + if (s == 0) + { + return 1; + } + in_uint32_le(s, order_type); + + switch(order_type) + { + case 2: /* update title info */ + in_uint32_le(s, window_id); + g_writeln(" update window title info: 0x%8.8x", window_id); + + g_memset(&rwso, 0, sizeof(rwso)); + in_uint32_le(s, size); /* title size */ + rwso.title_info = g_malloc(size + 1, 0); + in_uint8a(s, rwso.title_info, size); + rwso.title_info[size] = 0; + flags = WINDOW_ORDER_FIELD_TITLE; + rv = libxrdp_orders_init(self->wm->session); + rv = libxrdp_window_new_update(self->wm->session, window_id, &rwso, flags); + rv = libxrdp_orders_send(self->wm->session); + g_writeln(" set window title %s %d", rwso.title_info, rv); + g_free(rwso.title_info); + break; + default: + break; + } + + return 0; +} + /*****************************************************************************/ /* returns error process a message for the channel handler */ @@ -708,6 +781,9 @@ xrdp_mm_chan_process_msg(struct xrdp_mm *self, struct trans *trans, case 8: /* channel data */ rv = xrdp_mm_trans_process_channel_data(self, trans); break; + case 10: /* rail alternate secondary drawing orders */ + rv = xrdp_mm_process_rail_drawing_orders(self, trans); + break; default: log_message(LOG_LEVEL_ERROR,"xrdp_mm_chan_process_msg: unknown id %d", id); break; @@ -2551,6 +2627,12 @@ server_window_new_update(struct xrdp_mod *mod, int window_id, struct xrdp_wm *wm; wm = (struct xrdp_wm *)(mod->wm); + if ((flags & WINDOW_ORDER_STATE_NEW) && + !(window_state->style & 0x80000000)) + { + /* requesting title info / icon info */ + xrdp_mm_trans_send_channel_rail_title_request(wm->mm, window_id); + } return libxrdp_window_new_update(wm->session, window_id, window_state, flags); } diff --git a/xup/xup.c b/xup/xup.c index 27063366..882d157c 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -473,6 +473,25 @@ process_server_window_new_update(struct mod *mod, struct stream *s) return rv; } +/******************************************************************************/ +/* return error */ +static int APP_CC +process_server_window_show(struct mod* mod, struct stream* s) +{ + int window_id; + int rv; + int flags; + struct rail_window_state_order rwso; + + g_memset(&rwso, 0, sizeof(rwso)); + in_uint32_le(s, window_id); + in_uint32_le(s, flags); + in_uint32_le(s, rwso.show_state); + mod->server_window_new_update(mod, window_id, &rwso, flags); + rv = 0; + return rv; +} + /******************************************************************************/ /* return error */ static int APP_CC @@ -653,6 +672,9 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s) case 26: /* server_window_delete */ rv = process_server_window_delete(mod, s); break; + case 27: /* server_window_new_update - show */ + rv = process_server_window_show(mod, s); + break; case 51: /* server_set_pointer_ex */ rv = process_server_set_pointer_ex(mod, s); break; From 3221caff627f119080a98bb5ff34b12c99b10474 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sun, 30 Jun 2013 12:40:39 -0700 Subject: [PATCH 02/31] Hand-apply patches (keyboard fix for alt,shift on focus in) from Authentic8 branch: 108e625 29947e5 --- xorg/X11R7.6/rdp/rdpinput.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xorg/X11R7.6/rdp/rdpinput.c b/xorg/X11R7.6/rdp/rdpinput.c index 39cd78dd..9fa7fa0a 100644 --- a/xorg/X11R7.6/rdp/rdpinput.c +++ b/xorg/X11R7.6/rdp/rdpinput.c @@ -916,9 +916,13 @@ KbdAddEvent(int down, int param1, int param2, int param3, int param4) if (x_scancode > 0) { + /* left or right shift */ + if ((rdp_scancode == 42) || (rdp_scancode == 54)) + { + g_shift_down = down ? x_scancode : 0; + } rdpEnqueueKey(type, x_scancode); } - break; case 56: /* left - right alt button */ @@ -932,6 +936,7 @@ KbdAddEvent(int down, int param1, int param2, int param3, int param4) x_scancode = 64; /* left alt button */ } + g_alt_down = down ? x_scancode : 0; rdpEnqueueKey(type, x_scancode); break; From 3ae1b415a1805bf537bc907370e1a60d9da3aa56 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sun, 30 Jun 2013 16:05:23 -0700 Subject: [PATCH 03/31] Hand-apply patches (rail improvements) from Authentic8 branch: 6e15b4a 2c99e69 3f30429 aad2aaa 4f8481e 5117ac2 f3dcf1a --- sesman/chansrv/chansrv.c | 16 -- sesman/chansrv/rail.c | 521 +++++++++++++++++++++++++++++++------ sesman/chansrv/rail.h | 1 + sesman/chansrv/xcommon.c | 6 +- xorg/X11R7.6/rdp/rdpdraw.c | 6 + xorg/X11R7.6/rdp/rdpup.c | 2 + xrdp/xrdp_mm.c | 204 +++++++++++---- 7 files changed, 609 insertions(+), 147 deletions(-) diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index cef7812b..fd6bd787 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -525,19 +525,6 @@ process_message_channel_data(struct stream *s) return rv; } -/*****************************************************************************/ -/* returns error */ -static int APP_CC -process_message_channel_rail_title_request(struct stream* s) -{ - int window_id; - LOG(10, ("process_message_channel_rail_title_request:")); - - in_uint32_le(s, window_id); - rail_request_title(window_id); - return 0; -} - /*****************************************************************************/ /* returns error */ static int APP_CC @@ -595,9 +582,6 @@ process_message(void) case 7: /* channel data response */ rv = process_message_channel_data_response(s); break; - case 9: - rv = process_message_channel_rail_title_request(s); - break; default: LOGM((LOG_LEVEL_ERROR, "process_message: error in process_message ", "unknown msg %d", id)); diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index cc6c8feb..ff926177 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -43,6 +43,7 @@ extern Atom g_wm_delete_window_atom; /* in xcommon.c */ extern Atom g_wm_protocols_atom; /* in xcommon.c */ extern Atom g_utf8_string; /* in xcommon.c */ extern Atom g_net_wm_name; /* in xcommon.c */ +extern Atom g_wm_state; /* in xcommon.c */ int g_rail_up = 0; @@ -103,6 +104,24 @@ static int g_rail_running = 1; /* Perform the default action of the window's system menu. */ #define SC_DEFAULT 0xF160 +/* for tooltips */ +#define RAIL_STYLE_TOOLTIP (0x80000000) +#define RAIL_EXT_STYLE_TOOLTIP (0x00000080 | 0x00000008) + +/* for normal desktop windows */ +#define RAIL_STYLE_NORMAL (0x00C00000 | 0x00080000 | 0x00040000 | 0x00010000 | 0x00020000) +#define RAIL_EXT_STYLE_NORMAL (0x00040000) + +/* for dialogs */ +#define RAIL_STYLE_DIALOG (0x80000000) +#define RAIL_EXT_STYLE_DIALOG (0x00040000) + +static int APP_CC rail_win_get_state(Window win); +static int APP_CC rail_create_window(Window window_id, Window parent_id); +static int APP_CC rail_win_set_state(Window win, unsigned long state); +static int APP_CC rail_show_window(Window window_id, int show_state); +static int APP_CC rail_win_send_text(Window win); + /******************************************************************************/ static int APP_CC is_window_valid_child_of_root(unsigned int window_id) @@ -260,7 +279,6 @@ read_uni(struct stream *s, int num_chars) static int APP_CC rail_process_exec(struct stream *s, int size) { - int pid; int flags; int ExeOrFileLength; int WorkingDirLength; @@ -307,6 +325,10 @@ rail_close_window(int window_id) XEvent ce; LOG(0, ("chansrv::rail_close_window:")); + + /* don't receive UnmapNotify for closing window */ + XSelectInput(g_display, window_id, PropertyChangeMask); + g_memset(&ce, 0, sizeof(ce)); ce.xclient.type = ClientMessage; ce.xclient.message_type = g_wm_protocols_atom; @@ -341,11 +363,45 @@ rail_process_activate(struct stream *s, int size) XWindowAttributes window_attributes; XGetWindowAttributes(g_display, window_id, &window_attributes); + LOG(10, (" window attributes: override_redirect %d", + window_attributes.override_redirect)); if (window_attributes.override_redirect) { LOG(10, (" dismiss popup window 0x%8.8x", window_id)); - rail_close_window(window_id); + XUnmapWindow(g_display, window_id); + //rail_win_set_state(window_id, 0x3); + //rail_show_window(window_id, 0x0); + } + } + return 0; +} + +/*****************************************************************************/ +static int APP_CC +rail_restore_windows(void) +{ + unsigned int i; + unsigned int nchild; + Window r; + Window p; + Window* children; + + XQueryTree(g_display, g_root_window, &r, &p, &children, &nchild); + for (i = 0; i < nchild; i++) + { + XWindowAttributes window_attributes; + XGetWindowAttributes(g_display, children[i], &window_attributes); + if (!window_attributes.override_redirect) + { + if (window_attributes.map_state == IsViewable) + { + rail_win_set_state(children[i], 0x0); /* WithdrawnState */ + rail_create_window(children[i], g_root_window); + rail_win_set_state(children[i], 0x1); /* NormalState */ + rail_win_send_text(children[i]); + } } } + XFree(children); return 0; } @@ -358,9 +414,137 @@ rail_process_system_param(struct stream *s, int size) LOG(10, ("chansrv::rail_process_system_param:")); in_uint32_le(s, system_param); LOG(10, (" system_param 0x%8.8x", system_param)); + /* + * Ask client to re-create the existing rail windows. This is supposed + * to be done after handshake and client is initialised properly, we + * consider client is ready when it sends "SET_WORKAREA" sysparam. + */ + if (system_param == 0x0000002F) /*SPI_SET_WORK_AREA*/ + { + LOG(10, (" restore rail windows")); + rail_restore_windows(); + } + return 0; +} + +/*****************************************************************************/ +static int APP_CC +rail_get_property(Display* display, Window target, Atom type, Atom property, + unsigned char** data, unsigned long* count) +{ + Atom atom_return; + int size; + unsigned long nitems, bytes_left; + char* prop_name; + + int ret = XGetWindowProperty(display, target, property, + 0l, 1l, False, + type, &atom_return, &size, + &nitems, &bytes_left, data); + if ((ret != Success || nitems < 1) && atom_return == None) + { + prop_name = XGetAtomName(g_display, property); + LOG(10, (" rail_get_property %s: failed", prop_name)); + XFree(prop_name); + return 1; + } + + if (bytes_left != 0) + { + XFree(*data); + unsigned long remain = ((size / 8) * nitems) + bytes_left; + ret = XGetWindowProperty(g_display, target, + property, 0l, remain, False, + atom_return, &atom_return, &size, + &nitems, &bytes_left, data); + if (ret != Success) + { + return 1; + } + } + + *count = nitems; return 0; } +/*****************************************************************************/ +static int APP_CC +rail_win_get_state(Window win) +{ + unsigned long nitems = 0; + int rv = -1; + char* data = 0; + + rail_get_property(g_display, win, g_wm_state, g_wm_state, + (unsigned char **)&data, + &nitems); + + if (data || nitems > 0) + { + rv = *(unsigned long *)data; + XFree(data); + LOG(10, (" rail_win_get_state: %d", rv)); + } + + return rv; +} + +/*****************************************************************************/ +static int APP_CC +rail_win_set_state(Window win, unsigned long state) +{ + int old_state; + unsigned long data[2] = { state, None }; + + LOG(10, (" rail_win_set_state: %d", state)); + /* check whether WM_STATE exists */ + old_state = rail_win_get_state(win); + if (old_state == -1) + { + /* create WM_STATE property */ + XChangeProperty(g_display, win, g_wm_state, g_wm_state, 32, PropModeAppend, + (unsigned char *)data, 2); + LOG(10, (" rail_win_set_state: create WM_STATE property")); + } + else + { + XChangeProperty(g_display, win, g_wm_state, g_wm_state, 32, PropModeReplace, + (unsigned char *)data, 2); + } + return 0; +} + +/*****************************************************************************/ +static int APP_CC +rail_win_get_text(Window win, char **data) +{ + int ret = 0; + int i = 0; + unsigned long nitems = 0; + + ret = rail_get_property(g_display, win, g_utf8_string, g_net_wm_name, + (unsigned char **)data, &nitems); + if (ret != 0) + { + /* _NET_WM_NAME isn't set, use WM_NAME (XFetchName) instead */ + XFetchName(g_display, win, data); + } + + if (data) + { + char *ptr = *data; + for (; ptr != NULL; i++) + { + if (ptr[i] == '\0') + { + break; + } + } + } + + return i; +} + /******************************************************************************/ static int APP_CC rail_minmax_window(int window_id, int max) @@ -371,8 +555,13 @@ rail_minmax_window(int window_id, int max) } else { XUnmapWindow(g_display, window_id); - LOG(10, (" XUnmapWindow")); + /* change window state to IconicState (3) */ + rail_win_set_state(window_id, 0x3); + /* + * TODO dismiss popups opened so far + */ } + return 0; } /*****************************************************************************/ @@ -380,8 +569,12 @@ static int APP_CC rail_restore_window(int window_id) { LOG(10, ("chansrv::rail_restore_window 0x%8.8x:", window_id)); - LOG(10, (" XMapWindow")); XMapWindow(g_display, window_id); + LOG(10, ("chansrv::rail_process_activate: calling XRaiseWindow 0x%8.8x", window_id)); + XRaiseWindow(g_display, window_id); + LOG(10, ("chansrv::rail_process_activate: calling XSetInputFocus 0x%8.8x", window_id)); + XSetInputFocus(g_display, window_id, RevertToParent, CurrentTime); + return 0; } /*****************************************************************************/ @@ -651,73 +844,27 @@ rail_data_in(struct stream *s, int chan_id, int chan_flags, int length, } /*****************************************************************************/ -int APP_CC -rail_get_property(Display *display, Window target, Atom type, Atom property, - unsigned char** data, unsigned long* count) { - Atom atom_return; - int size; - unsigned long nitems, bytes_left; - - int ret = XGetWindowProperty(display, target, property, - 0l, 1l, False, - type, &atom_return, &size, - &nitems, &bytes_left, data); - if (ret != Success || nitems < 1) - { - return 0; - } - - if (bytes_left != 0) - { - XFree(*data); - unsigned long remain = ((size / 8) * nitems) + bytes_left; - ret = XGetWindowProperty(g_display, target, - property, 0l, remain, False, - type, &atom_return, &size, - &nitems, &bytes_left, data); - if (ret != Success) - { - return 1; - } - } - - *count = nitems; - return 0; -} - -/*****************************************************************************/ -const int APP_CC -rail_send_win_text(Display *disp, Window win) { - unsigned char *data = 0; - unsigned long nitems = 0; +/* returns 0, event handled, 1 unhandled */ +static int APP_CC +rail_win_send_text(Window win) { + char* data = 0; struct stream* s; + int len = 0; + int flags; - rail_get_property(disp, win, g_utf8_string, g_net_wm_name, - &data, &nitems); - if (nitems == 0) - { - /* _NET_WM_NAME isn't set, use WM_NAME (XFetchName) instead */ - XFetchName(disp, win, (char **)&data); - } + len = rail_win_get_text(win, &data); - if (data) - { - int i = 0; - for (;;i++) - { - if (data[i] == '\0') - { - break; - } - } - LOG(10, ("rail_send_win_text: 0x%8.8x text 0x%x size %d", win, data, i)); + if (data && len > 0) { + LOG(10, ("chansrv::rail_win_send_text: 0x%8.8x text %s length %d", + win, data, len)); make_stream(s); init_stream(s, 1024); - - out_uint32_le(s, 2); /* update title info */ + flags = WINDOW_ORDER_TYPE_WINDOW | WINDOW_ORDER_FIELD_TITLE; + out_uint32_le(s, 8); /* update title info */ out_uint32_le(s, win); /* window id */ - out_uint32_le(s, i); /* title size */ - out_uint8a(s, data, i); /* title */ + out_uint32_le(s, flags); /* flags */ + out_uint32_le(s, len); /* title size */ + out_uint8a(s, data, len); /* title */ s_mark_end(s); send_rail_drawing_orders(s->data, (int)(s->end - s->data)); free_stream(s); @@ -727,10 +874,173 @@ rail_send_win_text(Display *disp, Window win) { } /*****************************************************************************/ -int APP_CC -rail_request_title(int window_id) +static int APP_CC +rail_destroy_window(Window window_id) +{ + LOG(10, ("chansrv::rail_destroy_window 0x%8.8x", window_id)); + make_stream(s); + init_stream(s, 1024); + + out_uint32_le(s, 4); /* destroy_window */ + out_uint32_le(s, window_id); + s_mark_end(s); + send_rail_drawing_orders(s->data, (int)(s->end - s->data)); + free_stream(s); + + return 0; +} + +/*****************************************************************************/ +static int APP_CC +rail_show_window(Window window_id, int show_state) { - return rail_send_win_text(g_display, (Window)window_id); + int flags; + struct stream* s; + + LOG(10, ("chansrv::rail_show_window 0x%8.8x 0x%x", window_id, show_state)); + make_stream(s); + init_stream(s, 1024); + + flags = WINDOW_ORDER_TYPE_WINDOW | WINDOW_ORDER_FIELD_SHOW; + out_uint32_le(s, 6); /* show_window */ + out_uint32_le(s, window_id); /* window_id */ + out_uint32_le(s, flags); /* flags */ + out_uint32_le(s, show_state); /* show_state */ + s_mark_end(s); + send_rail_drawing_orders(s->data, (int)(s->end - s->data)); + free_stream(s); + return 0; +} + +/*****************************************************************************/ +static int APP_CC +rail_create_window(Window window_id, Window parent_id) +{ + int x; + int y; + tui32 width; + tui32 height; + tui32 border; + Window root; + tui32 depth; + char* title_bytes = 0; + int title_size = 0; + XWindowAttributes attributes; + int style; + int ext_style; + int num_window_rects = 1; + int num_visibility_rects = 1; + int i = 0; + + int flags; + int state; + struct stream* s; + + LOG(10, ("chansrv::rail_create_window 0x%8.8x", window_id)); + + XGetGeometry(g_display, window_id, &root, &x, &y, &width, &height, + &border, &depth); + XGetWindowAttributes(g_display, window_id, &attributes); + + LOG(10, (" x %d y %d width %d height %d border_width %d", x, y, width, + height, border)); + + state = rail_win_get_state(window_id); + if ((state == 0) || (state == -1)) + { + LOG(10, (" create new window")); + flags = WINDOW_ORDER_TYPE_WINDOW | WINDOW_ORDER_STATE_NEW; + list_add_item(g_window_list, window_id); + } + else + { + LOG(10, (" update existing window")); + flags = WINDOW_ORDER_TYPE_WINDOW; + } + + title_size = rail_win_get_text(window_id, &title_bytes); + + if (attributes.override_redirect) + { + style = RAIL_STYLE_TOOLTIP; + ext_style = RAIL_EXT_STYLE_TOOLTIP; + } + else + { + style = RAIL_STYLE_NORMAL; + ext_style = RAIL_EXT_STYLE_NORMAL; + } + + make_stream(s); + init_stream(s, 1024); + + out_uint32_le(s, 2); /* create_window */ + out_uint32_le(s, window_id); /* window_id */ + out_uint32_le(s, parent_id); /* owner_window_id */ + flags |= WINDOW_ORDER_FIELD_OWNER; + out_uint32_le(s, style); /* style */ + out_uint32_le(s, ext_style); /* extended_style */ + flags |= WINDOW_ORDER_FIELD_STYLE; + out_uint32_le(s, 0x05); /* show_state */ + flags |= WINDOW_ORDER_FIELD_SHOW; + if (title_size > 0) + { + out_uint16_le(s, title_size); /* title_size */ + out_uint8a(s, title_bytes, title_size); /* title */ + } + else + { + out_uint16_le(s, 5); /* title_size */ + out_uint8a(s, "title", 5); /* title */ + } + LOG(10, (" set title info %d", title_size)); + flags |= WINDOW_ORDER_FIELD_TITLE; + out_uint32_le(s, 0); /* client_offset_x */ + out_uint32_le(s, 0); /* client_offset_y */ + flags |= WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET; + out_uint32_le(s, width); /* client_area_width */ + out_uint32_le(s, height); /* client_area_height */ + flags |= WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE; + out_uint32_le(s, 0); /* rp_content */ + out_uint32_le(s, g_root_window); /* root_parent_handle */ + flags |= WINDOW_ORDER_FIELD_ROOT_PARENT; + out_uint32_le(s, x); /* window_offset_x */ + out_uint32_le(s, y); /* window_offset_y */ + flags |= WINDOW_ORDER_FIELD_WND_OFFSET; + out_uint32_le(s, 0); /* window_client_delta_x */ + out_uint32_le(s, 0); /* window_client_delta_y */ + flags |= WINDOW_ORDER_FIELD_WND_CLIENT_DELTA; + out_uint32_le(s, width); /* window_width */ + out_uint32_le(s, height); /* window_height */ + flags |= WINDOW_ORDER_FIELD_WND_SIZE; + out_uint16_le(s, num_window_rects); /* num_window_rects */ + for (i = 0; i < num_window_rects; i++) + { + out_uint16_le(s, 0); /* left */ + out_uint16_le(s, 0); /* top */ + out_uint16_le(s, width); /* right */ + out_uint16_le(s, height); /* bottom */ + } + flags |= WINDOW_ORDER_FIELD_WND_RECTS; + out_uint32_le(s, x); /* visible_offset_x */ + out_uint32_le(s, y); /* visible_offset_y */ + flags |= WINDOW_ORDER_FIELD_VIS_OFFSET; + out_uint16_le(s, num_visibility_rects); /* num_visibility_rects */ + for (i = 0; i < num_visibility_rects; i++) + { + out_uint16_le(s, 0); /* left */ + out_uint16_le(s, 0); /* top */ + out_uint16_le(s, width); /* right */ + out_uint16_le(s, height); /* bottom */ + } + flags |= WINDOW_ORDER_FIELD_VISIBILITY; + out_uint32_le(s, flags); /*flags*/ + + s_mark_end(s); + send_rail_drawing_orders(s->data, (int)(s->end - s->data)); + free_stream(s); + XFree(title_bytes); + return 0; } /*****************************************************************************/ @@ -741,12 +1051,6 @@ rail_xevent(void *xevent) XEvent *lxevent; XWindowChanges xwc; int rv; - int nchildren_return = 0; - Window root_return; - Window parent_return; - Window *children_return; - Window wreturn; - int revert_to; XWindowAttributes wnd_attributes; char* prop_name; @@ -764,14 +1068,20 @@ rail_xevent(void *xevent) { case PropertyNotify: prop_name = XGetAtomName(g_display, lxevent->xproperty.atom); - LOG(10, (" got PropertyNotify window_id 0x%8.8x %s", - lxevent->xproperty.window, prop_name)); - if (strcmp(prop_name, "WM_NAME") == 0 || - strcmp(prop_name, "_NEW_WM_NAME") == 0) + LOG(10, (" got PropertyNotify window_id 0x%8.8x %s state new %d", + lxevent->xproperty.window, prop_name, + lxevent->xproperty.state == PropertyNewValue)); + if (g_strcmp(prop_name, "WM_NAME") == 0 || + g_strcmp(prop_name, "_NET_WM_NAME") == 0) { - rail_send_win_text(g_display, lxevent->xproperty.window); - rv = 0; + XGetWindowAttributes(g_display, lxevent->xproperty.window, &wnd_attributes); + if (wnd_attributes.map_state == IsViewable) + { + rail_win_send_text(lxevent->xproperty.window); + rv = 0; + } } + XFree(prop_name); break; case ConfigureRequest: LOG(10, (" got ConfigureRequest window_id 0x%8.8x", lxevent->xconfigurerequest.window)); @@ -791,24 +1101,67 @@ rail_xevent(void *xevent) break; case CreateNotify: - LOG(10, (" got CreateNotify")); + LOG(10, (" got CreateNotify 0x%8.8x", lxevent->xcreatewindow.window)); XSelectInput(g_display, lxevent->xcreatewindow.window, PropertyChangeMask | StructureNotifyMask); + rail_win_set_state(lxevent->xcreatewindow.window, 0x0); /* WithdrawnState */ + rv = 0; + break; + + case DestroyNotify: + LOG(10, (" got DestroyNotify 0x%8.8x", lxevent->xdestroywindow.window)); + /* + * FIXME The destroy msg may be sent from a non-rail window. Ideally, + * this will be handled by client, but we better have to maintain + * a list of managed rail windows here. + */ + rail_destroy_window(lxevent->xdestroywindow.window); v = 0; break; case MapRequest: - LOG(10, (" got MapRequest")); + LOG(10, (" got MapRequest 0x%8.8x", lxevent->xmaprequest.window)); XMapWindow(g_display, lxevent->xmaprequest.window); rv = 0; break; case MapNotify: - LOG(10, (" got MapNotify")); + LOG(10, (" got MapNotify 0x%8.8x", lxevent->xmap.event)); + if (lxevent->xmap.window != lxevent->xmap.event) + { + XGetWindowAttributes(g_display, lxevent->xmap.window, &wnd_attributes); + if (wnd_attributes.map_state == IsViewable) + { + rail_create_window(lxevent->xmap.window, lxevent->xmap.event); + rail_win_set_state(lxevent->xmap.window, 0x1); /* NormalState */ + if (!wnd_attributes.override_redirect) + { + rail_win_send_text(lxevent->xmap.window); + } + rv = 0; + } + } break; case UnmapNotify: - LOG(10, (" got UnmapNotify")); + LOG(10, (" got UnmapNotify 0x%8.8x", lxevent->xunmap.event)); + if (lxevent->xunmap.window == lxevent->xunmap.event && + is_window_valid_child_of_root(lxevent->xunmap.window)) + { + int state = rail_win_get_state(lxevent->xunmap.window); + LOG(10, (" window 0x%8.8x is unmapped", lxevent->xunmap.window)); + if (state != -1 && state != 0x3) + { + LOG(10, (" trying to dismiss popup")); + XGetWindowAttributes(g_display, lxevent->xunmap.window, &wnd_attributes); + if (wnd_attributes.override_redirect) + { + rail_show_window(lxevent->xunmap.window, 0x0); + rail_win_set_state(lxevent->xunmap.window, 0x3); + rv = 0; + } + } + } break; case ConfigureNotify: diff --git a/sesman/chansrv/rail.h b/sesman/chansrv/rail.h index 50bbfd36..3be3a15d 100644 --- a/sesman/chansrv/rail.h +++ b/sesman/chansrv/rail.h @@ -19,6 +19,7 @@ #ifndef _RAIL_H_ #define _RAIL_H_ +#include "../../common/rail.h" #include "arch.h" #include "parse.h" diff --git a/sesman/chansrv/xcommon.c b/sesman/chansrv/xcommon.c index 8fd8e741..9884040f 100644 --- a/sesman/chansrv/xcommon.c +++ b/sesman/chansrv/xcommon.c @@ -42,6 +42,7 @@ Atom g_wm_delete_window_atom = 0; Atom g_wm_protocols_atom = 0; Atom g_utf8_string = 0; Atom g_net_wm_name = 0; +Atom g_wm_state = 0; /*****************************************************************************/ static int DEFAULT_CC @@ -119,9 +120,10 @@ xcommon_init(void) g_wm_delete_window_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", 0); g_wm_protocols_atom = XInternAtom(g_display, "WM_PROTOCOLS", 0); - g_utf8_string = XInternAtom(g_display, "UTF8_STRIING", 0); + g_utf8_string = XInternAtom(g_display, "UTF8_STRING", 0); g_net_wm_name = XInternAtom(g_display, "_NET_WM_NAME", 0); - + g_wm_state = XInternAtom(g_display, "WM_STATE", 0); + return 0; } diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index 1235edf6..602342b7 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -824,8 +824,10 @@ rdpDestroyWindow(WindowPtr pWindow) if (g_use_rail) { +#ifdef XRDP_WM_RDPUP LLOGLN(10, (" rdpup_delete_window")); rdpup_delete_window(pWindow, priv); +#endif } return rv; @@ -887,7 +889,9 @@ rdpRealizeWindow(WindowPtr pWindow) pWindow->drawable.x, pWindow->drawable.y, pWindow->drawable.width, pWindow->drawable.height)); priv->status = 1; +#ifdef XRDP_WM_RDPUP rdpup_create_window(pWindow, priv); +#endif } } } @@ -917,6 +921,7 @@ rdpUnrealizeWindow(WindowPtr pWindow) LLOGLN(10, ("rdpUnrealizeWindow:")); priv->status = 0; if (pWindow->overrideRedirect) { +#ifdef XRDP_WM_RDPUP /* * Popups are unmapped by X server, so probably * they will be mapped again. Thereby we should @@ -925,6 +930,7 @@ rdpUnrealizeWindow(WindowPtr pWindow) */ LLOGLN(10, (" rdpup_show_window")); rdpup_show_window(pWindow, priv, 0x0); /* 0x0 - do not show the window */ +#endif } } } diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index 620b53c4..3d7bf196 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -760,7 +760,9 @@ rdpup_process_msg(struct stream *s) if (g_rdpScreen.client_info.rail_support_level > 0) { g_use_rail = 1; +#ifdef XRDP_WM_RDPUP rdpup_send_rail(); +#endif } if (g_rdpScreen.client_info.offscreen_cache_entries == 2000) { diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index aeac2868..88c24611 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -676,28 +676,157 @@ xrdp_mm_trans_process_channel_data(struct xrdp_mm *self, struct trans *trans) } /*****************************************************************************/ -/* returns error */ +/* returns error + process rail create window order */ static int APP_CC -xrdp_mm_trans_send_channel_rail_title_request(struct xrdp_mm* self, - int window_id) +xrdp_mm_process_rail_create_window(struct xrdp_mm* self, struct stream* s) { - struct stream* s; + int flags; + int window_id; + int title_bytes; + int index; + int bytes; + int rv; + struct rail_window_state_order rwso; - s = trans_get_out_s(self->chan_trans, 8192); - g_writeln("xrdp_mm_trans_send_channel_rail_title_request: 0x%8.8x", - window_id); + g_memset(&rwso, 0, sizeof(rwso)); + in_uint32_le(s, window_id); - if (s == 0) - { - return 1; - } - out_uint32_le(s, 0); /* version */ - out_uint32_le(s, 8 + 8 + 4); /* size */ - out_uint32_le(s, 9); /* msg id */ - out_uint32_le(s, 8 + 4); /* size */ - out_uint32_le(s, window_id); - s_mark_end(s); - return trans_force_write(self->chan_trans); + g_writeln("xrdp_mm_process_rail_create_window: 0x%8.8x", window_id); + + in_uint32_le(s, rwso.owner_window_id); + in_uint32_le(s, rwso.style); + in_uint32_le(s, rwso.extended_style); + in_uint32_le(s, rwso.show_state); + in_uint16_le(s, title_bytes); + if (title_bytes > 0) + { + rwso.title_info = g_malloc(title_bytes + 1, 0); + in_uint8a(s, rwso.title_info, title_bytes); + rwso.title_info[title_bytes] = 0; + } + in_uint32_le(s, rwso.client_offset_x); + in_uint32_le(s, rwso.client_offset_y); + in_uint32_le(s, rwso.client_area_width); + in_uint32_le(s, rwso.client_area_height); + in_uint32_le(s, rwso.rp_content); + in_uint32_le(s, rwso.root_parent_handle); + in_uint32_le(s, rwso.window_offset_x); + in_uint32_le(s, rwso.window_offset_y); + in_uint32_le(s, rwso.window_client_delta_x); + in_uint32_le(s, rwso.window_client_delta_y); + in_uint32_le(s, rwso.window_width); + in_uint32_le(s, rwso.window_height); + in_uint16_le(s, rwso.num_window_rects); + if (rwso.num_window_rects > 0) + { + bytes = sizeof(struct rail_window_rect) * rwso.num_window_rects; + rwso.window_rects = (struct rail_window_rect*)g_malloc(bytes, 0); + for (index = 0; index < rwso.num_window_rects; index++) + { + in_uint16_le(s, rwso.window_rects[index].left); + in_uint16_le(s, rwso.window_rects[index].top); + in_uint16_le(s, rwso.window_rects[index].right); + in_uint16_le(s, rwso.window_rects[index].bottom); + } + } + in_uint32_le(s, rwso.visible_offset_x); + in_uint32_le(s, rwso.visible_offset_y); + in_uint16_le(s, rwso.num_visibility_rects); + if (rwso.num_visibility_rects > 0) + { + bytes = sizeof(struct rail_window_rect) * rwso.num_visibility_rects; + rwso.visibility_rects = (struct rail_window_rect*)g_malloc(bytes, 0); + for (index = 0; index < rwso.num_visibility_rects; index++) + { + in_uint16_le(s, rwso.visibility_rects[index].left); + in_uint16_le(s, rwso.visibility_rects[index].top); + in_uint16_le(s, rwso.visibility_rects[index].right); + in_uint16_le(s, rwso.visibility_rects[index].bottom); + } + } + in_uint32_le(s, flags); + rv = libxrdp_orders_init(self->wm->session); + rv = libxrdp_window_new_update(self->wm->session, window_id, &rwso, flags); + rv = libxrdp_orders_send(self->wm->session); + g_free(rwso.title_info); + g_free(rwso.window_rects); + g_free(rwso.visibility_rects); + return rv; +} + +/*****************************************************************************/ +/* returns error + process rail destroy window order */ +static int APP_CC +xrdp_mm_process_rail_destroy_window(struct xrdp_mm* self, struct stream* s) +{ + int window_id; + int rv; + + in_uint32_le(s, window_id); + g_writeln("xrdp_mm_process_rail_destroy_window 0x%8.8x", window_id); + rv = libxrdp_orders_init(self->wm->session); + rv = libxrdp_window_delete(self->wm->session, window_id); + rv = libxrdp_orders_send(self->wm->session); + return rv; +} + +/*****************************************************************************/ +/* returns error + process rail update window (show state) order */ +static int APP_CC +xrdp_mm_process_rail_show_window(struct xrdp_mm* self, struct stream* s) +{ + int window_id; + int rv; + int flags; + struct rail_window_state_order rwso; + + g_memset(&rwso, 0, sizeof(rwso)); + in_uint32_le(s, window_id); + in_uint32_le(s, flags); + in_uint32_le(s, rwso.show_state); + g_writeln("xrdp_mm_process_rail_show_window 0x%8.8x %x", window_id, + rwso.show_state); + rv = libxrdp_orders_init(self->wm->session); + rv = libxrdp_window_new_update(self->wm->session, window_id, &rwso, flags); + rv = libxrdp_orders_send(self->wm->session); + return rv; +} + +/*****************************************************************************/ +/* returns error + process rail update window (title) order */ +static int APP_CC +xrdp_mm_process_rail_update_window_text(struct xrdp_mm* self, struct stream* s) +{ + int size; + int flags; + int rv = 0; + int window_id; + struct rail_window_state_order rwso; + + g_writeln("xrdp_mm_process_rail_update_window_text:"); + + in_uint32_le(s, window_id); + in_uint32_le(s, flags); + g_writeln(" update window title info: 0x%8.8x", window_id); + + g_memset(&rwso, 0, sizeof(rwso)); + in_uint32_le(s, size); /* title size */ + rwso.title_info = g_malloc(size + 1, 0); + in_uint8a(s, rwso.title_info, size); + rwso.title_info[size] = 0; + g_writeln(" set window title %s size %d 0x%8.8x", rwso.title_info, size, flags); + rv = libxrdp_orders_init(self->wm->session); + rv = libxrdp_window_new_update(self->wm->session, window_id, &rwso, flags); + rv = libxrdp_orders_send(self->wm->session); + g_writeln(" set window title %s %d", rwso.title_info, rv); + + g_free(rwso.title_info); + + return rv; } /*****************************************************************************/ @@ -707,15 +836,10 @@ static int APP_CC xrdp_mm_process_rail_drawing_orders(struct xrdp_mm* self, struct trans* trans) { struct stream* s; - int size; int order_type; - int window_id; - int flags; int rv = 0; struct rail_window_state_order rwso; - g_writeln("xrdp_mm_process_rail_drawing_orders:"); - s = trans_get_in_s(trans); if (s == 0) { @@ -725,27 +849,23 @@ xrdp_mm_process_rail_drawing_orders(struct xrdp_mm* self, struct trans* trans) switch(order_type) { - case 2: /* update title info */ - in_uint32_le(s, window_id); - g_writeln(" update window title info: 0x%8.8x", window_id); - - g_memset(&rwso, 0, sizeof(rwso)); - in_uint32_le(s, size); /* title size */ - rwso.title_info = g_malloc(size + 1, 0); - in_uint8a(s, rwso.title_info, size); - rwso.title_info[size] = 0; - flags = WINDOW_ORDER_FIELD_TITLE; - rv = libxrdp_orders_init(self->wm->session); - rv = libxrdp_window_new_update(self->wm->session, window_id, &rwso, flags); - rv = libxrdp_orders_send(self->wm->session); - g_writeln(" set window title %s %d", rwso.title_info, rv); - g_free(rwso.title_info); + case 2: /* create_window */ + xrdp_mm_process_rail_create_window(self, s); + break; + case 4: /* destroy_window */ + xrdp_mm_process_rail_destroy_window(self, s); + break; + case 6: /* show_window */ + rv = xrdp_mm_process_rail_show_window(self, s); + break; + case 8: /* update title info */ + rv = xrdp_mm_process_rail_update_window_text(self, s); break; default: break; } - return 0; + return rv; } /*****************************************************************************/ @@ -2627,12 +2747,6 @@ server_window_new_update(struct xrdp_mod *mod, int window_id, struct xrdp_wm *wm; wm = (struct xrdp_wm *)(mod->wm); - if ((flags & WINDOW_ORDER_STATE_NEW) && - !(window_state->style & 0x80000000)) - { - /* requesting title info / icon info */ - xrdp_mm_trans_send_channel_rail_title_request(wm->mm, window_id); - } return libxrdp_window_new_update(wm->session, window_id, window_state, flags); } From bec583624c996ae60afe5e38a3606b5c2a8cd4ff Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sun, 30 Jun 2013 16:12:09 -0700 Subject: [PATCH 04/31] Hand-apply patches (rail improvements) from Authentic8 branch: 6d97878 --- sesman/chansrv/rail.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index ff926177..b74c3a8b 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -28,6 +28,7 @@ #include "log.h" #include "os_calls.h" #include "thread_calls.h" +#include "list.h" extern int g_rail_chan_id; /* in chansrv.c */ extern int g_display_num; /* in chansrv.c */ @@ -49,6 +50,8 @@ int g_rail_up = 0; /* for rail_is_another_wm_running */ static int g_rail_running = 1; +/* list of valid rail windows */ +static struct list* g_window_list = 0; /* Indicates a Client Execute PDU from client to server. */ #define TS_RAIL_ORDER_EXEC 0x0001 @@ -219,7 +222,8 @@ rail_init(void) log_message(LOG_LEVEL_ERROR, "rail_init: another window manager " "is running"); } - + list_delete(g_window_list); + g_window_list = list_create(); rail_send_init(); g_rail_up = 1; return 0; @@ -231,6 +235,8 @@ rail_deinit(void) { if (g_rail_up) { + list_delete(g_window_list); + g_window_list = 0; /* no longer window manager */ XSelectInput(g_display, g_root_window, 0); g_rail_up = 0; @@ -1051,6 +1057,7 @@ rail_xevent(void *xevent) XEvent *lxevent; XWindowChanges xwc; int rv; + int index; XWindowAttributes wnd_attributes; char* prop_name; @@ -1105,17 +1112,18 @@ rail_xevent(void *xevent) XSelectInput(g_display, lxevent->xcreatewindow.window, PropertyChangeMask | StructureNotifyMask); rail_win_set_state(lxevent->xcreatewindow.window, 0x0); /* WithdrawnState */ + list_add_item(g_window_list, lxevent->xcreatewindow.window); rv = 0; break; case DestroyNotify: LOG(10, (" got DestroyNotify 0x%8.8x", lxevent->xdestroywindow.window)); - /* - * FIXME The destroy msg may be sent from a non-rail window. Ideally, - * this will be handled by client, but we better have to maintain - * a list of managed rail windows here. - */ - rail_destroy_window(lxevent->xdestroywindow.window); + index = list_index_of(g_window_list, lxevent->xdestroywindow.window); + if (index >= 0) + { + rail_destroy_window(lxevent->xdestroywindow.window); + list_remove_item(g_window_list, index); + } v = 0; break; From 587231445c788471129e6dccc4a734a7cd78dfee Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Tue, 2 Jul 2013 17:16:39 -0700 Subject: [PATCH 05/31] Hand-apply patches (keyboard autorepeat) from Authentic8 branch: b5b58fcbbd9eb57ff1ff4b8df8f4426c1c2881fb --- xorg/X11R7.6/rdp/rdpinput.c | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/xorg/X11R7.6/rdp/rdpinput.c b/xorg/X11R7.6/rdp/rdpinput.c index 9fa7fa0a..5cef9458 100644 --- a/xorg/X11R7.6/rdp/rdpinput.c +++ b/xorg/X11R7.6/rdp/rdpinput.c @@ -58,6 +58,7 @@ static int g_tab_down = 0; /* this is toggled every time num lock key is released, not like the above *_down vars */ static int g_scroll_lock_down = 0; +static OsTimerPtr g_kbtimer = 0; #define MIN_KEY_CODE 8 #define MAX_KEY_CODE 255 @@ -314,11 +315,58 @@ rdpBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls) ErrorF("rdpBell:\n"); } +/******************************************************************************/ +static CARD32 +rdpInDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg) +{ + //ErrorF("rdpInDeferredUpdateCallback:\n"); + + /* our keyboard device */ + XkbSetRepeatKeys(g_keyboard, -1, AutoRepeatModeOff); + /* the main one for the server */ + XkbSetRepeatKeys(inputInfo.keyboard, -1, AutoRepeatModeOff); + + return 0; +} + /******************************************************************************/ void rdpChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) { + XkbControlsPtr ctrls; + ErrorF("rdpChangeKeyboardControl:\n"); + ctrls = 0; + if (pDev != 0) + { + if (pDev->key != 0) + { + if (pDev->key->xkbInfo != 0) + { + if (pDev->key->xkbInfo->desc != 0) + { + if (pDev->key->xkbInfo->desc->ctrls != 0) + { + ctrls = pDev->key->xkbInfo->desc->ctrls; + } + } + } + } + } + if (ctrls != 0) + { + if (ctrls->enabled_ctrls & XkbRepeatKeysMask) + { + //ErrorF("rdpChangeKeyboardControl: autoRepeat on\n"); + /* schedual to turn off the autorepeat after 100 ms so any app + * polling it will be happy it's on */ + g_kbtimer = TimerSet(g_kbtimer, 0, 100, rdpInDeferredUpdateCallback, 0);\ + } + else + { + //ErrorF("rdpChangeKeyboardControl: autoRepeat off\n"); + } + } } /******************************************************************************/ From 27b7a8c53747bcc31688500675ed8c41efc5f94e Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Tue, 2 Jul 2013 17:34:04 -0700 Subject: [PATCH 06/31] Hand-apply patches (framebuffer alloc) from Authentic8 branch: 15ba9cc409e8f57e1800abcd52e77ed409b6cc17 --- xorg/X11R7.6/rdp/rdpmain.c | 2 +- xorg/X11R7.6/rdp/rdprandr.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xorg/X11R7.6/rdp/rdpmain.c b/xorg/X11R7.6/rdp/rdpmain.c index ffb43d1f..b2cbf771 100644 --- a/xorg/X11R7.6/rdp/rdpmain.c +++ b/xorg/X11R7.6/rdp/rdpmain.c @@ -271,7 +271,7 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) g_rdpScreen.sizeInBytes = (g_rdpScreen.paddedWidthInBytes * g_rdpScreen.height); ErrorF("buffer size %d\n", g_rdpScreen.sizeInBytes); - g_rdpScreen.pfbMemory = (char *)g_malloc(2048 * 2048 * 4, 1); + g_rdpScreen.pfbMemory = (char *)g_malloc(g_rdpScreen.sizeInBytes, 1); } if (g_rdpScreen.pfbMemory == 0) diff --git a/xorg/X11R7.6/rdp/rdprandr.c b/xorg/X11R7.6/rdp/rdprandr.c index a767b1d8..26b56bfe 100644 --- a/xorg/X11R7.6/rdp/rdprandr.c +++ b/xorg/X11R7.6/rdp/rdprandr.c @@ -156,6 +156,8 @@ rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, ErrorF(" resizing screenPixmap [%p] to %dx%d, currently at %dx%d\n", (void *)screenPixmap, width, height, screenPixmap->drawable.width, screenPixmap->drawable.height); + g_free(g_rdpScreen.pfbMemory); + g_rdpScreen.pfbMemory = g_malloc(g_rdpScreen.sizeInBytes, 1); pScreen->ModifyPixmapHeader(screenPixmap, width, height, g_rdpScreen.depth, g_rdpScreen.bitsPerPixel, g_rdpScreen.paddedWidthInBytes, From d805992b62132bb4766f2184d0ff5233751dff69 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Wed, 3 Jul 2013 09:08:14 -0700 Subject: [PATCH 07/31] Hand-apply patches (X11rdp: fix for frame buffer getting smaller in randr) from Authentic8 branch: 1e92a08 --- xorg/X11R7.6/rdp/rdp.h | 4 +++- xorg/X11R7.6/rdp/rdpmain.c | 1 + xorg/X11R7.6/rdp/rdprandr.c | 9 +++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h index 22dcdbf7..b9c02353 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -114,7 +114,9 @@ struct _rdpScreenInfoRec int height; int depth; int bitsPerPixel; - int sizeInBytes; + int sizeInBytes; /* size of current used frame buffer */ + int sizeInBytesAlloc; /* size of current alloc frame buffer, + always >= sizeInBytes */ char* pfbMemory; Pixel blackPixel; Pixel whitePixel; diff --git a/xorg/X11R7.6/rdp/rdpmain.c b/xorg/X11R7.6/rdp/rdpmain.c index b2cbf771..f81b4f70 100644 --- a/xorg/X11R7.6/rdp/rdpmain.c +++ b/xorg/X11R7.6/rdp/rdpmain.c @@ -272,6 +272,7 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) (g_rdpScreen.paddedWidthInBytes * g_rdpScreen.height); ErrorF("buffer size %d\n", g_rdpScreen.sizeInBytes); g_rdpScreen.pfbMemory = (char *)g_malloc(g_rdpScreen.sizeInBytes, 1); + g_rdpScreen.sizeInBytesAlloc = g_rdpScreen.sizeInBytes; } if (g_rdpScreen.pfbMemory == 0) diff --git a/xorg/X11R7.6/rdp/rdprandr.c b/xorg/X11R7.6/rdp/rdprandr.c index 26b56bfe..8b3eb582 100644 --- a/xorg/X11R7.6/rdp/rdprandr.c +++ b/xorg/X11R7.6/rdp/rdprandr.c @@ -156,8 +156,13 @@ rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, ErrorF(" resizing screenPixmap [%p] to %dx%d, currently at %dx%d\n", (void *)screenPixmap, width, height, screenPixmap->drawable.width, screenPixmap->drawable.height); - g_free(g_rdpScreen.pfbMemory); - g_rdpScreen.pfbMemory = g_malloc(g_rdpScreen.sizeInBytes, 1); + if (g_rdpScreen.sizeInBytes > g_rdpScreen.sizeInBytesAlloc) + { + g_free(g_rdpScreen.pfbMemory); + g_rdpScreen.pfbMemory = (char*)g_malloc(g_rdpScreen.sizeInBytes, 1); + g_rdpScreen.sizeInBytesAlloc = g_rdpScreen.sizeInBytes; + ErrorF("new buffer size %d\n", g_rdpScreen.sizeInBytes); + } pScreen->ModifyPixmapHeader(screenPixmap, width, height, g_rdpScreen.depth, g_rdpScreen.bitsPerPixel, g_rdpScreen.paddedWidthInBytes, From 16954355f5be93fd231d9205fcea63561a8e519f Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Wed, 3 Jul 2013 09:09:14 -0700 Subject: [PATCH 08/31] Hand-apply patches (X11rdp: add cleanx.sh script) from Authentic8 branch: 88d3aa1 28044b3 --- xorg/X11R7.6/cleanx.sh | 102 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 xorg/X11R7.6/cleanx.sh diff --git a/xorg/X11R7.6/cleanx.sh b/xorg/X11R7.6/cleanx.sh new file mode 100755 index 00000000..7ec804e0 --- /dev/null +++ b/xorg/X11R7.6/cleanx.sh @@ -0,0 +1,102 @@ +#!/bin/sh +# +# all directories can be read only except +# Read Write +# share/X11/xkb/compiled/ + +if test $# -lt 1 +then + echo "" + echo "usage: clean_build_dir.sh " + echo "" + exit 1 +fi + +BASEDIR=$1 + +if ! test -d $BASEDIR +then + echo "error directory $BASEDIR does not exist" + exit 1 +fi + +if ! test -w $BASEDIR +then + echo "error directory $BASEDIR is not writable" + exit 1 +fi + +echo cleaning $BASEDIR + +if ! test -x $BASEDIR/bin/X11rdp +then + echo "error $BASEDIR/bin/X11rdp does not exist" +fi + +bin_check_file() +{ + if [ "$1" = "X11rdp" ] + then + return 0 + fi + if [ "$1" = "xkbcomp" ] + then + return 0 + fi + rm -f $1 + return 0 +} + +HOLDPATH=$PWD +cd $BASEDIR + +# remove unused directories +rm -fr man/ +rm -fr include/ +rm -fr lib/python2.7/ +rm -fr lib/pkgconfig/ +rm -fr share/pkgconfig/ +rm -fr share/gtk-doc +rm -fr share/doc +rm -fr share/man +rm -fr share/aclocal +rm -fr share/intltool +rm -fr share/util-macros + +# remove development files +rm -f lib/*.a +rm -f lib/*.la +rm -f lib/xorg/modules/*.a +rm -f lib/xorg/modules/*.la + +# remove symbols +#strip lib/*.so +#strip lib/xorg/modules/*.so + +# remove hardware specific files +rm -f lib/dri/i915_dri.so +rm -f lib/dri/i965_dri.so +rm -f lib/dri/mach64_dri.so +rm -f lib/dri/mga_dri.so +rm -f lib/dri/r128_dri.so +rm -f lib/dri/r200_dri.so +rm -f lib/dri/r300_dri.so +rm -f lib/dri/r600_dri.so +rm -f lib/dri/radeon_dri.so +rm -f lib/dri/savage_dri.so +#strip lib/dri/swrast_dri.so +rm -f lib/dri/tdfx_dri.so +rm -f lib/dri/unichrome_dri.so + +# remove extra bin tools +cd bin +for i in * +do + if ! test -d "$i" + then + bin_check_file $i + fi +done +cd .. + +cd $HOLDPATH From ab212921330e6bcab7d70e22aee58f04e1e22b1a Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Wed, 3 Jul 2013 09:32:18 -0700 Subject: [PATCH 09/31] Hand-apply patches (rail) from Authentic8: bc68076 --- sesman/chansrv/rail.c | 245 ++++++++++++++++++++++++++++++++++++++---- xrdp/xrdp_mm.c | 67 ++++++++++++ 2 files changed, 294 insertions(+), 18 deletions(-) diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index b74c3a8b..cdb77ae0 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -324,6 +324,94 @@ rail_process_exec(struct stream *s, int size) return 0; } +/*****************************************************************************/ +static void APP_CC +rail_simulate_mouse_click(int button) +{ + /* + * The below code can be referenced from: + * http://www.linuxquestions.org/questions/programming-9/simulating-a-mouse-click-594576/#post2936738 + */ + XEvent event; + g_memset(&event, 0x00, sizeof(event)); + + event.type = ButtonPress; + event.xbutton.button = button; + event.xbutton.same_screen = True; + + XQueryPointer(g_display, g_root_window, &event.xbutton.root, + &event.xbutton.window, &event.xbutton.x_root, + &event.xbutton.y_root, &event.xbutton.x, + &event.xbutton.y, &event.xbutton.state); + + event.xbutton.subwindow = event.xbutton.window; + + while(event.xbutton.subwindow) + { + event.xbutton.window = event.xbutton.subwindow; + + XQueryPointer(g_display, event.xbutton.window, &event.xbutton.root, + &event.xbutton.subwindow, &event.xbutton.x_root, + &event.xbutton.y_root, &event.xbutton.x, + &event.xbutton.y, &event.xbutton.state); + } + + if(XSendEvent(g_display, PointerWindow, True, 0xfff, &event) == 0) + { + LOG(0, (" error sending mouse event")); + } + + XFlush(g_display); + + usleep(100000); + + event.type = ButtonRelease; + event.xbutton.state = 0x100; + + if(XSendEvent(g_display, PointerWindow, True, 0xfff, &event) == 0) + { + LOG(0, (" error sending mouse event")); + } + + XFlush(g_display); +} + +/******************************************************************************/ +static int APP_CC +rail_win_popdown(int window_id) +{ + int rv = 0; + unsigned int i; + unsigned int nchild; + Window r; + Window p; + Window* children; + + /* + * Check the tree of current existing X windows and dismiss + * the managed rail popups by simulating a mouse click, so + * that the requested window can be closed properly. + */ + + XQueryTree(g_display, g_root_window, &r, &p, &children, &nchild); + for (i = 0; i < nchild; i++) + { + XWindowAttributes window_attributes; + XGetWindowAttributes(g_display, children[i], &window_attributes); + if (window_attributes.override_redirect && + window_attributes.map_state == IsViewable && + list_index_of(g_window_list, children[i]) >= 0) { + LOG(0, (" dismiss pop up 0x%8.8x", children[i])); + rail_simulate_mouse_click(Button1); + rv = 1; + break; + } + } + + XFree(children); + return rv; +} + /******************************************************************************/ static int APP_CC rail_close_window(int window_id) @@ -332,6 +420,11 @@ rail_close_window(int window_id) LOG(0, ("chansrv::rail_close_window:")); + if (rail_win_popdown(window_id)) + { + return 0; + } + /* don't receive UnmapNotify for closing window */ XSelectInput(g_display, window_id, PropertyChangeMask); @@ -344,6 +437,7 @@ rail_close_window(int window_id) ce.xclient.data.l[0] = g_wm_delete_window_atom; ce.xclient.data.l[1] = CurrentTime; XSendEvent(g_display, window_id, False, NoEventMask, &ce); + return 0; } @@ -353,14 +447,22 @@ rail_process_activate(struct stream *s, int size) { int window_id; int enabled; + XWindowAttributes window_attributes; LOG(10, ("chansrv::rail_process_activate:")); in_uint32_le(s, window_id); in_uint8(s, enabled); LOG(10, (" window_id 0x%8.8x enabled %d", window_id, enabled)); + XGetWindowAttributes(g_display, window_id, &window_attributes); + if (enabled) { + if (window_attributes.map_state != IsViewable) + { + /* In case that window is unmapped upon minimization and not yet mapped*/ + XMapWindow(g_display, window_id); + } LOG(10, ("chansrv::rail_process_activate: calling XRaiseWindow 0x%8.8x", window_id)); XRaiseWindow(g_display, window_id); LOG(10, ("chansrv::rail_process_activate: calling XSetInputFocus 0x%8.8x", window_id)); @@ -374,8 +476,6 @@ rail_process_activate(struct stream *s, int size) if (window_attributes.override_redirect) { LOG(10, (" dismiss popup window 0x%8.8x", window_id)); XUnmapWindow(g_display, window_id); - //rail_win_set_state(window_id, 0x3); - //rail_show_window(window_id, 0x0); } } return 0; @@ -574,12 +674,19 @@ rail_minmax_window(int window_id, int max) static int APP_CC rail_restore_window(int window_id) { + XWindowAttributes window_attributes; + LOG(10, ("chansrv::rail_restore_window 0x%8.8x:", window_id)); - XMapWindow(g_display, window_id); + XGetWindowAttributes(g_display, window_id, &window_attributes); + if (window_attributes.map_state != IsViewable) + { + XMapWindow(g_display, window_id); + } LOG(10, ("chansrv::rail_process_activate: calling XRaiseWindow 0x%8.8x", window_id)); XRaiseWindow(g_display, window_id); LOG(10, ("chansrv::rail_process_activate: calling XSetInputFocus 0x%8.8x", window_id)); XSetInputFocus(g_display, window_id, RevertToParent, CurrentTime); + return 0; } @@ -939,7 +1046,8 @@ rail_create_window(Window window_id, Window parent_id) int i = 0; int flags; - int state; + int index; + Window transient_for = 0; struct stream* s; LOG(10, ("chansrv::rail_create_window 0x%8.8x", window_id)); @@ -951,8 +1059,8 @@ rail_create_window(Window window_id, Window parent_id) LOG(10, (" x %d y %d width %d height %d border_width %d", x, y, width, height, border)); - state = rail_win_get_state(window_id); - if ((state == 0) || (state == -1)) + index = list_index_of(g_window_list, window_id); + if (index == -1) { LOG(10, (" create new window")); flags = WINDOW_ORDER_TYPE_WINDOW | WINDOW_ORDER_STATE_NEW; @@ -966,11 +1074,19 @@ rail_create_window(Window window_id, Window parent_id) title_size = rail_win_get_text(window_id, &title_bytes); + XGetTransientForHint(g_display, window_id, &transient_for); + if (attributes.override_redirect) { style = RAIL_STYLE_TOOLTIP; ext_style = RAIL_EXT_STYLE_TOOLTIP; } + else if (transient_for > 0) + { + style = RAIL_STYLE_DIALOG; + ext_style = RAIL_EXT_STYLE_DIALOG; + parent_id = transient_for; + } else { style = RAIL_STYLE_NORMAL; @@ -1049,6 +1165,94 @@ rail_create_window(Window window_id, Window parent_id) return 0; } +/*****************************************************************************/ +/* returns 0, event handled, 1 unhandled */ +int APP_CC +rail_configure_window(XConfigureEvent *config) +{ + int x; + int y; + tui32 width; + tui32 height; + int num_window_rects = 1; + int num_visibility_rects = 1; + int i = 0; + int flags; + int index; + int window_id; + + struct stream* s; + + window_id = config->window; + + LOG(10, ("chansrv::rail_configure_window 0x%8.8x", window_id)); + + + LOG(10, (" x %d y %d width %d height %d border_width %d", config->x, + config->y, config->width, config->height, config->border_width)); + + index = list_index_of(g_window_list, window_id); + if (index == -1) + { + /* window isn't mapped yet */ + return; + } + + flags = WINDOW_ORDER_TYPE_WINDOW; + + make_stream(s); + init_stream(s, 1024); + + out_uint32_le(s, 10); /* configure_window */ + out_uint32_le(s, window_id); /* window_id */ + + out_uint32_le(s, 0); /* client_offset_x */ + out_uint32_le(s, 0); /* client_offset_y */ + flags |= WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET; + out_uint32_le(s, config->width); /* client_area_width */ + out_uint32_le(s, config->height); /* client_area_height */ + flags |= WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE; + out_uint32_le(s, 0); /* rp_content */ + out_uint32_le(s, g_root_window); /* root_parent_handle */ + flags |= WINDOW_ORDER_FIELD_ROOT_PARENT; + out_uint32_le(s, config->x); /* window_offset_x */ + out_uint32_le(s, config->y); /* window_offset_y */ + flags |= WINDOW_ORDER_FIELD_WND_OFFSET; + out_uint32_le(s, 0); /* window_client_delta_x */ + out_uint32_le(s, 0); /* window_client_delta_y */ + flags |= WINDOW_ORDER_FIELD_WND_CLIENT_DELTA; + out_uint32_le(s, config->width); /* window_width */ + out_uint32_le(s, config->height); /* window_height */ + flags |= WINDOW_ORDER_FIELD_WND_SIZE; + out_uint16_le(s, num_window_rects); /* num_window_rects */ + for (i = 0; i < num_window_rects; i++) + { + out_uint16_le(s, 0); /* left */ + out_uint16_le(s, 0); /* top */ + out_uint16_le(s, config->width); /* right */ + out_uint16_le(s, config->height); /* bottom */ + } + flags |= WINDOW_ORDER_FIELD_WND_RECTS; + out_uint32_le(s, config->x); /* visible_offset_x */ + out_uint32_le(s, config->y); /* visible_offset_y */ + flags |= WINDOW_ORDER_FIELD_VIS_OFFSET; + out_uint16_le(s, num_visibility_rects); /* num_visibility_rects */ + for (i = 0; i < num_visibility_rects; i++) + { + out_uint16_le(s, 0); /* left */ + out_uint16_le(s, 0); /* top */ + out_uint16_le(s, config->width); /* right */ + out_uint16_le(s, config->height); /* bottom */ + } + flags |= WINDOW_ORDER_FIELD_VISIBILITY; + out_uint32_le(s, flags); /*flags*/ + + s_mark_end(s); + send_rail_drawing_orders(s->data, (int)(s->end - s->data)); + free_stream(s); + return 0; +} + /*****************************************************************************/ /* returns 0, event handled, 1 unhandled */ int APP_CC @@ -1109,11 +1313,6 @@ rail_xevent(void *xevent) case CreateNotify: LOG(10, (" got CreateNotify 0x%8.8x", lxevent->xcreatewindow.window)); - XSelectInput(g_display, lxevent->xcreatewindow.window, - PropertyChangeMask | StructureNotifyMask); - rail_win_set_state(lxevent->xcreatewindow.window, 0x0); /* WithdrawnState */ - list_add_item(g_window_list, lxevent->xcreatewindow.window); - rv = 0; break; case DestroyNotify: @@ -1129,8 +1328,9 @@ rail_xevent(void *xevent) case MapRequest: LOG(10, (" got MapRequest 0x%8.8x", lxevent->xmaprequest.window)); + XSelectInput(g_display, lxevent->xmaprequest.window, + PropertyChangeMask | StructureNotifyMask); XMapWindow(g_display, lxevent->xmaprequest.window); - rv = 0; break; case MapNotify: @@ -1141,9 +1341,9 @@ rail_xevent(void *xevent) if (wnd_attributes.map_state == IsViewable) { rail_create_window(lxevent->xmap.window, lxevent->xmap.event); - rail_win_set_state(lxevent->xmap.window, 0x1); /* NormalState */ if (!wnd_attributes.override_redirect) { + rail_win_set_state(lxevent->xmap.window, 0x1); /* NormalState */ rail_win_send_text(lxevent->xmap.window); } rv = 0; @@ -1153,19 +1353,19 @@ rail_xevent(void *xevent) case UnmapNotify: LOG(10, (" got UnmapNotify 0x%8.8x", lxevent->xunmap.event)); - if (lxevent->xunmap.window == lxevent->xunmap.event && + if (lxevent->xunmap.window != lxevent->xunmap.event && is_window_valid_child_of_root(lxevent->xunmap.window)) { int state = rail_win_get_state(lxevent->xunmap.window); + index = list_index_of(g_window_list, lxevent->xunmap.window); LOG(10, (" window 0x%8.8x is unmapped", lxevent->xunmap.window)); - if (state != -1 && state != 0x3) + if (index >= 0) { - LOG(10, (" trying to dismiss popup")); XGetWindowAttributes(g_display, lxevent->xunmap.window, &wnd_attributes); if (wnd_attributes.override_redirect) { + LOG(10, (" hide popup")); rail_show_window(lxevent->xunmap.window, 0x0); - rail_win_set_state(lxevent->xunmap.window, 0x3); rv = 0; } } @@ -1173,7 +1373,16 @@ rail_xevent(void *xevent) break; case ConfigureNotify: - LOG(10, (" got ConfigureNotify")); + LOG(10, (" got ConfigureNotify 0x%8.8x event 0x%8.8x", lxevent->xconfigure.window, + lxevent->xconfigure.event)); +#if 0 + if (lxevent->xconfigure.window != lxevent->xconfigure.event && + !lxevent->xconfigure.override_redirect) + { + rail_configure_window(&lxevent->xconfigure); + rv = 0; + } +#endif break; case FocusIn: diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 88c24611..67c53a28 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -755,6 +755,73 @@ xrdp_mm_process_rail_create_window(struct xrdp_mm* self, struct stream* s) return rv; } +/*****************************************************************************/ +/* returns error + process rail configure window order */ +static int APP_CC +xrdp_mm_process_rail_configure_window(struct xrdp_mm* self, struct stream* s) +{ + int flags; + int window_id; + int index; + int bytes; + int rv; + struct rail_window_state_order rwso; + + g_memset(&rwso, 0, sizeof(rwso)); + in_uint32_le(s, window_id); + + g_writeln("xrdp_mm_process_rail_configure_window: 0x%8.8x", window_id); + + in_uint32_le(s, rwso.client_offset_x); + in_uint32_le(s, rwso.client_offset_y); + in_uint32_le(s, rwso.client_area_width); + in_uint32_le(s, rwso.client_area_height); + in_uint32_le(s, rwso.rp_content); + in_uint32_le(s, rwso.root_parent_handle); + in_uint32_le(s, rwso.window_offset_x); + in_uint32_le(s, rwso.window_offset_y); + in_uint32_le(s, rwso.window_client_delta_x); + in_uint32_le(s, rwso.window_client_delta_y); + in_uint32_le(s, rwso.window_width); + in_uint32_le(s, rwso.window_height); + in_uint16_le(s, rwso.num_window_rects); + if (rwso.num_window_rects > 0) + { + bytes = sizeof(struct rail_window_rect) * rwso.num_window_rects; + rwso.window_rects = (struct rail_window_rect*)g_malloc(bytes, 0); + for (index = 0; index < rwso.num_window_rects; index++) + { + in_uint16_le(s, rwso.window_rects[index].left); + in_uint16_le(s, rwso.window_rects[index].top); + in_uint16_le(s, rwso.window_rects[index].right); + in_uint16_le(s, rwso.window_rects[index].bottom); + } + } + in_uint32_le(s, rwso.visible_offset_x); + in_uint32_le(s, rwso.visible_offset_y); + in_uint16_le(s, rwso.num_visibility_rects); + if (rwso.num_visibility_rects > 0) + { + bytes = sizeof(struct rail_window_rect) * rwso.num_visibility_rects; + rwso.visibility_rects = (struct rail_window_rect*)g_malloc(bytes, 0); + for (index = 0; index < rwso.num_visibility_rects; index++) + { + in_uint16_le(s, rwso.visibility_rects[index].left); + in_uint16_le(s, rwso.visibility_rects[index].top); + in_uint16_le(s, rwso.visibility_rects[index].right); + in_uint16_le(s, rwso.visibility_rects[index].bottom); + } + } + in_uint32_le(s, flags); + rv = libxrdp_orders_init(self->wm->session); + rv = libxrdp_window_new_update(self->wm->session, window_id, &rwso, flags); + rv = libxrdp_orders_send(self->wm->session); + g_free(rwso.window_rects); + g_free(rwso.visibility_rects); + return rv; +} + /*****************************************************************************/ /* returns error process rail destroy window order */ From 5cbe629b37f91794b72750078f1db7e59af9a7f6 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Wed, 3 Jul 2013 10:01:18 -0700 Subject: [PATCH 10/31] Hand-apply patches (rail) from Authentic8: b01207f b9807e9 42f0128 0f0750c aef2dce --- sesman/chansrv/rail.c | 396 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 375 insertions(+), 21 deletions(-) diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index cdb77ae0..e58a7030 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -19,9 +19,15 @@ /* window manager info http://www.freedesktop.org/wiki/Specifications/wm-spec + + rail + [MS-RDPERP]: Remote Desktop Protocol: + Remote Programs Virtual Channel Extension + http://msdn.microsoft.com/en-us/library/cc242568(v=prot.20).aspx */ #include +#include #include "chansrv.h" #include "rail.h" #include "xcommon.h" @@ -46,6 +52,8 @@ extern Atom g_utf8_string; /* in xcommon.c */ extern Atom g_net_wm_name; /* in xcommon.c */ extern Atom g_wm_state; /* in xcommon.c */ +static Atom g_rwd_atom = 0; + int g_rail_up = 0; /* for rail_is_another_wm_running */ @@ -53,6 +61,23 @@ static int g_rail_running = 1; /* list of valid rail windows */ static struct list* g_window_list = 0; +/* used in valid field of struct rail_window_data */ +#define RWD_X (1 << 0) +#define RWD_Y (1 << 1) +#define RWD_WIDTH (1 << 2) +#define RWD_HEIGHT (1 << 3) +#define RWD_TITLE (1 << 4) + +struct rail_window_data +{ + int valid; /* bits for which fields are valid */ + int x; + int y; + int width; + int height; + char title[64]; /* first 64 bytes of title for compare */ +}; + /* Indicates a Client Execute PDU from client to server. */ #define TS_RAIL_ORDER_EXEC 0x0001 /* Indicates a Client Activate PDU from client to server. */ @@ -125,6 +150,70 @@ static int APP_CC rail_win_set_state(Window win, unsigned long state); static int APP_CC rail_show_window(Window window_id, int show_state); static int APP_CC rail_win_send_text(Window win); +/*****************************************************************************/ +static struct rail_window_data* APP_CC +rail_get_window_data(Window window) +{ + int bytes; + Atom actual_type_return; + int actual_format_return; + unsigned long nitems_return; + unsigned long bytes_after_return; + unsigned char* prop_return; + struct rail_window_data* rv; + + LOG(10, ("chansrv::rail_get_window_data:")); + rv = 0; + actual_type_return = 0; + actual_format_return = 0; + nitems_return = 0; + prop_return = 0; + bytes = sizeof(struct rail_window_data); + XGetWindowProperty(g_display, window, g_rwd_atom, 0, bytes, 0, + XA_STRING, &actual_type_return, + &actual_format_return, &nitems_return, + &bytes_after_return, &prop_return); + if (prop_return == 0) + { + return 0; + } + if (nitems_return == bytes) + { + rv = (struct rail_window_data*)prop_return; + } + return rv; +} + +/*****************************************************************************/ +static int APP_CC +rail_set_window_data(Window window, struct rail_window_data* rwd) +{ + int bytes; + + bytes = sizeof(struct rail_window_data); + XChangeProperty(g_display, window, g_rwd_atom, XA_STRING, 8, + PropModeReplace, (unsigned char*)rwd, bytes); + return 0; +} + +/*****************************************************************************/ +/* get the rail window data, if not exist, try to create it and return */ +static struct rail_window_data* APP_CC +rail_get_window_data_safe(Window window) +{ + struct rail_window_data* rv; + + rv = rail_get_window_data(window); + if (rv != 0) + { + return rv; + } + rv = g_malloc(sizeof(struct rail_window_data), 1); + rail_set_window_data(window, rv); + g_free(rv); + return rail_get_window_data(window); +} + /******************************************************************************/ static int APP_CC is_window_valid_child_of_root(unsigned int window_id) @@ -226,6 +315,7 @@ rail_init(void) g_window_list = list_create(); rail_send_init(); g_rail_up = 1; + g_rwd_atom = XInternAtom(g_display, "XRDP_RAIL_WINDOW_DATA", 0); return 0; } @@ -363,7 +453,7 @@ rail_simulate_mouse_click(int button) XFlush(g_display); - usleep(100000); + g_sleep(100); event.type = ButtonRelease; event.xbutton.state = 0x100; @@ -777,16 +867,30 @@ rail_process_window_move(struct stream *s, int size) int top; int right; int bottom; + tsi16 si16; + struct rail_window_data* rwd; LOG(10, ("chansrv::rail_process_window_move:")); in_uint32_le(s, window_id); - in_uint16_le(s, left); - in_uint16_le(s, top); - in_uint16_le(s, right); - in_uint16_le(s, bottom); + in_uint16_le(s, si16); + left = si16; + in_uint16_le(s, si16); + top = si16; + in_uint16_le(s, si16); + right = si16; + in_uint16_le(s, si16); + bottom = si16; LOG(10, (" window_id 0x%8.8x left %d top %d right %d bottom %d width %d height %d", window_id, left, top, right, bottom, right - left, bottom - top)); XMoveResizeWindow(g_display, window_id, left, top, right - left, bottom - top); + rwd = (struct rail_window_data*) + g_malloc(sizeof(struct rail_window_data), 1); + rwd->x = left; + rwd->y = top; + rwd->width = right - left; + rwd->height = bottom - top; + rail_set_window_data(window_id, rwd); + g_free(rwd); return 0; } @@ -799,13 +903,16 @@ rail_process_local_move_size(struct stream *s, int size) int move_size_type; int pos_x; int pos_y; + tsi16 si16; LOG(10, ("chansrv::rail_process_local_move_size:")); in_uint32_le(s, window_id); in_uint16_le(s, is_move_size_start); in_uint16_le(s, move_size_type); - in_uint16_le(s, pos_x); - in_uint16_le(s, pos_y); + in_uint16_le(s, si16); + pos_x = si16; + in_uint16_le(s, si16); + pos_y = si16; LOG(10, (" window_id 0x%8.8x is_move_size_start %d move_size_type %d " "pos_x %d pos_y %d", window_id, is_move_size_start, move_size_type, pos_x, pos_y)); @@ -840,11 +947,14 @@ rail_process_sys_menu(struct stream *s, int size) int window_id; int left; int top; + tsi16 si16; LOG(10, ("chansrv::rail_process_sys_menu:")); in_uint32_le(s, window_id); - in_uint16_le(s, left); - in_uint16_le(s, top); + in_uint16_le(s, si16); + left = si16; + in_uint16_le(s, si16); + top = si16; LOG(10, (" window_id 0x%8.8x left %d top %d", window_id, left, top)); return 0; } @@ -959,14 +1069,37 @@ rail_data_in(struct stream *s, int chan_id, int chan_flags, int length, /*****************************************************************************/ /* returns 0, event handled, 1 unhandled */ static int APP_CC -rail_win_send_text(Window win) { +rail_win_send_text(Window win) +{ char* data = 0; struct stream* s; int len = 0; int flags; + struct rail_window_data* rwd; len = rail_win_get_text(win, &data); - + rwd = rail_get_window_data_safe(win); + if (rwd != 0) + { + if (data != 0) + { + if (rwd->valid & RWD_TITLE) + { + if (g_strncmp(rwd->title, data, 63) == 0) + { + LOG(0, ("chansrv::rail_win_send_text: skipping, title not changed")); + XFree(data); + XFree(rwd); + return 0; + } + } + } + } + else + { + LOG(0, ("chansrv::rail_win_send_text: error rail_get_window_data_safe failed")); + return 1; + } if (data && len > 0) { LOG(10, ("chansrv::rail_win_send_text: 0x%8.8x text %s length %d", win, data, len)); @@ -982,7 +1115,12 @@ rail_win_send_text(Window win) { send_rail_drawing_orders(s->data, (int)(s->end - s->data)); free_stream(s); XFree(data); + /* update rail window data */ + rwd->valid |= RWD_TITLE; + g_strncpy(rwd->title, data, 63); + rail_set_window_data(win, rwd); } + XFree(rwd); return 0; } @@ -1048,10 +1186,17 @@ rail_create_window(Window window_id, Window parent_id) int flags; int index; Window transient_for = 0; + struct rail_window_data* rwd; struct stream* s; LOG(10, ("chansrv::rail_create_window 0x%8.8x", window_id)); + rwd = rail_get_window_data_safe(window_id); + if (rwd == 0) + { + LOG(0, ("chansrv::rail_create_window: error rail_get_window_data_safe failed")); + return 0; + } XGetGeometry(g_display, window_id, &root, &x, &y, &width, &height, &border, &depth); XGetWindowAttributes(g_display, window_id, &attributes); @@ -1109,11 +1254,15 @@ rail_create_window(Window window_id, Window parent_id) { out_uint16_le(s, title_size); /* title_size */ out_uint8a(s, title_bytes, title_size); /* title */ + rwd->valid |= RWD_TITLE; + g_strncpy(rwd->title, title_bytes, 63); } else { out_uint16_le(s, 5); /* title_size */ out_uint8a(s, "title", 5); /* title */ + rwd->valid |= RWD_TITLE; + rwd->title[0] = 0; } LOG(10, (" set title info %d", title_size)); flags |= WINDOW_ORDER_FIELD_TITLE; @@ -1162,6 +1311,201 @@ rail_create_window(Window window_id, Window parent_id) send_rail_drawing_orders(s->data, (int)(s->end - s->data)); free_stream(s); XFree(title_bytes); + rail_set_window_data(window_id, rwd); + XFree(rwd); + return 0; +} + +/*****************************************************************************/ +/* returns 0, event handled, 1 unhandled */ +int APP_CC +rail_configure_request_window(XConfigureRequestEvent* config) +{ + int num_window_rects = 1; + int num_visibility_rects = 1; + int i = 0; + int flags; + int index; + int window_id; + int mask; + int resized = 0; + struct rail_window_data* rwd; + + struct stream* s; + + window_id = config->window; + mask = config->value_mask; + LOG(10, ("chansrv::rail_configure_request_window: mask %d", mask)); + rwd = rail_get_window_data(window_id); + if (rwd == 0) + { + rwd = (struct rail_window_data*)g_malloc(sizeof(struct rail_window_data), 1); + rwd->x = config->x; + rwd->y = config->y; + rwd->width = config->width; + rwd->height = config->height; + rwd->valid |= RWD_X | RWD_Y | RWD_WIDTH | RWD_HEIGHT; + rail_set_window_data(window_id, rwd); + g_free(rwd); + return 0; + } + if (!resized) + { + if (mask & CWX) + { + if (rwd->valid & RWD_X) + { + if (rwd->x != config->x) + { + resized = 1; + rwd->x = config->x; + } + } + else + { + resized = 1; + rwd->x = config->x; + rwd->valid |= RWD_X; + } + } + } + if (!resized) + { + if (mask & CWY) + { + if (rwd->valid & RWD_Y) + { + if (rwd->y != config->y) + { + resized = 1; + rwd->y = config->y; + } + } + else + { + resized = 1; + rwd->y = config->y; + rwd->valid |= RWD_Y; + } + } + } + if (!resized) + { + if (mask & CWWidth) + { + if (rwd->valid & RWD_WIDTH) + { + if (rwd->width != config->width) + { + resized = 1; + rwd->width = config->width; + } + } + else + { + resized = 1; + rwd->width = config->width; + rwd->valid |= RWD_WIDTH; + } + } + } + if (!resized) + { + if (mask & CWHeight) + { + if (rwd->valid & RWD_HEIGHT) + { + if (rwd->height != config->height) + { + resized = 1; + rwd->height = config->height; + } + } + else + { + resized = 1; + rwd->height = config->height; + rwd->valid |= RWD_HEIGHT; + } + } + } + if (resized) + { + rail_set_window_data(window_id, rwd); + XFree(rwd); + } + else + { + XFree(rwd); + return 0; + } + + LOG(10, ("chansrv::rail_configure_request_window: 0x%8.8x", window_id)); + + + LOG(10, (" x %d y %d width %d height %d border_width %d", config->x, + config->y, config->width, config->height, config->border_width)); + + index = list_index_of(g_window_list, window_id); + if (index == -1) + { + /* window isn't mapped yet */ + LOG(0, ("chansrv::rail_configure_request_window: window not mapped")); + return 0; + } + + flags = WINDOW_ORDER_TYPE_WINDOW; + + make_stream(s); + init_stream(s, 1024); + + out_uint32_le(s, 10); /* configure_window */ + out_uint32_le(s, window_id); /* window_id */ + + out_uint32_le(s, 0); /* client_offset_x */ + out_uint32_le(s, 0); /* client_offset_y */ + flags |= WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET; + out_uint32_le(s, config->width); /* client_area_width */ + out_uint32_le(s, config->height); /* client_area_height */ + flags |= WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE; + out_uint32_le(s, 0); /* rp_content */ + out_uint32_le(s, g_root_window); /* root_parent_handle */ + flags |= WINDOW_ORDER_FIELD_ROOT_PARENT; + out_uint32_le(s, config->x); /* window_offset_x */ + out_uint32_le(s, config->y); /* window_offset_y */ + flags |= WINDOW_ORDER_FIELD_WND_OFFSET; + out_uint32_le(s, 0); /* window_client_delta_x */ + out_uint32_le(s, 0); /* window_client_delta_y */ + flags |= WINDOW_ORDER_FIELD_WND_CLIENT_DELTA; + out_uint32_le(s, config->width); /* window_width */ + out_uint32_le(s, config->height); /* window_height */ + flags |= WINDOW_ORDER_FIELD_WND_SIZE; + out_uint16_le(s, num_window_rects); /* num_window_rects */ + for (i = 0; i < num_window_rects; i++) + { + out_uint16_le(s, 0); /* left */ + out_uint16_le(s, 0); /* top */ + out_uint16_le(s, config->width); /* right */ + out_uint16_le(s, config->height); /* bottom */ + } + flags |= WINDOW_ORDER_FIELD_WND_RECTS; + out_uint32_le(s, config->x); /* visible_offset_x */ + out_uint32_le(s, config->y); /* visible_offset_y */ + flags |= WINDOW_ORDER_FIELD_VIS_OFFSET; + out_uint16_le(s, num_visibility_rects); /* num_visibility_rects */ + for (i = 0; i < num_visibility_rects; i++) + { + out_uint16_le(s, 0); /* left */ + out_uint16_le(s, 0); /* top */ + out_uint16_le(s, config->width); /* right */ + out_uint16_le(s, config->height); /* bottom */ + } + flags |= WINDOW_ORDER_FIELD_VISIBILITY; + out_uint32_le(s, flags); /*flags*/ + + s_mark_end(s); + send_rail_drawing_orders(s->data, (int)(s->end - s->data)); + free_stream(s); return 0; } @@ -1170,10 +1514,6 @@ rail_create_window(Window window_id, Window parent_id) int APP_CC rail_configure_window(XConfigureEvent *config) { - int x; - int y; - tui32 width; - tui32 height; int num_window_rects = 1; int num_visibility_rects = 1; int i = 0; @@ -1195,7 +1535,7 @@ rail_configure_window(XConfigureEvent *config) if (index == -1) { /* window isn't mapped yet */ - return; + return 0; } flags = WINDOW_ORDER_TYPE_WINDOW; @@ -1259,6 +1599,7 @@ int APP_CC rail_xevent(void *xevent) { XEvent *lxevent; + XEvent lastevent; XWindowChanges xwc; int rv; int index; @@ -1308,6 +1649,7 @@ rail_xevent(void *xevent) lxevent->xconfigurerequest.window, lxevent->xconfigurerequest.value_mask, &xwc); + rail_configure_request_window(&(lxevent->xconfigurerequest)); rv = 0; break; @@ -1375,13 +1717,25 @@ rail_xevent(void *xevent) case ConfigureNotify: LOG(10, (" got ConfigureNotify 0x%8.8x event 0x%8.8x", lxevent->xconfigure.window, lxevent->xconfigure.event)); -#if 0 - if (lxevent->xconfigure.window != lxevent->xconfigure.event && - !lxevent->xconfigure.override_redirect) + rv = 0; + if (lxevent->xconfigure.event != lxevent->xconfigure.window || + lxevent->xconfigure.override_redirect) { - rail_configure_window(&lxevent->xconfigure); - rv = 0; + break; + } + /* skip dup ConfigureNotify */ + while (XCheckTypedWindowEvent(g_display, + lxevent->xconfigure.window, + ConfigureNotify, &lastevent)) + { + if (lastevent.xconfigure.event == lastevent.xconfigure.window && + lxevent->xconfigure.override_redirect == 0) + { + lxevent = &lastevent; + } } +#if 0 + rail_configure_window(&(lxevent->xconfigure)); #endif break; From 117e514cb420cdd13badfa0f277eda0f16697bd7 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Wed, 3 Jul 2013 10:27:07 -0700 Subject: [PATCH 11/31] Hand-apply patches (rail) from Authentic8 branch: e94d059 c36dc61 --- sesman/chansrv/rail.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index e58a7030..23399a18 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -145,7 +145,7 @@ struct rail_window_data #define RAIL_EXT_STYLE_DIALOG (0x00040000) static int APP_CC rail_win_get_state(Window win); -static int APP_CC rail_create_window(Window window_id, Window parent_id); +static int APP_CC rail_create_window(Window window_id, Window owner_id); static int APP_CC rail_win_set_state(Window win, unsigned long state); static int APP_CC rail_show_window(Window window_id, int show_state); static int APP_CC rail_win_send_text(Window win); @@ -538,6 +538,7 @@ rail_process_activate(struct stream *s, int size) int window_id; int enabled; XWindowAttributes window_attributes; + Window transient_for = 0; LOG(10, ("chansrv::rail_process_activate:")); in_uint32_le(s, window_id); @@ -553,6 +554,12 @@ rail_process_activate(struct stream *s, int size) /* In case that window is unmapped upon minimization and not yet mapped*/ XMapWindow(g_display, window_id); } + XGetTransientForHint(g_display, window_id, &transient_for); + if (transient_for > 0) + { + // Owner window should be raised up as well + XRaiseWindow(g_display, transient_for); + } LOG(10, ("chansrv::rail_process_activate: calling XRaiseWindow 0x%8.8x", window_id)); XRaiseWindow(g_display, window_id); LOG(10, ("chansrv::rail_process_activate: calling XSetInputFocus 0x%8.8x", window_id)); @@ -1165,7 +1172,7 @@ rail_show_window(Window window_id, int show_state) /*****************************************************************************/ static int APP_CC -rail_create_window(Window window_id, Window parent_id) +rail_create_window(Window window_id, Window owner_id) { int x; int y; @@ -1230,7 +1237,7 @@ rail_create_window(Window window_id, Window parent_id) { style = RAIL_STYLE_DIALOG; ext_style = RAIL_EXT_STYLE_DIALOG; - parent_id = transient_for; + owner_id = transient_for; } else { @@ -1243,7 +1250,7 @@ rail_create_window(Window window_id, Window parent_id) out_uint32_le(s, 2); /* create_window */ out_uint32_le(s, window_id); /* window_id */ - out_uint32_le(s, parent_id); /* owner_window_id */ + out_uint32_le(s, owner_id); /* owner_window_id */ flags |= WINDOW_ORDER_FIELD_OWNER; out_uint32_le(s, style); /* style */ out_uint32_le(s, ext_style); /* extended_style */ @@ -1703,6 +1710,7 @@ rail_xevent(void *xevent) LOG(10, (" window 0x%8.8x is unmapped", lxevent->xunmap.window)); if (index >= 0) { +#if 0 XGetWindowAttributes(g_display, lxevent->xunmap.window, &wnd_attributes); if (wnd_attributes.override_redirect) { @@ -1710,6 +1718,10 @@ rail_xevent(void *xevent) rail_show_window(lxevent->xunmap.window, 0x0); rv = 0; } +#else + rail_show_window(lxevent->xunmap.window, 0x0); + rv = 0; +#endif } } break; From c64586c25c183635c77bb55136aef5dc2467dc57 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Wed, 3 Jul 2013 10:45:46 -0700 Subject: [PATCH 12/31] Hand-apply patches (drawing configuration) from Authentic8 branch: 34b92df f994298 38e2def --- common/xrdp_constants.h | 2 ++ libxrdp/libxrdp.h | 1 + libxrdp/xrdp_orders.c | 9 ++++++++- libxrdp/xrdp_rdp.c | 10 +++++++--- xorg/X11R7.6/rdp/rdpdraw.c | 26 ++++++++++++++++---------- xrdp/xrdp_cache.c | 27 +++++++++++++++++++++------ xrdp/xrdp_types.h | 6 +++++- 7 files changed, 60 insertions(+), 21 deletions(-) diff --git a/common/xrdp_constants.h b/common/xrdp_constants.h index b978d2de..53c54852 100644 --- a/common/xrdp_constants.h +++ b/common/xrdp_constants.h @@ -559,4 +559,6 @@ #define CMDTYPE_FRAME_MARKER 0x0004 #define CMDTYPE_STREAM_SURFACE_BITS 0x0006 +#define XRDP_BITMAP_CACHE_ENTRIES 2048 + #endif diff --git a/libxrdp/libxrdp.h b/libxrdp/libxrdp.h index d31edbb4..83d3285c 100644 --- a/libxrdp/libxrdp.h +++ b/libxrdp/libxrdp.h @@ -211,6 +211,7 @@ struct xrdp_orders int order_count; int order_level; /* inc for every call to xrdp_orders_init */ struct xrdp_orders_state orders_state; + int rfx_min_pixel; }; #define PROTO_RDP_40 1 diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index aa399004..cfc0d43b 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -47,6 +47,11 @@ xrdp_orders_create(struct xrdp_session *session, struct xrdp_rdp *rdp_layer) init_stream(self->out_s, 16384); self->orders_state.clip_right = 1; /* silly rdp right clip */ self->orders_state.clip_bottom = 1; /* silly rdp bottom clip */ + self->rfx_min_pixel = rdp_layer->client_info.rfx_min_pixel; + if (self->rfx_min_pixel == 0) + { + self->rfx_min_pixel = 64 * 32; + } return self; } @@ -2241,7 +2246,9 @@ xrdp_orders_send_as_rfx(struct xrdp_orders *self, return 0; } - if (width * height < 64) + LLOGLN(10, ("width %d height %d rfx_min_pixel %d", width, height, + self->rfx_min_pixel)); + if (width * height < self->rfx_min_pixel) { return 0; } diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index 624b3b5d..bc324e9c 100644 --- a/libxrdp/xrdp_rdp.c +++ b/libxrdp/xrdp_rdp.c @@ -131,6 +131,10 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info) { client_info->max_bpp = g_atoi(value); } + else if (g_strcasecmp(item, "rfx_min_pixel") == 0) + { + client_info->rfx_min_pixel = g_atoi(value); + } else if (g_strcasecmp(item, "new_cursors") == 0) { client_info->pointer_flags = text2bool(value) == 0 ? 2 : 0; @@ -925,16 +929,16 @@ xrdp_process_capset_bmpcache2(struct xrdp_rdp *self, struct stream *s, self->client_info.bitmap_cache_persist_enable = i; in_uint8s(s, 2); /* number of caches in set, 3 */ in_uint32_le(s, i); - i = MIN(i, 2000); + i = MIN(i, XRDP_BITMAP_CACHE_ENTRIES); self->client_info.cache1_entries = i; self->client_info.cache1_size = 256 * Bpp; in_uint32_le(s, i); - i = MIN(i, 2000); + i = MIN(i, XRDP_BITMAP_CACHE_ENTRIES); self->client_info.cache2_entries = i; self->client_info.cache2_size = 1024 * Bpp; in_uint32_le(s, i); i = i & 0x7fffffff; - i = MIN(i, 2000); + i = MIN(i, XRDP_BITMAP_CACHE_ENTRIES); self->client_info.cache3_entries = i; self->client_info.cache3_size = 4096 * Bpp; DEBUG(("cache1 entries %d size %d", self->client_info.cache1_entries, diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index 602342b7..69a9c72d 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -487,6 +487,7 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) { struct rdp_draw_item *di; struct rdp_draw_item *di_prev; + RegionRec treg; #if 1 @@ -500,19 +501,17 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) while (di != 0) { - if ((di_prev->type == RDI_IMGLL) && (di->type == RDI_IMGLL)) + if ((di_prev->type == RDI_IMGLL || di_prev->type == RDI_IMGLY || + di_prev->type == RDI_FILL) && + (di->type == RDI_IMGLL || di->type == RDI_IMGLY || + di->type == RDI_FILL)) { - LLOGLN(10, ("draw_item_pack: packing RDI_IMGLL")); - RegionUnion(di_prev->reg, di_prev->reg, di->reg); - draw_item_remove(priv, di); - di = di_prev->next; - } - else if ((di_prev->type == RDI_IMGLY) && (di->type == RDI_IMGLY)) - { - LLOGLN(10, ("draw_item_pack: packing RDI_IMGLY")); + LLOGLN(10, ("draw_item_pack: packing RDI_IMGLL / RDI_IMGLY / " + "RDI_FILL")); RegionUnion(di_prev->reg, di_prev->reg, di->reg); draw_item_remove(priv, di); di = di_prev->next; + di_prev->type = RDI_IMGLL; } else { @@ -547,7 +546,14 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) while (di_prev != 0) { /* D = M - S */ - RegionSubtract(di_prev->reg, di_prev->reg, di->reg); + RegionInit(&treg, NullBox, 0); + RegionSubtract(&treg, di_prev->reg, di->reg); + if (!RegionNotEmpty(&treg)) + { + /* copy empty region so this draw item will get removed below */ + RegionCopy(di_prev->reg, &treg); + } + RegionUninit(&treg); di_prev = di_prev->prev; } } diff --git a/xrdp/xrdp_cache.c b/xrdp/xrdp_cache.c index cac7f114..62da4183 100644 --- a/xrdp/xrdp_cache.c +++ b/xrdp/xrdp_cache.c @@ -21,6 +21,18 @@ #include "xrdp.h" #include "log.h" +#define LLOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do \ + { \ + if (_level < LLOG_LEVEL) \ + { \ + g_write("xrdp:xrdp_cache [%10.10u]: ", g_time3()); \ + g_writeln _args ; \ + } \ + } \ + while (0) + /*****************************************************************************/ struct xrdp_cache *APP_CC xrdp_cache_create(struct xrdp_wm *owner, @@ -43,6 +55,8 @@ xrdp_cache_create(struct xrdp_wm *owner, self->bitmap_cache_version = client_info->bitmap_cache_version; self->pointer_cache_entries = client_info->pointer_cache_entries; self->xrdp_os_del_list = list_create(); + LLOGLN(10, ("xrdp_cache_create: 0 %d 1 %d 2 %d", + self->cache1_entries, self->cache2_entries, self->cache3_entries)); return self; } @@ -61,7 +75,7 @@ xrdp_cache_delete(struct xrdp_cache *self) /* free all the cached bitmaps */ for (i = 0; i < 3; i++) { - for (j = 0; j < 2000; j++) + for (j = 0; j < XRDP_BITMAP_CACHE_ENTRIES; j++) { xrdp_bitmap_delete(self->bitmap_items[i][j].bitmap); } @@ -100,7 +114,7 @@ xrdp_cache_reset(struct xrdp_cache *self, /* free all the cached bitmaps */ for (i = 0; i < 3; i++) { - for (j = 0; j < 2000; j++) + for (j = 0; j < XRDP_BITMAP_CACHE_ENTRIES; j++) { xrdp_bitmap_delete(self->bitmap_items[i][j].bitmap); } @@ -177,7 +191,7 @@ xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap, #endif { self->bitmap_items[i][j].stamp = self->bitmap_stamp; - DEBUG(("found bitmap at %d %d", i, j)); + LLOGLN(10, ("found bitmap at %d %d", i, j)); xrdp_bitmap_delete(bitmap); return MAKELONG(j, i); } @@ -197,7 +211,7 @@ xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap, #endif { self->bitmap_items[i][j].stamp = self->bitmap_stamp; - DEBUG(("found bitmap at %d %d", i, j)); + LLOGLN(10, ("found bitmap at %d %d", i, j)); xrdp_bitmap_delete(bitmap); return MAKELONG(j, i); } @@ -217,7 +231,7 @@ xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap, #endif { self->bitmap_items[i][j].stamp = self->bitmap_stamp; - DEBUG(("found bitmap at %d %d", i, j)); + LLOGLN(10, ("found bitmap at %d %d", i, j)); xrdp_bitmap_delete(bitmap); return MAKELONG(j, i); } @@ -276,7 +290,8 @@ xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap, } } - DEBUG(("adding bitmap at %d %d", cache_id, cache_idx)); + LLOGLN(10, ("adding bitmap at %d %d ptr %p", cache_id, cache_idx, + self->bitmap_items[cache_id][cache_idx].bitmap)); /* set, send bitmap and return */ xrdp_bitmap_delete(self->bitmap_items[cache_id][cache_idx].bitmap); self->bitmap_items[cache_id][cache_idx].bitmap = bitmap; diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index e7bb7baf..7dfd8ef3 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -22,6 +22,7 @@ #define LOG_WINDOW_CHAR_PER_LINE 60 #include "xrdp_rail.h" +#include "xrdp_constants.h" #define MAX_NR_CHANNELS 16 #define MAX_CHANNEL_NAME 16 @@ -185,6 +186,9 @@ struct xrdp_brush_item char pattern[8]; }; +/* moved to xrdp_constants.h +#define XRDP_BITMAP_CACHE_ENTRIES 2048 */ + /* differnce caches */ struct xrdp_cache { @@ -195,7 +199,7 @@ struct xrdp_cache struct xrdp_palette_item palette_items[6]; /* bitmap */ int bitmap_stamp; - struct xrdp_bitmap_item bitmap_items[3][2000]; + struct xrdp_bitmap_item bitmap_items[3][XRDP_BITMAP_CACHE_ENTRIES]; int use_bitmap_comp; int cache1_entries; int cache1_size; From cb1efca63704d342b3d1aba764f6971e2656a8d1 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Wed, 3 Jul 2013 15:57:00 -0700 Subject: [PATCH 13/31] Hand-apply patches (glyph cache) from Authentic8 branch: 653869c 30f23d4 74b015d 4e51e6d 2829087 --- libxrdp/libxrdpinc.h | 10 +- libxrdp/xrdp_orders.c | 14 +- xorg/X11R7.6/rdp/Makefile | 2 +- xorg/X11R7.6/rdp/rdp.h | 53 +- xorg/X11R7.6/rdp/rdpCopyArea.c | 6 +- xorg/X11R7.6/rdp/rdpCopyPlane.c | 4 +- xorg/X11R7.6/rdp/rdpFillPolygon.c | 4 +- xorg/X11R7.6/rdp/rdpImageGlyphBlt.c | 4 +- xorg/X11R7.6/rdp/rdpImageText16.c | 4 +- xorg/X11R7.6/rdp/rdpImageText8.c | 4 +- xorg/X11R7.6/rdp/rdpPolyArc.c | 4 +- xorg/X11R7.6/rdp/rdpPolyFillArc.c | 4 +- xorg/X11R7.6/rdp/rdpPolyFillRect.c | 4 +- xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c | 4 +- xorg/X11R7.6/rdp/rdpPolyRectangle.c | 4 +- xorg/X11R7.6/rdp/rdpPolyText16.c | 4 +- xorg/X11R7.6/rdp/rdpPolyText8.c | 4 +- xorg/X11R7.6/rdp/rdpPushPixels.c | 4 +- xorg/X11R7.6/rdp/rdpPutImage.c | 4 +- xorg/X11R7.6/rdp/rdpdraw.c | 238 +++++++-- xorg/X11R7.6/rdp/rdpglyph.c | 773 ++++++++++++++++++++++++++++ xorg/X11R7.6/rdp/rdpglyph.h | 64 +++ xorg/X11R7.6/rdp/rdpmain.c | 9 + xorg/X11R7.6/rdp/rdpmisc.c | 69 +++ xorg/X11R7.6/rdp/rdpup.c | 119 +++++ xrdp/xrdp.h | 4 + xrdp/xrdp_mm.c | 22 + xrdp/xrdp_types.h | 5 +- xup/xup.c | 54 ++ xup/xup.h | 5 +- 30 files changed, 1429 insertions(+), 74 deletions(-) create mode 100644 xorg/X11R7.6/rdp/rdpglyph.c create mode 100644 xorg/X11R7.6/rdp/rdpglyph.h diff --git a/libxrdp/libxrdpinc.h b/libxrdp/libxrdpinc.h index b971204e..2e5caee9 100644 --- a/libxrdp/libxrdpinc.h +++ b/libxrdp/libxrdpinc.h @@ -40,13 +40,15 @@ struct xrdp_pen int color; }; +/* 2.2.2.2.1.2.5.1 Cache Glyph Data (TS_CACHE_GLYPH_DATA) */ struct xrdp_font_char { - int offset; - int baseline; - int width; - int height; + int offset; /* x */ + int baseline; /* y */ + int width; /* cx */ + int height; /* cy */ int incby; + int bpp; char* data; }; diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index cfc0d43b..0fc4b10d 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -2015,15 +2015,25 @@ xrdp_orders_send_font(struct xrdp_orders *self, int order_flags = 0; int datasize = 0; int len = 0; + int flags; - datasize = FONT_DATASIZE(font_char); + if (font_char->bpp == 8) /* alpha font */ + { + datasize = ((font_char->width + 3) & ~3) * font_char->height; + flags = 8 | 0x4000; + } + else + { + datasize = FONT_DATASIZE(font_char); + flags = 8; + } xrdp_orders_check(self, datasize + 18); self->order_count++; order_flags = RDP_ORDER_STANDARD | RDP_ORDER_SECONDARY; out_uint8(self->out_s, order_flags); len = (datasize + 12) - 7; /* length after type minus 7 */ out_uint16_le(self->out_s, len); - out_uint16_le(self->out_s, 8); /* flags */ + out_uint16_le(self->out_s, flags); out_uint8(self->out_s, RDP_ORDER_FONTCACHE); /* type */ out_uint8(self->out_s, font_index); out_uint8(self->out_s, 1); /* num of chars */ diff --git a/xorg/X11R7.6/rdp/Makefile b/xorg/X11R7.6/rdp/Makefile index e40b7473..8d07e100 100644 --- a/xorg/X11R7.6/rdp/Makefile +++ b/xorg/X11R7.6/rdp/Makefile @@ -13,7 +13,7 @@ rdpPolylines.o rdpPolySegment.o rdpFillSpans.o rdpSetSpans.o \ rdpCopyPlane.o rdpPolyPoint.o rdpPolyArc.o rdpFillPolygon.o \ rdpPolyFillArc.o rdpPolyText8.o rdpPolyText16.o \ rdpImageText8.o rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o \ -rdpPushPixels.o rdpxv.o \ +rdpPushPixels.o rdpxv.o rdpglyph.o \ miinitext.o \ fbcmap_mi.o diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h index b9c02353..8f16316d 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -95,6 +95,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define PixelDPI 100 #define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10)) +#define TAG_COMPOSITE 0 +#define TAG_COPYAREA 1 +#define TAG_POLYFILLRECT 2 +#define TAG_PUTIMAGE 3 +#define TAG_POLYRECTANGLE 4 +#define TAG_COPYPLANE 5 +#define TAG_POLYARC 6 +#define TAG_FILLPOLYGON 7 +#define TAG_POLYFILLARC 8 +#define TAG_IMAGETEXT8 9 +#define TAG_POLYTEXT8 10 +#define TAG_POLYTEXT16 11 +#define TAG_IMAGETEXT16 12 +#define TAG_IMAGEGLYPHBLT 13 +#define TAG_POLYGLYPHBLT 14 +#define TAG_PUSHPIXELS 15 + struct image_data { int width; @@ -144,6 +161,8 @@ struct _rdpScreenInfoRec CopyWindowProcPtr CopyWindow; ClearToBackgroundProcPtr ClearToBackground; ScreenWakeupHandlerProcPtr WakeupHandler; + CreatePictureProcPtr CreatePicture; + DestroyPictureProcPtr DestroyPicture; CompositeProcPtr Composite; GlyphsProcPtr Glyphs; /* Backing store procedures */ @@ -200,6 +219,7 @@ typedef rdpWindowRec* rdpWindowPtr; #define RDI_IMGLY 3 /* lossy */ #define RDI_LINE 4 #define RDI_SCRBLT 5 +define RDI_TEXT 6 struct urdp_draw_item_fill { @@ -236,6 +256,13 @@ struct urdp_draw_item_scrblt int cy; }; +struct urdp_draw_item_text +{ + int opcode; + int fg_color; + struct rdp_text* rtext; /* in rdpglyph.h */ +}; + union urdp_draw_item { struct urdp_draw_item_fill fill; @@ -246,7 +273,7 @@ union urdp_draw_item struct rdp_draw_item { - int type; + int type; /* RDI_FILL, RDI_IMGLL, ... */ int flags; struct rdp_draw_item* prev; struct rdp_draw_item* next; @@ -327,6 +354,8 @@ void hexdump(unsigned char *p, unsigned int len); void RegionAroundSegs(RegionPtr reg, xSegment* segs, int nseg); +int +get_crc(char* data, int data_bytes); /* rdpdraw.c */ Bool @@ -343,7 +372,7 @@ int draw_item_pack(PixmapPtr pix, rdpPixmapRec* priv); int draw_item_add_img_region(rdpPixmapRec* priv, RegionPtr reg, int opcode, - int type); + int type, int code); int draw_item_add_fill_region(rdpPixmapRec* priv, RegionPtr reg, int color, int opcode); @@ -355,6 +384,9 @@ int draw_item_add_srcblt_region(rdpPixmapRec* priv, RegionPtr reg, int srcx, int srcy, int dstx, int dsty, int cx, int cy); +int +draw_item_add_text_region(rdpPixmapRec* priv, RegionPtr reg, int color, + int opcode, struct rdp_text* rtext); PixmapPtr rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, @@ -413,6 +445,10 @@ rdpDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor); void rdpRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed); +int +rdpCreatePicture(PicturePtr pPicture); +void +rdpDestroyPicture(PicturePtr pPicture); void rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, @@ -523,6 +559,19 @@ int rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec* pDirtyPriv); int rdpup_check_dirty_screen(rdpPixmapRec* pDirtyPriv); +int +rdpup_add_char(int font, int charactor, short x, short y, int cx, int cy, + char* bmpdata, int bmpdata_bytes); +int +rdpup_add_char_alpha(int font, int charactor, short x, short y, int cx, int cy, + char* bmpdata, int bmpdata_bytes); +int +rdpup_draw_text(int font, int flags, int mixmode, + short clip_left, short clip_top, + short clip_right, short clip_bottom, + short box_left, short box_top, + short box_right, short box_bottom, short x, short y, + char* data, int data_bytes); void rdpScheduleDeferredUpdate(void); diff --git a/xorg/X11R7.6/rdp/rdpCopyArea.c b/xorg/X11R7.6/rdp/rdpCopyArea.c index cdece2c9..bc802e81 100644 --- a/xorg/X11R7.6/rdp/rdpCopyArea.c +++ b/xorg/X11R7.6/rdp/rdpCopyArea.c @@ -460,6 +460,8 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, } } + LLOGLN(10, ("rdpCopyArea: fallback")); + /* do original call */ rv = rdpCopyAreaOrg(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty); @@ -537,7 +539,7 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, box.x2 = box.x1 + w; box.y2 = box.y1 + h; RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COPYAREA); RegionUninit(®1); } else if (got_id) @@ -561,7 +563,7 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, box.y2 = box.y1 + h; RegionInit(&box_reg, &box, 0); RegionIntersect(&clip_reg, &clip_reg, &box_reg); - draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_COPYAREA); RegionUninit(&box_reg); } else if (got_id) diff --git a/xorg/X11R7.6/rdp/rdpCopyPlane.c b/xorg/X11R7.6/rdp/rdpCopyPlane.c index 47e66e59..bc581789 100644 --- a/xorg/X11R7.6/rdp/rdpCopyPlane.c +++ b/xorg/X11R7.6/rdp/rdpCopyPlane.c @@ -168,7 +168,7 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, box.x2 = box.x1 + w; box.y2 = box.y1 + h; RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COPYPLANE); RegionUninit(®1); } else if (got_id) @@ -194,7 +194,7 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, RegionInit(®2, NullBox, 0); RegionCopy(®2, &clip_reg); RegionIntersect(®1, ®1, ®2); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COPYPLANE); RegionUninit(®1); RegionUninit(®2); } diff --git a/xorg/X11R7.6/rdp/rdpFillPolygon.c b/xorg/X11R7.6/rdp/rdpFillPolygon.c index 53227159..fceab93e 100644 --- a/xorg/X11R7.6/rdp/rdpFillPolygon.c +++ b/xorg/X11R7.6/rdp/rdpFillPolygon.c @@ -203,7 +203,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_FILLPOLYGON); RegionUninit(®1); } else if (got_id) @@ -223,7 +223,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_FILLPOLYGON); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c b/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c index e0ec5502..2b69432d 100644 --- a/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c +++ b/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c @@ -169,7 +169,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_IMAGEGLYPHBLT); RegionUninit(®1); } else if (got_id) @@ -189,7 +189,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_IMAGEGLYPHBLT); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpImageText16.c b/xorg/X11R7.6/rdp/rdpImageText16.c index 71e9b351..32a56cb5 100644 --- a/xorg/X11R7.6/rdp/rdpImageText16.c +++ b/xorg/X11R7.6/rdp/rdpImageText16.c @@ -167,7 +167,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_IMAGETEXT16); RegionUninit(®1); } else if (got_id) @@ -187,7 +187,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_IMAGETEXT16); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpImageText8.c b/xorg/X11R7.6/rdp/rdpImageText8.c index 6acdc205..c191bd75 100644 --- a/xorg/X11R7.6/rdp/rdpImageText8.c +++ b/xorg/X11R7.6/rdp/rdpImageText8.c @@ -167,7 +167,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_IMAGETEXT8); RegionUninit(®1); } else if (got_id) @@ -187,7 +187,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_IMAGETEXT8); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPolyArc.c b/xorg/X11R7.6/rdp/rdpPolyArc.c index 42a8c19e..2d1f153e 100644 --- a/xorg/X11R7.6/rdp/rdpPolyArc.c +++ b/xorg/X11R7.6/rdp/rdpPolyArc.c @@ -185,7 +185,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYARC); } else if (got_id) { @@ -217,7 +217,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYARC); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPolyFillArc.c b/xorg/X11R7.6/rdp/rdpPolyFillArc.c index aa1171da..bcbb2643 100644 --- a/xorg/X11R7.6/rdp/rdpPolyFillArc.c +++ b/xorg/X11R7.6/rdp/rdpPolyFillArc.c @@ -185,7 +185,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYFILLARC); } else if (got_id) { @@ -217,7 +217,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYFILLARC); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPolyFillRect.c b/xorg/X11R7.6/rdp/rdpPolyFillRect.c index 254cdff8..4c3d757a 100644 --- a/xorg/X11R7.6/rdp/rdpPolyFillRect.c +++ b/xorg/X11R7.6/rdp/rdpPolyFillRect.c @@ -173,7 +173,7 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, } else { - draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, RDI_IMGLL); + draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, RDI_IMGLL, TAG_POLYFILLRECT); } } else if (got_id) @@ -236,7 +236,7 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, } else { - draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, RDI_IMGLL); + draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, RDI_IMGLL, TAG_POLYFILLRECT); } } else if (got_id) diff --git a/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c b/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c index f166b731..97c8562e 100644 --- a/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c +++ b/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c @@ -169,7 +169,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_POLYGLYPHBLT); RegionUninit(®1); } else if (got_id) @@ -189,7 +189,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_POLYGLYPHBLT); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPolyRectangle.c b/xorg/X11R7.6/rdp/rdpPolyRectangle.c index 7fdb4e8b..3d3250e3 100644 --- a/xorg/X11R7.6/rdp/rdpPolyRectangle.c +++ b/xorg/X11R7.6/rdp/rdpPolyRectangle.c @@ -221,7 +221,7 @@ rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, } else { - draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, dirty_type, TAG_POLYRECTANGLE); } RegionDestroy(fill_reg); @@ -275,7 +275,7 @@ rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, } else { - draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_POLYRECTANGLE); } } else if (got_id) diff --git a/xorg/X11R7.6/rdp/rdpPolyText16.c b/xorg/X11R7.6/rdp/rdpPolyText16.c index 034b11e1..cf8b04c4 100644 --- a/xorg/X11R7.6/rdp/rdpPolyText16.c +++ b/xorg/X11R7.6/rdp/rdpPolyText16.c @@ -170,7 +170,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_POLYTEXT16); RegionUninit(®1); } else if (got_id) @@ -190,7 +190,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_POLYTEXT16); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPolyText8.c b/xorg/X11R7.6/rdp/rdpPolyText8.c index c06feac3..e92f8bc8 100644 --- a/xorg/X11R7.6/rdp/rdpPolyText8.c +++ b/xorg/X11R7.6/rdp/rdpPolyText8.c @@ -170,7 +170,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_POLYTEXT8); RegionUninit(®1); } else if (got_id) @@ -190,7 +190,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC, { if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®, GXcopy, dirty_type, TAG_POLYTEXT8); } else if (got_id) { diff --git a/xorg/X11R7.6/rdp/rdpPushPixels.c b/xorg/X11R7.6/rdp/rdpPushPixels.c index f7b77f23..a07ec5eb 100644 --- a/xorg/X11R7.6/rdp/rdpPushPixels.c +++ b/xorg/X11R7.6/rdp/rdpPushPixels.c @@ -160,7 +160,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, box.x2 = box.x1 + w; box.y2 = box.y1 + h; RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_PUSHPIXELS); RegionUninit(®1); } else if (got_id) @@ -185,7 +185,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_PUSHPIXELS); RegionUninit(®1); } else if (got_id) diff --git a/xorg/X11R7.6/rdp/rdpPutImage.c b/xorg/X11R7.6/rdp/rdpPutImage.c index 614d0a31..f27836d4 100644 --- a/xorg/X11R7.6/rdp/rdpPutImage.c +++ b/xorg/X11R7.6/rdp/rdpPutImage.c @@ -161,7 +161,7 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, box.x2 = box.x1 + w; box.y2 = box.y1 + h; RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_PUTIMAGE); RegionUninit(®1); } else if (got_id) @@ -183,7 +183,7 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, RegionInit(®2, NullBox, 0); RegionCopy(®2, &clip_reg); RegionIntersect(®1, ®1, ®2); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_PUTIMAGE); RegionUninit(®1); RegionUninit(®2); } diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index 69a9c72d..183b1346 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -45,6 +45,7 @@ Xserver drawing ops and funcs #include "rdpImageGlyphBlt.h" #include "rdpPolyGlyphBlt.h" #include "rdpPushPixels.h" +#include "rdpglyph.h" #define LOG_LEVEL 1 #define LLOG(_level, _args) \ @@ -65,6 +66,7 @@ extern int g_do_dirty_os; /* in rdpmain.c */ extern int g_do_dirty_ons; /* in rdpmain.c */ extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */ extern int g_con_number; /* in rdpmain.c */ +extern int g_do_glyph_cache; /* in rdpmain.c */ ColormapPtr g_rdpInstalledColormap; @@ -458,6 +460,11 @@ draw_item_remove(rdpPixmapRec *priv, struct rdp_draw_item *di) g_free(di->u.line.segs); } } + + if (di->type == RDI_TEXT) + { + delete_rdp_text(di->u.text.rtext); + } RegionDestroy(di->reg); g_free(di); @@ -481,6 +488,51 @@ draw_item_remove_all(rdpPixmapRec *priv) return 0; } +/******************************************************************************/ +int +region_get_pixel_count(RegionPtr reg) +{ + int index; + int count; + int pixels; + int width; + int height; + BoxRec box; + + pixels = 0; + count = REGION_NUM_RECTS(reg); + for (index = 0; index < count; index++) + { + box = REGION_RECTS(reg)[index]; + width = box.x2 - box.x1; + height = box.y2 - box.y1; + pixels += width * height; + } + return pixels; +} + +/******************************************************************************/ +int +region_in_region(RegionPtr reg_small, int sreg_pcount, RegionPtr reg_big) +{ + int rv; + RegionRec reg; + + rv = 0; + RegionInit(®, NullBox, 0); + RegionIntersect(®, reg_small, reg_big); + if (sreg_pcount == -1) + { + sreg_pcount = region_get_pixel_count(reg_small); + } + if (region_get_pixel_count(®) == sreg_pcount) + { + rv = 1; + } + RegionUninit(®); + return rv; +} + /******************************************************************************/ int draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) @@ -488,7 +540,25 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) struct rdp_draw_item *di; struct rdp_draw_item *di_prev; RegionRec treg; + BoxRec box; +#if 1 + box.x1 = 0; + box.x2 = pix->drawable.width; + box.y1 = 0; + box.y2 = pix->drawable.height; + RegionInit(&treg, &box, 0); + di = priv->draw_item_head; + di_prev = 0; + while (di != 0) + { + RegionIntersect(di->reg, di->reg, &treg); + di_prev = di; + di = di->next; + } + RegionUninit(&treg); +#endif + #if 1 /* look for repeating draw types */ @@ -501,17 +571,19 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) while (di != 0) { - if ((di_prev->type == RDI_IMGLL || di_prev->type == RDI_IMGLY || - di_prev->type == RDI_FILL) && - (di->type == RDI_IMGLL || di->type == RDI_IMGLY || - di->type == RDI_FILL)) + if ((di_prev->type == RDI_IMGLL) && (di->type == RDI_IMGLL)) + { + LLOGLN(10, ("draw_item_pack: packing RDI_IMGLL")); + RegionUnion(di_prev->reg, di_prev->reg, di->reg); + draw_item_remove(priv, di); + di = di_prev->next; + } + else if ((di_prev->type == RDI_IMGLY) && (di->type == RDI_IMGLY)) { - LLOGLN(10, ("draw_item_pack: packing RDI_IMGLL / RDI_IMGLY / " - "RDI_FILL")); + LLOGLN(10, ("draw_item_pack: packing RDI_IMGLY")); RegionUnion(di_prev->reg, di_prev->reg, di->reg); draw_item_remove(priv, di); di = di_prev->next; - di_prev->type = RDI_IMGLL; } else { @@ -545,15 +617,11 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) while (di_prev != 0) { - /* D = M - S */ - RegionInit(&treg, NullBox, 0); - RegionSubtract(&treg, di_prev->reg, di->reg); - if (!RegionNotEmpty(&treg)) + if (region_in_region(di_prev->reg, -1, di->reg)) { - /* copy empty region so this draw item will get removed below */ - RegionCopy(di_prev->reg, &treg); + /* empty region so this draw item will get removed below */ + RegionEmpty(di_prev->reg); } - RegionUninit(&treg); di_prev = di_prev->prev; } } @@ -589,13 +657,35 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) return 0; } +static char g_strings[][32] = +{ + "Composite", /* 0 */ + "CopyArea", /* 1 */ + "PolyFillRect", /* 2 */ + "PutImage", /* 3 */ + "PolyRectangle", /* 4 */ + "CopyPlane", /* 5 */ + "PolyArc", /* 6 */ + "FillPolygon", /* 7 */ + "PolyFillArc", /* 8 */ + "ImageText8", /* 9 */ + "PolyText8", /* 10 */ + "PolyText16", /* 11 */ + "ImageText16", /* 12 */ + "ImageGlyphBlt", /* 13 */ + "PolyGlyphBlt", /* 14 */ + "PushPixels", /* 15 */ + "Other" +}; + /******************************************************************************/ int draw_item_add_img_region(rdpPixmapRec *priv, RegionPtr reg, int opcode, - int type) + int type, int code) { struct rdp_draw_item *di; + LLOGLN(10, ("draw_item_add_img_region: %s", g_strings[code])); di = (struct rdp_draw_item *)g_malloc(sizeof(struct rdp_draw_item), 1); di->type = type; di->reg = RegionCreate(NullBox, 0); @@ -675,6 +765,25 @@ draw_item_add_srcblt_region(rdpPixmapRec *priv, RegionPtr reg, return 0; } +/******************************************************************************/ +int +draw_item_add_text_region(rdpPixmapRec* priv, RegionPtr reg, int color, + int opcode, struct rdp_text* rtext) +{ + struct rdp_draw_item* di; + + LLOGLN(10, ("draw_item_add_text_region:")); + di = (struct rdp_draw_item*)g_malloc(sizeof(struct rdp_draw_item), 1); + di->type = RDI_TEXT; + di->u.text.fg_color = color; + di->u.text.opcode = opcode; + di->u.text.rtext = rtext; + di->reg = RegionCreate(NullBox, 0); + RegionCopy(di->reg, reg); + draw_item_add(priv, di); + return 0; +} + /******************************************************************************/ PixmapPtr rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, @@ -1250,7 +1359,57 @@ rdpSaveScreen(ScreenPtr pScreen, int on) } /******************************************************************************/ -/* it looks like all the antialias draws go through here */ +int +rdpCreatePicture(PicturePtr pPicture) +{ + PictureScreenPtr ps; + int rv; + + LLOGLN(10, ("rdpCreatePicture:")); + ps = GetPictureScreen(g_pScreen); + ps->CreatePicture = g_rdpScreen.CreatePicture; + rv = ps->CreatePicture(pPicture); + ps->CreatePicture = rdpCreatePicture; + return rv; +} + +/******************************************************************************/ +void +rdpDestroyPicture(PicturePtr pPicture) +{ + PictureScreenPtr ps; + + LLOGLN(10, ("rdpDestroyPicture:")); + ps = GetPictureScreen(g_pScreen); + ps->DestroyPicture = g_rdpScreen.DestroyPicture; + ps->DestroyPicture(pPicture); + ps->DestroyPicture = rdpDestroyPicture; +} + +/******************************************************************************/ +/* it looks like all the antialias draws go through here + op is one of the following + #define PictOpMinimum 0 + #define PictOpClear 0 + #define PictOpSrc 1 + #define PictOpDst 2 + #define PictOpOver 3 + #define PictOpOverReverse 4 + #define PictOpIn 5 + #define PictOpInReverse 6 + #define PictOpOut 7 + #define PictOpOutReverse 8 + #define PictOpAtop 9 + #define PictOpAtopReverse 10 + #define PictOpXor 11 + #define PictOpAdd 12 + #define PictOpSaturate 13 + #define PictOpMaximum 13 + + see for porter duff + http://www.svgopen.org/2005/papers/abstractsvgopen/ + + */ void rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, @@ -1274,12 +1433,20 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, struct image_data id; LLOGLN(10, ("rdpComposite:")); + ps = GetPictureScreen(g_pScreen); ps->Composite = g_rdpScreen.Composite; ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height); ps->Composite = rdpComposite; + if (g_doing_font == 2) + { + return; + } + + LLOGLN(10, ("rdpComposite: op %d %p %p %p w %d h %d", op, pSrc, pMask, pDst, width, height)); + p = pDst->pDrawable; dirty_type = 0; @@ -1360,7 +1527,7 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, if (dirty_type != 0) { - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COMPOSITE); } else if (got_id) { @@ -1393,7 +1560,7 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, if (dirty_type != 0) { RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COMPOSITE); RegionUninit(®1); } else if (got_id) @@ -1418,26 +1585,31 @@ rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, GlyphPtr *glyphs) { PictureScreenPtr ps; - int index; - LLOGLN(10, ("rdpGlyphs:")); - LLOGLN(10, ("rdpGlyphs: nlists %d len %d", nlists, lists->len)); - rdpup_set_hints(1, 1); - g_doing_font = 1; + LLOGLN(10, ("rdpGlyphs: op %d xSrc %d ySrc %d", op, xSrc, ySrc)); - for (index = 0; index < lists->len; index++) + if (g_do_glyph_cache) { - LLOGLN(10, (" index %d size %d refcnt %d width %d height %d", - index, (int)(glyphs[index]->size), (int)(glyphs[index]->refcnt), - glyphs[index]->info.width, glyphs[index]->info.height)); + g_doing_font = 2; + ps = GetPictureScreen(g_pScreen); + ps->Glyphs = g_rdpScreen.Glyphs; + ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlists, lists, glyphs); + ps->Glyphs = rdpGlyphs; + rdpGlypht(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists, glyphs); + } + else + { + g_doing_font = 1; + rdpup_set_hints(1, 1); + ps = GetPictureScreen(g_pScreen); + ps->Glyphs = g_rdpScreen.Glyphs; + ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlists, lists, glyphs); + ps->Glyphs = rdpGlyphs; + rdpup_set_hints(0, 1); } - ps = GetPictureScreen(g_pScreen); - ps->Glyphs = g_rdpScreen.Glyphs; - ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, - nlists, lists, glyphs); - ps->Glyphs = rdpGlyphs; - rdpup_set_hints(0, 1); g_doing_font = 0; LLOGLN(10, ("rdpGlyphs: out")); } diff --git a/xorg/X11R7.6/rdp/rdpglyph.c b/xorg/X11R7.6/rdp/rdpglyph.c new file mode 100644 index 00000000..32811389 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpglyph.c @@ -0,0 +1,773 @@ +/* + Copyright 2012 Jay Sorg + + Permission to use, copy, modify, distribute, and sell this software and its + documentation for any purpose is hereby granted without fee, provided that + the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation. + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + */ + +/* + http://msdn.microsoft.com/en-us/library/cc241863(v=prot.20).aspx + 4.6.1 "d" Character + This topic has not yet been rated - Rate this topic + The following shows glyph image data (1 bpp format) for character + "d" extracted from a Cache Glyph (Revision 2) (section 2.2.2.2.1.2.6) + Secondary Drawing Order. + + Glyph width = 5 pixels + Glyph height = 9 pixels + Glyph origin = (0, -9), marked with an "X" on the image grid + Bitmap = { 0x08, 0x08, 0x08, 0x78, 0x88, 0x88, 0x88, 0x88, 0x78 } + + http://msdn.microsoft.com/en-us/library/cc241864(v=prot.20).aspx + 4.6.2 "p" Character + This topic has not yet been rated - Rate this topic + The following shows glyph image data (1 bpp format) for character + "p" extracted from a Cache Glyph (Revision 2) (section 2.2.2.2.1.2.6) + Secondary Drawing Order. + + Glyph width = 5 pixels + Glyph height = 8 pixels + Glyph origin = (0, -6), marked with an "X" on the image grid + Bitmap = { 0xF0, 0x88, 0x88, 0x88, 0x88, 0xF0, 0x80, 0x80 } + */ + +#include "rdp.h" +#include "rdpdraw.h" +#include "rdpglyph.h" + +extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */ +extern int g_do_dirty_os; /* in rdpmain.c */ +extern int g_do_alpha_glyphs; /* in rdpmain.c */ + +#define LOG_LEVEL 1 +#define LLOG(_level, _args) \ +do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0) +#define LLOGLN(_level, _args) \ +do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +struct font_cache +{ + int offset; + int baseline; + int width; + int height; + int crc; + int stamp; +}; + +static struct font_cache g_font_cache[12][256]; +static int g_stamp = 0; + +/*****************************************************************************/ +static void +set_mono_pixel(char* data, int x, int y, int width, int pixel) +{ + int start; + int shift; + + width = (width + 7) / 8; + start = (y * width) + x / 8; + shift = x % 8; + if (pixel != 0) + { + data[start] = data[start] | (0x80 >> shift); + } + else + { + data[start] = data[start] & ~(0x80 >> shift); + } +} + +/******************************************************************************/ +static int +glyph_get_data(ScreenPtr pScreen, GlyphPtr glyph, struct rdp_font_char* rfd) +{ + int i; + int j; + int src_xoff; + int src_yoff; + int stride_bytes; + int hh; + int ww; + int ss; + int depth; + unsigned char pixel; + PicturePtr pPicture; + pixman_image_t *src; + uint32_t* pi32; + char* pi8; + + pPicture = GlyphPicture(glyph)[pScreen->myNum]; + if (pPicture == 0) + { + return 0; + } + src = image_from_pict(pPicture, FALSE, &src_xoff, &src_yoff); + if (src == 0) + { + return 0; + } + + depth = pixman_image_get_depth(src); + stride_bytes = pixman_image_get_stride(src); + ww = pixman_image_get_width(src); + hh = pixman_image_get_height(src); + ss = (glyph->info.width + 3) & ~3; + if ((ww != glyph->info.width) || (hh != glyph->info.height) || + (depth != 8) || (stride_bytes != ss)) + { + LLOGLN(10, ("glyph_get_data: error w %d w %d h %d h %d " + "stride %d stride %d depth %d", ww, + glyph->info.width, hh, glyph->info.height, + stride_bytes, ss, depth)); + free_pixman_pict(pPicture, src); + return 0; + } + + if (g_do_alpha_glyphs) + { + rfd->data_bytes = glyph->info.height * stride_bytes; + rfd->bpp = 8; + } + else + { + rfd->data_bytes = (((glyph->info.height * + ((glyph->info.width + 7) / 8)) + 3) & ~3); + rfd->bpp = 1; + } + rfd->data = (char*)g_malloc(rfd->data_bytes, 1); + rfd->offset = -glyph->info.x; + rfd->baseline = -glyph->info.y; + rfd->width = glyph->info.width; + rfd->height = glyph->info.height; + + pi32 = pixman_image_get_data(src); + pi8 = (char*)pi32; + for (j = 0; j < rfd->height; j++) + { + for (i = 0; i < rfd->width; i++) + { + pixel = pi8[j * stride_bytes + i]; + if (g_do_alpha_glyphs) + { + rfd->data[j * stride_bytes + i] = pixel; + } + else + { + if (pixel > 0x7f) + { + set_mono_pixel(rfd->data, i, j, rfd->width, 1); + } + else + { + set_mono_pixel(rfd->data, i, j, rfd->width, 0); + } + } + } + } + free_pixman_pict(pPicture, src); + return 0; +} + +/******************************************************************************/ +struct rdp_text* +create_rdp_text(ScreenPtr pScreen, int nlists, GlyphListPtr lists, + GlyphPtr* glyphs) +{ + struct rdp_text* rv; + struct rdp_text* rtext; + struct rdp_text* last_rtext; + BoxRec box; + RegionRec reg1; + int n; + int lxoff; + int lyoff; + int count; + int lx; + int ly; + int font_index; + int max_height; + int min_height; + int force_new; + GlyphPtr glyph; + struct rdp_font_char* rfd; + + LLOGLN(10, ("create_rdp_text: nlists %d", nlists)); + + max_height = 0; + min_height = 0x7fffffff; + lx = lists->xOff; + ly = lists->yOff; + lxoff = 0; + lyoff = 0; + force_new = 0; + + rtext = (struct rdp_text*)g_malloc(sizeof(struct rdp_text), 1); + rtext->reg = RegionCreate(NullBox, 0); + rtext->flags = 3; + rtext->mixmode = 0; + rtext->x = lx; + rtext->y = ly; + + rv = rtext; + last_rtext = rtext; + + count = 0; + while (nlists--) + { + LLOGLN(10, ("lists->xOff %d lists->yOff %d", lists->xOff, lists->yOff)); + if (count != 0) + { + lx += lists->xOff; + ly += lists->yOff; + force_new = 1; + } + count++; + n = lists->len; + lists++; + while (n--) + { + glyph = *glyphs++; + /* process glyph here */ + if ((glyph->info.width > 0) && (glyph->info.height > 0)) + { + if (force_new) + { + LLOGLN(10, ("create_rdp_text: too many chars")); + force_new = 0; + rtext = (struct rdp_text*)g_malloc(sizeof(struct rdp_text), 1); + rtext->reg = RegionCreate(NullBox, 0); + rtext->flags = 3; + rtext->mixmode = 0; + rtext->x = lx; + rtext->y = ly; + last_rtext->next = rtext; + last_rtext = rtext; + lxoff = 0; + lyoff = 0; + } + LLOGLN(10, ("x %d y %d width %d height %d xOff %d yOff %d " + "num_chars %d lxoff %d lyoff %d lx %d ly %d", + glyph->info.x, glyph->info.y, + glyph->info.width, glyph->info.height, + glyph->info.xOff, glyph->info.yOff, rtext->num_chars, + lxoff, lyoff, lx, ly)); + rfd = (struct rdp_font_char*)g_malloc(sizeof(struct rdp_font_char), 1); + rtext->chars[rtext->num_chars] = rfd; + box.x1 = lx - glyph->info.x; + box.y1 = ly - glyph->info.y; + box.x2 = box.x1 + glyph->info.width; + box.y2 = box.y1 + glyph->info.height; + if (glyph->info.height > max_height) + { + max_height = glyph->info.height; + } + if (glyph->info.height < min_height) + { + min_height = glyph->info.height; + } + RegionInit(®1, &box, 0); + RegionUnion(rtext->reg, ®1, rtext->reg); + RegionUninit(®1); + + glyph_get_data(pScreen, glyph, rfd); + + rfd->incby = lxoff; + lxoff = glyph->info.xOff; + lyoff = glyph->info.yOff; + rtext->num_chars++; + if (rtext->num_chars > 63) + { + force_new = 1; + } + } + else + { + lxoff += glyph->info.xOff; + lyoff += glyph->info.yOff; + } + lx += glyph->info.xOff; + ly += glyph->info.yOff; + } + } + if (max_height > 10) + { + font_index = 8; + } + else if (max_height < 7) + { + font_index = 6; + } + else + { + font_index = 7; + } + LLOGLN(10, ("create_rdp_text: min_height %d max_height %d font_index %d", + min_height, max_height, font_index)); + rtext = rv; + while (rtext != 0) + { + rtext->font = font_index; + rtext = rtext->next; + } + return rv; +} + +/******************************************************************************/ +int +delete_rdp_text(struct rdp_text* rtext) +{ + int index; + + if (rtext == 0) + { + return 0; + } + for (index = 0; index < rtext->num_chars; index++) + { + if (rtext->chars[index] != 0) + { + g_free(rtext->chars[index]->data); + g_free(rtext->chars[index]); + } + } + RegionDestroy(rtext->reg); + delete_rdp_text(rtext->next); + g_free(rtext); + return 0; +} + +/******************************************************************************/ +static int +get_color(PicturePtr pPicture) +{ + int src_xoff; + int src_yoff; + int rv; + uint32_t* pi32; + pixman_image_t *src; + + src = image_from_pict(pPicture, FALSE, &src_xoff, &src_yoff); + if (src == 0) + { + return 0; + } + pi32 = pixman_image_get_data(src); + rv = *pi32; + LLOGLN(10, ("get_color: 0x%8.8x width %d height %d ", rv, + pixman_image_get_width(src), + pixman_image_get_height(src))); + free_pixman_pict(pPicture, src); + return rv; +} + +/******************************************************************************/ +static int +find_or_add_char(int font, struct rdp_font_char* rfd) +{ + int crc; + int index; + int char_index; + int oldest; + + crc = get_crc(rfd->data, rfd->data_bytes); + LLOGLN(10, ("find_or_add_char: crc 0x%8.8x", crc)); + char_index = 0; + oldest = 0x7fffffff; + for (index = 0; index < 250; index++) + { + if ((g_font_cache[font][index].crc == crc) && + (g_font_cache[font][index].width == rfd->width) && + (g_font_cache[font][index].height == rfd->height) && + (g_font_cache[font][index].offset == rfd->offset) && + (g_font_cache[font][index].baseline == rfd->baseline)) + { + g_stamp++; + g_font_cache[font][index].stamp = g_stamp; + LLOGLN(10, ("find_or_add_char: found char at %d %d", font, index)); + return index; + } + if (g_font_cache[font][index].stamp < oldest) + { + oldest = g_font_cache[font][index].stamp; + char_index = index; + } + } + g_stamp++; + g_font_cache[font][char_index].stamp = g_stamp; + g_font_cache[font][char_index].crc = crc; + g_font_cache[font][char_index].width = rfd->width; + g_font_cache[font][char_index].height = rfd->height; + g_font_cache[font][char_index].offset = rfd->offset; + g_font_cache[font][char_index].baseline = rfd->baseline; + LLOGLN(10, ("find_or_add_char: adding char at %d %d", font, char_index)); + if (rfd->bpp == 8) + { + rdpup_add_char_alpha(font, char_index, rfd->offset, rfd->baseline, + rfd->width, rfd->height, + rfd->data, rfd->data_bytes); + } + else + { + rdpup_add_char(font, char_index, rfd->offset, rfd->baseline, + rfd->width, rfd->height, + rfd->data, rfd->data_bytes); + } + return char_index; +} + +/******************************************************************************/ +int +rdp_text_chars_to_data(struct rdp_text* rtext) +{ + int index; + int data_bytes; + int char_index; + struct rdp_font_char* rfd; + + LLOGLN(10, ("rdp_text_chars_to_data: rtext->num_chars %d", rtext->num_chars)); + data_bytes = 0; + for (index = 0; index < rtext->num_chars; index++) + { + rfd = rtext->chars[index]; + if (rfd == 0) + { + LLOGLN(0, ("rdp_text_chars_to_data: error rfd is nil")); + continue; + } + char_index = find_or_add_char(rtext->font, rfd); + rtext->data[data_bytes] = char_index; + data_bytes++; + if (rfd->incby > 127) + { + rtext->data[data_bytes] = 0x80; + data_bytes++; + rtext->data[data_bytes] = (rfd->incby >> 0) & 0xff; + data_bytes++; + rtext->data[data_bytes] = (rfd->incby >> 8) & 0xff; + data_bytes++; + } + else + { + rtext->data[data_bytes] = rfd->incby; + data_bytes++; + } + } + rtext->data_bytes = data_bytes; + return 0; +} + +/******************************************************************************/ +/* + typedef struct _GlyphList { + INT16 xOff; + INT16 yOff; + CARD8 len; + PictFormatPtr format; + } GlyphListRec, *GlyphListPtr; + */ +/* see ghyphstr.h but the follow is not in there + typedef struct _XGlyphInfo { + unsigned short width; + unsigned short height; + short x; + short y; + short xOff; + short yOff; + } XGlyphInfo; + */ +static void +rdpGlyphu(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, + int nlists, GlyphListPtr lists, GlyphPtr* glyphs, + BoxPtr extents) +{ + BoxRec box; + RegionRec reg1; + RegionRec reg2; + DrawablePtr p; + int dirty_type; + int j; + int num_clips; + int post_process; + int reset_surface; + int got_id; + int fg_color; + WindowPtr pDstWnd; + PixmapPtr pDstPixmap; + rdpPixmapRec* pDstPriv; + rdpPixmapRec* pDirtyPriv; + struct image_data id; + struct rdp_text* rtext; + struct rdp_text* trtext; + + LLOGLN(10, ("rdpGlyphu: xSrc %d ySrc %d", xSrc, ySrc)); + + p = pDst->pDrawable; + + dirty_type = 0; + pDirtyPriv = 0; + post_process = 0; + reset_surface = 0; + got_id = 0; + if (p->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)p; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + post_process = 1; + if (g_do_dirty_os) + { + LLOGLN(10, ("rdpGlyphu: gettig dirty")); + pDstPriv->is_dirty = 1; + dirty_type = RDI_IMGLL; + pDirtyPriv = pDstPriv; + + } + else + { + rdpup_switch_os_surface(pDstPriv->rdpindex); + reset_surface = 1; + rdpup_get_pixmap_image_rect(pDstPixmap, &id); + got_id = 1; + LLOGLN(10, ("rdpGlyphu: offscreen")); + } + } + } + else + { + if (p->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)p; + if (pDstWnd->viewable) + { + post_process = 1; + rdpup_get_screen_image_rect(&id); + got_id = 1; + LLOGLN(10, ("rdpGlyphu: screen")); + } + } + } + if (!post_process) + { + return; + } + + rtext = create_rdp_text(pDst->pDrawable->pScreen, nlists, lists, glyphs); + if (rtext == 0) + { + LLOGLN(0, ("rdpGlyphu: create_rdp_text failed")); + return; + } + fg_color = get_color(pSrc); + + LLOGLN(10, ("rdpGlyphu: pDst->clientClipType %d pCompositeClip %p", + pDst->clientClipType, pDst->pCompositeClip)); + + if (pDst->pCompositeClip != 0) + { + box.x1 = p->x + extents->x1; + box.y1 = p->y + extents->y1; + box.x2 = p->x + extents->x2; + box.y2 = p->y + extents->y2; + RegionInit(®1, &box, 0); + RegionInit(®2, NullBox, 0); + RegionCopy(®2, pDst->pCompositeClip); + RegionIntersect(®1, ®1, ®2); + if (dirty_type != 0) + { + LLOGLN(10, ("1")); + draw_item_add_text_region(pDirtyPriv, ®1, fg_color, GXcopy, rtext); + rtext = 0; + } + else if (got_id) + { + num_clips = REGION_NUM_RECTS(®1); + if (num_clips > 0) + { + LLOGLN(10, (" num_clips %d", num_clips)); + rdpup_begin_update(); + rdpup_set_fgcolor(fg_color); + trtext = rtext; + while (trtext != 0) + { + rdp_text_chars_to_data(trtext); + for (j = num_clips - 1; j >= 0; j--) + { + box = REGION_RECTS(®1)[j]; + LLOGLN(10, ("2")); + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + LLOGLN(10, ("rdpGlyphu: rdpup_draw_text")); + box = RegionExtents(trtext->reg)[0]; + rdpup_draw_text(trtext->font, trtext->flags, trtext->mixmode, + box.x1 + p->x, box.y1 + p->y, + box.x2 + p->x, box.y2 + p->y, + //box.x1 + p->x, box.y1 + p->y, + //box.x2 + p->x, box.y2 + p->y, + 0, 0, 0, 0, + trtext->x + p->x, trtext->y + p->y, + trtext->data, trtext->data_bytes); + } + trtext = trtext->next; + } + rdpup_reset_clip(); + rdpup_end_update(); + } + } + RegionUninit(®1); + RegionUninit(®2); + } + else + { + box.x1 = p->x + extents->x1; + box.y1 = p->y + extents->y1; + box.x2 = p->x + extents->x2; + box.y2 = p->y + extents->y2; + if (dirty_type != 0) + { + RegionInit(®1, &box, 0); + LLOGLN(10, ("3")); + draw_item_add_text_region(pDirtyPriv, ®1, fg_color, GXcopy, rtext); + rtext = 0; + RegionUninit(®1); + } + else if (got_id) + { + rdpup_begin_update(); + LLOGLN(10, ("4")); + rdpup_set_fgcolor(fg_color); + trtext = rtext; + while (trtext != 0) + { + LLOGLN(10, ("rdpGlyphu: rdpup_draw_text")); + rdp_text_chars_to_data(trtext); + box = RegionExtents(trtext->reg)[0]; + rdpup_draw_text(trtext->font, trtext->flags, trtext->mixmode, + box.x1 + p->x, box.y1 + p->y, + box.x2 + p->x, box.y2 + p->y, + //box.x1 + p->x, box.y1 + p->y, + //box.x2 + p->x, box.y2 + p->y, + 0, 0, 0, 0, + trtext->x + p->x, trtext->y + p->y, + trtext->data, trtext->data_bytes); + trtext = trtext->next; + } + rdpup_end_update(); + } + } + if (reset_surface) + { + rdpup_switch_os_surface(-1); + } + delete_rdp_text(rtext); +} + +/******************************************************************************/ +static void +GlyphExtents(int nlist, GlyphListPtr list, GlyphPtr* glyphs, BoxPtr extents) +{ + int x1; + int x2; + int y1; + int y2; + int n; + int x; + int y; + GlyphPtr glyph; + + x = 0; + y = 0; + extents->x1 = MAXSHORT; + extents->x2 = MINSHORT; + extents->y1 = MAXSHORT; + extents->y2 = MINSHORT; + while (nlist--) + { + x += list->xOff; + y += list->yOff; + n = list->len; + list++; + while (n--) + { + glyph = *glyphs++; + x1 = x - glyph->info.x; + if (x1 < MINSHORT) + { + x1 = MINSHORT; + } + y1 = y - glyph->info.y; + if (y1 < MINSHORT) + { + y1 = MINSHORT; + } + x2 = x1 + glyph->info.width; + if (x2 > MAXSHORT) + { + x2 = MAXSHORT; + } + y2 = y1 + glyph->info.height; + if (y2 > MAXSHORT) + { + y2 = MAXSHORT; + } + if (x1 < extents->x1) + { + extents->x1 = x1; + } + if (x2 > extents->x2) + { + extents->x2 = x2; + } + if (y1 < extents->y1) + { + extents->y1 = y1; + } + if (y2 > extents->y2) + { + extents->y2 = y2; + } + x += glyph->info.xOff; + y += glyph->info.yOff; + } + } +} + +/******************************************************************************/ +void +rdpGlypht(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, + int nlists, GlyphListPtr lists, GlyphPtr* glyphs) +{ + BoxRec extents; + + GlyphExtents(nlists, lists, glyphs, &extents); + if ((extents.x2 <= extents.x1) || (extents.y2 <= extents.y1)) + { + return; + } + rdpGlyphu(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists, + glyphs, &extents); +} + +/******************************************************************************/ +int +rdpGlyphInit(void) +{ + memset(&g_font_cache, 0, sizeof(g_font_cache)); + return 0; +} diff --git a/xorg/X11R7.6/rdp/rdpglyph.h b/xorg/X11R7.6/rdp/rdpglyph.h new file mode 100644 index 00000000..6bc6a9b3 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpglyph.h @@ -0,0 +1,64 @@ +/* +Copyright 2012 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPGLYPH_H +#define __RDPGLYPH_H + +struct rdp_font_char +{ + int offset; /* x */ + int baseline; /* y */ + int width; /* cx */ + int height; /* cy */ + int incby; + int bpp; + char* data; + int data_bytes; +}; + +struct rdp_text +{ + RegionPtr reg; + int font; + int x; + int y; + int flags; + int mixmode; + char data[256]; + int data_bytes; + struct rdp_font_char* chars[256]; + int num_chars; + struct rdp_text* next; +}; + +int +delete_rdp_text(struct rdp_text* rtext); +int +rdp_text_chars_to_data(struct rdp_text* rtext); + +void +rdpGlypht(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, + int nlists, GlyphListPtr lists, GlyphPtr* glyphs); +int +rdpGlyphInit(void); + +#endif diff --git a/xorg/X11R7.6/rdp/rdpmain.c b/xorg/X11R7.6/rdp/rdpmain.c index f81b4f70..b92ba044 100644 --- a/xorg/X11R7.6/rdp/rdpmain.c +++ b/xorg/X11R7.6/rdp/rdpmain.c @@ -24,6 +24,7 @@ Sets up the functions #include "rdp.h" #include "rdprandr.h" +#include "rdpglyph.h" #if 1 #define DEBUG_OUT(arg) @@ -47,6 +48,8 @@ int g_can_do_pix_to_pix = 0; int g_do_dirty_os = 1; /* delay remoting off screen bitmaps */ int g_do_dirty_ons = 0; /* delay remoting screen */ +int g_do_glyph_cache = 1; +int g_do_alpha_glyphs = 1; Bool g_wrapWindow = 1; Bool g_wrapPixmap = 1; @@ -396,6 +399,8 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) if (ps) { + g_rdpScreen.CreatePicture = ps->CreatePicture; + g_rdpScreen.DestroyPicture = ps->DestroyPicture; g_rdpScreen.Composite = ps->Composite; g_rdpScreen.Glyphs = ps->Glyphs; @@ -409,6 +414,8 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) if (ps) { + ps->CreatePicture = rdpCreatePicture; + ps->DestroyPicture = rdpDestroyPicture; ps->Composite = rdpComposite; ps->Glyphs = rdpGlyphs; } @@ -528,6 +535,8 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) } + rdpGlyphInit(); + //rdpXvInit(pScreen); ErrorF("rdpScreenInit: ret %d\n", ret); diff --git a/xorg/X11R7.6/rdp/rdpmisc.c b/xorg/X11R7.6/rdp/rdpmisc.c index dc54581a..eb5bedad 100644 --- a/xorg/X11R7.6/rdp/rdpmisc.c +++ b/xorg/X11R7.6/rdp/rdpmisc.c @@ -27,6 +27,59 @@ the rest Bool noFontCacheExtension = 1; +static int g_crc_seed = 0xffffffff; +static int g_crc_table[256] = +{ + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, + 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, + 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, + 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, + 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, + 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, + 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, + 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d +}; + +#define CRC_START(in_crc) (in_crc) = g_crc_seed +#define CRC_PASS(in_pixel, in_crc) \ + (in_crc) = g_crc_table[((in_crc) ^ (in_pixel)) & 0xff] ^ ((in_crc) >> 8) +#define CRC_END(in_crc) (in_crc) = ((in_crc) ^ g_crc_seed) + /******************************************************************************/ /* print a time-stamped message to the log file (stderr). */ void @@ -599,3 +652,19 @@ RegionAroundSegs(RegionPtr reg, xSegment *segs, int nseg) index++; } } + +/******************************************************************************/ +int +get_crc(char* data, int data_bytes) +{ + int crc; + int index; + + CRC_START(crc); + for (index = 0; index < data_bytes; index++) + { + CRC_PASS(data[index], crc); + } + CRC_END(crc); + return crc; +} diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index 3d7bf196..1d4962b2 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -21,6 +21,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "rdp.h" #include "xrdp_rail.h" +#include "rdpglyph.h" #define LOG_LEVEL 1 #define LLOG(_level, _args) \ @@ -941,6 +942,7 @@ rdpup_check(void) g_sck_closed = 0; g_begin = 0; g_con_number++; + rdpGlyphInit(); AddEnabledDevice(g_sck); } } @@ -1876,6 +1878,8 @@ rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec *pDirtyPriv) xSegment *seg; struct image_data id; struct rdp_draw_item *di; + struct rdp_text* rtext; + struct rdp_text* trtext; if (pDirtyPriv == 0) { @@ -1982,6 +1986,37 @@ rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec *pDirtyPriv) case RDI_SCRBLT: LLOGLN(10, (" RDI_SCRBLT")); break; + case RDI_TEXT: + LLOGLN(10, (" RDI_TEXT")); + num_clips = REGION_NUM_RECTS(di->reg); + if (num_clips > 0) + { + LLOGLN(10, (" num_clips %d", num_clips)); + rdpup_set_fgcolor(di->u.text.fg_color); + rdpup_set_opcode(di->u.text.opcode); + rtext = di->u.text.rtext; + trtext = rtext; + while (trtext != 0) + { + rdp_text_chars_to_data(trtext); + for (clip_index = num_clips - 1; clip_index >= 0; clip_index--) + { + box = REGION_RECTS(di->reg)[clip_index]; + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + LLOGLN(10, (" %d %d %d %d", box.x1, box.y1, box.x2, box.y2)); + box = RegionExtents(trtext->reg)[0]; + rdpup_draw_text(trtext->font, trtext->flags, trtext->mixmode, + box.x1, box.y1, box.x2, box.y2, + //box.x1, box.y1, box.x2, box.y2, + 0, 0, 0, 0, + trtext->x, trtext->y, trtext->data, trtext->data_bytes); + } + trtext = trtext->next; + } + } + rdpup_reset_clip(); + rdpup_set_opcode(GXcopy); + break; } di = di->next; @@ -2117,3 +2152,87 @@ rdpup_check_dirty_screen(rdpPixmapRec *pDirtyPriv) pDirtyPriv->is_dirty = 0; return 0; } + +/******************************************************************************/ +int +rdpup_add_char(int font, int charactor, short x, short y, int cx, int cy, + char* bmpdata, int bmpdata_bytes) +{ + if (g_connected) + { + LLOGLN(10, (" rdpup_add_char")); + rdpup_pre_check(18 + bmpdata_bytes); + out_uint16_le(g_out_s, 28); /* add char */ + out_uint16_le(g_out_s, 18 + bmpdata_bytes); /* size */ + g_count++; + out_uint16_le(g_out_s, font); + out_uint16_le(g_out_s, charactor); + out_uint16_le(g_out_s, x); + out_uint16_le(g_out_s, y); + out_uint16_le(g_out_s, cx); + out_uint16_le(g_out_s, cy); + out_uint16_le(g_out_s, bmpdata_bytes); + out_uint8a(g_out_s, bmpdata, bmpdata_bytes); + } + return 0; +} + +/******************************************************************************/ +int +rdpup_add_char_alpha(int font, int charactor, short x, short y, int cx, int cy, + char* bmpdata, int bmpdata_bytes) +{ + if (g_connected) + { + LLOGLN(10, (" rdpup_add_char_alpha")); + rdpup_pre_check(18 + bmpdata_bytes); + out_uint16_le(g_out_s, 29); /* add char alpha */ + out_uint16_le(g_out_s, 18 + bmpdata_bytes); /* size */ + g_count++; + out_uint16_le(g_out_s, font); + out_uint16_le(g_out_s, charactor); + out_uint16_le(g_out_s, x); + out_uint16_le(g_out_s, y); + out_uint16_le(g_out_s, cx); + out_uint16_le(g_out_s, cy); + out_uint16_le(g_out_s, bmpdata_bytes); + out_uint8a(g_out_s, bmpdata, bmpdata_bytes); + } + return 0; +} + +/******************************************************************************/ +int +rdpup_draw_text(int font, int flags, int mixmode, + short clip_left, short clip_top, + short clip_right, short clip_bottom, + short box_left, short box_top, + short box_right, short box_bottom, short x, short y, + char* data, int data_bytes) +{ + if (g_connected) + { + LLOGLN(10, (" rdpup_draw_text")); + rdpup_pre_check(32 + data_bytes); + out_uint16_le(g_out_s, 30); /* draw text */ + out_uint16_le(g_out_s, 32 + data_bytes); /* size */ + g_count++; + out_uint16_le(g_out_s, font); + out_uint16_le(g_out_s, flags); + out_uint16_le(g_out_s, mixmode); + out_uint16_le(g_out_s, clip_left); + out_uint16_le(g_out_s, clip_top); + out_uint16_le(g_out_s, clip_right); + out_uint16_le(g_out_s, clip_bottom); + out_uint16_le(g_out_s, box_left); + out_uint16_le(g_out_s, box_top); + out_uint16_le(g_out_s, box_right); + out_uint16_le(g_out_s, box_bottom); + out_uint16_le(g_out_s, x); + out_uint16_le(g_out_s, y); + out_uint16_le(g_out_s, data_bytes); + out_uint8a(g_out_s, data, data_bytes); + } + return 0; +} + diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index 99d5743b..44246984 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -468,3 +468,7 @@ int DEFAULT_CC server_monitored_desktop(struct xrdp_mod* mod, struct rail_monitored_desktop_order* mdo, int flags); +int DEFAULT_CC +server_add_char_alpha(struct xrdp_mod* mod, int font, int charactor, + int offset, int baseline, + int width, int height, char* data); diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 67c53a28..88f888c7 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -413,6 +413,7 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self) self->mod->server_notify_new_update = server_notify_new_update; self->mod->server_notify_delete = server_notify_delete; self->mod->server_monitored_desktop = server_monitored_desktop; + self->mod->server_add_char_alpha = server_add_char_alpha; } } @@ -2293,6 +2294,7 @@ server_add_char(struct xrdp_mod *mod, int font, int charactor, fi.height = height; fi.incby = 0; fi.data = data; + fi.bpp = 1; return libxrdp_orders_send_font(((struct xrdp_wm *)mod->wm)->session, &fi, font, charactor); } @@ -2890,3 +2892,23 @@ server_monitored_desktop(struct xrdp_mod *mod, wm = (struct xrdp_wm *)(mod->wm); return libxrdp_monitored_desktop(wm->session, mdo, flags); } + +/*****************************************************************************/ +int DEFAULT_CC +server_add_char_alpha(struct xrdp_mod* mod, int font, int charactor, + int offset, int baseline, + int width, int height, char* data) +{ + struct xrdp_font_char fi; + + fi.offset = offset; + fi.baseline = baseline; + fi.width = width; + fi.height = height; + fi.incby = 0; + fi.data = data; + fi.bpp = 8; + return libxrdp_orders_send_font(((struct xrdp_wm*)mod->wm)->session, + &fi, font, charactor); +} + diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index 7dfd8ef3..7f08b4a0 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -118,8 +118,11 @@ struct xrdp_mod int flags); int (*server_set_pointer_ex)(struct xrdp_mod* v, int x, int y, char* data, char* mask, int bpp); + int (*server_add_char_alpha)(struct xrdp_mod* mod, int font, int charactor, + int offset, int baseline, + int width, int height, char* data); - long server_dumby[100 - 38]; /* align, 100 minus the number of server + long server_dumby[100 - 39]; /* align, 100 minus the number of server functions above */ /* common */ long handle; /* pointer to self as int */ diff --git a/xup/xup.c b/xup/xup.c index 882d157c..d77eee55 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -554,6 +554,18 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s) int height; int fgcolor; int opcode; + int charactor; + int font; + int flags; + int mixmode; + int clip_left; + int clip_top; + int clip_right; + int clip_bottom; + int box_left; + int box_top; + int box_right; + int box_bottom; char *bmpdata; char cur_data[32 * (32 * 3)]; char cur_mask[32 * (32 / 8)]; @@ -675,6 +687,48 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s) case 27: /* server_window_new_update - show */ rv = process_server_window_show(mod, s); break; + case 28: /* server_add_char */ + in_uint16_le(s, font); + in_uint16_le(s, charactor); + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + in_uint16_le(s, len_bmpdata); + in_uint8p(s, bmpdata, len_bmpdata); + rv = mod->server_add_char(mod, font, charactor, x, y, cx, cy, bmpdata); + break; + case 29: /* server_add_char_alpha */ + in_uint16_le(s, font); + in_uint16_le(s, charactor); + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + in_uint16_le(s, len_bmpdata); + in_uint8p(s, bmpdata, len_bmpdata); + rv = mod->server_add_char_alpha(mod, font, charactor, x, y, cx, cy, bmpdata); + break; + case 30: /* server_draw_text */ + in_uint16_le(s, font); + in_uint16_le(s, flags); + in_uint16_le(s, mixmode); + in_sint16_le(s, clip_left); + in_sint16_le(s, clip_top); + in_sint16_le(s, clip_right); + in_sint16_le(s, clip_bottom); + in_sint16_le(s, box_left); + in_sint16_le(s, box_top); + in_sint16_le(s, box_right); + in_sint16_le(s, box_bottom); + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, len_bmpdata); + in_uint8p(s, bmpdata, len_bmpdata); + rv = mod->server_draw_text(mod, font, flags, mixmode, clip_left, clip_top, + clip_right, clip_bottom, box_left, box_top, + box_right, box_bottom, x, y, bmpdata, len_bmpdata); + break; case 51: /* server_set_pointer_ex */ rv = process_server_set_pointer_ex(mod, s); break; diff --git a/xup/xup.h b/xup/xup.h index a7956915..93465695 100644 --- a/xup/xup.h +++ b/xup/xup.h @@ -119,8 +119,11 @@ struct mod int flags); int (*server_set_cursor_ex)(struct mod* v, int x, int y, char* data, char* mask, int bpp); + int (*server_add_char_alpha)(struct mod* v, int font, int charactor, + int offset, int baseline, + int width, int height, char* data); - tbus server_dumby[100 - 38]; /* align, 100 minus the number of server + tbus server_dumby[100 - 39]; /* align, 100 minus the number of server functions above */ /* common */ tbus handle; /* pointer to self as long */ From 4bfe0c167a593c6c8c8a810f6b912025c45e9662 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Fri, 5 Jul 2013 14:27:40 -0700 Subject: [PATCH 14/31] Fix merge errors introduced in 3ae1b415 and 20ec9ee3 --- sesman/chansrv/rail.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index 23399a18..c2137fb7 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -1135,6 +1135,8 @@ rail_win_send_text(Window win) static int APP_CC rail_destroy_window(Window window_id) { + struct stream *s; + LOG(10, ("chansrv::rail_destroy_window 0x%8.8x", window_id)); make_stream(s); init_stream(s, 1024); @@ -1672,7 +1674,7 @@ rail_xevent(void *xevent) rail_destroy_window(lxevent->xdestroywindow.window); list_remove_item(g_window_list, index); } - v = 0; + rv = 0; break; case MapRequest: From 689b178050a175528d737e077bad461e0fd71b1d Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Fri, 5 Jul 2013 14:55:31 -0700 Subject: [PATCH 15/31] Hand-apply patches (glphy cache) from Authetnic8 branch: 1048147 3fc5974 0552905 00b08a0 --- libxrdp/xrdp_rdp.c | 64 ++++++++++++++++++------------------- xorg/X11R7.6/rdp/rdpglyph.c | 64 ++++++++++++++++++++++--------------- xorg/X11R7.6/rdp/rdpmain.c | 2 +- xorg/X11R7.6/rdp/rdpup.c | 7 ++++ 4 files changed, 79 insertions(+), 58 deletions(-) diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index bc324e9c..38e98882 100644 --- a/libxrdp/xrdp_rdp.c +++ b/libxrdp/xrdp_rdp.c @@ -671,38 +671,38 @@ xrdp_rdp_send_demand_active(struct xrdp_rdp *self) out_uint16_le(s, 0x2f); /* Number of fonts */ out_uint16_le(s, 0x22); /* Capability flags */ /* caps */ - out_uint8(s, 1); /* dest blt */ - out_uint8(s, 1); /* pat blt */ - out_uint8(s, 1); /* screen blt */ - out_uint8(s, 1); /* mem blt */ - out_uint8(s, 0); /* tri blt */ - out_uint8(s, 0); /* unused */ - out_uint8(s, 0); /* unused */ - out_uint8(s, 0); /* nine grid */ - out_uint8(s, 1); /* line to */ - out_uint8(s, 0); /* multi nine grid */ - out_uint8(s, 1); /* rect */ - out_uint8(s, 0); /* desk save */ - out_uint8(s, 0); /* unused */ - out_uint8(s, 0); /* unused */ - out_uint8(s, 0); /* unused */ - out_uint8(s, 0); /* multi dest blt */ - out_uint8(s, 0); /* multi pat blt */ - out_uint8(s, 0); /* multi screen blt */ - out_uint8(s, 1); /* multi rect */ - out_uint8(s, 0); /* fast index */ - out_uint8(s, 0); /* polygonSC ([MS-RDPEGDI], 2.2.2.2.1.1.2.16) */ - out_uint8(s, 0); /* polygonCB ([MS-RDPEGDI], 2.2.2.2.1.1.2.17) */ - out_uint8(s, 0); /* polyline */ - out_uint8(s, 0); /* unused */ - out_uint8(s, 0); /* fast glyph */ - out_uint8(s, 0); /* ellipse */ - out_uint8(s, 0); /* ellipse */ - out_uint8(s, 0); /* ? */ - out_uint8(s, 0); /* unused */ - out_uint8(s, 0); /* unused */ - out_uint8(s, 0); /* unused */ - out_uint8(s, 0); /* unused */ + out_uint8(s, 1); /* NEG_DSTBLT_INDEX 0x00 0 */ + out_uint8(s, 1); /* NEG_PATBLT_INDEX 0x01 1 */ + out_uint8(s, 1); /* NEG_SCRBLT_INDEX 0x02 2 */ + out_uint8(s, 1); /* NEG_MEMBLT_INDEX 0x03 3 */ + out_uint8(s, 0); /* NEG_MEM3BLT_INDEX 0x04 4 */ + out_uint8(s, 0); /* NEG_ATEXTOUT_INDEX 0x05 5 */ + out_uint8(s, 0); /* NEG_AEXTTEXTOUT_INDEX 0x06 6 */ + out_uint8(s, 0); /* NEG_DRAWNINEGRID_INDEX 0x07 7 */ + out_uint8(s, 1); /* NEG_LINETO_INDEX 0x08 8 */ + out_uint8(s, 0); /* NEG_MULTI_DRAWNINEGRID_INDEX 0x09 9 */ + out_uint8(s, 1); /* NEG_OPAQUE_RECT_INDEX 0x0A 10 */ + out_uint8(s, 0); /* NEG_SAVEBITMAP_INDEX 0x0B 11 */ + out_uint8(s, 0); /* NEG_WTEXTOUT_INDEX 0x0C 12 */ + out_uint8(s, 0); /* NEG_MEMBLT_V2_INDEX 0x0D 13 */ + out_uint8(s, 0); /* NEG_MEM3BLT_V2_INDEX 0x0E 14 */ + out_uint8(s, 0); /* NEG_MULTIDSTBLT_INDEX 0x0F 15 */ + out_uint8(s, 0); /* NEG_MULTIPATBLT_INDEX 0x10 16 */ + out_uint8(s, 0); /* NEG_MULTISCRBLT_INDEX 0x11 17 */ + out_uint8(s, 1); /* NEG_MULTIOPAQUERECT_INDEX 0x12 18 */ + out_uint8(s, 0); /* NEG_FAST_INDEX_INDEX 0x13 19 */ + out_uint8(s, 0); /* NEG_POLYGON_SC_INDEX 0x14 20 */ + out_uint8(s, 0); /* NEG_POLYGON_CB_INDEX 0x15 21 */ + out_uint8(s, 0); /* NEG_POLYLINE_INDEX 0x16 22 */ + out_uint8(s, 0); /* unused 0x17 23 */ + out_uint8(s, 0); /* NEG_FAST_GLYPH_INDEX 0x18 24 */ + out_uint8(s, 0); /* NEG_ELLIPSE_SC_INDEX 0x19 25 */ + out_uint8(s, 0); /* NEG_ELLIPSE_CB_INDEX 0x1A 26 */ + out_uint8(s, 1); /* NEG_GLYPH_INDEX_INDEX 0x1B 27 */ + out_uint8(s, 0); /* NEG_GLYPH_WEXTTEXTOUT_INDEX 0x1C 28 */ + out_uint8(s, 0); /* NEG_GLYPH_WLONGTEXTOUT_INDEX 0x1D 29 */ + out_uint8(s, 0); /* NEG_GLYPH_WLONGEXTTEXTOUT_INDEX 0x1E 30 */ + out_uint8(s, 0); /* unused 0x1F 31 */ out_uint16_le(s, 0x6a1); /* declare support of bitmap cache rev3 */ out_uint16_le(s, XR_ORDERFLAGS_EX_CACHE_BITMAP_REV3_SUPPORT); diff --git a/xorg/X11R7.6/rdp/rdpglyph.c b/xorg/X11R7.6/rdp/rdpglyph.c index 32811389..3da30737 100644 --- a/xorg/X11R7.6/rdp/rdpglyph.c +++ b/xorg/X11R7.6/rdp/rdpglyph.c @@ -92,6 +92,26 @@ set_mono_pixel(char* data, int x, int y, int width, int pixel) } } +/*****************************************************************************/ +static int +lget_pixel(char* data, int x, int y, int depth, int stride_bytes) +{ + int start; + int shift; + + if (depth == 1) + { + start = (y * stride_bytes) + x / 8; + shift = x % 8; + return (data[start] & (0x01 << shift)) ? 0xff : 0; + } + else if (depth == 8) + { + return data[y * stride_bytes + x]; + } + return 0; +} + /******************************************************************************/ static int glyph_get_data(ScreenPtr pScreen, GlyphPtr glyph, struct rdp_font_char* rfd) @@ -100,11 +120,11 @@ glyph_get_data(ScreenPtr pScreen, GlyphPtr glyph, struct rdp_font_char* rfd) int j; int src_xoff; int src_yoff; - int stride_bytes; + int src_stride_bytes; + int dst_stride_bytes; int hh; int ww; - int ss; - int depth; + int src_depth; unsigned char pixel; PicturePtr pPicture; pixman_image_t *src; @@ -122,49 +142,43 @@ glyph_get_data(ScreenPtr pScreen, GlyphPtr glyph, struct rdp_font_char* rfd) return 0; } - depth = pixman_image_get_depth(src); - stride_bytes = pixman_image_get_stride(src); - ww = pixman_image_get_width(src); - hh = pixman_image_get_height(src); - ss = (glyph->info.width + 3) & ~3; - if ((ww != glyph->info.width) || (hh != glyph->info.height) || - (depth != 8) || (stride_bytes != ss)) - { - LLOGLN(10, ("glyph_get_data: error w %d w %d h %d h %d " - "stride %d stride %d depth %d", ww, - glyph->info.width, hh, glyph->info.height, - stride_bytes, ss, depth)); - free_pixman_pict(pPicture, src); - return 0; - } - + src_stride_bytes = pixman_image_get_stride(src); if (g_do_alpha_glyphs) { - rfd->data_bytes = glyph->info.height * stride_bytes; + dst_stride_bytes = (glyph->info.width + 3) & ~3; rfd->bpp = 8; } else { - rfd->data_bytes = (((glyph->info.height * - ((glyph->info.width + 7) / 8)) + 3) & ~3); + dst_stride_bytes = (((glyph->info.width + 7) / 8) + 3) & ~3; rfd->bpp = 1; } + src_depth = pixman_image_get_depth(src); + ww = pixman_image_get_width(src); + hh = pixman_image_get_height(src); + if ((ww != glyph->info.width) || (hh != glyph->info.height) || + ((src_depth != 1) && (src_depth != 8))) + { + LLOGLN(0, ("glyph_get_data: bad glyph")); + free_pixman_pict(pPicture, src); + return 0; + } + rfd->data_bytes = glyph->info.height * dst_stride_bytes; rfd->data = (char*)g_malloc(rfd->data_bytes, 1); rfd->offset = -glyph->info.x; rfd->baseline = -glyph->info.y; rfd->width = glyph->info.width; rfd->height = glyph->info.height; - pi32 = pixman_image_get_data(src); pi8 = (char*)pi32; for (j = 0; j < rfd->height; j++) { for (i = 0; i < rfd->width; i++) { - pixel = pi8[j * stride_bytes + i]; + pixel = lget_pixel(pi8, i, j, src_depth, src_stride_bytes); if (g_do_alpha_glyphs) { - rfd->data[j * stride_bytes + i] = pixel; + rfd->data[j * dst_stride_bytes + i] = pixel; } else { diff --git a/xorg/X11R7.6/rdp/rdpmain.c b/xorg/X11R7.6/rdp/rdpmain.c index b92ba044..5a42c5b8 100644 --- a/xorg/X11R7.6/rdp/rdpmain.c +++ b/xorg/X11R7.6/rdp/rdpmain.c @@ -48,7 +48,7 @@ int g_can_do_pix_to_pix = 0; int g_do_dirty_os = 1; /* delay remoting off screen bitmaps */ int g_do_dirty_ons = 0; /* delay remoting screen */ -int g_do_glyph_cache = 1; +int g_do_glyph_cache = 0; int g_do_alpha_glyphs = 1; Bool g_wrapWindow = 1; Bool g_wrapPixmap = 1; diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index 1d4962b2..193ce9a8 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -54,6 +54,7 @@ extern ScreenPtr g_pScreen; /* from rdpmain.c */ extern int g_Bpp; /* from rdpmain.c */ extern int g_Bpp_mask; /* from rdpmain.c */ extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */ +extern int g_do_glyph_cache; /* from rdpmain.c */ extern int g_can_do_pix_to_pix; /* from rdpmain.c */ extern int g_use_rail; /* from rdpmain.c */ @@ -157,6 +158,7 @@ rdpup_disconnect(void) g_free(g_os_bitmaps); g_os_bitmaps = 0; g_use_rail = 0; + g_do_glyph_cache = 0; return 0; } @@ -765,6 +767,11 @@ rdpup_process_msg(struct stream *s) rdpup_send_rail(); #endif } + if (g_rdpScreen.client_info.orders[0x1b]) /* 27 NEG_GLYPH_INDEX_INDEX */ + { + LLOGLN(0, (" using glyph cache")); + g_do_glyph_cache = 1; + } if (g_rdpScreen.client_info.offscreen_cache_entries == 2000) { LLOGLN(0, (" client can do offscreen to offscreen blits")); From 9162ffeaee5ca06621e0dc166b7947a537464c14 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sat, 6 Jul 2013 07:57:21 -0700 Subject: [PATCH 16/31] Hand-apply patch (added special meta keys) from Authentic8: c22b7d7 --- xorg/X11R7.6/rdp/rdpinput.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xorg/X11R7.6/rdp/rdpinput.c b/xorg/X11R7.6/rdp/rdpinput.c index 5cef9458..3fd4bcf4 100644 --- a/xorg/X11R7.6/rdp/rdpinput.c +++ b/xorg/X11R7.6/rdp/rdpinput.c @@ -1118,6 +1118,14 @@ KbdAddEvent(int down, int param1, int param2, int param3, int param4) rdpEnqueueKey(type, 117); break; + case 89: /* left meta */ + rdpEnqueueKey(type, 156); + break; + + case 90: /* right meta */ + rdpEnqueueKey(type, 156); + break; + default: x_scancode = rdp_scancode + MIN_KEY_CODE; From 20f740bd68049a16bae98548de6ae25567d4abdc Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sat, 6 Jul 2013 08:10:33 -0700 Subject: [PATCH 17/31] Hand-apply patches (glyph cache) from Authentic8: d9641da --- xorg/X11R7.6/rdp/rdpdraw.c | 179 +++++++++++++++++++++++++++++++++---- xorg/X11R7.6/rdp/rdpup.c | 5 +- 2 files changed, 164 insertions(+), 20 deletions(-) diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index 183b1346..411f10cb 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -512,6 +512,7 @@ region_get_pixel_count(RegionPtr reg) } /******************************************************************************/ +/* returns boolean */ int region_in_region(RegionPtr reg_small, int sreg_pcount, RegionPtr reg_big) { @@ -525,6 +526,11 @@ region_in_region(RegionPtr reg_small, int sreg_pcount, RegionPtr reg_big) { sreg_pcount = region_get_pixel_count(reg_small); } + if (sreg_pcount == 0) + { + /* empty region not even in */ + return 0; + } if (region_get_pixel_count(®) == sreg_pcount) { rv = 1; @@ -533,6 +539,95 @@ region_in_region(RegionPtr reg_small, int sreg_pcount, RegionPtr reg_big) return rv; } +/******************************************************************************/ +static int +remove_empties(rdpPixmapRec* priv) +{ + struct rdp_draw_item* di; + struct rdp_draw_item* di_prev; + int rv; + + rv = 0; + /* remove draw items with empty regions */ + di = priv->draw_item_head; + di_prev = 0; + while (di != 0) + { + if (!RegionNotEmpty(di->reg)) + { + LLOGLN(0, ("remove_empties: removing empty item type %d", di->type)); + draw_item_remove(priv, di); + di = di_prev == 0 ? priv->draw_item_head : di_prev->next; + rv++; + } + else + { + di_prev = di; + di = di->next; + } + } + return rv; +} + +/******************************************************************************/ +static int +dump_draw_list(rdpPixmapRec* priv) +{ + struct rdp_draw_item* di; + int index; + int count; + BoxRec box; + + LLOGLN(0, ("dump_draw_list:")); + di = priv->draw_item_head; + while (di != 0) + { + LLOGLN(0, (" type %d", di->type)); + count = REGION_NUM_RECTS(di->reg); + if (count == 0) + { + LLOGLN(0, (" empty region")); + } + else + { + box = RegionExtents(di->reg)[0]; + LLOGLN(0, (" region list follows extents x1 %d y1 %d x2 %d y2 %d", + box.x1, box.y1, box.x2, box.y2)); + for (index = 0; index < count; index++) + { + box = REGION_RECTS(di->reg)[index]; + LLOGLN(0, (" index %d x1 %d y1 %d x2 %d y2 %d", + index, box.x1, box.y1, box.x2, box.y2)); + } + } + di = di->next; + } + return 0; +} + +/******************************************************************************/ +/* returns boolean */ +static int +region_interect_at_all(RegionPtr reg_small, RegionPtr reg_big) +{ + int rv; + RegionRec reg; + + if (!RegionNotEmpty(reg_small)) + { + return 0; + } + rv = 0; + RegionInit(®, NullBox, 0); + RegionIntersect(®, reg_big, reg_big); + if (RegionNotEmpty(®)) + { + rv = 1; + } + RegionUninit(®); + return rv; +} + /******************************************************************************/ int draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) @@ -557,6 +652,7 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) di = di->next; } RegionUninit(&treg); + remove_empties(priv); #endif #if 1 @@ -593,10 +689,37 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) } } } - + remove_empties(priv); #endif + #if 0 + if (priv->draw_item_tail != 0) + { + if (priv->draw_item_tail->prev != 0) + { + di = priv->draw_item_tail; + while (di->prev != 0) + { + di_prev = di->prev; + while (di_prev != 0) + { + if ((di->type == RDI_TEXT) && (di_prev->type == RDI_IMGLY)) + { + if (region_interect_at_all(di->reg, di_prev->reg)) + { + di_prev->type = RDI_IMGLL; + } + } + di_prev = di_prev->prev; + } + di = di->prev; + } + } + } + remove_empties(priv); +#endif +#if 0 /* subtract regions */ if (priv->draw_item_tail != 0) { @@ -630,30 +753,48 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) } } } - + remove_empties(priv); #endif + #if 1 - - /* remove draw items with empty regions */ - di = priv->draw_item_head; - di_prev = 0; - - while (di != 0) + if (priv->draw_item_tail != 0) { - if (!RegionNotEmpty(di->reg)) - { - LLOGLN(10, ("draw_item_pack: removing empty item type %d", di->type)); - draw_item_remove(priv, di); - di = di_prev == 0 ? priv->draw_item_head : di_prev->next; - } - else + if (priv->draw_item_tail->prev != 0) { - di_prev = di; - di = di->next; + di = priv->draw_item_tail; + while (di->prev != 0) + { + di_prev = di->prev; + while (di_prev != 0) + { + if ((di_prev->flags & 1) == 0) + { + if ((di_prev->type == RDI_IMGLY) || (di_prev->type == RDI_IMGLL)) + { + if ((di->type == RDI_TEXT) && + region_interect_at_all(di->reg, di_prev->reg)) + { + RegionSubtract(di->reg, di->reg, di_prev->reg); + di_prev->type = RDI_IMGLL; + } + } + else + { + if (region_in_region(di->reg, -1, di_prev->reg)) + { + break; + } + } + } + di_prev = di_prev->prev; + } + di = di->prev; + } } } - + remove_empties(priv); #endif + return 0; } @@ -1586,7 +1727,7 @@ rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, { PictureScreenPtr ps; - LLOGLN(10, ("rdpGlyphs: op %d xSrc %d ySrc %d", op, xSrc, ySrc)); + LLOGLN(10, ("rdpGlyphs: op %d xSrc %d ySrc %d maskFormat %p", op, xSrc, ySrc, maskFormat)); if (g_do_glyph_cache) { diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index 193ce9a8..819c84a7 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -769,9 +769,12 @@ rdpup_process_msg(struct stream *s) } if (g_rdpScreen.client_info.orders[0x1b]) /* 27 NEG_GLYPH_INDEX_INDEX */ { - LLOGLN(0, (" using glyph cache")); g_do_glyph_cache = 1; } + if (g_do_glyph_cache) + { + LLOGLN(0, (" using glyph cache")); + } if (g_rdpScreen.client_info.offscreen_cache_entries == 2000) { LLOGLN(0, (" client can do offscreen to offscreen blits")); From d510a126b04386f2719e2be1bf7d12e081b470da Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sat, 6 Jul 2013 08:16:37 -0700 Subject: [PATCH 18/31] Hand-apply patch (reduce logging in xorg/X11R7.6/rdp/rdpdraw.c) from Authentic8: 44a1390 --- xorg/X11R7.6/rdp/rdpdraw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index 411f10cb..24f84470 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -555,7 +555,7 @@ remove_empties(rdpPixmapRec* priv) { if (!RegionNotEmpty(di->reg)) { - LLOGLN(0, ("remove_empties: removing empty item type %d", di->type)); + LLOGLN(10, ("remove_empties: removing empty item type %d", di->type)); draw_item_remove(priv, di); di = di_prev == 0 ? priv->draw_item_head : di_prev->next; rv++; From 30f10284d75d79300fc0ef64aa46c58c89387a22 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sat, 6 Jul 2013 08:17:20 -0700 Subject: [PATCH 19/31] Hand-apply patch (chansrv: handle ReparentNotify) from Authentic8: 68cdc07 --- sesman/chansrv/rail.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index c2137fb7..a0964914 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -1663,7 +1663,8 @@ rail_xevent(void *xevent) break; case CreateNotify: - LOG(10, (" got CreateNotify 0x%8.8x", lxevent->xcreatewindow.window)); + LOG(10, (" got CreateNotify window 0x%8.8x parent 0x%8.8x", + lxevent->xcreatewindow.window, lxevent->xcreatewindow.parent)); break; case DestroyNotify: @@ -1678,14 +1679,15 @@ rail_xevent(void *xevent) break; case MapRequest: - LOG(10, (" got MapRequest 0x%8.8x", lxevent->xmaprequest.window)); + LOG(10, (" got MapRequest window 0x%8.8x", lxevent->xmaprequest.window)); XSelectInput(g_display, lxevent->xmaprequest.window, PropertyChangeMask | StructureNotifyMask); XMapWindow(g_display, lxevent->xmaprequest.window); break; case MapNotify: - LOG(10, (" got MapNotify 0x%8.8x", lxevent->xmap.event)); + LOG(10, (" got MapNotify window 0x%8.8x event 0x%8.8x", + lxevent->xmap.window, lxevent->xmap.event)); if (lxevent->xmap.window != lxevent->xmap.event) { XGetWindowAttributes(g_display, lxevent->xmap.window, &wnd_attributes); @@ -1769,6 +1771,24 @@ rail_xevent(void *xevent) LOG(10, (" got LeaveNotify")); break; + case ReparentNotify: + LOG(10, (" got ReparentNotify window 0x%8.8x parent 0x%8.8x " + "event 0x%8.8x x %d y %d overrider redirect %d", + lxevent->xreparent.window, lxevent->xreparent.parent, + lxevent->xreparent.event, lxevent->xreparent.x, + lxevent->xreparent.y, lxevent->xreparent.override_redirect)); + + if (lxevent->xreparent.parent != g_root_window) + { + index = list_index_of(g_window_list, lxevent->xreparent.window); + if (index >= 0) + { + rail_destroy_window(lxevent->xreparent.window); + list_remove_item(g_window_list, index); + } + } + rv = 0; + break; } return rv; From adb8a359f3b0241d4792c44fdbd2f1ba1401d45c Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sat, 6 Jul 2013 08:19:39 -0700 Subject: [PATCH 20/31] Hand-apply patch (Update cursor location whenever receiving mouse down events) from Authentic8: 19f1718 --- xorg/X11R7.6/rdp/rdpup.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index 819c84a7..50f73492 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -680,6 +680,8 @@ rdpup_process_msg(struct stream *s) PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; case 102: + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); g_button_mask = g_button_mask | 1; PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; @@ -688,6 +690,8 @@ rdpup_process_msg(struct stream *s) PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; case 104: + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); g_button_mask = g_button_mask | 4; PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; @@ -696,6 +700,8 @@ rdpup_process_msg(struct stream *s) PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; case 106: + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); g_button_mask = g_button_mask | 2; PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; @@ -704,6 +710,8 @@ rdpup_process_msg(struct stream *s) PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; case 108: + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); g_button_mask = g_button_mask | 8; PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; @@ -712,6 +720,8 @@ rdpup_process_msg(struct stream *s) PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; case 110: + g_cursor_x = l_bound_by(param1, 0, g_rdpScreen.width - 2); + g_cursor_y = l_bound_by(param2, 0, g_rdpScreen.height - 2); g_button_mask = g_button_mask | 16; PtrAddEvent(g_button_mask, g_cursor_x, g_cursor_y); break; From 2f395bdfa04af365496d3213882742427227f91d Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sat, 6 Jul 2013 08:42:05 -0700 Subject: [PATCH 21/31] Hand-apply patches (chansrv/rail) from Authentic8: 516fd1d 6a4fb28 c038a99 --- sesman/chansrv/chansrv.c | 139 +++++++++++++++++++++++++++++++++ sesman/chansrv/chansrv.h | 2 + sesman/chansrv/rail.c | 162 +++++++++++++++++---------------------- 3 files changed, 212 insertions(+), 91 deletions(-) diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index fd6bd787..ef647a63 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -75,6 +75,143 @@ int g_exec_pid = 0; /* this variable gets bumped up once per DVC we create */ tui32 g_dvc_chan_id = 100; +struct timeout_obj +{ + tui32 mstime; + void* data; + void (*callback)(void* data); + struct timeout_obj* next; +}; + +static struct timeout_obj* g_timeout_head = 0; +static struct timeout_obj* g_timeout_tail = 0; + +/*****************************************************************************/ +int APP_CC +add_timeout(int msoffset, void (*callback)(void* data), void* data) +{ + struct timeout_obj* tobj; + tui32 now; + + LOG(10, ("add_timeout:")); + now = g_time3(); + tobj = g_malloc(sizeof(struct timeout_obj), 1); + tobj->mstime = now + msoffset; + tobj->callback = callback; + tobj->data = data; + if (g_timeout_tail == 0) + { + g_timeout_head = tobj; + g_timeout_tail = tobj; + } + else + { + g_timeout_tail->next = tobj; + g_timeout_tail = tobj; + } + return 0; +} + +/*****************************************************************************/ +static int APP_CC +get_timeout(int* timeout) +{ + struct timeout_obj* tobj; + tui32 now; + int ltimeout; + + LOG(10, ("get_timeout:")); + ltimeout = *timeout; + if (ltimeout < 1) + { + ltimeout = 0; + } + tobj = g_timeout_head; + if (tobj != 0) + { + now = g_time3(); + while (tobj != 0) + { + LOG(10, (" now %u tobj->mstime %u", now, tobj->mstime)); + if (now < tobj->mstime) + { + ltimeout = tobj->mstime - now; + } + tobj = tobj->next; + } + } + if (ltimeout > 0) + { + LOG(10, (" ltimeout %d", ltimeout)); + if (*timeout < 1) + { + *timeout = ltimeout; + } + else + { + if (*timeout > ltimeout) + { + *timeout = ltimeout; + } + } + } + return 0; +} + +/*****************************************************************************/ +static int APP_CC +check_timeout(void) +{ + struct timeout_obj* tobj; + struct timeout_obj* last_tobj; + struct timeout_obj* temp_tobj; + int count; + tui32 now; + + LOG(10, ("check_timeout:")); + count = 0; + tobj = g_timeout_head; + if (tobj != 0) + { + last_tobj = 0; + while (tobj != 0) + { + count++; + now = g_time3(); + if (now >= tobj->mstime) + { + tobj->callback(tobj->data); + if (last_tobj == 0) + { + g_timeout_head = tobj->next; + if (g_timeout_head == 0) + { + g_timeout_tail = 0; + } + } + else + { + last_tobj->next = tobj->next; + if (g_timeout_tail == tobj) + { + g_timeout_tail = last_tobj; + } + } + temp_tobj = tobj; + tobj = tobj->next; + g_free(temp_tobj); + } + else + { + last_tobj = tobj; + tobj = tobj->next; + } + } + } + LOG(10, (" count %d", count)); + return 0; +} + /*****************************************************************************/ /* add data to chan_item, on its way to the client */ /* returns error */ @@ -939,6 +1076,7 @@ channel_thread_loop(void *in_val) while (g_obj_wait(objs, num_objs, 0, 0, timeout) == 0) { + check_timeout(); if (g_is_wait_obj_set(g_term_event)) { LOGM((LOG_LEVEL_INFO, "channel_thread_loop: g_term_event set")); @@ -1021,6 +1159,7 @@ channel_thread_loop(void *in_val) sound_get_wait_objs(objs, &num_objs, &timeout); dev_redir_get_wait_objs(objs, &num_objs, &timeout); xfuse_get_wait_objs(objs, &num_objs, &timeout); + get_timeout(&timeout); } /* end while (g_obj_wait(objs, num_objs, 0, 0, timeout) == 0) */ } diff --git a/sesman/chansrv/chansrv.h b/sesman/chansrv/chansrv.h index 61b62e4e..2d18a711 100644 --- a/sesman/chansrv/chansrv.h +++ b/sesman/chansrv/chansrv.h @@ -57,6 +57,8 @@ struct xrdp_api_data int APP_CC send_channel_data(int chan_id, char *data, int size); int APP_CC send_rail_drawing_orders(char* data, int size); int APP_CC main_cleanup(void); +int APP_CC +add_timeout(int msoffset, void (*callback)(void* data), void* data); int APP_CC find_empty_slot_in_dvc_channels(); struct xrdp_api_data *APP_CC struct_from_dvc_chan_id(tui32 dvc_chan_id); int remove_struct_with_chan_id(tui32 dvc_chan_id); diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index a0964914..59b19411 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -61,6 +61,10 @@ static int g_rail_running = 1; /* list of valid rail windows */ static struct list* g_window_list = 0; +static int g_got_focus = 0; +static int g_focus_counter = 0; +static Window g_focus_win = 0; + /* used in valid field of struct rail_window_data */ #define RWD_X (1 << 0) #define RWD_Y (1 << 1) @@ -150,6 +154,24 @@ static int APP_CC rail_win_set_state(Window win, unsigned long state); static int APP_CC rail_show_window(Window window_id, int show_state); static int APP_CC rail_win_send_text(Window win); +/*****************************************************************************/ +static int APP_CC +rail_send_key_esc(int window_id) +{ + XEvent event; + + g_memset(&event, 0, sizeof(event)); + event.type = KeyPress; + event.xkey.same_screen = True; + event.xkey.root = g_root_window; + event.xkey.window = window_id; + event.xkey.keycode = 9; + XSendEvent(g_display, window_id, True, 0xfff, &event); + event.type = KeyRelease; + XSendEvent(g_display, window_id, True, 0xfff, &event); + return 0; +} + /*****************************************************************************/ static struct rail_window_data* APP_CC rail_get_window_data(Window window) @@ -414,87 +436,35 @@ rail_process_exec(struct stream *s, int size) return 0; } -/*****************************************************************************/ -static void APP_CC -rail_simulate_mouse_click(int button) -{ - /* - * The below code can be referenced from: - * http://www.linuxquestions.org/questions/programming-9/simulating-a-mouse-click-594576/#post2936738 - */ - XEvent event; - g_memset(&event, 0x00, sizeof(event)); - - event.type = ButtonPress; - event.xbutton.button = button; - event.xbutton.same_screen = True; - - XQueryPointer(g_display, g_root_window, &event.xbutton.root, - &event.xbutton.window, &event.xbutton.x_root, - &event.xbutton.y_root, &event.xbutton.x, - &event.xbutton.y, &event.xbutton.state); - - event.xbutton.subwindow = event.xbutton.window; - - while(event.xbutton.subwindow) - { - event.xbutton.window = event.xbutton.subwindow; - - XQueryPointer(g_display, event.xbutton.window, &event.xbutton.root, - &event.xbutton.subwindow, &event.xbutton.x_root, - &event.xbutton.y_root, &event.xbutton.x, - &event.xbutton.y, &event.xbutton.state); - } - - if(XSendEvent(g_display, PointerWindow, True, 0xfff, &event) == 0) - { - LOG(0, (" error sending mouse event")); - } - - XFlush(g_display); - - g_sleep(100); - - event.type = ButtonRelease; - event.xbutton.state = 0x100; - - if(XSendEvent(g_display, PointerWindow, True, 0xfff, &event) == 0) - { - LOG(0, (" error sending mouse event")); - } - - XFlush(g_display); -} - /******************************************************************************/ static int APP_CC -rail_win_popdown(int window_id) +rail_win_popdown(void) { int rv = 0; - unsigned int i; + int i; unsigned int nchild; Window r; Window p; Window* children; + XWindowAttributes window_attributes; /* * Check the tree of current existing X windows and dismiss - * the managed rail popups by simulating a mouse click, so + * the managed rail popups by simulating a esc key, so * that the requested window can be closed properly. */ XQueryTree(g_display, g_root_window, &r, &p, &children, &nchild); - for (i = 0; i < nchild; i++) + for (i = nchild - 1; i >= 0; i--) { - XWindowAttributes window_attributes; XGetWindowAttributes(g_display, children[i], &window_attributes); if (window_attributes.override_redirect && window_attributes.map_state == IsViewable && - list_index_of(g_window_list, children[i]) >= 0) { - LOG(0, (" dismiss pop up 0x%8.8x", children[i])); - rail_simulate_mouse_click(Button1); + list_index_of(g_window_list, children[i]) >= 0) + { + LOG(10, (" dismiss pop up 0x%8.8x", children[i])); + rail_send_key_esc(children[i]); rv = 1; - break; } } @@ -510,13 +480,7 @@ rail_close_window(int window_id) LOG(0, ("chansrv::rail_close_window:")); - if (rail_win_popdown(window_id)) - { - return 0; - } - - /* don't receive UnmapNotify for closing window */ - XSelectInput(g_display, window_id, PropertyChangeMask); + rail_win_popdown(); g_memset(&ce, 0, sizeof(ce)); ce.xclient.type = ClientMessage; @@ -531,6 +495,18 @@ rail_close_window(int window_id) return 0; } +/*****************************************************************************/ +void DEFAULT_CC +my_timoeut(void* data) +{ + LOG(10, ("my_timoeut: g_got_focus %d", g_got_focus)); + if (g_focus_counter == (int)(long)data) + { + LOG(10, ("my_timoeut: g_focus_counter %d", g_focus_counter)); + rail_win_popdown(); + } +} + /*****************************************************************************/ static int APP_CC rail_process_activate(struct stream *s, int size) @@ -543,22 +519,37 @@ rail_process_activate(struct stream *s, int size) LOG(10, ("chansrv::rail_process_activate:")); in_uint32_le(s, window_id); in_uint8(s, enabled); + g_focus_counter++; + g_got_focus = enabled; LOG(10, (" window_id 0x%8.8x enabled %d", window_id, enabled)); XGetWindowAttributes(g_display, window_id, &window_attributes); if (enabled) { - if (window_attributes.map_state != IsViewable) + if (g_focus_win == window_id) { /* In case that window is unmapped upon minimization and not yet mapped*/ XMapWindow(g_display, window_id); } - XGetTransientForHint(g_display, window_id, &transient_for); - if (transient_for > 0) + else { - // Owner window should be raised up as well - XRaiseWindow(g_display, transient_for); + rail_win_popdown(); + if (window_attributes.map_state != IsViewable) + { + /* In case that window is unmapped upon minimization and not yet mapped */ + XMapWindow(g_display, window_id); + } + XGetTransientForHint(g_display, window_id, &transient_for); + if (transient_for > 0) + { + /* Owner window should be raised up as well */ + XRaiseWindow(g_display, transient_for); + } + LOG(10, ("chansrv::rail_process_activate: calling XRaiseWindow 0x%8.8x", window_id)); + XRaiseWindow(g_display, window_id); + LOG(10, ("chansrv::rail_process_activate: calling XSetInputFocus 0x%8.8x", window_id)); + XSetInputFocus(g_display, window_id, RevertToParent, CurrentTime); } LOG(10, ("chansrv::rail_process_activate: calling XRaiseWindow 0x%8.8x", window_id)); XRaiseWindow(g_display, window_id); @@ -570,10 +561,7 @@ rail_process_activate(struct stream *s, int size) LOG(10, (" window attributes: override_redirect %d", window_attributes.override_redirect)); - if (window_attributes.override_redirect) { - LOG(10, (" dismiss popup window 0x%8.8x", window_id)); - XUnmapWindow(g_display, window_id); - } + add_timeout(200, my_timoeut, (void*)(long)g_focus_counter); } return 0; } @@ -1094,7 +1082,7 @@ rail_win_send_text(Window win) { if (g_strncmp(rwd->title, data, 63) == 0) { - LOG(0, ("chansrv::rail_win_send_text: skipping, title not changed")); + LOG(10, ("chansrv::rail_win_send_text: skipping, title not changed")); XFree(data); XFree(rwd); return 0; @@ -1665,6 +1653,10 @@ rail_xevent(void *xevent) case CreateNotify: LOG(10, (" got CreateNotify window 0x%8.8x parent 0x%8.8x", lxevent->xcreatewindow.window, lxevent->xcreatewindow.parent)); + XSelectInput(g_display, lxevent->xcreatewindow.window, + PropertyChangeMask | StructureNotifyMask | + FocusChangeMask | + EnterWindowMask | LeaveWindowMask); break; case DestroyNotify: @@ -1680,8 +1672,6 @@ rail_xevent(void *xevent) case MapRequest: LOG(10, (" got MapRequest window 0x%8.8x", lxevent->xmaprequest.window)); - XSelectInput(g_display, lxevent->xmaprequest.window, - PropertyChangeMask | StructureNotifyMask); XMapWindow(g_display, lxevent->xmaprequest.window); break; @@ -1709,23 +1699,12 @@ rail_xevent(void *xevent) if (lxevent->xunmap.window != lxevent->xunmap.event && is_window_valid_child_of_root(lxevent->xunmap.window)) { - int state = rail_win_get_state(lxevent->xunmap.window); index = list_index_of(g_window_list, lxevent->xunmap.window); LOG(10, (" window 0x%8.8x is unmapped", lxevent->xunmap.window)); if (index >= 0) { -#if 0 - XGetWindowAttributes(g_display, lxevent->xunmap.window, &wnd_attributes); - if (wnd_attributes.override_redirect) - { - LOG(10, (" hide popup")); - rail_show_window(lxevent->xunmap.window, 0x0); - rv = 0; - } -#else rail_show_window(lxevent->xunmap.window, 0x0); rv = 0; -#endif } } break; @@ -1757,6 +1736,7 @@ rail_xevent(void *xevent) case FocusIn: LOG(10, (" got FocusIn")); + g_focus_win = lxevent->xfocus.window; break; case ButtonPress: From a5348298fd048b55c710d142cbb5fc51a50e0195 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sat, 6 Jul 2013 08:50:12 -0700 Subject: [PATCH 22/31] Hand-apply patches (X11rdp text) from Authentic8: d25c23d f977cd9 --- xorg/X11R7.6/rdp/rdpdraw.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index 24f84470..ca8c785a 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -780,7 +780,8 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) } else { - if (region_in_region(di->reg, -1, di_prev->reg)) + if ((di->type == RDI_TEXT) && + region_interect_at_all(di->reg, di_prev->reg)) { break; } @@ -1718,6 +1719,32 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, } } +/******************************************************************************/ +/* make sure no glyph is too big */ +/* returns boolean */ +static int +rdpGlyphCheck(int nlist, GlyphListPtr list, GlyphPtr* glyphs) +{ + int n; + GlyphPtr glyph; + + while (nlist--) + { + n = list->len; + list++; + while (n--) + { + glyph = *glyphs++; + if ((glyph->info.width * glyph->info.height) > 8192) + { + LLOGLN(10, ("rdpGlyphCheck: too big")); + return 0; + } + } + } + return 1; +} + /******************************************************************************/ void rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, @@ -1729,7 +1756,7 @@ rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, LLOGLN(10, ("rdpGlyphs: op %d xSrc %d ySrc %d maskFormat %p", op, xSrc, ySrc, maskFormat)); - if (g_do_glyph_cache) + if (g_do_glyph_cache && rdpGlyphCheck(nlists, lists, glyphs)) { g_doing_font = 2; ps = GetPictureScreen(g_pScreen); From 4b2ce5351834a6b2b5da16bd21dc630a7e6ae5f8 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sat, 6 Jul 2013 08:52:25 -0700 Subject: [PATCH 23/31] Hand-apply patch (rail: send ShowState when window order changes) from Authentic8: c36a2d7 --- sesman/chansrv/rail.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index 59b19411..a22336e2 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -1333,6 +1333,18 @@ rail_configure_request_window(XConfigureRequestEvent* config) window_id = config->window; mask = config->value_mask; LOG(10, ("chansrv::rail_configure_request_window: mask %d", mask)); + if (mask & CWStackMode) + { + LOG(10, ("chansrv::rail_configure_request_window: CWStackMode " + "detail 0x%8.8x above 0x%8.8x", config->detail, config->above)); + if (config->detail == Above) + { + LOG(10, ("chansrv::rail_configure_request_window: bring to front " + "window_id 0x%8.8x", window_id)); + /* 0x05 - Show the window in its current size and position. */ + rail_show_window(window_id, 5); + } + } rwd = rail_get_window_data(window_id); if (rwd == 0) { From 363d35fa21ee164dffd0edc31586bf5d2e59e8ea Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sat, 6 Jul 2013 12:53:54 -0700 Subject: [PATCH 24/31] Fix typo introduced in cb1efca6 --- xorg/X11R7.6/rdp/rdp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h index 8f16316d..2af36435 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -219,7 +219,7 @@ typedef rdpWindowRec* rdpWindowPtr; #define RDI_IMGLY 3 /* lossy */ #define RDI_LINE 4 #define RDI_SCRBLT 5 -define RDI_TEXT 6 +#define RDI_TEXT 6 struct urdp_draw_item_fill { From 0054b70446ae5024e1c8cd5fd7bbe21c8591c592 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sat, 6 Jul 2013 13:42:55 -0700 Subject: [PATCH 25/31] fix typo introduced in cb1efca6 --- xorg/X11R7.6/rdp/rdp.h | 1 + 1 file changed, 1 insertion(+) diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h index 2af36435..6750c523 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -269,6 +269,7 @@ union urdp_draw_item struct urdp_draw_item_img img; struct urdp_draw_item_line line; struct urdp_draw_item_scrblt scrblt; + struct urdp_draw_item_text text; }; struct rdp_draw_item From a27cbddaa57ea6504b023ada1f77cda372c32275 Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sat, 6 Jul 2013 21:03:58 -0700 Subject: [PATCH 26/31] Hand-apply patch (compositing) from Authentic8: 5d5e470 81c9c29 b0c2c10 27d8a01 a96a217 e512090 a9a6762 9c02bfa bd26fcc c0d29d9 676dd35 3b26737 --- common/xrdp_constants.h | 1 + libxrdp/libxrdp.c | 19 ++ libxrdp/libxrdp.h | 31 +++ libxrdp/libxrdpinc.h | 10 + libxrdp/xrdp_orders.c | 326 ++++++++++++++++++++++++++++++ xorg/X11R7.6/rdp/Makefile | 2 +- xorg/X11R7.6/rdp/rdp.h | 34 +++- xorg/X11R7.6/rdp/rdpdraw.c | 391 ++++++++++-------------------------- xorg/X11R7.6/rdp/rdpglyph.c | 1 + xorg/X11R7.6/rdp/rdpmain.c | 4 +- xorg/X11R7.6/rdp/rdpup.c | 255 ++++++++++++++++++++++- xrdp/xrdp.h | 27 +++ xrdp/xrdp_cache.c | 2 +- xrdp/xrdp_mm.c | 102 +++++++++- xrdp/xrdp_painter.c | 82 +++++++- xrdp/xrdp_types.h | 20 +- xup/xup.c | 67 ++++++ xup/xup.h | 15 +- 18 files changed, 1087 insertions(+), 302 deletions(-) diff --git a/common/xrdp_constants.h b/common/xrdp_constants.h index 53c54852..8a81d18f 100644 --- a/common/xrdp_constants.h +++ b/common/xrdp_constants.h @@ -416,6 +416,7 @@ #define RDP_ORDER_TRIBLT 14 #define RDP_ORDER_POLYLINE 22 #define RDP_ORDER_TEXT2 27 +#define RDP_ORDER_COMPOSITE 37 /* 0x25 */ #define RDP_ORDER_RAW_BMPCACHE 0 #define RDP_ORDER_COLCACHE 1 diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c index 23cf5b09..bd247c61 100644 --- a/libxrdp/libxrdp.c +++ b/libxrdp/libxrdp.c @@ -627,6 +627,25 @@ libxrdp_orders_mem_blt(struct xrdp_session *session, int cache_id, srcx, srcy, cache_idx, rect); } +/******************************************************************************/ +int DEFAULT_CC +libxrdp_orders_composite_blt(struct xrdp_session* session, int srcidx, + int srcformat, int srcwidth, int srcrepeat, + int* srctransform, int mskflags, + int mskidx, int mskformat, int mskwidth, + int mskrepeat, int op, int srcx, int srcy, + int mskx, int msky, int dstx, int dsty, + int width, int height, int dstformat, + struct xrdp_rect* rect) +{ + return xrdp_orders_composite_blt((struct xrdp_orders*)session->orders, + srcidx, srcformat, srcwidth, srcrepeat, + srctransform, mskflags, + mskidx, mskformat, mskwidth, mskrepeat, + op, srcx, srcy, mskx, msky, dstx, dsty, + width, height, dstformat, rect); +} + /******************************************************************************/ int EXPORT_CC libxrdp_orders_text(struct xrdp_session *session, diff --git a/libxrdp/libxrdp.h b/libxrdp/libxrdp.h index 83d3285c..33bcdc09 100644 --- a/libxrdp/libxrdp.h +++ b/libxrdp/libxrdp.h @@ -197,6 +197,28 @@ struct xrdp_orders_state int text_y; int text_len; char* text_data; + + int com_blt_srcidx; /* RDP_ORDER_COMPOSITE */ /* 2 */ + int com_blt_srcformat; /* 2 */ + int com_blt_srcwidth; /* 2 */ + int com_blt_srcrepeat; /* 1 */ + int com_blt_srctransform[10]; /* 40 */ + int com_blt_mskflags; /* 1 */ + int com_blt_mskidx; /* 2 */ + int com_blt_mskformat; /* 2 */ + int com_blt_mskwidth; /* 2 */ + int com_blt_mskrepeat; /* 1 */ + int com_blt_op; /* 1 */ + int com_blt_srcx; /* 2 */ + int com_blt_srcy; /* 2 */ + int com_blt_mskx; /* 2 */ + int com_blt_msky; /* 2 */ + int com_blt_dstx; /* 2 */ + int com_blt_dsty; /* 2 */ + int com_blt_width; /* 2 */ + int com_blt_height; /* 2 */ + int com_blt_dstformat; /* 2 */ + }; /* orders */ @@ -379,6 +401,15 @@ xrdp_orders_mem_blt(struct xrdp_orders* self, int cache_id, int rop, int srcx, int srcy, int cache_idx, struct xrdp_rect* rect); int APP_CC +xrdp_orders_composite_blt(struct xrdp_orders* self, int srcidx, + int srcformat, int srcwidth, + int srcrepeat, int* srctransform, int mskflags, + int mskidx, int mskformat, int mskwidth, + int mskrepeat, int op, int srcx, int srcy, + int mskx, int msky, int dstx, int dsty, + int width, int height, int dstformat, + struct xrdp_rect* rect); +int APP_CC xrdp_orders_text(struct xrdp_orders* self, int font, int flags, int mixmode, int fg_color, int bg_color, diff --git a/libxrdp/libxrdpinc.h b/libxrdp/libxrdpinc.h index 2e5caee9..e5f52a05 100644 --- a/libxrdp/libxrdpinc.h +++ b/libxrdp/libxrdpinc.h @@ -130,6 +130,16 @@ libxrdp_orders_mem_blt(struct xrdp_session* session, int cache_id, int rop, int srcx, int srcy, int cache_idx, struct xrdp_rect* rect); int DEFAULT_CC +libxrdp_orders_composite_blt(struct xrdp_session* session, int srcidx, + int srcformat, int srcwidth, int srcrepeat, + int* srctransform, int mskflags, + int mskidx, int mskformat, int mskwidth, + int mskrepeat, int op, int srcx, int srcy, + int mskx, int msky, int dstx, int dsty, + int width, int height, int dstformat, + struct xrdp_rect* rect); + +int DEFAULT_CC libxrdp_orders_text(struct xrdp_session* session, int font, int flags, int mixmode, int fg_color, int bg_color, diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index 0fc4b10d..5678c79b 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -1589,6 +1589,332 @@ xrdp_orders_mem_blt(struct xrdp_orders *self, int cache_id, return 0; } +/*****************************************************************************/ +/* returns error */ +int APP_CC +xrdp_orders_composite_blt(struct xrdp_orders* self, int srcidx, int srcformat, + int srcwidth, int srcrepeat, int* srctransform, + int mskflags, int mskidx, int mskformat, + int mskwidth, int mskrepeat, int op, + int srcx, int srcy, int mskx, int msky, + int dstx, int dsty, int width, int height, + int dstformat, + struct xrdp_rect* rect) +{ + int order_flags; + int vals[20]; + int present; + char* present_ptr; + char* order_flags_ptr; + + xrdp_orders_check(self, 80); + self->order_count++; + order_flags = RDP_ORDER_STANDARD; + if (self->orders_state.last_order != RDP_ORDER_COMPOSITE) + { + order_flags |= RDP_ORDER_CHANGE; + } + self->orders_state.last_order = RDP_ORDER_COMPOSITE; + if (rect != 0) + { + /* if clip is present, still check if its needed */ + if (dstx < rect->left || dsty < rect->top || + dstx + width > rect->right || dsty + height > rect->bottom) + { + order_flags |= RDP_ORDER_BOUNDS; + if (xrdp_orders_last_bounds(self, rect)) + { + + order_flags |= RDP_ORDER_LASTBOUNDS; + + } + } + } + vals[0] = srcx; + vals[1] = self->orders_state.com_blt_srcx; + vals[2] = srcy; + vals[3] = self->orders_state.com_blt_srcy; + vals[4] = mskx; + vals[5] = self->orders_state.com_blt_mskx; + vals[6] = msky; + vals[7] = self->orders_state.com_blt_msky; + vals[8] = dstx; + vals[9] = self->orders_state.com_blt_dstx; + vals[10] = dsty; + vals[11] = self->orders_state.com_blt_dsty; + vals[12] = width; + vals[13] = self->orders_state.com_blt_width; + vals[14] = height; + vals[15] = self->orders_state.com_blt_height; + vals[16] = srcwidth; + vals[17] = self->orders_state.com_blt_srcwidth; + vals[18] = mskwidth; + vals[19] = self->orders_state.com_blt_mskwidth; + if (xrdp_orders_send_delta(self, vals, 20)) + { + order_flags |= RDP_ORDER_DELTA; + } + /* order_flags, set later, 1 byte */ + order_flags_ptr = self->out_s->p; + out_uint8s(self->out_s, 1); + if (order_flags & RDP_ORDER_CHANGE) + { + out_uint8(self->out_s, self->orders_state.last_order); + } + present = 0; + /* present, set later, 3 bytes */ + present_ptr = self->out_s->p; + out_uint8s(self->out_s, 3); + if ((order_flags & RDP_ORDER_BOUNDS) && + !(order_flags & RDP_ORDER_LASTBOUNDS)) + { + xrdp_orders_out_bounds(self, rect); + } + + if (srcidx != self->orders_state.com_blt_srcidx) + { + present |= 0x000001; + out_uint16_le(self->out_s, srcidx); + self->orders_state.com_blt_srcidx = srcidx; + } + + if (srcformat != self->orders_state.com_blt_srcformat) + { + present |= 0x000002; + out_uint32_le(self->out_s, srcformat); + self->orders_state.com_blt_srcformat = srcformat; + } + + if (srcwidth != self->orders_state.com_blt_srcwidth) + { + present |= 0x000004; + if (order_flags & RDP_ORDER_DELTA) + { + out_uint8(self->out_s, srcwidth - self->orders_state.com_blt_srcwidth); + } + else + { + out_uint16_le(self->out_s, srcwidth); + } + self->orders_state.com_blt_srcwidth = srcwidth; + } + + if (srcrepeat != self->orders_state.com_blt_srcrepeat) + { + present |= 0x000008; + out_uint8(self->out_s, srcrepeat); + self->orders_state.com_blt_srcrepeat = srcrepeat; + } + + if (srctransform != 0) + { + if (srctransform[0] != self->orders_state.com_blt_srctransform[0]) + { + present |= 0x000010; + out_uint32_le(self->out_s, srctransform[0]); + self->orders_state.com_blt_srctransform[0] = srctransform[0]; + } + if (g_memcmp(&(srctransform[1]), + &(self->orders_state.com_blt_srctransform[1]), + 36) != 0) + { + present |= 0x000020; + out_uint32_le(self->out_s, srctransform[1]); + out_uint32_le(self->out_s, srctransform[2]); + out_uint32_le(self->out_s, srctransform[3]); + out_uint32_le(self->out_s, srctransform[4]); + out_uint32_le(self->out_s, srctransform[5]); + out_uint32_le(self->out_s, srctransform[6]); + out_uint32_le(self->out_s, srctransform[7]); + out_uint32_le(self->out_s, srctransform[8]); + out_uint32_le(self->out_s, srctransform[9]); + } + } + else + { + if (self->orders_state.com_blt_srctransform[0] != 0) + { + present |= 0x000010; + out_uint32_le(self->out_s, 0); + self->orders_state.com_blt_srctransform[0] = 0; + } + } + + if (mskflags != self->orders_state.com_blt_mskflags) + { + present |= 0x000040; + out_uint8(self->out_s, mskflags); + self->orders_state.com_blt_mskflags = mskflags; + } + + if (mskidx != self->orders_state.com_blt_mskidx) + { + present |= 0x000080; + out_uint16_le(self->out_s, mskidx); + self->orders_state.com_blt_mskidx = mskidx; + } + + if (mskformat != self->orders_state.com_blt_mskformat) + { + present |= 0x000100; + out_uint32_le(self->out_s, mskformat); + self->orders_state.com_blt_mskformat = mskformat; + } + + if (mskwidth != self->orders_state.com_blt_mskwidth) + { + present |= 0x000200; + if (order_flags & RDP_ORDER_DELTA) + { + out_uint8(self->out_s, mskwidth - self->orders_state.com_blt_mskwidth); + } + else + { + out_uint16_le(self->out_s, mskwidth); + } + self->orders_state.com_blt_mskwidth = mskwidth; + } + + if (mskrepeat != self->orders_state.com_blt_mskrepeat) + { + present |= 0x000400; + out_uint8(self->out_s, mskrepeat); + self->orders_state.com_blt_mskrepeat = mskrepeat; + } + + if (op != self->orders_state.com_blt_op) + { + present |= 0x000800; + out_uint8(self->out_s, op); + self->orders_state.com_blt_op = op; + } + + if (srcx != self->orders_state.com_blt_srcx) + { + present |= 0x001000; + if (order_flags & RDP_ORDER_DELTA) + { + out_uint8(self->out_s, srcx - self->orders_state.com_blt_srcx); + } + else + { + out_uint16_le(self->out_s, srcx); + } + self->orders_state.com_blt_srcx = srcx; + } + + if (srcy != self->orders_state.com_blt_srcy) + { + present |= 0x002000; + if (order_flags & RDP_ORDER_DELTA) + { + out_uint8(self->out_s, srcy - self->orders_state.com_blt_srcy); + } + else + { + out_uint16_le(self->out_s, srcy); + } + self->orders_state.com_blt_srcy = srcy; + } + + if (mskx != self->orders_state.com_blt_mskx) + { + present |= 0x004000; + if (order_flags & RDP_ORDER_DELTA) + { + out_uint8(self->out_s, mskx - self->orders_state.com_blt_mskx); + } + else + { + out_uint16_le(self->out_s, mskx); + } + self->orders_state.com_blt_mskx = mskx; + } + + if (msky != self->orders_state.com_blt_msky) + { + present |= 0x008000; + if (order_flags & RDP_ORDER_DELTA) + { + out_uint8(self->out_s, msky - self->orders_state.com_blt_msky); + } + else + { + out_uint16_le(self->out_s, msky); + } + self->orders_state.com_blt_msky = msky; + } + + if (dstx != self->orders_state.com_blt_dstx) + { + present |= 0x010000; + if (order_flags & RDP_ORDER_DELTA) + { + out_uint8(self->out_s, dstx - self->orders_state.com_blt_dstx); + } + else + { + out_uint16_le(self->out_s, dstx); + } + self->orders_state.com_blt_dstx = dstx; + } + + if (dsty != self->orders_state.com_blt_dsty) + { + present |= 0x020000; + if (order_flags & RDP_ORDER_DELTA) + { + out_uint8(self->out_s, dsty - self->orders_state.com_blt_dsty); + } + else + { + out_uint16_le(self->out_s, dsty); + } + self->orders_state.com_blt_dsty = dsty; + } + + if (width != self->orders_state.com_blt_width) + { + present |= 0x040000; + if (order_flags & RDP_ORDER_DELTA) + { + out_uint8(self->out_s, width - self->orders_state.com_blt_width); + } + else + { + out_uint16_le(self->out_s, width); + } + self->orders_state.com_blt_width = width; + } + + if (height != self->orders_state.com_blt_height) + { + present |= 0x080000; + if (order_flags & RDP_ORDER_DELTA) + { + out_uint8(self->out_s, height - self->orders_state.com_blt_height); + } + else + { + out_uint16_le(self->out_s, height); + } + self->orders_state.com_blt_height = height; + } + + if (dstformat != self->orders_state.com_blt_dstformat) + { + present |= 0x100000; + out_uint32_le(self->out_s, dstformat); + self->orders_state.com_blt_dstformat = dstformat; + } + + xrdp_order_pack_small_or_tiny(self, order_flags_ptr, order_flags, + + present_ptr, present, 3); + + return 0; +} + /*****************************************************************************/ /* returns error */ int APP_CC diff --git a/xorg/X11R7.6/rdp/Makefile b/xorg/X11R7.6/rdp/Makefile index 8d07e100..b38d27c0 100644 --- a/xorg/X11R7.6/rdp/Makefile +++ b/xorg/X11R7.6/rdp/Makefile @@ -13,7 +13,7 @@ rdpPolylines.o rdpPolySegment.o rdpFillSpans.o rdpSetSpans.o \ rdpCopyPlane.o rdpPolyPoint.o rdpPolyArc.o rdpFillPolygon.o \ rdpPolyFillArc.o rdpPolyText8.o rdpPolyText16.o \ rdpImageText8.o rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o \ -rdpPushPixels.o rdpxv.o rdpglyph.o \ +rdpPushPixels.o rdpxv.o rdpglyph.o rdpComposite.o \ miinitext.o \ fbcmap_mi.o diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h index 8f16316d..655c536c 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -281,13 +281,19 @@ struct rdp_draw_item union urdp_draw_item u; }; +#define XRDP_USE_COUNT_THRESHOLD 1 + struct _rdpPixmapRec { int status; int rdpindex; int con_number; int is_dirty; - int pad0; + int is_alpha_dirty_not; + /* number of times used in a remote operation + if this gets above XRDP_USE_COUNT_THRESHOLD + then we force remote the pixmap */ + int use_count; int kind_width; struct rdp_draw_item* draw_item_head; struct rdp_draw_item* draw_item_tail; @@ -445,6 +451,14 @@ rdpDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor); void rdpRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed); + +/* rdpglyph.c */ +void +rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, + int nlists, GlyphListPtr lists, GlyphPtr* glyphs); + +/* rdpComposite.c */ int rdpCreatePicture(PicturePtr pPicture); void @@ -542,6 +556,8 @@ rdpup_set_cursor_ex(short x, short y, char *cur_data, char *cur_mask, int bpp); int rdpup_create_os_surface(int rdpindexd, int width, int height); int +rdpup_create_os_surface_bpp(int rdpindexd, int width, int height, int bpp); +int rdpup_switch_os_surface(int rdpindex); int rdpup_delete_os_surface(int rdpindex); @@ -558,6 +574,8 @@ rdpup_delete_window(WindowPtr pWindow, rdpWindowRec* priv); int rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec* pDirtyPriv); int +rdpup_check_alpha_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec* pDirtyPriv); +int rdpup_check_dirty_screen(rdpPixmapRec* pDirtyPriv); int rdpup_add_char(int font, int charactor, short x, short y, int cx, int cy, @@ -572,6 +590,13 @@ rdpup_draw_text(int font, int flags, int mixmode, short box_left, short box_top, short box_right, short box_bottom, short x, short y, char* data, int data_bytes); +int +rdpup_composite(short srcidx, int srcformat, short srcwidth, CARD8 srcrepeat, + PictTransform* srctransform, CARD8 mskflags, + short mskidx, int mskformat, short mskwidth, CARD8 mskrepeat, + CARD8 op, short srcx, short srcy, short mskx, short msky, + short dstx, short dsty, short width, short height, + int dstformat); void rdpScheduleDeferredUpdate(void); @@ -669,6 +694,13 @@ struct stream out_uint8p((s), (v), (n)); \ } +/******************************************************************************/ +#define out_uint8s(s, n) do \ +{ \ + memset((s)->p, 0, (n)); \ + (s)->p += (n); \ +} while (0) + /******************************************************************************/ #if defined(B_ENDIAN) || defined(NEED_ALIGN) #define out_uint32_le(s, v) \ diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index ca8c785a..0fb8ff4f 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -70,8 +70,6 @@ extern int g_do_glyph_cache; /* in rdpmain.c */ ColormapPtr g_rdpInstalledColormap; -static int g_doing_font = 0; - GCFuncs g_rdpGCFuncs = { rdpValidateGC, rdpChangeGC, rdpCopyGC, rdpDestroyGC, rdpChangeClip, @@ -409,6 +407,8 @@ rdpCloseScreen(int i, ScreenPtr pScreen) int draw_item_add(rdpPixmapRec *priv, struct rdp_draw_item *di) { + priv->is_alpha_dirty_not = 0; + if (priv->draw_item_tail == 0) { priv->draw_item_tail = di; @@ -667,6 +667,17 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) while (di != 0) { +#if 0 + if ((di_prev->type == RDI_IMGLL || di_prev->type == RDI_IMGLY) && + (di->type == RDI_IMGLL || di->type == RDI_IMGLY)) + { + LLOGLN(10, ("draw_item_pack: packing RDI_IMGLL and RDI_IMGLY")); + di_prev->type = RDI_IMGLY; + RegionUnion(di_prev->reg, di_prev->reg, di->reg); + draw_item_remove(priv, di); + di = di_prev->next; + } +#else if ((di_prev->type == RDI_IMGLL) && (di->type == RDI_IMGLL)) { LLOGLN(10, ("draw_item_pack: packing RDI_IMGLL")); @@ -674,6 +685,7 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) draw_item_remove(priv, di); di = di_prev->next; } +#endif else if ((di_prev->type == RDI_IMGLY) && (di->type == RDI_IMGLY)) { LLOGLN(10, ("draw_item_pack: packing RDI_IMGLY")); @@ -756,7 +768,7 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) remove_empties(priv); #endif -#if 1 +#if 0 if (priv->draw_item_tail != 0) { if (priv->draw_item_tail->prev != 0) @@ -796,6 +808,38 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv) remove_empties(priv); #endif +#if 0 + /* subtract regions */ + if (priv->draw_item_tail != 0) + { + if (priv->draw_item_tail->prev != 0) + { + di = priv->draw_item_tail; + while (di->prev != 0) + { + /* skip subtract flag + * draw items like line can't be used to clear(subtract) previous + * draw items since they are not opaque + * eg they can not be the 'S' in 'D = M - S' + * the region for line draw items is the clip region */ + if ((di->flags & 1) == 0) + { + di_prev = di->prev; + while (di_prev != 0) + { + /* D = M - S */ + RegionSubtract(di_prev->reg, di_prev->reg, di->reg); + di_prev = di_prev->prev; + } + } + + di = di->prev; + } + } + } + remove_empties(priv); +#endif + return 0; } @@ -942,12 +986,12 @@ rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, width, org_width, depth, g_rdpScreen.depth)); pScreen->CreatePixmap = g_rdpScreen.CreatePixmap; rv = pScreen->CreatePixmap(pScreen, width, height, depth, usage_hint); + pScreen->CreatePixmap = rdpCreatePixmap; priv = GETPIXPRIV(rv); priv->rdpindex = -1; priv->con_number = g_con_number; priv->kind_width = width; pScreen->ModifyPixmapHeader(rv, org_width, 0, 0, 0, 0, 0); - pScreen->CreatePixmap = rdpCreatePixmap; return rv; } @@ -982,6 +1026,64 @@ rdpDestroyPixmap(PixmapPtr pPixmap) return rv; } +/*****************************************************************************/ +int +xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv) +{ + RegionRec reg1; + BoxRec box; + int width; + int height; + struct image_data id; + + if (priv->status == 0) + { + width = pix->drawable.width; + height = pix->drawable.height; + if ((pix->usage_hint == 0) && + (pix->drawable.depth >= g_rdpScreen.depth) && + (width > 0) && (height > 0) && + (priv->use_count > XRDP_USE_COUNT_THRESHOLD)) + { + width = (width + 3) & ~3; + priv->rdpindex = rdpup_add_os_bitmap(pix, priv); + if (priv->rdpindex >= 0) + { + priv->status = 1; + rdpup_create_os_surface(priv->rdpindex, width, height); + box.x1 = 0; + box.y1 = 0; + box.x2 = width; + box.y2 = height; + if (g_do_dirty_os) + { + draw_item_remove_all(priv); + RegionInit(®1, &box, 0); + draw_item_add_img_region(priv, ®1, GXcopy, RDI_IMGLY, 16); + RegionUninit(®1); + priv->is_dirty = 1; + } + else + { + rdpup_get_pixmap_image_rect(pix, &id); + rdpup_switch_os_surface(priv->rdpindex); + rdpup_begin_update(); + rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, + box.y2 - box.y1); + rdpup_end_update(); + rdpup_switch_os_surface(-1); + } + priv->use_count++; + return 1; + } + } + priv->use_count++; + return 0; + } + priv->use_count++; + return 1; +} + /*****************************************************************************/ int xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv) @@ -1500,284 +1602,3 @@ rdpSaveScreen(ScreenPtr pScreen, int on) return 1; } -/******************************************************************************/ -int -rdpCreatePicture(PicturePtr pPicture) -{ - PictureScreenPtr ps; - int rv; - - LLOGLN(10, ("rdpCreatePicture:")); - ps = GetPictureScreen(g_pScreen); - ps->CreatePicture = g_rdpScreen.CreatePicture; - rv = ps->CreatePicture(pPicture); - ps->CreatePicture = rdpCreatePicture; - return rv; -} - -/******************************************************************************/ -void -rdpDestroyPicture(PicturePtr pPicture) -{ - PictureScreenPtr ps; - - LLOGLN(10, ("rdpDestroyPicture:")); - ps = GetPictureScreen(g_pScreen); - ps->DestroyPicture = g_rdpScreen.DestroyPicture; - ps->DestroyPicture(pPicture); - ps->DestroyPicture = rdpDestroyPicture; -} - -/******************************************************************************/ -/* it looks like all the antialias draws go through here - op is one of the following - #define PictOpMinimum 0 - #define PictOpClear 0 - #define PictOpSrc 1 - #define PictOpDst 2 - #define PictOpOver 3 - #define PictOpOverReverse 4 - #define PictOpIn 5 - #define PictOpInReverse 6 - #define PictOpOut 7 - #define PictOpOutReverse 8 - #define PictOpAtop 9 - #define PictOpAtopReverse 10 - #define PictOpXor 11 - #define PictOpAdd 12 - #define PictOpSaturate 13 - #define PictOpMaximum 13 - - see for porter duff - http://www.svgopen.org/2005/papers/abstractsvgopen/ - - */ -void -rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, - INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, - INT16 yDst, CARD16 width, CARD16 height) -{ - BoxRec box; - PictureScreenPtr ps; - RegionRec reg1; - RegionRec reg2; - DrawablePtr p; - int dirty_type; - int j; - int num_clips; - int post_process; - int reset_surface; - int got_id; - WindowPtr pDstWnd; - PixmapPtr pDstPixmap; - rdpPixmapRec *pDstPriv; - rdpPixmapRec *pDirtyPriv; - struct image_data id; - - LLOGLN(10, ("rdpComposite:")); - - ps = GetPictureScreen(g_pScreen); - ps->Composite = g_rdpScreen.Composite; - ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc, - xMask, yMask, xDst, yDst, width, height); - ps->Composite = rdpComposite; - - if (g_doing_font == 2) - { - return; - } - - LLOGLN(10, ("rdpComposite: op %d %p %p %p w %d h %d", op, pSrc, pMask, pDst, width, height)); - - p = pDst->pDrawable; - - dirty_type = 0; - pDirtyPriv = 0; - post_process = 0; - reset_surface = 0; - got_id = 0; - - if (p->type == DRAWABLE_PIXMAP) - { - pDstPixmap = (PixmapPtr)p; - pDstPriv = GETPIXPRIV(pDstPixmap); - - if (xrdp_is_os(pDstPixmap, pDstPriv)) - { - post_process = 1; - - if (g_do_dirty_os) - { - LLOGLN(10, ("rdpComposite: gettig dirty")); - pDstPriv->is_dirty = 1; - dirty_type = g_doing_font ? RDI_IMGLL : RDI_IMGLY; - pDirtyPriv = pDstPriv; - - } - else - { - rdpup_switch_os_surface(pDstPriv->rdpindex); - reset_surface = 1; - rdpup_get_pixmap_image_rect(pDstPixmap, &id); - got_id = 1; - LLOGLN(10, ("rdpComposite: offscreen")); - } - } - } - else - { - if (p->type == DRAWABLE_WINDOW) - { - pDstWnd = (WindowPtr)p; - - if (pDstWnd->viewable) - { - post_process = 1; - - if (g_do_dirty_ons) - { - LLOGLN(0, ("rdpComposite: gettig dirty")); - g_screenPriv.is_dirty = 1; - pDirtyPriv = &g_screenPriv; - dirty_type = RDI_IMGLL; - } - else - { - rdpup_get_screen_image_rect(&id); - got_id = 1; - LLOGLN(10, ("rdpComposite: screen")); - } - } - } - } - - if (!post_process) - { - return; - } - - if (pDst->pCompositeClip != 0) - { - box.x1 = p->x + xDst; - box.y1 = p->y + yDst; - box.x2 = box.x1 + width; - box.y2 = box.y1 + height; - RegionInit(®1, &box, 0); - RegionInit(®2, NullBox, 0); - RegionCopy(®2, pDst->pCompositeClip); - RegionIntersect(®1, ®1, ®2); - - if (dirty_type != 0) - { - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COMPOSITE); - } - else if (got_id) - { - num_clips = REGION_NUM_RECTS(®1); - - if (num_clips > 0) - { - rdpup_begin_update(); - - for (j = num_clips - 1; j >= 0; j--) - { - box = REGION_RECTS(®1)[j]; - rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - } - - rdpup_end_update(); - } - } - - RegionUninit(®1); - RegionUninit(®2); - } - else - { - box.x1 = p->x + xDst; - box.y1 = p->y + yDst; - box.x2 = box.x1 + width; - box.y2 = box.y1 + height; - - if (dirty_type != 0) - { - RegionInit(®1, &box, 0); - draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COMPOSITE); - RegionUninit(®1); - } - else if (got_id) - { - rdpup_begin_update(); - rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); - rdpup_end_update(); - } - } - - if (reset_surface) - { - rdpup_switch_os_surface(-1); - } -} - -/******************************************************************************/ -/* make sure no glyph is too big */ -/* returns boolean */ -static int -rdpGlyphCheck(int nlist, GlyphListPtr list, GlyphPtr* glyphs) -{ - int n; - GlyphPtr glyph; - - while (nlist--) - { - n = list->len; - list++; - while (n--) - { - glyph = *glyphs++; - if ((glyph->info.width * glyph->info.height) > 8192) - { - LLOGLN(10, ("rdpGlyphCheck: too big")); - return 0; - } - } - } - return 1; -} - -/******************************************************************************/ -void -rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, - GlyphPtr *glyphs) -{ - PictureScreenPtr ps; - - LLOGLN(10, ("rdpGlyphs: op %d xSrc %d ySrc %d maskFormat %p", op, xSrc, ySrc, maskFormat)); - - if (g_do_glyph_cache && rdpGlyphCheck(nlists, lists, glyphs)) - { - g_doing_font = 2; - ps = GetPictureScreen(g_pScreen); - ps->Glyphs = g_rdpScreen.Glyphs; - ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, - nlists, lists, glyphs); - ps->Glyphs = rdpGlyphs; - rdpGlypht(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists, glyphs); - } - else - { - g_doing_font = 1; - rdpup_set_hints(1, 1); - ps = GetPictureScreen(g_pScreen); - ps->Glyphs = g_rdpScreen.Glyphs; - ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, - nlists, lists, glyphs); - ps->Glyphs = rdpGlyphs; - rdpup_set_hints(0, 1); - } - - g_doing_font = 0; - LLOGLN(10, ("rdpGlyphs: out")); -} diff --git a/xorg/X11R7.6/rdp/rdpglyph.c b/xorg/X11R7.6/rdp/rdpglyph.c index 3da30737..e6e011be 100644 --- a/xorg/X11R7.6/rdp/rdpglyph.c +++ b/xorg/X11R7.6/rdp/rdpglyph.c @@ -544,6 +544,7 @@ rdpGlyphu(CARD8 op, PicturePtr pSrc, PicturePtr pDst, pDstPriv = GETPIXPRIV(pDstPixmap); if (XRDP_IS_OS(pDstPriv)) { + rdpup_check_dirty(pDstPixmap, pDstPriv); post_process = 1; if (g_do_dirty_os) { diff --git a/xorg/X11R7.6/rdp/rdpmain.c b/xorg/X11R7.6/rdp/rdpmain.c index 5a42c5b8..6ca2912b 100644 --- a/xorg/X11R7.6/rdp/rdpmain.c +++ b/xorg/X11R7.6/rdp/rdpmain.c @@ -48,8 +48,9 @@ int g_can_do_pix_to_pix = 0; int g_do_dirty_os = 1; /* delay remoting off screen bitmaps */ int g_do_dirty_ons = 0; /* delay remoting screen */ -int g_do_glyph_cache = 0; +int g_do_glyph_cache = 0; /* rdpup.c may set this */ int g_do_alpha_glyphs = 1; +int g_do_composite = 0; /* rdpup.c may set this */ Bool g_wrapWindow = 1; Bool g_wrapPixmap = 1; @@ -61,6 +62,7 @@ int g_use_rail = 0; int g_con_number = 0; /* increments for each connection */ WindowPtr g_invalidate_window = 0; +int g_doing_font = 0; /* if true, use a unix domain socket instead of a tcp socket */ int g_use_uds = 0; diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index 50f73492..bf8aea1c 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -57,6 +57,7 @@ extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */ extern int g_do_glyph_cache; /* from rdpmain.c */ extern int g_can_do_pix_to_pix; /* from rdpmain.c */ extern int g_use_rail; /* from rdpmain.c */ +extern int g_do_composite; /* from rdpmain.c */ /* true is to use unix domain socket */ extern int g_use_uds; /* in rdpmain.c */ @@ -159,6 +160,7 @@ rdpup_disconnect(void) g_os_bitmaps = 0; g_use_rail = 0; g_do_glyph_cache = 0; + g_do_composite = 0; return 0; } @@ -347,6 +349,9 @@ rdpup_send_msg(struct stream *s) static int rdpup_send_pending(void) { + int rv; + + rv = 0; if (g_connected && g_begin) { LLOGLN(10, ("end %d", g_count)); @@ -354,12 +359,16 @@ rdpup_send_pending(void) out_uint16_le(g_out_s, 4); g_count++; s_mark_end(g_out_s); - rdpup_send_msg(g_out_s); + if (rdpup_send_msg(g_out_s) != 0) + { + LLOGLN(0, ("rdpup_send_pending: rdpup_send_msg failed")); + rv = 1; + } } g_count = 0; g_begin = 0; - return 0; + return rv; } /******************************************************************************/ @@ -781,10 +790,19 @@ rdpup_process_msg(struct stream *s) { g_do_glyph_cache = 1; } + if (g_rdpScreen.client_info.order_flags_ex & 0x100) + { + g_do_composite = 1; + } if (g_do_glyph_cache) { LLOGLN(0, (" using glyph cache")); } + if (g_do_composite) + { + LLOGLN(0, (" using client composite")); + } + LLOGLN(10, ("order_flags_ex 0x%x", g_rdpScreen.client_info.order_flags_ex)); if (g_rdpScreen.client_info.offscreen_cache_entries == 2000) { LLOGLN(0, (" client can do offscreen to offscreen blits")); @@ -1040,6 +1058,9 @@ rdpup_end_update(void) int rdpup_pre_check(int in_size) { + int rv; + + rv = 0; if (!g_begin) { rdpup_begin_update(); @@ -1048,13 +1069,17 @@ rdpup_pre_check(int in_size) if ((g_out_s->p - g_out_s->data) > (g_out_s->size - (in_size + 20))) { s_mark_end(g_out_s); - rdpup_send_msg(g_out_s); + if (rdpup_send_msg(g_out_s) != 0) + { + LLOGLN(0, ("rdpup_pre_check: rdpup_send_msg failed")); + rv = 1; + } g_count = 0; init_stream(g_out_s, 0); s_push_layer(g_out_s, iso_hdr, 8); } - return 0; + return rv; } /******************************************************************************/ @@ -1277,6 +1302,25 @@ convert_pixels(void *src, void *dst, int num_pixels) return 0; } +/******************************************************************************/ +int +alpha_pixels(void* src, void* dst, int num_pixels) +{ + unsigned int* src32; + unsigned char* dst8; + int index; + + src32 = (unsigned int*)src; + dst8 = (unsigned char*)dst; + for (index = 0; index < num_pixels; index++) + { + *dst8 = (*src32) >> 24; + dst8++; + src32++; + } + return 0; +} + /******************************************************************************/ int rdpup_set_fgcolor(int fgcolor) @@ -1448,6 +1492,26 @@ rdpup_create_os_surface(int rdpindex, int width, int height) return 0; } +/******************************************************************************/ +int +rdpup_create_os_surface_bpp(int rdpindex, int width, int height, int bpp) +{ + LLOGLN(10, ("rdpup_create_os_surface_bpp:")); + if (g_connected) + { + LLOGLN(10, (" width %d height %d bpp %d", width, height, bpp)); + rdpup_pre_check(13); + out_uint16_le(g_out_s, 31); + out_uint16_le(g_out_s, 13); + g_count++; + out_uint32_le(g_out_s, rdpindex); + out_uint16_le(g_out_s, width); + out_uint16_le(g_out_s, height); + out_uint8(g_out_s, bpp); + } + return 0; +} + /******************************************************************************/ int rdpup_switch_os_surface(int rdpindex) @@ -1653,7 +1717,7 @@ rdpup_send_area(struct image_data *id, int x, int y, int w, int h) LLOGLN(10, (" rdpup_send_area")); ly = y; - while (ly < y + h) + while ((ly < y + h) && g_connected) { lx = x; @@ -1704,6 +1768,103 @@ rdpup_send_area(struct image_data *id, int x, int y, int w, int h) } } +/******************************************************************************/ +/* split the bitmap up into 64 x 64 pixel areas */ +void +rdpup_send_alpha_area(struct image_data* id, int x, int y, int w, int h) +{ + char* s; + int i; + int lx; + int ly; + int lh; + int lw; + int size; + struct image_data lid; + + LLOGLN(10, ("rdpup_send_alpha_area: id %p x %d y %d w %d h %d", + id, x, y, w, h)); + if (id == 0) + { + rdpup_get_screen_image_rect(&lid); + id = &lid; + } + + if (x >= id->width) + { + return; + } + if (y >= id->height) + { + return; + } + if (x < 0) + { + w += x; + x = 0; + } + if (y < 0) + { + h += y; + y = 0; + } + if (w <= 0) + { + return; + } + if (h <= 0) + { + return; + } + if (x + w > id->width) + { + w = id->width - x; + } + if (y + h > id->height) + { + h = id->height - y; + } + LLOGLN(10, ("%d", w * h)); + if (g_connected && g_begin) + { + LLOGLN(10, (" rdpup_send_area")); + ly = y; + while ((ly < y + h) && g_connected) + { + lx = x; + while ((lx < x + w) && g_connected) + { + lw = MIN(64, (x + w) - lx); + lh = MIN(64, (y + h) - ly); + size = lw * lh + 25; + rdpup_pre_check(size); + out_uint16_le(g_out_s, 32); /* server_paint_rect_bpp */ + out_uint16_le(g_out_s, size); + g_count++; + out_uint16_le(g_out_s, lx); + out_uint16_le(g_out_s, ly); + out_uint16_le(g_out_s, lw); + out_uint16_le(g_out_s, lh); + out_uint32_le(g_out_s, lw * lh); + for (i = 0; i < lh; i++) + { + s = (id->pixels + + ((ly + i) * id->lineBytes) + (lx * g_Bpp)); + alpha_pixels(s, g_out_s->p, lw); + g_out_s->p += lw; + } + out_uint16_le(g_out_s, lw); + out_uint16_le(g_out_s, lh); + out_uint16_le(g_out_s, 0); + out_uint16_le(g_out_s, 0); + out_uint8(g_out_s, 8); + lx += 64; + } + ly += 64; + } + } +} + /******************************************************************************/ void rdpup_paint_rect_os(int x, int y, int cx, int cy, @@ -2173,6 +2334,35 @@ rdpup_check_dirty_screen(rdpPixmapRec *pDirtyPriv) return 0; } +/******************************************************************************/ +int +rdpup_check_alpha_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec* pDirtyPriv) +{ + struct image_data id; + + LLOGLN(10, ("rdpup_check_alpha_dirty: width %d height %d", + pDirtyPixmap->drawable.width, pDirtyPixmap->drawable.height)); + if (pDirtyPriv == 0) + { + return 0; + } + LLOGLN(10, ("rdpup_check_alpha_dirty: is_alpha_dirty_not %d", + pDirtyPriv->is_alpha_dirty_not)); + if (pDirtyPriv->is_alpha_dirty_not) + { + return 0; + } + pDirtyPriv->is_alpha_dirty_not = 1; + rdpup_switch_os_surface(pDirtyPriv->rdpindex); + rdpup_get_pixmap_image_rect(pDirtyPixmap, &id); + rdpup_begin_update(); + rdpup_send_alpha_area(&id, 0, 0, pDirtyPixmap->drawable.width, + pDirtyPixmap->drawable.height); + rdpup_end_update(); + rdpup_switch_os_surface(-1); + return 0; +} + /******************************************************************************/ int rdpup_add_char(int font, int charactor, short x, short y, int cx, int cy, @@ -2256,3 +2446,58 @@ rdpup_draw_text(int font, int flags, int mixmode, return 0; } +/******************************************************************************/ +int +rdpup_composite(short srcidx, int srcformat, short srcwidth, CARD8 srcrepeat, + PictTransform* srctransform, CARD8 mskflags, + short mskidx, int mskformat, short mskwidth, CARD8 mskrepeat, + CARD8 op, short srcx, short srcy, short mskx, short msky, + short dstx, short dsty, short width, short height, + int dstformat) +{ + if (g_connected) + { + LLOGLN(10, (" rdpup_composite")); + rdpup_pre_check(84); + out_uint16_le(g_out_s, 33); + out_uint16_le(g_out_s, 84); /* size */ + g_count++; + out_uint16_le(g_out_s, srcidx); + out_uint32_le(g_out_s, srcformat); + out_uint16_le(g_out_s, srcwidth); + out_uint8(g_out_s, srcrepeat); + if (srctransform == 0) + { + out_uint8s(g_out_s, 10 * 4); + } + else + { + out_uint32_le(g_out_s, 1); + out_uint32_le(g_out_s, srctransform->matrix[0][0]); + out_uint32_le(g_out_s, srctransform->matrix[0][1]); + out_uint32_le(g_out_s, srctransform->matrix[0][2]); + out_uint32_le(g_out_s, srctransform->matrix[1][0]); + out_uint32_le(g_out_s, srctransform->matrix[1][1]); + out_uint32_le(g_out_s, srctransform->matrix[1][2]); + out_uint32_le(g_out_s, srctransform->matrix[2][0]); + out_uint32_le(g_out_s, srctransform->matrix[2][1]); + out_uint32_le(g_out_s, srctransform->matrix[2][2]); + } + out_uint8(g_out_s, mskflags); + out_uint16_le(g_out_s, mskidx); + out_uint32_le(g_out_s, mskformat); + out_uint16_le(g_out_s, mskwidth); + out_uint8(g_out_s, mskrepeat); + out_uint8(g_out_s, op); + out_uint16_le(g_out_s, srcx); + out_uint16_le(g_out_s, srcy); + out_uint16_le(g_out_s, mskx); + out_uint16_le(g_out_s, msky); + out_uint16_le(g_out_s, dstx); + out_uint16_le(g_out_s, dsty); + out_uint16_le(g_out_s, width); + out_uint16_le(g_out_s, height); + out_uint32_le(g_out_s, dstformat); + } + return 0; +} diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index 44246984..4215c27b 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -283,6 +283,20 @@ xrdp_painter_copy(struct xrdp_painter* self, int x, int y, int cx, int cy, int srcx, int srcy); int APP_CC +xrdp_painter_composite(struct xrdp_painter* self, + struct xrdp_bitmap* src, + int srcformat, + int srcwidth, + int srcrepeat, + struct xrdp_bitmap* dst, + int* srctransform, + int mskflags, + struct xrdp_bitmap* msk, + int mskformat, int mskwidth, int mskrepeat, int op, + int srcx, int srcy, int mskx, int msky, + int dstx, int dsty, int width, int height, + int dstformat); +int APP_CC xrdp_painter_line(struct xrdp_painter* self, struct xrdp_bitmap* bitmap, int x1, int y1, int x2, int y2); @@ -374,6 +388,16 @@ int DEFAULT_CC server_paint_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy, char* data, int width, int height, int srcx, int srcy); int DEFAULT_CC +server_paint_rect_bpp(struct xrdp_mod* mod, int x, int y, int cx, int cy, + char* data, int width, int height, int srcx, int srcy, + int bpp); +int DEFAULT_CC +server_composite(struct xrdp_mod* mod, int srcidx, int srcformat, int srcwidth, + int srcrepeat, int* srctransform, int mskflags, int mskidx, + int mskformat, int mskwidth, int mskrepeat, int op, + int srcx, int srcy, int mskx, int msky, + int dstx, int dsty, int width, int height, int dstformat); +int DEFAULT_CC server_set_pointer(struct xrdp_mod* mod, int x, int y, char* data, char* mask); int DEFAULT_CC @@ -434,6 +458,9 @@ int DEFAULT_CC server_create_os_surface(struct xrdp_mod* mod, int id, int width, int height); int DEFAULT_CC +server_create_os_surface_bpp(struct xrdp_mod* mod, int id, + int width, int height, int bpp); +int DEFAULT_CC server_switch_os_surface(struct xrdp_mod* mod, int id); int DEFAULT_CC server_delete_os_surface(struct xrdp_mod* mod, int id); diff --git a/xrdp/xrdp_cache.c b/xrdp/xrdp_cache.c index 62da4183..16ce1283 100644 --- a/xrdp/xrdp_cache.c +++ b/xrdp/xrdp_cache.c @@ -239,7 +239,7 @@ xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap, } else { - log_message(LOG_LEVEL_ERROR,"error in xrdp_cache_add_bitmap, too big(%d)", bmp_size); + log_message(LOG_LEVEL_ERROR,"error in xrdp_cache_add_bitmap, too big(%d) bpp %d", bmp_size, bitmap->bpp); } /* look for oldest */ diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 88f888c7..b1499984 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -414,6 +414,9 @@ xrdp_mm_setup_mod1(struct xrdp_mm *self) self->mod->server_notify_delete = server_notify_delete; self->mod->server_monitored_desktop = server_monitored_desktop; self->mod->server_add_char_alpha = server_add_char_alpha; + self->mod->server_create_os_surface_bpp = server_create_os_surface_bpp; + self->mod->server_paint_rect_bpp = server_paint_rect_bpp; + self->mod->server_composite = server_composite; } } @@ -906,7 +909,6 @@ xrdp_mm_process_rail_drawing_orders(struct xrdp_mm* self, struct trans* trans) struct stream* s; int order_type; int rv = 0; - struct rail_window_state_order rwso; s = trans_get_in_s(trans); if (s == 0) @@ -1057,7 +1059,7 @@ xrdp_mm_connect_chansrv(struct xrdp_mm *self, char *ip, char *port) self->usechansrv = 1; /* connect channel redir */ - if ((ip == 0) || (g_strcmp(ip, "127.0.0.1") == 0) || (ip[0] == 0)) + if ((g_strcmp(ip, "127.0.0.1") == 0) || (ip[0] == 0)) { /* unix socket */ self->chan_trans = trans_create(TRANS_MODE_UNIX, 8192, 8192); @@ -2058,6 +2060,79 @@ server_paint_rect(struct xrdp_mod *mod, int x, int y, int cx, int cy, return 0; } +/*****************************************************************************/ +int DEFAULT_CC +server_paint_rect_bpp(struct xrdp_mod* mod, int x, int y, int cx, int cy, + char* data, int width, int height, int srcx, int srcy, + int bpp) +{ + struct xrdp_wm* wm; + struct xrdp_bitmap* b; + struct xrdp_painter* p; + + p = (struct xrdp_painter*)(mod->painter); + if (p == 0) + { + return 0; + } + wm = (struct xrdp_wm*)(mod->wm); + b = xrdp_bitmap_create_with_data(width, height, bpp, data, wm); + xrdp_painter_copy(p, b, wm->target_surface, x, y, cx, cy, srcx, srcy); + xrdp_bitmap_delete(b); + return 0; +} + +/*****************************************************************************/ +int DEFAULT_CC +server_composite(struct xrdp_mod* mod, int srcidx, int srcformat, + int srcwidth, int srcrepeat, int* srctransform, + int mskflags, int mskidx, int mskformat, int mskwidth, + int mskrepeat, int op, int srcx, int srcy, + int mskx, int msky, int dstx, int dsty, + int width, int height, int dstformat) +{ + struct xrdp_wm* wm; + struct xrdp_bitmap* b; + struct xrdp_bitmap* msk; + struct xrdp_painter* p; + struct xrdp_os_bitmap_item* bi; + + p = (struct xrdp_painter*)(mod->painter); + if (p == 0) + { + return 0; + } + wm = (struct xrdp_wm*)(mod->wm); + b = 0; + msk = 0; + bi = xrdp_cache_get_os_bitmap(wm->cache, srcidx); + if (bi != 0) + { + b = bi->bitmap; + } + if (mskflags & 1) + { + bi = xrdp_cache_get_os_bitmap(wm->cache, mskidx); + if (bi != 0) + { + msk = bi->bitmap; + } + } + if (b != 0) + { + xrdp_painter_composite(p, b, srcformat, srcwidth, srcrepeat, + wm->target_surface, srctransform, + mskflags, msk, mskformat, mskwidth, mskrepeat, + op, srcx, srcy, mskx, msky, dstx, dsty, + width, height, dstformat); + } + else + { + g_writeln("server_composite: error finding id %d or %d", srcidx, mskidx); + } + return 0; +} + /*****************************************************************************/ int DEFAULT_CC server_set_pointer(struct xrdp_mod *mod, int x, int y, @@ -2673,6 +2748,29 @@ server_create_os_surface(struct xrdp_mod *mod, int rdpindex, return 0; } +/*****************************************************************************/ +int DEFAULT_CC +server_create_os_surface_bpp(struct xrdp_mod* mod, int rdpindex, + int width, int height, int bpp) +{ + struct xrdp_wm* wm; + struct xrdp_bitmap* bitmap; + int error; + + wm = (struct xrdp_wm*)(mod->wm); + bitmap = xrdp_bitmap_create(width, height, bpp, + WND_TYPE_OFFSCREEN, wm); + error = xrdp_cache_add_os_bitmap(wm->cache, bitmap, rdpindex); + if (error != 0) + { + g_writeln("server_create_os_surface_bpp: xrdp_cache_add_os_bitmap failed"); + return 1; + } + bitmap->item_index = rdpindex; + bitmap->id = rdpindex; + return 0; +} + /*****************************************************************************/ int DEFAULT_CC server_switch_os_surface(struct xrdp_mod *mod, int rdpindex) diff --git a/xrdp/xrdp_painter.c b/xrdp/xrdp_painter.c index 4457fee8..b9d1da16 100644 --- a/xrdp/xrdp_painter.c +++ b/xrdp/xrdp_painter.c @@ -849,7 +849,7 @@ xrdp_painter_copy(struct xrdp_painter *self, { w = MIN(64, ((srcx + cx) - i)); h = MIN(64, ((srcy + cy) - j)); - b = xrdp_bitmap_create(w, h, self->wm->screen->bpp, 0, self->wm); + b = xrdp_bitmap_create(w, h, src->bpp, 0, self->wm); xrdp_bitmap_copy_box_with_crc(src, b, i, j, w, h); bitmap_id = xrdp_cache_add_bitmap(self->wm->cache, b, self->wm->hints); cache_id = HIWORD(bitmap_id); @@ -887,6 +887,86 @@ xrdp_painter_copy(struct xrdp_painter *self, return 0; } +/*****************************************************************************/ +int APP_CC +xrdp_painter_composite(struct xrdp_painter* self, + struct xrdp_bitmap* src, + int srcformat, + int srcwidth, + int srcrepeat, + struct xrdp_bitmap* dst, + int* srctransform, + int mskflags, + struct xrdp_bitmap* msk, + int mskformat, int mskwidth, int mskrepeat, int op, + int srcx, int srcy, int mskx, int msky, + int dstx, int dsty, int width, int height, int dstformat) +{ + struct xrdp_rect clip_rect; + struct xrdp_rect draw_rect; + struct xrdp_rect rect1; + struct xrdp_rect rect2; + struct xrdp_region* region; + int k; + int dx; + int dy; + int palette_id; + int cache_srcidx; + int cache_mskidx; + + if (self == 0 || src == 0 || dst == 0) + { + return 0; + } + + /* todo data */ + + if (dst->type == WND_TYPE_BITMAP) + { + return 0; + } + + if (src->type == WND_TYPE_OFFSCREEN) + { + xrdp_bitmap_get_screen_clip(dst, self, &clip_rect, &dx, &dy); + region = xrdp_region_create(self->wm); + xrdp_region_add_rect(region, &clip_rect); + dstx += dx; + dsty += dy; + + palette_id = 0; + cache_srcidx = src->item_index; + cache_mskidx = -1; + if (mskflags & 1) + { + if (msk != 0) + { + cache_mskidx = msk->item_index; // todo + } + } + + k = 0; + while (xrdp_region_get_rect(region, k, &rect1) == 0) + { + if (rect_intersect(&rect1, &clip_rect, &rect2)) + { + MAKERECT(rect1, dstx, dsty, width, height); + if (rect_intersect(&rect2, &rect1, &draw_rect)) + { + libxrdp_orders_composite_blt(self->session, cache_srcidx, srcformat, srcwidth, + srcrepeat, srctransform, mskflags, cache_mskidx, + mskformat, mskwidth, mskrepeat, op, srcx, srcy, + mskx, msky, dstx, dsty, width, height, dstformat, + &draw_rect); + } + } + k++; + } + xrdp_region_delete(region); + } + return 0; +} + /*****************************************************************************/ int APP_CC xrdp_painter_line(struct xrdp_painter *self, diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index 7f08b4a0..14ae2237 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -52,8 +52,10 @@ struct xrdp_mod int (*server_screen_blt)(struct xrdp_mod* v, int x, int y, int cx, int cy, int srcx, int srcy); int (*server_paint_rect)(struct xrdp_mod* v, int x, int y, int cx, int cy, - char* data, int width, int height, int srcx, int srcy); - int (*server_set_pointer)(struct xrdp_mod* v, int x, int y, char* data, char* mask); + char* data, int width, int height, + int srcx, int srcy); + int (*server_set_pointer)(struct xrdp_mod* v, int x, int y, + char* data, char* mask); int (*server_palette)(struct xrdp_mod* v, int* palette); int (*server_msg)(struct xrdp_mod* v, char* msg, int code); int (*server_is_term)(struct xrdp_mod* v); @@ -122,7 +124,19 @@ struct xrdp_mod int offset, int baseline, int width, int height, char* data); - long server_dumby[100 - 39]; /* align, 100 minus the number of server + int (*server_create_os_surface_bpp)(struct xrdp_mod* v, int rdpindex, + int width, int height, int bpp); + int (*server_paint_rect_bpp)(struct xrdp_mod* v, int x, int y, int cx, int cy, + char* data, int width, int height, + int srcx, int srcy, int bpp); + int (*server_composite)(struct xrdp_mod* v, int srcidx, int srcformat, + int srcwidth, int srcrepeat, int* srctransform, + int mskflags, int mskidx, int mskformat, + int mskwidth, int mskrepeat, int op, + int srcx, int srcy, int mskx, int msky, + int dstx, int dsty, int width, int height, + int dstformat); + long server_dumby[100 - 42]; /* align, 100 minus the number of server functions above */ /* common */ long handle; /* pointer to self as int */ diff --git a/xup/xup.c b/xup/xup.c index d77eee55..acac30a4 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -541,12 +541,17 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s) int cy; int srcx; int srcy; + int mskx; + int msky; + int dstx; + int dsty; int len_bmpdata; int style; int x1; int y1; int x2; int y2; + int bpp; int rdpid; int hints; int mask; @@ -566,6 +571,18 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s) int box_top; int box_right; int box_bottom; + int srcrepeat; + int srcidx; + int srcformat; + int srcwidth; + int mskflags; + int mskidx; + int mskformat; + int mskwidth; + int mskrepeat; + int dstformat; + int op; + int transform[10]; char *bmpdata; char cur_data[32 * (32 * 3)]; char cur_mask[32 * (32 / 8)]; @@ -729,6 +746,56 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s) clip_right, clip_bottom, box_left, box_top, box_right, box_bottom, x, y, bmpdata, len_bmpdata); break; + case 31: /* server_create_os_surface_bpp */ + in_uint32_le(s, rdpid); + in_uint16_le(s, width); + in_uint16_le(s, height); + in_uint8(s, bpp); + rv = mod->server_create_os_surface_bpp(mod, rdpid, width, height, bpp); + break; + case 32: /* server_paint_rect_bpp */ + in_sint16_le(s, x); + in_sint16_le(s, y); + in_uint16_le(s, cx); + in_uint16_le(s, cy); + in_uint32_le(s, len_bmpdata); + in_uint8p(s, bmpdata, len_bmpdata); + in_uint16_le(s, width); + in_uint16_le(s, height); + in_sint16_le(s, srcx); + in_sint16_le(s, srcy); + in_uint8(s, bpp); + rv = mod->server_paint_rect_bpp(mod, x, y, cx, cy, + bmpdata, width, height, + srcx, srcy, bpp); + break; + case 33: + in_uint16_le(s, srcidx); + in_uint32_le(s, srcformat); + in_uint16_le(s, srcwidth); + in_uint8(s, srcrepeat); + g_memcpy(transform, s->p, 40); + in_uint8s(s, 40); + in_uint8(s, mskflags); + in_uint16_le(s, mskidx); + in_uint32_le(s, mskformat); + in_uint16_le(s, mskwidth); + in_uint8(s, mskrepeat); + in_uint8(s, op); + in_sint16_le(s, srcx); + in_sint16_le(s, srcy); + in_sint16_le(s, mskx); + in_sint16_le(s, msky); + in_sint16_le(s, dstx); + in_sint16_le(s, dsty); + in_uint16_le(s, width); + in_uint16_le(s, height); + in_uint32_le(s, dstformat); + rv = mod->server_composite(mod, srcidx, srcformat, srcwidth, srcrepeat, + transform, mskflags, mskidx, mskformat, + mskwidth, mskrepeat, op, srcx, srcy, mskx, msky, + dstx, dsty, width, height, dstformat); + break; case 51: /* server_set_pointer_ex */ rv = process_server_set_pointer_ex(mod, s); break; diff --git a/xup/xup.h b/xup/xup.h index 93465695..ca232c4d 100644 --- a/xup/xup.h +++ b/xup/xup.h @@ -53,7 +53,8 @@ struct mod int (*server_screen_blt)(struct mod* v, int x, int y, int cx, int cy, int srcx, int srcy); int (*server_paint_rect)(struct mod* v, int x, int y, int cx, int cy, - char* data, int width, int height, int srcx, int srcy); + char* data, int width, int height, + int srcx, int srcy); int (*server_set_cursor)(struct mod* v, int x, int y, char* data, char* mask); int (*server_palette)(struct mod* v, int* palette); int (*server_msg)(struct mod* v, char* msg, int code); @@ -122,8 +123,18 @@ struct mod int (*server_add_char_alpha)(struct mod* v, int font, int charactor, int offset, int baseline, int width, int height, char* data); + int (*server_create_os_surface_bpp)(struct mod* v, int rdpindex, + int width, int height, int bpp); + int (*server_paint_rect_bpp)(struct mod* v, int x, int y, int cx, int cy, + char* data, int width, int height, + int srcx, int srcy, int bpp); + int (*server_composite)(struct mod* v, int srcidx, int srcformat, int srcwidth, + int srcrepeat, int* srctransform, int mskflags, int mskidx, + int mskformat, int mskwidth, int mskrepeat, int op, + int srcx, int srcy, int mskx, int msky, + int dstx, int dsty, int width, int height, int dstformat); - tbus server_dumby[100 - 39]; /* align, 100 minus the number of server + tbus server_dumby[100 - 42]; /* align, 100 minus the number of server functions above */ /* common */ tbus handle; /* pointer to self as long */ From 1b5437923de105a3713a66ed8174c5d6447336cf Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Sun, 7 Jul 2013 08:17:12 -0700 Subject: [PATCH 27/31] Add xorg/X11R7.6/rdp/rdpComposite.c, missed from previous commit (a27cbdd) --- xorg/X11R7.6/rdp/rdpComposite.c | 908 ++++++++++++++++++++++++++++++++ 1 file changed, 908 insertions(+) create mode 100644 xorg/X11R7.6/rdp/rdpComposite.c diff --git a/xorg/X11R7.6/rdp/rdpComposite.c b/xorg/X11R7.6/rdp/rdpComposite.c new file mode 100644 index 00000000..8528c4c6 --- /dev/null +++ b/xorg/X11R7.6/rdp/rdpComposite.c @@ -0,0 +1,908 @@ +/* + Copyright 2012-2013 Jay Sorg + + Permission to use, copy, modify, distribute, and sell this software and its + documentation for any purpose is hereby granted without fee, provided that + the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation. + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + */ + +#include "rdp.h" +#include "rdpdraw.h" + +#define LDEBUG 0 + +#define LOG_LEVEL 1 +#define LLOG(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0) +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */ +extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */ +extern int g_Bpp; /* from rdpmain.c */ +extern ScreenPtr g_pScreen; /* from rdpmain.c */ +extern Bool g_wrapPixmap; /* from rdpmain.c */ +extern int g_can_do_pix_to_pix; /* from rdpmain.c */ +extern int g_do_dirty_os; /* in rdpmain.c */ +extern int g_do_glyph_cache; /* in rdpmain.c */ +extern int g_doing_font; /* in rdpmain.c */ +extern int g_do_composite; /* in rdpmain.c */ + +extern GCOps g_rdpGCOps; /* from rdpdraw.c */ + +extern int g_con_number; /* in rdpup.c */ + +extern int g_crc_seed; /* in rdpmisc.c */ +extern int g_crc_table[]; /* in rdpmisc.c */ + +/******************************************************************************/ +int +rdpCreatePicture(PicturePtr pPicture) +{ + PictureScreenPtr ps; + int rv; + + LLOGLN(10, ("rdpCreatePicture:")); + ps = GetPictureScreen(g_pScreen); + ps->CreatePicture = g_rdpScreen.CreatePicture; + rv = ps->CreatePicture(pPicture); + ps->CreatePicture = rdpCreatePicture; + return rv; +} + +/******************************************************************************/ +void +rdpDestroyPicture(PicturePtr pPicture) +{ + PictureScreenPtr ps; + + LLOGLN(10, ("rdpDestroyPicture:")); + ps = GetPictureScreen(g_pScreen); + ps->DestroyPicture = g_rdpScreen.DestroyPicture; + ps->DestroyPicture(pPicture); + ps->DestroyPicture = rdpDestroyPicture; +} + +/******************************************************************************/ +static int +print_format(PictFormatShort format) +{ + switch (format) + { + case PIXMAN_a2r10g10b10: + LLOGLN(0, (" PIXMAN_x2r10g10b10")); + break; + case PIXMAN_x2r10g10b10: + LLOGLN(0, (" PIXMAN_x2r10g10b10")); + break; + case PIXMAN_a2b10g10r10: + LLOGLN(0, (" PIXMAN_a2b10g10r10")); + break; + case PIXMAN_x2b10g10r10: + LLOGLN(0, (" PIXMAN_x2b10g10r10")); + break; + + case PIXMAN_a8r8g8b8: + LLOGLN(0, (" PIXMAN_a8r8g8b8")); + break; + case PIXMAN_x8r8g8b8: + LLOGLN(0, (" PIXMAN_x8r8g8b8")); + break; + case PIXMAN_a8b8g8r8: + LLOGLN(0, (" PIXMAN_a8b8g8r8")); + break; + case PIXMAN_x8b8g8r8: + LLOGLN(0, (" PIXMAN_x8b8g8r8")); + break; + case PIXMAN_b8g8r8a8: + LLOGLN(0, (" PIXMAN_b8g8r8a8")); + break; + case PIXMAN_b8g8r8x8: + LLOGLN(0, (" PIXMAN_b8g8r8x8")); + break; + + /* 24bpp formats */ + case PIXMAN_r8g8b8: + LLOGLN(0, (" PIXMAN_r8g8b8")); + break; + case PIXMAN_b8g8r8: + LLOGLN(0, (" PIXMAN_b8g8r8")); + break; + + /* 16bpp formats */ + case PIXMAN_r5g6b5: + LLOGLN(0, (" PIXMAN_r5g6b5")); + break; + case PIXMAN_b5g6r5: + LLOGLN(0, (" PIXMAN_b5g6r5")); + break; + + case PIXMAN_a1r5g5b5: + LLOGLN(0, (" PIXMAN_a1r5g5b5")); + break; + case PIXMAN_x1r5g5b5: + LLOGLN(0, (" PIXMAN_x1r5g5b5")); + break; + case PIXMAN_a1b5g5r5: + LLOGLN(0, (" PIXMAN_a1b5g5r5")); + break; + case PIXMAN_x1b5g5r5: + LLOGLN(0, (" PIXMAN_x1b5g5r5")); + break; + case PIXMAN_a4r4g4b4: + LLOGLN(0, (" PIXMAN_a4r4g4b4")); + break; + case PIXMAN_x4r4g4b4: + LLOGLN(0, (" PIXMAN_x4r4g4b4")); + break; + case PIXMAN_a4b4g4r4: + LLOGLN(0, (" PIXMAN_a4b4g4r4")); + break; + case PIXMAN_x4b4g4r4: + LLOGLN(0, (" PIXMAN_x4b4g4r4")); + break; + + /* 8bpp formats */ + case PIXMAN_a8: + LLOGLN(0, (" PIXMAN_a8")); + break; + case PIXMAN_r3g3b2: + LLOGLN(0, (" PIXMAN_r3g3b2")); + break; + case PIXMAN_b2g3r3: + LLOGLN(0, (" PIXMAN_b2g3r3")); + break; + case PIXMAN_a2r2g2b2: + LLOGLN(0, (" PIXMAN_a2r2g2b2")); + break; + case PIXMAN_a2b2g2r2: + LLOGLN(0, (" PIXMAN_a2b2g2r2")); + break; + + case PIXMAN_c8: + LLOGLN(0, (" PIXMAN_c8")); + break; + case PIXMAN_g8: + LLOGLN(0, (" PIXMAN_g8")); + break; + + case PIXMAN_x4a4: + LLOGLN(0, (" PIXMAN_x4a4")); + break; + + /* 4bpp formats */ + case PIXMAN_a4: + LLOGLN(0, (" PIXMAN_a4")); + break; + case PIXMAN_r1g2b1: + LLOGLN(0, (" PIXMAN_r1g2b1")); + break; + case PIXMAN_b1g2r1: + LLOGLN(0, (" PIXMAN_b1g2r1")); + break; + case PIXMAN_a1r1g1b1: + LLOGLN(0, (" PIXMAN_a1r1g1b1")); + break; + case PIXMAN_a1b1g1r1: + LLOGLN(0, (" PIXMAN_a1b1g1r1")); + break; + + case PIXMAN_c4: + LLOGLN(0, (" PIXMAN_c4")); + break; + case PIXMAN_g4: + LLOGLN(0, (" PIXMAN_g4")); + break; + + /* 1bpp formats */ + case PIXMAN_a1: + LLOGLN(0, (" PIXMAN_a1")); + break; + case PIXMAN_g1: + LLOGLN(0, (" PIXMAN_g1")); + break; + } + return 0; +} + +/******************************************************************************/ +static int +compsoite_print(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height) +{ + PixmapPtr pSrcPixmap; + PixmapPtr pDstPixmap; + rdpPixmapRec* pSrcPriv; + rdpPixmapRec* pDstPriv; + + LLOGLN(0, ("compsoite_print: op %d xSrc %d ySrc %d xDst %d yDst %d " + "width %d height %d", + op, xSrc, ySrc, xDst, yDst, width, height)); + + if (pSrc != 0) + { + LLOGLN(0, (" src depth %d width %d height %d repeat %d repeatType %d " + "dither %d filter %d alphaMap %p componentAlpha %d", pSrc->pDrawable->depth, + pSrc->pDrawable->width, pSrc->pDrawable->height, + pSrc->repeat, pSrc->repeatType, pSrc->dither, pSrc->filter, + pSrc->alphaMap, pSrc->componentAlpha)); + LLOGLN(0, (" transform %p", pSrc->transform)); + LLOGLN(0, (" detail format red %d red mask %d green %d green mask %d " + "blue %d blue mask %d", + pSrc->pFormat->direct.red, pSrc->pFormat->direct.redMask, + pSrc->pFormat->direct.green, pSrc->pFormat->direct.greenMask, + pSrc->pFormat->direct.blue, pSrc->pFormat->direct.blueMask)); + print_format(pSrc->format); + if (pSrc->pDrawable->type == DRAWABLE_PIXMAP) + { + pSrcPixmap = (PixmapPtr)(pSrc->pDrawable); + pSrcPriv = GETPIXPRIV(pSrcPixmap); + LLOGLN(0, (" DRAWABLE_PIXMAP pSrcPriv %p status %d", pSrcPriv, pSrcPriv->status)); + } + else if (pSrc->pDrawable->type == DRAWABLE_WINDOW) + { + LLOGLN(0, (" DRAWABLE_WINDOW")); + } + else + { + LLOGLN(0, (" OTHER")); + } + } + if (pMask != 0) + { + LLOGLN(0, (" msk depth %d width %d height %d repeat %d repeatType %d", + pMask->pDrawable->depth, + pMask->pDrawable->width, + pMask->pDrawable->height, pMask->repeat, pMask->repeatType)); + print_format(pMask->format); + } + if (pDst != 0) + { + LLOGLN(0, (" dst depth %d width %d height %d repeat %d repeatType %d " + "dither %d filter %d alphaMap %p", pDst->pDrawable->depth, + pDst->pDrawable->width, pDst->pDrawable->height, + pDst->repeat, pDst->repeatType, pDst->dither, pDst->filter, + pDst->alphaMap)); + LLOGLN(0, (" transform %p", pDst->transform)); + print_format(pDst->format); + if (pDst->pDrawable->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)(pDst->pDrawable); + pDstPriv = GETPIXPRIV(pDstPixmap); + LLOGLN(0, (" DRAWABLE_PIXMAP pDstPriv %p status %d", pDstPriv, pDstPriv->status)); + } + else if (pDst->pDrawable->type == DRAWABLE_WINDOW) + { + LLOGLN(0, (" DRAWABLE_WINDOW")); + } + else + { + LLOGLN(0, (" OTHER")); + } + } + return 0; +} + +/******************************************************************************/ +static int +src_alpha_needed(CARD8 op) +{ + int rv; + + rv = 0; + switch (op) + { + case 3: /* Over */ + case 6: /* InReverse */ + case 8: /* OutReverse */ + case 9: /* Atop */ + case 10: /* AtopReverse */ + case 11: /* Xor */ + case 13: /* Saturate */ + case 17: /* DisjointOver */ + case 18: /* DisjointOverReverse */ + case 19: /* DisjointIn */ + case 20: /* DisjointInReverse */ + case 21: /* DisjointOut */ + case 22: /* DisjointOutReverse */ + case 23: /* DisjointAtop */ + case 24: /* DisjointAtopReverse */ + case 25: /* DisjointXor */ + case 29: /* ConjointOver */ + case 30: /* ConjointOverReverse */ + case 31: /* ConjointIn */ + case 32: /* ConjointInReverse */ + case 33: /* ConjointOut */ + case 34: /* ConjointOutReverse */ + case 35: /* ConjointAtop */ + case 36: /* ConjointAtopReverse */ + case 37: /* ConjointXor */ + rv = 1; + break; + } + return rv; +} + +/******************************************************************************/ +static int +dst_alpha_needed(CARD8 op) +{ + int rv; + + rv = 0; + switch (op) + { + case 4: /* OverReverse */ + case 5: /* In */ + case 7: /* Out */ + case 9: /* Atop */ + case 10: /* AtopReverse */ + case 11: /* Xor */ + case 13: /* Saturate */ + case 17: /* DisjointOver */ + case 18: /* DisjointOverReverse */ + case 19: /* DisjointIn */ + case 20: /* DisjointInReverse */ + case 21: /* DisjointOut */ + case 22: /* DisjointOutReverse */ + case 23: /* DisjointAtop */ + case 24: /* DisjointAtopReverse */ + case 25: /* DisjointXor */ + case 29: /* ConjointOver */ + case 30: /* ConjointOverReverse */ + case 31: /* ConjointIn */ + case 32: /* ConjointInReverse */ + case 33: /* ConjointOut */ + case 34: /* ConjointOutReverse */ + case 35: /* ConjointAtop */ + case 36: /* ConjointAtopReverse */ + case 37: /* ConjointXor */ + rv = 1; + break; + } + return rv; +} + +struct msk_info +{ + int flags; + int idx; + int format; + int width; + int repeat; +}; + +static char g_com_fail_strings[][128] = +{ + "OK", + "src not remotable", + "dst not remotable", + "msk not remotable" +}; + +/******************************************************************************/ +/* returns boolean */ +static int +check_drawables(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height, struct msk_info* msk) +{ + int rv; + int fail_reason; + PixmapPtr pSrcPixmap; + PixmapPtr pDstPixmap; + PixmapPtr pMskPixmap; + rdpPixmapRec* pSrcPriv; + rdpPixmapRec* pDstPriv; + rdpPixmapRec* pMskPriv; + + fail_reason = 0; + pSrcPixmap = 0; + pDstPixmap = 0; + pMskPixmap = 0; + pSrcPriv = 0; + pDstPriv = 0; + pMskPriv = 0; + rv = 0; + if (pSrc != 0) + { + if (pSrc->pDrawable != 0) + { + if (pSrc->pDrawable->type == DRAWABLE_PIXMAP) + { + pSrcPixmap = (PixmapPtr)(pSrc->pDrawable); + pSrcPriv = GETPIXPRIV(pSrcPixmap); + if (xrdp_is_os(pSrcPixmap, pSrcPriv)) + { + if (pDst != 0) + { + if (pDst->pDrawable != 0) + { + if (pDst->pDrawable->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)(pDst->pDrawable); + pDstPriv = GETPIXPRIV(pDstPixmap); + if (xrdp_is_os(pDstPixmap, pDstPriv)) + { + rv = 1; + } + else + { + fail_reason = 2; + } + } + } + } + } + else + { + fail_reason = 1; + } + } + } + } + if (rv) + { + if (pMask != 0) + { +#if 1 + rv = 0; + if (pMask->pDrawable != 0) + { + if (pMask->pDrawable->type == DRAWABLE_PIXMAP) + { + pMskPixmap = (PixmapPtr)(pMask->pDrawable); + pMskPriv = GETPIXPRIV(pMskPixmap); + if (xrdp_is_os(pMskPixmap, pMskPriv)) + { + rv = 1; + msk->flags = 1; + msk->idx = pMskPriv->rdpindex; + msk->format = pMask->format; + msk->width = pMask->pDrawable->width; + msk->repeat = pMask->repeatType; + } + else + { + fail_reason = 3; + } + } + } +#endif + } + } + if (rv != 0) + { + /* TODO: figure out why source XRGB does not work + skipping for now because they rarely happen + happens when drawing Firefox open file dialog, the button icons */ + if (PIXMAN_FORMAT_A(pSrc->format) == 0) + { + rv = 0; + LLOGLN(10, ("check_drawables: src format")); + } + } + if (rv == 0) + { + LLOGLN(10, ("check_drawables: can not remote [%s]", g_com_fail_strings[fail_reason])); +#if 0 + compsoite_print(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, + xDst, yDst, width, height); +#endif + } + else + { + LLOGLN(10, ("check_drawables: can remote [%s]", g_com_fail_strings[fail_reason])); +#if 0 + compsoite_print(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, + xDst, yDst, width, height); +#endif + } + return rv; +} + +/******************************************************************************/ +static int +rdpRemoteComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height) +{ + int ok_to_remote; + PixmapPtr pSrcPixmap; + PixmapPtr pMskPixmap; + PixmapPtr pDstPixmap; + rdpPixmapRec* pSrcPriv; + rdpPixmapRec* pMskPriv; + rdpPixmapRec* pDstPriv; + BoxRec box; + RegionRec reg1; + RegionRec reg2; + DrawablePtr p; + int j; + int num_clips; + struct msk_info msk; + + LLOGLN(10, ("rdpRemoteComposite:")); + + memset(&msk, 0, sizeof(msk)); + ok_to_remote = check_drawables(op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height, + &msk); + if (!ok_to_remote) + { + return 1; + } + + ValidatePicture(pSrc); + pSrcPixmap = (PixmapPtr)(pSrc->pDrawable); + pSrcPriv = GETPIXPRIV(pSrcPixmap); + rdpup_check_dirty(pSrcPixmap, pSrcPriv); + if (PIXMAN_FORMAT_A(pSrc->format) > 0) + { + if (src_alpha_needed(op)) + { + rdpup_check_alpha_dirty(pSrcPixmap, pSrcPriv); + } + } + + ValidatePicture(pDst); + pDstPixmap = (PixmapPtr)(pDst->pDrawable); + pDstPriv = GETPIXPRIV(pDstPixmap); + rdpup_check_dirty(pDstPixmap, pDstPriv); + + if (PIXMAN_FORMAT_A(pDst->format) > 0) + { + if (dst_alpha_needed(op)) + { + rdpup_check_alpha_dirty(pDstPixmap, pDstPriv); + } + } + + if (pMask != 0) + { + ValidatePicture(pMask); + pMskPixmap = (PixmapPtr)(pMask->pDrawable); + pMskPriv = GETPIXPRIV(pMskPixmap); + rdpup_check_dirty(pMskPixmap, pMskPriv); + if (PIXMAN_FORMAT_A(msk.format) > 0) + { + rdpup_check_alpha_dirty(pMskPixmap, pMskPriv); + } + } + + p = pDst->pDrawable; + rdpup_switch_os_surface(pDstPriv->rdpindex); + if (pDst->pCompositeClip != 0) + { + box.x1 = xDst; + box.y1 = yDst; + box.x2 = box.x1 + width; + box.y2 = box.y1 + height; + RegionInit(®1, &box, 0); + RegionInit(®2, NullBox, 0); + RegionCopy(®2, pDst->pCompositeClip); + RegionIntersect(®1, ®1, ®2); + RegionTranslate(®1, p->x, p->y); + num_clips = REGION_NUM_RECTS(®1); + if (num_clips > 0) + { + LLOGLN(10, ("num_clips %d", num_clips)); + rdpup_begin_update(); + for (j = num_clips - 1; j >= 0; j--) + { + box = REGION_RECTS(®1)[j]; + rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + LLOGLN(10, ("pSrc->format 0x%x 0x%x 0x%x %d %d %d %d %d %d %d %d", + pSrc->format, msk.format, pDst->format, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height)); + rdpup_composite(pSrcPriv->rdpindex, pSrc->format, + pSrc->pDrawable->width, pSrc->repeatType, + pSrc->transform, msk.flags, msk.idx, msk.format, + msk.width, msk.repeat, op, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height, pDst->format); + } + rdpup_reset_clip(); + rdpup_end_update(); + } + RegionUninit(®1); + RegionUninit(®2); + } + else + { + rdpup_begin_update(); + rdpup_composite(pSrcPriv->rdpindex, pSrc->format, + pSrc->pDrawable->width, pSrc->repeatType, + pSrc->transform, msk.flags, msk.idx, msk.format, + msk.width, msk.repeat, op, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height, pDst->format); + rdpup_end_update(); + } + rdpup_switch_os_surface(-1); + + return 0; +} + +/******************************************************************************/ +static void +rdpCompositeOrg(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height) +{ + PictureScreenPtr ps; + + ps = GetPictureScreen(g_pScreen); + ps->Composite = g_rdpScreen.Composite; + ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height); + ps->Composite = rdpComposite; +} + +/******************************************************************************/ +/* it looks like all the antialias draws go through here + op is one of the following + #define PictOpMinimum 0 + #define PictOpClear 0 + #define PictOpSrc 1 + #define PictOpDst 2 + #define PictOpOver 3 + #define PictOpOverReverse 4 + #define PictOpIn 5 + #define PictOpInReverse 6 + #define PictOpOut 7 + #define PictOpOutReverse 8 + #define PictOpAtop 9 + #define PictOpAtopReverse 10 + #define PictOpXor 11 + #define PictOpAdd 12 + #define PictOpSaturate 13 + #define PictOpMaximum 13 + + see for porter duff + http://www.svgopen.org/2005/papers/abstractsvgopen/ + + */ +void +rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height) +{ + BoxRec box; + RegionRec reg1; + RegionRec reg2; + DrawablePtr p; + int dirty_type; + int j; + int num_clips; + int post_process; + int reset_surface; + int got_id; + WindowPtr pDstWnd; + PixmapPtr pDstPixmap; + rdpPixmapRec* pDstPriv; + rdpPixmapRec* pDirtyPriv; + struct image_data id; + + LLOGLN(10, ("rdpComposite:")); + + if (g_doing_font == 2) + { + rdpCompositeOrg(op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height); + + return; + } + +#if 0 + if (g_do_glyph_cache && g_do_alpha_glyphs) + { + if (pSrc->pDrawable->width == 1 && + pSrc->pDrawable->height == 1) + { + if (pMask != 0) + { + /* TODO: here we can try to send it as a gylph */ + } + } + } +#endif + + /* try to remote the composite call */ + if (g_do_composite && + rdpRemoteComposite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, + xDst, yDst, width, height) == 0) + { + rdpCompositeOrg(op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height); + return; + } + + rdpCompositeOrg(op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height); + + LLOGLN(10, ("rdpComposite: op %d %p %p %p w %d h %d", op, pSrc, pMask, pDst, width, height)); + + p = pDst->pDrawable; + + pDstPriv = 0; + dirty_type = 0; + pDirtyPriv = 0; + post_process = 0; + reset_surface = 0; + got_id = 0; + if (p->type == DRAWABLE_PIXMAP) + { + pDstPixmap = (PixmapPtr)p; + pDstPriv = GETPIXPRIV(pDstPixmap); + if (XRDP_IS_OS(pDstPriv)) + { + post_process = 1; + if (g_do_dirty_os) + { + LLOGLN(10, ("rdpComposite: gettig dirty")); + pDstPriv->is_dirty = 1; + dirty_type = g_doing_font ? RDI_IMGLL : RDI_IMGLY; + pDirtyPriv = pDstPriv; + } + else + { + rdpup_switch_os_surface(pDstPriv->rdpindex); + reset_surface = 1; + rdpup_get_pixmap_image_rect(pDstPixmap, &id); + got_id = 1; + LLOGLN(10, ("rdpComposite: offscreen")); + } + } + } + else + { + if (p->type == DRAWABLE_WINDOW) + { + pDstWnd = (WindowPtr)p; + if (pDstWnd->viewable) + { + post_process = 1; + rdpup_get_screen_image_rect(&id); + got_id = 1; + LLOGLN(10, ("rdpComposite: screen")); + } + } + } + + if (!post_process) + { + return; + } + + if (pDst->pCompositeClip != 0) + { + box.x1 = p->x + xDst; + box.y1 = p->y + yDst; + box.x2 = box.x1 + width; + box.y2 = box.y1 + height; + RegionInit(®1, &box, 0); + RegionInit(®2, NullBox, 0); + RegionCopy(®2, pDst->pCompositeClip); + RegionIntersect(®1, ®1, ®2); + if (dirty_type != 0) + { + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COMPOSITE); + } + else if (got_id) + { + num_clips = REGION_NUM_RECTS(®1); + if (num_clips > 0) + { + rdpup_begin_update(); + for (j = num_clips - 1; j >= 0; j--) + { + box = REGION_RECTS(®1)[j]; + rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + } + rdpup_end_update(); + } + } + RegionUninit(®1); + RegionUninit(®2); + } + else + { + box.x1 = p->x + xDst; + box.y1 = p->y + yDst; + box.x2 = box.x1 + width; + box.y2 = box.y1 + height; + if (dirty_type != 0) + { + RegionInit(®1, &box, 0); + draw_item_add_img_region(pDirtyPriv, ®1, GXcopy, dirty_type, TAG_COMPOSITE); + RegionUninit(®1); + } + else if (got_id) + { + rdpup_begin_update(); + rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1); + rdpup_end_update(); + } + } + if (reset_surface) + { + rdpup_switch_os_surface(-1); + } +} + +/******************************************************************************/ +/* make sure no glyph is too big */ +/* returns boolean */ +static int +rdpGlyphCheck(int nlist, GlyphListPtr list, GlyphPtr* glyphs) +{ + int n; + GlyphPtr glyph; + + while (nlist--) + { + n = list->len; + list++; + while (n--) + { + glyph = *glyphs++; + if ((glyph->info.width * glyph->info.height) > 8192) + { + LLOGLN(10, ("rdpGlyphCheck: too big")); + return 0; + } + } + } + return 1; +} + +/******************************************************************************/ +void +rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, + GlyphPtr* glyphs) +{ + PictureScreenPtr ps; + + LLOGLN(10, ("rdpGlyphs: op %d xSrc %d ySrc %d maskFormat %p", op, xSrc, ySrc, maskFormat)); + + if (g_do_glyph_cache && rdpGlyphCheck(nlists, lists, glyphs)) + { + g_doing_font = 2; + rdpGlyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists, glyphs); + ps = GetPictureScreen(g_pScreen); + ps->Glyphs = g_rdpScreen.Glyphs; + ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlists, lists, glyphs); + ps->Glyphs = rdpGlyphs; + } + else + { + g_doing_font = 1; + rdpup_set_hints(1, 1); + ps = GetPictureScreen(g_pScreen); + ps->Glyphs = g_rdpScreen.Glyphs; + ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlists, lists, glyphs); + ps->Glyphs = rdpGlyphs; + rdpup_set_hints(0, 1); + } + g_doing_font = 0; + LLOGLN(10, ("rdpGlyphs: out")); +} From d963774fe8d4892427f0de25f458c991797ca80b Mon Sep 17 00:00:00 2001 From: Jim Grandy Date: Mon, 8 Jul 2013 16:22:38 -0700 Subject: [PATCH 28/31] rdpup: use out_uint8s instead of out_uint8; rdpdraw.c: resolve bad merge with rdp_is_os, and use a temporary value as final parameter to draw_item_add_img_region --- xorg/X11R7.6/rdp/rdpdraw.c | 63 ++------------------------------------ xorg/X11R7.6/rdp/rdpup.c | 12 ++++---- 2 files changed, 8 insertions(+), 67 deletions(-) diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index 0fb8ff4f..99ada0c5 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -1084,65 +1084,6 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv) return 1; } -/*****************************************************************************/ -int -xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv) -{ - RegionRec reg1; - BoxRec box; - int width; - int height; - struct image_data id; - - if (!XRDP_IS_OS(priv)) - { - width = pix->drawable.width; - height = pix->drawable.height; - if ((pix->usage_hint == 0) && - (pix->drawable.depth >= g_rdpScreen.depth) && - (width > 1) && (height > 1) && (priv->kind_width > 0)) - { - LLOGLN(10, ("%d %d", priv->kind_width, pix->drawable.width)); - priv->rdpindex = rdpup_add_os_bitmap(pix, priv); - if (priv->rdpindex >= 0) - { - priv->status = 1; - rdpup_create_os_surface(priv->rdpindex, - priv->kind_width, height); - box.x1 = 0; - box.y1 = 0; - box.x2 = width; - box.y2 = height; - if (g_do_dirty_os) - { - if (priv->con_number != g_con_number) - { - draw_item_remove_all(priv); - RegionInit(®1, &box, 0); - draw_item_add_img_region(priv, ®1, GXcopy, RDI_IMGLL); - RegionUninit(®1); - priv->is_dirty = 1; - priv->con_number = g_con_number; - } - } - else - { - rdpup_get_pixmap_image_rect(pix, &id); - rdpup_switch_os_surface(priv->rdpindex); - rdpup_begin_update(); - rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, - box.y2 - box.y1); - rdpup_end_update(); - rdpup_switch_os_surface(-1); - } - return 1; - } - } - return 0; - } - return 1; -} - /******************************************************************************/ Bool rdpCreateWindow(WindowPtr pWindow) @@ -1480,7 +1421,7 @@ rdpClearToBackground(WindowPtr pWin, int x, int y, int w, int h, if (g_do_dirty_ons) { - draw_item_add_img_region(&g_screenPriv, ®, GXcopy, RDI_IMGLL); + draw_item_add_img_region(&g_screenPriv, ®, GXcopy, RDI_IMGLL, 16); } else { @@ -1518,7 +1459,7 @@ rdpRestoreAreas(WindowPtr pWin, RegionPtr prgnExposed) if (g_do_dirty_ons) { - draw_item_add_img_region(&g_screenPriv, ®, GXcopy, RDI_IMGLL); + draw_item_add_img_region(&g_screenPriv, ®, GXcopy, RDI_IMGLL, 16); } else { diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index bf8aea1c..1903b0c0 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -1507,7 +1507,7 @@ rdpup_create_os_surface_bpp(int rdpindex, int width, int height, int bpp) out_uint32_le(g_out_s, rdpindex); out_uint16_le(g_out_s, width); out_uint16_le(g_out_s, height); - out_uint8(g_out_s, bpp); + out_uint8s(g_out_s, bpp); } return 0; } @@ -1857,7 +1857,7 @@ rdpup_send_alpha_area(struct image_data* id, int x, int y, int w, int h) out_uint16_le(g_out_s, lh); out_uint16_le(g_out_s, 0); out_uint16_le(g_out_s, 0); - out_uint8(g_out_s, 8); + out_uint8s(g_out_s, 8); lx += 64; } ly += 64; @@ -2465,7 +2465,7 @@ rdpup_composite(short srcidx, int srcformat, short srcwidth, CARD8 srcrepeat, out_uint16_le(g_out_s, srcidx); out_uint32_le(g_out_s, srcformat); out_uint16_le(g_out_s, srcwidth); - out_uint8(g_out_s, srcrepeat); + out_uint8s(g_out_s, srcrepeat); if (srctransform == 0) { out_uint8s(g_out_s, 10 * 4); @@ -2483,12 +2483,12 @@ rdpup_composite(short srcidx, int srcformat, short srcwidth, CARD8 srcrepeat, out_uint32_le(g_out_s, srctransform->matrix[2][1]); out_uint32_le(g_out_s, srctransform->matrix[2][2]); } - out_uint8(g_out_s, mskflags); + out_uint8s(g_out_s, mskflags); out_uint16_le(g_out_s, mskidx); out_uint32_le(g_out_s, mskformat); out_uint16_le(g_out_s, mskwidth); - out_uint8(g_out_s, mskrepeat); - out_uint8(g_out_s, op); + out_uint8s(g_out_s, mskrepeat); + out_uint8s(g_out_s, op); out_uint16_le(g_out_s, srcx); out_uint16_le(g_out_s, srcy); out_uint16_le(g_out_s, mskx); From a1b4baddc66b783a4779f29ead9bf537b2cc17ed Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Fri, 12 Jul 2013 11:08:22 -0700 Subject: [PATCH 29/31] part of merge, move all glyph calls to rdpglyph.c --- xorg/X11R7.6/rdp/rdpComposite.c | 68 ++------------------------------ xorg/X11R7.6/rdp/rdpglyph.c | 69 ++++++++++++++++++++++++++++++++- xorg/X11R7.6/rdp/rdpglyph.h | 4 +- 3 files changed, 73 insertions(+), 68 deletions(-) diff --git a/xorg/X11R7.6/rdp/rdpComposite.c b/xorg/X11R7.6/rdp/rdpComposite.c index 8528c4c6..ec161994 100644 --- a/xorg/X11R7.6/rdp/rdpComposite.c +++ b/xorg/X11R7.6/rdp/rdpComposite.c @@ -697,9 +697,9 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, rdpPixmapRec* pDstPriv; rdpPixmapRec* pDirtyPriv; struct image_data id; - + LLOGLN(10, ("rdpComposite:")); - + if (g_doing_font == 2) { rdpCompositeOrg(op, pSrc, pMask, pDst, xSrc, ySrc, @@ -707,7 +707,7 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, return; } - + #if 0 if (g_do_glyph_cache && g_do_alpha_glyphs) { @@ -844,65 +844,3 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, rdpup_switch_os_surface(-1); } } - -/******************************************************************************/ -/* make sure no glyph is too big */ -/* returns boolean */ -static int -rdpGlyphCheck(int nlist, GlyphListPtr list, GlyphPtr* glyphs) -{ - int n; - GlyphPtr glyph; - - while (nlist--) - { - n = list->len; - list++; - while (n--) - { - glyph = *glyphs++; - if ((glyph->info.width * glyph->info.height) > 8192) - { - LLOGLN(10, ("rdpGlyphCheck: too big")); - return 0; - } - } - } - return 1; -} - -/******************************************************************************/ -void -rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, - GlyphPtr* glyphs) -{ - PictureScreenPtr ps; - - LLOGLN(10, ("rdpGlyphs: op %d xSrc %d ySrc %d maskFormat %p", op, xSrc, ySrc, maskFormat)); - - if (g_do_glyph_cache && rdpGlyphCheck(nlists, lists, glyphs)) - { - g_doing_font = 2; - rdpGlyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists, glyphs); - ps = GetPictureScreen(g_pScreen); - ps->Glyphs = g_rdpScreen.Glyphs; - ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, - nlists, lists, glyphs); - ps->Glyphs = rdpGlyphs; - } - else - { - g_doing_font = 1; - rdpup_set_hints(1, 1); - ps = GetPictureScreen(g_pScreen); - ps->Glyphs = g_rdpScreen.Glyphs; - ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, - nlists, lists, glyphs); - ps->Glyphs = rdpGlyphs; - rdpup_set_hints(0, 1); - } - g_doing_font = 0; - LLOGLN(10, ("rdpGlyphs: out")); -} diff --git a/xorg/X11R7.6/rdp/rdpglyph.c b/xorg/X11R7.6/rdp/rdpglyph.c index e6e011be..af1d28ec 100644 --- a/xorg/X11R7.6/rdp/rdpglyph.c +++ b/xorg/X11R7.6/rdp/rdpglyph.c @@ -52,6 +52,11 @@ extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */ extern int g_do_dirty_os; /* in rdpmain.c */ extern int g_do_alpha_glyphs; /* in rdpmain.c */ +extern int g_do_glyph_cache; /* in rdpmain.c */ +extern int g_doing_font; /* in rdpmain.c */ +extern ScreenPtr g_pScreen; /* in rdpmain.c */ +extern rdpScreenInfoRec g_rdpScreen; /* in rdpmain.c */ + #define LOG_LEVEL 1 #define LLOG(_level, _args) \ @@ -763,7 +768,7 @@ GlyphExtents(int nlist, GlyphListPtr list, GlyphPtr* glyphs, BoxPtr extents) } /******************************************************************************/ -void +static void rdpGlypht(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, GlyphPtr* glyphs) @@ -779,6 +784,68 @@ rdpGlypht(CARD8 op, PicturePtr pSrc, PicturePtr pDst, glyphs, &extents); } +/******************************************************************************/ +/* make sure no glyph is too big */ +/* returns boolean */ +static int +rdpGlyphCheck(int nlist, GlyphListPtr list, GlyphPtr* glyphs) +{ + int n; + GlyphPtr glyph; + + while (nlist--) + { + n = list->len; + list++; + while (n--) + { + glyph = *glyphs++; + if ((glyph->info.width * glyph->info.height) > 8192) + { + LLOGLN(10, ("rdpGlyphCheck: too big")); + return 0; + } + } + } + return 1; +} + +/******************************************************************************/ +void +rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, + GlyphPtr* glyphs) +{ + PictureScreenPtr ps; + + LLOGLN(0, ("rdpGlyphs: op %d xSrc %d ySrc %d maskFormat %p", op, xSrc, ySrc, maskFormat)); + + if (g_do_glyph_cache && rdpGlyphCheck(nlists, lists, glyphs)) + { + g_doing_font = 2; + rdpGlypht(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists, glyphs); + ps = GetPictureScreen(g_pScreen); + ps->Glyphs = g_rdpScreen.Glyphs; + ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlists, lists, glyphs); + ps->Glyphs = rdpGlyphs; + } + else + { + g_doing_font = 1; + rdpup_set_hints(1, 1); + ps = GetPictureScreen(g_pScreen); + ps->Glyphs = g_rdpScreen.Glyphs; + ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlists, lists, glyphs); + ps->Glyphs = rdpGlyphs; + rdpup_set_hints(0, 1); + } + g_doing_font = 0; + LLOGLN(0, ("rdpGlyphs: out")); +} + /******************************************************************************/ int rdpGlyphInit(void) diff --git a/xorg/X11R7.6/rdp/rdpglyph.h b/xorg/X11R7.6/rdp/rdpglyph.h index 6bc6a9b3..6907f9e7 100644 --- a/xorg/X11R7.6/rdp/rdpglyph.h +++ b/xorg/X11R7.6/rdp/rdpglyph.h @@ -1,5 +1,5 @@ /* -Copyright 2012 Jay Sorg +Copyright 2012-2013 Jay Sorg Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that @@ -55,7 +55,7 @@ int rdp_text_chars_to_data(struct rdp_text* rtext); void -rdpGlypht(CARD8 op, PicturePtr pSrc, PicturePtr pDst, +rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, GlyphPtr* glyphs); int From f5fddc1a57634eea142da4fceff6202304675d98 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Fri, 12 Jul 2013 12:21:20 -0700 Subject: [PATCH 30/31] part of merge, composite, out_uint8s fixes --- xorg/X11R7.6/rdp/rdp.h | 17 ++++++++--------- xorg/X11R7.6/rdp/rdpglyph.c | 5 +++-- xorg/X11R7.6/rdp/rdpup.c | 17 +++++++++++------ 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h index 85a52645..c2d94430 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -454,10 +454,7 @@ rdpRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed); /* rdpglyph.c */ -void -rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, - int nlists, GlyphListPtr lists, GlyphPtr* glyphs); +/* look in rdpglyph.h */ /* rdpComposite.c */ int @@ -468,11 +465,6 @@ void rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); -void -rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, - GlyphPtr* glyphs); /* rdpinput.c */ int @@ -668,6 +660,13 @@ struct stream } #endif +/******************************************************************************/ +#define out_uint8(s, v) \ +{ \ + *((s)->p) = (unsigned char)((v) >> 0); \ + (s)->p++; \ +} + /******************************************************************************/ #define init_stream(s, v) \ { \ diff --git a/xorg/X11R7.6/rdp/rdpglyph.c b/xorg/X11R7.6/rdp/rdpglyph.c index af1d28ec..11a45ee7 100644 --- a/xorg/X11R7.6/rdp/rdpglyph.c +++ b/xorg/X11R7.6/rdp/rdpglyph.c @@ -819,7 +819,8 @@ rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, { PictureScreenPtr ps; - LLOGLN(0, ("rdpGlyphs: op %d xSrc %d ySrc %d maskFormat %p", op, xSrc, ySrc, maskFormat)); + LLOGLN(10, ("rdpGlyphs: op %d xSrc %d ySrc %d maskFormat %p", + op, xSrc, ySrc, maskFormat)); if (g_do_glyph_cache && rdpGlyphCheck(nlists, lists, glyphs)) { @@ -843,7 +844,7 @@ rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, rdpup_set_hints(0, 1); } g_doing_font = 0; - LLOGLN(0, ("rdpGlyphs: out")); + LLOGLN(10, ("rdpGlyphs: out")); } /******************************************************************************/ diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index 1903b0c0..e3a484b0 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -132,6 +132,7 @@ rdpup_disconnect(void) { int index; + LLOGLN(0, ("rdpup_disconnect:")); RemoveEnabledDevice(g_sck); g_connected = 0; g_tcp_close(g_sck); @@ -293,12 +294,14 @@ rdpup_send(char *data, int len) } else { + LLOGLN(0, ("rdpup_send: g_tcp_send failed(returned -1)")); rdpup_disconnect(); return 1; } } else if (sent == 0) { + LLOGLN(0, ("rdpup_send: g_tcp_send failed(returned zero)")); rdpup_disconnect(); return 1; } @@ -425,12 +428,14 @@ rdpup_recv(char *data, int len) } else { + LLOGLN(0, ("rdpup_recv: g_tcp_recv failed(returned -1)")); rdpup_disconnect(); return 1; } } else if (rcvd == 0) { + LLOGLN(0, ("rdpup_recv: g_tcp_recv failed(returned 0)")); rdpup_disconnect(); return 1; } @@ -1507,7 +1512,7 @@ rdpup_create_os_surface_bpp(int rdpindex, int width, int height, int bpp) out_uint32_le(g_out_s, rdpindex); out_uint16_le(g_out_s, width); out_uint16_le(g_out_s, height); - out_uint8s(g_out_s, bpp); + out_uint8(g_out_s, bpp); } return 0; } @@ -1857,7 +1862,7 @@ rdpup_send_alpha_area(struct image_data* id, int x, int y, int w, int h) out_uint16_le(g_out_s, lh); out_uint16_le(g_out_s, 0); out_uint16_le(g_out_s, 0); - out_uint8s(g_out_s, 8); + out_uint8(g_out_s, 8); lx += 64; } ly += 64; @@ -2465,7 +2470,7 @@ rdpup_composite(short srcidx, int srcformat, short srcwidth, CARD8 srcrepeat, out_uint16_le(g_out_s, srcidx); out_uint32_le(g_out_s, srcformat); out_uint16_le(g_out_s, srcwidth); - out_uint8s(g_out_s, srcrepeat); + out_uint8(g_out_s, srcrepeat); if (srctransform == 0) { out_uint8s(g_out_s, 10 * 4); @@ -2483,12 +2488,12 @@ rdpup_composite(short srcidx, int srcformat, short srcwidth, CARD8 srcrepeat, out_uint32_le(g_out_s, srctransform->matrix[2][1]); out_uint32_le(g_out_s, srctransform->matrix[2][2]); } - out_uint8s(g_out_s, mskflags); + out_uint8(g_out_s, mskflags); out_uint16_le(g_out_s, mskidx); out_uint32_le(g_out_s, mskformat); out_uint16_le(g_out_s, mskwidth); - out_uint8s(g_out_s, mskrepeat); - out_uint8s(g_out_s, op); + out_uint8(g_out_s, mskrepeat); + out_uint8(g_out_s, op); out_uint16_le(g_out_s, srcx); out_uint16_le(g_out_s, srcy); out_uint16_le(g_out_s, mskx); From 997be5d621adf14c03d3a00d4dda52fc3cf51b74 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Fri, 12 Jul 2013 12:22:48 -0700 Subject: [PATCH 31/31] part of merge, no logic change, add -g to Makefile and LLOGLN to xup.c --- xorg/X11R7.6/rdp/Makefile | 2 +- xup/xup.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/xorg/X11R7.6/rdp/Makefile b/xorg/X11R7.6/rdp/Makefile index b38d27c0..3b84c43c 100644 --- a/xorg/X11R7.6/rdp/Makefile +++ b/xorg/X11R7.6/rdp/Makefile @@ -43,7 +43,7 @@ LIBS = $(XSRCBASE)/dbe/.libs/libdbe.a \ LLIBS = -Wl,-rpath=$(LIBBASE) -lfreetype -lz -lm -lXfont -lXau \ -lXdmcp -lpixman-1 -lrt -ldl -lcrypto -lGL -lXdamage -CFLAGS = -O2 -Wall -fno-strength-reduce \ +CFLAGS = -g -O2 -Wall -fno-strength-reduce \ -I../../include \ -I../../cfb \ -I../../mfb \ diff --git a/xup/xup.c b/xup/xup.c index acac30a4..9d61d7d3 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -20,6 +20,12 @@ #include "xup.h" +#define LOG_LEVEL 1 +#define LLOG(_level, _args) \ + do { if (_level < LOG_LEVEL) { g_write _args ; } } while (0) +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { g_writeln _args ; } } while (0) + /******************************************************************************/ /* returns error */ int DEFAULT_CC