return status;
}
+static char* xf_window_get_title(rdpSettings* settings)
+{
+ BOOL port;
+ char* windowTitle;
+ size_t size;
+ char* name;
+ const char* prefix = "FreeRDP:";
+
+ if (!settings)
+ return NULL;
+
+ name = settings->ServerHostname;
+
+ if (settings->WindowTitle)
+ return _strdup(settings->WindowTitle);
+
+ port = (settings->ServerPort != 3389);
+ size = strlen(name) + 16;
+ windowTitle = calloc(size, sizeof(char));
+
+ if (!windowTitle)
+ return NULL;
+
+ if (!port)
+ sprintf_s(windowTitle, size, "%s %s", prefix, name);
+ else
+ sprintf_s(windowTitle, size, "%s %s:%i", prefix, name, settings->ServerPort);
+
+ return windowTitle;
+}
+
BOOL xf_create_window(xfContext* xfc)
{
XGCValues gcv;
xfc->offset_x = 0;
xfc->offset_y = 0;
#endif
+ windowTitle = xf_window_get_title(settings);
- if (settings->WindowTitle)
- {
- windowTitle = _strdup(settings->WindowTitle);
-
- if (!windowTitle)
- return FALSE;
- }
- else if (settings->ServerPort == 3389)
- {
- size_t size = 1 + sizeof("FreeRDP: ") + strlen(
- settings->ServerHostname);
- windowTitle = malloc(size);
-
- if (!windowTitle)
- return FALSE;
-
- sprintf_s(windowTitle, size, "FreeRDP: %s", settings->ServerHostname);
- }
- else
- {
- size_t size = 1 + sizeof("FreeRDP: ") + strlen(settings->ServerHostname)
- + sizeof(":00000");
- windowTitle = malloc(size);
-
- if (!windowTitle)
- return FALSE;
-
- sprintf_s(windowTitle, size, "FreeRDP: %s:%i", settings->ServerHostname,
- settings->ServerPort);
- }
+ if (!windowTitle)
+ return FALSE;
#ifdef WITH_XRENDER
DWORD flags;
BOOL created;
Window root_window;
+ char* title;
};
struct xf_floatbar_button
return button;
}
-xfFloatbar* xf_floatbar_new(xfContext* xfc, Window window, DWORD flags)
+xfFloatbar* xf_floatbar_new(xfContext* xfc, Window window, const char* name, DWORD flags)
{
xfFloatbar* floatbar;
if (!floatbar)
return NULL;
+ floatbar->title = _strdup(name);
+
+ if (!floatbar->title)
+ goto fail;
+
floatbar->root_window = window;
floatbar->flags = flags;
floatbar->xfc = xfc;
floatbar->locked = flags & 0x0002;
xf_floatbar_toggle_fullscreen(floatbar, FALSE);
return floatbar;
+fail:
+ xf_floatbar_free(floatbar);
+ return NULL;
}
static unsigned long xf_floatbar_get_color(xfFloatbar* floatbar, char* rgb_value)
Pixmap pmap;
XPoint shape[5], border[5];
int len;
- rdpSettings* settings = floatbar->xfc->context.settings;
Display* display = floatbar->xfc->display;
/* create the pixmap that we'll use for shaping the window */
pmap = XCreatePixmap(display, floatbar->handle, floatbar->width, floatbar->height, 1);
XSetForeground(display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BORDER));
XDrawLines(display, floatbar->handle, gc, border, 5, CoordModeOrigin);
/* draw the host name connected to */
- len = strlen(settings->ServerHostname);
+ len = strlen(floatbar->title);
XSetForeground(display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_FOREGROUND));
XDrawString(display, floatbar->handle, gc, floatbar->width / 2 - len * 2, 15,
- settings->ServerHostname, len);
+ floatbar->title, len);
XFreeGC(display, gc);
XFreeGC(display, shape_gc);
}
if (!floatbar)
return;
+ free(floatbar->title);
xfc = floatbar->xfc;
size = ARRAYSIZE(floatbar->buttons);
#include "xfreerdp.h"
-xfFloatbar* xf_floatbar_new(xfContext* xfc, Window window, DWORD flags);
+xfFloatbar* xf_floatbar_new(xfContext* xfc, Window window, const char* title, DWORD flags);
void xf_floatbar_free(xfFloatbar* floatbar);
BOOL xf_floatbar_event_process(xfFloatbar* floatbar, XEvent* event);
settings->DesktopPosY);
}
- window->floatbar = xf_floatbar_new(xfc, window->handle, settings->Floatbar);
+ window->floatbar = xf_floatbar_new(xfc, window->handle, name, settings->Floatbar);
return window;
}