Removed some unused variables. Also gets the right size and colors on
secondary screens. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@411 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -72,7 +72,6 @@ int time_left, prompt_x, prompt_y, time_x, time_y;
|
|||||||
unsigned long interval;
|
unsigned long interval;
|
||||||
Pixmap left0, left1, right0, right1, left_front,
|
Pixmap left0, left1, right0, right1, left_front,
|
||||||
right_front, front, down;
|
right_front, front, down;
|
||||||
int test;
|
|
||||||
|
|
||||||
#define MAXLINES 40
|
#define MAXLINES 40
|
||||||
|
|
||||||
@@ -85,6 +84,8 @@ char LOGOUT_PASSWD[] = "LOGOUT"; /* when given password "xx" */
|
|||||||
time_t locked_at;
|
time_t locked_at;
|
||||||
|
|
||||||
struct appres_t {
|
struct appres_t {
|
||||||
|
Pixel bg;
|
||||||
|
Pixel fg;
|
||||||
XFontStruct *font;
|
XFontStruct *font;
|
||||||
Boolean ignore_passwd;
|
Boolean ignore_passwd;
|
||||||
Boolean do_reverse;
|
Boolean do_reverse;
|
||||||
@@ -94,8 +95,15 @@ struct appres_t {
|
|||||||
} appres;
|
} appres;
|
||||||
|
|
||||||
static XtResource resources[] = {
|
static XtResource resources[] = {
|
||||||
|
{ XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
|
||||||
|
XtOffsetOf(struct appres_t, bg), XtRString, "black" },
|
||||||
|
|
||||||
|
{ XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
|
||||||
|
XtOffsetOf(struct appres_t, fg), XtRString, "white" },
|
||||||
|
|
||||||
{ XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
|
{ XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
|
||||||
XtOffsetOf(struct appres_t, font), XtRImmediate, NULL },
|
XtOffsetOf(struct appres_t, font),
|
||||||
|
XtRString, "-*-new century schoolbook-*-*-*-18-*" },
|
||||||
|
|
||||||
{ "ignorePasswd", "IgnorePasswd", XtRBoolean, sizeof(Boolean),
|
{ "ignorePasswd", "IgnorePasswd", XtRBoolean, sizeof(Boolean),
|
||||||
XtOffsetOf(struct appres_t,ignore_passwd),XtRImmediate,(XtPointer)False },
|
XtOffsetOf(struct appres_t,ignore_passwd),XtRImmediate,(XtPointer)False },
|
||||||
@@ -104,7 +112,7 @@ static XtResource resources[] = {
|
|||||||
XtOffsetOf(struct appres_t, accept_root), XtRImmediate, (XtPointer)True },
|
XtOffsetOf(struct appres_t, accept_root), XtRImmediate, (XtPointer)True },
|
||||||
|
|
||||||
{ "text", "Text", XtRString, sizeof(String),
|
{ "text", "Text", XtRString, sizeof(String),
|
||||||
XtOffsetOf(struct appres_t, text), XtRImmediate, NULL },
|
XtOffsetOf(struct appres_t, text), XtRString, "I'm out running around." },
|
||||||
|
|
||||||
{ "program", "Program", XtRString, sizeof(String),
|
{ "program", "Program", XtRString, sizeof(String),
|
||||||
XtOffsetOf(struct appres_t, text_prog), XtRImmediate, NULL },
|
XtOffsetOf(struct appres_t, text_prog), XtRImmediate, NULL },
|
||||||
@@ -116,17 +124,11 @@ static XtResource resources[] = {
|
|||||||
XtOffsetOf(struct appres_t,no_screensaver), XtRImmediate, (XtPointer)False },
|
XtOffsetOf(struct appres_t,no_screensaver), XtRImmediate, (XtPointer)False },
|
||||||
};
|
};
|
||||||
|
|
||||||
String fallback[]={
|
|
||||||
"*font : -*-new century schoolbook-*-*-*-18-*",
|
|
||||||
"*background : black",
|
|
||||||
"*foreground : white",
|
|
||||||
"*text : I'm out running around.",
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
Widget *xshell, *xcore;
|
|
||||||
|
|
||||||
static XrmOptionDescRec options[] = {
|
static XrmOptionDescRec options[] = {
|
||||||
|
{ "-fg", ".foreground", XrmoptionSepArg, NULL },
|
||||||
|
{ "-foreground", ".foreground", XrmoptionSepArg, NULL },
|
||||||
|
{ "-fn", ".font", XrmoptionSepArg, NULL },
|
||||||
|
{ "-font", ".font", XrmoptionSepArg, NULL },
|
||||||
{ "-ip", ".ignorePasswd", XrmoptionNoArg, "True" },
|
{ "-ip", ".ignorePasswd", XrmoptionNoArg, "True" },
|
||||||
{ "-noip", ".ignorePasswd", XrmoptionNoArg, "False" },
|
{ "-noip", ".ignorePasswd", XrmoptionNoArg, "False" },
|
||||||
{ "-ar", ".acceptRootPasswd", XrmoptionNoArg, "True" },
|
{ "-ar", ".acceptRootPasswd", XrmoptionNoArg, "True" },
|
||||||
@@ -139,7 +141,6 @@ get_words(void)
|
|||||||
{
|
{
|
||||||
FILE *pp = NULL;
|
FILE *pp = NULL;
|
||||||
static char buf[BUFSIZ];
|
static char buf[BUFSIZ];
|
||||||
register char *p = buf;
|
|
||||||
|
|
||||||
if(appres.text_prog){
|
if(appres.text_prog){
|
||||||
pp = popen(appres.text_prog, "r");
|
pp = popen(appres.text_prog, "r");
|
||||||
@@ -184,7 +185,6 @@ void usage(void)
|
|||||||
static void
|
static void
|
||||||
init_words (int argc, char **argv)
|
init_words (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c;
|
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@@ -278,6 +278,8 @@ walk(int dir)
|
|||||||
static int up = 1;
|
static int up = 1;
|
||||||
static Pixmap frame;
|
static Pixmap frame;
|
||||||
|
|
||||||
|
XSetForeground(dpy, gc, White);
|
||||||
|
XSetBackground(dpy, gc, Black);
|
||||||
if (dir & (LEFT|RIGHT)) { /* left/right movement (mabye up/down too) */
|
if (dir & (LEFT|RIGHT)) { /* left/right movement (mabye up/down too) */
|
||||||
up = -up; /* bouncing effect (even if hit a wall) */
|
up = -up; /* bouncing effect (even if hit a wall) */
|
||||||
if (dir & LEFT) {
|
if (dir & LEFT) {
|
||||||
@@ -415,9 +417,12 @@ post_prompt_box(Window window)
|
|||||||
if (height < 100)
|
if (height < 100)
|
||||||
height = 100;
|
height = 100;
|
||||||
|
|
||||||
time_x = prompt_x = Width / 3;
|
if(width < 105 + font->max_bounds.width*MAX_PASSWD_LENGTH)
|
||||||
|
width = 105 + font->max_bounds.width*MAX_PASSWD_LENGTH;
|
||||||
|
box_x = (Width - width) / 2;
|
||||||
|
time_x = prompt_x = box_x + 105;
|
||||||
|
|
||||||
time_y = prompt_y = Height / 2;
|
time_y = prompt_y = Height / 2;
|
||||||
box_x = prompt_x - 105;
|
|
||||||
box_y = prompt_y - 3 * font_height(font);
|
box_y = prompt_y - 3 * font_height(font);
|
||||||
|
|
||||||
if (inst[0] == 0)
|
if (inst[0] == 0)
|
||||||
@@ -431,9 +436,9 @@ post_prompt_box(Window window)
|
|||||||
/* Clear area in middle of screen for prompt box */
|
/* Clear area in middle of screen for prompt box */
|
||||||
XSetForeground(dpy, gc, White);
|
XSetForeground(dpy, gc, White);
|
||||||
XFillRectangle(dpy, window, gc, box_x, box_y, width, height);
|
XFillRectangle(dpy, window, gc, box_x, box_y, width, height);
|
||||||
XSetForeground(dpy, gc, Black);
|
|
||||||
|
|
||||||
/* make a box that's 5 pixels thick. Then add a thin box inside it */
|
/* make a box that's 5 pixels thick. Then add a thin box inside it */
|
||||||
|
XSetForeground(dpy, gc, Black);
|
||||||
XSetLineAttributes(dpy, gc, 5, 0, 0, 0);
|
XSetLineAttributes(dpy, gc, 5, 0, 0, 0);
|
||||||
XDrawRectangle(dpy, window, gc, box_x+5, box_y+5, width-10, height-10);
|
XDrawRectangle(dpy, window, gc, box_x+5, box_y+5, width-10, height-10);
|
||||||
XSetLineAttributes(dpy, gc, 0, 0, 0, 0);
|
XSetLineAttributes(dpy, gc, 0, 0, 0, 0);
|
||||||
@@ -445,7 +450,7 @@ post_prompt_box(Window window)
|
|||||||
/* set background for copyplane and DrawImageString; need reverse video */
|
/* set background for copyplane and DrawImageString; need reverse video */
|
||||||
XSetBackground(dpy, gc, White);
|
XSetBackground(dpy, gc, White);
|
||||||
XCopyPlane(dpy, right0, window, gc, 0,0, 64,64,
|
XCopyPlane(dpy, right0, window, gc, 0,0, 64,64,
|
||||||
box_x + 20, box_y + (height - 64)/2, 1L);
|
box_x + 20, box_y + (height - 64)/2, 1L);
|
||||||
prompt_x += XTextWidth(font, PROMPT, strlen(PROMPT));
|
prompt_x += XTextWidth(font, PROMPT, strlen(PROMPT));
|
||||||
time_y += 2*font_height(font);
|
time_y += 2*font_height(font);
|
||||||
}
|
}
|
||||||
@@ -521,7 +526,7 @@ GetPasswd(Widget w, XEvent *_event, String *_s, Cardinal *_n)
|
|||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
|
|
||||||
if (event->type == ButtonPress) {
|
if (event->type == ButtonPress) {
|
||||||
x = event->x, y = event->y, test = 2;
|
x = event->x, y = event->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state == IS_MOVING) {
|
if (state == IS_MOVING) {
|
||||||
@@ -687,12 +692,10 @@ talk(int force_erase)
|
|||||||
if (talking == 2) {
|
if (talking == 2) {
|
||||||
XSetForeground(dpy, gc, Black);
|
XSetForeground(dpy, gc, Black);
|
||||||
XDrawString(dpy, XtWindow(widget), gc, X, Y, words, strlen(words));
|
XDrawString(dpy, XtWindow(widget), gc, X, Y, words, strlen(words));
|
||||||
XSetForeground(dpy, gc, White);
|
|
||||||
} else if (talking == 1) {
|
} else if (talking == 1) {
|
||||||
XSetForeground(dpy, gc, Black);
|
XSetForeground(dpy, gc, Black);
|
||||||
XFillRectangle(dpy, XtWindow(widget), gc, s_rect.x-5, s_rect.y-5,
|
XFillRectangle(dpy, XtWindow(widget), gc, s_rect.x-5, s_rect.y-5,
|
||||||
s_rect.width+10, s_rect.height+10);
|
s_rect.width+10, s_rect.height+10);
|
||||||
XSetForeground(dpy, gc, White);
|
|
||||||
}
|
}
|
||||||
talking = 0;
|
talking = 0;
|
||||||
if (!force_erase)
|
if (!force_erase)
|
||||||
@@ -701,6 +704,7 @@ talk(int force_erase)
|
|||||||
NULL);
|
NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
XSetForeground(dpy, gc, White);
|
||||||
talking = 1;
|
talking = 1;
|
||||||
walk(FRONT);
|
walk(FRONT);
|
||||||
p = strcpy(buf, words);
|
p = strcpy(buf, words);
|
||||||
@@ -767,15 +771,16 @@ talk(int force_erase)
|
|||||||
XSetForeground(dpy, gc, White);
|
XSetForeground(dpy, gc, White);
|
||||||
XFillRectangle(dpy, XtWindow(widget), gc,
|
XFillRectangle(dpy, XtWindow(widget), gc,
|
||||||
s_rect.x-5, s_rect.y-5, s_rect.width+10, s_rect.height+10);
|
s_rect.x-5, s_rect.y-5, s_rect.width+10, s_rect.height+10);
|
||||||
XSetForeground(dpy, gc, Black);
|
|
||||||
|
|
||||||
/* make a box that's 5 pixels thick. Then add a thin box inside it */
|
/* make a box that's 5 pixels thick. Then add a thin box inside it */
|
||||||
|
XSetForeground(dpy, gc, Black);
|
||||||
XSetLineAttributes(dpy, gc, 5, 0, 0, 0);
|
XSetLineAttributes(dpy, gc, 5, 0, 0, 0);
|
||||||
XDrawRectangle(dpy, XtWindow(widget), gc,
|
XDrawRectangle(dpy, XtWindow(widget), gc,
|
||||||
s_rect.x, s_rect.y, s_rect.width-1, s_rect.height-1);
|
s_rect.x, s_rect.y, s_rect.width-1, s_rect.height-1);
|
||||||
XSetLineAttributes(dpy, gc, 0, 0, 0, 0);
|
XSetLineAttributes(dpy, gc, 0, 0, 0, 0);
|
||||||
XDrawRectangle(dpy, XtWindow(widget), gc,
|
XDrawRectangle(dpy, XtWindow(widget), gc,
|
||||||
s_rect.x + 7, s_rect.y + 7, s_rect.width - 15, s_rect.height - 15);
|
s_rect.x + 7, s_rect.y + 7, s_rect.width - 15,
|
||||||
|
s_rect.height - 15);
|
||||||
|
|
||||||
X = 15;
|
X = 15;
|
||||||
Y = 15 + font_height(font);
|
Y = 15 + font_height(font);
|
||||||
@@ -793,6 +798,8 @@ talk(int force_erase)
|
|||||||
static unsigned long
|
static unsigned long
|
||||||
look(void)
|
look(void)
|
||||||
{
|
{
|
||||||
|
XSetForeground(dpy, gc, White);
|
||||||
|
XSetBackground(dpy, gc, Black);
|
||||||
if (rand() % 3) {
|
if (rand() % 3) {
|
||||||
XCopyPlane(dpy, (rand() & 1)? down : front, XtWindow(widget), gc,
|
XCopyPlane(dpy, (rand() & 1)? down : front, XtWindow(widget), gc,
|
||||||
0, 0, 64,64, x, y, 1L);
|
0, 0, 64,64, x, y, 1L);
|
||||||
@@ -816,12 +823,8 @@ int
|
|||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
int foo;
|
|
||||||
Widget override;
|
Widget override;
|
||||||
XGCValues gcvalues;
|
XGCValues gcvalues;
|
||||||
char **list;
|
|
||||||
|
|
||||||
int nscr;
|
|
||||||
|
|
||||||
srand(getpid());
|
srand(getpid());
|
||||||
for (i = 0; i < (sizeof(STRING)-2); i++)
|
for (i = 0; i < (sizeof(STRING)-2); i++)
|
||||||
@@ -873,13 +876,17 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
|
|
||||||
override = XtVaAppInitialize(&app, "XNlock", options, XtNumber(options),
|
override = XtVaAppInitialize(&app, "XNlock", options, XtNumber(options),
|
||||||
&argc, argv, fallback,
|
&argc, argv, NULL,
|
||||||
XtNoverrideRedirect, True,
|
XtNoverrideRedirect, True,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
XtVaGetApplicationResources(override,(XtPointer)&appres,
|
XtVaGetApplicationResources(override,(XtPointer)&appres,
|
||||||
resources,XtNumber(resources),
|
resources,XtNumber(resources),
|
||||||
NULL);
|
NULL);
|
||||||
|
/* the background is black and the little guy is white */
|
||||||
|
Black = appres.bg;
|
||||||
|
White = appres.fg;
|
||||||
|
|
||||||
dpy = XtDisplay(override);
|
dpy = XtDisplay(override);
|
||||||
|
|
||||||
if (dpy == 0)
|
if (dpy == 0)
|
||||||
@@ -891,44 +898,49 @@ main (int argc, char **argv)
|
|||||||
Width = DisplayWidth(dpy, DefaultScreen(dpy)) + 2;
|
Width = DisplayWidth(dpy, DefaultScreen(dpy)) + 2;
|
||||||
Height = DisplayHeight(dpy, DefaultScreen(dpy)) + 2;
|
Height = DisplayHeight(dpy, DefaultScreen(dpy)) + 2;
|
||||||
|
|
||||||
nscr = ScreenCount(dpy) - 1;
|
for(i = 0; i < ScreenCount(dpy); i++){
|
||||||
|
Widget shell, core;
|
||||||
|
|
||||||
if(nscr > 0){
|
struct xxx{
|
||||||
xshell = (Widget*)malloc(nscr*sizeof(Widget));
|
Pixel bg;
|
||||||
xcore = (Widget*)malloc(nscr*sizeof(Widget));
|
}res;
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < nscr; i++){
|
XtResource Res[] = {
|
||||||
char name[32];
|
{ XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
|
||||||
sprintf(name, "xnlock%d", i+1);
|
XtOffsetOf(struct xxx, bg), XtRString, "black" }
|
||||||
xshell[i] = XtVaAppCreateShell(NULL, NULL, /*name, "XNlock", */
|
};
|
||||||
applicationShellWidgetClass, dpy,
|
|
||||||
XtNscreen, ScreenOfDisplay(dpy, i+1),
|
|
||||||
XtNoverrideRedirect, True,
|
|
||||||
XtNx, -1,
|
|
||||||
XtNy, -1,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
xcore[i] = XtVaCreateManagedWidget("_foo", widgetClass, xshell[i],
|
if(i == DefaultScreen(dpy))
|
||||||
XtNwidth, Width,
|
continue;
|
||||||
XtNheight, Height,
|
|
||||||
NULL);
|
shell = XtVaAppCreateShell(NULL,NULL, applicationShellWidgetClass, dpy,
|
||||||
XtRealizeWidget(xshell[i]);
|
XtNscreen, ScreenOfDisplay(dpy, i),
|
||||||
|
XtNoverrideRedirect, True,
|
||||||
|
XtNx, -1,
|
||||||
|
XtNy, -1,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
XtVaGetApplicationResources(shell, (XtPointer)&res,
|
||||||
|
Res, XtNumber(Res),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
core = XtVaCreateManagedWidget("_foo", widgetClass, shell,
|
||||||
|
XtNwidth, DisplayWidth(dpy, i),
|
||||||
|
XtNheight, DisplayHeight(dpy, i),
|
||||||
|
XtNbackground, res.bg,
|
||||||
|
NULL);
|
||||||
|
XtRealizeWidget(shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
widget = XtVaCreateManagedWidget("_foo", widgetClass, override,
|
widget = XtVaCreateManagedWidget("_foo", widgetClass, override,
|
||||||
XtNwidth, Width,
|
XtNwidth, Width,
|
||||||
XtNheight, Height,
|
XtNheight, Height,
|
||||||
|
XtNbackground, Black,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
init_words(--argc, ++argv);
|
init_words(--argc, ++argv);
|
||||||
init_images();
|
init_images();
|
||||||
|
|
||||||
/* the background is black and the little guy is white */
|
|
||||||
XtVaGetValues(override,
|
|
||||||
XtNbackground, &Black,
|
|
||||||
XtNforeground, &White,
|
|
||||||
NULL);
|
|
||||||
gcvalues.foreground = Black;
|
gcvalues.foreground = Black;
|
||||||
gcvalues.background = White;
|
gcvalues.background = White;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user