Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
affaf98f
Commit
affaf98f
authored
14 years ago
by
egottlieb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added hiding-as-positioning trick and finally fixed flags.
parent
b3840496
master
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
SDL_shape.c
src/video/SDL_shape.c
+4
-3
SDL_win32shape.c
src/video/win32/SDL_win32shape.c
+8
-8
No files found.
src/video/SDL_shape.c
View file @
affaf98f
...
...
@@ -32,7 +32,7 @@
SDL_Window
*
SDL_CreateShapedWindow
(
const
char
*
title
,
unsigned
int
x
,
unsigned
int
y
,
unsigned
int
w
,
unsigned
int
h
,
Uint32
flags
)
{
SDL_Window
*
result
=
SDL_CreateWindow
(
title
,
x
,
y
,
w
,
h
,
flags
|
SDL_WINDOW_BORDERLESS
&
!
SDL_WINDOW_FULLSCREEN
&
!
SDL_WINDOW_RESIZABLE
);
SDL_Window
*
result
=
SDL_CreateWindow
(
title
,
x
,
y
,
w
,
h
,
flags
|
SDL_WINDOW_BORDERLESS
&
~
SDL_WINDOW_FULLSCREEN
&
~
SDL_WINDOW_RESIZABLE
);
if
(
result
!=
NULL
)
{
result
->
shaper
=
result
->
display
->
device
->
shape_driver
.
CreateShaper
(
result
);
if
(
result
->
shaper
!=
NULL
)
{
...
...
@@ -126,7 +126,7 @@ RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rec
SDL_Color
key
;
SDL_ShapeTree
*
result
=
(
SDL_ShapeTree
*
)
SDL_malloc
(
sizeof
(
SDL_ShapeTree
));
SDL_Rect
next
=
{
0
,
0
,
0
,
0
};
for
(
y
=
dimensions
.
y
;
y
<
dimensions
.
y
+
dimensions
.
h
;
y
++
)
for
(
y
=
dimensions
.
y
;
y
<
dimensions
.
y
+
dimensions
.
h
;
y
++
)
{
for
(
x
=
dimensions
.
x
;
x
<
dimensions
.
x
+
dimensions
.
w
;
x
++
)
{
pixel_value
=
0
;
pixel
=
(
Uint8
*
)(
mask
->
pixels
)
+
(
y
*
mask
->
pitch
)
+
(
x
*
mask
->
format
->
BytesPerPixel
);
...
...
@@ -183,6 +183,7 @@ RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rec
return
result
;
}
}
}
//If we never recursed, all the pixels in this quadrant have the same "value".
result
->
kind
=
(
last_opaque
==
SDL_TRUE
?
OpaqueShape
:
TransparentShape
);
result
->
data
.
shape
=
dimensions
;
...
...
@@ -240,7 +241,7 @@ SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *sh
window
->
shaper
->
mode
=
*
shape_mode
;
result
=
window
->
display
->
device
->
shape_driver
.
SetWindowShape
(
window
->
shaper
,
shape
,
shape_mode
);
window
->
shaper
->
hasshape
=
SDL_TRUE
;
if
(
window
->
shaper
->
userx
==
0
&&
window
->
shaper
->
usery
=
=
0
)
{
if
(
window
->
shaper
->
userx
!=
0
&&
window
->
shaper
->
usery
!
=
0
)
{
SDL_SetWindowPosition
(
window
,
window
->
shaper
->
userx
,
window
->
shaper
->
usery
);
window
->
shaper
->
userx
=
0
;
window
->
shaper
->
usery
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/video/win32/SDL_win32shape.c
View file @
affaf98f
...
...
@@ -50,11 +50,10 @@ CombineRectRegions(SDL_ShapeTree* node,void* closure) {
HRGN
mask_region
=
*
((
HRGN
*
)
closure
),
temp_region
=
NULL
;
if
(
node
->
kind
==
OpaqueShape
)
{
//Win32 API regions exclude their outline, so we widen the region by one pixel in each direction to include the real outline.
sprintf_s
(
&
debug_str
[
0
],
200
,
"x: %u y: %u, x+w: %u, y+h: %u
\n
"
,
/*
sprintf_s(&debug_str[0],200,"x: %u y: %u, x+w: %u, y+h: %u\n",
node->data.shape.x,node->data.shape.y,
node
->
data
.
shape
.
x
+
node
->
data
.
shape
.
w
,
node
->
data
.
shape
.
y
+
node
->
data
.
shape
.
h
);
OutputDebugStringA
(
debug_str
);
OutputDebugStringA
(
"Converting SDL_ShapeTree opaque node to Windows rectangle.
\n
"
);
node->data.shape.x + node->data.shape.w,node->data.shape.y + node->data.shape.h);*/
//OutputDebugStringA(debug_str);
temp_region
=
CreateRectRgn
(
node
->
data
.
shape
.
x
-
1
,
node
->
data
.
shape
.
y
-
1
,
node
->
data
.
shape
.
x
+
node
->
data
.
shape
.
w
+
1
,
node
->
data
.
shape
.
y
+
node
->
data
.
shape
.
h
+
1
);
if
(
mask_region
!=
NULL
)
{
CombineRgn
(
mask_region
,
mask_region
,
temp_region
,
RGN_OR
);
...
...
@@ -100,10 +99,11 @@ Win32_ResizeWindowShape(SDL_Window *window) {
if
(
data
->
mask_tree
!=
NULL
)
SDL_FreeShapeTree
(
&
data
->
mask_tree
);
window
->
shaper
->
userx
=
window
->
x
;
window
->
shaper
->
usery
=
window
->
y
;
SDL_SetWindowPosition
(
window
,
-
1000
,
-
1000
);
if
(
window
->
shaper
->
hasshape
==
SDL_TRUE
)
{
window
->
shaper
->
userx
=
window
->
x
;
window
->
shaper
->
usery
=
window
->
y
;
SDL_SetWindowPosition
(
window
,
-
1000
,
-
1000
);
}
return
0
;
}
This diff is collapsed.
Click to expand it.
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