wmbutton: wmbutton.c code clean

This patch is a code clean patch:

- Removes spaces and tabs at end of line.
- Remove curly brackets not needed.
- Change spaces by tabs.
- Add spaces after and before operators.
- Removes spaces not needed.
- Better code style.
This commit is contained in:
Rodolfo García Peñas (kix) 2012-08-21 20:33:40 +02:00 committed by Carlos R. Mafra
parent e07b2facf2
commit 77a89054f5

View file

@ -73,8 +73,8 @@ typedef struct _XpmIcon {
} XpmIcon; } XpmIcon;
typedef struct _button_region { typedef struct _button_region {
int x,y; int x, y;
int i,j; int i, j;
} ButtonArea; } ButtonArea;
ButtonArea button_region[9]; ButtonArea button_region[9];
@ -89,13 +89,12 @@ char *app_name = "wmbutton";
/*********************************************************************** /***********************************************************************
* Main * Main
***********************************************************************/ ***********************************************************************/
int main( int argc, char ** argv ) { int main(int argc, char **argv)
{
XEvent report; XEvent report;
XGCValues xgcValues; XGCValues xgcValues;
XTextProperty app_name_atom; XTextProperty app_name_atom;
XSizeHints xsizehints; XSizeHints xsizehints;
Pixmap pixmask; Pixmap pixmask;
int dummy = 0; int dummy = 0;
@ -113,15 +112,15 @@ int main( int argc, char ** argv ) {
parseargs(argc, argv); parseargs(argc, argv);
/* Open Display */ /* Open Display */
if ( (display = XOpenDisplay(Config.Display_str)) == NULL ) if ((display = XOpenDisplay(Config.Display_str)) == NULL)
err_mess(FAILDISP, Config.Display_str); err_mess(FAILDISP, Config.Display_str);
screen = DefaultScreen(display); screen = DefaultScreen(display);
rootwin = RootWindow(display,screen); rootwin = RootWindow(display, screen);
depth = DefaultDepth(display, screen); depth = DefaultDepth(display, screen);
bg_pixel = WhitePixel(display, screen ); bg_pixel = WhitePixel(display, screen);
fg_pixel = BlackPixel(display, screen ); fg_pixel = BlackPixel(display, screen);
xsizehints.flags = USSize | USPosition; xsizehints.flags = USSize | USPosition;
xsizehints.width = 64; xsizehints.width = 64;
@ -139,39 +138,37 @@ int main( int argc, char ** argv ) {
&xsizehints.height, &xsizehints.height,
&dummy); &dummy);
if ( (win = XCreateSimpleWindow(display, if ((win = XCreateSimpleWindow(display,
rootwin, rootwin,
xsizehints.x, xsizehints.x,
xsizehints.y, xsizehints.y,
xsizehints.width, xsizehints.width,
xsizehints.height, xsizehints.height,
border, border,
fg_pixel, bg_pixel) ) == 0 ) fg_pixel, bg_pixel)) == 0)
err_mess(FAILSWIN, NULL); err_mess(FAILSWIN, NULL);
if ((iconwin = XCreateSimpleWindow(display,
if ( (iconwin = XCreateSimpleWindow(display,
win, win,
xsizehints.x, xsizehints.x,
xsizehints.y, xsizehints.y,
xsizehints.width, xsizehints.width,
xsizehints.height, xsizehints.height,
border, border,
fg_pixel, bg_pixel) ) == 0 ) fg_pixel, bg_pixel)) == 0)
err_mess(FAILICON, NULL); err_mess(FAILICON, NULL);
/* Set up shaped windows */ /* Set up shaped windows */
/*Gives the appicon a border so you can grab and move it. */ /* Gives the appicon a border so you can grab and move it. */
if ((pixmask = XCreateBitmapFromData(display,
if ( ( pixmask = XCreateBitmapFromData(display,
win, win,
mask_bits, mask_bits,
mask_width, mask_width,
mask_height) ) == 0 ) mask_height)) == 0)
err_mess(FAILXPM,NULL); err_mess(FAILXPM, NULL);
XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet );
XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet); XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
/* Convert in pixmaps from .xpm includes. */ /* Convert in pixmaps from .xpm includes. */
@ -182,19 +179,19 @@ int main( int argc, char ** argv ) {
SetWmHints(); SetWmHints();
SetClassHints(); SetClassHints();
XSetWMNormalHints(display, win, &xsizehints);
XSetWMNormalHints( display, win, &xsizehints );
/* Tell window manager what the title bar name is. We never see */ /* Tell window manager what the title bar name is. We never see */
/* this anyways in the WithdrawnState */ /* this anyways in the WithdrawnState */
if ( XStringListToTextProperty(&app_name, 1, &app_name_atom) == 0 ) if (XStringListToTextProperty(&app_name, 1, &app_name_atom) == 0)
err_mess(FAILWNAM,app_name); err_mess(FAILWNAM, app_name);
XSetWMName( display, win, &app_name_atom );
XSetWMName(display, win, &app_name_atom);
/* Create Graphic Context */ /* Create Graphic Context */
if (( gc = XCreateGC(display, win,(GCForeground | GCBackground), &xgcValues)) if ((gc = XCreateGC(display, win, (GCForeground | GCBackground),
== NULL ) &xgcValues)) == NULL)
err_mess(FAILGC,NULL); err_mess(FAILGC, NULL);
/* XEvent Masks. We want both window to process X events */ /* XEvent Masks. We want both window to process X events */
XSelectInput(display, win, XSelectInput(display, win,
@ -203,21 +200,22 @@ int main( int argc, char ** argv ) {
ButtonReleaseMask | /* added ButtonReleaseMask *charkins*/ ButtonReleaseMask | /* added ButtonReleaseMask *charkins*/
PointerMotionMask | PointerMotionMask |
StructureNotifyMask | StructureNotifyMask |
LeaveWindowMask ); LeaveWindowMask);
XSelectInput(display, iconwin, XSelectInput(display, iconwin,
ExposureMask | ExposureMask |
ButtonPressMask | ButtonPressMask |
ButtonReleaseMask | /* added ButtonReleaseMask *charkins*/ ButtonReleaseMask | /* added ButtonReleaseMask *charkins*/
PointerMotionMask | PointerMotionMask |
StructureNotifyMask | StructureNotifyMask |
LeaveWindowMask ); LeaveWindowMask);
/* Store the 'state' of the application for restarting */ /* Store the 'state' of the application for restarting */
XSetCommand( display, win, argv, argc ); XSetCommand(display, win, argv, argc);
/* Window won't ever show up until it is mapped.. then drawn after a */ /* Window won't ever show up until it is mapped.. then drawn after a */
/* ConfigureNotify */ /* ConfigureNotify */
XMapWindow( display, win ); XMapWindow(display, win);
/* Initialize Tooltip Support */ /* Initialize Tooltip Support */
initTime(); initTime();
@ -226,33 +224,38 @@ int main( int argc, char ** argv ) {
/* X Event Loop */ /* X Event Loop */
while (1) { while (1) {
while (XPending(display) || nTooltipTimer == -1) { while (XPending(display) || nTooltipTimer == -1) {
XNextEvent(display, &report ); XNextEvent(display, &report);
switch (report.type) { switch (report.type) {
case Expose: case Expose:
if (report.xexpose.count != 0) { if (report.xexpose.count != 0)
break; break;
}
if ( Config.Verbose ) fprintf(stdout,"Event: Expose\n"); if (Config.Verbose)
fprintf(stdout, "Event: Expose\n");
redraw(); redraw();
break; break;
case ConfigureNotify: case ConfigureNotify:
if ( Config.Verbose ) fprintf(stdout,"Event: ConfigureNotify\n"); if (Config.Verbose)
fprintf(stdout, "Event: ConfigureNotify\n");
redraw(); redraw();
break; break;
case MotionNotify: case MotionNotify:
if (hasTooltipSupport()) { if (hasTooltipSupport()) {
if (!hasTooltip()) { if (!hasTooltip()) {
nTooltipTimer= currentTimeMillis(); nTooltipTimer = currentTimeMillis();
nTooltipX= report.xbutton.x; nTooltipX = report.xbutton.x;
nTooltipY= report.xbutton.y; nTooltipY = report.xbutton.y;
nTooltipButton= whichButton(report.xbutton.x, report.xbutton.y); nTooltipButton = whichButton(report.xbutton.x, report.xbutton.y);
} else { } else {
int nButton = whichButton(report.xbutton.x, report.xbutton.y); int nButton = whichButton(report.xbutton.x, report.xbutton.y);
if (nButton != nTooltipButton) { if (nButton != nTooltipButton) {
hideTooltip(); hideTooltip();
nTooltipTimer= -1; nTooltipTimer = -1;
nTooltipX = report.xbutton.x; nTooltipX = report.xbutton.x;
nTooltipY = report.xbutton.y; nTooltipY = report.xbutton.y;
nTooltipButton = nButton; nTooltipButton = nButton;
@ -263,109 +266,116 @@ int main( int argc, char ** argv ) {
break; break;
case LeaveNotify: case LeaveNotify:
if ( Config.Verbose ) fprintf(stdout,"Event: LeaveNotify\n"); if (Config.Verbose)
fprintf(stdout, "Event: LeaveNotify\n");
if (hasTooltip()) { if (hasTooltip()) {
hideTooltip(); hideTooltip();
nTooltipHideTimer= currentTimeMillis(); nTooltipHideTimer = currentTimeMillis();
} }
nTooltipTimer= -1; nTooltipTimer = -1;
break; break;
case ButtonPress: /* draw button pressed, don't launch *charkins*/ case ButtonPress: /* draw button pressed, don't launch *charkins*/
if (hasTooltip()) { if (hasTooltip()) {
hideTooltip(); hideTooltip();
nTooltipHideTimer= currentTimeMillis(); nTooltipHideTimer = currentTimeMillis();
} switch (report.xbutton.button) { }
switch (report.xbutton.button) {
case Button1: case Button1:
N = whichButton(report.xbutton.x, report.xbutton.y ); N = whichButton(report.xbutton.x, report.xbutton.y);
if ( (N >= 0) && (N <= NUMB_OF_APPS) ) { if ((N >= 0) && (N <= NUMB_OF_APPS)) {
button_pressed = N + LMASK; button_pressed = N + LMASK;
redraw(); redraw();
} }
if ( Config.Verbose ) if (Config.Verbose)
fprintf(stdout,"Button 1:x=%d y=%d N=%d\n", fprintf(stdout, "Button 1:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+LMASK); report.xbutton.x, report.xbutton.y, N+LMASK);
break; break;
case Button2: case Button2:
if (Config.mmouse) { if (Config.mmouse) {
N = whichButton(report.xbutton.x, report.xbutton.y ); N = whichButton(report.xbutton.x, report.xbutton.y);
if ( (N >= 0) && (N <= NUMB_OF_APPS) ) { if ((N >= 0) && (N <= NUMB_OF_APPS)) {
button_pressed = N + MMASK; button_pressed = N + MMASK;
redraw(); redraw();
} }
if ( Config.Verbose ) if (Config.Verbose)
fprintf(stdout,"Button 2:x=%d y=%d N=%d\n", fprintf(stdout, "Button 2:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+MMASK); report.xbutton.x, report.xbutton.y, N+MMASK);
} }
break; break;
case Button3: case Button3:
N = whichButton(report.xbutton.x, report.xbutton.y ); N = whichButton(report.xbutton.x, report.xbutton.y);
if ( (N >= 0) && (N <= NUMB_OF_APPS) ) { if ((N >= 0) && (N <= NUMB_OF_APPS)) {
button_pressed = N + RMASK; button_pressed = N + RMASK;
redraw(); redraw();
} }
if ( Config.Verbose ) if (Config.Verbose)
fprintf(stdout,"Button 3:x=%d y=%d N=%d\n", fprintf(stdout, "Button 3:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+RMASK); report.xbutton.x, report.xbutton.y, N+RMASK);
break; break;
} }
break; break;
case ButtonRelease: /* launch app here if still over button *charkins*/ case ButtonRelease: /* launch app here if still over button *charkins*/
switch (report.xbutton.button) { switch (report.xbutton.button) {
case Button1: case Button1:
N = whichButton(report.xbutton.x, report.xbutton.y ); N = whichButton(report.xbutton.x, report.xbutton.y);
if ( (N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed)) if ((N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed))
RunAppN( N + LMASK); RunAppN(N + LMASK);
button_pressed=-1;
button_pressed = -1;
redraw(); redraw();
if ( Config.Verbose ) if (Config.Verbose)
fprintf(stdout,"Button 1:x=%d y=%d N=%d\n", fprintf(stdout, "Button 1:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+LMASK); report.xbutton.x, report.xbutton.y, N+LMASK);
break; break;
case Button2: case Button2:
if (Config.mmouse) { if (Config.mmouse) {
N = whichButton(report.xbutton.x, report.xbutton.y ); N = whichButton(report.xbutton.x, report.xbutton.y);
if ( (N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed)) if ((N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed))
RunAppN( N + MMASK); RunAppN(N + MMASK);
button_pressed=-1;
button_pressed = -1;
redraw(); redraw();
if ( Config.Verbose ) if (Config.Verbose)
fprintf(stdout,"Button 2:x=%d y=%d N=%d\n", fprintf(stdout, "Button 2:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+MMASK); report.xbutton.x, report.xbutton.y, N+MMASK);
} }
break; break;
case Button3: case Button3:
N = whichButton(report.xbutton.x, report.xbutton.y ); N = whichButton(report.xbutton.x, report.xbutton.y);
if ( (N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed)) if ((N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed))
RunAppN( N + RMASK); RunAppN(N + RMASK);
button_pressed=-1;
button_pressed = -1;
redraw(); redraw();
if ( Config.Verbose ) if (Config.Verbose)
fprintf(stdout,"Button 3:x=%d y=%d N=%d\n", fprintf(stdout, "Button 3:x=%d y=%d N=%d\n",
report.xbutton.x, report.xbutton.y, N+RMASK); report.xbutton.x, report.xbutton.y, N+RMASK);
break; break;
} }
break; break;
case DestroyNotify:
if ( Config.Verbose ) fprintf(stdout, "Bye\n"); case DestroyNotify:
if (Config.Verbose)
fprintf(stdout, "Bye\n");
destroyTooltip(); destroyTooltip();
XFreeGC(display, gc); XFreeGC(display, gc);
XDestroyWindow(display,win); XDestroyWindow(display, win);
XDestroyWindow(display,iconwin); XDestroyWindow(display, iconwin);
XCloseDisplay(display); XCloseDisplay(display);
exit(0); exit(0);
break; break;
@ -374,16 +384,17 @@ int main( int argc, char ** argv ) {
usleep(50000); usleep(50000);
nNow = currentTimeMillis(); nNow = currentTimeMillis();
if ( nTooltipTimer != -1 && if (nTooltipTimer != -1 &&
( (nNow > nTooltipTimer + nTooltipShowDelay) || (nNow < nTooltipHideTimer + nTooltipReshowDelay) ) ) { ((nNow > nTooltipTimer + nTooltipShowDelay) ||
(nNow < nTooltipHideTimer + nTooltipReshowDelay))) {
showTooltip(nTooltipButton, nTooltipX, nTooltipY); showTooltip(nTooltipButton, nTooltipX, nTooltipY);
nTooltipTimer = -1; nTooltipTimer = -1;
} }
} }
return (0); return (0);
}/***********************************************************************/ }
/***********************************************************************/
/*********************************************************************** /***********************************************************************
* redraw * redraw
@ -397,24 +408,21 @@ int main( int argc, char ** argv ) {
* main window and the icon window which is the main window's icon image.) * main window and the icon window which is the main window's icon image.)
***********************************************************************/ ***********************************************************************/
void redraw() { void redraw() {
int n; int n, i, j, dest_x, dest_y, space, offset, bsize = 18;
int i,j;
int dest_x, dest_y; if (Config.Verbose)
int space; fprintf(stdout, "In Redraw()\n");
int offset;
int bsize = 18;
if ( Config.Verbose ) fprintf(stdout,"In Redraw()\n");
space = 0; space = 0;
offset = 5; offset = 5;
XCopyArea(display, template.pixmap, visible.pixmap, gc, 0, 0, XCopyArea(display, template.pixmap, visible.pixmap, gc, 0, 0,
template.attributes.width, template.attributes.height, 0, 0 ); template.attributes.width, template.attributes.height, 0, 0);
for ( j=0; j < 3; j++ ) { for (j = 0; j < 3; j++) {
for ( i=0; i < 3; i++ ) { for (i = 0; i < 3; i++) {
n = i + j * 3; n = i + j * 3;
dest_x = i*(bsize + space) + offset + space; dest_x = i * (bsize + space) + offset + space;
dest_y = j*(bsize + space) + offset + space; dest_y = j * (bsize + space) + offset + space;
/* Define button mouse coords */ /* Define button mouse coords */
button_region[n].x = dest_x; button_region[n].x = dest_x;
@ -423,41 +431,46 @@ void redraw() {
button_region[n].j = dest_y + bsize - 1; button_region[n].j = dest_y + bsize - 1;
/* Copy button images for valid apps */ /* Copy button images for valid apps */
if ( (n + 1) <= NUMB_OF_APPS ) { if ((n + 1) <= NUMB_OF_APPS)
XCopyArea(display, buttons.pixmap, visible.pixmap, gc, XCopyArea(display, buttons.pixmap, visible.pixmap, gc,
i * bsize, j * bsize, bsize, bsize, dest_x, dest_y); i * bsize, j * bsize, bsize, bsize, dest_x, dest_y);
} }
} }
}
if ( button_pressed>0 ) { /* draw pressed button *charkins*/ if (button_pressed > 0) { /* draw pressed button *charkins*/
if(button_pressed>RMASK) button_pressed-=RMASK; if (button_pressed > RMASK)
else if(button_pressed>MMASK) button_pressed-=MMASK; button_pressed -= RMASK;
else if(button_pressed>LMASK) button_pressed-=LMASK; else if (button_pressed > MMASK)
i = (button_pressed-1) % 3; /* get col of button */ button_pressed -= MMASK;
j = (button_pressed-1) / 3; /* get row of button */ else if (button_pressed > LMASK)
button_pressed -= LMASK;
i = (button_pressed - 1) % 3; /* get col of button */
j = (button_pressed - 1) / 3; /* get row of button */
dest_x = i * (bsize + space) + offset + space; dest_x = i * (bsize + space) + offset + space;
dest_y = j * (bsize + space) + offset + space; dest_y = j * (bsize + space) + offset + space;
XSetForeground(display, gc, bg_pixel); XSetForeground(display, gc, bg_pixel);
XDrawLine(display, visible.pixmap, gc, XDrawLine(display, visible.pixmap, gc,
dest_x+1, dest_y+bsize-1, dest_x+bsize-1, dest_y+bsize-1); dest_x + 1, dest_y + bsize - 1,
dest_x + bsize - 1, dest_y + bsize - 1);
XDrawLine(display, visible.pixmap, gc, XDrawLine(display, visible.pixmap, gc,
dest_x+bsize-1, dest_y+bsize-1, dest_x+bsize-1, dest_y+1); dest_x + bsize - 1, dest_y + bsize - 1,
dest_x + bsize - 1, dest_y + 1);
XSetForeground(display, gc, fg_pixel); XSetForeground(display, gc, fg_pixel);
XDrawLine(display, visible.pixmap, gc, XDrawLine(display, visible.pixmap, gc,
dest_x, dest_y, dest_x+bsize-2, dest_y); dest_x, dest_y, dest_x + bsize - 2, dest_y);
XDrawLine(display, visible.pixmap, gc, XDrawLine(display, visible.pixmap, gc,
dest_x, dest_y, dest_x, dest_y+bsize-2); dest_x, dest_y, dest_x, dest_y + bsize - 2);
} /*charkins*/ } /*charkins*/
flush_expose( win ); flush_expose(win);
XCopyArea(display, visible.pixmap, win, gc, 0, 0, XCopyArea(display, visible.pixmap, win, gc, 0, 0,
visible.attributes.width, visible.attributes.height, 0, 0 ); visible.attributes.width, visible.attributes.height, 0, 0);
flush_expose( iconwin ); flush_expose(iconwin);
XCopyArea(display, visible.pixmap, iconwin, gc, 0, 0, XCopyArea(display, visible.pixmap, iconwin, gc, 0, 0,
visible.attributes.width, visible.attributes.height, 0, 0 ); visible.attributes.width, visible.attributes.height, 0, 0);
}
}/***********************************************************************/ /***********************************************************************/
/*********************************************************************** /***********************************************************************
* whichButton * whichButton
@ -465,19 +478,20 @@ void redraw() {
* Return the button that at the x,y coordinates. The button need not * Return the button that at the x,y coordinates. The button need not
* be visible ( drawn ). Return -1 if no button match. * be visible ( drawn ). Return -1 if no button match.
***********************************************************************/ ***********************************************************************/
int whichButton( int x, int y ) { int whichButton(int x, int y)
{
int index; int index;
for ( index=0; index < NUMB_OF_APPS; index++ ) { for (index = 0; index < NUMB_OF_APPS; index++) {
if ( x >= button_region[index].x && if (x >= button_region[index].x &&
x <= button_region[index].i && x <= button_region[index].i &&
y >= button_region[index].y && y >= button_region[index].y &&
y <= button_region[index].j ) { y <= button_region[index].j)
return( index + 1); return(index + 1);
} }
} return -1;
return(-1); }
}/***********************************************************************/ /***********************************************************************/
/*********************************************************************** /***********************************************************************
@ -491,50 +505,58 @@ int whichButton( int x, int y ) {
* Pixmap buttons holds the images for individual buttons that are * Pixmap buttons holds the images for individual buttons that are
* later copied onto Pixmap visible. * later copied onto Pixmap visible.
***********************************************************************/ ***********************************************************************/
void getPixmaps() { void getPixmaps()
{
int loaded = 0; int loaded = 0;
template.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions); template.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
visible.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions); visible.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
buttons.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions); buttons.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
if (Config.Verbose)
fprintf(stdout, "In getPixmaps\n");
if (Config.Verbose) fprintf(stdout, "In getPixmaps\n");
/* Template Pixmap. Never Drawn To. */ /* Template Pixmap. Never Drawn To. */
if ( XpmCreatePixmapFromData( display, rootwin, backdrop_xpm, if (XpmCreatePixmapFromData(display, rootwin, backdrop_xpm,
&template.pixmap, &template.mask, &template.pixmap, &template.mask,
&template.attributes) != XpmSuccess ) &template.attributes) != XpmSuccess)
err_mess(FAILTMPL, NULL); err_mess(FAILTMPL, NULL);
/* Visible Pixmap. Copied from template Pixmap and then drawn to. */ /* Visible Pixmap. Copied from template Pixmap and then drawn to. */
if ( XpmCreatePixmapFromData( display, rootwin, backdrop_xpm, if (XpmCreatePixmapFromData(display, rootwin, backdrop_xpm,
&visible.pixmap, &visible.mask, &visible.pixmap, &visible.mask,
&visible.attributes) != XpmSuccess ) &visible.attributes) != XpmSuccess)
err_mess(FAILVIS, NULL); err_mess(FAILVIS, NULL);
/* Button Pixmap. */ /* Button Pixmap. */
if ( access( Config.buttonfile, R_OK ) == 0 ) { if (access(Config.buttonfile, R_OK) == 0) {
/* load buttons from file */ /* load buttons from file */
if ( XpmReadFileToPixmap( display, rootwin, Config.buttonfile, if (XpmReadFileToPixmap(display, rootwin, Config.buttonfile,
&buttons.pixmap, &buttons.mask, &buttons.pixmap, &buttons.mask,
&buttons.attributes) != XpmSuccess ) { &buttons.attributes) != XpmSuccess)
err_mess(FAILBUT, NULL); err_mess(FAILBUT, NULL);
} else { else
loaded = 1; loaded = 1;
} }
}
if (! loaded) { if (!loaded) {
/* Use Builtin Button Pixmap. */ /* Use Builtin Button Pixmap. */
if (Config.Verbose) fprintf(stdout, "Using builtin buttons pixmap\n"); if (Config.Verbose)
if ( XpmCreatePixmapFromData( display, rootwin, buttons_xpm, fprintf(stdout, "Using builtin buttons pixmap\n");
if (XpmCreatePixmapFromData(display, rootwin, buttons_xpm,
&buttons.pixmap, &buttons.mask, &buttons.pixmap, &buttons.mask,
&buttons.attributes) != XpmSuccess ) &buttons.attributes) != XpmSuccess)
err_mess(FAILBUT, NULL); err_mess(FAILBUT, NULL);
} }
if (Config.Verbose) fprintf(stdout, "Leaving getPixmaps\n");
}/*********************************************************************/ if (Config.Verbose)
fprintf(stdout, "Leaving getPixmaps\n");
void SetWmHints() { }
/*********************************************************************/
void SetWmHints()
{
XWMHints *xwmhints; XWMHints *xwmhints;
xwmhints = XAllocWMHints(); xwmhints = XAllocWMHints();
@ -542,16 +564,16 @@ void SetWmHints() {
xwmhints->icon_window = iconwin; xwmhints->icon_window = iconwin;
xwmhints->window_group = win; xwmhints->window_group = win;
xwmhints->initial_state = WithdrawnState; xwmhints->initial_state = WithdrawnState;
XSetWMHints( display, win, xwmhints ); XSetWMHints(display, win, xwmhints);
XFree(xwmhints); XFree(xwmhints);
xwmhints = NULL; xwmhints = NULL;
} }
void SetClassHints() { void SetClassHints()
{
XClassHint xclasshint; XClassHint xclasshint;
xclasshint.res_name = "wmbutton"; xclasshint.res_name = "wmbutton";
xclasshint.res_class = "Wmbutton"; xclasshint.res_class = "Wmbutton";
XSetClassHint( display, win, &xclasshint ); XSetClassHint(display, win, &xclasshint);
} }