aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/README12
-rwxr-xr-xsrc/config.h16
-rwxr-xr-xsrc/dminiwm.c89
3 files changed, 103 insertions, 14 deletions
diff --git a/src/README b/src/README
index 7a7e668..914ad69 100644
--- a/src/README
+++ b/src/README
@@ -8,7 +8,7 @@ Summary
dminiwm is a very minimal and lightweight dynamic tiling window manager.
I will try to stay under 1000 SLOC.
- Currently well under 900 lines with the config file included.
+ Currently well under 800 lines with the config file included.
Modes
@@ -26,6 +26,15 @@ It allows the "normal" method of tiling window managers(with the new window as t
| | |
--------------
+ There's horizontal tiling mode:
+ --------------
+ | |
+ | Master |
+ |____________|
+ | | |
+ | W | |
+ --------------
+
Fullscreen mode(which you'll know when you see it)
All accessible with keyboard shortcuts defined in the config.h file.
@@ -45,6 +54,7 @@ Status
There are a couple more options in the config file than the original catwm.
Fixed the window manager crashing on a bad window error.
Fixed the keyboard shortcuts not working if numlock was on.
+ Added option to focus the window the mouse moves into
Added option to resize window on the top of the stack.
diff --git a/src/config.h b/src/config.h
index ea4a5c3..81380e3 100755
--- a/src/config.h
+++ b/src/config.h
@@ -1,8 +1,8 @@
- /* config.h for dminiwm.c [ 0..0.1 ]
+ /* config.h for dminiwm.c [ 0..0.2 ]
*
- * Started from catwm 31/12/10 with many thanks !
+ * Started from catwm 31/12/10
* Bad window error checking and numlock checking used from
- * 2wm at http://hg.suckless.org/2wm/ with many thanks !
+ * 2wm at http://hg.suckless.org/2wm/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,6 +32,7 @@
#define BORDER_WIDTH 2
#define ATTACH_ASIDE 1 /* 0=TRUE, 1=New window is master */
#define DEFAULT_MODE 0 /* 0 = Vertical, 1 = Fullscreen */
+#define FOLLOW_MOUSE 0 /* 1=Don't 0=Focus the window the mouse just entered */
// Colors
#define FOCUS "#664422" // dkorange
@@ -44,9 +45,9 @@ const char* thunarcmd[] = {"thunar",NULL};
const char* firefoxcmd[] = {"firefox",NULL};
const char* conkerorcmd[] = {"conkeror",NULL};
const char* mailcmd[] = {"thunderbird",NULL };
-const char* voldowncmd[] = {"/home/pnewm/bin/voldown",NULL};
-const char* volupcmd[] = {"/home/pnewm/bin/volup",NULL};
-const char* vols_what[] = {"/home/pnewm/bin/volumes_what",NULL};
+const char* voldowncmd[] = {"/home/pnewm/.bin/voldown",NULL};
+const char* volupcmd[] = {"/home/pnewm/.bin/volup",NULL};
+const char* vols_what[] = {"/home/pnewm/.bin/volumes_what",NULL};
// for reboot and shutdown
const char* rebootcmd[] = {"sudo","reboot",NULL};
const char* shutdowncmd[] = {"sudo","shutdown","-h","now",NULL};
@@ -71,7 +72,10 @@ static key keys[] = {
{ MOD1, XK_Up, spawn, {.com = volupcmd}},
{ MOD1, XK_Down, spawn, {.com = voldowncmd}},
// alt + shift + shortcut
+ { MOD1|ShiftMask, XK_j, move_up, {NULL}},
+ { MOD1|ShiftMask, XK_k, move_down, {NULL}},
{ MOD1|ShiftMask, XK_Return, swap_master, {NULL}},
+ { MOD1|ShiftMask, XK_h, switch_horizontal, {NULL}},
{ MOD1|ShiftMask, XK_m, switch_fullscreen, {NULL}},
{ MOD1|ShiftMask, XK_v, switch_vertical, {NULL}},
// Control + alt + shortcut
diff --git a/src/dminiwm.c b/src/dminiwm.c
index 4ee82e8..8b53f9c 100755
--- a/src/dminiwm.c
+++ b/src/dminiwm.c
@@ -1,8 +1,8 @@
-/* dminiwm.c [ 0.0.1 ]
+/* dminiwm.c [ 0.0.2 ]
*
-* I started this from catwm 31/12/10 with many thanks!
+* I started this from catwm 31/12/10
* Bad window error checking and numlock checking used from
-* 2wm at http://hg.suckless.org/2wm/ with many thanks !
+* 2wm at http://hg.suckless.org/2wm/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -68,6 +68,7 @@ static void configurenotify(XEvent *e);
static void configurerequest(XEvent *e);
static void decrease();
static void destroynotify(XEvent *e);
+static void enternotify(XEvent *e);
static void logger(const char* e);
static unsigned long getcolor(const char* color);
static void grabkeys();
@@ -76,6 +77,8 @@ static void increase();
static void keypress(XEvent *e);
static void kill_client();
static void maprequest(XEvent *e);
+static void move_down();
+static void move_up();
static void next_desktop();
static void next_win();
static void prev_desktop();
@@ -93,6 +96,7 @@ static void start();
static void swap_master();
static void tile();
static void switch_fullscreen();
+static void switch_horizontal();
static void switch_vertical();
static void update_current();
@@ -122,6 +126,7 @@ static client *current;
static void (*events[LASTEvent])(XEvent *e) = {
[KeyPress] = keypress,
[MapRequest] = maprequest,
+ [EnterNotify] = enternotify,
[DestroyNotify] = destroynotify,
[ConfigureNotify] = configurenotify,
[ConfigureRequest] = configurerequest
@@ -170,6 +175,9 @@ void add_window(Window w) {
current = c;
save_desktop(current_desktop);
+ // for folow mouse
+ if(FOLLOW_MOUSE == 0)
+ XSelectInput(dis, c->win, EnterWindowMask);
}
void remove_window(Window w) {
@@ -259,6 +267,33 @@ void prev_win() {
}
}
+void move_down() {
+ Window tmp;
+ if(current == NULL || current->next == NULL || current->win == head->win || current->prev == NULL)
+ return;
+
+ tmp = current->win;
+ current->win = current->next->win;
+ current->next->win = tmp;
+ //keep the moved window activated
+ next_win();
+ save_desktop(current_desktop);
+ tile();
+}
+
+void move_up() {
+ Window tmp;
+ if(current == NULL || current->prev == head || current->win == head->win) {
+ return;
+ }
+ tmp = current->win;
+ current->win = current->prev->win;
+ current->prev->win = tmp;
+ prev_win();
+ save_desktop(current_desktop);
+ tile();
+}
+
void swap_master() {
Window tmp;
@@ -407,6 +442,20 @@ void tile() {
XMoveResizeWindow(dis,c->win,0,0,sw-BORDER_WIDTH,sh-BORDER_WIDTH);
}
break;
+ case 2: /* Horizontal */
+ // Master window
+ XMoveResizeWindow(dis,head->win,0,0,sw-BORDER_WIDTH,master_size - BORDER_WIDTH);
+
+ // Stack
+ for(c=head->next;c;c=c->next) ++n;
+ if(n == 1) growth = 0;
+ XMoveResizeWindow(dis,head->next->win,0,master_size + BORDER_WIDTH,(sw/n)+growth-BORDER_WIDTH,sh-master_size-(2*BORDER_WIDTH));
+ x = (sw/n)+growth;
+ for(c=head->next->next;c;c=c->next) {
+ XMoveResizeWindow(dis,c->win,x,master_size + BORDER_WIDTH,(sw/n)-(growth/(n-1)) - BORDER_WIDTH,sh-master_size-(2*BORDER_WIDTH));
+ x += (sw/n)-(growth/(n-1));
+ }
+ break;
}
}
}
@@ -428,6 +477,15 @@ void update_current() {
XSync(dis, False);
}
+void switch_vertical() {
+ if(mode != 0) {
+ mode = 0;
+ master_size = sw * MASTER_SIZE;
+ tile();
+ update_current();
+ }
+}
+
void switch_fullscreen() {
if(mode != 1) {
mode = 1;
@@ -436,10 +494,11 @@ void switch_fullscreen() {
}
}
-void switch_vertical() {
- if(mode != 0) {
- mode = 0;
- tile();
+void switch_horizontal() {
+ if(mode != 2) {
+ mode = 2;
+ master_size = sh * MASTER_SIZE;
+ tile();
update_current();
}
}
@@ -549,6 +608,22 @@ void destroynotify(XEvent *e) {
select_desktop(tmp);
}
+void enternotify(XEvent *e) {
+ client *c;
+ XCrossingEvent *ev = &e->xcrossing;
+
+ if(FOLLOW_MOUSE == 0) {
+ if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
+ return;
+ for(c=head;c;c=c->next)
+ if(ev->window == c->win) {
+ current = c;
+ update_current();
+ return;
+ }
+ }
+}
+
void send_kill_signal(Window w) {
XEvent ke;
ke.type = ClientMessage;