39 Commits

Author SHA1 Message Date
Martin Duquesnoy
321669eb3a Draw: Fix possible segfault in textw (securize strcpy) 2010-03-28 16:09:00 +02:00
Martin Duquesnoy
aa9609b5cf Draw: Replace statustext_image by parse_color_block, remove image stuff in status.c (draw_text image stuff is sufficient) and update version 2010-03-28 15:41:54 +02:00
Martin Duquesnoy
09418c6dd7 Draw: Can put image everywhere we can habitually put text with same sequences than in statustext: \i[x;y;w;h;/image/path.ext]\ (example: layout, tag: http://omploader.org/vM3lzNg) 2010-03-28 14:49:10 +02:00
Martin Duquesnoy
0ce0d1a352 Draw: Add Imlib2 support to draw image (optional feature, work only if have imlib2): statustext block to draw image: \i[x;y;width;height;imagepath.extension]\ 2010-03-28 03:36:56 +02:00
OldMan
c350bb45d0 Conf: Buttons as indicators of client mode (Feature #33) 2010-03-25 19:53:00 +01:00
Martin Duquesnoy
06a9c44792 Client: Add ignore_next_client_rules uicb function requested by Armael. 2010-03-25 19:40:21 +01:00
Martin Duquesnoy
c5da009b7a Conf: Add [misc] status_path option to choose status script path 2010-03-25 19:19:24 +01:00
Martin Duquesnoy
23b0539686 Client: Reverse client_configure last modif 2010-03-25 13:46:59 +01:00
Martin Duquesnoy
8a236cc7ac Client: Update selbar if selected client get a new title 2010-03-25 12:36:34 +01:00
Martin Duquesnoy
4199b7bb50 Event: manage expose event for selbar 2010-03-24 19:15:11 +01:00
Martin Duquesnoy
842bc7d3ce Infobar: Add selbar; title of selected client in infobar (Feature #31 requested by markand), conf: [bar] selbar = true/false 2010-03-24 18:03:17 +01:00
Martin Duquesnoy
fab6a9f584 Tag: Fix mad behavior when wanting to transfer a client on the its tag 2010-03-04 21:54:18 +01:00
Martin Duquesnoy
7a714c03a9 Screen: Add screen_prev_sel function to go to the last used screen. (Feature #30 requested by Erus) 2010-02-26 23:40:16 +01:00
Martin Duquesnoy
2e0b050be3 Update version 2010-02-26 21:07:57 +01:00
OldMan
ade723b6bc Tag: Add functions to transfert selected client to next/previous tag. 2010-02-25 20:56:49 +01:00
OldMan
2b7d1c115d Client: Keep free-size after toggle_{free, max}. 2010-02-25 20:48:24 +01:00
Martin Duquesnoy
7e44e4b314 Tag: Add tag_prev_sel function request by Erus (Feature #29) 2010-02-25 20:39:04 +01:00
Martin Duquesnoy
77cb589f03 Mouse: Fix move_tag_client. 2010-02-07 17:56:48 +01:00
Martin Duquesnoy
56079ebdfe Infobar: Add option to move layout button before of after tags list (Feature #20 requested by Erus.) 2010-02-07 17:27:42 +01:00
Martin Duquesnoy
881ac9f68f Status: Add status.c, clean statutext fonction and add located text stuff: \s[x;y;#color;text]\. 2010-02-04 02:58:28 +01:00
Martin Duquesnoy
55fa590785 Revert "Conf: Fix bug (last keybind)"
This reverts commit a164eb8f7c.
2010-02-03 16:09:12 +01:00
Martin Duquesnoy
a164eb8f7c Conf: Fix bug (last keybind) 2010-02-03 15:42:59 +01:00
Martin Duquesnoy
888b2a7467 Infobar: Set buffers size to MAXSS 2010-01-31 16:27:27 +01:00
Philippe Pepiot
6f1624f43b Init: Define layout_list statically 2010-01-24 19:41:24 +01:00
Philippe Pepiot
04bef9a4b8 rc/status.sh: be posix compliant 2010-01-24 16:44:26 +01:00
Philippe Pepiot
344d80206c init: fix possible segfault if HOME not set 2010-01-20 11:38:32 +01:00
Philippe Pepiot
c6b97b7892 init: end layout list with { NULL, NULL } 2010-01-20 11:29:59 +01:00
Martin Duquesnoy
6c0a0b62b6 Infobar: Remove debug stuff ... again... 2010-01-10 16:33:56 +01:00
Martin Duquesnoy
bc94d42372 Infobar: Remove useless strncpy. 2010-01-10 16:32:49 +01:00
Martin Duquesnoy
f4d683f17f Infobar: Remove debug stuff 2010-01-10 15:07:19 +01:00
Martin Duquesnoy
d8afcfa013 Infobar: Fix strncpy mistake. 2010-01-10 15:06:37 +01:00
Martin Duquesnoy
af0d459b4c Infobar: Improve and simplify infobar_draw_statustext. 2010-01-10 03:00:48 +01:00
Martin Duquesnoy
b766375db8 Infobar: Code cosmetic. 2010-01-07 18:33:16 +01:00
Martin Duquesnoy
26498dc07b Infobar: Add bar feature in infobar_draw_statustext to make rectangle with wmfs -s -> \b[xx;yy;width;height;#color]\ *TEST* 2010-01-07 18:27:34 +01:00
Martin Duquesnoy
000a1f4c3d Infobar: Add bar feature in infobar_draw_statustext to make rectangle with wmfs -s -> \b[xx;yy;width;height;#color]\ *TEST* 2010-01-03 23:02:25 +01:00
Martin Duquesnoy
f0daf5ba20 Init: Replace system by spawn at the first execution of status_path 2010-01-02 20:31:42 +01:00
Martin Duquesnoy
250518c2a4 Wmfsrc: Add status_timing in default conf 2010-01-02 18:31:19 +01:00
Martin Duquesnoy
7acf0139d4 Infobar/Wmfs: Fix infobar_draw_statustext, remove useless screen_count() 2010-01-02 17:38:13 +01:00
Martin Duquesnoy
e4bbe15fc4 Infobar: Fix memleak in infobar_draw_statustext by replacing pointer to array 2010-01-02 16:50:37 +01:00
23 changed files with 766 additions and 236 deletions

View File

@@ -42,6 +42,7 @@ set(wmfs_src
src/menu.c
src/mouse.c
src/screen.c
src/status.c
src/tag.c
src/util.c
src/viwmfs.c
@@ -51,10 +52,10 @@ set(wmfs_src
add_executable(wmfs ${wmfs_src})
# Set the version
set(VERSION "WMFS-201001")
set(VERSION "WMFS-201003")
# FLAGS
set(CFLAGS "-g -Wall -ansi")
set(CFLAGS "-Wall -ansi")
set(CMAKE_C_FLAGS ${CFLAGS})
# Linker FLAGS
@@ -105,6 +106,8 @@ pkg_check_modules(WMFS_REQUIRED REQUIRED
freetype2
xft)
# Optional dependencies check
# Check for xinerama
pkg_check_modules(HAVE_XINERAMA xinerama)
if(HAVE_XINERAMA_FOUND)
@@ -123,6 +126,15 @@ else()
set(WMFS_HAVE_XRANDR "")
endif()
# Check for Imlib
pkg_check_modules(HAVE_IMLIB imlib2)
if(HAVE_IMLIB_FOUND)
set(WMFS_HAVE_IMLIB "#define HAVE_IMLIB")
set(LIBRARIES_TO_LINK ${LIBRARIES_TO_LINK} Imlib2)
else()
set(WMFS_HAVE_IMLIB "")
endif()
target_link_libraries(wmfs ${LIBRARIES_TO_LINK})
# Messages

View File

@@ -5,9 +5,7 @@
statustext()
{
local DATE=`date`
wmfs -s "$DATE"
wmfs -s "`date`"
}
statustext

View File

@@ -107,6 +107,9 @@ barwin_create(Window parent,
void
barwin_draw_text(BarWindow *bw, int x, int y, char *text)
{
if(!text)
return;
/* Background color of the text if there is stipple */
if(bw->stipple)
draw_rectangle(bw->dr, x - 4, 0, textw(text) + 8, bw->geo.height, bw->bg);

View File

@@ -270,9 +270,16 @@ client_focus(Client *c)
client_above(sel);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
if(conf.bars.selbar)
infobar_draw_selbar(sel->screen);
}
else
{
XSetInputFocus(dpy, ROOT, RevertToPointerRoot, CurrentTime);
if(conf.bars.selbar)
infobar_draw_selbar(selscreen);
}
return;
}
@@ -389,6 +396,9 @@ client_get_name(Client *c)
frame_update(c);
if(conf.bars.selbar && c == sel)
infobar_draw_selbar(c->screen);
return;
}
@@ -555,6 +565,7 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
c->ogeo.y = c->geo.y = my;
c->ogeo.width = c->geo.width = wa->width;
c->ogeo.height = c->geo.height = wa->height;
c->free_geo = c->geo;
c->tag = seltag[c->screen];
c->layer = (sel && sel->layer > 0) ? sel->layer : 1;
@@ -826,6 +837,12 @@ client_set_wanted_tag(Client *c)
XClassHint xch = { 0 };
int i, j, k;
if(conf.ignore_next_client_rules)
{
conf.ignore_next_client_rules = False;
return;
}
XGetClassHint(dpy, c->win, &xch);
for(i = 0; i < screen_count(); ++i)
@@ -1119,3 +1136,16 @@ uicb_client_resize(uicb_t cmd)
return;
}
/** Ignore next client rules
*\param cmd uicb_t type
*/
void
uicb_ignore_next_client_rules(uicb_t cmd)
{
conf.ignore_next_client_rules = !conf.ignore_next_client_rules;
return;
}

View File

@@ -37,44 +37,47 @@ static void conf_section(void (*)(char*), char *, char *);
func_name_list_t tmp_func_list[] =
{
{"spawn", uicb_spawn },
{"client_kill", uicb_client_kill },
{"client_prev", uicb_client_prev },
{"client_next", uicb_client_next },
{"client_swap_next", uicb_client_swap_next },
{"client_swap_prev", uicb_client_swap_prev },
{"client_screen_next", uicb_client_screen_next },
{"client_screen_prev", uicb_client_screen_prev },
{"client_move", uicb_client_move },
{"client_resize", uicb_client_resize },
{"toggle_max", uicb_togglemax },
{"layout_next", uicb_layout_next },
{"layout_prev", uicb_layout_prev },
{"tag", uicb_tag },
{"tag_next", uicb_tag_next },
{"tag_prev", uicb_tag_prev },
{"tag_transfert", uicb_tagtransfert },
{"set_mwfact", uicb_set_mwfact },
{"set_nmaster", uicb_set_nmaster },
{"quit", uicb_quit },
{"toggle_infobar_position", uicb_infobar_togglepos },
{"toggle_resizehint", uicb_toggle_resizehint },
{"mouse_move", uicb_mouse_move },
{"mouse_resize", uicb_mouse_resize },
{"client_raise", uicb_client_raise },
{"toggle_free", uicb_togglefree },
{"toggle_abovefc", uicb_toggle_abovefc },
{"screen_select", uicb_screen_select },
{"screen_next", uicb_screen_next },
{"screen_prev", uicb_screen_prev },
{"reload", uicb_reload },
{"launcher", uicb_launcher },
{"set_layout", uicb_set_layout },
{"menu", uicb_menu },
{"set_client_layer", uicb_set_client_layer },
{"set_layer", uicb_set_layer }
{"spawn", uicb_spawn },
{"client_kill", uicb_client_kill },
{"client_prev", uicb_client_prev },
{"client_next", uicb_client_next },
{"client_swap_next", uicb_client_swap_next },
{"client_swap_prev", uicb_client_swap_prev },
{"client_screen_next", uicb_client_screen_next },
{"client_screen_prev", uicb_client_screen_prev },
{"client_move", uicb_client_move },
{"client_resize", uicb_client_resize },
{"toggle_max", uicb_togglemax },
{"layout_next", uicb_layout_next },
{"layout_prev", uicb_layout_prev },
{"tag", uicb_tag },
{"tag_next", uicb_tag_next },
{"tag_prev", uicb_tag_prev },
{"tag_prev_sel", uicb_tag_prev_sel },
{"tag_transfert", uicb_tagtransfert },
{"tag_transfert_next", uicb_tagtransfert_next },
{"tag_transfert_prev", uicb_tagtransfert_prev },
{"set_mwfact", uicb_set_mwfact },
{"set_nmaster", uicb_set_nmaster },
{"quit", uicb_quit },
{"toggle_infobar_position", uicb_infobar_togglepos },
{"toggle_resizehint", uicb_toggle_resizehint },
{"mouse_move", uicb_mouse_move },
{"mouse_resize", uicb_mouse_resize },
{"client_raise", uicb_client_raise },
{"toggle_free", uicb_togglefree },
{"toggle_abovefc", uicb_toggle_abovefc },
{"screen_select", uicb_screen_select },
{"screen_next", uicb_screen_next },
{"screen_prev", uicb_screen_prev },
{"screen_prev_sel", uicb_screen_prev_sel},
{"reload", uicb_reload },
{"launcher", uicb_launcher },
{"set_layout", uicb_set_layout },
{"menu", uicb_menu },
{"set_client_layer", uicb_set_client_layer },
{"set_layer", uicb_set_layer },
{"ignore_next_client_rules", uicb_ignore_next_client_rules }
};
key_name_list_t key_list[] =
@@ -141,6 +144,7 @@ conf_misc_section(char *src)
conf.raiseswitch = get_opt(src, "false", "raiseswitch").bool;
conf.focus_fmouse = get_opt(src, "true", "focus_follow_mouse").bool;
conf.status_timing = get_opt(src, "1", "status_timing").num;
conf.status_path = get_opt(src, "", "status_path").str;
pad = get_opt(src, "12", "pad").num;
if(pad > 24 || pad < 1)
@@ -170,6 +174,7 @@ conf_bar_section(char *src)
conf.bars.height = get_opt(src, "-1", "height").num;
conf.colors.bar = getcolor(get_opt(src, "#000000", "bg").str);
conf.colors.text = get_opt(src, "#ffffff", "fg").str;
conf.bars.selbar = get_opt(src, "false", "selbar").bool;
if((conf.bars.nmouse = get_size_sec(src, "mouse")))
{
@@ -259,6 +264,15 @@ conf_client_section(char *src)
cfg_set_sauv(tmp2);
tmp3 = get_opt(tmp2, "none", "flags").str;
conf.titlebar.button[i].flags = 0;
if(strstr(tmp3, "free"))
conf.titlebar.button[i].flags |= FreeFlag;
if(strstr(tmp3, "max"))
conf.titlebar.button[i].flags |= MaxFlag;
if(strstr(tmp3, "tile"))
conf.titlebar.button[i].flags |= TileFlag;
/* Multi mouse section */
if((conf.titlebar.button[i].nmouse = get_size_sec(tmp2, "mouse")))
{
@@ -318,6 +332,9 @@ conf_layout_section(char *src)
if((tmp = get_opt(src, "menu", "system").str) && !strcmp(tmp, "menu"))
conf.layout_system = True;
if((tmp = get_opt(src, "right", "placement").str) && !strcmp(tmp, "left"))
conf.layout_placement = True;
conf.nlayout = get_size_sec(src, "layout");
if(conf.nlayout > NUM_OF_LAYOUT || !(conf.nlayout))
@@ -391,9 +408,10 @@ conf_tag_section(char *src)
sc = screen_count();
/* Alloc all */
conf.ntag = emalloc(sc, sizeof(int));
tags = emalloc(sc, sizeof(Tag*));
seltag = emalloc(sc, sizeof(int));
conf.ntag = emalloc(sc, sizeof(int));
tags = emalloc(sc, sizeof(Tag*));
seltag = emalloc(sc, sizeof(int));
prevseltag = emalloc(sc, sizeof(int));
for(i = 0; i < sc; ++i)
seltag[i] = 1;

View File

@@ -41,7 +41,10 @@
#define WMFS_COMPILE_FLAGS "@WMFS_COMPILE_FLAGS@"
#define WMFS_LINKED_LIBS "@WMFS_LINKED_LIBS@"
#define XDG_CONFIG_DIR "@XDG_CONFIG_DIR@"
/* Optional dependencies */
@WMFS_HAVE_XINERAMA@
@WMFS_HAVE_XRANDR@
@WMFS_HAVE_IMLIB@
#endif /* CONFIG_H */

View File

@@ -46,6 +46,26 @@ draw_text(Drawable d, int x, int y, char* fg, int pad, char *str)
XftColor xftcolor;
XftDraw *xftd;
if(!str)
return;
/* To draw image everywhere we can draw text */
#ifdef HAVE_IMLIB
char *ostr = NULL;
int i, ni;
ImageAttr im[128];
ostr = _strdup(str);
if(strstr(str, "i["))
{
ni = parse_image_block(im, str);
for(i = 0; i < ni; ++i)
draw_image(d, im[i].x, im[i].y, im[i].w, im[i].h, im[i].name);
}
#endif /* HAVE_IMLIB */
/* Transform X Drawable -> Xft Drawable */
xftd = XftDrawCreate(dpy, d, DefaultVisual(dpy, SCREEN), DefaultColormap(dpy, SCREEN));
@@ -60,6 +80,13 @@ draw_text(Drawable d, int x, int y, char* fg, int pad, char *str)
XftDrawDestroy(xftd);
#ifdef HAVE_IMLIB
if(strstr(ostr, "i["))
strcpy(str, ostr);
IFREE(ostr);
#endif /* HAVE_IMLIB */
return;
}
@@ -82,20 +109,80 @@ draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color)
return;
}
#ifdef HAVE_IMLIB
/** Draw an image in a drawable
* \param dr Drawable
* \param x X position
* \param y Y position
* \param name Path of the image
*/
void
draw_image(Drawable dr, int x, int y, int w, int h, char *name)
{
Imlib_Image image;
if(!name)
return;
imlib_set_cache_size(2048 * 1024);
imlib_context_set_display(dpy);
imlib_context_set_visual(DefaultVisual(dpy, DefaultScreen(dpy)));
imlib_context_set_colormap(DefaultColormap(dpy, DefaultScreen(dpy)));
imlib_context_set_drawable(dr);
image = imlib_load_image(name);
imlib_context_set_image(image);
if(w <= 0)
w = imlib_image_get_width();
if(h <= 0)
h = imlib_image_get_height();
if(image)
{
imlib_render_image_on_drawable_at_size(x, y, w, h);
imlib_free_image();
}
else
warnx("Can't draw image: '%s'", name);
return;
}
#endif /* HAVE_IMLIB */
/** Calculates the text's size relatively to the font
* \param text Text string
* \return final text width
*/
ushort
textw(const char *text)
textw(char *text)
{
XGlyphInfo gl;
if(!text)
return 0;
#ifdef HAVE_IMLIB
char *ostr = NULL;
ImageAttr im[128];
ostr = _strdup(text);
if(strstr(text, "i["))
parse_image_block(im, text);
#endif /* HAVE_IMLIB */
XftTextExtentsUtf8(dpy, font, (FcChar8 *)text, strlen(text), &gl);
#ifdef HAVE_IMLIB
if(strstr(ostr, "i["))
strcpy(text, ostr);
IFREE(ostr);
#endif /* HAVE_IMLIB */
return gl.width + font->descent;
}

View File

@@ -140,7 +140,7 @@ void
clientmessageevent(XClientMessageEvent *ev)
{
Client *c;
int i, mess_t = 0;
int s, i, mess_t = 0;
Atom rt;
int rf;
ulong ir, il;
@@ -151,7 +151,9 @@ clientmessageevent(XClientMessageEvent *ev)
if(ev->format != 32)
return;
for(i = 0; i < net_last + screen_count(); ++i)
s = screen_count();
for(i = 0; i < net_last + s; ++i)
if(net_atom[i] == ev->message_type)
mess_t = i;
@@ -166,7 +168,7 @@ clientmessageevent(XClientMessageEvent *ev)
/* Manage _WMFS_SET_SCREEN */
if(mess_t == wmfs_set_screen
&& ev->data.l[0] >= 0
&& ev->data.l[0] <= screen_count())
&& ev->data.l[0] <= s)
screen_set_sel((int)(ev->data.l[0]));
/* Manage _NET_ACTIVE_WINDOW */
@@ -196,7 +198,7 @@ clientmessageevent(XClientMessageEvent *ev)
if(XGetWindowProperty(dpy, ROOT, net_atom[mess_t], 0, 4096,
False, net_atom[utf8_string], &rt, &rf, &ir, &il, &ret) == Success)
{
infobar_draw_statustext(mess_t - wmfs_statustext, (char*)ret);
statustext_handle(mess_t - wmfs_statustext, (char*)ret);
XFree(ret);
}
}
@@ -233,7 +235,7 @@ clientmessageevent(XClientMessageEvent *ev)
if(mess_t == wmfs_update_status
&& estatus)
spawn(status_path);
spawn(conf.status_path);
return;
}
@@ -349,6 +351,8 @@ expose(XExposeEvent *ev)
barwin_refresh(infobar[sc].bar);
if(ev->window == infobar[sc].layout_button->win)
barwin_refresh(infobar[sc].layout_button);
if(conf.bars.selbar && ev->window == infobar[sc].selbar->win)
barwin_refresh(infobar[sc].selbar);
for(i = 1; i < conf.ntag[sc] + 1; ++i)
if(ev->window == infobar[sc].tags[i]->win)
barwin_refresh(infobar[sc].tags[i]);

View File

@@ -42,12 +42,13 @@
void
ewmh_init_hints(void)
{
int i = 1, j, showing_desk = 0;
int i = 1, s, j, showing_desk = 0;
char root_name[] = WMFS_VERSION;
char class[] = "wmfs", st[64];
long pid = (long)getpid();
net_atom = emalloc(net_last + screen_count(), sizeof(Atom));
s = screen_count();
net_atom = emalloc(net_last + s, sizeof(Atom));
/* EWMH hints */
net_atom[net_supported] = ATOM("_NET_SUPPORTED");
@@ -93,14 +94,14 @@ ewmh_init_hints(void)
net_atom[wmfs_cmd] = ATOM("_WMFS_CMD");
/* Multi atom _WMFS_STATUSTEXT_<screennum> */
for(j = 0; j < screen_count(); ++j)
for(j = 0; j < s; ++j)
{
sprintf(st, "_WMFS_STATUSTEXT_%d", j);
net_atom[wmfs_statustext + j] = ATOM(st);
}
XChangeProperty(dpy, ROOT, net_atom[net_supported], XA_ATOM, 32,
PropModeReplace, (uchar*)net_atom, net_last + screen_count());
PropModeReplace, (uchar*)net_atom, net_last + s);
XChangeProperty(dpy, ROOT, net_atom[wmfs_running], XA_CARDINAL, 32,
PropModeReplace, (uchar*)&i, 1);
@@ -213,15 +214,17 @@ void
ewmh_get_desktop_names(void)
{
char *str = NULL;
int s, i, len = 0, pos = 0;
int S, s, i, len = 0, pos = 0;
for(s = 0 ; s < screen_count(); ++s)
S = screen_count();
for(s = 0 ; s < S; ++s)
for(i = 1; i < conf.ntag[s] + 1; ++i)
len += strlen(tags[s][i].name);
str = emalloc(len + i + 1, sizeof(char*));
for(s = 0; s < screen_count(); ++s)
for(s = 0; s < S; ++s)
for(i = 1; i < conf.ntag[s] + 1; ++i, ++pos)
{
strncpy(str + pos, tags[s][i].name, strlen(tags[s][i].name));
@@ -264,14 +267,16 @@ void
ewmh_set_workarea(void)
{
long *data;
int i, j, tag_c = 0, pos = 0;
int i, s, j, tag_c = 0, pos = 0;
for(i = 0; i < screen_count(); ++i)
s = screen_count();
for(i = 0; i < s; ++i)
tag_c += conf.ntag[i];
data = emalloc(tag_c * 4, sizeof(long));
for(i = 0; i < screen_count(); ++i)
for(i = 0; i < s; ++i)
for(j = 0; j < conf.ntag[i]; ++j)
{
data[pos++] = spgeo[i].x;

View File

@@ -220,16 +220,26 @@ frame_update(Client *c)
{
XSetWindowBackground(dpy, c->button[i], c->colors.frame);
XClearWindow(dpy, c->button[i]);
XSetWindowBorder(dpy, c->button[i], getcolor(c->colors.fg));
/* Button's lines */
if(conf.titlebar.button[i].nlines)
if((!conf.titlebar.button[i].flags)
|| ((conf.titlebar.button[i].flags & FreeFlag) && (c->flags & FreeFlag))
|| ((conf.titlebar.button[i].flags & MaxFlag) && (c->flags & MaxFlag))
|| ((conf.titlebar.button[i].flags & TileFlag) && (c->flags & TileFlag)))
{
XSetForeground(dpy, gc, getcolor(c->colors.fg));
XDrawSegments(dpy, c->button[i], gc,
conf.titlebar.button[i].linecoord,
conf.titlebar.button[i].nlines);
XSetWindowBorder(dpy, c->button[i], getcolor(c->colors.fg));
/* Button's lines */
if(conf.titlebar.button[i].nlines)
{
XSetForeground(dpy, gc, getcolor(c->colors.fg));
XDrawSegments(dpy, c->button[i], gc,
conf.titlebar.button[i].linecoord,
conf.titlebar.button[i].nlines);
}
}
else
XSetWindowBorder(dpy, c->button[i], c->colors.frame);
}
}

View File

@@ -37,12 +37,14 @@
void
infobar_init(void)
{
int sc, i, j;
int s, sc, i, j = 0;
s = screen_count();
if(!infobar)
infobar = emalloc(screen_count(), sizeof(InfoBar));
infobar = emalloc(s, sizeof(InfoBar));
for(sc = 0; sc < screen_count(); ++sc)
for(sc = 0; sc < s; ++sc)
{
j = 0;
infobar[sc].geo.height = INFOBARH;
@@ -70,35 +72,64 @@ infobar_init(void)
sgeo[sc].width, infobar[sc].geo.height,
conf.colors.bar, conf.colors.text, False, False, conf.border.bar);
infobar[sc].tags_board = barwin_create(infobar[sc].bar->win,
((conf.layout_placement) ? textw(tags[sc][seltag[sc]].layout.symbol) + PAD * 1.5: 0), 0,
textw(tags[sc][0].name) + PAD, /* Base size, will change */
infobar[sc].geo.height,
conf.colors.bar, conf.colors.text, False, False, False);
/* Create tags window */
for(i = 1; i < conf.ntag[sc] + 1; ++i)
{
infobar[sc].tags[i] = barwin_create(infobar[sc].bar->win, j, 0,
infobar[sc].tags[i] = barwin_create(infobar[sc].tags_board->win, j, 0,
textw(tags[sc][i].name) + PAD,
infobar[sc].geo.height,
conf.colors.bar, conf.colors.text, False, False, conf.border.tag);
j += textw(tags[sc][i].name) + PAD;
barwin_resize(infobar[sc].tags_board, j, infobar[sc].geo.height);
barwin_map_subwin(infobar[sc].tags[i]);
}
/* Create layout switch barwindow */
infobar[sc].layout_button = barwin_create(infobar[sc].bar->win, j + PAD / 2, 0,
textw(tags[sc][seltag[sc]].layout.symbol) + PAD,
infobar[sc].geo.height,
conf.colors.layout_bg, conf.colors.layout_fg,
False, False, conf.border.layout);
infobar[sc].layout_button = barwin_create(infobar[sc].bar->win,
((conf.layout_placement) ? 0 : (j + PAD / 2)), 0,
textw(tags[sc][seltag[sc]].layout.symbol) + PAD,
infobar[sc].geo.height,
conf.colors.layout_bg, conf.colors.layout_fg,
False, False, conf.border.layout);
/* Selbar */
if(conf.bars.selbar)
infobar[sc].selbar = barwin_create(infobar[sc].bar->win,
((conf.layout_placement)
? (j + PAD / 2)
: infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + PAD / 2), 1,
(sel) ? textw(sel->title) + PAD : 1,
infobar[sc].geo.height - 2,
conf.colors.bar, conf.colors.text, False, False, False);
/* Map/Refresh all */
barwin_map(infobar[sc].bar);
barwin_map_subwin(infobar[sc].bar);
barwin_map(infobar[sc].tags_board);
barwin_map_subwin(infobar[sc].tags_board);
if(conf.border.layout)
barwin_map_subwin(infobar[sc].layout_button);
if(conf.bars.selbar)
barwin_map(infobar[sc].selbar);
barwin_refresh_color(infobar[sc].bar);
barwin_refresh(infobar[sc].bar);
/* Default statustext is set here */
for(i = 0; i < screen_count(); ++i)
for(i = 0; i < s; ++i)
infobar[i].statustext = _strdup(WMFS_VERSION);
infobar_draw(sc);
}
@@ -113,8 +144,9 @@ infobar_draw(int sc)
{
infobar_draw_taglist(sc);
infobar_draw_layout(sc);
infobar_draw_selbar(sc);
barwin_refresh_color(infobar[sc].bar);
infobar_draw_statustext(sc, infobar[sc].statustext);
statustext_handle(sc, infobar[sc].statustext);
return;
}
@@ -127,12 +159,36 @@ infobar_draw_layout(int sc)
{
barwin_resize(infobar[sc].layout_button, textw(tags[sc][seltag[sc]].layout.symbol) + PAD, infobar[sc].geo.height);
barwin_refresh_color(infobar[sc].layout_button);
if(tags[sc][seltag[sc]].layout.symbol)
barwin_draw_text(infobar[sc].layout_button, PAD / 2, FHINFOBAR, tags[sc][seltag[sc]].layout.symbol);
return;
}
/** Draw Selbar (selected client title bar in infobar
*\param sc Screen Number
*/
void
infobar_draw_selbar(int sc)
{
if(!conf.bars.selbar)
return;
barwin_move(infobar[sc].selbar,
((conf.layout_placement)
? (infobar[sc].tags_board->geo.x + infobar[sc].tags_board->geo.width + PAD / 2)
: (infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + PAD / 2)), 1);
barwin_resize(infobar[sc].selbar, textw(sel ? sel->title : NULL) + PAD, infobar[sc].geo.height - 2);
barwin_refresh_color(infobar[sc].selbar);
barwin_draw_text(infobar[sc].selbar, PAD / 2, FHINFOBAR - 1, (sel) ? sel->title : NULL);
barwin_refresh(infobar[sc].selbar);
return;
}
/** Draw the taglist in the InfoBar
*\param sc Screen number
*/
@@ -142,6 +198,9 @@ infobar_draw_taglist(int sc)
int i;
Client *c;
if(conf.layout_placement)
barwin_move(infobar[sc].tags_board, textw(tags[sc][seltag[sc]].layout.symbol) + PAD * 1.5, 0);
for(i = 1; i < conf.ntag[sc] + 1; ++i)
{
infobar[sc].tags[i]->bg = ((i == seltag[sc]) ? conf.colors.tagselbg : conf.colors.bar);
@@ -164,86 +223,6 @@ infobar_draw_taglist(int sc)
return;
}
/** Draw text in the statustext and parse color format
*\param sc Screen
*\param str String
*/
void
infobar_draw_statustext(int sc, char *str)
{
char *buf = NULL;
char *strwc = NULL;
char col[8] = { 0 };
int i, j, c, k = 0;
char *lastst;
/* If the str == the current statustext, return (not needed) */
if(!str)
return;
barwin_refresh_color(infobar[sc].bar);
/* save last status text address (for free at the end) */
lastst = infobar[sc].statustext;
infobar[sc].statustext = _strdup(str);
strwc = _strdup(str);
/* Count how many color block there is and make a string without color block (\#....\)*/
for(i = j = c = 0; i < strlen(str); ++i, ++j)
{
if(str[i] == '\\' && str[i + 1] == '#' && str[i + 8] == '\\')
{
++c;
i += 8;
--j;
}
else
strwc[j] = str[i];
}
strwc[j] = '\0';
/* Draw a first time the statustext for non colorized text */
draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(strwc),
FHINFOBAR, infobar[sc].bar->fg, 0, strwc);
/* Draw text with its color */
if(c)
{
buf = _strdup(strwc);
for(i = k; i < strlen(str); ++i, ++k)
if(str[i] == '\\' && str[i + 1] == '#' && str[i + 8] == '\\')
{
/* Store current color in col[] */
for(j = 0, ++i; str[i] != '\\'; col[j++] = str[i++]);
buf += k;
/* Draw a rectangle with the bar color to draw the text properly */
draw_rectangle(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(buf),
0, INFOBARH - (sgeo[sc].width - SHADH) - textw(buf),
INFOBARH, conf.colors.bar);
/* Draw text with its color */
draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(buf),
FHINFOBAR, col, 0, buf);
buf = _strdup(strwc);
++i;
}
free(buf);
}
barwin_refresh(infobar[sc].bar);
free(lastst);
free(strwc);
return;
}
/** Destroy the InfoBar
*/
void
@@ -255,11 +234,15 @@ infobar_destroy(void)
{
barwin_delete(infobar[sc].layout_button);
barwin_delete_subwin(infobar[sc].layout_button);
for(i = 1; i < conf.ntag[sc] + 1; ++i)
{
barwin_delete_subwin(infobar[sc].tags[i]);
barwin_delete(infobar[sc].tags[i]);
}
barwin_delete_subwin(infobar[sc].tags_board);
barwin_delete(infobar[sc].tags_board);
barwin_delete_subwin(infobar[sc].bar);
barwin_delete(infobar[sc].bar);
}

View File

@@ -32,6 +32,28 @@
#include "wmfs.h"
const func_name_list_t layout_list[] =
{
{"tile", tile },
{"tile_right", tile },
{"tile_left", tile_left },
{"tile_top", tile_top },
{"tile_bottom", tile_bottom },
{"tile_grid", grid },
{"grid", grid },
{"mirror_vertical", mirror_vertical },
{"tile_mirror_vertical", mirror_vertical },
{"mirror_horizontal", mirror_horizontal },
{"tile_mirror_horizontal", mirror_horizontal },
{"layer", layer },
{"max", maxlayout },
{"maxlayout", maxlayout },
{"freelayout", freelayout },
{"free", freelayout },
{ NULL, NULL }
};
/** Init WMFS
*/
void
@@ -39,7 +61,6 @@ init(void)
{
/* First init */
ewmh_init_hints();
init_layout();
init_conf();
init_gc();
init_font();
@@ -154,42 +175,6 @@ init_root(void)
return;
}
/** Init layout
*/
void
init_layout(void)
{
int i;
const func_name_list_t layout_list_tmp[] =
{
{"tile", tile },
{"tile_right", tile },
{"tile_left", tile_left },
{"tile_top", tile_top },
{"tile_bottom", tile_bottom },
{"tile_grid", grid },
{"grid", grid },
{"mirror_vertical", mirror_vertical },
{"tile_mirror_vertical", mirror_vertical },
{"mirror_horizontal", mirror_horizontal },
{"tile_mirror_horizontal", mirror_horizontal },
{"layer", layer },
{"max", maxlayout },
{"maxlayout", maxlayout },
{"freelayout", freelayout },
{"free", freelayout }
};
layout_list = emalloc(LEN(layout_list_tmp), sizeof(func_name_list_t));
memset(layout_list, 0, LEN(layout_list_tmp));
for(i = 0; i < LEN(layout_list_tmp); ++i)
layout_list[i] = layout_list_tmp[i];
return;
}
/** Init statustext shell script
*/
void
@@ -197,30 +182,40 @@ init_status(void)
{
int fd;
struct stat st;
char *home;
status_path = emalloc(strlen(getenv("HOME")) + strlen(DEF_STATUS) + 2, sizeof(char));
sprintf(status_path, "%s/"DEF_STATUS, getenv("HOME"));
if(!(fd = open(status_path, O_RDONLY))
|| !fopen(status_path, "r"))
if(!conf.status_path)
{
free(status_path);
if(!(home = getenv("HOME")))
{
warnx("HOME not set, can't launch status.sh");
estatus = False;
return;
}
conf.status_path = emalloc(strlen(home) + strlen(DEF_STATUS) + 2, sizeof(char));
sprintf(conf.status_path, "%s/"DEF_STATUS, home);
}
if(!(fd = open(conf.status_path, O_RDONLY))
|| !fopen(conf.status_path, "r"))
{
free(conf.status_path);
estatus = False;
return;
}
stat(status_path, &st);
stat(conf.status_path, &st);
if(st.st_size && st.st_mode & S_IXUSR)
{
estatus = True;
system(status_path);
spawn(conf.status_path);
}
else
warnx("status.sh file present in wmfs directory can't be executed, try 'chmod +x %s'.",
status_path);
warnx("status file specified in configuratin (status_path) or present in wmfs directory can't be executed, try 'chmod +x %s'.", conf.status_path);
close(fd);

View File

@@ -71,7 +71,7 @@ freelayout(int screen)
&& c->screen == screen_get_sel()
&& !(c->flags & MaxFlag))
{
client_moveresize(c, c->ogeo, True);
client_moveresize(c, c->free_geo, True);
c->flags &= ~(TileFlag | LMaxFlag);
}
@@ -93,7 +93,10 @@ layoutswitch(Bool b)
if(tags[selscreen][seltag[selscreen]].layout.func == freelayout)
for(c = clients; c && (c->tag != seltag[selscreen] && c->screen != selscreen); c = c->next)
{
c->ogeo = c->geo;
c->free_geo = c->geo;
}
for(i = 0; i < conf.nlayout; ++i)
{
@@ -775,11 +778,14 @@ uicb_togglefree(uicb_t cmd)
if((sel->flags & FreeFlag))
{
sel->flags &= ~(TileFlag | MaxFlag | LMaxFlag);
client_moveresize(sel, sel->ogeo, True);
client_moveresize(sel, sel->free_geo, True);
client_raise(sel);
}
else
{
sel->free_geo = sel->geo;
sel->ogeo = sel->geo;
}
client_update_attributes(sel);
@@ -802,6 +808,7 @@ uicb_togglemax(uicb_t cmd)
if(!(sel->flags & MaxFlag))
{
sel->ogeo = sel->geo;
sel->free_geo = sel->geo;
sel->flags &= ~(TileFlag | FreeFlag);
client_maximize(sel);
client_raise(sel);
@@ -809,6 +816,8 @@ uicb_togglemax(uicb_t cmd)
}
else
{
sel->geo = sel->free_geo;
client_moveresize(sel, sel->geo, True);
sel->flags &= ~MaxFlag;
tags[selscreen][seltag[selscreen]].layout.func(selscreen);
}

View File

@@ -53,7 +53,6 @@ void
mouse_move_tile_client(Client **c)
{
Client *sc;
Window w;
int d;
@@ -88,7 +87,7 @@ mouse_move_tag_client(Client *c)
s = c->screen;
XQueryPointer(dpy, infobar[selscreen].bar->win, &w, &w, &d, &d, &d, &d, (uint*)&d);
XQueryPointer(dpy, infobar[selscreen].tags_board->win, &w, &w, &d, &d, &d, &d, (uint*)&d);
for(i = 1; i < conf.ntag[selscreen] + 1; ++i)
if(infobar[selscreen].tags[i]->win == w

View File

@@ -123,10 +123,13 @@ screen_set_sel(int screen)
if(screen < 0 || screen > screen_count() - 1)
screen = 0;
prevselscreen = selscreen;
client_focus(NULL);
XWarpPointer(dpy, None, ROOT, 0, 0, 0, 0,
sgeo[screen].x + sgeo[screen].width / 2,
sgeo[screen].y + sgeo[screen].height / 2);
selscreen = screen;
return;
@@ -138,6 +141,8 @@ screen_set_sel(int screen)
int
screen_get_sel(void)
{
int os = selscreen;
selscreen = 0;
#ifdef HAVE_XINERAMA
@@ -157,6 +162,9 @@ screen_get_sel(void)
XChangeProperty(dpy, ROOT, net_atom[wmfs_current_screen], XA_CARDINAL, 32,
PropModeReplace, (uchar*)&selscreen, 1);
if(os != selscreen)
prevselscreen = os;
return selscreen;
}
@@ -166,11 +174,12 @@ void
screen_init_geo(void)
{
int i;
int s = screen_count();
sgeo = emalloc(screen_count(), sizeof(XRectangle));
spgeo = emalloc(screen_count(), sizeof(XRectangle));
sgeo = emalloc(s, sizeof(XRectangle));
spgeo = emalloc(s, sizeof(XRectangle));
for(i = 0; i < screen_count(); ++i)
for(i = 0; i < s; ++i)
sgeo[i] = screen_get_geo(i);
spgeo[0].x = 0;
@@ -250,3 +259,18 @@ uicb_screen_prev(uicb_t cmd)
return;
}
/** Uicb: screen prev sel
* \param cmd uicb_t type unused
*/
void
uicb_screen_prev_sel(uicb_t cmd)
{
screen_get_sel();
screen_set_sel(prevselscreen);
return;
}

207
src/status.c Normal file
View File

@@ -0,0 +1,207 @@
/*
* status.c
* Copyright © 2008, 2009 Martin Duquesnoy <xorg62@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of the nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "wmfs.h"
/** Check rectangles blocks in str and return properties
* --> \b[x;y;width;height;#color]\
*\param r StatusRec pointer, rectangles properties
*\param str String
*\return n Length of r
*/
int
statustext_rectangle(StatusRec *r, char *str)
{
char as;
int n, i, j, k;
for(i = j = n = 0; i < strlen(str); ++i, ++j)
if(sscanf(&str[i], "\\b[%d;%d;%d;%d;#%x]%c", &r[n].x, &r[n].y, &r[n].w, &r[n].h, &r[n].color, &as) == 6
&& as == '\\')
for(++n, ++i, --j; str[i] != as || str[i - 1] != ']'; ++i);
else if(j != i)
str[j] = str[i];
for(k = j; k < i; str[k++] = 0);
return n;
}
/** Check text blocks in str and return properties
* --> \s[x;y;#color;text]\
*\param s StatusText pointer, text properties
*\param str String
*\return n Length of s
*/
int
statustext_text(StatusText *s, char *str)
{
char as;
int n, i, j, k;
for(i = j = n = 0; i < strlen(str); ++i, ++j)
if(sscanf(&str[i], "\\s[%d;%d;%7[^;];%512[^]]]%c", &s[n].x, &s[n].y, s[n].color, s[n].text, &as) == 5
&& as == '\\')
for(++n, ++i, --j; str[i] != as || str[i - 1] != ']'; ++i);
else if(j != i)
str[j] = str[i];
for(k = j; k < i; str[k++] = 0);
return n;
}
#ifdef HAVE_IMLIB
/** Check images blocks in str and return properties
* --> \i[x;y;w;h;name]\
*\param im ImageAttr pointer, image properties
*\param str String
*\return n Lenght of i
*/
int
statustext_image(ImageAttr *im, char *str)
{
char as;
int n, i, j, k;
for(i = j = n = 0; i < strlen(str); ++i, ++j)
if(sscanf(&str[i], "\\i[%d;%d;%d;%d;%512[^]]]%c", &im[n].x, &im[n].y, &im[n].w, &im[n].h, im[n].name, &as) == 6
&& as == '\\')
for(++n, ++i, --j; str[i] != as || str[i - 1] != ']'; ++i);
else if(j != i)
str[j] = str[i];
for(k = j; k < i; str[k++] = 0);
return n;
}
#endif /* HAVE_IMLIB */
/** Draw normal text and colored normal text
* --> \#color\ text in color
*\param sc Screen
*\param str String
*/
void
statustext_normal(int sc, char *str)
{
char strwc[MAXSTATUS] = { 0 };
char buf[MAXSTATUS] = { 0 };
char col[8] = { 0 };
int n, i, j, k;
for(i = j = n = 0; i < strlen(str); ++i, ++j)
if(str[i] == '\\' && str[i + 1] == '#' && str[i + 8] == '\\')
{
++n;
i += 8;
--j;
}
else
strwc[j] = str[i];
/* Draw normal text without any blocks */
draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(strwc),
FHINFOBAR, infobar[sc].bar->fg, 0, strwc);
if(n)
{
strcpy(buf, strwc);
for(i = k = 0; i < strlen(str); ++i, ++k)
if(str[i] == '\\' && str[i + 1] == '#' && str[i + 8] == '\\')
{
/* Store current color in col[] */
for(j = 0, ++i; str[i] != '\\'; col[j++] = str[i++]);
/* Draw a rectangle with the bar color to draw the text properly */
draw_rectangle(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(&buf[k]),
0, INFOBARH - (sgeo[sc].width - SHADH) - textw(&buf[k]),
INFOBARH, conf.colors.bar);
/* Draw text with its color */
draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(&buf[k]),
FHINFOBAR, col, 0, &buf[k]);
strcpy(buf, strwc);
++i;
}
}
return;
}
/** Handle statustext and draw all things in infobar of specified screen
*\param sc Screen number
*\param str String
*/
void
statustext_handle(int sc, char *str)
{
char *lastst;
int i, nr, ns, len;
StatusRec r[128];
StatusText s[128];
/* If the str == the current statustext, return (not needed) */
if(!str)
return;
barwin_refresh_color(infobar[sc].bar);
/* save last status text address (for free at the end) */
lastst = infobar[sc].statustext;
infobar[sc].statustext = _strdup(str);
len = ((strlen(str) > MAXSTATUS) ? MAXSTATUS : strlen(str));
/* Store rectangles, located text & images properties. */
nr = statustext_rectangle(r, str);
ns = statustext_text(s, str);
/* Draw normal text (and possibly colored with \#color\ blocks) */
statustext_normal(sc, str);
/* Draw rectangles with stored properties. */
for(i = 0; i < nr; ++i)
draw_rectangle(infobar[sc].bar->dr, r[i].x, r[i].y, r[i].w, r[i].h, r[i].color);
/* Draw located text with stored properties. */
for(i = 0; i < ns; ++i)
draw_text(infobar[sc].bar->dr, s[i].x, s[i].y, s[i].color, 0, s[i].text);
barwin_refresh(infobar[sc].bar);
free(lastst);
return;
}

View File

@@ -176,6 +176,8 @@ struct Client
XRectangle frame_geo;
/* Old window attribute */
XRectangle ogeo;
/* Free window attribute */
XRectangle free_geo;
/* For resizehint usage */
int basew, baseh, incw, inch;
int maxw, maxh, minw, minh;
@@ -224,9 +226,9 @@ typedef struct
/* InfoBar Struct */
typedef struct
{
BarWindow *bar;
BarWindow *bar, *selbar;
BarWindow *layout_button;
BarWindow *tags[MAXTAG];
BarWindow *tags_board, *tags[MAXTAG];
XRectangle geo;
int position;
char *statustext;
@@ -301,6 +303,7 @@ typedef struct
XSegment *linecoord;
int nlines;
int nmouse;
uint flags;
} Button;
/* Alias struct */
@@ -321,8 +324,10 @@ typedef struct
Bool raisefocus;
Bool raiseswitch;
Bool focus_fmouse;
Bool ignore_next_client_rules;
uint pad;
int status_timing;
char *status_path;
struct
{
/*
@@ -343,6 +348,7 @@ typedef struct
int height;
MouseBinding *mouse;
int nmouse;
Bool selbar;
} bars;
struct
{
@@ -392,6 +398,7 @@ typedef struct
int *ntag;
Bool tag_round;
Bool layout_system; /* Switch: False, Menu: True. */
Bool layout_placement; /* Right (normal): False, Left: True. */
/* Number of... */
int nkeybind;
int nlayout;
@@ -399,6 +406,25 @@ typedef struct
int nlauncher;
} Conf;
typedef struct
{
uint x, y, w, h;
uint color;
} StatusRec;
typedef struct
{
uint x, y;
char color[8];
char text[512];
} StatusText;
typedef struct
{
uint x, y, w, h;
char name[512];
} ImageAttr;
/* Config.c struct */
typedef struct
{

View File

@@ -28,7 +28,6 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "wmfs.h"
@@ -39,12 +38,11 @@
void
tag_set(int tag)
{
int otag;
Client *c;
screen_get_sel();
otag = seltag[selscreen];
prevseltag[selscreen] = seltag[selscreen];
if(conf.tag_round)
{
@@ -60,13 +58,14 @@ tag_set(int tag)
if(!tag || tag == seltag[selscreen]
|| tag > conf.ntag[selscreen])
return;
seltag[selscreen] = tag;
}
ewmh_update_current_tag_prop();
/* Arrange infobar position */
if(tags[selscreen][otag].barpos != tags[selscreen][seltag[selscreen]].barpos)
if(tags[selscreen][prevseltag[selscreen]].barpos != tags[selscreen][seltag[selscreen]].barpos)
infobar_set_position(tags[selscreen][seltag[selscreen]].barpos);
arrange(selscreen, False);
@@ -106,7 +105,7 @@ tag_transfert(Client *c, int tag)
arrange(c->screen, True);
if(c == sel)
if(c == sel && c->tag != tag)
client_focus(NULL);
client_update_attributes(c);
@@ -171,3 +170,56 @@ uicb_tagtransfert(uicb_t cmd)
return;
}
/** Set the previous selected tag
* \param cmd uicb_t type unused
*/
void
uicb_tag_prev_sel(uicb_t cmd)
{
screen_get_sel();
tag_set(prevseltag[selscreen]);
return;
}
/** Transfert the selected client to the next tag
* \param cmd uicb_t type unused
*/
void
uicb_tagtransfert_next(uicb_t cmd)
{
CHECK(sel);
int tag = seltag[selscreen] + 1;
if(tag > conf.ntag[selscreen])
{
if(!conf.tag_round)
return;
tag = 1;
}
tag_transfert(sel, tag);
return;
}
/** Transfert the selected client to the prev tag
* \param cmd uicb_t type unused
*/
void
uicb_tagtransfert_prev(uicb_t cmd)
{
CHECK(sel);
int tag = seltag[selscreen] - 1;
if(tag <= 0)
{
if(!conf.tag_round)
return;
tag = conf.ntag[selscreen];
}
tag_transfert(sel, tag);
return;
}

View File

@@ -111,7 +111,7 @@ _strdup(const char *str)
usage. {{{
*/
void*
name_to_func(char *name, func_name_list_t *l)
name_to_func(char *name, const func_name_list_t *l)
{
int i;
@@ -150,7 +150,7 @@ char_to_button(char *name, name_to_uint_t blist[])
}
Layout
layout_name_to_struct(Layout lt[], char *name, int n, func_name_list_t llist[])
layout_name_to_struct(Layout lt[], char *name, int n, const func_name_list_t llist[])
{
int i;
@@ -263,3 +263,30 @@ uicb_spawn(uicb_t cmd)
{
spawn("%s", cmd);
}
#ifdef HAVE_IMLIB
/** Check images blocks in str and return properties
* --> \i[x;y;w;h;name]\
*\param im ImageAttr pointer, image properties
*\param str String
*\return n Lenght of i
*/
int
parse_image_block(ImageAttr *im, char *str)
{
char as;
int n, i, j, k;
for(i = j = n = 0; i < strlen(str); ++i, ++j)
if(sscanf(&str[i], "\\i[%d;%d;%d;%d;%512[^]]]%c", &im[n].x, &im[n].y, &im[n].w, &im[n].h, im[n].name, &as) == 6
&& as == '\\')
for(++n, ++i, --j; str[i] != as || str[i - 1] != ']'; ++i);
else if(j != i)
str[j] = str[i];
for(k = j; k < i; str[k++] = 0);
return n;
}
#endif /* HAVE_IMLIB */

View File

@@ -49,6 +49,8 @@ vicmd_to_uicb vicmd[] =
{"sp", "screen_prev"},
{"cc", "client_kill"},
{"ct", "tag_transfert"},
{"ctn", "tag_transfert_next"},
{"ctp", "tag_transfert_prev"},
{"cn", "client_next"},
{"cp", "client_prev"},
{"csn", "client_swap_next"},

View File

@@ -103,7 +103,6 @@ quit(void)
IFREE(infobar);
IFREE(keys);
IFREE(func_list);
IFREE(layout_list);
IFREE(net_atom);
/* Clean conf alloced thing */
@@ -155,7 +154,7 @@ thread_process(void *arg)
{
while(!exiting)
{
spawn(status_path);
spawn(conf.status_path);
sleep(conf.status_timing);
}
@@ -210,11 +209,13 @@ scan(void)
XWindowAttributes wa;
Window usl, usl2, *w = NULL;
Atom rt;
int rf, tag = -1, screen = -1, free = -1;
int s, rf, tag = -1, screen = -1, free = -1;
ulong ir, il;
uchar *ret;
Client *c;
s = screen_count();
if(XQueryTree(dpy, ROOT, &usl, &usl2, &w, &n))
for(i = n - 1; i != -1; --i)
if(XGetWindowAttributes(dpy, w[i], &wa)
@@ -246,7 +247,7 @@ scan(void)
if(tag != -1)
c->tag = tag;
if(screen != -1 && screen <= screen_count() - 1)
if(screen != -1 && screen <= s - 1)
c->screen = screen;
if(free != -1)
c->flags |= (free) ? FreeFlag : 0;
@@ -262,7 +263,7 @@ scan(void)
tags[c->screen][c->tag].request_update = True;
}
for(i = 0; i < screen_count(); ++i)
for(i = 0; i < s; ++i)
arrange(i, True);
XFree(w);

View File

@@ -68,6 +68,10 @@
#include <X11/extensions/Xrandr.h>
#endif /* HAVE_XRANDR */
#ifdef HAVE_IMLIB
#include <Imlib2.h>
#endif /* HAVE_IMLIB */
/* MACRO */
#define ButtonMask (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
#define MouseMask (ButtonMask | PointerMotionMask)
@@ -87,6 +91,7 @@
#define DEF_CONF ".config/wmfs/wmfsrc"
#define DEF_STATUS ".config/wmfs/status.sh"
#define PAD conf.pad
#define MAXSTATUS 4096
#define CWIN(win, parent, x, y, w, h, b, mask, col, at) \
do { \
@@ -126,14 +131,19 @@ void barwin_refresh(BarWindow *bw);
/* draw.c */
void draw_text(Drawable d, int x, int y, char* fg, int pad, char *str);
void draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color);
ushort textw(const char *text);
#ifdef HAVE_IMLIB
void draw_image(Drawable dr, int x, int y, int w, int h, char *name);
#endif /* HAVE_IMLIB */
ushort textw(char *text);
/* infobar.c */
void infobar_init(void);
void infobar_draw(int sc);
void infobar_draw_layout(int sc);
void infobar_draw_selbar(int sc);
void infobar_draw_taglist(int sc);
void infobar_draw_statustext(int sc, char *str);
void infobar_destroy(void);
void infobar_set_position(int pos);
void uicb_infobar_togglepos(uicb_t);
@@ -180,6 +190,8 @@ void uicb_client_screen_next(uicb_t);
void uicb_client_screen_prev(uicb_t);
void uicb_client_move(uicb_t cmd);
void uicb_client_resize(uicb_t cmd);
void uicb_ignore_next_client_rules(uicb_t cmd);
/* ewmh.c */
void ewmh_init_hints(void);
@@ -249,10 +261,10 @@ long getcolor(char *color);
void setwinstate(Window win, long state);
char* _strdup(char const *str);
/* Conf usage {{{ */
void* name_to_func(char *name, func_name_list_t *l);
void* name_to_func(char *name, const func_name_list_t *l);
ulong char_to_modkey(char *name, key_name_list_t key_l[]);
uint char_to_button(char *name, name_to_uint_t blist[]);
Layout layout_name_to_struct(Layout lt[], char *name, int n, func_name_list_t llist[]);
Layout layout_name_to_struct(Layout lt[], char *name, int n, const func_name_list_t llist[]);
char* alias_to_str(char *conf_choice);
/* }}} */
XRectangle get_mouse_pos(void);
@@ -261,6 +273,11 @@ void spawn(const char *str, ...);
void swap_ptr(void **x, void **y);
void uicb_spawn(uicb_t);
#ifdef HAVE_IMLIB
int parse_image_block(ImageAttr *im, char *str);
#endif /* HAVE_IMLIB */
/* tag.c */
void tag_set(int tag);
void tag_transfert(Client *c, int tag);
@@ -268,6 +285,9 @@ void uicb_tag(uicb_t);
void uicb_tag_next(uicb_t);
void uicb_tag_prev(uicb_t);
void uicb_tagtransfert(uicb_t);
void uicb_tag_prev_sel(uicb_t);
void uicb_tagtransfert_next(uicb_t);
void uicb_tagtransfert_prev(uicb_t);
/* screen.c */
int screen_count(void);
@@ -279,6 +299,13 @@ void screen_init_geo(void);
void uicb_screen_select(uicb_t);
void uicb_screen_next(uicb_t);
void uicb_screen_prev(uicb_t);
void uicb_screen_prev_sel(uicb_t);
/* status.c */
int statustext_rectangle(StatusRec *r, char *str);
int statustext_text(StatusText *s, char *str);
void statustext_normal(int sc, char *str);
void statustext_handle(int sc, char *str);
/* layout.c */
void arrange(int screen, Bool update_layout);
@@ -312,7 +339,6 @@ void layout_set_client_master(Client *c);
/* init.c */
void init(void);
void init_root(void);
void init_layout(void);
void init_font(void);
void init_gc(void);
void init_cursor(void);
@@ -352,13 +378,14 @@ void uicb_reload(uicb_t);
Display *dpy;
GC gc, gc_stipple;
int selscreen;
int prevselscreen;
Conf conf;
Key *keys;
Bool exiting, estatus;
XRectangle *sgeo;
XRectangle *spgeo;
Cursor cursor[CurLast];
char *argv_global, *status_path;
char *argv_global;
int xrandr_event;
uint timing;
@@ -372,6 +399,7 @@ Atom *net_atom;
InfoBar *infobar;
Tag **tags;
int *seltag;
int *prevseltag;
Menu menulayout;
/* Important Client */
@@ -380,7 +408,7 @@ Client *sel;
/* Other */
func_name_list_t *func_list;
func_name_list_t *layout_list;
extern const func_name_list_t layout_list[];
uint numlockmask;
#endif /* WMFS_H */

View File

@@ -7,12 +7,14 @@
font = "dejavu-10"
raisefocus = false
focus_follow_mouse = true
status_timing = 1 #seconds
[/misc]
[bar]
bg = "#191919"
fg = "#D4D4D4"
border = true
selbar = false
[/bar]
[layouts]
@@ -25,6 +27,9 @@
# Value menu or switch.
system = "menu"
# Value left or right.
placement = "right"
# Tiling layouts.
[layout] type = "tile_right" symbol = "RIGHT" [/layout]
[layout] type = "tile_left" symbol = "LEFT" [/layout]
@@ -106,6 +111,8 @@
[mouse] button = "3" func = "mouse_resize" [/mouse]
[button]
# Available "free", "max", "tile" flags of button.
flags = "free,max,tile"
[mouse] button = "1" func = "client_kill" [/mouse]
[mouse] button = "3" func = "menu" cmd = "clientmenu" [/mouse]