Module: wine Branch: master Commit: 94e65bae5421be51559c1c12f142b5fc26648094 URL: http://source.winehq.org/git/wine.git/?a=commit;h=94e65bae5421be51559c1c12f1...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Oct 18 12:11:17 2010 +0200
winex11: Avoid creating a DC when not necessary.
---
dlls/winex11.drv/mouse.c | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index b3e5fcf..0b87c44 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -830,19 +830,13 @@ done: static Cursor create_cursor( HANDLE handle ) { Cursor cursor = 0; - HDC hdc; ICONINFOEXW info; BITMAP bm;
if (!handle) return get_empty_cursor();
- if (!(hdc = CreateCompatibleDC( 0 ))) return 0; info.cbSize = sizeof(info); - if (!GetIconInfoExW( handle, &info )) - { - DeleteDC( hdc ); - return 0; - } + if (!GetIconInfoExW( handle, &info )) return 0;
GetObjectW( info.hbmMask, sizeof(bm), &bm ); if (!info.hbmColor) bm.bmHeight /= 2; @@ -856,11 +850,17 @@ static Cursor create_cursor( HANDLE handle )
if (info.hbmColor) { + HDC hdc = CreateCompatibleDC( 0 ); + if (hdc) + { #ifdef SONAME_LIBXCURSOR - if (pXcursorImagesLoadCursor) cursor = create_xcursor_cursor( hdc, &info, handle, bm.bmWidth, bm.bmHeight ); + if (pXcursorImagesLoadCursor) + cursor = create_xcursor_cursor( hdc, &info, handle, bm.bmWidth, bm.bmHeight ); #endif - if (!cursor) cursor = create_xlib_cursor( hdc, &info, bm.bmWidth, bm.bmHeight ); + if (!cursor) cursor = create_xlib_cursor( hdc, &info, bm.bmWidth, bm.bmHeight ); + } DeleteObject( info.hbmColor ); + DeleteDC( hdc ); } else { @@ -872,7 +872,6 @@ static Cursor create_cursor( HANDLE handle ) }
DeleteObject( info.hbmMask ); - DeleteDC( hdc ); return cursor; }