Skip to content

Commit

Permalink
Import dwm-win32-alpha2
Browse files Browse the repository at this point in the history
  • Loading branch information
martanne committed Jun 29, 2009
1 parent 90f3671 commit 78b68fd
Show file tree
Hide file tree
Showing 4 changed files with 490 additions and 181 deletions.
167 changes: 157 additions & 10 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,164 @@
dwm-win32 is a port of the well known X11 window manager dwm to the Microsoft Windows platform.
dwm-win32 is a port of the well known X11 window manager dwm to Microsoft Windows.

Description
===========

dwm is a dynamic window manager for Microsoft Windows. It manages windows in tiled,
monocle and floating layouts. Either layout can be applied dynamically, optimising
the environment for the application in use and the task performed.

In tiled layouts windows are managed in a master and stacking area. The master area
contains the window which currently needs most attention, whereas the stacking area
contains all other windows. In monocle layout all windows are maximised to the screen
size. In floating layout windows can be resized and moved freely. Dialog windows are
always managed floating, regardless of the layout applied.

Windows are grouped by tags. Each window can be tagged with one or multiple tags.
Selecting certain tags displays all windows with these tags.

dwm contains a small status bar which displays all available tags, the layout, the
title of the focused window, and the text read from the root window name property.
A floating window is indicated with an empty square and a maximised floating window
is indicated with a filled square before the windows title. The selected tags are
indicated with a different color. The tags of the focused window are indicated with
a filled square in the top left corner. The tags which are applied to one or more
windows are indicated with an empty square in the top left corner.

dwm draws a small border around windows to indicate the focus state.


Usage
=====

Keyboard

dwm uses a modifier key by default this is CTRL + ALT.

MOD + Shift + Return
- start cmd.exe.

MOD + b
- Toggles bar on and off.

MOD + e
- Toogles windows explorer and taskbar on and off.

MOD + t
- Sets tiled layout.

MOD + f
- Sets floating layout.

MOD + m
- Sets monocle layout.

MOD + space
- Toggles between current and previous layout.

MOD + j
- Focus next window.

MOD + k
- Focus previous window.

MOD + h
- Decrease master area size.

MOD + l
- Increase master area size.

MOD + Return
- Zooms/cycles focused window to/from master area (tiled layouts only).

MOD + Shift + c
- Close focused window.

MOD + Shift + Space
- Toggle focused window between tiled and floating state.

MOD + n
- Toggles border of currently focused window.

Mod + i
- Display classname of currently focused window, useful for wiriting tagging rules.

MOD + Tab
- Toggles to the previously selected tags.

MOD + Shift + [1..n]
- Apply nth tag to focused window.

MOD + Shift + 0
- Apply all tags to focused window.

MOD + Control + Shift + [1..n]
- Add/remove nth tag to/from focused window.

MOD + [1..n]
- View all windows with nth tag.

MOD + 0
- View all windows with any tag.

MOD + Control + [1..n]
- Add/remove all windows with nth tag to/from the view.

MOD + q
- Quit dwm.


Mouse

Left Button
- click on a tag label to display all windows with that tag, click on the layout
label toggles between tiled and floating layout.

Right Button
- click on a tag label adds/removes all windows with that tag to/from the view.

Alt + Left Button
- click on a tag label applies that tag to the focused window.

Alt + Right Button
- click on a tag label adds/removes that tag to/from the focused window.


How it works
============

A ShellHook is registered which is notified upon window creation and destruction,
however it is important to know that this only works for unowned top level windows.
This means we will not get notified when child windows are created/destroyed.
Therefore we scan the currently active top level window upon activation to collect
all associated child windows. This information is for example used to tag all windows
and not just the toplevel one when tag changes occur.

This is all kind of messy and we might miss some child windows in certain situations.
A better approach would probably be to introduce a CBTProc function and register it
with SetWindowsHookEx(WH_CBT, ...) with this we would get notified by all and every
windows including toolbars etc. which we would have to filter out.

Unfortunately the SetWindowsHookEx thingy seems to require a separate dll because it
will be loaded into each process address space.

TODO
- focus handling / stealling / floating windows (ex. WinSCP)
- fix redraw problems which happen from time to time
- fullscreen windows? Screensaver?
- window border currently it's drawn into the client area which is bad
====
- show/hide child windows upon tag switch, in theory this should already work but
in practice we need to tweak ismanageable() so that it recognises child windows
but doesn't generate false positives.
- fullscreen windows, mstsc for example doesn't resize properly when maximized.
- Screensaver?
- system dialogs from desktop window
- urgent flag?
- window border isn't yet perfect
- status text via stdin or a separate tool
- crash handler which makes all windows visible restores borders etc
- use BeginDeferWindowPos, DeferWindowPos and EndDeferWindowPos
- optimize for speed
- code cleanups all over the place
- multi head support?

[ - introduce a ShellProc function and register it with SetWindowsHookEx
to handle window events instead of current mechanism in WndProc which
is based on the shellhookid but seems to be bugy in some cases?.
Unfortunately the SetWindowsHookEx thingy seems to require a separate
dll which sucks. ]
[ - introduce a CBTProc function and register it with SetWindowsHookEx(WH_CBT, ...)
to handle window events instead of the current mechanism in WndProc which
is based on the shellhookid and WH_SHELL because this only works for
toplevel windows. See also the "How it works" section. ]
81 changes: 40 additions & 41 deletions config.def.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* See LICENSE file for copyright and license details. */

/* appearance */
static const COLORREF normbordercolor = RGB(204, 204, 204);
static const COLORREF normbgcolor = RGB(204, 204, 204);
static const COLORREF normfgcolor = RGB(0,0,0);
static const COLORREF selbordercolor = RGB(0,102,255);
static const COLORREF selbgcolor = RGB(0,102,255);
static const COLORREF selfgcolor = RGB(255,255,255);
/* appearance, colors are specified in the form 0x00bbggrr or with the RGB(r, g, b) macro */
#define normbordercolor 0x00cccccc
#define normbgcolor 0x00cccccc
#define normfgcolor 0x00000000
#define selbordercolor 0x00ff6600
#define selbgcolor 0x00ff6600
#define selfgcolor 0x00ffffff

static const unsigned int borderpx = 2; /* border pixel of windows */
static const unsigned int textmargin = 5; /* margin for the text displayed on the bar */
Expand Down Expand Up @@ -47,40 +47,39 @@ static Layout layouts[] = {
static const char *termcmd[] = { "cmd.exe", NULL };

static Key keys[] = {
/* modifier key function argument */
{ MODKEY, 'P', spawn, {.v = termcmd } },
{ MODKEY|MOD_SHIFT, VK_RETURN, spawn, {.v = termcmd } },
{ MODKEY, 'B', togglebar, {0} },
{ MODKEY, 'J', focusstack, {.i = +1 } },
{ MODKEY, 'K', focusstack, {.i = -1 } },
{ MODKEY, 'H', setmfact, {.f = -0.05} },
{ MODKEY, 'L', setmfact, {.f = +0.05} },
{ MODKEY, 'I', showclientclassname, {0} },
{ MODKEY, VK_RETURN, zoom, {0} },
{ MODKEY, VK_TAB, view, {0} },
{ MODKEY|MOD_SHIFT, 'C', killclient, {0} },
{ MODKEY, 'T', setlayout, {.v = &layouts[0]} },
{ MODKEY, 'F', setlayout, {.v = &layouts[1]} },
{ MODKEY, 'M', setlayout, {.v = &layouts[2]} },
{ MODKEY, VK_SPACE, setlayout, {0} },
{ MODKEY|MOD_SHIFT, VK_SPACE, togglefloating, {0} },
{ MODKEY, 'N', toggleborder, {0} },
{ MODKEY, 'E', toggleexplorer, {0} },

{ MODKEY, '0', view, {.ui = ~0 } },
{ MODKEY|MOD_SHIFT, '0', tag, {.ui = ~0 } },
TAGKEYS( '1', 0)
TAGKEYS( '2', 1)
TAGKEYS( '3', 2)
TAGKEYS( '4', 3)
TAGKEYS( '5', 4)
TAGKEYS( '6', 5)
TAGKEYS( '7', 6)
TAGKEYS( '8', 7)
TAGKEYS( '9', 8)
{ MODKEY, 'Q', quit, {0} },
/* modifier key function argument */
{ MODKEY|MOD_SHIFT, VK_RETURN, spawn, {.v = termcmd } },
{ MODKEY, 'B', togglebar, {0} },
{ MODKEY, 'J', focusstack, {.i = +1 } },
{ MODKEY, 'K', focusstack, {.i = -1 } },
{ MODKEY, 'H', setmfact, {.f = -0.05} },
{ MODKEY, 'L', setmfact, {.f = +0.05} },
{ MODKEY, 'I', showclientclassname, {0} },
{ MODKEY, VK_RETURN, zoom, {0} },
{ MODKEY, VK_TAB, view, {0} },
{ MODKEY|MOD_SHIFT, 'C', killclient, {0} },
{ MODKEY, 'T', setlayout, {.v = &layouts[0]} },
{ MODKEY, 'F', setlayout, {.v = &layouts[1]} },
{ MODKEY, 'M', setlayout, {.v = &layouts[2]} },
{ MODKEY, VK_SPACE, setlayout, {0} },
{ MODKEY|MOD_SHIFT, VK_SPACE, togglefloating, {0} },
{ MODKEY, 'N', toggleborder, {0} },
{ MODKEY, 'E', toggleexplorer, {0} },
{ MODKEY, '0', view, {.ui = ~0 } },
{ MODKEY|MOD_SHIFT, '0', tag, {.ui = ~0 } },
TAGKEYS( '1', 0)
TAGKEYS( '2', 1)
TAGKEYS( '3', 2)
TAGKEYS( '4', 3)
TAGKEYS( '5', 4)
TAGKEYS( '6', 5)
TAGKEYS( '7', 6)
TAGKEYS( '8', 7)
TAGKEYS( '9', 8)
{ MODKEY, 'Q', quit, {0} },
};


/* button definitions */
/* click can be a tag number (starting at 0), ClkLtSymbol, ClkStatusText or ClkWinTitle */
static Button buttons[] = {
Expand All @@ -92,8 +91,8 @@ static Button buttons[] = {
#if 0
{ ClkClientWin, WM_MBUTTONDOWN, MODKEY, togglefloating, {0} },
#endif
{ ClkTagBar, WM_LBUTTONDOWN, VK_MENU, tag, {0} },
{ ClkTagBar, WM_RBUTTONDOWN, VK_MENU, toggletag, {0} },
{ ClkTagBar, WM_LBUTTONDOWN, 0, view, {0} },
{ ClkTagBar, WM_RBUTTONDOWN, 0, toggleview, {0} },
{ ClkTagBar, WM_LBUTTONDOWN, MODKEY, tag, {0} },
{ ClkTagBar, WM_RBUTTONDOWN, MODKEY, toggletag, {0} },
};
32 changes: 16 additions & 16 deletions config.mk
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# dwm-win32 version
VERSION = alpha1

# Customize below to fit your system

# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man

# flags
CPPFLAGS = -DVERSION=\"${VERSION}\"
CFLAGS = -std=c99 -pedantic -Wall -Os ${CPPFLAGS}
LDFLAGS = -s -mwindows

# compiler and linker
CC = gcc
# dwm-win32 version
VERSION = alpha2

# Customize below to fit your system

# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man

# flags
CPPFLAGS = -DVERSION=\"${VERSION}\"
CFLAGS = -std=c99 -pedantic -Wall -Os ${CPPFLAGS}
LDFLAGS = -s -mwindows

# compiler and linker
CC = gcc
Loading

0 comments on commit 78b68fd

Please sign in to comment.