1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-02 14:15:46 +01:00

changed indentation to use spaces only

This commit is contained in:
dan
2004-10-12 21:28:27 +00:00
parent 5912898b06
commit 6830b05716
240 changed files with 35951 additions and 35773 deletions

View File

@@ -1,9 +1,9 @@
/* directjpeg.c- loads a jpeg file directly into a XImage
*
* WindowMaker window manager
*
*
* Copyright (c) 1999-2003 Alfredo K. Kojima
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
@@ -39,9 +39,9 @@
struct my_error_mgr {
struct jpeg_error_mgr pub; /* "public" fields */
struct jpeg_error_mgr pub; /* "public" fields */
jmp_buf setjmp_buffer; /* for return to caller */
jmp_buf setjmp_buffer; /* for return to caller */
};
typedef struct my_error_mgr * my_error_ptr;
@@ -53,15 +53,15 @@ typedef struct my_error_mgr * my_error_ptr;
static void
my_error_exit (j_common_ptr cinfo)
{
/* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
my_error_ptr myerr = (my_error_ptr) cinfo->err;
/* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
my_error_ptr myerr = (my_error_ptr) cinfo->err;
/* Always display the message. */
/* We could postpone this until after returning, if we chose. */
(*cinfo->err->output_message) (cinfo);
/* Always display the message. */
/* We could postpone this until after returning, if we chose. */
(*cinfo->err->output_message) (cinfo);
/* Return control to the setjmp point */
longjmp(myerr->setjmp_buffer, 1);
/* Return control to the setjmp point */
longjmp(myerr->setjmp_buffer, 1);
}
@@ -69,8 +69,8 @@ static Bool
canLoad(RContext *rc)
{
if (rc->depth != 16 || rc->vclass != TrueColor
|| rc->red_offset!=11 || rc->green_offset!=5 || rc->blue_offset!=0)
return False;
|| rc->red_offset!=11 || rc->green_offset!=5 || rc->blue_offset!=0)
return False;
return True;
}
@@ -78,7 +78,7 @@ canLoad(RContext *rc)
static void
readData(RContext *rc, struct jpeg_decompress_struct *cinfo,
JSAMPROW *buffer, RXImage *ximg)
JSAMPROW *buffer, RXImage *ximg)
{
int i, j;
unsigned long pixel;
@@ -89,31 +89,31 @@ readData(RContext *rc, struct jpeg_decompress_struct *cinfo,
jpeg_read_scanlines(cinfo, buffer, (JDIMENSION)1);
if (cinfo->out_color_space==JCS_RGB) {
for (i=0,j=0; i<cinfo->image_width; i++) {
if (cinfo->out_color_space==JCS_RGB) {
for (i=0,j=0; i<cinfo->image_width; i++) {
printf("%i %i %i\n",
(((unsigned long)buffer[0][j])&0xf8)<<8,
(((unsigned long)buffer[0][j+1])&0xf4)<<3,
(((unsigned long)buffer[0][j+2]))>>3);
pixel = (((unsigned long)buffer[0][j++])&0xf8)<<8
|(((unsigned long)buffer[0][j++])&0xf4)<<3
|(((unsigned long)buffer[0][j++]))>>3;
printf("%i %i %i\n",
(((unsigned long)buffer[0][j])&0xf8)<<8,
(((unsigned long)buffer[0][j+1])&0xf4)<<3,
(((unsigned long)buffer[0][j+2]))>>3);
XPutPixel(ximg->image, i, y, pixel);
}
} else {
for (i=0,j=0; i<cinfo->image_width; i++, j++) {
pixel = (((unsigned long)buffer[0][j++])&0xf8)<<8
|(((unsigned long)buffer[0][j++])&0xf4)<<3
|(((unsigned long)buffer[0][j++]))>>3;
pixel = (unsigned long)buffer[0][j]<<8
|(unsigned long)buffer[0][j]<<3
|(unsigned long)buffer[0][j]>>3;
XPutPixel(ximg->image, i, y, pixel);
}
} else {
for (i=0,j=0; i<cinfo->image_width; i++, j++) {
XPutPixel(ximg->image, i, y, pixel);
}
}
y++;
pixel = (unsigned long)buffer[0][j]<<8
|(unsigned long)buffer[0][j]<<3
|(unsigned long)buffer[0][j]>>3;
XPutPixel(ximg->image, i, y, pixel);
}
}
y++;
}
}
@@ -131,19 +131,19 @@ LoadJPEG(RContext *rc, char *file_name, int *width, int *height)
Pixmap p = None;
if (!canLoad(rc))
return None;
return None;
file = fopen(file_name, "rb");
if (!file) {
return None;
return None;
}
if (fread(buf, 2, 1, file) != 1) {
fclose(file);
return None;
fclose(file);
return None;
}
if (buf[0] != 0xff || buf[1] != 0xd8) {
fclose(file);
return None;
fclose(file);
return None;
}
rewind(file);
@@ -151,33 +151,33 @@ LoadJPEG(RContext *rc, char *file_name, int *width, int *height)
jerr.pub.error_exit = my_error_exit;
/* Establish the setjmp return context for my_error_exit to use. */
if (setjmp(jerr.setjmp_buffer)) {
/* If we get here, the JPEG code has signaled an error.
* We need to clean up the JPEG object, close the input file, and return.
*/
jpeg_destroy_decompress(&cinfo);
fclose(file);
/* If we get here, the JPEG code has signaled an error.
* We need to clean up the JPEG object, close the input file, and return.
*/
jpeg_destroy_decompress(&cinfo);
fclose(file);
if (ximg) {
RDestroyXImage(rc, ximg);
}
return None;
if (ximg) {
RDestroyXImage(rc, ximg);
}
return None;
}
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, file);
jpeg_read_header(&cinfo, TRUE);
buffer[0] = (JSAMPROW)malloc(cinfo.image_width*cinfo.num_components);
if (!buffer[0]) {
RErrorCode = RERR_NOMEMORY;
goto bye;
RErrorCode = RERR_NOMEMORY;
goto bye;
}
if(cinfo.jpeg_color_space==JCS_GRAYSCALE) {
cinfo.out_color_space=JCS_GRAYSCALE;
cinfo.out_color_space=JCS_GRAYSCALE;
} else
cinfo.out_color_space = JCS_RGB;
cinfo.quantize_colors = FALSE;
@@ -187,7 +187,7 @@ LoadJPEG(RContext *rc, char *file_name, int *width, int *height)
ximg = RCreateXImage(rc, rc->depth, cinfo.image_width, cinfo.image_height);
if (!ximg) {
goto bye;
goto bye;
}
jpeg_start_decompress(&cinfo);
@@ -195,26 +195,26 @@ LoadJPEG(RContext *rc, char *file_name, int *width, int *height)
jpeg_finish_decompress(&cinfo);
p = XCreatePixmap(rc->dpy, rc->drawable, cinfo.image_width,
cinfo.image_height, rc->depth);
p = XCreatePixmap(rc->dpy, rc->drawable, cinfo.image_width,
cinfo.image_height, rc->depth);
RPutXImage(rc, p, rc->copy_gc, ximg, 0, 0, 0, 0, cinfo.image_width,
cinfo.image_height);
cinfo.image_height);
*width = cinfo.image_width;
*height = cinfo.image_height;
bye:
bye:
jpeg_destroy_decompress(&cinfo);
fclose(file);
if (buffer[0])
free(buffer[0]);
free(buffer[0]);
if (ximg)
RDestroyXImage(rc, ximg);
RDestroyXImage(rc, ximg);
return p;
}

View File

@@ -1,9 +1,9 @@
/* geticonset.c - outputs icon configuration from WindowMaker to stdout
*
* Window Maker window manager
*
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
@@ -44,18 +44,18 @@ defaultsPathForDomain(char *domain)
gspath = getenv("GNUSTEP_USER_ROOT");
if (gspath) {
strcpy(path, gspath);
strcat(path, "/");
strcpy(path, gspath);
strcat(path, "/");
} else {
char *home;
home = getenv("HOME");
if (!home) {
printf("%s:could not get HOME environment variable!\n", ProgName);
exit(0);
}
strcpy(path, home);
strcat(path, "/GNUstep/");
char *home;
home = getenv("HOME");
if (!home) {
printf("%s:could not get HOME environment variable!\n", ProgName);
exit(0);
}
strcpy(path, home);
strcat(path, "/GNUstep/");
}
strcat(path, DEFAULTS_DIR);
strcat(path, "/");
@@ -75,7 +75,7 @@ print_help()
}
int
int
main(int argc, char **argv)
{
WMPropList *window_name, *icon_key, *window_attrs, *icon_value;
@@ -87,52 +87,52 @@ main(int argc, char **argv)
ProgName = argv[0];
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-h")==0
|| strcmp(argv[i], "--help")==0) {
print_help();
exit(0);
} else if (strcmp(argv[i], "--version")==0) {
puts(PROG_VERSION);
exit(0);
}
if (strcmp(argv[i], "-h")==0
|| strcmp(argv[i], "--help")==0) {
print_help();
exit(0);
} else if (strcmp(argv[i], "--version")==0) {
puts(PROG_VERSION);
exit(0);
}
}
path = defaultsPathForDomain("WMWindowAttributes");
all_windows = WMReadPropListFromFile(path);
if (!all_windows) {
printf("%s:could not load WindowMaker configuration file \"%s\".\n",
ProgName, path);
exit(1);
printf("%s:could not load WindowMaker configuration file \"%s\".\n",
ProgName, path);
exit(1);
}
iconset = WMCreatePLDictionary(NULL, NULL);
keylist = WMGetPLDictionaryKeys(all_windows);
icon_key = WMCreatePLString("Icon");
for (i=0; i<WMGetPropListItemCount(keylist); i++) {
WMPropList *icondic;
window_name = WMGetFromPLArray(keylist, i);
if (!WMIsPLString(window_name))
continue;
window_attrs = WMGetFromPLDictionary(all_windows, window_name);
if (window_attrs && WMIsPLDictionary(window_attrs)) {
icon_value = WMGetFromPLDictionary(window_attrs, icon_key);
if (icon_value) {
icondic = WMCreatePLDictionary(icon_key, icon_value, NULL);
WMPutInPLDictionary(iconset, window_name, icondic);
}
}
WMPropList *icondic;
window_name = WMGetFromPLArray(keylist, i);
if (!WMIsPLString(window_name))
continue;
window_attrs = WMGetFromPLDictionary(all_windows, window_name);
if (window_attrs && WMIsPLDictionary(window_attrs)) {
icon_value = WMGetFromPLDictionary(window_attrs, icon_key);
if (icon_value) {
icondic = WMCreatePLDictionary(icon_key, icon_value, NULL);
WMPutInPLDictionary(iconset, window_name, icondic);
}
}
}
if (argc==2) {
WMWritePropListToFile(iconset, argv[1], False);
WMWritePropListToFile(iconset, argv[1], False);
} else {
puts(WMGetPropListDescription(iconset, True));
puts(WMGetPropListDescription(iconset, True));
}
exit(0);
}

View File

@@ -1,9 +1,9 @@
/* seticons.c - sets icon configuration in WindowMaker
*
* WindowMaker window manager
*
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
@@ -40,19 +40,19 @@ defaultsPathForDomain(char *domain)
gspath = getenv("GNUSTEP_USER_ROOT");
if (gspath) {
strcpy(path, gspath);
strcat(path, "/");
strcpy(path, gspath);
strcat(path, "/");
} else {
char *home;
home = getenv("HOME");
if (!home) {
printf("%s:could not get HOME environment variable!\n", ProgName);
exit(0);
}
char *home;
strcpy(path, home);
strcat(path, "/GNUstep/");
home = getenv("HOME");
if (!home) {
printf("%s:could not get HOME environment variable!\n", ProgName);
exit(0);
}
strcpy(path, home);
strcat(path, "/GNUstep/");
}
strcat(path, DEFAULTS_DIR);
strcat(path, "/");
@@ -73,7 +73,7 @@ print_help()
}
int
int
main(int argc, char **argv)
{
WMPropList *window_name, *icon_key, *window_attrs, *icon_value;
@@ -85,66 +85,66 @@ main(int argc, char **argv)
if (argc < 2) {
printf("%s: missing argument\n", ProgName);
printf("Try '%s --help' for more information\n", ProgName);
printf("%s: missing argument\n", ProgName);
printf("Try '%s --help' for more information\n", ProgName);
}
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-h")==0
|| strcmp(argv[i], "--help")==0) {
print_help();
exit(0);
} else if (strcmp(argv[i], "--version")==0) {
puts(PROG_VERSION);
exit(0);
} else {
if (path) {
printf("%s: invalid argument '%s'\n", ProgName, argv[i]);
printf("Try '%s --help' for more information\n", ProgName);
exit(1);
}
path = argv[i];
}
if (strcmp(argv[i], "-h")==0
|| strcmp(argv[i], "--help")==0) {
print_help();
exit(0);
} else if (strcmp(argv[i], "--version")==0) {
puts(PROG_VERSION);
exit(0);
} else {
if (path) {
printf("%s: invalid argument '%s'\n", ProgName, argv[i]);
printf("Try '%s --help' for more information\n", ProgName);
exit(1);
}
path = argv[i];
}
}
path = defaultsPathForDomain("WMWindowAttributes");
all_windows = WMReadPropListFromFile(path);
if (!all_windows) {
printf("%s:could not load WindowMaker configuration file \"%s\".\n",
ProgName, path);
exit(1);
printf("%s:could not load WindowMaker configuration file \"%s\".\n",
ProgName, path);
exit(1);
}
iconset = WMReadPropListFromFile(argv[1]);
if (!iconset) {
printf("%s:could not load icon set file \"%s\".\n", ProgName, argv[1]);
exit(1);
printf("%s:could not load icon set file \"%s\".\n", ProgName, argv[1]);
exit(1);
}
keylist = WMGetPLDictionaryKeys(iconset);
icon_key = WMCreatePLString("Icon");
for (i=0; i<WMGetPropListItemCount(keylist); i++) {
window_name = WMGetFromPLArray(keylist, i);
if (!WMIsPLString(window_name))
continue;
icon_value = WMGetFromPLDictionary(iconset, window_name);
if (!icon_value || !WMIsPLDictionary(icon_value))
continue;
for (i=0; i<WMGetPropListItemCount(keylist); i++) {
window_name = WMGetFromPLArray(keylist, i);
if (!WMIsPLString(window_name))
continue;
window_attrs = WMGetFromPLDictionary(all_windows, window_name);
if (window_attrs) {
if (WMIsPLDictionary(window_attrs)) {
WMMergePLDictionaries(window_attrs, icon_value, True);
}
} else {
WMPutInPLDictionary(all_windows, window_name, icon_value);
}
icon_value = WMGetFromPLDictionary(iconset, window_name);
if (!icon_value || !WMIsPLDictionary(icon_value))
continue;
window_attrs = WMGetFromPLDictionary(all_windows, window_name);
if (window_attrs) {
if (WMIsPLDictionary(window_attrs)) {
WMMergePLDictionaries(window_attrs, icon_value, True);
}
} else {
WMPutInPLDictionary(all_windows, window_name, icon_value);
}
}
WMWritePropListToFile(all_windows, path, True);
exit(0);

View File

@@ -175,7 +175,7 @@ strToInt(str *token)
int res=0, pos, c;
if (token->len==0 || token->str[0]=='*') {
return -1;
return -1;
} else {
for (res=0, pos=0; pos<token->len; pos++) {
c = token->str[pos] - '0';
@@ -579,11 +579,11 @@ print_help()
puts(" --ignore <option> ignore changes in the specified option");
puts(" --help display this help and exit");
/*
puts(" --format <format> specifies the format of the theme to be converted");
puts(" --format <format> specifies the format of the theme to be converted");
*/
puts(" --version output version information and exit");
/*puts("");
puts("Supported formats: blackbox");*/
puts("Supported formats: blackbox");*/
}
@@ -806,3 +806,4 @@ readBlackBoxStyle(char *path)
}
}
#endif

View File

@@ -1,10 +1,10 @@
/* wdread.c - read value from defaults database
*
* WindowMaker window manager
*
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
* (cowardly remade from wdwrite.c; by judas@hell on Jan 26 2001)
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
@@ -50,11 +50,11 @@ gethomedir()
struct passwd *user;
if (home)
return home;
return home;
user = getpwuid(getuid());
if (!user) {
perror(ProgName);
perror(ProgName);
return "/";
}
if (!user->pw_dir) {
@@ -66,7 +66,8 @@ gethomedir()
void wAbort()
void
wAbort()
{
exit(0);
}
@@ -87,33 +88,33 @@ int main(int argc, char **argv)
WMPropList *key, *value, *dict;
char *gsdir;
int i;
ProgName = argv[0];
for (i = 1; i < argc; i++) {
if (strcmp("--help", argv[i])==0) {
help();
exit(0);
} else if (strcmp("--version", argv[i])==0) {
puts(PROG_VERSION);
exit(0);
}
if (strcmp("--help", argv[i])==0) {
help();
exit(0);
} else if (strcmp("--version", argv[i])==0) {
puts(PROG_VERSION);
exit(0);
}
}
if (argc<3) {
printf("%s: invalid argument format\n", ProgName);
printf("Try '%s --help' for more information\n", ProgName);
exit(1);
printf("%s: invalid argument format\n", ProgName);
printf("Try '%s --help' for more information\n", ProgName);
exit(1);
}
key = WMCreatePLString(argv[2]);
gsdir = getenv("GNUSTEP_USER_ROOT");
if (gsdir) {
strcpy(path, gsdir);
strcpy(path, gsdir);
} else {
strcpy(path, gethomedir());
strcat(path, "/GNUstep");
strcpy(path, gethomedir());
strcat(path, "/GNUstep");
}
strcat(path, "/");
strcat(path, DEFAULTS_DIR);
@@ -121,9 +122,9 @@ int main(int argc, char **argv)
strcat(path, argv[1]);
if ((dict = WMReadPropListFromFile(path)) == NULL)
return 1; /* bad domain */
return 1; /* bad domain */
if ((value = WMGetFromPLDictionary(dict, key)) == NULL)
return 2; /* bad key */
return 2; /* bad key */
printf("%s\n", WMGetPropListDescription(value, True));
return 0;

View File

@@ -1,9 +1,9 @@
/* wdwrite.c - write key/value to defaults database
*
* WindowMaker window manager
*
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
@@ -49,11 +49,11 @@ gethomedir()
struct passwd *user;
if (home)
return home;
return home;
user = getpwuid(getuid());
if (!user) {
perror(ProgName);
perror(ProgName);
return "/";
}
if (!user->pw_dir) {
@@ -86,38 +86,38 @@ int main(int argc, char **argv)
WMPropList *dom, *key, *value, *dict;
char *gsdir;
int i;
ProgName = argv[0];
for (i = 1; i < argc; i++) {
if (strcmp("--help", argv[i])==0) {
help();
exit(0);
} else if (strcmp("--version", argv[i])==0) {
puts(PROG_VERSION);
exit(0);
}
if (strcmp("--help", argv[i])==0) {
help();
exit(0);
} else if (strcmp("--version", argv[i])==0) {
puts(PROG_VERSION);
exit(0);
}
}
if (argc<4) {
printf("%s: invalid argument format\n", ProgName);
printf("Try '%s --help' for more information\n", ProgName);
exit(1);
printf("%s: invalid argument format\n", ProgName);
printf("Try '%s --help' for more information\n", ProgName);
exit(1);
}
dom = WMCreatePLString(argv[1]);
key = WMCreatePLString(argv[2]);
value = WMCreatePropListFromDescription(argv[3]);
if (!value) {
printf("%s:syntax error in value \"%s\"", ProgName, argv[3]);
exit(1);
printf("%s:syntax error in value \"%s\"", ProgName, argv[3]);
exit(1);
}
gsdir = getenv("GNUSTEP_USER_ROOT");
if (gsdir) {
path = wstrdup(gsdir);
path = wstrdup(gsdir);
} else {
path = wstrdup(gethomedir());
path = wstrappend(path, "/GNUstep");
path = wstrdup(gethomedir());
path = wstrappend(path, "/GNUstep");
}
path = wstrappend(path, "/");
path = wstrappend(path, DEFAULTS_DIR);
@@ -126,9 +126,9 @@ int main(int argc, char **argv)
dict = WMReadPropListFromFile(path);
if (!dict) {
dict = WMCreatePLDictionary(key, value, NULL);
dict = WMCreatePLDictionary(key, value, NULL);
} else {
WMPutInPLDictionary(dict, key, value);
WMPutInPLDictionary(dict, key, value);
}
WMWritePropListToFile(dict, path, True);

View File

@@ -1,8 +1,8 @@
/*
* magnify - a X utility for magnifying screen image
*
*
* 2000/5/21 Alfredo K. Kojima
*
*
* This program is in the Public Domain.
*/
@@ -16,8 +16,8 @@
/*
* TODO:
* - lens that shows where it's magnifying
*
*
*
*
*/
int refreshrate = 200;
@@ -75,33 +75,33 @@ WMColor *cursorColor2;
static BufferData*
makeBufferData(WMWindow *win, WMLabel *label, int width, int height,
int magfactor)
int magfactor)
{
BufferData *data;
data = wmalloc(sizeof(BufferData));
data->rwidth = width;
data->rheight = height;
data->refreshrate = refreshrate;
data->firstDraw = True;
data->magfactor = magfactor;
data->rects = wmalloc(sizeof(XRectangle)*rectBufferSize);
data->rectP = 0;
data->win = win;
data->label = label;
data->pixmap = WMCreatePixmap(scr, width, height,
WMScreenDepth(scr), False);
WMScreenDepth(scr), False);
WMSetLabelImage(data->label, data->pixmap);
data->d = WMGetPixmapXID(data->pixmap);
data->frozen = False;
width /= magfactor;
@@ -133,10 +133,10 @@ resizeBufferData(BufferData *data, int width, int height, int magfactor)
WMResizeWidget(data->label, width, height);
WMReleasePixmap(data->pixmap);
data->pixmap = WMCreatePixmap(scr, width, height, WMScreenDepth(scr),
False);
data->pixmap = WMCreatePixmap(scr, width, height, WMScreenDepth(scr),
False);
WMSetLabelImage(data->label, data->pixmap);
data->d = WMGetPixmapXID(data->pixmap);
}
@@ -148,23 +148,23 @@ drawpoint(BufferData *data, unsigned long pixel, int x, int y)
Bool flush = (x < 0);
if (!flush) {
if (data->buffer[x+data->width*y] == pixel && !data->firstDraw)
return 0;
data->buffer[x+data->width*y] = pixel;
if (data->buffer[x+data->width*y] == pixel && !data->firstDraw)
return 0;
data->buffer[x+data->width*y] = pixel;
}
if (gc == NULL) {
gc = XCreateGC(dpy, DefaultRootWindow(dpy), 0, NULL);
gc = XCreateGC(dpy, DefaultRootWindow(dpy), 0, NULL);
}
if (!flush && data->lastpixel == pixel && data->rectP < rectBufferSize) {
data->rects[data->rectP].x = x*data->magfactor;
data->rects[data->rectP].y = y*data->magfactor;
data->rects[data->rectP].width = data->magfactor;
data->rects[data->rectP].height = data->magfactor;
data->rectP++;
return 0;
if (!flush && data->lastpixel == pixel && data->rectP < rectBufferSize) {
data->rects[data->rectP].x = x*data->magfactor;
data->rects[data->rectP].y = y*data->magfactor;
data->rects[data->rectP].width = data->magfactor;
data->rects[data->rectP].height = data->magfactor;
data->rectP++;
return 0;
}
XSetForeground(dpy, gc, data->lastpixel);
XFillRectangles(dpy, data->d, gc, data->rects, data->rectP);
@@ -174,7 +174,7 @@ drawpoint(BufferData *data, unsigned long pixel, int x, int y)
data->rects[data->rectP].width = data->magfactor;
data->rects[data->rectP].height = data->magfactor;
data->rectP++;
data->lastpixel = pixel;
return 1;
@@ -185,8 +185,8 @@ static inline unsigned long
getpix(XImage *image, int x, int y, int xoffs, int yoffs)
{
if (x < xoffs || y < yoffs
|| x >= xoffs + image->width || y >= yoffs + image->height) {
return black;
|| x >= xoffs + image->width || y >= yoffs + image->height) {
return black;
}
return XGetPixel(image, x-xoffs, y-yoffs);
}
@@ -203,79 +203,79 @@ updateImage(BufferData *data, int rx, int ry)
gw = data->width;
gh = data->height;
gx = rx - gw/2;
gy = ry - gh/2;
xoffs = yoffs = 0;
if (gx < 0) {
xoffs = abs(gx);
gw += gx;
gx = 0;
xoffs = abs(gx);
gw += gx;
gx = 0;
}
if (gx + gw >= WidthOfScreen(DefaultScreenOfDisplay(vdpy))) {
gw = WidthOfScreen(DefaultScreenOfDisplay(vdpy)) - gx;
gw = WidthOfScreen(DefaultScreenOfDisplay(vdpy)) - gx;
}
if (gy < 0) {
yoffs = abs(gy);
gh += gy;
gy = 0;
yoffs = abs(gy);
gh += gy;
gy = 0;
}
if (gy + gh >= HeightOfScreen(DefaultScreenOfDisplay(vdpy))) {
gh = HeightOfScreen(DefaultScreenOfDisplay(vdpy)) - gy;
gh = HeightOfScreen(DefaultScreenOfDisplay(vdpy)) - gy;
}
image = XGetImage(vdpy, DefaultRootWindow(vdpy), gx, gy, gw, gh,
AllPlanes, ZPixmap);
AllPlanes, ZPixmap);
for (y = 0; y < data->height; y++) {
for (x = 0; x < data->width; x++) {
unsigned long pixel;
for (x = 0; x < data->width; x++) {
unsigned long pixel;
pixel = getpix(image, x, y, xoffs, yoffs);
pixel = getpix(image, x, y, xoffs, yoffs);
if (drawpoint(data, pixel, x, y))
changedPixels++;
}
if (drawpoint(data, pixel, x, y))
changedPixels++;
}
}
/* flush the point cache */
drawpoint(data, 0, -1, -1);
XDestroyImage(image);
if (data->markPointerHotspot && !data->frozen) {
XRectangle rects[4];
XRectangle rects[4];
rects[0].x = (data->width/2 - 3)*data->magfactor;
rects[0].y = (data->height/2)*data->magfactor;
rects[0].width = 2*data->magfactor;
rects[0].height = data->magfactor;
rects[0].x = (data->width/2 - 3)*data->magfactor;
rects[0].y = (data->height/2)*data->magfactor;
rects[0].width = 2*data->magfactor;
rects[0].height = data->magfactor;
rects[1].x = (data->width/2 + 2)*data->magfactor;
rects[1].y = (data->height/2)*data->magfactor;
rects[1].width = 2*data->magfactor;
rects[1].height = data->magfactor;
rects[1].x = (data->width/2 + 2)*data->magfactor;
rects[1].y = (data->height/2)*data->magfactor;
rects[1].width = 2*data->magfactor;
rects[1].height = data->magfactor;
XFillRectangles(dpy, data->d, WMColorGC(cursorColor1), rects, 2);
XFillRectangles(dpy, data->d, WMColorGC(cursorColor1), rects, 2);
rects[2].y = (data->height/2 - 3)*data->magfactor;
rects[2].x = (data->width/2)*data->magfactor;
rects[2].height = 2*data->magfactor;
rects[2].width = data->magfactor;
rects[2].y = (data->height/2 - 3)*data->magfactor;
rects[2].x = (data->width/2)*data->magfactor;
rects[2].height = 2*data->magfactor;
rects[2].width = data->magfactor;
rects[3].y = (data->height/2 + 2)*data->magfactor;
rects[3].x = (data->width/2)*data->magfactor;
rects[3].height = 2*data->magfactor;
rects[3].width = data->magfactor;
rects[3].y = (data->height/2 + 2)*data->magfactor;
rects[3].x = (data->width/2)*data->magfactor;
rects[3].height = 2*data->magfactor;
rects[3].width = data->magfactor;
XFillRectangles(dpy, data->d, WMColorGC(cursorColor2), rects + 2, 2);
XFillRectangles(dpy, data->d, WMColorGC(cursorColor2), rects + 2, 2);
}
if (changedPixels > 0) {
WMRedisplayWidget(data->label);
WMRedisplayWidget(data->label);
}
data->firstDraw = False;
}
@@ -288,14 +288,14 @@ update(void *d)
int rx, ry;
int bla;
unsigned ubla;
if (data->frozen) {
rx = data->x;
ry = data->y;
rx = data->x;
ry = data->y;
} else {
XQueryPointer(dpy, DefaultRootWindow(dpy), &win, &win, &rx, &ry,
&bla, &bla, &ubla);
XQueryPointer(dpy, DefaultRootWindow(dpy), &win, &win, &rx, &ry,
&bla, &bla, &ubla);
}
updateImage(data, rx, ry);
@@ -310,7 +310,7 @@ void resizedWindow(void *d, WMNotification *notif)
WMSize size;
size = WMGetViewSize(view);
resizeBufferData(data, size.width, size.height, data->magfactor);
}
@@ -322,14 +322,14 @@ void closeWindow(WMWidget *w, void *d)
windowCount--;
if (windowCount == 0) {
exit(0);
exit(0);
} else {
WMDeleteTimerHandler(data->tid);
WMDestroyWidget(w);
wfree(data->buffer);
wfree(data->rects);
WMReleasePixmap(data->pixmap);
wfree(data);
WMDeleteTimerHandler(data->tid);
WMDestroyWidget(w);
wfree(data->buffer);
wfree(data->rects);
WMReleasePixmap(data->pixmap);
wfree(data);
}
}
@@ -339,15 +339,15 @@ static void
clickHandler(XEvent *event, void *d)
{
BufferData *data = (BufferData*)d;
data->win = WMCreateWindow(scr, "setup");
WMSetWindowTitle(data->win, "Magnify Options");
data->speed = WMCreateSlider(data->win);
data->magnify = WMCreateSlider(data->win);
}
#endif
@@ -365,43 +365,43 @@ keyHandler(XEvent *event, void *d)
size = WMGetViewSize(view);
if (XLookupString(&event->xkey, buf, 31, &ks, NULL) > 0) {
switch (buf[0]) {
case 'n':
newWindow(data->magfactor);
break;
case 'm':
data->markPointerHotspot = !data->markPointerHotspot;
break;
case 'f':
case ' ':
data->frozen = !data->frozen;
if (data->frozen) {
data->x = event->xkey.x_root;
data->y = event->xkey.y_root;
sprintf(buf, "[Magnify %ix]", data->magfactor);
} else {
sprintf(buf, "Magnify %ix", data->magfactor);
}
WMSetWindowTitle(data->win, buf);
break;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
resizeBufferData(data, size.width, size.height, buf[0]-'0');
if (data->frozen) {
sprintf(buf, "[Magnify %ix]", data->magfactor);
} else {
sprintf(buf, "Magnify %ix", data->magfactor);
}
WMSetWindowTitle(data->win, buf);
break;
}
switch (buf[0]) {
case 'n':
newWindow(data->magfactor);
break;
case 'm':
data->markPointerHotspot = !data->markPointerHotspot;
break;
case 'f':
case ' ':
data->frozen = !data->frozen;
if (data->frozen) {
data->x = event->xkey.x_root;
data->y = event->xkey.y_root;
sprintf(buf, "[Magnify %ix]", data->magfactor);
} else {
sprintf(buf, "Magnify %ix", data->magfactor);
}
WMSetWindowTitle(data->win, buf);
break;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
resizeBufferData(data, size.width, size.height, buf[0]-'0');
if (data->frozen) {
sprintf(buf, "[Magnify %ix]", data->magfactor);
} else {
sprintf(buf, "Magnify %ix", data->magfactor);
}
WMSetWindowTitle(data->win, buf);
break;
}
}
}
@@ -415,7 +415,7 @@ newWindow(int magfactor)
char buf[32];
windowCount++;
win = WMCreateWindow(scr, "magnify");
WMResizeWidget(win, 300, 200);
sprintf(buf, "Magnify %ix", magfactor);
@@ -427,15 +427,15 @@ newWindow(int magfactor)
WMMoveWidget(label, 0, 0);
WMSetLabelRelief(label, WRSunken);
WMSetLabelImagePosition(label, WIPImageOnly);
data = makeBufferData(win, label, 300, 200, magfactor);
WMCreateEventHandler(WMWidgetView(win), KeyReleaseMask,
keyHandler, data);
keyHandler, data);
WMAddNotificationObserver(resizedWindow, data,
WMViewSizeDidChangeNotification,
WMWidgetView(win));
WMViewSizeDidChangeNotification,
WMWidgetView(win));
WMRealizeWidget(win);
@@ -460,79 +460,79 @@ int main(int argc, char **argv)
WMButton *radio, *tradio;
#endif
WMInitializeApplication("Magnify", &argc, argv);
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-display")==0) {
i++;
if (i >= argc)
goto help;
display = argv[i];
} else if (strcmp(argv[i], "-vdisplay")==0) {
i++;
if (i >= argc)
goto help;
vdisplay = argv[i];
} else if (strcmp(argv[i], "-m")==0) {
i++;
if (i >= argc)
goto help;
magfactor = atoi(argv[i]);
if (magfactor < 1 || magfactor > 32) {
printf("%s:invalid magnification factor ``%s''\n", argv[0],
argv[i]);
exit(1);
}
} else if (strcmp(argv[i], "-r")==0) {
i++;
if (i >= argc)
goto help;
refreshrate = atoi(argv[i]);
if (refreshrate < 1) {
printf("%s:invalid refresh rate ``%s''\n", argv[0], argv[i]);
exit(1);
}
} else if (strcmp(argv[i], "-h")==0
|| strcmp(argv[i], "--help")==0) {
help:
printf("Syntax: %s [options]\n",
argv[0]);
puts("Options:");
puts(" -display <display> display that should be used");
puts(" -m <number> change magnification factor (default 2)");
puts(" -r <number> change refresh delay, in milliseconds (default 200)");
puts("Keys:");
puts(" 1,2,3,4,5,6,7,8,9 change the magnification factor");
puts(" <space>, f freeze the 'camera', making it magnify only the current\n"
" position");
puts(" n create a new window");
puts(" m show/hide the pointer hotspot mark");
exit(0);
}
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-display")==0) {
i++;
if (i >= argc)
goto help;
display = argv[i];
} else if (strcmp(argv[i], "-vdisplay")==0) {
i++;
if (i >= argc)
goto help;
vdisplay = argv[i];
} else if (strcmp(argv[i], "-m")==0) {
i++;
if (i >= argc)
goto help;
magfactor = atoi(argv[i]);
if (magfactor < 1 || magfactor > 32) {
printf("%s:invalid magnification factor ``%s''\n", argv[0],
argv[i]);
exit(1);
}
} else if (strcmp(argv[i], "-r")==0) {
i++;
if (i >= argc)
goto help;
refreshrate = atoi(argv[i]);
if (refreshrate < 1) {
printf("%s:invalid refresh rate ``%s''\n", argv[0], argv[i]);
exit(1);
}
} else if (strcmp(argv[i], "-h")==0
|| strcmp(argv[i], "--help")==0) {
help:
printf("Syntax: %s [options]\n",
argv[0]);
puts("Options:");
puts(" -display <display> display that should be used");
puts(" -m <number> change magnification factor (default 2)");
puts(" -r <number> change refresh delay, in milliseconds (default 200)");
puts("Keys:");
puts(" 1,2,3,4,5,6,7,8,9 change the magnification factor");
puts(" <space>, f freeze the 'camera', making it magnify only the current\n"
" position");
puts(" n create a new window");
puts(" m show/hide the pointer hotspot mark");
exit(0);
}
}
dpy = XOpenDisplay(display);
if (!dpy) {
puts("couldnt open display");
exit(1);
puts("couldnt open display");
exit(1);
}
if (vdisplay) {
vdpy = XOpenDisplay(vdisplay);
if (!vdpy) {
puts("couldnt open display to be viewed");
exit(1);
}
if (!vdpy) {
puts("couldnt open display to be viewed");
exit(1);
}
} else {
vdpy = dpy;
vdpy = dpy;
}
/* calculate how many rectangles we can send in a trip to the server */
rectBufferSize = XMaxRequestSize(dpy) - 128;
rectBufferSize /= sizeof(XRectangle);
if (rectBufferSize < 1)
rectBufferSize = 1;
rectBufferSize = 1;
black = BlackPixel(dpy, DefaultScreen(dpy));
@@ -540,7 +540,7 @@ int main(int argc, char **argv)
cursorColor1 = WMCreateNamedColor(scr, "#ff0000", False);
cursorColor2 = WMCreateNamedColor(scr, "#00ff00", False);
data = newWindow(magfactor);
WMScreenMainLoop(scr);

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/* wmsetup.c- create wmaker config file dir structure and copy default
* config files.
*
*
* Copyright (c) 2000-2003 Alfredo K. Kojima
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -41,25 +41,25 @@ main()
char *RequiredDirectories[] = {
"/Defaults",
"/.AppInfo",
"/Library",
"/Library/Icons",
"/Library/WindowMaker",
"/Library/WindowMaker/Backgrounds",
"/Library/WindowMaker/IconSets",
"/Library/WindowMaker/Pixmaps",
"/Library/WindowMaker/SoundSets",
"/Library/WindowMaker/Sounds",
"/Library/WindowMaker/Styles",
"/Library/WindowMaker/Themes",
NULL
"/.AppInfo",
"/Library",
"/Library/Icons",
"/Library/WindowMaker",
"/Library/WindowMaker/Backgrounds",
"/Library/WindowMaker/IconSets",
"/Library/WindowMaker/Pixmaps",
"/Library/WindowMaker/SoundSets",
"/Library/WindowMaker/Sounds",
"/Library/WindowMaker/Styles",
"/Library/WindowMaker/Themes",
NULL
};
char *RequiredFiles[] = {
"/Defaults/WindowMaker",
"/Defaults/WMWindowAttributes",
NULL
"/Defaults/WMWindowAttributes",
NULL
};
@@ -72,7 +72,7 @@ WMScreen *scr;
#if 0
void
void
wlog(const char *msg, ...)
{
va_list args;
@@ -88,7 +88,8 @@ wlog(const char *msg, ...)
#endif
void alert(const char *msg, ...)
void
alert(const char *msg, ...)
{
va_list args;
char buffer[2048];
@@ -96,17 +97,16 @@ void alert(const char *msg, ...)
va_start(args, msg);
vsprintf(buf, msg, args);
WMRunAlertPanel(scr, NULL, _("Error"),
buffer, _("OK"), NULL, NULL);
buffer, _("OK"), NULL, NULL);
va_end(args);
}
Bool ask(char *title, char *yes, char *no, const char *msg, ...)
Bool
ask(char *title, char *yes, char *no, const char *msg, ...)
{
va_list args;
char buffer[2048];
@@ -114,140 +114,144 @@ Bool ask(char *title, char *yes, char *no, const char *msg, ...)
va_start(args, msg);
vsprintf(buf, msg, args);
WMRunAlertPanel(scr, NULL, title,
buffer, yes, no, NULL);
buffer, yes, no, NULL);
va_end(args);
}
char *renameName(char *path)
char*
renameName(char *path)
{
char *buf = wmalloc(strlen(path)+8);
int i;
sprintf(buf, "%s~", path);
if (access(buf, F_OK) < 0) {
return buf;
return buf;
}
for (i = 0; i < 10; i++) {
sprintf(buf, "%s~%i", path, i);
if (access(buf, F_OK) < 0) {
return buf;
}
sprintf(buf, "%s~%i", path, i);
if (access(buf, F_OK) < 0) {
return buf;
}
}
sprintf(buf, "%s~", path);
return buf;
}
void showFileError(int error, Bool directory, char *path)
void
showFileError(int error, Bool directory, char *path)
{
switch (error) {
case EACCESS:
if (directory) {
alert(_("The directory %s needs to be fully accessible, but is\n"
"not. Make sure all of it's parent directories have\n"
"read and execute permissions set."), path);
} else {
alert(_("The file %s needs to be fully accessible, but is not.\n"
"Make sure it has read and write permissions set and\n"
"all of it's parent directories have read and execute\n"
"permissions."), path);
}
break;
case EROFS:
alert(_("The %s %s is in a read-only file system, but it needs to be\n"
"writable. Start wmaker with the --static command line option."),
directory ? _("directory") : _("file"), path);
break;
default:
alert(_("An error occurred while accessing the %s %s. Please make sure\n"
"it exists and is accessible.\n%s"),
directory ? _("directory") : _("file"), path,
wstrerror(error));
break;
case EACCESS:
if (directory) {
alert(_("The directory %s needs to be fully accessible, but is\n"
"not. Make sure all of it's parent directories have\n"
"read and execute permissions set."), path);
} else {
alert(_("The file %s needs to be fully accessible, but is not.\n"
"Make sure it has read and write permissions set and\n"
"all of it's parent directories have read and execute\n"
"permissions."), path);
}
break;
case EROFS:
alert(_("The %s %s is in a read-only file system, but it needs to be\n"
"writable. Start wmaker with the --static command line option."),
directory ? _("directory") : _("file"), path);
break;
default:
alert(_("An error occurred while accessing the %s %s. Please make sure\n"
"it exists and is accessible.\n%s"),
directory ? _("directory") : _("file"), path,
wstrerror(error));
break;
}
}
Bool checkDir(char *path, Bool fatal)
Bool
checkDir(char *path, Bool fatal)
{
if (access(path, F_OK) < 0) {
if (mkdir(path, 0775) < 0) {
alert(_("could not create directory %s\n%s"), path,
wstrerror(errno));
return False;
} else {
wlog(_("created directory %s"), path);
}
if (mkdir(path, 0775) < 0) {
alert(_("could not create directory %s\n%s"), path,
wstrerror(errno));
return False;
} else {
wlog(_("created directory %s"), path);
}
}
if (access(path, R_OK|W_OK|X_OK) == 0) {
return True;
return True;
}
wsyserror("bad access to directory %s", path);
if (!fatal) {
struct stat buf;
if (stat(path, &buf) < 0) {
alert(_("The directory %s could not be stat()ed. Please make sure\n"
"it exists and is accessible."), path);
return False;
}
if (!S_ISDIR(buf)) {
char *newName = renameName(path);
struct stat buf;
if (ask(_("Rename"), _("OK"), _("Cancel"),
_("A directory named %s needs to be created but a file with\n"
"the same name already exists. The file will be renamed to\n"
"%s and the directory will be created."),
path, newName)) {
if (rename(path, newName) < 0) {
alert(_("Could not rename %s to %s:%s"),
path, newName, wstrerror(errno));
}
}
wfree(newName);
return False;
}
if (!(buf.st_mode & S_IRWXU)) {
if (chmod(path, (buf.st_mode & 00077)|7) < 0) {
return False;
}
}
if (stat(path, &buf) < 0) {
alert(_("The directory %s could not be stat()ed. Please make sure\n"
"it exists and is accessible."), path);
return False;
}
return checkDir(path, True);
if (!S_ISDIR(buf)) {
char *newName = renameName(path);
if (ask(_("Rename"), _("OK"), _("Cancel"),
_("A directory named %s needs to be created but a file with\n"
"the same name already exists. The file will be renamed to\n"
"%s and the directory will be created."),
path, newName)) {
if (rename(path, newName) < 0) {
alert(_("Could not rename %s to %s:%s"),
path, newName, wstrerror(errno));
}
}
wfree(newName);
return False;
}
if (!(buf.st_mode & S_IRWXU)) {
if (chmod(path, (buf.st_mode & 00077)|7) < 0) {
return False;
}
}
return checkDir(path, True);
}
showFileError(errno, True, path);
return False;
}
Bool checkFile(char *path)
Bool
checkFile(char *path)
{
if (access(path, F_OK|R_OK|W_OK) == 0) {
return True;
}
return True;
}
showFileError(errno, False, path);
return False;
@@ -255,29 +259,30 @@ Bool checkFile(char *path)
Bool checkCurrentSetup(char *home)
Bool
checkCurrentSetup(char *home)
{
char path[1024];
char *p;
if (!checkDir(home, False)) {
wlog("couldnt make directory %s", home);
return False;
wlog("couldnt make directory %s", home);
return False;
}
for (p = RequiredDirectories; p != NULL; p++) {
sprintf(path, "%s%s", home, p);
if (!checkDir(p, False)) {
wlog("couldnt make directory %s", p);
return False;
}
sprintf(path, "%s%s", home, p);
if (!checkDir(p, False)) {
wlog("couldnt make directory %s", p);
return False;
}
}
for (p = RequiredFiles; p != NULL; p++) {
sprintf(path, "%s%s", home, p);
if (!checkFile(p, False)) {
return False;
}
sprintf(path, "%s%s", home, p);
if (!checkFile(p, False)) {
return False;
}
}
return True;
@@ -285,7 +290,8 @@ Bool checkCurrentSetup(char *home)
Bool copyAllFiles(char *gsdir)
Bool
copyAllFiles(char *gsdir)
{
FILE *f;
char path[2048];
@@ -295,80 +301,82 @@ Bool copyAllFiles(char *gsdir)
/* copy misc data files */
sprintf(path, "%s/USER_FILES", DATADIR);
f = fopen(path, "rb");
while (!feof(f)) {
if (!fgets(file, 255, f)) {
break;
}
sprintf(path, "%s/%s", DATADIR, file);
sprintf(target, "%s/Library/WindowMaker/%s", gsdir, file);
if (!copyFile(path, target)) {
return False;
}
if (!fgets(file, 255, f)) {
break;
}
sprintf(path, "%s/%s", DATADIR, file);
sprintf(target, "%s/Library/WindowMaker/%s", gsdir, file);
if (!copyFile(path, target)) {
return False;
}
}
fclose(f);
/* copy auto{start,finish} scripts */
/* select and copy menu */
/* copy Defaults stuff */
sprintf(path, "%s/USER_FILES", ETCDIR);
f = fopen(path, "rb");
while (!feof(f)) {
if (!fgets(path, 255, f)) {
break;
}
sprintf(path, "%s/%s", ETCDIR, file);
sprintf(target, "%s/Defaults/%s", gsdir, file);
if (!copyFile(path, target)) {
return False;
}
if (!fgets(path, 255, f)) {
break;
}
sprintf(path, "%s/%s", ETCDIR, file);
sprintf(target, "%s/Defaults/%s", gsdir, file);
if (!copyFile(path, target)) {
return False;
}
}
fclose(f);
/* setup .xinitrc */
}
void showFinishSplash(char *gsdir)
void
showFinishSplash(char *gsdir)
{
#if 0
WMWindow *win;
win = WMCreateWindow(scr, "finished");
#endif
}
int main(int argc, char **argv)
int
main(int argc, char **argv)
{
Display *dpy;
char *gsdir;
int i;
for (i=1; i<argc; i++) {
if (strcmp(argv[i], "-display")==0) {
i++;
if (i>=argc) {
wwarning(_("too few arguments for %s"), argv[i-1]);
exit(0);
}
DisplayName = argv[i];
} else if (strcmp(argv[i], "-version")==0
|| strcmp(argv[i], "--version")==0) {
puts(PROG_VERSION);
exit(0);
}
if (strcmp(argv[i], "-display")==0) {
i++;
if (i>=argc) {
wwarning(_("too few arguments for %s"), argv[i-1]);
exit(0);
}
DisplayName = argv[i];
} else if (strcmp(argv[i], "-version")==0
|| strcmp(argv[i], "--version")==0) {
puts(PROG_VERSION);
exit(0);
}
}
WMInitializeApplication("WMSetup", &argc, argv);
dpy = XOpenDisplay("");
@@ -376,36 +384,36 @@ int main(int argc, char **argv)
printf("could not open display\n");
exit(1);
}
scr = WMCreateScreen(dpy, DefaultScreen(dpy));
gsdir = wusergnusteppath();
/* check directory structure and copy files */
if (access(gsdir, F_OK) != 0) {
if (!ask(_("Window Maker"), _("OK"), _("Cancel"),
_("Window Maker will create a directory named %s, where\n"
"it will store it's configuration files and other data."),
gsdir)) {
alert(_("Window Maker will be started in 'static' mode, where\n"
"it will use default configuration and will not write\n"
"any information to disk."));
return 1;
}
if (!ask(_("Window Maker"), _("OK"), _("Cancel"),
_("Window Maker will create a directory named %s, where\n"
"it will store it's configuration files and other data."),
gsdir)) {
alert(_("Window Maker will be started in 'static' mode, where\n"
"it will use default configuration and will not write\n"
"any information to disk."));
return 1;
}
}
if (checkCurrentSetup(gsdir)) {
printf(_("%s: wmaker configuration files already installed\n"),
argv[0]);
return 0;
printf(_("%s: wmaker configuration files already installed\n"),
argv[0]);
return 0;
}
if (!copyAllFiles(gsdir)) {
alert(_("An error occurred while doing user specific setup of\n"
"Window Maker. It will be started in 'static' mode, where\n"
"the default configuration will be used and it will not write\n"
"any information to disk."));
return 1;
alert(_("An error occurred while doing user specific setup of\n"
"Window Maker. It will be started in 'static' mode, where\n"
"the default configuration will be used and it will not write\n"
"any information to disk."));
return 1;
}
showFinishSplash(gsdir);
@@ -413,3 +421,4 @@ int main(int argc, char **argv)
return 0;
}
#endif

View File

@@ -70,71 +70,71 @@ main(int argc, char **argv)
int clear_selection = 0;
for (i=1; i<argc; i++) {
if (argv[i][0]=='-') {
if (strcmp(argv[i], "--help")==0) {
help(argv[0]);
exit(0);
} else if (strcmp(argv[i], "--version")==0) {
puts(PROG_VERSION);
exit(0);
} else if (strcmp(argv[i],"-cutbuffer")==0
|| strcmp(argv[i],"--cutbuffer")==0) {
if (i<argc-1) {
i++;
if (sscanf(argv[i],"%i", &buffer)!=1) {
fprintf(stderr, "%s: could not convert '%s' to int\n",
argv[0], argv[i]);
exit(1);
}
if (buffer<0 || buffer > 7) {
fprintf(stderr, "%s: invalid buffer number %i\n",
argv[0], buffer);
exit(1);
}
} else {
printf("%s: missing argument for '%s'\n", argv[0], argv[i]);
printf("Try '%s --help' for more information\n", argv[0]);
exit(1);
}
} else if (strcmp(argv[i], "-display")==0) {
if (i < argc-1) {
display_name = argv[++i];
} else {
printf("%s: missing argument for '%s'\n", argv[0], argv[i]);
printf("Try '%s --help' for more information\n", argv[0]);
exit(1);
}
} else if (strcmp(argv[i],"-clearselection")==0
|| strcmp(argv[i],"--clear-selection")==0) {
clear_selection = 1;
} else if (strcmp(argv[i],"-nolimit")==0
|| strcmp(argv[i],"--no-limit")==0) {
limit_check = 0;
} else {
printf("%s: invalid argument '%s'\n", argv[0], argv[i]);
printf("Try '%s --help' for more information\n", argv[0]);
exit(1);
}
} else {
filename = argv[i];
}
if (argv[i][0]=='-') {
if (strcmp(argv[i], "--help")==0) {
help(argv[0]);
exit(0);
} else if (strcmp(argv[i], "--version")==0) {
puts(PROG_VERSION);
exit(0);
} else if (strcmp(argv[i],"-cutbuffer")==0
|| strcmp(argv[i],"--cutbuffer")==0) {
if (i<argc-1) {
i++;
if (sscanf(argv[i],"%i", &buffer)!=1) {
fprintf(stderr, "%s: could not convert '%s' to int\n",
argv[0], argv[i]);
exit(1);
}
if (buffer<0 || buffer > 7) {
fprintf(stderr, "%s: invalid buffer number %i\n",
argv[0], buffer);
exit(1);
}
} else {
printf("%s: missing argument for '%s'\n", argv[0], argv[i]);
printf("Try '%s --help' for more information\n", argv[0]);
exit(1);
}
} else if (strcmp(argv[i], "-display")==0) {
if (i < argc-1) {
display_name = argv[++i];
} else {
printf("%s: missing argument for '%s'\n", argv[0], argv[i]);
printf("Try '%s --help' for more information\n", argv[0]);
exit(1);
}
} else if (strcmp(argv[i],"-clearselection")==0
|| strcmp(argv[i],"--clear-selection")==0) {
clear_selection = 1;
} else if (strcmp(argv[i],"-nolimit")==0
|| strcmp(argv[i],"--no-limit")==0) {
limit_check = 0;
} else {
printf("%s: invalid argument '%s'\n", argv[0], argv[i]);
printf("Try '%s --help' for more information\n", argv[0]);
exit(1);
}
} else {
filename = argv[i];
}
}
if (filename) {
file = fopen(filename, "rb");
if (!file) {
char line[1024];
sprintf(line, "%s: could not open \"%s\"", argv[0], filename);
perror(line);
exit(1);
}
file = fopen(filename, "rb");
if (!file) {
char line[1024];
sprintf(line, "%s: could not open \"%s\"", argv[0], filename);
perror(line);
exit(1);
}
}
dpy = XOpenDisplay(display_name);
XSetErrorHandler(errorHandler);
if (!dpy) {
fprintf(stderr, "%s: could not open display \"%s\"\n", argv[0],
XDisplayName(display_name));
exit(1);
fprintf(stderr, "%s: could not open display \"%s\"\n", argv[0],
XDisplayName(display_name));
exit(1);
}
if (buffer<0) {
@@ -175,25 +175,25 @@ main(int argc, char **argv)
}
}
XRotateBuffers(dpy, 1);
buffer=0;
XRotateBuffers(dpy, 1);
buffer=0;
}
while (!feof(file)) {
char *nbuf;
char tmp[LINESIZE+2];
int nl=0;
char *nbuf;
char tmp[LINESIZE+2];
int nl=0;
/*
* Use read() instead of fgets() to preserve NULLs, since
* especially since there's no reason to read one line at a time.
*/
if ((nl = fread(tmp, 1, LINESIZE, file)) <= 0) {
break;
}
if (buf_len == 0) {
nbuf = malloc(buf_len = l+nl+1);
} else if (buf_len < l+nl+1) {
/*
* Use read() instead of fgets() to preserve NULLs, since
* especially since there's no reason to read one line at a time.
*/
if ((nl = fread(tmp, 1, LINESIZE, file)) <= 0) {
break;
}
if (buf_len == 0) {
nbuf = malloc(buf_len = l+nl+1);
} else if (buf_len < l+nl+1) {
/*
* To avoid terrible performance on big input buffers,
* grow by doubling, not by the minimum needed for the
@@ -209,34 +209,34 @@ main(int argc, char **argv)
} else {
nbuf = buf;
}
if (!nbuf) {
fprintf(stderr, "%s: out of memory\n", argv[0]);
exit(1);
}
buf=nbuf;
/*
* Don't strcat, since it would make the algorithm n-squared.
* Don't use strcpy, since it stops on a NUL.
*/
memcpy(buf+l, tmp, nl);
l+=nl;
if (limit_check && l>=MAXDATA) {
fprintf
(
stderr,
"%s: too much data in input - more than %d bytes\n"
" use the -nolimit argument to remove the limit check.\n",
argv[0], MAXDATA
);
exit(1);
}
if (!nbuf) {
fprintf(stderr, "%s: out of memory\n", argv[0]);
exit(1);
}
buf=nbuf;
/*
* Don't strcat, since it would make the algorithm n-squared.
* Don't use strcpy, since it stops on a NUL.
*/
memcpy(buf+l, tmp, nl);
l+=nl;
if (limit_check && l>=MAXDATA) {
fprintf
(
stderr,
"%s: too much data in input - more than %d bytes\n"
" use the -nolimit argument to remove the limit check.\n",
argv[0], MAXDATA
);
exit(1);
}
}
if (clear_selection) {
XSetSelectionOwner(dpy, XA_PRIMARY, None, CurrentTime);
XSetSelectionOwner(dpy, XA_PRIMARY, None, CurrentTime);
}
if (buf) {
XStoreBuffer(dpy, buf, l, buffer);
XStoreBuffer(dpy, buf, l, buffer);
}
XFlush(dpy);
XCloseDisplay(dpy);

View File

@@ -1,7 +1,7 @@
/* wxpaste.c- paste contents of cutbuffer to stdout
*
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -47,7 +47,7 @@ help(char *progn)
puts(" -display display display to use");
puts(" --cutbuffer number cutbuffer number to get data from");
puts(" --selection [selection] reads data from named selection instead of\n"
" cutbuffer");
" cutbuffer");
puts(" --help display this help and exit");
puts(" --version output version information and exit");
}
@@ -59,15 +59,15 @@ getTimestamp(Display *dpy, Window win)
XEvent ev;
/* So we do this trickery to get a time stamp:
*
*
* 1. Grab the server because we are paranoid and don't want to
* get in a race with another instance of wxpaste being ran at the
* same time.
*
*
* 2. Set a dummy property in our window.
*
*
* 3. Get the PropertyNotify event and get it's timestamp.
*
*
* 4. Ungrab the server.
*/
@@ -78,9 +78,9 @@ getTimestamp(Display *dpy, Window win)
/* wait for the event */
while (1) {
XNextEvent(dpy, &ev);
if (ev.type == PropertyNotify)
break;
XNextEvent(dpy, &ev);
if (ev.type == PropertyNotify)
break;
}
return ev.xproperty.time;
@@ -100,8 +100,8 @@ fetchSelection(Display *dpy, char *selection, char *progName)
fd_set fdset;
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1, 1,
0, 0, 0);
/*
0, 0, 0);
/*
* The ICCCM says that we can't pass CurrentTime as the timestamp
* for XConvertSelection(), but we don't have anything to use as
* a timestamp...
@@ -115,43 +115,43 @@ fetchSelection(Display *dpy, char *selection, char *progName)
/* wait for the convertion */
while (0) {
int res;
int res;
if (XPending(dpy)==0) {
FD_ZERO(&fdset);
FD_SET(ConnectionNumber(dpy), &fdset);
res = select(ConnectionNumber(dpy)+1, &fdset, NULL, NULL,
&timeout);
if (res <= 0) {
ok = 0;
break;
}
}
if (res > 0 || XPending(dpy) > 0) {
XNextEvent(dpy, &ev);
if (ev.type == SelectionNotify && ev.xany.window == win) {
ok = 1;
break;
}
}
if (XPending(dpy)==0) {
FD_ZERO(&fdset);
FD_SET(ConnectionNumber(dpy), &fdset);
res = select(ConnectionNumber(dpy)+1, &fdset, NULL, NULL,
&timeout);
if (res <= 0) {
ok = 0;
break;
}
}
if (res > 0 || XPending(dpy) > 0) {
XNextEvent(dpy, &ev);
if (ev.type == SelectionNotify && ev.xany.window == win) {
ok = 1;
break;
}
}
}
/* if success, return the data */
if (ok) {
Atom rtype;
int bits;
unsigned long len, bytes;
unsigned char *data;
Atom rtype;
int bits;
unsigned long len, bytes;
unsigned char *data;
if (XGetWindowProperty(dpy, win, clipatom, 0, MAXDATA/4, False,
XA_STRING, &rtype, &bits, &len, &bytes, &data)!=0)
return NULL;
if (XGetWindowProperty(dpy, win, clipatom, 0, MAXDATA/4, False,
XA_STRING, &rtype, &bits, &len, &bytes, &data)!=0)
return NULL;
if ((rtype!=XA_STRING) || (bits!=8)) {
return NULL;
} else {
return (char*)data;
}
if ((rtype!=XA_STRING) || (bits!=8)) {
return NULL;
} else {
return (char*)data;
}
}
return NULL;
}
@@ -169,80 +169,80 @@ main(int argc, char **argv)
char *selection_name=NULL;
for (i=1; i<argc; i++) {
if (argv[i][0]=='-') {
if (argv[i][1]=='h' || strcmp(argv[i], "--help")==0) {
help(argv[0]);
exit(0);
} else if (strcmp(argv[i], "--version")==0) {
puts(PROG_VERSION);
exit(0);
} else if (strcmp(argv[i],"-selection")==0
|| strcmp(argv[i],"--selection")==0) {
if (i<argc-1) {
selection_name = argv[++i];
} else {
selection_name = "PRIMARY";
}
} else if (strcmp(argv[i],"-display")==0) {
if (i<argc-1) {
display_name = argv[++i];
} else {
help(argv[0]);
exit(0);
}
} else if (strcmp(argv[i],"-cutbuffer")==0
|| strcmp(argv[i],"--cutbuffer")==0) {
if (i<argc-1) {
i++;
if (sscanf(argv[i],"%i", &buffer)!=1) {
fprintf(stderr, "%s: could not convert \"%s\" to int\n",
argv[0], argv[i]);
exit(1);
}
if (buffer<0 || buffer > 7) {
fprintf(stderr, "%s: invalid buffer number %i\n",
argv[0], buffer);
exit(1);
}
} else {
fprintf(stderr, "%s: invalid argument '%s'\n", argv[0],
argv[i]);
fprintf(stderr, "Try '%s --help' for more information.\n",
argv[0]);
exit(1);
}
}
} else {
fprintf(stderr, "%s: invalid argument '%s'\n", argv[0], argv[i]);
fprintf(stderr, "Try '%s --help' for more information.\n",
argv[0]);
exit(1);
}
if (argv[i][0]=='-') {
if (argv[i][1]=='h' || strcmp(argv[i], "--help")==0) {
help(argv[0]);
exit(0);
} else if (strcmp(argv[i], "--version")==0) {
puts(PROG_VERSION);
exit(0);
} else if (strcmp(argv[i],"-selection")==0
|| strcmp(argv[i],"--selection")==0) {
if (i<argc-1) {
selection_name = argv[++i];
} else {
selection_name = "PRIMARY";
}
} else if (strcmp(argv[i],"-display")==0) {
if (i<argc-1) {
display_name = argv[++i];
} else {
help(argv[0]);
exit(0);
}
} else if (strcmp(argv[i],"-cutbuffer")==0
|| strcmp(argv[i],"--cutbuffer")==0) {
if (i<argc-1) {
i++;
if (sscanf(argv[i],"%i", &buffer)!=1) {
fprintf(stderr, "%s: could not convert \"%s\" to int\n",
argv[0], argv[i]);
exit(1);
}
if (buffer<0 || buffer > 7) {
fprintf(stderr, "%s: invalid buffer number %i\n",
argv[0], buffer);
exit(1);
}
} else {
fprintf(stderr, "%s: invalid argument '%s'\n", argv[0],
argv[i]);
fprintf(stderr, "Try '%s --help' for more information.\n",
argv[0]);
exit(1);
}
}
} else {
fprintf(stderr, "%s: invalid argument '%s'\n", argv[0], argv[i]);
fprintf(stderr, "Try '%s --help' for more information.\n",
argv[0]);
exit(1);
}
}
dpy = XOpenDisplay(display_name);
if (!dpy) {
fprintf(stderr, "%s: could not open display \"%s\"\n", argv[0],
XDisplayName(display_name));
exit(1);
fprintf(stderr, "%s: could not open display \"%s\"\n", argv[0],
XDisplayName(display_name));
exit(1);
}
if (selection_name) {
buf = fetchSelection(dpy, selection_name, argv[0]);
buf = fetchSelection(dpy, selection_name, argv[0]);
} else {
buf = NULL;
buf = NULL;
}
if (buf == NULL) {
buf = XFetchBuffer(dpy, &l, buffer);
buf = XFetchBuffer(dpy, &l, buffer);
}
if (buf == NULL) {
status = 1;
status = 1;
} else {
if (write(STDOUT_FILENO, buf, l) == -1)
status = errno;
else
status = 0;
if (write(STDOUT_FILENO, buf, l) == -1)
status = errno;
else
status = 0;
}
XCloseDisplay(dpy);
exit(status);