Windows client: Suppress minimize and restore buttons in float bar when toggle-fullsc...
authorDon Caton <don.caton@route1.com>
Wed, 22 Jun 2016 18:58:39 +0000 (14:58 -0400)
committerArmin Novak <armin.novak@thincast.com>
Fri, 7 Dec 2018 14:22:28 +0000 (15:22 +0100)
# Conflicts:
# client/Windows/wf_client.c
# client/Windows/wf_event.c
# client/Windows/wf_floatbar.c

18 files changed:
client/Windows/resource.h
client/Windows/resource/bg.bmp [deleted file]
client/Windows/resource/close.bmp
client/Windows/resource/close_active.bmp
client/Windows/resource/lock.bmp
client/Windows/resource/lock_active.bmp
client/Windows/resource/minimize.bmp
client/Windows/resource/minimize_active.bmp
client/Windows/resource/restore.bmp
client/Windows/resource/restore_active.bmp
client/Windows/resource/unlock.bmp
client/Windows/resource/unlock_active.bmp
client/Windows/wf_client.c
client/Windows/wf_client.h
client/Windows/wf_event.c
client/Windows/wf_floatbar.c
client/Windows/wf_floatbar.h
client/Windows/wfreerdp.rc

index 89c1e79..fe79d50 100644 (file)
@@ -1,6 +1,5 @@
 
 #define IDI_ICON1                       101
-#define IDB_BACKGROUND                  102
 #define IDB_MINIMIZE                    103
 #define IDB_MINIMIZE_ACT                104
 #define IDB_LOCK                        105
diff --git a/client/Windows/resource/bg.bmp b/client/Windows/resource/bg.bmp
deleted file mode 100644 (file)
index 7e90ec6..0000000
Binary files a/client/Windows/resource/bg.bmp and /dev/null differ
index f9bf31e..bb17b28 100644 (file)
Binary files a/client/Windows/resource/close.bmp and b/client/Windows/resource/close.bmp differ
index 43dc5b2..a59b2e3 100644 (file)
Binary files a/client/Windows/resource/close_active.bmp and b/client/Windows/resource/close_active.bmp differ
index 6857787..0442c02 100644 (file)
Binary files a/client/Windows/resource/lock.bmp and b/client/Windows/resource/lock.bmp differ
index b4fa35f..2e37e36 100644 (file)
Binary files a/client/Windows/resource/lock_active.bmp and b/client/Windows/resource/lock_active.bmp differ
index 7fce92d..485e170 100644 (file)
Binary files a/client/Windows/resource/minimize.bmp and b/client/Windows/resource/minimize.bmp differ
index 6f0b74d..e16b252 100644 (file)
Binary files a/client/Windows/resource/minimize_active.bmp and b/client/Windows/resource/minimize_active.bmp differ
index b2ae47b..26117b0 100644 (file)
Binary files a/client/Windows/resource/restore.bmp and b/client/Windows/resource/restore.bmp differ
index a0516af..c2479ba 100644 (file)
Binary files a/client/Windows/resource/restore_active.bmp and b/client/Windows/resource/restore_active.bmp differ
index f59b72a..fc1b0d3 100644 (file)
Binary files a/client/Windows/resource/unlock.bmp and b/client/Windows/resource/unlock.bmp differ
index a5d9c38..5a7f007 100644 (file)
Binary files a/client/Windows/resource/unlock_active.bmp and b/client/Windows/resource/unlock_active.bmp differ
index e297fa3..f92a8e1 100644 (file)
@@ -195,8 +195,7 @@ static BOOL wf_pre_connect(freerdp* instance)
        wfc->fullscreen = settings->Fullscreen;
        wfc->floatbar_active = settings->Floatbar;
 
-       if (wfc->fullscreen)
-               wfc->fs_toggle = 1;
+       wfc->fullscreen_toggle = settings->ToggleFullscreen;
 
        desktopWidth = settings->DesktopWidth;
        desktopHeight = settings->DesktopHeight;
@@ -259,8 +258,15 @@ static BOOL wf_pre_connect(freerdp* instance)
 
 static void wf_add_system_menu(wfContext* wfc)
 {
-       HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE);
+       HMENU hMenu;
        MENUITEMINFO item_info;
+       
+       if (wfc->fullscreen && !wfc->fullscreen_toggle)
+       {
+               return;
+       }
+       
+       hMenu = GetSystemMenu(wfc->hwnd, FALSE);
        ZeroMemory(&item_info, sizeof(MENUITEMINFO));
        item_info.fMask = MIIM_CHECKMARKS | MIIM_FTYPE | MIIM_ID | MIIM_STRING |
                          MIIM_DATA;
@@ -285,7 +291,6 @@ static BOOL wf_post_connect(freerdp* instance)
        rdpCache* cache;
        wfContext* wfc;
        rdpContext* context;
-       WCHAR lpWindowName[512];
        rdpSettings* settings;
        EmbedWindowEventArgs e;
        const UINT32 format = PIXEL_FORMAT_BGRX32;
@@ -307,12 +312,12 @@ static BOOL wf_post_connect(freerdp* instance)
        }
 
        if (settings->WindowTitle != NULL)
-               _snwprintf_s(lpWindowName, ARRAYSIZE(lpWindowName), _TRUNCATE, L"%S", settings->WindowTitle);
+               _snwprintf_s(wfc->window_title, ARRAYSIZE(wfc->window_title), _TRUNCATE, L"%S", settings->WindowTitle);
        else if (settings->ServerPort == 3389)
-               _snwprintf_s(lpWindowName, ARRAYSIZE(lpWindowName), _TRUNCATE, L"FreeRDP: %S",
+               _snwprintf_s(wfc->window_title, ARRAYSIZE(wfc->window_title), _TRUNCATE, L"FreeRDP: %S",
                             settings->ServerHostname);
        else
-               _snwprintf_s(lpWindowName, ARRAYSIZE(lpWindowName), _TRUNCATE, L"FreeRDP: %S:%u",
+               _snwprintf_s(wfc->window_title, ARRAYSIZE(wfc->window_title), _TRUNCATE, L"FreeRDP: %S:%u",
                             settings->ServerHostname, settings->ServerPort);
 
        if (settings->EmbeddedWindow)
@@ -328,7 +333,7 @@ static BOOL wf_post_connect(freerdp* instance)
 
        if (!wfc->hwnd)
        {
-               wfc->hwnd = CreateWindowEx((DWORD) NULL, wfc->wndClassName, lpWindowName,
+               wfc->hwnd = CreateWindowEx((DWORD) NULL, wfc->wndClassName, wfc->window_title,
                                           dwStyle,
                                           0, 0, 0, 0, wfc->hWndParent, NULL, wfc->hInstance, NULL);
                SetWindowLongPtr(wfc->hwnd, GWLP_USERDATA, (LONG_PTR) wfc);
index a7c0658..61eb95e 100644 (file)
@@ -78,11 +78,11 @@ struct wf_context
 
        int offset_x;
        int offset_y;
-       int fs_toggle;
+       int fullscreen_toggle;
        int fullscreen;
        int floatbar_active;
        int percentscreen;
-       char window_title[64];
+       WCHAR window_title[512];
        int client_x;
        int client_y;
        int client_width;
index 8057999..bf8ce0f 100644 (file)
@@ -93,7 +93,7 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
                                DEBUG_KBD("keydown %d scanCode 0x%08lX flags 0x%08lX vkCode 0x%08lX",
                                          (wParam == WM_KEYDOWN), p->scanCode, p->flags, p->vkCode);
 
-                               if (wfc->fs_toggle &&
+                               if (wfc->fullscreen_toggle &&
                                    ((p->vkCode == VK_RETURN) || (p->vkCode == VK_CANCEL)) &&
                                    (GetAsyncKeyState(VK_CONTROL) & 0x8000) &&
                                    (GetAsyncKeyState(VK_MENU) & 0x8000)) /* could also use flags & LLKHF_ALTDOWN */
index 71f9898..9c8f393 100644 (file)
@@ -25,6 +25,7 @@
 #include "wf_client.h"
 #include "wf_floatbar.h"
 #include "wf_gdi.h"
+#pragma comment( lib, "Msimg32.lib" )
 
 typedef struct _Button Button;
 
@@ -41,19 +42,21 @@ typedef struct _Button Button;
 #define BTN_MAX             4
 
 /* bmp size */
-#define BACKGROUND_W        581
-#define BACKGROUND_H        29
-#define LOCK_X              13
-#define MINIMIZE_X          (BACKGROUND_W - 91)
-#define CLOSE_X             (BACKGROUND_W - 37)
-#define RESTORE_X           (BACKGROUND_W - 64)
-
+#define BACKGROUND_W        576
+#define BACKGROUND_H        27
+#define BUTTON_OFFSET       5 
 #define BUTTON_Y            2
-#define BUTTON_WIDTH        24
-#define BUTTON_HEIGHT       24
+#define BUTTON_WIDTH        23
+#define BUTTON_HEIGHT       21
+#define BUTTON_SPACING      1
 
-struct _Button
-{
+#define LOCK_X              ( BACKGROUND_H + BUTTON_OFFSET )
+#define CLOSE_X             ( (BACKGROUND_W - ( BACKGROUND_H + BUTTON_OFFSET ) ) - BUTTON_WIDTH )
+#define RESTORE_X           ( CLOSE_X - ( BUTTON_WIDTH + BUTTON_SPACING ) )
+#define MINIMIZE_X          ( RESTORE_X - ( BUTTON_WIDTH + BUTTON_SPACING ) )
+#define TEXT_X              ( BACKGROUND_H + ( ( BUTTON_WIDTH + BUTTON_SPACING ) * 3 ) + 5 )
+
+struct _Button {
        FloatBar* floatbar;
        int type;
        int x, y, h, w;
@@ -68,8 +71,7 @@ struct _Button
        HBITMAP unlocked_bmp_act;
 };
 
-struct _FloatBar
-{
+struct _FloatBar {
        HWND parent;
        HWND hwnd;
        RECT rect;
@@ -80,12 +82,12 @@ struct _FloatBar
        BOOL shown;
        BOOL locked;
        HDC hdcmem;
-       HBITMAP background;
+    RECT textRect;
 };
 
-static int button_hit(Button* button)
+static int button_hit(Button * const  button)
 {
-       FloatBar* floatbar = button->floatbar;
+       FloatBar* const floatbar = button->floatbar;
 
        switch (button->type)
        {
@@ -125,20 +127,31 @@ static int button_hit(Button* button)
        return 0;
 }
 
-static int button_paint(Button* button, HDC hdc)
+static int button_paint( const Button * const button, const HDC hdc)
 {
-       FloatBar* floatbar = button->floatbar;
-       SelectObject(floatbar->hdcmem, button->active ? button->bmp_act : button->bmp);
-       StretchBlt(hdc, button->x, button->y, button->w, button->h, floatbar->hdcmem, 0,
-                  0, button->w, button->h, SRCCOPY);
+    if (button != NULL)
+    {
+        FloatBar* floatbar = button->floatbar;
+
+        SelectObject( floatbar->hdcmem, button->active ? button->bmp_act : button->bmp );
+
+        BLENDFUNCTION bf;
+        bf.BlendOp = AC_SRC_OVER;
+        bf.BlendFlags = 0;
+        bf.SourceConstantAlpha = 255;
+        bf.AlphaFormat = AC_SRC_ALPHA;
+
+        AlphaBlend( hdc, button->x, button->y, button->w, button->h, floatbar->hdcmem, 0, 0, button->w, button->h, bf );
+    }
+
        return 0;
 }
 
-static Button* floatbar_create_button(FloatBar* floatbar, int type, int resid,
-                                      int resid_act, int x, int y, int h, int w)
+static Button* floatbar_create_button( FloatBar *const floatbar, const int type, const int resid, const int resid_act, const int x, const int y, const int h, const int w)
 {
-       Button* button;
-       button = (Button*)malloc(sizeof(Button));
+       Button *button;
+
+       button = (Button *)malloc(sizeof(Button));
 
        if (!button)
                return NULL;
@@ -150,101 +163,174 @@ static Button* floatbar_create_button(FloatBar* floatbar, int type, int resid,
        button->w = w;
        button->h = h;
        button->active = FALSE;
-       button->bmp = (HBITMAP)LoadImage(floatbar->wfc->hInstance,
-                                        MAKEINTRESOURCE(resid), IMAGE_BITMAP, w, h, LR_DEFAULTCOLOR);
-       button->bmp_act = (HBITMAP)LoadImage(floatbar->wfc->hInstance,
-                                            MAKEINTRESOURCE(resid_act), IMAGE_BITMAP, w, h, LR_DEFAULTCOLOR);
+
+       button->bmp = (HBITMAP)LoadImage(floatbar->wfc->hInstance, MAKEINTRESOURCE(resid), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
+       button->bmp_act = (HBITMAP)LoadImage(floatbar->wfc->hInstance, MAKEINTRESOURCE(resid_act), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
+
        return button;
 }
 
-static Button* floatbar_create_lock_button(FloatBar* floatbar,
-        int unlock_resid, int unlock_resid_act,
-        int lock_resid, int lock_resid_act,
-        int x, int y, int h, int w)
+static Button* floatbar_create_lock_button( FloatBar * const floatbar, const int unlock_resid, const int unlock_resid_act, const int lock_resid, const int lock_resid_act, const int x, const int y, const int h, const int w)
 {
        Button* button;
-       button = floatbar_create_button(floatbar, BUTTON_LOCKPIN, unlock_resid,
-                                       unlock_resid_act, x, y, h, w);
+
+       button = floatbar_create_button(floatbar, BUTTON_LOCKPIN, unlock_resid, unlock_resid_act, x, y, h, w);
 
        if (!button)
                return NULL;
 
        button->unlocked_bmp = button->bmp;
        button->unlocked_bmp_act = button->bmp_act;
-       button->locked_bmp = (HBITMAP)LoadImage(floatbar->wfc->hInstance,
-                                               MAKEINTRESOURCE(lock_resid), IMAGE_BITMAP, w, h, LR_DEFAULTCOLOR);
-       button->locked_bmp_act = (HBITMAP)LoadImage(floatbar->wfc->hInstance,
-                                MAKEINTRESOURCE(lock_resid_act), IMAGE_BITMAP, w, h, LR_DEFAULTCOLOR);
+       button->locked_bmp = (HBITMAP)LoadImage(floatbar->wfc->hInstance, MAKEINTRESOURCE(lock_resid), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
+       button->locked_bmp_act = (HBITMAP)LoadImage(floatbar->wfc->hInstance, MAKEINTRESOURCE(lock_resid_act), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
+
        return button;
 }
 
-static Button* floatbar_get_button(FloatBar* floatbar, int x, int y)
+static Button* floatbar_get_button( const FloatBar * const floatbar, const int x, const int y)
 {
        int i;
 
        if (y > BUTTON_Y && y < BUTTON_Y + BUTTON_HEIGHT)
+    {
                for (i = 0; i < BTN_MAX; i++)
-                       if (x > floatbar->buttons[i]->x
-                           && x < floatbar->buttons[i]->x + floatbar->buttons[i]->w)
+        {
+            if (floatbar->buttons[i] != NULL && x > floatbar->buttons[i]->x && x < floatbar->buttons[i]->x + floatbar->buttons[i]->w)
+            {
                                return floatbar->buttons[i];
+            }
+        }
+    }
 
        return NULL;
 }
 
-static int floatbar_paint(FloatBar* floatbar, HDC hdc)
+static int floatbar_paint( FloatBar * const floatbar, const HDC hdc)
 {
        int i;
+
        /* paint background */
-       SelectObject(floatbar->hdcmem, floatbar->background);
-       StretchBlt(hdc, 0, 0, BACKGROUND_W, BACKGROUND_H, floatbar->hdcmem, 0, 0,
-                  BACKGROUND_W, BACKGROUND_H, SRCCOPY);
+  
+    GRADIENT_RECT gradientRect = { 0, 1 };
+    COLORREF rgbTop = RGB( 117, 154, 198 );
+    COLORREF rgbBottom = RGB( 6, 55, 120 );
+
+    const int top = 0;
+    int left = 0;
+    int bottom = BACKGROUND_H - 1;
+    int right = BACKGROUND_W - 1;
+    const int angleOffset = BACKGROUND_H - 1;
+
+    TRIVERTEX triVertext[2] = {
+        left,
+        top,
+        GetRValue( rgbTop ) << 8,
+        GetGValue( rgbTop ) << 8,
+        GetBValue( rgbTop ) << 8,
+        0x0000,
+        right,
+        bottom,
+        GetRValue( rgbBottom ) << 8,
+        GetGValue( rgbBottom ) << 8,
+        GetBValue( rgbBottom ) << 8,
+        0x0000
+    };
+
+    GradientFill( hdc, triVertext, 2, &gradientRect, 1, GRADIENT_FILL_RECT_V );
+
+    /* paint shadow */
+
+    HPEN hpen = CreatePen( PS_SOLID, 1, RGB( 71, 71, 71 ) );
+    HGDIOBJECT orig = SelectObject( hdc, hpen );
+
+    MoveToEx( hdc, left, top, NULL );
+    LineTo( hdc, left + angleOffset, bottom );
+    LineTo( hdc, right - angleOffset, bottom );
+    LineTo( hdc, right + 1, top - 1 );
+    DeleteObject( hpen );
+
+    hpen = CreatePen( PS_SOLID, 1, RGB( 107, 141, 184 ) );
+    SelectObject( hdc, hpen );
+
+    left += 1;
+    bottom -= 1;
+    right -= 1;
+
+    MoveToEx( hdc, left, top, NULL );
+    LineTo( hdc, left + ( angleOffset - 1 ), bottom );
+    LineTo( hdc, right - ( angleOffset - 1 ), bottom );
+    LineTo( hdc, right + 1, top - 1 );
+    DeleteObject( hpen );
+
+    SelectObject( hdc, orig );
+
+    DrawText( hdc, floatbar->wfc->window_title, wcslen( floatbar->wfc->window_title ), &floatbar->textRect, DT_CENTER | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE );
 
        /* paint buttons */
+
        for (i = 0; i < BTN_MAX; i++)
+    {
                button_paint(floatbar->buttons[i], hdc);
+    }
 
        return 0;
 }
 
-static int floatbar_animation(FloatBar* floatbar, BOOL show)
+static int floatbar_animation( FloatBar* const floatbar, const BOOL show)
 {
-       SetTimer(floatbar->hwnd, show ? TIMER_ANIMAT_SHOW : TIMER_ANIMAT_HIDE, 10,
-                NULL);
+       SetTimer(floatbar->hwnd, show ? TIMER_ANIMAT_SHOW : TIMER_ANIMAT_HIDE, 10, NULL);
        floatbar->shown = show;
        return 0;
 }
 
-LRESULT CALLBACK floatbar_proc(HWND hWnd, UINT Msg, WPARAM wParam,
-                               LPARAM lParam)
+LRESULT CALLBACK floatbar_proc(const HWND hWnd, const UINT Msg, const WPARAM wParam, const LPARAM lParam)
 {
        static int dragging = FALSE;
        static int lbtn_dwn = FALSE;
        static int btn_dwn_x = 0;
+    static wfContext * wfc;
        static FloatBar* floatbar;
        static TRACKMOUSEEVENT tme;
+
        PAINTSTRUCT ps;
        Button* button;
        HDC hdc;
        int pos_x;
        int pos_y;
+       NONCLIENTMETRICS ncm;
        int xScreen = GetSystemMetrics(SM_CXSCREEN);
 
-       switch (Msg)
+       switch(Msg)
        {
                case WM_CREATE:
-                       floatbar = (FloatBar*)((CREATESTRUCT*)lParam)->lpCreateParams;
+            wfc = ( (wfContext *) ( (CREATESTRUCT *) lParam )->lpCreateParams );
+            floatbar = wfc->floatbar;
                        floatbar->hwnd = hWnd;
                        floatbar->parent = GetParent(hWnd);
+
                        GetWindowRect(floatbar->hwnd, &floatbar->rect);
                        floatbar->width = floatbar->rect.right - floatbar->rect.left;
                        floatbar->height = floatbar->rect.bottom - floatbar->rect.top;
+
                        hdc = GetDC(hWnd);
                        floatbar->hdcmem = CreateCompatibleDC(hdc);
                        ReleaseDC(hWnd, hdc);
+
                        tme.cbSize = sizeof(TRACKMOUSEEVENT);
                        tme.dwFlags = TME_LEAVE;
                        tme.hwndTrack = hWnd;
                        tme.dwHoverTime = HOVER_DEFAULT;
+
+            // Use caption font, white, draw transparent
+            GetClientRect( hWnd, &floatbar->textRect );
+            InflateRect( &floatbar->textRect, -TEXT_X, 0 );
+            SetBkMode( hdc, TRANSPARENT );
+            SetTextColor( hdc, RGB( 255, 255, 255 ) );
+            
+            ncm.cbSize = sizeof( NONCLIENTMETRICS );
+            SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof( NONCLIENTMETRICS ), &ncm, 0 );
+            SelectObject( hdc, CreateFontIndirect( &ncm.lfCaptionFont ) );
+
                        SetTimer(hWnd, TIMER_HIDE, 3000, NULL);
                        break;
 
@@ -257,8 +343,8 @@ LRESULT CALLBACK floatbar_proc(HWND hWnd, UINT Msg, WPARAM wParam,
                case WM_LBUTTONDOWN:
                        pos_x = lParam & 0xffff;
                        pos_y = (lParam >> 16) & 0xffff;
-                       button = floatbar_get_button(floatbar, pos_x, pos_y);
 
+                       button = floatbar_get_button(floatbar, pos_x, pos_y);
                        if (!button)
                        {
                                SetCapture(hWnd);
@@ -273,19 +359,17 @@ LRESULT CALLBACK floatbar_proc(HWND hWnd, UINT Msg, WPARAM wParam,
                case WM_LBUTTONUP:
                        pos_x = lParam & 0xffff;
                        pos_y = (lParam >> 16) & 0xffff;
+
                        ReleaseCapture();
                        dragging = FALSE;
 
                        if (lbtn_dwn)
                        {
                                button = floatbar_get_button(floatbar, pos_x, pos_y);
-
                                if (button)
                                        button_hit(button);
-
                                lbtn_dwn = FALSE;
                        }
-
                        break;
 
                case WM_MOUSEMOVE:
@@ -305,18 +389,21 @@ LRESULT CALLBACK floatbar_proc(HWND hWnd, UINT Msg, WPARAM wParam,
                                else if (floatbar->rect.left > xScreen - floatbar->width)
                                        floatbar->rect.left = xScreen - floatbar->width;
 
-                               MoveWindow(hWnd, floatbar->rect.left, floatbar->rect.top, floatbar->width,
-                                          floatbar->height, TRUE);
+                               MoveWindow(hWnd, floatbar->rect.left, floatbar->rect.top, floatbar->width, floatbar->height, TRUE);
                        }
                        else
                        {
                                int i;
 
                                for (i = 0; i < BTN_MAX; i++)
-                                       floatbar->buttons[i]->active = FALSE;
+                {
+                    if (floatbar->buttons[i] != NULL)
+                    {
+                                          floatbar->buttons[i]->active = FALSE;
+                    }
+                }
 
                                button = floatbar_get_button(floatbar, pos_x, pos_y);
-
                                if (button)
                                        button->active = TRUE;
 
@@ -332,65 +419,60 @@ LRESULT CALLBACK floatbar_proc(HWND hWnd, UINT Msg, WPARAM wParam,
                        break;
 
                case WM_MOUSELEAVE:
-                       {
-                               int i;
+               {
+                       int i;
 
-                               for (i = 0; i < BTN_MAX; i++)
-                                       floatbar->buttons[i]->active = FALSE;
+            for (i = 0; i < BTN_MAX; i++)
+            {
+                if (floatbar->buttons[i] != NULL)
+                {
+                    floatbar->buttons[i]->active = FALSE;
+                }
+            }
 
-                               InvalidateRect(hWnd, NULL, FALSE);
-                               UpdateWindow(hWnd);
-                               SetTimer(hWnd, TIMER_HIDE, 3000, NULL);
-                               break;
-                       }
+                       InvalidateRect(hWnd, NULL, FALSE);
+                       UpdateWindow(hWnd);
 
+                       SetTimer(hWnd, TIMER_HIDE, 3000, NULL);
+                       break;
+               }
                case WM_TIMER:
                        switch (wParam)
                        {
                                case TIMER_HIDE:
-                                       {
-                                               KillTimer(hWnd, TIMER_HIDE);
-
-                                               if (!floatbar->locked)
-                                                       floatbar_animation(floatbar, FALSE);
-
-                                               break;
-                                       }
-
+                               {
+                                       KillTimer(hWnd, TIMER_HIDE);
+                                       if (!floatbar->locked)
+                                               floatbar_animation(floatbar, FALSE);
+                                       break;
+                               }
                                case TIMER_ANIMAT_SHOW:
-                                       {
-                                               static int y = 0;
-                                               MoveWindow(floatbar->hwnd, floatbar->rect.left, (y++ - floatbar->height),
-                                                          floatbar->width, floatbar->height, TRUE);
+                               {
+                                       static int y = 0;
 
-                                               if (y == floatbar->height)
-                                               {
-                                                       y = 0;
-                                                       KillTimer(hWnd, wParam);
-                                               }
-
-                                               break;
+                                       MoveWindow(floatbar->hwnd, floatbar->rect.left, (y++ - floatbar->height), floatbar->width, floatbar->height, TRUE);
+                                       if (y == floatbar->height)
+                                       {
+                                               y = 0;
+                                               KillTimer(hWnd, wParam);
                                        }
-
+                                       break;
+                               }
                                case TIMER_ANIMAT_HIDE:
-                                       {
-                                               static int y = 0;
-                                               MoveWindow(floatbar->hwnd, floatbar->rect.left, -y++, floatbar->width,
-                                                          floatbar->height, TRUE);
-
-                                               if (y == floatbar->height)
-                                               {
-                                                       y = 0;
-                                                       KillTimer(hWnd, wParam);
-                                               }
+                               {
+                                       static int y = 0;
 
-                                               break;
+                                       MoveWindow(floatbar->hwnd, floatbar->rect.left, -y++, floatbar->width, floatbar->height, TRUE);
+                                       if (y == floatbar->height)
+                                       {
+                                               y = 0;
+                                               KillTimer(hWnd, wParam);
                                        }
-
+                                       break;
+                               }
                                default:
                                        break;
                        }
-
                        break;
 
                case WM_DESTROY:
@@ -401,14 +483,14 @@ LRESULT CALLBACK floatbar_proc(HWND hWnd, UINT Msg, WPARAM wParam,
                default:
                        return DefWindowProc(hWnd, Msg, wParam, lParam);
        }
-
        return 0;
 }
 
-static FloatBar* floatbar_create(wfContext* wfc)
+static FloatBar* floatbar_create(wfContext* const wfc)
 {
        FloatBar* floatbar;
-       floatbar = (FloatBar*)malloc(sizeof(FloatBar));
+
+       floatbar = (FloatBar *)calloc(1, sizeof(FloatBar));
 
        if (!floatbar)
                return NULL;
@@ -419,23 +501,25 @@ static FloatBar* floatbar_create(wfContext* wfc)
        floatbar->parent = wfc->hwnd;
        floatbar->wfc = wfc;
        floatbar->hdcmem = NULL;
-       floatbar->background = (HBITMAP)LoadImage(wfc->hInstance,
-                              MAKEINTRESOURCE(IDB_BACKGROUND), IMAGE_BITMAP, BACKGROUND_W, BACKGROUND_H,
-                              LR_DEFAULTCOLOR);
-       floatbar->buttons[0] = floatbar_create_button(floatbar, BUTTON_MINIMIZE,
-                              IDB_MINIMIZE, IDB_MINIMIZE_ACT, MINIMIZE_X, BUTTON_Y, BUTTON_HEIGHT,
-                              BUTTON_WIDTH);
-       floatbar->buttons[1] = floatbar_create_button(floatbar, BUTTON_RESTORE,
-                              IDB_RESTORE, IDB_RESTORE_ACT, RESTORE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
-       floatbar->buttons[2] = floatbar_create_button(floatbar, BUTTON_CLOSE, IDB_CLOSE,
-                              IDB_CLOSE_ACT, CLOSE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
-       floatbar->buttons[3] = floatbar_create_lock_button(floatbar, IDB_UNLOCK,
-                              IDB_UNLOCK_ACT, IDB_LOCK, IDB_LOCK_ACT, LOCK_X, BUTTON_Y, BUTTON_HEIGHT,
-                              BUTTON_WIDTH);
+
+    if (wfc->fullscreen_toggle)
+    {
+        floatbar->buttons[0] = floatbar_create_button( floatbar, BUTTON_MINIMIZE, IDB_MINIMIZE, IDB_MINIMIZE_ACT, MINIMIZE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH );
+        floatbar->buttons[1] = floatbar_create_button( floatbar, BUTTON_RESTORE, IDB_RESTORE, IDB_RESTORE_ACT, RESTORE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH );
+    }
+    else
+    {
+        floatbar->buttons[0] = NULL;
+        floatbar->buttons[1] = NULL;
+    }
+
+       floatbar->buttons[2] = floatbar_create_button(floatbar, BUTTON_CLOSE, IDB_CLOSE, IDB_CLOSE_ACT, CLOSE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
+       floatbar->buttons[3] = floatbar_create_lock_button(floatbar, IDB_UNLOCK, IDB_UNLOCK_ACT, IDB_LOCK, IDB_LOCK_ACT, LOCK_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
+
        return floatbar;
 }
 
-int floatbar_hide(FloatBar* floatbar)
+int floatbar_hide(const FloatBar* const floatbar)
 {
        KillTimer(floatbar->hwnd, TIMER_HIDE);
        MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->height,
@@ -443,7 +527,7 @@ int floatbar_hide(FloatBar* floatbar)
        return 0;
 }
 
-int floatbar_show(FloatBar* floatbar)
+int floatbar_show(const FloatBar* const floatbar)
 {
        SetTimer(floatbar->hwnd, TIMER_HIDE, 3000, NULL);
        MoveWindow(floatbar->hwnd, floatbar->rect.left, floatbar->rect.top,
@@ -451,11 +535,14 @@ int floatbar_show(FloatBar* floatbar)
        return 0;
 }
 
-void floatbar_window_create(wfContext* wfc)
+void floatbar_window_create( wfContext * const wfc )
 {
        WNDCLASSEX wnd_cls;
        HWND barWnd;
+       HRGN hRgn;
+       POINT pt[4];
        int x = (GetSystemMetrics(SM_CXSCREEN) - BACKGROUND_W) / 2;
+
        wnd_cls.cbSize        = sizeof(WNDCLASSEX);
        wnd_cls.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
        wnd_cls.lpfnWndProc   = floatbar_proc;
@@ -468,13 +555,28 @@ void floatbar_window_create(wfContext* wfc)
        wnd_cls.lpszClassName = L"floatbar";
        wnd_cls.hInstance     = wfc->hInstance;
        wnd_cls.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
+
        RegisterClassEx(&wnd_cls);
+
        wfc->floatbar = floatbar_create(wfc);
+
        barWnd = CreateWindowEx(WS_EX_TOPMOST, L"floatbar", L"floatbar", WS_CHILD, x, 0,
-                               BACKGROUND_W, BACKGROUND_H, wfc->hwnd, NULL, wfc->hInstance, wfc->floatbar);
+                               BACKGROUND_W, BACKGROUND_H, wfc->hwnd, NULL, wfc->hInstance, wfc );
 
        if (barWnd == NULL)
                return;
 
+       pt[0].x = 0;
+       pt[0].y = 0;
+       pt[1].x = BACKGROUND_W;
+       pt[1].y = 0;
+       pt[2].x = BACKGROUND_W - BACKGROUND_H;
+       pt[2].y = BACKGROUND_H;
+       pt[3].x = BACKGROUND_H;
+       pt[3].y = BACKGROUND_H;
+
+       hRgn = CreatePolygonRgn( pt, 4, ALTERNATE );
+       SetWindowRgn( barWnd, hRgn, TRUE );
+
        ShowWindow(barWnd, SW_SHOWNORMAL);
 }
index 9867e9d..d562d2f 100644 (file)
@@ -23,8 +23,8 @@
 typedef struct _FloatBar FloatBar;
 typedef struct wf_context wfContext;
 
-void floatbar_window_create(wfContext* wfc);
-int floatbar_show(FloatBar* floatbar);
-int floatbar_hide(FloatBar* floatbar);
+void floatbar_window_create(wfContext* const wfc);
+int floatbar_show(const FloatBar* const floatbar);
+int floatbar_hide(const FloatBar* const floatbar);
 
 #endif /* FREERDP_CLIENT_WIN_FLOATBAR_H */
index 135f641..e5bfc9c 100644 (file)
Binary files a/client/Windows/wfreerdp.rc and b/client/Windows/wfreerdp.rc differ