xfreerdp: added RAIL window titles
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Thu, 18 Aug 2011 02:31:27 +0000 (22:31 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Thu, 18 Aug 2011 02:31:27 +0000 (22:31 -0400)
client/X11/xf_rail.c
client/X11/xf_window.c
client/X11/xf_window.h
client/X11/xfreerdp.c
include/freerdp/rail/rail.h
include/freerdp/rail/window.h
libfreerdp-core/window.c
libfreerdp-rail/rail.c
libfreerdp-rail/window.c
libfreerdp-rail/window_list.c

index 46e4657..5db2920 100644 (file)
@@ -51,16 +51,24 @@ void xf_rail_CreateWindow(rdpRail* rail, rdpWindow* window)
 
        xfw = xf_CreateWindow((xfInfo*) rail->extra,
                        window->windowOffsetX, window->windowOffsetY,
-                       window->windowWidth, window->windowHeight, "RAIL");
+                       window->windowWidth, window->windowHeight, window->title);
 
        window->extra = (void*) xfw;
        window->extraId = (void*) xfw->handle;
 }
 
+void xf_rail_DestroyWindow(rdpRail* rail, rdpWindow* window)
+{
+       xfWindow* xfw;
+       xfw = (xfWindow*) window->extra;
+       xf_DestroyWindow((xfInfo*) rail->extra, xfw);
+}
+
 void xf_rail_register_callbacks(xfInfo* xfi, rdpRail* rail)
 {
        rail->extra = (void*) xfi;
        rail->CreateWindow = xf_rail_CreateWindow;
+       rail->DestroyWindow = xf_rail_DestroyWindow;
 }
 
 void xf_process_rail_get_sysparams_event(xfInfo* xfi, rdpChanMan* chanman, RDP_EVENT* event)
index 068b1e4..fcd9d21 100644 (file)
@@ -245,9 +245,7 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, char
 
                if (class_hints != NULL)
                {
-                       if (name != NULL)
-                               class_hints->res_name = name;
-
+                       class_hints->res_name = "rail";
                        class_hints->res_class = "freerdp";
                        XSetClassHint(xfi->display, window->handle, class_hints);
                        XFree(class_hints);
@@ -276,14 +274,19 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, char
                window->gc = XCreateGC(xfi->display, window->handle, GCGraphicsExposures, &gcv);
                window->surface = XCreatePixmap(xfi->display, window->handle, window->width, window->height, xfi->depth);
 
+               XStoreName(xfi->display, window->handle, name);
+
                window_move(xfi, window, x, y, width, height);
        }
 
        return window;
 }
 
-void window_destroy(xfInfo* xfi, xfWindow* window)
+void xf_DestroyWindow(xfInfo* xfi, xfWindow* window)
 {
+       XFreeGC(xfi->display, window->gc);
+       XFreePixmap(xfi->display, window->surface);
+       XUnmapWindow(xfi->display, window->handle);
        XDestroyWindow(xfi->display, window->handle);
        xfree(window);
 }
index c090cd2..ef37b25 100644 (file)
@@ -47,8 +47,9 @@ void window_move(xfInfo* xfi, xfWindow* window, int x, int y, int width, int hei
 void window_show_decorations(xfInfo* xfi, xfWindow* window, boolean show);
 
 xfWindow* window_create(xfInfo* xfi, char* name);
-void window_destroy(xfInfo* xfi, xfWindow* window);
+void xf_DestroyWindow(xfInfo* xfi, xfWindow* window);
 
 xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, char* name);
+void xf_DestroyWindow(xfInfo* xfi, xfWindow* window);
 
 #endif /* __XF_WINDOW_H */
index 7ce6af9..814bfcf 100644 (file)
@@ -412,7 +412,7 @@ void xf_window_free(xfInfo* xfi)
        XFreeGC(xfi->display, xfi->gc);
        xfi->gc = 0;
 
-       window_destroy(xfi, xfi->window);
+       xf_DestroyWindow(xfi, xfi->window);
        xfi->window = NULL;
 
        if (xfi->primary)
index 14528dc..8ba5ef1 100644 (file)
@@ -32,12 +32,15 @@ typedef struct rdp_rail rdpRail;
 #include <freerdp/rail/window_list.h>
 
 typedef void (*railCreateWindow)(rdpRail* rail, rdpWindow* window);
+typedef void (*railDestroyWindow)(rdpRail* rail, rdpWindow* window);
 
 struct rdp_rail
 {
        void* extra;
+       UNICONV* uniconv;
        rdpWindowList* list;
        railCreateWindow CreateWindow;
+       railDestroyWindow DestroyWindow;
 };
 
 FREERDP_API void rail_register_update_callbacks(rdpRail* rail, rdpUpdate* update);
index 1d8b225..3662db0 100644 (file)
@@ -34,6 +34,7 @@ struct rdp_window
 {
        void* extra;
        void* extraId;
+       char* title;
        rdpWindow* prev;
        rdpWindow* next;
        uint32 windowId;
index 8ab01a3..db2e58a 100644 (file)
@@ -185,7 +185,7 @@ void update_read_window_cached_icon_order(STREAM* s, WINDOW_ORDER_INFO* orderInf
        update_read_cached_icon_info(s, &window_cached_icon->cachedIcon); /* cachedIcon (CACHED_ICON_INFO) */
 }
 
-void update_read_window_deleted_order(STREAM* s, WINDOW_ORDER_INFO* orderInfo)
+void update_read_window_delete_order(STREAM* s, WINDOW_ORDER_INFO* orderInfo)
 {
        /* window deletion event */
 }
@@ -209,7 +209,7 @@ void update_recv_window_info_order(rdpUpdate* update, STREAM* s, WINDOW_ORDER_IN
        else if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_DELETED)
        {
                DEBUG_WND("Window Deleted Order");
-               update_read_window_deleted_order(s, orderInfo);
+               update_read_window_delete_order(s, orderInfo);
                IFCALL(update->WindowDelete, update, orderInfo);
        }
        else
@@ -245,7 +245,7 @@ void update_read_notification_icon_state_order(STREAM* s, WINDOW_ORDER_INFO* ord
                update_read_cached_icon_info(s, &notify_icon_state->cachedIcon); /* cachedIcon (CACHED_ICON_INFO) */
 }
 
-void update_read_notification_icon_deleted_order(STREAM* s, WINDOW_ORDER_INFO* orderInfo)
+void update_read_notification_icon_delete_order(STREAM* s, WINDOW_ORDER_INFO* orderInfo)
 {
        /* notification icon deletion event */
 }
@@ -258,7 +258,7 @@ void update_recv_notification_icon_info_order(rdpUpdate* update, STREAM* s, WIND
        if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_DELETED)
        {
                DEBUG_WND("Delete Notification Icon Deleted Order");
-               update_read_notification_icon_deleted_order(s, orderInfo);
+               update_read_notification_icon_delete_order(s, orderInfo);
                IFCALL(update->NotifyIconDelete, update, orderInfo);
        }
        else
index 5fe1c19..f1739ab 100644 (file)
@@ -59,6 +59,7 @@ rdpRail* rail_new()
        if (rail != NULL)
        {
                rail->list = window_list_new(rail);
+               rail->uniconv = freerdp_uniconv_new();
        }
 
        return rail;
@@ -68,6 +69,8 @@ void rail_free(rdpRail* rail)
 {
        if (rail != NULL)
        {
+               window_list_free(rail->list);
+               freerdp_uniconv_free(rail->uniconv);
                xfree(rail);
        }
 }
index 9e69ea4..63c4269 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <freerdp/utils/stream.h>
 #include <freerdp/utils/memory.h>
+#include <freerdp/utils/hexdump.h>
+#include <freerdp/utils/unicode.h>
 
 #include <freerdp/rail/window.h>
 
@@ -43,7 +45,10 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
 
        if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TITLE)
        {
-
+               window->titleInfo.length = window_state->titleInfo.length;
+               window->titleInfo.string = xmalloc(window_state->titleInfo.length);
+               memcpy(window->titleInfo.string, window_state->titleInfo.string, window->titleInfo.length);
+               freerdp_hexdump(window->titleInfo.string, window->titleInfo.length);
        }
 
        if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
@@ -123,11 +128,25 @@ void window_state_update(rdpWindow* window, WINDOW_ORDER_INFO* orderInfo, WINDOW
 
 void rail_CreateWindow(rdpRail* rail, rdpWindow* window)
 {
+       if (window->titleInfo.length > 0)
+       {
+               window->title = freerdp_uniconv_in(rail->uniconv, window->titleInfo.string, window->titleInfo.length);
+       }
+       else
+       {
+               window->title = (char*) xmalloc(sizeof("RAIL"));
+               memcpy(window->title, "RAIL", sizeof("RAIL"));
+       }
+
        IFCALL(rail->CreateWindow, rail, window);
 }
 
 void rail_DestroyWindow(rdpRail* rail, rdpWindow* window)
 {
+       printf("rail_DestroyWindow\n");
+
+       IFCALL(rail->DestroyWindow, rail, window);
+
        if (window != NULL)
        {
                xfree(window);
index 2d855e8..2bf078f 100644 (file)
@@ -80,7 +80,7 @@ rdpWindow* window_list_get_by_id(rdpWindowList* list, uint32 windowId)
        if (window == NULL)
                return NULL;
 
-       while (window->next != NULL)
+       while (window != NULL)
        {
                if (window->windowId == windowId)
                        return window;