winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
May 2012
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
737 discussions
Start a n
N
ew thread
Alexandre Julliard : winex11: Use the create_pixmap_from_image helper to create window icons.
by Alexandre Julliard
16 May '12
16 May '12
Module: wine Branch: master Commit: c2073b7ba2af154af0c10d528ad6bb98ada1aaad URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c2073b7ba2af154af0c10d528…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue May 15 20:58:39 2012 +0200 winex11: Use the create_pixmap_from_image helper to create window icons. --- dlls/winex11.drv/window.c | 110 +++++++++++++++++++++++++++++++++------------ dlls/winex11.drv/x11drv.h | 4 +- 2 files changed, 83 insertions(+), 31 deletions(-) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 193a165..720a49c 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -804,14 +804,14 @@ static void destroy_icon_window( Display *display, struct x11drv_win_data *data */ static unsigned long *get_bitmap_argb( HDC hdc, HBITMAP color, HBITMAP mask, unsigned int *size ) { + char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + BITMAPINFO *info = (BITMAPINFO *)buffer; BITMAP bm; - BITMAPINFO *info; unsigned int *ptr, *bits = NULL; unsigned char *mask_bits = NULL; int i, j, has_alpha = 0; if (!GetObjectW( color, sizeof(bm), &bm )) return NULL; - if (!(info = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] )))) return NULL; info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); info->bmiHeader.biWidth = bm.bmWidth; info->bmiHeader.biHeight = -bm.bmHeight; @@ -856,7 +856,6 @@ static unsigned long *get_bitmap_argb( HDC hdc, HBITMAP color, HBITMAP mask, uns return (unsigned long *)bits; failed: - HeapFree( GetProcessHeap(), 0, info ); HeapFree( GetProcessHeap(), 0, bits ); HeapFree( GetProcessHeap(), 0, mask_bits ); return NULL; @@ -864,6 +863,69 @@ failed: /*********************************************************************** + * create_icon_pixmaps + */ +static BOOL create_icon_pixmaps( HDC hdc, const ICONINFO *icon, struct x11drv_win_data *data ) +{ + char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + BITMAPINFO *info = (BITMAPINFO *)buffer; + XVisualInfo vis; + struct gdi_image_bits bits; + Pixmap color_pixmap = 0, mask_pixmap = 0; + int i, lines; + + bits.ptr = NULL; + bits.free = NULL; + bits.is_copy = TRUE; + + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info->bmiHeader.biBitCount = 0; + if (!(lines = GetDIBits( hdc, icon->hbmColor, 0, 0, NULL, info, DIB_RGB_COLORS ))) goto failed; + if (!(bits.ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto failed; + if (!GetDIBits( hdc, icon->hbmColor, 0, lines, bits.ptr, info, DIB_RGB_COLORS )) goto failed; + + vis.visual = visual; + vis.depth = screen_depth; + vis.visualid = visual->visualid; + vis.class = visual->class; + vis.red_mask = visual->red_mask; + vis.green_mask = visual->green_mask; + vis.blue_mask = visual->blue_mask; + color_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS ); + HeapFree( GetProcessHeap(), 0, bits.ptr ); + bits.ptr = NULL; + if (!color_pixmap) goto failed; + + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info->bmiHeader.biBitCount = 0; + if (!(lines = GetDIBits( hdc, icon->hbmMask, 0, 0, NULL, info, DIB_RGB_COLORS ))) goto failed; + if (!(bits.ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto failed; + if (!GetDIBits( hdc, icon->hbmMask, 0, lines, bits.ptr, info, DIB_RGB_COLORS )) goto failed; + + /* invert the mask */ + for (i = 0; i < info->bmiHeader.biSizeImage / sizeof(DWORD); i++) ((DWORD *)bits.ptr)[i] ^= ~0u; + + vis.depth = 1; + mask_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS ); + HeapFree( GetProcessHeap(), 0, bits.ptr ); + bits.ptr = NULL; + if (!mask_pixmap) goto failed; + + data->icon_pixmap = color_pixmap; + data->icon_mask = mask_pixmap; + return TRUE; + +failed: + wine_tsx11_lock(); + if (color_pixmap) XFreePixmap( gdi_display, color_pixmap ); + if (mask_pixmap) XFreePixmap( gdi_display, mask_pixmap ); + wine_tsx11_unlock(); + HeapFree( GetProcessHeap(), 0, bits.ptr ); + return FALSE; +} + + +/*********************************************************************** * set_icon_hints * * Set the icon wm hints @@ -884,10 +946,11 @@ static void set_icon_hints( Display *display, struct x11drv_win_data *data, if (!icon_small) icon_small = (HICON)GetClassLongPtrW( data->hwnd, GCLP_HICONSM ); } - if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap ); - if (data->hWMIconMask) DeleteObject( data->hWMIconMask); - data->hWMIconBitmap = 0; - data->hWMIconMask = 0; + wine_tsx11_lock(); + if (data->icon_pixmap) XFreePixmap( gdi_display, data->icon_pixmap ); + if (data->icon_mask) XFreePixmap( gdi_display, data->icon_mask ); + data->icon_pixmap = data->icon_mask = 0; + wine_tsx11_unlock(); if (!icon_big) { @@ -897,9 +960,6 @@ static void set_icon_hints( Display *display, struct x11drv_win_data *data, } else { - HBITMAP hbmOrig; - RECT rcMask; - BITMAP bm; ICONINFO ii, ii_small; HDC hDC; unsigned int size; @@ -907,12 +967,6 @@ static void set_icon_hints( Display *display, struct x11drv_win_data *data, if (!GetIconInfo(icon_big, &ii)) return; - GetObjectW(ii.hbmMask, sizeof(bm), &bm); - rcMask.top = 0; - rcMask.left = 0; - rcMask.right = bm.bmWidth; - rcMask.bottom = bm.bmHeight; - hDC = CreateCompatibleDC(0); bits = get_bitmap_argb( hDC, ii.hbmColor, ii.hbmMask, &size ); if (bits && GetIconInfo( icon_small, &ii_small )) @@ -944,19 +998,17 @@ static void set_icon_hints( Display *display, struct x11drv_win_data *data, wine_tsx11_unlock(); HeapFree( GetProcessHeap(), 0, bits ); - hbmOrig = SelectObject(hDC, ii.hbmMask); - InvertRect(hDC, &rcMask); - SelectObject(hDC, ii.hbmColor); /* force the color bitmap to x11drv mode too */ - SelectObject(hDC, hbmOrig); - - data->hWMIconBitmap = ii.hbmColor; - data->hWMIconMask = ii.hbmMask; - - hints->icon_pixmap = X11DRV_get_pixmap(data->hWMIconBitmap); - hints->icon_mask = X11DRV_get_pixmap(data->hWMIconMask); + if (create_icon_pixmaps( hDC, &ii, data )) + { + hints->icon_pixmap = data->icon_pixmap; + hints->icon_mask = data->icon_mask; + hints->flags |= IconPixmapHint | IconMaskHint; + } destroy_icon_window( display, data ); - hints->flags = (hints->flags & ~IconWindowHint) | IconPixmapHint | IconMaskHint; + hints->flags &= ~IconWindowHint; + DeleteObject( ii.hbmColor ); + DeleteObject( ii.hbmMask ); DeleteDC(hDC); } } @@ -1894,9 +1946,9 @@ void CDECL X11DRV_DestroyWindow( HWND hwnd ) if (thread_data->last_focus == hwnd) thread_data->last_focus = 0; if (thread_data->last_xic_hwnd == hwnd) thread_data->last_xic_hwnd = 0; - if (data->hWMIconBitmap) DeleteObject( data->hWMIconBitmap ); - if (data->hWMIconMask) DeleteObject( data->hWMIconMask); wine_tsx11_lock(); + if (data->icon_pixmap) XFreePixmap( gdi_display, data->icon_pixmap ); + if (data->icon_mask) XFreePixmap( gdi_display, data->icon_mask ); XDeleteContext( thread_data->display, (XID)hwnd, win_data_context ); wine_tsx11_unlock(); HeapFree( GetProcessHeap(), 0, data ); diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 7ed4bdd..9b05e3e 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -592,8 +592,8 @@ struct x11drv_win_data DWORD net_wm_state; /* bit mask of active x11drv_net_wm_state values */ Window embedder; /* window id of embedder */ unsigned long configure_serial; /* serial number of last configure request */ - HBITMAP hWMIconBitmap; - HBITMAP hWMIconMask; + Pixmap icon_pixmap; + Pixmap icon_mask; }; extern struct x11drv_win_data *X11DRV_get_win_data( HWND hwnd ) DECLSPEC_HIDDEN;
1
0
0
0
Alexandre Julliard : winex11: Use the create_pixmap_from_image helper to create monochrome cursors.
by Alexandre Julliard
15 May '12
15 May '12
Module: wine Branch: master Commit: 8ee12778f90d7796fff2f1befa385d576fe7d2d8 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8ee12778f90d7796fff2f1bef…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue May 15 16:18:34 2012 +0200 winex11: Use the create_pixmap_from_image helper to create monochrome cursors. --- dlls/winex11.drv/mouse.c | 126 ++++++++++++++++++++++++++-------------------- 1 files changed, 72 insertions(+), 54 deletions(-) diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index ef9dca9..718efa6 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -936,24 +936,51 @@ done: /*********************************************************************** - * create_cursor_from_bitmaps + * create_xlib_monochrome_cursor * - * Create an X11 cursor from source bitmaps. + * Create a monochrome X cursor from a Windows one. */ -static Cursor create_cursor_from_bitmaps( HBITMAP src_xor, HBITMAP src_and, int width, int height, - int xor_y, int and_y, XColor *fg, XColor *bg, - int hotspot_x, int hotspot_y ) +static Cursor create_xlib_monochrome_cursor( HDC hdc, const ICONINFOEXW *icon, int width, int height ) { - HDC src = 0, dst = 0; - HBITMAP bits = 0, mask = 0, mask_inv = 0; + char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + BITMAPINFO *info = (BITMAPINFO *)buffer; + const int and_y = 0; + const int xor_y = height; + unsigned int width_bytes = (width + 31) / 32 * 4; + unsigned char *mask_bits = NULL; + GC gc; + XColor fg, bg; + XVisualInfo vis; + Pixmap src_pixmap, bits_pixmap, mask_pixmap; + struct gdi_image_bits bits; Cursor cursor = 0; - if (!(src = CreateCompatibleDC( 0 ))) goto done; - if (!(dst = CreateCompatibleDC( 0 ))) goto done; + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info->bmiHeader.biWidth = width; + info->bmiHeader.biHeight = -height * 2; + info->bmiHeader.biPlanes = 1; + info->bmiHeader.biBitCount = 1; + info->bmiHeader.biCompression = BI_RGB; + info->bmiHeader.biSizeImage = width_bytes * height * 2; + info->bmiHeader.biXPelsPerMeter = 0; + info->bmiHeader.biYPelsPerMeter = 0; + info->bmiHeader.biClrUsed = 0; + info->bmiHeader.biClrImportant = 0; + + if (!(mask_bits = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto done; + if (!GetDIBits( hdc, icon->hbmMask, 0, height * 2, mask_bits, info, DIB_RGB_COLORS )) goto done; + + vis.depth = 1; + bits.ptr = mask_bits; + bits.free = NULL; + bits.is_copy = TRUE; + if (!(src_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS ))) goto done; - if (!(bits = CreateBitmap( width, height, 1, 1, NULL ))) goto done; - if (!(mask = CreateBitmap( width, height, 1, 1, NULL ))) goto done; - if (!(mask_inv = CreateBitmap( width, height, 1, 1, NULL ))) goto done; + wine_tsx11_lock(); + bits_pixmap = XCreatePixmap( gdi_display, root_window, width, height, 1 ); + mask_pixmap = XCreatePixmap( gdi_display, root_window, width, height, 1 ); + gc = XCreateGC( gdi_display, src_pixmap, 0, NULL ); + XSetGraphicsExposures( gdi_display, gc, False ); /* We have to do some magic here, as cursors are not fully * compatible between Windows and X11. Under X11, there are @@ -973,45 +1000,41 @@ static Cursor create_cursor_from_bitmaps( HBITMAP src_xor, HBITMAP src_and, int * Bits = not 'And' and 'Xor' or 'And2' and 'Xor2' * Mask = not 'And' or 'Xor' or 'And2' and 'Xor2' */ - SelectObject( src, src_and ); - SelectObject( dst, bits ); - BitBlt( dst, 0, 0, width, height, src, 0, and_y, SRCCOPY ); - SelectObject( dst, mask ); - BitBlt( dst, 0, 0, width, height, src, 0, and_y, SRCCOPY ); - SelectObject( dst, mask_inv ); - BitBlt( dst, 0, 0, width, height, src, 0, and_y, SRCCOPY ); - SelectObject( src, src_xor ); - BitBlt( dst, 0, 0, width, height, src, 0, xor_y, SRCAND /* src & dst */ ); - SelectObject( dst, bits ); - BitBlt( dst, 0, 0, width, height, src, 0, xor_y, SRCERASE /* src & ~dst */ ); - SelectObject( dst, mask ); - BitBlt( dst, 0, 0, width, height, src, 0, xor_y, 0xdd0228 /* src | ~dst */ ); + XSetFunction( gdi_display, gc, GXcopy ); + XCopyArea( gdi_display, src_pixmap, bits_pixmap, gc, 0, and_y, width, height, 0, 0 ); + XCopyArea( gdi_display, src_pixmap, mask_pixmap, gc, 0, and_y, width, height, 0, 0 ); + XSetFunction( gdi_display, gc, GXandReverse ); + XCopyArea( gdi_display, src_pixmap, bits_pixmap, gc, 0, xor_y, width, height, 0, 0 ); + XSetFunction( gdi_display, gc, GXorReverse ); + XCopyArea( gdi_display, src_pixmap, mask_pixmap, gc, 0, xor_y, width, height, 0, 0 ); /* additional white */ - SelectObject( src, mask_inv ); - BitBlt( dst, 1, 1, width, height, src, 0, 0, SRCPAINT /* src | dst */); - SelectObject( dst, bits ); - BitBlt( dst, 1, 1, width, height, src, 0, 0, SRCPAINT /* src | dst */ ); - - wine_tsx11_lock(); - cursor = XCreatePixmapCursor( gdi_display, X11DRV_get_pixmap(bits), X11DRV_get_pixmap(mask), - fg, bg, hotspot_x, hotspot_y ); + XSetFunction( gdi_display, gc, GXand ); + XCopyArea( gdi_display, src_pixmap, src_pixmap, gc, 0, xor_y, width, height, 0, and_y ); + XSetFunction( gdi_display, gc, GXor ); + XCopyArea( gdi_display, src_pixmap, mask_pixmap, gc, 0, and_y, width, height, 1, 1 ); + XCopyArea( gdi_display, src_pixmap, bits_pixmap, gc, 0, and_y, width, height, 1, 1 ); + XFreeGC( gdi_display, gc ); + + fg.red = fg.green = fg.blue = 0xffff; + bg.red = bg.green = bg.blue = 0; + cursor = XCreatePixmapCursor( gdi_display, bits_pixmap, mask_pixmap, + &fg, &bg, icon->xHotspot, icon->yHotspot ); + XFreePixmap( gdi_display, src_pixmap ); + XFreePixmap( gdi_display, bits_pixmap ); + XFreePixmap( gdi_display, mask_pixmap ); wine_tsx11_unlock(); done: - DeleteDC( src ); - DeleteDC( dst ); - DeleteObject( bits ); - DeleteObject( mask ); - DeleteObject( mask_inv ); + HeapFree( GetProcessHeap(), 0, mask_bits ); return cursor; } /*********************************************************************** - * create_xlib_cursor + * create_xlib_color_cursor * - * Create an X cursor from a Windows one. + * Create a color X cursor from a Windows one. */ -static Cursor create_xlib_cursor( HDC hdc, const ICONINFOEXW *icon, int width, int height ) +static Cursor create_xlib_color_cursor( HDC hdc, const ICONINFOEXW *icon, int width, int height ) { char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; BITMAPINFO *info = (BITMAPINFO *)buffer; @@ -1148,6 +1171,7 @@ static Cursor create_cursor( HANDLE handle ) Cursor cursor = 0; ICONINFOEXW info; BITMAP bm; + HDC hdc; if (!handle) return get_empty_cursor(); @@ -1173,30 +1197,24 @@ static Cursor create_cursor( HANDLE handle ) info.yHotspot = bm.bmHeight / 2; } + hdc = CreateCompatibleDC( 0 ); + 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_color_cursor( hdc, &info, bm.bmWidth, bm.bmHeight ); DeleteObject( info.hbmColor ); - DeleteDC( hdc ); } else { - XColor fg, bg; - fg.red = fg.green = fg.blue = 0xffff; - bg.red = bg.green = bg.blue = 0; - cursor = create_cursor_from_bitmaps( info.hbmMask, info.hbmMask, bm.bmWidth, bm.bmHeight, - bm.bmHeight, 0, &fg, &bg, info.xHotspot, info.yHotspot ); + cursor = create_xlib_monochrome_cursor( hdc, &info, bm.bmWidth, bm.bmHeight ); } DeleteObject( info.hbmMask ); + DeleteDC( hdc ); return cursor; }
1
0
0
0
Alexandre Julliard : winex11: Use the create_pixmap_from_image helper to create color cursors.
by Alexandre Julliard
15 May '12
15 May '12
Module: wine Branch: master Commit: 70a9bb95186ffd5032a0bd177cb6aea2856816ea URL:
http://source.winehq.org/git/wine.git/?a=commit;h=70a9bb95186ffd5032a0bd177…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue May 15 15:46:23 2012 +0200 winex11: Use the create_pixmap_from_image helper to create color cursors. --- dlls/winex11.drv/mouse.c | 53 +++++++++++++++++++++++---------------------- 1 files changed, 27 insertions(+), 26 deletions(-) diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 2d38406..ef9dca9 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -1013,18 +1013,19 @@ done: */ static Cursor create_xlib_cursor( HDC hdc, const ICONINFOEXW *icon, int width, int height ) { + char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + BITMAPINFO *info = (BITMAPINFO *)buffer; XColor fg, bg; Cursor cursor = None; - HBITMAP xor_bitmap = 0; - BITMAPINFO *info; + XVisualInfo vis; + Pixmap xor_pixmap, mask_pixmap; + struct gdi_image_bits bits; unsigned int *color_bits = NULL, *ptr; unsigned char *mask_bits = NULL, *xor_bits = NULL; int i, x, y, has_alpha = 0; int rfg, gfg, bfg, rbg, gbg, bbg, fgBits, bgBits; unsigned int width_bytes = (width + 31) / 32 * 4; - if (!(info = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] )))) - return FALSE; info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); info->bmiHeader.biWidth = width; info->bmiHeader.biHeight = -height; @@ -1048,7 +1049,6 @@ static Cursor create_xlib_cursor( HDC hdc, const ICONINFOEXW *icon, int width, i /* compute fg/bg color and xor bitmap based on average of the color values */ - if (!(xor_bitmap = CreateBitmap( width, height, 1, 1, NULL ))) goto done; rfg = gfg = bfg = rbg = gbg = bbg = fgBits = 0; for (y = 0, ptr = color_bits; y < height; y++) { @@ -1090,8 +1090,8 @@ static Cursor create_xlib_cursor( HDC hdc, const ICONINFOEXW *icon, int width, i else bg.red = bg.green = bg.blue = 0; info->bmiHeader.biBitCount = 1; + info->bmiHeader.biClrUsed = 0; info->bmiHeader.biSizeImage = width_bytes * height; - SetDIBits( hdc, xor_bitmap, 0, height, xor_bits, info, DIB_RGB_COLORS ); /* generate mask from the alpha channel if we have one */ @@ -1100,37 +1100,38 @@ static Cursor create_xlib_cursor( HDC hdc, const ICONINFOEXW *icon, int width, i if (has_alpha) { - /* make sure the bitmaps are owned by x11drv */ - HBITMAP orig = SelectObject( hdc, icon->hbmMask ); - SelectObject( hdc, xor_bitmap ); - SelectObject( hdc, orig ); - memset( mask_bits, 0, width_bytes * height ); for (y = 0, ptr = color_bits; y < height; y++) for (x = 0; x < width; x++, ptr++) if ((*ptr >> 24) > 25) /* more than 10% alpha */ mask_bits[y * width_bytes + x / 8] |= 0x80 >> (x % 8); + } + else /* invert the mask */ + { + ptr = (unsigned int *)mask_bits; + for (i = 0; i < info->bmiHeader.biSizeImage / sizeof(*ptr); i++, ptr++) *ptr ^= ~0u; + } - info->bmiHeader.biBitCount = 1; - info->bmiHeader.biSizeImage = width_bytes * height; - SetDIBits( hdc, icon->hbmMask, 0, height, mask_bits, info, DIB_RGB_COLORS ); + vis.depth = 1; + bits.ptr = xor_bits; + bits.free = NULL; + bits.is_copy = TRUE; + if (!(xor_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS ))) goto done; - wine_tsx11_lock(); - cursor = XCreatePixmapCursor( gdi_display, - X11DRV_get_pixmap(xor_bitmap), - X11DRV_get_pixmap(icon->hbmMask), - &fg, &bg, icon->xHotspot, icon->yHotspot ); - wine_tsx11_unlock(); - } - else + bits.ptr = mask_bits; + mask_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS ); + + wine_tsx11_lock(); + if (mask_pixmap) { - cursor = create_cursor_from_bitmaps( xor_bitmap, icon->hbmMask, width, height, 0, 0, - &fg, &bg, icon->xHotspot, icon->yHotspot ); + cursor = XCreatePixmapCursor( gdi_display, xor_pixmap, mask_pixmap, + &fg, &bg, icon->xHotspot, icon->yHotspot ); + XFreePixmap( gdi_display, mask_pixmap ); } + XFreePixmap( gdi_display, xor_pixmap ); + wine_tsx11_unlock(); done: - DeleteObject( xor_bitmap ); - HeapFree( GetProcessHeap(), 0, info ); HeapFree( GetProcessHeap(), 0, color_bits ); HeapFree( GetProcessHeap(), 0, xor_bits ); HeapFree( GetProcessHeap(), 0, mask_bits );
1
0
0
0
Alexandre Julliard : winex11: Use the create_pixmap_from_image helper to export XA_PIXMAP clipboard formats .
by Alexandre Julliard
15 May '12
15 May '12
Module: wine Branch: master Commit: e85895e4c5eb46d1579adbf5e175d8b6f186f9bd URL:
http://source.winehq.org/git/wine.git/?a=commit;h=e85895e4c5eb46d1579adbf5e…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Fri May 11 15:27:04 2012 +0200 winex11: Use the create_pixmap_from_image helper to export XA_PIXMAP clipboard formats. --- dlls/winex11.drv/clipboard.c | 40 ++++++++++++++++------------------------ 1 files changed, 16 insertions(+), 24 deletions(-) diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index ac17bdd..8dc3f0e 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -1758,7 +1758,6 @@ static HANDLE X11DRV_CLIPBOARD_ExportString(Display *display, Window requestor, static HANDLE X11DRV_CLIPBOARD_ExportXAPIXMAP(Display *display, Window requestor, Atom aTarget, Atom rprop, LPWINE_CLIPDATA lpdata, LPDWORD lpBytes) { - HDC hdc, memdc; HANDLE hData; unsigned char* lpData; @@ -1770,33 +1769,26 @@ static HANDLE X11DRV_CLIPBOARD_ExportXAPIXMAP(Display *display, Window requestor if (!lpdata->drvData) /* If not already rendered */ { - /* Create a DDB from the DIB */ - - Pixmap pixmap = 0; - X_PHYSBITMAP *physBitmap; - HBITMAP hBmp; + Pixmap pixmap; + XVisualInfo vis; LPBITMAPINFO pbmi; + struct gdi_image_bits bits; + + memset( &vis, 0, sizeof(vis) ); + vis.visual = visual; + vis.depth = screen_depth; + vis.visualid = visual->visualid; + vis.class = visual->class; + vis.red_mask = visual->red_mask; + vis.green_mask = visual->green_mask; + vis.blue_mask = visual->blue_mask; - hdc = GetDC(0); pbmi = GlobalLock( lpdata->hData ); - hBmp = CreateDIBitmap( hdc, &pbmi->bmiHeader, CBM_INIT, - (LPBYTE)pbmi + bitmap_info_size( pbmi, DIB_RGB_COLORS ), - pbmi, DIB_RGB_COLORS ); + bits.ptr = (LPBYTE)pbmi + bitmap_info_size( pbmi, DIB_RGB_COLORS ); + bits.free = NULL; + bits.is_copy = FALSE; + pixmap = create_pixmap_from_image( 0, &vis, pbmi, &bits, DIB_RGB_COLORS ); GlobalUnlock( lpdata->hData ); - - /* make sure it's owned by x11drv */ - memdc = CreateCompatibleDC( hdc ); - SelectObject( memdc, hBmp ); - DeleteDC( memdc ); - - /* clear the physBitmap so that we can steal its pixmap */ - if ((physBitmap = X11DRV_get_phys_bitmap( hBmp ))) - { - pixmap = physBitmap->pixmap; - physBitmap->pixmap = 0; - } - DeleteObject( hBmp ); - ReleaseDC( 0, hdc ); lpdata->drvData = pixmap; }
1
0
0
0
Alexandre Julliard : winex11: Use the create_pixmap_from_image helper to select DIB pattern brushes.
by Alexandre Julliard
15 May '12
15 May '12
Module: wine Branch: master Commit: bf2ad337b55dbc8498b28ce78708c5ac62107461 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=bf2ad337b55dbc8498b28ce78…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Fri May 11 15:28:24 2012 +0200 winex11: Use the create_pixmap_from_image helper to select DIB pattern brushes. --- dlls/winex11.drv/brush.c | 47 ++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 41 insertions(+), 6 deletions(-) diff --git a/dlls/winex11.drv/brush.c b/dlls/winex11.drv/brush.c index ea41f8a..6574eb8 100644 --- a/dlls/winex11.drv/brush.c +++ b/dlls/winex11.drv/brush.c @@ -280,6 +280,45 @@ HBITMAP create_brush_bitmap( X11DRV_PDEVICE *physDev, const struct brush_pattern return bitmap; } +static BOOL select_pattern_brush( X11DRV_PDEVICE *physdev, const struct brush_pattern *pattern ) +{ + XVisualInfo vis; + Pixmap pixmap; + const BITMAPINFO *info = pattern->info; + + memset( &vis, 0, sizeof(vis) ); + vis.visual = visual; + vis.visualid = visual->visualid; + + if (physdev->depth > 1 && info->bmiHeader.biBitCount > 1) + { + vis.depth = screen_depth; + vis.red_mask = visual->red_mask; + vis.green_mask = visual->green_mask; + vis.blue_mask = visual->blue_mask; + } + else vis.depth = 1; + + pixmap = create_pixmap_from_image( physdev->dev.hdc, &vis, info, &pattern->bits, pattern->usage ); + if (!pixmap) return FALSE; + + wine_tsx11_lock(); + if (physdev->brush.pixmap) XFreePixmap( gdi_display, physdev->brush.pixmap ); + physdev->brush.pixmap = pixmap; + + if (vis.depth == 1) + { + physdev->brush.fillStyle = FillOpaqueStippled; + physdev->brush.pixel = -1; /* Special case (see DC_SetupGCForBrush) */ + } + else + { + physdev->brush.fillStyle = FillTiled; + physdev->brush.pixel = 0; /* Ignored */ + } + wine_tsx11_unlock(); + return TRUE; +} /*********************************************************************** * SelectBrush (X11DRV.@) @@ -293,18 +332,14 @@ HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_patter { X_PHYSBITMAP *physbitmap; HBITMAP bitmap = pattern->bitmap; - BOOL delete_bitmap = FALSE; if (!bitmap || !(physbitmap = X11DRV_get_phys_bitmap( bitmap ))) { - if (!(bitmap = create_brush_bitmap( physDev, pattern ))) return 0; - physbitmap = X11DRV_get_phys_bitmap( bitmap ); - delete_bitmap = TRUE; + if (!select_pattern_brush( physDev, pattern )) return 0; } - BRUSH_SelectPatternBrush( physDev, bitmap, physbitmap ); + else BRUSH_SelectPatternBrush( physDev, bitmap, physbitmap ); TRACE("BS_PATTERN\n"); physDev->brush.style = BS_PATTERN; - if (delete_bitmap) DeleteObject( bitmap ); return hbrush; }
1
0
0
0
Alexandre Julliard : winex11: Add a helper to create a pixmap from an image .
by Alexandre Julliard
15 May '12
15 May '12
Module: wine Branch: master Commit: 3e8ad9a064cfce36752233a7a7439b11dac01074 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=3e8ad9a064cfce36752233a7a…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Fri May 11 13:48:19 2012 +0200 winex11: Add a helper to create a pixmap from an image. --- dlls/winex11.drv/bitblt.c | 126 +++++++++++++++++++++++++++++++++++++++++++++ dlls/winex11.drv/x11drv.h | 2 + 2 files changed, 128 insertions(+), 0 deletions(-) diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 413f4e4..6dec77f 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -937,6 +937,16 @@ static void free_ximage_bits( struct gdi_image_bits *bits ) wine_tsx11_unlock(); } +/* only for use on sanitized BITMAPINFO structures */ +static inline int get_dib_info_size( const BITMAPINFO *info, UINT coloruse ) +{ + if (info->bmiHeader.biCompression == BI_BITFIELDS) + return sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD); + if (coloruse == DIB_PAL_COLORS) + return sizeof(BITMAPINFOHEADER) + info->bmiHeader.biClrUsed * sizeof(WORD); + return FIELD_OFFSET( BITMAPINFO, bmiColors[info->bmiHeader.biClrUsed] ); +} + /* store the palette or color mask data in the bitmap info structure */ static void set_color_info( const XVisualInfo *vis, BITMAPINFO *info ) { @@ -1464,6 +1474,122 @@ DWORD X11DRV_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info, /*********************************************************************** + * put_pixmap_image + * + * Simplified equivalent of X11DRV_PutImage that writes directly to a pixmap. + */ +static DWORD put_pixmap_image( Pixmap pixmap, const XVisualInfo *vis, + BITMAPINFO *info, const struct gdi_image_bits *bits ) +{ + DWORD ret; + XImage *image; + struct bitblt_coords coords; + struct gdi_image_bits dst_bits; + const XPixmapFormatValues *format = pixmap_formats[vis->depth]; + const int *mapping = NULL; + + if (!format) return ERROR_INVALID_PARAMETER; + if (info->bmiHeader.biPlanes != 1) goto update_format; + if (info->bmiHeader.biBitCount != format->bits_per_pixel) goto update_format; + /* FIXME: could try to handle 1-bpp using XCopyPlane */ + if (!matching_color_info( vis, info )) goto update_format; + if (!bits) return ERROR_SUCCESS; /* just querying the format */ + + coords.x = 0; + coords.y = 0; + coords.width = info->bmiHeader.biWidth; + coords.height = abs( info->bmiHeader.biHeight ); + SetRect( &coords.visrect, 0, 0, coords.width, coords.height ); + + wine_tsx11_lock(); + image = XCreateImage( gdi_display, visual, vis->depth, ZPixmap, 0, NULL, + coords.width, coords.height, 32, 0 ); + wine_tsx11_unlock(); + if (!image) return ERROR_OUTOFMEMORY; + + if (image->bits_per_pixel == 4 || image->bits_per_pixel == 8) + mapping = X11DRV_PALETTE_PaletteToXPixel; + + if (!(ret = copy_image_bits( info, is_r8g8b8(vis), image, bits, &dst_bits, &coords, mapping, ~0u ))) + { + image->data = dst_bits.ptr; + wine_tsx11_lock(); + XPutImage( gdi_display, pixmap, get_bitmap_gc( vis->depth ), + image, 0, 0, 0, 0, coords.width, coords.height ); + wine_tsx11_unlock(); + image->data = NULL; + } + + wine_tsx11_lock(); + XDestroyImage( image ); + wine_tsx11_unlock(); + if (dst_bits.free) dst_bits.free( &dst_bits ); + return ret; + +update_format: + info->bmiHeader.biPlanes = 1; + info->bmiHeader.biBitCount = format->bits_per_pixel; + if (info->bmiHeader.biHeight > 0) info->bmiHeader.biHeight = -info->bmiHeader.biHeight; + set_color_info( vis, info ); + return ERROR_BAD_FORMAT; +} + + +/*********************************************************************** + * create_pixmap_from_image + */ +Pixmap create_pixmap_from_image( HDC hdc, const XVisualInfo *vis, const BITMAPINFO *info, + const struct gdi_image_bits *bits, UINT coloruse ) +{ + static const RGBQUAD default_colortable[2] = { { 0x00, 0x00, 0x00 }, { 0xff, 0xff, 0xff } }; + char dst_buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + char src_buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + BITMAPINFO *dst_info = (BITMAPINFO *)dst_buffer; + BITMAPINFO *src_info = (BITMAPINFO *)src_buffer; + struct gdi_image_bits dst_bits; + Pixmap pixmap; + DWORD err; + HBITMAP dib; + + wine_tsx11_lock(); + pixmap = XCreatePixmap( gdi_display, root_window, + info->bmiHeader.biWidth, abs(info->bmiHeader.biHeight), vis->depth ); + wine_tsx11_unlock(); + if (!pixmap) return 0; + + memcpy( src_info, info, get_dib_info_size( info, coloruse )); + memcpy( dst_info, info, get_dib_info_size( info, coloruse )); + + if (coloruse == DIB_PAL_COLORS || + (err = put_pixmap_image( pixmap, vis, dst_info, bits )) == ERROR_BAD_FORMAT) + { + if (dst_info->bmiHeader.biBitCount == 1) /* set a default color table for 1-bpp */ + memcpy( dst_info->bmiColors, default_colortable, sizeof(default_colortable) ); + dib = CreateDIBSection( hdc, dst_info, coloruse, &dst_bits.ptr, 0, 0 ); + if (dib) + { + if (src_info->bmiHeader.biBitCount == 1 && !src_info->bmiHeader.biClrUsed) + memcpy( src_info->bmiColors, default_colortable, sizeof(default_colortable) ); + SetDIBits( hdc, dib, 0, abs(info->bmiHeader.biHeight), bits->ptr, src_info, coloruse ); + dst_bits.free = NULL; + dst_bits.is_copy = TRUE; + err = put_pixmap_image( pixmap, vis, dst_info, &dst_bits ); + DeleteObject( dib ); + } + else err = ERROR_OUTOFMEMORY; + } + + if (!err) return pixmap; + + wine_tsx11_lock(); + XFreePixmap( gdi_display, pixmap ); + wine_tsx11_unlock(); + return 0; + +} + + +/*********************************************************************** * get_pixmap_image * * Equivalent of X11DRV_GetImage that reads directly from a pixmap. diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index d17565b..7ed4bdd 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -229,6 +229,8 @@ extern Pixmap X11DRV_get_pixmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN; extern DWORD copy_image_bits( BITMAPINFO *info, BOOL is_r8g8b8, XImage *image, const struct gdi_image_bits *src_bits, struct gdi_image_bits *dst_bits, struct bitblt_coords *coords, const int *mapping, unsigned int zeropad_mask ) DECLSPEC_HIDDEN; +extern Pixmap create_pixmap_from_image( HDC hdc, const XVisualInfo *vis, const BITMAPINFO *info, + const struct gdi_image_bits *bits, UINT coloruse ) DECLSPEC_HIDDEN; extern DWORD get_pixmap_image( Pixmap pixmap, int width, int height, const XVisualInfo *vis, BITMAPINFO *info, struct gdi_image_bits *bits ) DECLSPEC_HIDDEN;
1
0
0
0
Jacek Caban : appwiz.cpl: Replace install_wine_gecko with configurable install_addon.
by Alexandre Julliard
15 May '12
15 May '12
Module: wine Branch: master Commit: f25f97d86a5370f84cfb0bfc5b85472dd5d16b00 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f25f97d86a5370f84cfb0bfc5…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue May 15 11:48:31 2012 +0200 appwiz.cpl: Replace install_wine_gecko with configurable install_addon. --- dlls/appwiz.cpl/addons.c | 18 ++++++++++-------- dlls/appwiz.cpl/appwiz.c | 2 +- dlls/appwiz.cpl/appwiz.h | 6 +++++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dlls/appwiz.cpl/addons.c b/dlls/appwiz.cpl/addons.c index 8703f97..1cff5c4 100644 --- a/dlls/appwiz.cpl/addons.c +++ b/dlls/appwiz.cpl/addons.c @@ -84,7 +84,7 @@ static const addon_info_t addons_info[] = { } }; -static const addon_info_t *addon = &addons_info[0]; +static const addon_info_t *addon; static HWND install_dialog = NULL; static LPWSTR url = NULL; @@ -553,18 +553,20 @@ static INT_PTR CALLBACK installer_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARA return FALSE; } -BOOL install_wine_gecko(void) +BOOL install_addon(addon_t addon_type) { if(!*ARCH_STRING) return FALSE; + addon = addons_info+addon_type; + /* - * Try to find Gecko .cab file in following order: - * - directory stored in GeckoCabDir value of HKCU/Wine/Software/MSHTML key - * - $datadir/gecko/ - * - $INSTALL_DATADIR/wine/gecko/ - * - /usr/share/wine/gecko/ - * - download from URL stored in GeckoUrl value of HKCU/Wine/Software/MSHTML key + * Try to find addon .msi file in following order: + * - directory stored in $dir_config_key value of HKCU/Wine/Software/$config_key key + * - $datadir/$addon_subdir/ + * - $INSTALL_DATADIR/wine/$addon_subdir/ + * - /usr/share/wine/$addon_subdir/ + * - download from URL stored in $url_config_key value of HKCU/Wine/Software/$config_key key */ if(!install_from_registered_dir() && !install_from_default_dir() diff --git a/dlls/appwiz.cpl/appwiz.c b/dlls/appwiz.cpl/appwiz.c index 1d8f47c..14ace66 100644 --- a/dlls/appwiz.cpl/appwiz.c +++ b/dlls/appwiz.cpl/appwiz.c @@ -975,7 +975,7 @@ static LONG start_params(const WCHAR *params) return FALSE; if(!strcmpW(params, install_geckoW)) { - install_wine_gecko(); + install_addon(ADDON_GECKO); return TRUE; } diff --git a/dlls/appwiz.cpl/appwiz.h b/dlls/appwiz.cpl/appwiz.h index d4f9375..6e189fa 100644 --- a/dlls/appwiz.cpl/appwiz.h +++ b/dlls/appwiz.cpl/appwiz.h @@ -16,7 +16,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -BOOL install_wine_gecko(void) DECLSPEC_HIDDEN; +typedef enum { + ADDON_GECKO +} addon_t; + +BOOL install_addon(addon_t) DECLSPEC_HIDDEN; extern HINSTANCE hInst DECLSPEC_HIDDEN;
1
0
0
0
Jacek Caban : appwiz.cpl: Moved config_key value to addon_info_t.
by Alexandre Julliard
15 May '12
15 May '12
Module: wine Branch: master Commit: 5779ce287ad8e147ecd9a8f13a46b112d6c36b25 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=5779ce287ad8e147ecd9a8f13…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue May 15 11:48:12 2012 +0200 appwiz.cpl: Moved config_key value to addon_info_t. --- dlls/appwiz.cpl/addons.c | 51 +++++++++++++++++++++++++++++---------------- dlls/appwiz.cpl/appwiz.h | 16 ++++++++++++++ 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/dlls/appwiz.cpl/addons.c b/dlls/appwiz.cpl/addons.c index 2694fb7..8703f97 100644 --- a/dlls/appwiz.cpl/addons.c +++ b/dlls/appwiz.cpl/addons.c @@ -69,6 +69,9 @@ typedef struct { const char *file_name; const char *subdir_name; const char *sha; + const char *config_key; + const char *url_config_key; + const char *dir_config_key; } addon_info_t; static const addon_info_t addons_info[] = { @@ -76,17 +79,13 @@ static const addon_info_t addons_info[] = { GECKO_VERSION, "wine_gecko-" GECKO_VERSION "-" ARCH_STRING ".msi", "gecko", - GECKO_SHA + GECKO_SHA, + "MSHTML", "GeckoUrl", "GeckoCabDir" } }; static const addon_info_t *addon = &addons_info[0]; -static const WCHAR mshtml_keyW[] = - {'S','o','f','t','w','a','r','e', - '\\','W','i','n','e', - '\\','M','S','H','T','M','L',0}; - static HWND install_dialog = NULL; static LPWSTR url = NULL; @@ -233,6 +232,23 @@ static BOOL install_from_unix_file(const char *dir, const char *subdir, const ch return ret; } +static HKEY open_config_key(void) +{ + HKEY hkey, ret; + DWORD res; + + static const WCHAR wine_keyW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e',0}; + + /* @@ Wine registry key: HKCU\Software\Wine\$config_key */ + res = RegOpenKeyW(HKEY_CURRENT_USER, wine_keyW, &hkey); + if(res != ERROR_SUCCESS) + return NULL; + + res = RegOpenKeyA(hkey, addon->config_key, &ret); + RegCloseKey(hkey); + return res == ERROR_SUCCESS ? ret : NULL; +} + static BOOL install_from_registered_dir(void) { char *package_dir; @@ -240,16 +256,15 @@ static BOOL install_from_registered_dir(void) DWORD res, type, size = MAX_PATH; BOOL ret; - /* @@ Wine registry key: HKCU\Software\Wine\MSHTML */ - res = RegOpenKeyW(HKEY_CURRENT_USER, mshtml_keyW, &hkey); - if(res != ERROR_SUCCESS) + hkey = open_config_key(); + if(!hkey) return FALSE; package_dir = heap_alloc(size); - res = RegGetValueA(hkey, NULL, "GeckoCabDir", RRF_RT_ANY, &type, (PBYTE)package_dir, &size); + res = RegGetValueA(hkey, NULL, addon->dir_config_key, RRF_RT_ANY, &type, (PBYTE)package_dir, &size); if(res == ERROR_MORE_DATA) { package_dir = heap_realloc(package_dir, size); - res = RegGetValueA(hkey, NULL, "GeckoCabDir", RRF_RT_ANY, &type, (PBYTE)package_dir, &size); + res = RegGetValueA(hkey, NULL, addon->dir_config_key, RRF_RT_ANY, &type, (PBYTE)package_dir, &size); } RegCloseKey(hkey); if(res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ)) { @@ -399,26 +414,26 @@ static IBindStatusCallback InstallCallback = { &InstallCallbackVtbl }; static LPWSTR get_url(void) { + DWORD size = INTERNET_MAX_URL_LENGTH*sizeof(WCHAR); + WCHAR *url, *config_key; HKEY hkey; DWORD res, type; - DWORD size = INTERNET_MAX_URL_LENGTH*sizeof(WCHAR); DWORD returned_size; - LPWSTR url; - static const WCHAR wszGeckoUrl[] = {'G','e','c','k','o','U','r','l',0}; static const WCHAR httpW[] = {'h','t','t','p'}; static const WCHAR arch_formatW[] = {'?','a','r','c','h','='}; static const WCHAR v_formatW[] = {'&','v','='}; - /* @@ Wine registry key: HKCU\Software\Wine\MSHTML */ - res = RegOpenKeyW(HKEY_CURRENT_USER, mshtml_keyW, &hkey); - if(res != ERROR_SUCCESS) + hkey = open_config_key(); + if(!hkey) return NULL; url = heap_alloc(size); returned_size = size; - res = RegQueryValueExW(hkey, wszGeckoUrl, NULL, &type, (LPBYTE)url, &returned_size); + config_key = heap_strdupAtoW(addon->url_config_key); + res = RegQueryValueExW(hkey, config_key, NULL, &type, (LPBYTE)url, &returned_size); + heap_free(config_key); RegCloseKey(hkey); if(res != ERROR_SUCCESS || type != REG_SZ) { heap_free(url); diff --git a/dlls/appwiz.cpl/appwiz.h b/dlls/appwiz.cpl/appwiz.h index 05b9dc8..d4f9375 100644 --- a/dlls/appwiz.cpl/appwiz.h +++ b/dlls/appwiz.cpl/appwiz.h @@ -34,3 +34,19 @@ static inline BOOL heap_free(void *mem) { return HeapFree(GetProcessHeap(), 0, mem); } + +static inline WCHAR *heap_strdupAtoW(const char *str) +{ + WCHAR *ret = NULL; + + if(str) { + size_t len; + + len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + ret = heap_alloc(len*sizeof(WCHAR)); + if(ret) + MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); + } + + return ret; +}
1
0
0
0
Jacek Caban : appwiz.cpl: Moved package subdir to addon_info_t.
by Alexandre Julliard
15 May '12
15 May '12
Module: wine Branch: master Commit: 87538c6233904ecd1e104efbff3eb3fdaeb07a6f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=87538c6233904ecd1e104efbf…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue May 15 11:47:58 2012 +0200 appwiz.cpl: Moved package subdir to addon_info_t. --- dlls/appwiz.cpl/addons.c | 50 ++++++++++++++++++++++++--------------------- 1 files changed, 27 insertions(+), 23 deletions(-) diff --git a/dlls/appwiz.cpl/addons.c b/dlls/appwiz.cpl/addons.c index 9766f45..2694fb7 100644 --- a/dlls/appwiz.cpl/addons.c +++ b/dlls/appwiz.cpl/addons.c @@ -67,6 +67,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(appwizcpl); typedef struct { const char *version; const char *file_name; + const char *subdir_name; const char *sha; } addon_info_t; @@ -74,6 +75,7 @@ static const addon_info_t addons_info[] = { { GECKO_VERSION, "wine_gecko-" GECKO_VERSION "-" ARCH_STRING ".msi", + "gecko", GECKO_SHA } }; @@ -171,7 +173,7 @@ static BOOL install_file(const WCHAR *file_name) return TRUE; } -static BOOL install_from_unix_file(const char *dir, const char *file_name) +static BOOL install_from_unix_file(const char *dir, const char *subdir, const char *file_name) { LPWSTR dos_file_name; char *file_path; @@ -182,13 +184,18 @@ static BOOL install_from_unix_file(const char *dir, const char *file_name) static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0}; len = strlen(dir); - file_path = heap_alloc(len+strlen(file_name)+2); + file_path = heap_alloc(len+strlen(subdir)+strlen(file_name)+3); if(!file_path) return FALSE; memcpy(file_path, dir, len); if(len && file_path[len-1] != '/' && file_path[len-1] != '\\') file_path[len++] = '/'; + if(*subdir) { + strcpy(file_path+len, subdir); + len += strlen(subdir); + file_path[len++] = '/'; + } strcpy(file_path+len, file_name); fd = open(file_path, O_RDONLY); @@ -252,7 +259,7 @@ static BOOL install_from_registered_dir(void) TRACE("Trying %s/%s\n", debugstr_a(package_dir), debugstr_a(addon->file_name)); - ret = install_from_unix_file(package_dir, addon->file_name); + ret = install_from_unix_file(package_dir, "", addon->file_name); heap_free(package_dir); return ret; @@ -260,33 +267,30 @@ static BOOL install_from_registered_dir(void) static BOOL install_from_default_dir(void) { - const char *data_dir, *subdir; - char *package_dir; - int len, len2; + const char *data_dir, *package_dir; + char *dir_buf = NULL; + int len; BOOL ret; - if((data_dir = wine_get_data_dir())) - subdir = "/gecko/"; - else if((data_dir = wine_get_build_dir())) - subdir = "/../gecko/"; - else + if((data_dir = wine_get_data_dir())) { + package_dir = data_dir; + }else if((data_dir = wine_get_build_dir())) { + len = strlen(data_dir); + dir_buf = heap_alloc(len + sizeof("/../")); + memcpy(dir_buf, data_dir, len); + strcpy(dir_buf+len, "/../"); + package_dir = dir_buf; + }else { return FALSE; + } - len = strlen(data_dir); - len2 = strlen(subdir); - - package_dir = heap_alloc(len+len2+1); - memcpy(package_dir, data_dir, len); - memcpy(package_dir+len, subdir, len2+1); - - ret = install_from_unix_file(package_dir, addon->file_name); - - heap_free(package_dir); + ret = install_from_unix_file(package_dir, addon->subdir_name, addon->file_name); + heap_free(dir_buf); if (!ret) - ret = install_from_unix_file(INSTALL_DATADIR "/wine/gecko/", addon->file_name); + ret = install_from_unix_file(INSTALL_DATADIR "/wine/", addon->subdir_name, addon->file_name); if (!ret && strcmp(INSTALL_DATADIR, "/usr/share")) - ret = install_from_unix_file("/usr/share/wine/gecko/", addon->file_name); + ret = install_from_unix_file("/usr/share/wine/", addon->subdir_name, addon->file_name); return ret; }
1
0
0
0
Jacek Caban : appwiz.cpl: Moved addon SHA and version to addon_info_t.
by Alexandre Julliard
15 May '12
15 May '12
Module: wine Branch: master Commit: 39d444fb9974562ecd0261e1e188698a51da3e22 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=39d444fb9974562ecd0261e1e…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue May 15 11:47:40 2012 +0200 appwiz.cpl: Moved addon SHA and version to addon_info_t. --- dlls/appwiz.cpl/addons.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dlls/appwiz.cpl/addons.c b/dlls/appwiz.cpl/addons.c index 0e731e4..9766f45 100644 --- a/dlls/appwiz.cpl/addons.c +++ b/dlls/appwiz.cpl/addons.c @@ -65,12 +65,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(appwizcpl); #endif typedef struct { + const char *version; const char *file_name; + const char *sha; } addon_info_t; static const addon_info_t addons_info[] = { { - "wine_gecko-" GECKO_VERSION "-" ARCH_STRING ".msi" + GECKO_VERSION, + "wine_gecko-" GECKO_VERSION "-" ARCH_STRING ".msi", + GECKO_SHA } }; @@ -131,10 +135,10 @@ static BOOL sha_check(const WCHAR *file_name) for(i=0; i < sizeof(sha); i++) sprintf(buf + i*2, "%02x", *((unsigned char*)sha+i)); - if(strcmp(buf, GECKO_SHA)) { + if(strcmp(buf, addon->sha)) { WCHAR message[256]; - WARN("Got %s, expected %s\n", buf, GECKO_SHA); + WARN("Got %s, expected %s\n", buf, addon->sha); if(LoadStringW(hInst, IDS_INVALID_SHA, message, sizeof(message)/sizeof(WCHAR))) MessageBoxW(NULL, message, NULL, MB_ICONERROR); @@ -426,7 +430,7 @@ static LPWSTR get_url(void) len += MultiByteToWideChar(CP_ACP, 0, ARCH_STRING, sizeof(ARCH_STRING), url+len, size/sizeof(WCHAR)-len)-1; memcpy(url+len, v_formatW, sizeof(v_formatW)); len += sizeof(v_formatW)/sizeof(WCHAR); - MultiByteToWideChar(CP_ACP, 0, GECKO_VERSION, -1, url+len, size/sizeof(WCHAR)-len); + MultiByteToWideChar(CP_ACP, 0, addon->version, -1, url+len, size/sizeof(WCHAR)-len); } TRACE("Got URL %s\n", debugstr_w(url));
1
0
0
0
← Newer
1
...
37
38
39
40
41
42
43
...
74
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Results per page:
10
25
50
100
200