Layout: Get the selected screen before toggle resizhint.

This commit is contained in:
Martin Duquesnoy 2009-08-19 23:16:10 +02:00
parent 93f2fe49fa
commit 020e2c88c7
8 changed files with 104 additions and 69 deletions

View File

@ -28,7 +28,7 @@ set(wmfs_src
src/confparse/confparse.c
src/barwin.c
src/client.c
# src/config_new.c
# src/config_new.c
src/config.c
src/
src/draw.c

View File

@ -355,6 +355,7 @@ conf_tag_section(char *src)
for(i = 0; i < get_size_sec(src, "tag"); ++i)
{
/* printf("%d -> %s\n", i, (cfgtmp = get_nsec(src, "tag", i)));*/
cfgtmp = get_nsec(src, "tag", i);
j = get_opt(cfgtmp, "-1", "screen").num;
@ -530,6 +531,10 @@ init_conf(void)
func_list = emalloc(LEN(tmp_func_list), sizeof(func_name_list_t));
memcpy(func_list, tmp_func_list, LEN(tmp_func_list) * sizeof(func_name_list_t));
printf("-> %s\n", erase_sec_content(" [pwet] tagada = prout hihi=tralalère [uh] wpwer [/uh] [uh] pwefvbg [/uh] [/pwet] "));
return;
conf_misc_section(get_sec(file, "misc"));
conf_bar_section(get_sec(file, "bar"));
conf_root_section(get_sec(file, "root"));

View File

@ -68,7 +68,7 @@ char*
get_sec(char *src, char *name)
{
char *ret, *p;
char *secn;
char **sec;
if(!src)
return NULL;
@ -76,16 +76,15 @@ get_sec(char *src, char *name)
if(!name)
return src;
secn = emalloc((strlen(name) + 2), sizeof(char));
sprintf(secn, "%c%s%c", SEC_DEL_S, name, SEC_DEL_E);
sec = secname(name);
ret = _strdup(src);
if((p = strstr(erase_delim_content(src), secn)))
if((p = strstr(erase_delim_content(src), sec[SecStart])))
{
ret += strlen(ret) - strlen(p) + strlen(secn) + 1;
ret += strlen(ret) - strlen(p) + strlen(sec[SecStart]) + 1;
if((p = strstr(erase_delim_content(ret), secn)))
if((p = strstr(erase_delim_content(ret), sec[SecEnd])))
*(ret + (strlen(ret) - strlen(p))) = '\0';
else
ret = NULL;
@ -93,7 +92,7 @@ get_sec(char *src, char *name)
else
ret = NULL;
free(secn);
free(sec);
return ret;
}

View File

@ -50,6 +50,8 @@
/* Comment character */
#define COMMENT_CHAR '#'
enum { SecStart, SecEnd, SecLast };
typedef struct
{
long int num;
@ -65,6 +67,7 @@ char *erase_sec_content(char *buf);
char *opt_srch(char *buf, char *opt);
opt_type str_to_opt(char *str);
char *clean_value(char *str);
char **secname(char *name);
/* confparse.c */
char *file_to_str(char *path);

View File

@ -67,6 +67,7 @@ erase_sec_content(char *buf)
{
int i, j;
char *p, *str, *name, *ret;
char *sname;
if(!buf || !(str = erase_delim_content(buf)))
return NULL;
@ -79,7 +80,11 @@ erase_sec_content(char *buf)
for(j = 0; str[i] && str[i - 1] != SEC_DEL_E; name[j++] = str[i++]);
name[j] = '\0';
if((p = strstr(str + i, name)))
sname = emalloc(strlen(name) + 1, sizeof(char));
sprintf(sname, "[/%s]", name);
if((p = strstr(str + i, sname)))
for(++i; i < strlen(ret) - strlen(p); ret[i++] = ' ');
else
return ret;
@ -154,3 +159,25 @@ clean_value(char *str)
return p;
}
char**
secname(char *name)
{
char **ret = NULL;
if(!name)
return NULL;
ret = emalloc(SecLast, sizeof(char*));
/* Len of name + '[' + ']' */
ret[SecStart] = emalloc(strlen(name) + 2, sizeof(char));
/* Len of name + '[' + '/' + ']' */
ret[SecEnd] = emalloc(strlen(name) + 3, sizeof(char));
sprintf(ret[SecStart], "%c%s%c", SEC_DEL_S, name, SEC_DEL_E);
sprintf(ret[SecEnd], "%c/%s%c", SEC_DEL_S, name, SEC_DEL_E);
return ret;
}

View File

@ -734,6 +734,8 @@ uicb_togglemax(uicb_t cmd)
void
uicb_toggle_resizehint(uicb_t cmd)
{
screen_get_sel();
tags[selscreen][seltag[selscreen]].resizehint = !tags[selscreen][seltag[selscreen]].resizehint;
tags[selscreen][seltag[selscreen]].layout.func(selscreen);

View File

@ -102,7 +102,6 @@ _strdup(const char *str)
{
char *ret = emalloc(strlen(str) + 1, sizeof(char));
memset(ret, strlen(str) + 1, 0);
strcpy(ret, str);
return ret;

View File

@ -7,13 +7,13 @@
font = "dejavu-10"
raisefocus = false
focus_follow_mouse = true
[misc]
[/misc]
[bar]
bg = "#191919"
fg = "#D4D4D4"
border = true
[bar]
[/bar]
[layouts]
fg = "#191919"
@ -26,19 +26,19 @@
system = "menu"
# Tiling layouts.
[layout] type = "tile_right" symbol = "RIGHT" [layout]
[layout] type = "tile_left" symbol = "LEFT" [layout]
[layout] type = "tile_top" symbol = "TOP" [layout]
[layout] type = "tile_bottom" symbol = "BOTTOM" [layout]
[layout] type = "tile_grid" symbol = "GRID" [layout]
[layout] type = "mirror_vertical" symbol = "MIRROR_V" [layout]
[layout] type = "mirror_horizontal" symbol = "MIRROR_H" [layout]
[layout] type = "tile_right" symbol = "RIGHT" [/layout]
[layout] type = "tile_left" symbol = "LEFT" [/layout]
[layout] type = "tile_top" symbol = "TOP" [/layout]
[layout] type = "tile_bottom" symbol = "BOTTOM" [/layout]
[layout] type = "tile_grid" symbol = "GRID" [/layout]
[layout] type = "mirror_vertical" symbol = "MIRROR_V" [/layout]
[layout] type = "mirror_horizontal" symbol = "MIRROR_H" [/layout]
# Other layouts.
[layout] type = "max" symbol = "MAX" [layout]
[layout] type = "free" symbol = "FREE" [layout]
[layout] type = "max" symbol = "MAX" [/layout]
[layout] type = "free" symbol = "FREE" [/layout]
[layouts]
[/layouts]
[tags]
tag_round = false
@ -57,26 +57,26 @@
layout = "tile_right"
resizehint = false
infobar_position = "top"
[tag]
[/tag]
[tag] name = "two" clients = {"pwet,"}[tag]
[tag] name = "three" [tag]
[tag] name = "four" [tag]
[tag] name = "five" [tag]
[tag] name = "six" [tag]
[tag] name = "seven" [tag]
[tag] name = "eight" [tag]
[tag] name = "nine" [tag]
[tags]
[tag] name = "two" clients = {"Browser"} [/tag]
[tag] name = "three" [/tag]
[tag] name = "four" [/tag]
[tag] name = "five" [/tag]
[tag] name = "six" [/tag]
[tag] name = "seven" [/tag]
[tag] name = "eight" [/tag]
[tag] name = "nine" [/tag]
[/tags]
[root]
# Command you can execute to set the background.
background_command = "xsetroot -solid black"
[mouse] button = "4" func = "tag_next" [mouse]
[mouse] button = "5" func = "tag_prev" [mouse]
[mouse] button = "3" func = "menu" cmd = "rootmenu" [mouse]
[root]
[mouse] button = "4" func = "tag_next" [/mouse]
[mouse] button = "5" func = "tag_prev" [/mouse]
[mouse] button = "3" func = "menu" cmd = "rootmenu" [/mouse]
[/root]
[client]
border_height = 3
@ -88,10 +88,10 @@
modifier = "Alt"
[mouse] button = "1" func = "client_raise" [mouse]
[mouse] button = "1" func = "mouse_move" [mouse]
[mouse] button = "3" func = "client_raise" [mouse]
[mouse] button = "3" func = "mouse_resize" [mouse]
[mouse] button = "1" func = "client_raise" [/mouse]
[mouse] button = "1" func = "mouse_move" [/mouse]
[mouse] button = "3" func = "client_raise" [/mouse]
[mouse] button = "3" func = "mouse_resize" [/mouse]
# Remove this section to delete the titlebar.
[titlebar]
@ -100,21 +100,21 @@
fg_normal = "#7E89A2"
fg_focus = "#9F9AB3"
[mouse] button = "1" func = "client_raise" [mouse]
[mouse] button = "1" func = "mouse_move" [mouse]
[mouse] button = "3" func = "client_raise" [mouse]
[mouse] button = "3" func = "mouse_resize" [mouse]
[mouse] button = "1" func = "client_raise" [/mouse]
[mouse] button = "1" func = "mouse_move" [/mouse]
[mouse] button = "3" func = "client_raise" [/mouse]
[mouse] button = "3" func = "mouse_resize" [/mouse]
[button]
[mouse] button = "1" func = "client_kill" [mouse]
[mouse] button = "3" func = "menu" cmd = "clientmenu" [mouse]
[mouse] button = "1" func = "client_kill" [/mouse]
[mouse] button = "3" func = "menu" cmd = "clientmenu" [/mouse]
[line] coord = {1, 1, 4, 1} [line]
[line] coord = {1, 1, 1, 4} [line]
[line] coord = {1, 4, 4, 4} [line]
[button]
[titlebar]
[client]
[line] coord = {1, 1, 4, 1} [/line]
[line] coord = {1, 1, 1, 4} [/line]
[line] coord = {1, 4, 4, 4} [/line]
[/button]
[/titlebar]
[/client]
[menu]
# Default menu, binded on the root window, button 3.
@ -127,14 +127,14 @@
fg_focus = "#191919" bg_focus = "#7E89A2"
fg_normal = "#9F9AB3" bg_normal = "#191919"
[item] name = "Terminal" func = "spawn" cmd = term [item]
[item] name = "Next tag" func = "tag_next" [item]
[item] name = "Previous tag" func = "tag_prev" [item]
[item] name = "Next layout" func = "layout_next" [item]
[item] name = "Previous layout" func = "layout_prev" [item]
[item] name = "Toggle infobar" func = "toggle_infobar_position" [item]
[item] name = "Quit WMFS" func = "quit" [item]
[set_menu]
[item] name = "Terminal" func = "spawn" cmd = term [/item]
[item] name = "Next tag" func = "tag_next" [/item]
[item] name = "Previous tag" func = "tag_prev" [/item]
[item] name = "Next layout" func = "layout_next" [/item]
[item] name = "Previous layout" func = "layout_prev" [/item]
[item] name = "Toggle infobar" func = "toggle_infobar_position" [/item]
[item] name = "Quit WMFS" func = "quit" [/item]
[/set_menu]
[set_menu]
name = "clientmenu"
@ -142,25 +142,25 @@
fg_focus = "#D4D4D4" bg_focus = "#003366"
fg_normal = "#D4D4D4" bg_normal = "#191919"
[item] name = "Close" func = "client_kill" [item]
[item] name = "Maximize" func = "toggle_max" [item]
[item] name = "Free" func = "toggle_free" [item]
[set_menu]
[menu]
[item] name = "Close" func = "client_kill" [/item]
[item] name = "Maximize" func = "toggle_max" [/item]
[item] name = "Free" func = "toggle_free" [/item]
[/set_menu]
[/menu]
[launcher]
[set_launcher]
name = "launcher_exec"
prompt = "Exec: "
command = "exec"
[set_launcher]
[/set_launcher]
[set_launcher]
[/set_launcher]
name = "launcher_ssh"
prompt = "ssh to: "
command = "urxvt -e ssh"
[set_launcher]
[launcher]
[/set_launcher]
[/launcher]
[keys]
# Reload the configuration of wmfs.