Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed DEFAULT_MODE line in rc.conf to set each desktop mode

  • Loading branch information...
commit 8be9dd9466e934b5ca8c3996e5b814f8dc363d5e 1 parent 1407148
@moetunes authored
Showing with 34 additions and 48 deletions.
  1. +4 −0 ChangeLog
  2. +0 −18 config.h
  3. +13 −8 readrc.c
  4. +3 −2 sample.rc.conf
  5. +14 −20 snapwm.c
View
4 ChangeLog
@@ -1,3 +1,7 @@
+11/10/12
+ Changed the DEFAULT_MODE line in rc.conf
+ to set the default mode for each desktop
+
10/10/12
Added multi monitor support
View
18 config.h
@@ -6,26 +6,8 @@
#ifndef CONFIG_H
#define CONFIG_H
-#define STATUS_BAR 0 /* 1=Don't 0=Make the bar */
#define FONTS_ERROR 1 /* 1=Don't 0=Print errors about missing fonts */
-// The settings from here to defaultfont[] are in the rc file, which has precedence,
-// so if the rc file all has these 15 options they don't have to be changed.
-
-#define UF_ALPHA 75 /* Percentage transparency for unfocused windows - 100 to turn off */
-#define MASTER_SIZE 55
-#define BORDER_WIDTH 2
-#define RESIZEMOVEKEY MOD1
-#define ATTACH_ASIDE 1 /* 1=Don't 0=Place new window in the stack */
-#define TOP_STACK 0 /* 1=Don't 0=Place new window at the top of the stack when using ATTACH_ASIDE*/
-#define DEFAULT_MODE 4 /* 0=Vertical, 1=Fullscreen 2=Horizontal 3=Grid 4=Stacking*/
-#define FOLLOW_MOUSE 0 /* 1=Don't 0=Focus the window the mouse just entered */
-#define CLICK_TO_FOCUS 1 /* 1=Don't 0=Focus an unfocused window when clicked */
-#define TOP_BAR 0 /* 1=Don't 0=Have the bar at the top instead of the bottom */
-#define SHOW_BAR 0 /* 1=Don't 0=Have the bar shown at startup */
-#define SHOW_NUM_OPEN 1 /* 1=Dont' 0=Show the number of open windows in the switcher */
-#define WINDOW_NAME_LENGTH 35 /* Character length for the current window's name in the bar */
-
static const char *defaultdesktopnames[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", };
static const char *defaultbarcolor[] = { "#ff0000", "#00ff00", "#0000ff", "#000000", };
static const char *defaulttextcolor[] = { "#000000", "#ffffff", "#ffffff", "#ffff00", "#ff00ff", "#f0f0f0", "#0f0f0f", "#000000", "#000000", "#000000", };
View
21 readrc.c
@@ -6,7 +6,7 @@ void read_rcfile() {
char buffer[256];
char dummy[256];
char *dummy2, *dummy3;
- unsigned int i;
+ unsigned int i; int j=-1;
rcfile = fopen( RC_FILE, "rb" ) ;
if ( rcfile == NULL ) {
@@ -58,7 +58,15 @@ void read_rcfile() {
} else if(strstr(buffer, "CLICKTOFOCUS" ) != NULL) {
clicktofocus = atoi(strstr(buffer, " ")+1);
} else if(strstr(buffer, "DEFAULTMODE" ) != NULL) {
- mode = atoi(strstr(buffer, " ")+1);
+ strncpy(dummy, strstr(buffer, " ")+1, strlen(strstr(buffer, " ")+1)-1);
+ dummy[strlen(dummy)-1] = '\0';
+ dummy2 = strdup(dummy);
+ for(i=0;i<DESKTOPS; ++i) {
+ j = atoi(strsep(&dummy2, ";"));
+ if(j > -1 && j < 5)
+ desktops[i].mode = j;
+ if(dummy2 == NULL) break;
+ }
} else if(STATUS_BAR == 0) {
if(strstr(buffer, "SWITCHERTHEME" ) != NULL) {
strncpy(dummy, strstr(buffer, " ")+1, strlen(strstr(buffer, " ")+1)-1);
@@ -177,14 +185,14 @@ void set_defaults() {
if(STATUS_BAR == 0) {
for(i=0;i<4;++i)
theme[i].barcolor = getcolor(defaultbarcolor[i]);
- for(i=0;i<10;++i)
- theme[i].textcolor = getcolor(defaulttextcolor[i]);
for(i=0;i<5;++i)
theme[i].modename = strdup(defaultmodename[i]);
for(i=0;i<10;++i) {
if(!(defaultdesktopnames[i]))
sb_bar[i].label = strdup("?");
else sb_bar[i].label = strdup(defaultdesktopnames[i]);
+ theme[i].textcolor = getcolor(defaulttextcolor[i]);
+ desktops[i].mode = mode;
}
strncpy(font_list, defaultfontlist, strlen(defaultfontlist));
get_font();
@@ -244,11 +252,8 @@ void update_config() {
XFillRectangle(dis, area_sb, theme[0].gc, 0, 0, total_w, sb_height+4);
}
}
- for(i=0;i<DESKTOPS;++i) {
+ for(i=0;i<DESKTOPS;++i)
desktops[i].master_size = (desktops[i].mode == 2) ? (desktops[i].h*msize)/100 : (desktops[i].w*msize)/100;
- if(desktops[i].head == NULL)
- desktops[i].mode = mode;
- }
select_desktop(current_desktop);
Arg a = {.i = mode}; switch_mode(a);
tile();
View
5 sample.rc.conf
@@ -27,8 +27,9 @@ MASTERSIZE 52
ATTACHASIDE 1
# if new window is in the stack add it at the top
TOPSTACK 1
-# default tiling mode: 0=vert,1=fullscreen,2=horiz,3=grid,4=stacking
-DEFAULTMODE 0
+# default tiling modes for each desktop(defaults to 0):
+# 0=vert,1=fullscreen,2=horiz,3=grid,4=stacking
+DEFAULTMODE 3;4;0;1;2;3;
# For semi transparent unfocused windows if using a compositor e.g. compton
UF_WIN_ALPHA 65
# only one of FOLLOWMOUSE and CLICKTOFOCUS should be zero, but none have to be
View
34 snapwm.c
@@ -192,7 +192,7 @@ static unsigned int wc_size(char *string);
// Variable
static Display *dis;
static unsigned int attachaside, bdw, bool_quit, clicktofocus, current_desktop, doresize, dowarp;
-static unsigned int screen, followmouse, mode, msize, previous_desktop, DESKTOPS;
+static unsigned int screen, followmouse, mode, msize, previous_desktop, DESKTOPS, STATUS_BAR;
static int num_screens, growth, sh, sw, master_size, nmaster;
static unsigned int sb_desks; // width of the desktop switcher
static unsigned int sb_height, sb_width, screen, show_bar, has_bar, wnamebg;
@@ -285,8 +285,8 @@ void add_window(Window w, int tw, client *cl) {
c->next = NULL; c->prev = NULL;
dummy = c;
} else {
- if(ATTACH_ASIDE == 0) {
- if(TOP_STACK == 0) {
+ if(attachaside == 0) {
+ if(top_stack == 0) {
c->next = dummy->next; c->prev = dummy;
dummy->next = c;
} else {
@@ -1293,7 +1293,7 @@ void init_desks() {
//printf("**screen is %d - desktop is %d **\n", i, j);
desktops[j].x = info[i].x_org + last_width;
desktops[j].y = info[i].y_org;
- desktops[j].w = info[i].width - BORDER_WIDTH;
+ desktops[j].w = info[i].width - bdw;
if(i == 0 && STATUS_BAR == 0 && show_bar == 0) {
desktops[j].h = info[i].height - (sb_height+4+bdw);
desktops[j].showbar = show_bar;
@@ -1304,7 +1304,7 @@ void init_desks() {
//printf(" x=%d - y=%d - w=%d - h=%d \n", desktops[j].x, desktops[j].y, desktops[j].w, desktops[j].h);
desktops[j].master_size = (mode == 2) ? (desktops[j].h*msize)/100 : (desktops[j].w*msize)/100;
desktops[j].nmaster = 0;
- desktops[j].mode = mode;
+ //desktops[j].mode = mode;
desktops[j].growth = 0;
desktops[j].numwins = 0;
desktops[j].head = NULL;
@@ -1328,21 +1328,15 @@ void setup() {
// Initialize variables
DESKTOPS = 4;
- mode = DEFAULT_MODE;
- msize = MASTER_SIZE;
- ufalpha = UF_ALPHA;
- bdw = BORDER_WIDTH;
- attachaside = ATTACH_ASIDE;
- top_stack = TOP_STACK;
- followmouse = FOLLOW_MOUSE;
- clicktofocus = CLICK_TO_FOCUS;
+ topbar = followmouse = top_stack = mode = 0;
+ LA_WINDOWNAME = wnamebg = dowarp = doresize = 0;
+ msize = 55;
+ ufalpha = 75;
+ bdw = 2;
+ showopen = clicktofocus = attachaside = 1;
resizemovekey = Mod1Mask;
- windownamelength = WINDOW_NAME_LENGTH;
- topbar = TOP_BAR;
- showopen = SHOW_NUM_OPEN;
- LA_WINDOWNAME = wnamebg = 0;
- dowarp = doresize = 0;
- show_bar = STATUS_BAR;
+ windownamelength = 35;
+ show_bar = STATUS_BAR = 0;
char *loc;
loc = setlocale(LC_ALL, "");
@@ -1362,7 +1356,7 @@ void setup() {
setup_status_bar();
status_bar();
update_output(1);
- if(SHOW_BAR > 0) toggle_bar();
+ if(show_bar > 0) toggle_bar();
}
read_apps_file();
Please sign in to comment.
Something went wrong with that request. Please try again.