ALL: Remove XPM support
This commit is contained in:
parent
b39959f8ba
commit
ecda429cec
@ -1,17 +0,0 @@
|
||||
/* XPM */
|
||||
static char * free_xpm[] =
|
||||
{
|
||||
"10 10 2 1",
|
||||
" c None",
|
||||
"+ c #ffffff",
|
||||
"++++++++++",
|
||||
"+ +",
|
||||
"+ +++++ +",
|
||||
"+ + + +",
|
||||
"+ + ++ +",
|
||||
"+ ++++++ +",
|
||||
"+ + + +",
|
||||
"+ +++++ +",
|
||||
"+ +",
|
||||
"++++++++++"
|
||||
};
|
||||
@ -1,18 +0,0 @@
|
||||
/* XPM */
|
||||
static char * max_xpm[] =
|
||||
{
|
||||
"10 10 2 1",
|
||||
" c None",
|
||||
"+ c #ffffff",
|
||||
"++++++++++",
|
||||
"++++++++++",
|
||||
"+ +",
|
||||
"+ +",
|
||||
"+ +",
|
||||
"+ +",
|
||||
"+ +",
|
||||
"+ +",
|
||||
"++++++++++",
|
||||
"++++++++++"
|
||||
};
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
/* XPM */
|
||||
static char * tile_xpm[] =
|
||||
{
|
||||
"10 10 2 1",
|
||||
" c None",
|
||||
"+ c #ffffff",
|
||||
"++++++++++",
|
||||
"+ + +",
|
||||
"+ + +",
|
||||
"+ ++++++",
|
||||
"+ + +",
|
||||
"+ + +",
|
||||
"+ ++++++",
|
||||
"+ + +",
|
||||
"+ + +",
|
||||
"++++++++++"
|
||||
};
|
||||
37
src/bar.c
37
src/bar.c
@ -118,7 +118,7 @@ updatebar(void)
|
||||
draw_taglist(bar->dr);
|
||||
|
||||
/* Draw layout symbol */
|
||||
draw_layout(taglen[conf.ntag], bary + (!conf.bartop));
|
||||
draw_layout();
|
||||
|
||||
/* Draw status text */
|
||||
draw_text(bar->dr, mw - textw(bartext), fonth, conf.colors.text, conf.colors.bar, 0, bartext);
|
||||
@ -151,11 +151,10 @@ updatebutton(Bool c)
|
||||
int y = 0, hi = 0;
|
||||
|
||||
/* Calcul the position of the first button with the layout image size */
|
||||
j = taglen[conf.ntag] + get_image_attribute(tags[seltag].layout.image)->width + PAD / 2;
|
||||
j = taglen[conf.ntag] + textw(tags[seltag].layout.symbol) + PAD*1.5;
|
||||
|
||||
if(!conf.bartop)
|
||||
y = bary + 1;
|
||||
|
||||
y = bary + 2;
|
||||
if(conf.tagbordwidth)
|
||||
hi = -1;
|
||||
|
||||
@ -164,22 +163,18 @@ updatebutton(Bool c)
|
||||
|
||||
/* CALCUL POSITION */
|
||||
{
|
||||
buttonw = textw(conf.barbutton[i].content) + BPAD;
|
||||
|
||||
if(!(x = conf.barbutton[i].x))
|
||||
{
|
||||
if(i)
|
||||
pm += (conf.barbutton[i-1].type) ?
|
||||
get_image_attribute(conf.barbutton[i-1].content)->width :
|
||||
textw(conf.barbutton[i-1].content) + BPAD;
|
||||
pm += textw(conf.barbutton[i-1].content) + BPAD;
|
||||
|
||||
x = (!i) ? j : j + pm;
|
||||
buttonw = textw(conf.barbutton[i].content) + BPAD;
|
||||
x = (!i) ? j : j + pm;
|
||||
}
|
||||
|
||||
buttonw = (conf.barbutton[i].type) ?
|
||||
get_image_attribute(conf.barbutton[i].content)->width :
|
||||
textw(conf.barbutton[i].content) + BPAD;
|
||||
}
|
||||
|
||||
|
||||
/* FIRST TIME */
|
||||
{
|
||||
if(!c)
|
||||
@ -190,21 +185,15 @@ updatebutton(Bool c)
|
||||
}
|
||||
}
|
||||
|
||||
/* REFRESH/DRAW TEXT/IMAGE */
|
||||
/* REFRESH TEXT */
|
||||
{
|
||||
if(!conf.barbutton[i].bw)
|
||||
return;
|
||||
if(!conf.barbutton[i].type)
|
||||
bar_refresh_color(conf.barbutton[i].bw);
|
||||
bar_moveresize(conf.barbutton[i].bw, x, y, buttonw, barheight + hi);
|
||||
|
||||
/* Check the button type (image/text) */
|
||||
if(conf.barbutton[i].type)
|
||||
draw_image(conf.barbutton[i].bw->dr, 0, 0,
|
||||
conf.barbutton[i].content);
|
||||
else
|
||||
draw_text(conf.barbutton[i].bw->dr, BPAD/2, fonth, conf.barbutton[i].fg_color,
|
||||
conf.barbutton[i].bg_color, BPAD, conf.barbutton[i].content);
|
||||
bar_refresh_color(conf.barbutton[i].bw);
|
||||
bar_moveresize(conf.barbutton[i].bw, x, y, buttonw, barheight + hi);
|
||||
draw_text(conf.barbutton[i].bw->dr, BPAD/2, fonth, conf.barbutton[i].fg_color,
|
||||
conf.barbutton[i].bg_color, PAD, conf.barbutton[i].content);
|
||||
|
||||
/* Refresh button */
|
||||
bar_refresh(conf.barbutton[i].bw);
|
||||
|
||||
22
src/config.c
22
src/config.c
@ -190,7 +190,7 @@ init_conf(void)
|
||||
static cfg_opt_t layout_opts[] =
|
||||
{
|
||||
CFG_STR("type", "", CFGF_NONE),
|
||||
CFG_STR("image", "", CFGF_NONE),
|
||||
CFG_STR("symbol", "", CFGF_NONE),
|
||||
CFG_END()
|
||||
};
|
||||
|
||||
@ -241,7 +241,6 @@ init_conf(void)
|
||||
|
||||
static cfg_opt_t button_opts[] =
|
||||
{
|
||||
CFG_STR("type", "text", CFGF_NONE),
|
||||
CFG_STR("content", "", CFGF_NONE),
|
||||
CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI),
|
||||
CFG_STR("fg_color", "#000000", CFGF_NONE),
|
||||
@ -358,12 +357,12 @@ init_conf(void)
|
||||
{
|
||||
fprintf(stderr, "WMFS Configuration: Too much or no layouts\n");
|
||||
conf.nlayout = 1;
|
||||
conf.layout[0].image = strdup("TILE");
|
||||
conf.layout[0].symbol = strdup("TILE");
|
||||
conf.layout[0].func = tile;
|
||||
}
|
||||
|
||||
if(!conf.layout[0].image
|
||||
&& !conf.layout[0].func)
|
||||
if(!conf.layout[0].symbol
|
||||
&& !conf.layout[0].func)
|
||||
{
|
||||
for(i = 0; i < conf.nlayout; ++i)
|
||||
{
|
||||
@ -376,7 +375,7 @@ init_conf(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
conf.layout[i].image = strdup(var_to_str(cfg_getstr(cfgtmp, "image")));
|
||||
conf.layout[i].symbol = strdup(var_to_str(cfg_getstr(cfgtmp, "symbol")));
|
||||
conf.layout[i].func = name_to_func(strdup(cfg_getstr(cfgtmp, "type")), layout_list);
|
||||
}
|
||||
}
|
||||
@ -460,16 +459,9 @@ init_conf(void)
|
||||
conf.barbutton[i].mouse[j] = char_to_button(cfg_getstr(cfgtmp3, "button"));
|
||||
}
|
||||
conf.barbutton[i].nmousesec = cfg_size(cfgtmp2, "mouse");
|
||||
if(strcmp("image", strdup(cfg_getstr(cfgtmp2, "type"))) == 0)
|
||||
conf.barbutton[i].type = True;
|
||||
else
|
||||
conf.barbutton[i].type = False;
|
||||
conf.barbutton[i].content = strdup(var_to_str(cfg_getstr(cfgtmp2, "content")));
|
||||
if(!conf.barbutton[i].type)
|
||||
{
|
||||
conf.barbutton[i].fg_color = strdup(var_to_str(cfg_getstr(cfgtmp2, "fg_color")));
|
||||
conf.barbutton[i].bg_color = getcolor(strdup(var_to_str(cfg_getstr(cfgtmp2, "bg_color"))));
|
||||
}
|
||||
conf.barbutton[i].fg_color = strdup(var_to_str(cfg_getstr(cfgtmp2, "fg_color")));
|
||||
conf.barbutton[i].bg_color = getcolor(strdup(var_to_str(cfg_getstr(cfgtmp2, "bg_color"))));
|
||||
conf.barbutton[i].x = cfg_getint(cfgtmp2, "x");
|
||||
}
|
||||
|
||||
|
||||
51
src/draw.c
51
src/draw.c
@ -57,24 +57,6 @@ draw_text(Drawable d, int x, int y, char* fg, uint bg, int pad, char *str)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Drawing image function :
|
||||
* Only *.xpm file for now. */
|
||||
void
|
||||
draw_image(Drawable dr, int x, int y, char *file)
|
||||
{
|
||||
XImage *img;
|
||||
|
||||
if (XpmReadFileToImage(dpy, file, &img, NULL, NULL)) {
|
||||
fprintf(stderr, "WMFS Error: reading xpm file %s\n", file);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
XPutImage(dpy, dr, gc, img, 0, 0, x, y, img->width, img->height);
|
||||
|
||||
XFree(img);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
draw_taglist(Drawable dr)
|
||||
{
|
||||
@ -106,24 +88,10 @@ draw_taglist(Drawable dr)
|
||||
}
|
||||
|
||||
void
|
||||
draw_layout(int x, int y)
|
||||
draw_layout(void)
|
||||
{
|
||||
if(!layoutsym)
|
||||
{
|
||||
layoutsym = bar_create(x, y,
|
||||
get_image_attribute(tags[seltag].layout.image)->width,
|
||||
barheight-1, 0, conf.colors.bar, False);
|
||||
XMapRaised(dpy, layoutsym->win);
|
||||
}
|
||||
|
||||
bar_refresh_color(layoutsym);
|
||||
bar_moveresize(layoutsym, x, y, get_image_attribute(tags[seltag].layout.image)->width, barheight-1);
|
||||
|
||||
draw_image(layoutsym->dr, 0,
|
||||
(barheight/2 - get_image_attribute(tags[seltag].layout.image)->height/2),
|
||||
tags[seltag].layout.image);
|
||||
|
||||
bar_refresh(layoutsym);
|
||||
draw_text(bar->dr, taglen[conf.ntag] + PAD/2, fonth, conf.colors.layout_fg,
|
||||
conf.colors.layout_bg, PAD, tags[seltag].layout.symbol);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -139,19 +107,6 @@ draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color)
|
||||
return;
|
||||
}
|
||||
|
||||
XImage*
|
||||
get_image_attribute(char *file)
|
||||
{
|
||||
XImage *ret;
|
||||
|
||||
if (XpmReadFileToImage(dpy, file, &ret, NULL, NULL)) {
|
||||
fprintf(stderr, "WMFS Error: reading xpm file %s\n", file);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
draw_border(Window win, int color)
|
||||
{
|
||||
|
||||
40
src/event.c
40
src/event.c
@ -158,32 +158,32 @@ buttonpress(XEvent ev)
|
||||
uicb_tag("-1");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* ****** */
|
||||
/* LAYOUT */
|
||||
/* ****** */
|
||||
else if(ev.xbutton.window == layoutsym->win)
|
||||
{
|
||||
/* BUTTON 1 / 4 */
|
||||
/* ****** */
|
||||
/* LAYOUT */
|
||||
/* ****** */
|
||||
{
|
||||
if(ev.xbutton.button == Button1
|
||||
|| ev.xbutton.button == Button4)
|
||||
layoutswitch(True);
|
||||
if(ev.xbutton.x >= taglen[conf.ntag]
|
||||
&& ev.xbutton.x <= taglen[conf.ntag] + textw(tags[seltag].layout.symbol) + PAD/2)
|
||||
{
|
||||
/* BUTTON 1 / 4 */
|
||||
{
|
||||
if(ev.xbutton.button == Button1
|
||||
|| ev.xbutton.button == Button4)
|
||||
layoutswitch(True);
|
||||
}
|
||||
/* BUTTON 3 / 5 */
|
||||
{
|
||||
if(ev.xbutton.button == Button3
|
||||
|| ev.xbutton.button == Button5)
|
||||
layoutswitch(False);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* BUTTON 3 / 5 */
|
||||
{
|
||||
if(ev.xbutton.button == Button3
|
||||
|| ev.xbutton.button == Button5)
|
||||
layoutswitch(False);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* **** */
|
||||
|
||||
@ -83,7 +83,7 @@ layoutswitch(Bool b)
|
||||
|
||||
for(i = 0; i < conf.nlayout; ++i)
|
||||
{
|
||||
if(tags[seltag].layout.image == conf.layout[i].image
|
||||
if(tags[seltag].layout.symbol == conf.layout[i].symbol
|
||||
&& tags[seltag].layout.func == conf.layout[i].func)
|
||||
{
|
||||
if(b)
|
||||
|
||||
@ -103,7 +103,6 @@ typedef struct
|
||||
/* Bar Button */
|
||||
typedef struct
|
||||
{
|
||||
Bool type; /* False -> text, True -> image. */
|
||||
char *content;
|
||||
BarWindow *bw;
|
||||
char *fg_color;
|
||||
@ -118,7 +117,7 @@ typedef struct
|
||||
/* Layout Structure */
|
||||
typedef struct
|
||||
{
|
||||
char *image;
|
||||
char *symbol;
|
||||
void (*func)(void);
|
||||
} Layout;
|
||||
|
||||
|
||||
@ -96,7 +96,6 @@ quit(void)
|
||||
XFreeCursor(dpy, cursor[CurMove]);
|
||||
XFreeCursor(dpy, cursor[CurResize]);
|
||||
bar_delete(bar);
|
||||
bar_delete(layoutsym);
|
||||
if(conf.nbutton)
|
||||
for(i = 0; i < conf.nbutton; ++i)
|
||||
bar_delete(conf.barbutton[i].bw);
|
||||
@ -134,8 +133,8 @@ init(void)
|
||||
fprintf(stderr, "WMFS Error: Cannot initialize font\n");
|
||||
xftfont = XftFontOpenName(dpy, screen, "sans-10");
|
||||
}
|
||||
fonth = (xftfont->ascent + xftfont->descent);
|
||||
barheight = fonth + 3;
|
||||
fonth = (xftfont->ascent + xftfont->descent) - 1;
|
||||
barheight = fonth + 4;
|
||||
|
||||
|
||||
/* INIT CURSOR */
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
#include <time.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <confuse.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xatom.h>
|
||||
@ -50,8 +51,6 @@
|
||||
#include <X11/cursorfont.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <X11/xpm.h>
|
||||
#include <confuse.h>
|
||||
|
||||
/* Local headers */
|
||||
#include "config.h"
|
||||
@ -80,11 +79,9 @@ void uicb_togglebarpos(uicb_t);
|
||||
|
||||
/* draw.c */
|
||||
void draw_text(Drawable d, int x, int y, char* fg, uint bg, int pad, char *str);
|
||||
void draw_image(Drawable dr, int x, int y, char *file);
|
||||
void draw_taglist(Drawable dr);
|
||||
void draw_layout(int x, int y);
|
||||
void draw_layout(void);
|
||||
void draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color);
|
||||
XImage* get_image_attribute(char *file);
|
||||
void draw_border(Window win, int color);
|
||||
ushort textw(const char *text);
|
||||
|
||||
@ -192,7 +189,6 @@ XftFont *xftfont;
|
||||
|
||||
/* Bar / Tags */
|
||||
BarWindow *bar;
|
||||
BarWindow *layoutsym;
|
||||
Tag tags[MAXTAG];
|
||||
int barheight;
|
||||
char bartext[1024];
|
||||
|
||||
6
wmfsrc
6
wmfsrc
@ -42,9 +42,9 @@ colors
|
||||
|
||||
layouts
|
||||
{
|
||||
layout { type = "tile" image = "/usr/local/share/wmfs/icons/tile.xpm" }
|
||||
layout { type = "max" image = "/usr/local/share/wmfs/icons/max.xpm" }
|
||||
layout { type = "free" image = "/usr/local/share/wmfs/icons/free.xpm" }
|
||||
layout { type = "tile" symbol = "TILE" }
|
||||
layout { type = "max" symbol = "MAX" }
|
||||
layout { type = "free" symbol = "FREE" }
|
||||
}
|
||||
|
||||
tags
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user