[MPlayer-cvslog] r34221 - trunk/gui/win32/gui.c

ib subversion at mplayerhq.hu
Thu Oct 20 14:48:36 CEST 2011


Author: ib
Date: Thu Oct 20 14:48:35 2011
New Revision: 34221

Log:
Support transparency in decorated windows in the Win32 GUI.

So far, the Win32 GUI only supports transparency in non-decorated
windows. Now there is equal support of skin transparency for both
GUIs, because skins are universal for both of them.

Modified:
   trunk/gui/win32/gui.c

Modified: trunk/gui/win32/gui.c
==============================================================================
--- trunk/gui/win32/gui.c	Thu Oct 20 14:24:00 2011	(r34220)
+++ trunk/gui/win32/gui.c	Thu Oct 20 14:48:35 2011	(r34221)
@@ -1240,16 +1240,23 @@ static void create_submenu(gui_t *gui)
 static void maketransparent(HWND hwnd, COLORREF crTransparent)
 {
     HDC mdc = GetDC(hwnd);
-    RECT rd;
+    RECT wrd, crd;
     HRGN crRgnres, crRgn, crRgnTmp;
     int iX = 0, iY = 0, iLeftX = 0;
+    int border, title;
     int width, height;
-    GetWindowRect(hwnd, &rd);
-    width = rd.right - rd.left;
-    height = rd.bottom - rd.top;
 
-    /* create an empty region */
-    crRgn = CreateRectRgn(0, 0, 0, 0);
+    GetWindowRect(hwnd, &wrd);
+    GetClientRect(hwnd, &crd);
+
+    border = (wrd.right - wrd.left - crd.right) / 2;
+    title = (wrd.bottom - wrd.top - crd.bottom) - border;
+
+    width = crd.right - crd.left;
+    height = crd.bottom - crd.top;
+
+    /* create the title bar region */
+    crRgn = CreateRectRgn(0, 0, width + border + border, title);
 
     /* Create a region from a bitmap with transparency colour of Purple */
     for (iY = -1; iY < height; iY++)
@@ -1262,11 +1269,11 @@ static void maketransparent(HWND hwnd, C
             /* remember this pixel */
             iLeftX = iX;
 
-            /* now find first non transparent pixel */
+            /* now find last non transparent pixel */
             while (iX <= width && GetPixel(mdc,iX, iY) != crTransparent) ++iX;
 
             /* create a temp region on this info */
-            crRgnTmp = CreateRectRgn(iLeftX, iY, iX, iY+1);
+            crRgnTmp = CreateRectRgn(iLeftX + border, iY + title, iX + border, iY + title + 1);
 
             /* combine into main region */
             crRgnres = crRgn;
@@ -1278,6 +1285,22 @@ static void maketransparent(HWND hwnd, C
         } while (iX < width);
         iX = 0;
     }
+
+    /* left border region */
+    crRgnTmp = CreateRectRgn(0, title, border, title + height);
+    CombineRgn(crRgn, crRgn, crRgnTmp, RGN_OR);
+    DeleteObject(crRgnTmp);
+
+    /* right border region */
+    crRgnTmp = CreateRectRgn(width + border, title, width + border + border, title + height);
+    CombineRgn(crRgn, crRgn, crRgnTmp, RGN_OR);
+    DeleteObject(crRgnTmp);
+
+    /* bottom region */
+    crRgnTmp = CreateRectRgn(0, title + height, width + border + border, title + height + border);
+    CombineRgn(crRgn, crRgn, crRgnTmp, RGN_OR);
+    DeleteObject(crRgnTmp);
+
     SetWindowRgn(hwnd, crRgn, TRUE);
     DeleteObject(crRgn);
     ReleaseDC(hwnd,mdc);


More information about the MPlayer-cvslog mailing list