xfreerdp, wfreerdp: Add -T option to set window title

This commit is contained in:
bluebird 2011-12-02 15:58:38 +01:00
parent c900284014
commit a40f5c1718
5 changed files with 38 additions and 11 deletions

View File

@ -253,12 +253,12 @@ boolean wf_post_connect(freerdp* instance)
wfi->hdc->hwnd->ninvalid = 0;
}
if (strlen(wfi->window_title) > 0)
_snwprintf(win_title, sizeof(win_title), L"%S", wfi->window_title);
if (strlen(settings->window_title) > 0)
_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"%S - FreeRDP", settings->hostname);
_snwprintf(win_title, sizeof(win_title) / sizeof(win_title[0]), L"FreeRDP: %S", settings->hostname);
else
_snwprintf(win_title, sizeof(win_title) / sizeof(win_title[0]), L"%S:%d - FreeRDP", settings->hostname, settings->port);
_snwprintf(win_title, sizeof(win_title) / sizeof(win_title[0]), L"FreeRDP: %S:%d", settings->hostname, settings->port);
if (wfi->hwnd == 0)
{

View File

@ -91,6 +91,14 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-T <replaceable class="parameter">text</replaceable></term>
<listitem>
<para>
Sets the window title to <replaceable class="parameter">text</replaceable>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-g <replaceable class="parameter">geometry</replaceable></term>
<listitem>

View File

@ -277,8 +277,7 @@ boolean xf_check_fds(freerdp* instance, fd_set* set)
void xf_create_window(xfInfo* xfi)
{
XEvent xevent;
char* title;
char* hostname;
char* win_title;
int width, height;
width = xfi->width;
@ -298,12 +297,19 @@ void xf_create_window(xfInfo* xfi)
height = xfi->fullscreen ? HeightOfScreen(xfi->screen) : xfi->height;
}
hostname = xfi->instance->settings->hostname;
title = xmalloc(sizeof("FreeRDP: ") + strlen(hostname));
sprintf(title, "FreeRDP: %s", hostname);
if (strlen(xfi->instance->settings->window_title) > 0) {
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) {
win_title = xmalloc(sizeof("FreeRDP: ") + strlen(xfi->instance->settings->hostname));
sprintf(win_title, "FreeRDP: %s", xfi->instance->settings->hostname);
} 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);
}
xfi->window = xf_CreateDesktopWindow(xfi, title, width, height, xfi->decorations);
xfree(title);
xfi->window = xf_CreateDesktopWindow(xfi, win_title, width, height, xfi->decorations);
xfree(win_title);
if (xfi->fullscreen)
xf_SetWindowFullscreen(xfi, xfi->window, xfi->fullscreen);

View File

@ -227,6 +227,7 @@ struct rdp_settings
uint32 percent_screen; /* 85 */
boolean mouse_motion; /* 86 */
uint32 paddingD[112 - 87]; /* 87 */
char window_title[64];
/* Internal Parameters */
char* home_path; /* 112 */

View File

@ -62,6 +62,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
" -a: set color depth in bit, default is 16\n"
" -c: initial working directory\n"
" -D: hide window decorations\n"
" -T: window title\n"
" -d: domain\n"
" -f: fullscreen mode\n"
" -g: set geometry, using format WxH or X%% or 'workarea', default is 1024x768\n"
@ -209,6 +210,17 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
{
settings->decorations = false;
}
else if (strcmp("-T", argv[index]) == 0)
{
index++;
if (index == argc)
{
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;
}
else if (strcmp("-t", argv[index]) == 0)
{
index++;