xfreerdp: add -X option for reparenting window

This commit is contained in:
Marc-André Moreau 2011-12-09 13:53:19 -05:00
parent 80add94130
commit 904a9a7c6a
7 changed files with 56 additions and 11 deletions

View File

@ -253,7 +253,7 @@ boolean wf_post_connect(freerdp* instance)
wfi->hdc->hwnd->ninvalid = 0;
}
if (strlen(settings->window_title) > 0)
if (settings->window_title != NULL)
_snwprintf(win_title, sizeof(win_title), L"%S", settings->window_title);
else if (settings->port == 3389)
_snwprintf(win_title, sizeof(win_title) / sizeof(win_title[0]), L"FreeRDP: %S", settings->hostname);

View File

@ -299,13 +299,18 @@ void xf_create_window(xfInfo* xfi)
height = xfi->fullscreen ? HeightOfScreen(xfi->screen) : xfi->height;
}
if (strlen(xfi->instance->settings->window_title) > 0) {
if (xfi->instance->settings->window_title != NULL)
{
win_title = xmalloc(sizeof(xfi->instance->settings->window_title));
sprintf(win_title, "%s", xfi->instance->settings->window_title);
} else if (xfi->instance->settings->port == 3389) {
}
else if (xfi->instance->settings->port == 3389)
{
win_title = xmalloc(sizeof("FreeRDP: ") + strlen(xfi->instance->settings->hostname));
sprintf(win_title, "FreeRDP: %s", xfi->instance->settings->hostname);
} else {
}
else
{
win_title = xmalloc(sizeof("FreeRDP: ") + strlen(xfi->instance->settings->hostname) + sizeof(":00000"));
sprintf(win_title, "FreeRDP: %s:%i", xfi->instance->settings->hostname, xfi->instance->settings->port);
}
@ -313,6 +318,9 @@ void xf_create_window(xfInfo* xfi)
xfi->window = xf_CreateDesktopWindow(xfi, win_title, width, height, xfi->decorations);
xfree(win_title);
if (xfi->parent_window)
XReparentWindow(xfi->display, xfi->window->handle, xfi->parent_window, 0, 0);
if (xfi->fullscreen)
xf_SetWindowFullscreen(xfi, xfi->window, xfi->fullscreen);
@ -469,6 +477,7 @@ boolean xf_pre_connect(freerdp* instance)
if (xfi->display == NULL)
{
printf("xf_pre_connect: failed to open display: %s\n", XDisplayName(NULL));
printf("Please check that the $DISPLAY environment variable is properly set.\n");
return false;
}
@ -517,6 +526,7 @@ boolean xf_pre_connect(freerdp* instance)
xfi->grab_keyboard = settings->grab_keyboard;
xfi->fullscreen_toggle = true;
xfi->sw_gdi = settings->sw_gdi;
xfi->parent_window = (Window) settings->parent_window_xid;
xf_detect_monitors(xfi, settings);

View File

@ -107,6 +107,7 @@ struct xf_info
int current_desktop;
boolean remote_app;
HCLRCONV clrconv;
Window parent_window;
HGDI_DC hdc;
boolean sw_gdi;
@ -128,6 +129,7 @@ struct xf_info
void* nsc_context;
void* xv_context;
void* clipboard_context;
Atom _NET_WM_ICON;
Atom _MOTIF_WM_HINTS;
Atom _NET_CURRENT_DESKTOP;

View File

@ -57,5 +57,6 @@
#endif
#define IFCALL(_cb, ...) do { if (_cb != NULL) { _cb( __VA_ARGS__ ); } } while (0)
#define IFCALLRET(_cb, _ret, ...) do { if (_cb != NULL) { _ret = _cb( __VA_ARGS__ ); } } while (0)
#endif

View File

@ -226,8 +226,9 @@ struct rdp_settings
boolean decorations; /* 84 */
uint32 percent_screen; /* 85 */
boolean mouse_motion; /* 86 */
uint32 paddingD[112 - 87]; /* 87 */
char window_title[64];
char* window_title; /* 87 */
uint64 parent_window_xid; /* 88 */
uint32 paddingD[112 - 89]; /* 89 */
/* Internal Parameters */
char* home_path; /* 112 */

View File

@ -31,13 +31,19 @@
boolean freerdp_connect(freerdp* instance)
{
rdpRdp* rdp;
boolean status;
boolean status = false;
rdp = instance->context->rdp;
extension_pre_connect(rdp->extension);
IFCALL(instance->PreConnect, instance);
IFCALLRET(instance->PreConnect, status, instance);
if (status != true)
{
printf("freerdp_pre_connect failed\n");
return false;
}
status = rdp_client_connect(rdp);
@ -52,7 +58,13 @@ boolean freerdp_connect(freerdp* instance)
extension_post_connect(rdp->extension);
IFCALL(instance->PostConnect, instance);
IFCALLRET(instance->PostConnect, status, instance);
if (status != true)
{
printf("freerdp_post_connect failed\n");
return false;
}
if (instance->settings->play_rfx)
{

View File

@ -77,6 +77,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
" -t: alternative port number, default is 3389\n"
" -u: username\n"
" -x: performance flags (m[odem], b[roadband] or l[an])\n"
" -X: embed into another window with a given XID.\n"
" -z: enable compression\n"
" --app: RemoteApp connection. This implies -g workarea\n"
" --ext: load an extension\n"
@ -218,8 +219,8 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
printf("missing window title\n");
return -1;
}
strncpy(settings->window_title, argv[index], sizeof(settings->window_title) - 1);
settings->window_title[sizeof(settings->window_title) - 1] = 0;
settings->window_title = xstrdup(argv[index]);
}
else if (strcmp("-t", argv[index]) == 0)
{
@ -423,6 +424,24 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
settings->performance_flags = strtol(argv[index], 0, 16);
}
}
else if (strcmp("-X", argv[index]) == 0)
{
index++;
if (index == argc)
{
printf("missing parent window XID\n");
return -1;
}
settings->parent_window_xid = strtoul(argv[index], NULL, 16);
if (settings->parent_window_xid == 0)
{
printf("invalid parent window XID\n");
return -1;
}
}
else if (strcmp("--no-rdp", argv[index]) == 0)
{
settings->rdp_security = false;