summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile23
-rw-r--r--README48
-rw-r--r--x-alt-tab.c15
-rw-r--r--x-move-resize.c112
-rw-r--r--x-session.c5
5 files changed, 203 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..33249c5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,23 @@
+PREFIX = /usr/local/
+SRC = x-session.c
+X11SRC = x-move-resize.c x-alt-tab.c
+
+CC = gcc
+CFLAGS = -O2 -Wall
+X11LIB = -lX11 -L/usr/X11/lib
+
+BIN = ${SRC:.c=}
+X11BIN = ${X11SRC:.c=}
+all: $(BIN) $(X11BIN)
+
+$(BIN): %: %.c
+ $(CC) $(CFLAGS) $^ -o $@
+
+$(X11BIN): %: %.c
+ $(CC) $(CFLAGS) $(X11LIB) $^ -o $@
+
+clean:
+ rm $(BIN) $(X11BIN)
+
+install:
+ install -m 0755 $(BIN) $(X11BIN) ${PREFIX}/bin/.
diff --git a/README b/README
new file mode 100644
index 0000000..7efcb5e
--- /dev/null
+++ b/README
@@ -0,0 +1,48 @@
+nowm
+ using X11 without a window manager
+
+component
+ included
+ x-alt-tab
+ x-move-resize
+ x-session
+ distributed with X11
+ xsel xprop xrdb xset xsetroot
+ key-daemons
+ xbindkeys http://www.nongnu.org/xbindkeys/xbindkeys.html
+ speckeysd http://www.jessies.org/~enh/software/x11/
+ window-manipulators
+ xdotool http://www.semicomplete.com/projects/xdotool/
+ window http://www.jessies.org/~enh/software/x11/
+ niceties
+ unclutter http://unclutter.sourceforge.net/
+ dmenu http://tools.suckless.org/dmenu/
+ autocutsel http://www.nongnu.org/autocutsel/
+
+procedure
+ set up your ${HOME}/.xinitrc to be something like
+ #!/bin/bash
+ xrdb -merge ${HOME}/etc/Xresources
+ xsetroot -solid black
+ exec xterm &
+ exec speckeysd ${HOME}/etc/speckeysd.conf &
+ exec x-session
+ and your ${HOME}/etc/speckeysd.conf to be like
+ # Key names come from <X11/keysymdef.h> (remove the XK_ prefix).
+ # MUST have a Tab separating the key-combo and command
+ Alt-Tab x-alt-tab
+ Alt-Shift-Tab x-alt-tab -1
+ Control-Alt-r echo run | dmenu -fn 10x20 | exec bash -s
+ Control-Alt-s surf "$( echo www.duckduckgo.com | dmenu )"
+ Control-Alt-t urxvt || rxvt || xterm
+ Alt-F1 x-move-resize
+ F10 xdotool getwindowfocus windowsize 100% 100% windowmove 0 0
+ then ${HOME}/etc/Xresources with the preferred window geometries
+ R_x11*geometry: 1024x600+0+0
+ XTerm*geometry: 1024x600+0+0
+ URxvt*geometry: 1024x600+0+0
+ surf*geometry: 1024x600+0+0
+
+
+window managers bind orthogonals (keyboard shortcuts, window manipulation, window decoration)
+which should remain separate.
diff --git a/x-alt-tab.c b/x-alt-tab.c
new file mode 100644
index 0000000..e8d4355
--- /dev/null
+++ b/x-alt-tab.c
@@ -0,0 +1,15 @@
+#include <X11/Xlib.h>
+
+int main(int argc, char **argv)
+{
+ Display *dpy;
+
+ if(!(dpy = XOpenDisplay(0x0))) return 1;
+ if (argc > 1)
+ XCirculateSubwindowsDown(dpy, DefaultRootWindow(dpy));
+ else
+ XCirculateSubwindowsUp(dpy, DefaultRootWindow(dpy));
+ XSync(dpy, True);
+ return 0;
+}
+
diff --git a/x-move-resize.c b/x-move-resize.c
new file mode 100644
index 0000000..b8911e3
--- /dev/null
+++ b/x-move-resize.c
@@ -0,0 +1,112 @@
+/* TinyWM is written by Nick Welch <mack AT incise.org>, 2005.
+ *
+ * This software is in the public domain
+ * and is provided AS IS, with NO WARRANTY. */
+
+#include <errno.h>
+#include <sys/select.h>
+#include <X11/Xlib.h>
+#include <X11/cursorfont.h>
+
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
+/* interruptibleXNextEvent() is taken from the Blender source and comes with
+ * the following copyright notice: */
+
+/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. */
+
+/* This program is freely distributable without licensing fees
+ * and is provided without guarantee or warrantee expressed or
+ * implied. This program is -not- in the public domain. */
+
+/* Unlike XNextEvent, if a signal arrives, interruptibleXNextEvent will
+ * return zero. */
+
+static int interruptibleXNextEvent(Display *dpy, XEvent *event) {
+ fd_set fds;
+ int rc;
+ int dpy_fd = ConnectionNumber(dpy);
+ for (;;) {
+ if (XPending(dpy)) {
+ XNextEvent(dpy, event);
+ return 1;
+ }
+ FD_ZERO(&fds);
+ FD_SET(dpy_fd, &fds);
+ rc = select(dpy_fd + 1, &fds, NULL, NULL, NULL);
+ if (rc < 0) {
+ if (errno == EINTR) {
+ return 0;
+ }
+ // LOG_ERROR("interruptibleXNextEvent(): select()\n");
+ }
+ }
+}
+
+int die(Display *dpy, int return_value) {
+ XUngrabPointer(dpy, CurrentTime);
+ XCloseDisplay(dpy);
+ return return_value;
+}
+
+int main()
+{
+ Display * dpy;
+ Window root;
+ XWindowAttributes attr;
+ XButtonEvent start;
+ XEvent ev;
+ Cursor cursor;
+ int cursor_shape = XC_X_cursor;
+ start.button = 0; start.x_root = 0; start.y_root = 0;
+
+ if(!(dpy = XOpenDisplay(0x0))) return 1;
+
+ root = DefaultRootWindow(dpy);
+
+ XGrabButton(dpy, 1, 0, root, True, ButtonPressMask, GrabModeAsync,
+ GrabModeAsync, None, None);
+ XGrabButton(dpy, 3, 0, root, True, ButtonPressMask, GrabModeAsync,
+ GrabModeAsync, None, None);
+
+
+ cursor = XCreateFontCursor(dpy, cursor_shape);
+ XDefineCursor(dpy, root, cursor);
+ XSync (dpy, root); /* give xterm a chance */
+ if (XGrabPointer (dpy, root, False, (ButtonPressMask | PointerMotionMask | ButtonReleaseMask),
+ GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime) != GrabSuccess)
+ return die(dpy, 1);
+
+ for(;;)
+ {
+ if (! interruptibleXNextEvent(dpy, &ev))
+ continue;
+ switch(ev.type) {
+ case ButtonPress:
+ if (ev.xbutton.subwindow == None)
+ break;
+ if( XGrabPointer(dpy, ev.xbutton.subwindow, False,
+ PointerMotionMask|ButtonReleaseMask, GrabModeAsync,
+ GrabModeAsync, None, cursor, CurrentTime) != GrabSuccess)
+ return die(dpy, 1);
+ XGetWindowAttributes(dpy, ev.xbutton.subwindow, &attr);
+ start = ev.xbutton;
+ break;
+ case MotionNotify: {
+ int xdiff, ydiff;
+ while (XCheckTypedEvent(dpy, MotionNotify, &ev));
+ xdiff = ev.xbutton.x_root - start.x_root;
+ ydiff = ev.xbutton.y_root - start.y_root;
+ XMoveResizeWindow(dpy, ev.xmotion.window,
+ attr.x + (start.button==1 ? xdiff : 0),
+ attr.y + (start.button==1 ? ydiff : 0),
+ MAX(1, attr.width + (start.button==3 ? xdiff : 0)),
+ MAX(1, attr.height + (start.button==3 ? ydiff : 0)));
+ }
+ break;
+ case ButtonRelease:
+ return die(dpy, 0);
+ break;
+ }
+ }
+}
diff --git a/x-session.c b/x-session.c
new file mode 100644
index 0000000..a162512
--- /dev/null
+++ b/x-session.c
@@ -0,0 +1,5 @@
+#include <unistd.h>
+#include <sys/wait.h>
+
+int main(void) { for (;;) { wait(NULL); sleep(1); } }
+