projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver]
/
hacks
/
glx
/
sonar.c
diff --git
a/hacks/glx/sonar.c
b/hacks/glx/sonar.c
index 74e7b6b252c5d5fd8b1aae72b336ea21aa55a2cc..42bcdc8e7d6cc4ddb3d8afff039dff1535c00f2a 100644
(file)
--- a/
hacks/glx/sonar.c
+++ b/
hacks/glx/sonar.c
@@
-1,4
+1,4
@@
-/* sonar, Copyright (c) 1998-201
4
Jamie Zawinski and Stephen Martin
+/* sonar, Copyright (c) 1998-201
5
Jamie Zawinski and Stephen Martin
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@
-77,6
+77,7
@@
# define refresh_sonar 0
# define refresh_sonar 0
+# define release_sonar 0
#undef countof
#define countof(x) (sizeof((x))/sizeof((*x)))
#undef countof
#define countof(x) (sizeof((x))/sizeof((*x)))
@@
-370,7
+371,11
@@
draw_text (ModeInfo *mi, const char *string, GLfloat r, GLfloat th,
while ((line = strtok (token, "\r\n")))
{
while ((line = strtok (token, "\r\n")))
{
- int w = texture_string_width (sp->texfont, line, &lh);
+ XCharStruct e;
+ int w, ascent, descent;
+ texture_string_metrics (sp->texfont, line, &e, &ascent, &descent);
+ w = e.width;
+ lh = ascent + descent;
if (w > max_w) max_w = w;
lines++;
token = 0;
if (w > max_w) max_w = w;
lines++;
token = 0;
@@
-403,7
+408,10
@@
draw_text (ModeInfo *mi, const char *string, GLfloat r, GLfloat th,
token = string2;
while ((line = strtok (token, "\r\n")))
{
token = string2;
while ((line = strtok (token, "\r\n")))
{
- int w = texture_string_width (sp->texfont, line, 0);
+ XCharStruct e;
+ int w;
+ texture_string_metrics (sp->texfont, line, &e, 0, 0);
+ w = e.width;
glPushMatrix();
glTranslatef ((max_w-w)/2, 0, polys * 4); /* 'polys' stops Z-fighting. */
glPushMatrix();
glTranslatef ((max_w-w)/2, 0, polys * 4); /* 'polys' stops Z-fighting. */
@@
-750,22
+758,22
@@
static void
draw_startup_blurb (ModeInfo *mi)
{
sonar_configuration *sp = &sps[MI_SCREEN(mi)];
draw_startup_blurb (ModeInfo *mi)
{
sonar_configuration *sp = &sps[MI_SCREEN(mi)];
- const char *msg = (sp->error ? sp->error : "Resolving hosts...");
- static const GLfloat color[4] = {0, 1, 0, 1};
- if (!sp->error && ping_arg && !strcmp (ping_arg, "simulation"))
- return; /* don't bother */
+ if (sp->error)
+ {
+ const char *msg = sp->error;
+ static const GLfloat color[4] = {0, 1, 0, 1};
- glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color);
- glTranslatef (0, 0, 0.3);
- draw_text (mi, msg, 0, 0, 0, 30.0);
+
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color);
+
glTranslatef (0, 0, 0.3);
+
draw_text (mi, msg, 0, 0, 0, 30.0);
- /* only leave error message up for N seconds */
- if (sp->error &&
- sp->start_time + 6 < double_time())
- {
-
free (sp->error)
;
- sp->error = 0;
+
/* only leave error message up for N seconds */
+ if (sp->start_time + 6 < double_time())
+ {
+ free (sp->error);
+
sp->error = 0
;
+ }
}
}
}
}
@@
-809,20
+817,14
@@
sonar_handle_event (ModeInfo *mi, XEvent *event)
return False;
}
return False;
}
+static void free_sonar (ModeInfo *mi);
ENTRYPOINT void
init_sonar (ModeInfo *mi)
{
sonar_configuration *sp;
ENTRYPOINT void
init_sonar (ModeInfo *mi)
{
sonar_configuration *sp;
- if (!sps) {
- sps = (sonar_configuration *)
- calloc (MI_NUM_SCREENS(mi), sizeof (sonar_configuration));
- if (!sps) {
- fprintf(stderr, "%s: out of memory\n", progname);
- exit(1);
- }
- }
+ MI_INIT (mi, sps, free_sonar);
sp = &sps[MI_SCREEN(mi)];
sp->glx_context = init_GL(mi);
sp = &sps[MI_SCREEN(mi)];
sp->glx_context = init_GL(mi);
@@
-919,16
+921,15
@@
init_sensor (ModeInfo *mi)
if (!ping_arg || !*ping_arg ||
!strcmp(ping_arg, "default") ||
!!strcmp (ping_arg, "simulation"))
if (!ping_arg || !*ping_arg ||
!strcmp(ping_arg, "default") ||
!!strcmp (ping_arg, "simulation"))
+ /* sonar_init_ping() always disavows privs, even on failure. */
sp->ssd = sonar_init_ping (MI_DISPLAY (mi), &sp->error, &sp->desc,
ping_arg, ping_timeout, resolve_p, times_p,
debug_p);
sp->ssd = sonar_init_ping (MI_DISPLAY (mi), &sp->error, &sp->desc,
ping_arg, ping_timeout, resolve_p, times_p,
debug_p);
+ else
+ setuid(getuid()); /* Disavow privs if not pinging. */
sp->start_time = double_time (); /* for error message timing */
sp->start_time = double_time (); /* for error message timing */
- /* Disavow privs. This was already done in init_ping(), but
- we might not have called that at all, so do it again. */
- setuid(getuid());
-
if (!sp->ssd)
sp->ssd = sonar_init_simulation (MI_DISPLAY (mi), &sp->error, &sp->desc,
team_a_name, team_b_name,
if (!sp->ssd)
sp->ssd = sonar_init_simulation (MI_DISPLAY (mi), &sp->error, &sp->desc,
team_a_name, team_b_name,
@@
-1217,8
+1218,8
@@
draw_sonar (ModeInfo *mi)
# endif /* TEST_ASYNC_NETDB */
}
# endif /* TEST_ASYNC_NETDB */
}
-
ENTRYPOINT
void
-
releas
e_sonar (ModeInfo *mi)
+
static
void
+
fre
e_sonar (ModeInfo *mi)
{
#if 0
sonar_configuration *sp = &sps[MI_SCREEN(mi)];
{
#if 0
sonar_configuration *sp = &sps[MI_SCREEN(mi)];