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
c1eb1e8f
Commit
c1eb1e8f
authored
Jul 15, 2010
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for testing window manager icons
parent
43503a8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletion
+43
-1
common.c
test/common.c
+42
-1
common.h
test/common.h
+1
-0
No files found.
test/common.c
View file @
c1eb1e8f
...
...
@@ -6,7 +6,7 @@
#include "common.h"
#define VIDEO_USAGE \
"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display N] [--fullscreen | --windows N] [--title title] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab] [--double] [--triple]"
"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display N] [--fullscreen | --windows N] [--title title] [--
icon icon.bmp] [--
center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab] [--double] [--triple]"
#define AUDIO_USAGE \
"[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
...
...
@@ -192,6 +192,14 @@ CommonArg(CommonState * state, int index)
state
->
window_title
=
argv
[
index
];
return
2
;
}
if
(
SDL_strcasecmp
(
argv
[
index
],
"--icon"
)
==
0
)
{
++
index
;
if
(
!
argv
[
index
])
{
return
-
1
;
}
state
->
window_icon
=
argv
[
index
];
return
2
;
}
if
(
SDL_strcasecmp
(
argv
[
index
],
"--center"
)
==
0
)
{
state
->
window_x
=
SDL_WINDOWPOS_CENTERED
;
state
->
window_y
=
SDL_WINDOWPOS_CENTERED
;
...
...
@@ -611,6 +619,30 @@ PrintRenderer(SDL_RendererInfo * info)
}
}
static
SDL_Surface
*
LoadIcon
(
const
char
*
file
)
{
SDL_Surface
*
icon
;
/* Load the icon surface */
icon
=
SDL_LoadBMP
(
file
);
if
(
icon
==
NULL
)
{
fprintf
(
stderr
,
"Couldn't load %s: %s
\n
"
,
file
,
SDL_GetError
());
return
(
NULL
);
}
if
(
icon
->
format
->
palette
==
NULL
)
{
fprintf
(
stderr
,
"Icon must have a palette!
\n
"
);
SDL_FreeSurface
(
icon
);
return
(
NULL
);
}
/* Set the colorkey */
SDL_SetColorKey
(
icon
,
1
,
*
((
Uint8
*
)
icon
->
pixels
));
return
(
icon
);
}
SDL_bool
CommonInit
(
CommonState
*
state
)
{
...
...
@@ -791,6 +823,15 @@ CommonInit(CommonState * state)
SDL_GetError
());
return
SDL_FALSE
;
}
if
(
state
->
window_icon
)
{
SDL_Surface
*
icon
=
LoadIcon
(
state
->
window_icon
);
if
(
icon
)
{
SDL_SetWindowIcon
(
state
->
windows
[
i
],
icon
);
SDL_FreeSurface
(
icon
);
}
}
SDL_ShowWindow
(
state
->
windows
[
i
]);
if
(
!
state
->
skip_renderer
...
...
test/common.h
View file @
c1eb1e8f
...
...
@@ -24,6 +24,7 @@ typedef struct
const
char
*
videodriver
;
int
display
;
const
char
*
window_title
;
const
char
*
window_icon
;
Uint32
window_flags
;
int
window_x
;
int
window_y
;
...
...
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