Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
73393fab
Commit
73393fab
authored
Dec 30, 2008
by
Andrew Riedi
Committed by
Alexandre Julliard
Jan 02, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winex11: Factor out the 'alpha_zero' test and use it for legacy cursor support.
parent
6bdcdc42
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
33 deletions
+47
-33
mouse.c
dlls/winex11.drv/mouse.c
+47
-33
No files found.
dlls/winex11.drv/mouse.c
View file @
73393fab
...
@@ -399,6 +399,47 @@ void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y,
...
@@ -399,6 +399,47 @@ void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y,
}
}
/***********************************************************************
* check_alpha_zero
*
* Generally 32 bit bitmaps have an alpha channel which is used in favor of the
* AND mask. However, if all pixels have alpha = 0x00, the bitmap is treated
* like one without alpha and the masks are used. As soon as one pixel has
* alpha != 0x00, and the mask ignored as described in the docs.
*
* This is most likely for applications which create the bitmaps with
* CreateDIBitmap, which creates a device dependent bitmap, so the format that
* arrives when loading depends on the screen's bpp. Apps that were written at
* 8 / 16 bpp times do not know about the 32 bit alpha, so they would get a
* completely transparent cursor on 32 bit displays.
*
* Non-32 bit bitmaps always use the AND mask.
*/
static
BOOL
check_alpha_zero
(
CURSORICONINFO
*
ptr
,
unsigned
char
*
xor_bits
)
{
int
x
,
y
;
unsigned
char
*
xor_ptr
;
if
(
ptr
->
bBitsPerPixel
==
32
)
{
for
(
y
=
0
;
y
<
ptr
->
nHeight
;
++
y
)
{
xor_ptr
=
xor_bits
+
(
y
*
ptr
->
nWidthBytes
);
for
(
x
=
0
;
x
<
ptr
->
nWidth
;
++
x
)
{
if
(
xor_ptr
[
3
]
!=
0x00
)
{
return
FALSE
;
}
xor_ptr
+=
4
;
}
}
}
return
TRUE
;
}
#ifdef SONAME_LIBXCURSOR
#ifdef SONAME_LIBXCURSOR
/***********************************************************************
/***********************************************************************
...
@@ -434,7 +475,7 @@ static XcursorImage *create_cursor_image( CURSORICONINFO *ptr )
...
@@ -434,7 +475,7 @@ static XcursorImage *create_cursor_image( CURSORICONINFO *ptr )
XcursorPixel
*
pixel_ptr
;
XcursorPixel
*
pixel_ptr
;
XcursorImage
*
image
;
XcursorImage
*
image
;
unsigned
char
tmp
;
unsigned
char
tmp
;
BOOL
alpha_zero
=
TRUE
;
BOOL
alpha_zero
;
and_width_bytes
=
2
*
((
ptr
->
nWidth
+
15
)
/
16
);
and_width_bytes
=
2
*
((
ptr
->
nWidth
+
15
)
/
16
);
xor_width_bytes
=
ptr
->
nWidthBytes
;
xor_width_bytes
=
ptr
->
nWidthBytes
;
...
@@ -447,36 +488,7 @@ static XcursorImage *create_cursor_image( CURSORICONINFO *ptr )
...
@@ -447,36 +488,7 @@ static XcursorImage *create_cursor_image( CURSORICONINFO *ptr )
image
=
pXcursorImageCreate
(
ptr
->
nWidth
,
ptr
->
nHeight
);
image
=
pXcursorImageCreate
(
ptr
->
nWidth
,
ptr
->
nHeight
);
pixel_ptr
=
image
->
pixels
;
pixel_ptr
=
image
->
pixels
;
/* Generally 32 bit bitmaps have an alpha channel which is used in favor
alpha_zero
=
check_alpha_zero
(
ptr
,
xor_bits
);
* of the AND mask. However, if all pixels have alpha = 0x00, the bitmap
* is treated like one without alpha and the masks are used. As soon as
* one pixel has alpha != 0x00, and the mask ignored as described in the
* docs.
*
* This is most likely for applications which create the bitmaps with
* CreateDIBitmap, which creates a device dependent bitmap, so the format
* that arrives when loading depends on the screen's bpp. Apps that were
* written at 8 / 16 bpp times do not know about the 32 bit alpha, so
* they would get a completely transparent cursor on 32 bit displays.
*
* Non-32 bit bitmaps always use the AND mask
*/
if
(
ptr
->
bBitsPerPixel
==
32
)
{
for
(
y
=
0
;
alpha_zero
&&
y
<
ptr
->
nHeight
;
++
y
)
{
xor_ptr
=
xor_bits
+
(
y
*
xor_width_bytes
);
for
(
x
=
0
;
x
<
ptr
->
nWidth
;
++
x
)
{
if
(
xor_ptr
[
3
]
!=
0x00
)
{
alpha_zero
=
FALSE
;
break
;
}
xor_ptr
+=
4
;
}
}
}
/* On windows, to calculate the color for a pixel, first an AND is done
/* On windows, to calculate the color for a pixel, first an AND is done
* with the background and the "and" bitmap, then an XOR with the "xor"
* with the background and the "and" bitmap, then an XOR with the "xor"
...
@@ -618,6 +630,7 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
...
@@ -618,6 +630,7 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
Cursor
cursor
=
None
;
Cursor
cursor
=
None
;
POINT
hotspot
;
POINT
hotspot
;
char
*
bitMask32
=
NULL
;
char
*
bitMask32
=
NULL
;
BOOL
alpha_zero
=
TRUE
;
#ifdef SONAME_LIBXCURSOR
#ifdef SONAME_LIBXCURSOR
if
(
pXcursorImageLoadCursor
)
return
create_xcursor_cursor
(
display
,
ptr
);
if
(
pXcursorImageLoadCursor
)
return
create_xcursor_cursor
(
display
,
ptr
);
...
@@ -733,6 +746,7 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
...
@@ -733,6 +746,7 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
ptr
->
nWidth
,
ptr
->
nHeight
);
ptr
->
nWidth
,
ptr
->
nHeight
);
}
}
ymax
=
(
ptr
->
nHeight
>
32
)
?
32
:
ptr
->
nHeight
;
ymax
=
(
ptr
->
nHeight
>
32
)
?
32
:
ptr
->
nHeight
;
alpha_zero
=
check_alpha_zero
(
ptr
,
theImage
);
memset
(
pXorBits
,
0
,
128
);
memset
(
pXorBits
,
0
,
128
);
for
(
y
=
0
;
y
<
ymax
;
y
++
)
for
(
y
=
0
;
y
<
ymax
;
y
++
)
...
@@ -841,7 +855,7 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
...
@@ -841,7 +855,7 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
/* Now create the 2 pixmaps for bits and mask */
/* Now create the 2 pixmaps for bits and mask */
pixmapBits
=
XCreatePixmap
(
display
,
root_window
,
ptr
->
nWidth
,
ptr
->
nHeight
,
1
);
pixmapBits
=
XCreatePixmap
(
display
,
root_window
,
ptr
->
nWidth
,
ptr
->
nHeight
,
1
);
if
(
ptr
->
bBitsPerPixel
!=
32
)
if
(
alpha_zero
)
{
{
pixmapMaskInv
=
XCreatePixmap
(
display
,
root_window
,
ptr
->
nWidth
,
ptr
->
nHeight
,
1
);
pixmapMaskInv
=
XCreatePixmap
(
display
,
root_window
,
ptr
->
nWidth
,
ptr
->
nHeight
,
1
);
pixmapMask
=
XCreatePixmap
(
display
,
root_window
,
ptr
->
nWidth
,
ptr
->
nHeight
,
1
);
pixmapMask
=
XCreatePixmap
(
display
,
root_window
,
ptr
->
nWidth
,
ptr
->
nHeight
,
1
);
...
@@ -901,7 +915,6 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
...
@@ -901,7 +915,6 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
pixmapMask
=
XCreateBitmapFromData
(
display
,
root_window
,
pixmapMask
=
XCreateBitmapFromData
(
display
,
root_window
,
bitMask32
,
ptr
->
nWidth
,
bitMask32
,
ptr
->
nWidth
,
ptr
->
nHeight
);
ptr
->
nHeight
);
HeapFree
(
GetProcessHeap
(),
0
,
bitMask32
);
}
}
/* Make sure hotspot is valid */
/* Make sure hotspot is valid */
...
@@ -924,6 +937,7 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
...
@@ -924,6 +937,7 @@ static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
if
(
pixmapBits
)
XFreePixmap
(
display
,
pixmapBits
);
if
(
pixmapBits
)
XFreePixmap
(
display
,
pixmapBits
);
if
(
pixmapMask
)
XFreePixmap
(
display
,
pixmapMask
);
if
(
pixmapMask
)
XFreePixmap
(
display
,
pixmapMask
);
if
(
pixmapMaskInv
)
XFreePixmap
(
display
,
pixmapMaskInv
);
if
(
pixmapMaskInv
)
XFreePixmap
(
display
,
pixmapMaskInv
);
HeapFree
(
GetProcessHeap
(),
0
,
bitMask32
);
XFreeGC
(
display
,
gc
);
XFreeGC
(
display
,
gc
);
}
}
return
cursor
;
return
cursor
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment