From 4dffc9f58d81a0df77da97a485c3ffe54a6e1ddb Mon Sep 17 00:00:00 2001
From: Ilya Shpigor <shpigor@etersoft.ru>
Date: Thu, 26 Feb 2009 10:45:36 +0300
Subject: [PATCH] user32: Exclude the icon title using for minimized windows (eterbug #1011)

---
 dlls/user32/Makefile.in |    1 -
 dlls/user32/class.c     |    1 -
 dlls/user32/icontitle.c |  241 -----------------------------------------------
 dlls/user32/nonclient.c |    5 +-
 dlls/user32/win.c       |    3 -
 dlls/user32/win.h       |    1 -
 dlls/user32/winpos.c    |   76 ---------------
 7 files changed, 1 insertions(+), 327 deletions(-)
 delete mode 100644 dlls/user32/icontitle.c

diff --git a/dlls/user32/Makefile.in b/dlls/user32/Makefile.in
index 28d6fbd..81c9895 100644
--- a/dlls/user32/Makefile.in
+++ b/dlls/user32/Makefile.in
@@ -37,7 +37,6 @@ C_SRCS = \
 	exticon.c \
 	focus.c \
 	hook.c \
-	icontitle.c \
 	input.c \
 	listbox.c \
 	lstr.c \
diff --git a/dlls/user32/class.c b/dlls/user32/class.c
index e94cd2b..7f40641 100644
--- a/dlls/user32/class.c
+++ b/dlls/user32/class.c
@@ -417,7 +417,6 @@ void CLASS_RegisterBuiltinClasses(void)
     register_builtin( &COMBOLBOX_builtin_class );
     register_builtin( &DIALOG_builtin_class );
     EDIT_winproc_handle = register_builtin( &EDIT_builtin_class );
-    register_builtin( &ICONTITLE_builtin_class );
     register_builtin( &LISTBOX_builtin_class );
     register_builtin( &MDICLIENT_builtin_class );
     register_builtin( &MENU_builtin_class );
diff --git a/dlls/user32/icontitle.c b/dlls/user32/icontitle.c
deleted file mode 100644
index 8217f83..0000000
--- a/dlls/user32/icontitle.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Icontitle window class.
- *
- * Copyright 1997 Alex Korobka
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "config.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#include "windef.h"
-#include "winbase.h"
-#include "wingdi.h"
-#include "winuser.h"
-#include "wine/unicode.h"
-#include "controls.h"
-#include "win.h"
-
-static BOOL bMultiLineTitle;
-static HFONT hIconTitleFont;
-
-static LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
-
-/*********************************************************************
- * icon title class descriptor
- */
-const struct builtin_class_descr ICONTITLE_builtin_class =
-{
-    (LPCWSTR)ICONTITLE_CLASS_ATOM, /* name */
-    0,                    /* style */
-    NULL,                 /* procA (winproc is Unicode only) */
-    IconTitleWndProc,     /* procW */
-    0,                    /* extra */
-    IDC_ARROW,            /* cursor */
-    0                     /* brush */
-};
-
-
-
-/***********************************************************************
- *           ICONTITLE_Create
- */
-HWND ICONTITLE_Create( HWND owner )
-{
-    HWND hWnd;
-    HINSTANCE instance = (HINSTANCE)GetWindowLongPtrA( owner, GWLP_HINSTANCE );
-    LONG style = WS_CLIPSIBLINGS;
-
-    if (!IsWindowEnabled(owner)) style |= WS_DISABLED;
-    if( GetWindowLongA( owner, GWL_STYLE ) & WS_CHILD )
-	hWnd = CreateWindowExA( 0, (LPCSTR)ICONTITLE_CLASS_ATOM, NULL,
-                                style | WS_CHILD, 0, 0, 1, 1,
-                                GetParent(owner), 0, instance, NULL );
-    else
-	hWnd = CreateWindowExA( 0, (LPCSTR)ICONTITLE_CLASS_ATOM, NULL,
-                                style, 0, 0, 1, 1,
-                                owner, 0, instance, NULL );
-    WIN_SetOwner( hWnd, owner );  /* MDI depends on this */
-    SetWindowLongW( hWnd, GWL_STYLE,
-                    GetWindowLongW( hWnd, GWL_STYLE ) & ~(WS_CAPTION | WS_BORDER) );
-    return hWnd;
-}
-
-/***********************************************************************
- *           ICONTITLE_SetTitlePos
- */
-static BOOL ICONTITLE_SetTitlePos( HWND hwnd, HWND owner )
-{
-    static const WCHAR emptyTitleText[] = {'<','.','.','.','>',0};
-    WCHAR str[80];
-    HDC hDC;
-    HFONT hPrevFont;
-    RECT rect;
-    INT cx, cy;
-    POINT pt;
-
-    int length = GetWindowTextW( owner, str, sizeof(str)/sizeof(WCHAR) );
-
-    while (length && str[length - 1] == ' ') /* remove trailing spaces */
-        str[--length] = 0;
-
-    if( !length )
-    {
-        strcpyW( str, emptyTitleText );
-        length = strlenW( str );
-    }
-
-    if (!(hDC = GetDC( hwnd ))) return FALSE;
-
-    hPrevFont = SelectObject( hDC, hIconTitleFont );
-
-    SetRect( &rect, 0, 0, GetSystemMetrics(SM_CXICONSPACING) -
-             GetSystemMetrics(SM_CXBORDER) * 2,
-             GetSystemMetrics(SM_CYBORDER) * 2 );
-
-    DrawTextW( hDC, str, length, &rect, DT_CALCRECT | DT_CENTER | DT_NOPREFIX | DT_WORDBREAK |
-               (( bMultiLineTitle ) ? 0 : DT_SINGLELINE) );
-
-    SelectObject( hDC, hPrevFont );
-    ReleaseDC( hwnd, hDC );
-
-    cx = rect.right - rect.left +  4 * GetSystemMetrics(SM_CXBORDER);
-    cy = rect.bottom - rect.top;
-
-    pt.x = (GetSystemMetrics(SM_CXICON) - cx) / 2;
-    pt.y = GetSystemMetrics(SM_CYICON);
-
-    /* point is relative to owner, make it relative to parent */
-    MapWindowPoints( owner, GetParent(hwnd), &pt, 1 );
-
-    SetWindowPos( hwnd, owner, pt.x, pt.y, cx, cy, SWP_NOACTIVATE );
-    return TRUE;
-}
-
-/***********************************************************************
- *           ICONTITLE_Paint
- */
-static BOOL ICONTITLE_Paint( HWND hwnd, HWND owner, HDC hDC, BOOL bActive )
-{
-    RECT rect;
-    HFONT hPrevFont;
-    HBRUSH hBrush = 0;
-    COLORREF textColor = 0;
-
-    if( bActive )
-    {
-	hBrush = GetSysColorBrush(COLOR_ACTIVECAPTION);
-	textColor = GetSysColor(COLOR_CAPTIONTEXT);
-    }
-    else
-    {
-        if( GetWindowLongA( hwnd, GWL_STYLE ) & WS_CHILD )
-	{
-	    hBrush = (HBRUSH) GetClassLongPtrW(hwnd, GCLP_HBRBACKGROUND);
-	    if( hBrush )
-	    {
-		INT level;
-		LOGBRUSH logBrush;
-		GetObjectA( hBrush, sizeof(logBrush), &logBrush );
-		level = GetRValue(logBrush.lbColor) +
-			   GetGValue(logBrush.lbColor) +
-			      GetBValue(logBrush.lbColor);
-		if( level < (0x7F * 3) )
-		    textColor = RGB( 0xFF, 0xFF, 0xFF );
-	    }
-	    else
-		hBrush = GetStockObject( WHITE_BRUSH );
-	}
-	else
-	{
-	    hBrush = GetStockObject( BLACK_BRUSH );
-	    textColor = RGB( 0xFF, 0xFF, 0xFF );
-	}
-    }
-
-    GetClientRect( hwnd, &rect );
-    DPtoLP( hDC, (LPPOINT)&rect, 2 );
-    FillRect( hDC, &rect, hBrush );
-
-    hPrevFont = SelectObject( hDC, hIconTitleFont );
-    if( hPrevFont )
-    {
-	WCHAR buffer[80];
-
-        INT length = GetWindowTextW( owner, buffer, sizeof(buffer)/sizeof(buffer[0]) );
-        SetTextColor( hDC, textColor );
-        SetBkMode( hDC, TRANSPARENT );
-
-        DrawTextW( hDC, buffer, length, &rect, DT_CENTER | DT_NOPREFIX |
-                   DT_WORDBREAK | ((bMultiLineTitle) ? 0 : DT_SINGLELINE) );
-
-	SelectObject( hDC, hPrevFont );
-    }
-    return (hPrevFont != 0);
-}
-
-/***********************************************************************
- *           IconTitleWndProc
- */
-LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg,
-                                 WPARAM wParam, LPARAM lParam )
-{
-    HWND owner = GetWindow( hWnd, GW_OWNER );
-
-    if (!IsWindow(hWnd)) return 0;
-
-    switch( msg )
-    {
-        case WM_CREATE:
-            if (!hIconTitleFont)
-            {
-                LOGFONTA logFont;
-                SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 );
-                SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &bMultiLineTitle, 0 );
-                hIconTitleFont = CreateFontIndirectA( &logFont );
-            }
-            return (hIconTitleFont ? 0 : -1);
-	case WM_NCHITTEST:
-	     return HTCAPTION;
-	case WM_NCMOUSEMOVE:
-	case WM_NCLBUTTONDOWN:
-	case WM_NCLBUTTONDBLCLK:
-	     return SendMessageW( owner, msg, wParam, lParam );
-	case WM_ACTIVATE:
-	     if( wParam ) SetActiveWindow( owner );
-             return 0;
-	case WM_CLOSE:
-	     return 0;
-	case WM_SHOWWINDOW:
-            if (wParam) ICONTITLE_SetTitlePos( hWnd, owner );
-	     return 0;
-	case WM_ERASEBKGND:
-            if( GetWindowLongW( owner, GWL_STYLE ) & WS_CHILD )
-                lParam = SendMessageW( owner, WM_ISACTIVEICON, 0, 0 );
-            else
-                lParam = (owner == GetActiveWindow());
-            if( ICONTITLE_Paint( hWnd, owner, (HDC)wParam, (BOOL)lParam ) )
-                ValidateRect( hWnd, NULL );
-            return 1;
-    }
-    return DefWindowProcW( hWnd, msg, wParam, lParam );
-}
diff --git a/dlls/user32/nonclient.c b/dlls/user32/nonclient.c
index 910ce6e..f265512 100644
--- a/dlls/user32/nonclient.c
+++ b/dlls/user32/nonclient.c
@@ -1145,10 +1145,7 @@ LRESULT NC_HandleNCActivate( HWND hwnd, WPARAM wParam, LPARAM lParam )
      */
     if (lParam != -1)
     {
-        if (IsIconic(hwnd))
-            WINPOS_RedrawIconTitle( hwnd );
-        else
-            NC_DoNCPaint( hwnd, (HRGN)1, FALSE );
+        NC_DoNCPaint( hwnd, (HRGN)1, FALSE );
     }
 
     return TRUE;
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 797fe07..1fa57a7 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -664,7 +664,6 @@ LRESULT WIN_DestroyWindow( HWND hwnd )
     WND *wndPtr;
     HWND *list;
     HMENU menu = 0, sys_menu;
-    HWND icon_title;
 
     TRACE("%p\n", hwnd );
 
@@ -704,10 +703,8 @@ LRESULT WIN_DestroyWindow( HWND hwnd )
     sys_menu = wndPtr->hSysMenu;
     free_dce( wndPtr->dce, hwnd );
     wndPtr->dce = NULL;
-    icon_title = wndPtr->icon_title;
     WIN_ReleasePtr( wndPtr );
 
-    if (icon_title) DestroyWindow( icon_title );
     if (menu) DestroyMenu( menu );
     if (sys_menu) DestroyMenu( sys_menu );
 
diff --git a/dlls/user32/win.h b/dlls/user32/win.h
index 2311773..707311a 100644
--- a/dlls/user32/win.h
+++ b/dlls/user32/win.h
@@ -49,7 +49,6 @@ typedef struct tagWND
     RECT           normal_rect;   /* Normal window rect saved when maximized/minimized */
     POINT          min_pos;       /* Position for minimized window */
     POINT          max_pos;       /* Position for maximized window */
-    HWND           icon_title;    /* Icon title window */
     LPWSTR         text;          /* Window text */
     void          *pVScroll;      /* Vertical scroll-bar info */
     void          *pHScroll;      /* Horizontal scroll-bar info */
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index 7bb65c5..e80298d 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -591,66 +591,6 @@ BOOL WINAPI MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
 }
 
 
-/***********************************************************************
- *           WINPOS_RedrawIconTitle
- */
-BOOL WINPOS_RedrawIconTitle( HWND hWnd )
-{
-    HWND icon_title = 0;
-    WND *win = WIN_GetPtr( hWnd );
-
-    if (win && win != WND_OTHER_PROCESS && win != WND_DESKTOP)
-    {
-	icon_title = win->icon_title;
-        WIN_ReleasePtr( win );
-    }
-    if (!icon_title) return FALSE;
-    SendMessageW( icon_title, WM_SHOWWINDOW, TRUE, 0 );
-    InvalidateRect( icon_title, NULL, TRUE );
-    return TRUE;
-}
-
-/***********************************************************************
- *           WINPOS_ShowIconTitle
- */
-static BOOL WINPOS_ShowIconTitle( HWND hwnd, BOOL bShow )
-{
-    if (!GetPropA( hwnd, "__wine_x11_managed" ))
-    {
-        WND *win = WIN_GetPtr( hwnd );
-        HWND title = 0;
-
-	TRACE("%p %i\n", hwnd, (bShow != 0) );
-
-        if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP) return FALSE;
-        title = win->icon_title;
-        WIN_ReleasePtr( win );
-
-	if( bShow )
-        {
-            if (!title)
-            {
-                title = ICONTITLE_Create( hwnd );
-                if (!(win = WIN_GetPtr( hwnd )) || win == WND_OTHER_PROCESS)
-                {
-                    DestroyWindow( title );
-                    return FALSE;
-                }
-                win->icon_title = title;
-                WIN_ReleasePtr( win );
-            }
-            if (!IsWindowVisible(title))
-            {
-                SendMessageW( title, WM_SHOWWINDOW, TRUE, 0 );
-                SetWindowPos( title, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
-                              SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
-            }
-	}
-	else if (title) ShowWindow( title, SW_HIDE );
-    }
-    return FALSE;
-}
-
 /*******************************************************************
  *           WINPOS_GetMinMaxInfo
  *
@@ -885,7 +825,6 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
         WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL );
 
         old_style = WIN_SetStyle( hwnd, WS_MAXIMIZE, WS_MINIMIZE );
-        if (old_style & WS_MINIMIZE) WINPOS_ShowIconTitle( hwnd, FALSE );
 
         if (!(old_style & WS_MAXIMIZE)) swpFlags |= SWP_STATECHANGED;
         SetRect( rect, wpl.ptMaxPosition.x, wpl.ptMaxPosition.y,
@@ -900,8 +839,6 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
         {
             BOOL restore_max;
 
-            WINPOS_ShowIconTitle( hwnd, FALSE );
-
             if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
             restore_max = (wndPtr->flags & WIN_RESTORE_MAX) != 0;
             WIN_ReleasePtr( wndPtr );
@@ -1031,8 +968,6 @@ static BOOL show_window( HWND hwnd, INT cmd )
     {
         HWND hFocus;
 
-        WINPOS_ShowIconTitle( hwnd, FALSE );
-
         /* FIXME: This will cause the window to be activated irrespective
          * of whether it is owned by the same thread. Has to be done
          * asynchronously.
@@ -1052,8 +987,6 @@ static BOOL show_window( HWND hwnd, INT cmd )
         return wasVisible;
     }
 
-    if (IsIconic(hwnd)) WINPOS_ShowIconTitle( hwnd, TRUE );
-
     if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return wasVisible;
 
     if (wndPtr->flags & WIN_NEED_SIZE)
@@ -1295,7 +1228,6 @@ static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT f
     {
         if (flags & PLACE_MIN)
         {
-            WINPOS_ShowIconTitle( hwnd, FALSE );
             SetWindowPos( hwnd, 0, wp.ptMinPosition.x, wp.ptMinPosition.y, 0, 0,
                           SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
         }
@@ -1311,8 +1243,6 @@ static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT f
 
     if (IsIconic( hwnd ))
     {
-        if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE) WINPOS_ShowIconTitle( hwnd, TRUE );
-
         /* SDK: ...valid only the next time... */
         if( wndpl->flags & WPF_RESTORETOMAXIMIZED )
         {
@@ -2222,13 +2152,9 @@ UINT WINAPI ArrangeIconicWindows( HWND parent )
     {
         if( IsIconic( hwndChild ) )
         {
-            WINPOS_ShowIconTitle( hwndChild, FALSE );
-
             SetWindowPos( hwndChild, 0, x + (xspacing - GetSystemMetrics(SM_CXICON)) / 2,
                             y - yspacing - GetSystemMetrics(SM_CYICON)/2, 0, 0,
                             SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
-	    if( IsWindow(hwndChild) )
-                WINPOS_ShowIconTitle(hwndChild , TRUE );
 
             if (x <= rectParent.right - xspacing) x += xspacing;
             else
@@ -2530,7 +2456,6 @@ void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
                 {
                     hOldCursor = SetCursor(hDragCursor);
                     ShowCursor( TRUE );
-                    WINPOS_ShowIconTitle( hwnd, FALSE );
                 }
                 else if(!DragFullWindows)
                     draw_moving_frame( hdc, &sizingRect, thickframe );
@@ -2627,6 +2552,5 @@ void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
                 SendMessageW( hwnd, WM_SYSCOMMAND,
                               SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y));
         }
-        else WINPOS_ShowIconTitle( hwnd, TRUE );
     }
 }
-- 
1.6.1.3.GIT

