static void handle_enter_event(XCrossingEvent *);
static void handle_expose_event(XExposeEvent *);
-static int interruptible_XNextEvent(XEvent *event);
-
/* We may want to put in some sort of check for unknown events at some
* point. TWM has an interesting and different way of doing this... */
XEvent ev;
for (;;)
{
- interruptible_XNextEvent(&ev);
+ XNextEvent(dsply, &ev);
switch (ev.type)
{
case ButtonPress:
static void handle_windowbar_click(XButtonEvent *e, Client *c)
{
- static Client * first_click_c;
- static Time first_click_time;
- XEvent ev;
-
- if (first_click_c == c && (e->time - first_click_time) < DEF_DBLCLKTIME)
- {
- raise_lower(c);
- first_click_c = NULL; // prevent 3rd clicks counting as double clicks
- }
- else
- {
- first_click_c = c;
- }
- first_click_time = e->time;
move(c);
}
}
}
-/* interruptibleXNextEvent() was originally taken from Blender's source code
- * and came 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 interruptible_XNextEvent(XEvent *event)
-{
- fd_set fds;
- int rc;
- int dsply_fd = ConnectionNumber(dsply);
- for (;;)
- {
- if (XPending(dsply))
- {
- XNextEvent(dsply, event);
- return 1;
- }
- FD_ZERO(&fds);
- FD_SET(dsply_fd, &fds);
- rc = select(dsply_fd + 1, &fds, NULL, NULL, NULL);
- if (rc < 0)
- {
- if (errno == EINTR)
- {
- return 0;
- }
- return 1;
- }
- }
-}
int screen;
XftFont *xftfont = NULL;
XftColor xft_detail;
-GC string_gc, border_gc, text_gc, active_gc, depressed_gc, inactive_gc, selected_gc, empty_gc;
-XColor border_col, text_col, active_col, depressed_col, inactive_col, selected_col, empty_col;
-Cursor resize_curs;
+GC border_gc, active_gc;
+XColor border_col, text_col, active_col;
Atom wm_state, wm_change_state, wm_protos, wm_delete, wm_cmapwins;
Client *head_client = NULL, *focused_client = NULL, *topmost_client = NULL;
unsigned int focus_count = 0;
-Rect fs_prevdims;
-char *opt_font = DEF_FONT;
-char *opt_border = DEF_BORDER;
-char *opt_text = DEF_TEXT;
-char *opt_active = DEF_ACTIVE;
-char *opt_inactive = DEF_INACTIVE;
-char *opt_selected = DEF_SELECTED;
-char *opt_empty = DEF_EMPTY;
-char *opt_display = NULL;
-unsigned int numlockmask = 0;
static void scan_wins(void);
static void setup_display(void);
XColor dummyc;
XGCValues gv;
XSetWindowAttributes sattr;
- XModifierKeymap *modmap;
- int i, j;
- dsply = XOpenDisplay(opt_display);
+ dsply = XOpenDisplay(NULL);
if (dsply == NULL)
{
err("can't open display! check your DISPLAY variable.");
wm_delete = XInternAtom(dsply, "WM_DELETE_WINDOW", False);
wm_cmapwins = XInternAtom(dsply, "WM_COLORMAP_WINDOWS", False);
- XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_border, &border_col, &dummyc);
- XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_text, &text_col, &dummyc);
- XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_active, &active_col, &dummyc);
- XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_inactive, &inactive_col, &dummyc);
- XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_selected, &selected_col, &dummyc);
- XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_empty, &empty_col, &dummyc);
-
- depressed_col.pixel = active_col.pixel;
- depressed_col.red = active_col.red - ACTIVE_SHADOW;
- depressed_col.green = active_col.green - ACTIVE_SHADOW;
- depressed_col.blue = active_col.blue - ACTIVE_SHADOW;
- depressed_col.red = depressed_col.red <= (USHRT_MAX - ACTIVE_SHADOW) ? depressed_col.red : 0;
- depressed_col.green = depressed_col.green <= (USHRT_MAX - ACTIVE_SHADOW) ? depressed_col.green : 0;
- depressed_col.blue = depressed_col.blue <= (USHRT_MAX - ACTIVE_SHADOW) ? depressed_col.blue : 0;
- XAllocColor(dsply, DefaultColormap(dsply, screen), &depressed_col);
+ XAllocNamedColor(dsply, DefaultColormap(dsply, screen), DEF_BORDER, &border_col, &dummyc);
+ XAllocNamedColor(dsply, DefaultColormap(dsply, screen), DEF_TEXT, &text_col, &dummyc);
+ XAllocNamedColor(dsply, DefaultColormap(dsply, screen), DEF_ACTIVE, &active_col, &dummyc);
xft_detail.color.red = text_col.red;
xft_detail.color.green = text_col.green;
xft_detail.color.alpha = 0xffff;
xft_detail.pixel = text_col.pixel;
- xftfont = XftFontOpenXlfd(dsply, DefaultScreen(dsply), opt_font);
+ xftfont = XftFontOpenXlfd(dsply, DefaultScreen(dsply), DEF_FONT);
if (xftfont == NULL)
{
- err("font '%s' not found", opt_font);
+ err("font '%s' not found", DEF_FONT);
exit(1);
}
- resize_curs = XCreateFontCursor(dsply, XC_fleur);
-
- /* find out which modifier is NumLock - we'll use this when grabbing every combination of modifiers we can think of */
- modmap = XGetModifierMapping(dsply);
- for (i = 0; i < 8; i++)
- {
- for (j = 0; j < modmap->max_keypermod; j++)
- {
- if (modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dsply, XK_Num_Lock))
- {
- numlockmask = (1 << i);
- }
- }
- }
- XFree(modmap);
-
gv.function = GXcopy;
gv.foreground = border_col.pixel;
gv.foreground = text_col.pixel;
gv.line_width = 1;
- text_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv);
-
gv.foreground = active_col.pixel;
active_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv);
- gv.foreground = depressed_col.pixel;
- depressed_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv);
-
- gv.foreground = inactive_col.pixel;
- inactive_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv);
-
- gv.foreground = selected_col.pixel;
- selected_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv);
-
- gv.foreground = empty_col.pixel;
- empty_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv);
-
sattr.event_mask = ChildMask|ColormapChangeMask|ButtonMask;
XChangeWindowAttributes(dsply, root, CWEventMask, &sattr);
-
- grab_keysym(root, MODIFIER, KEY_CYCLEPREV);
- grab_keysym(root, MODIFIER, KEY_CYCLENEXT);
- grab_keysym(root, MODIFIER, KEY_FULLSCREEN);
- grab_keysym(root, MODIFIER, KEY_TOGGLEZ);
}
#include "windowlab.h"
-void raise_lower(Client *c)
-{
- if (c != NULL)
- {
- if (c == topmost_client)
- {
- lower_win(c);
- topmost_client = NULL; // lazy but amiwm does similar
- }
- else
- {
- raise_win(c);
- topmost_client = c;
- }
- }
-}
-
/* The name of this function is a bit misleading: if the client
* doesn't listen to WM_DELETE then we just terminate it with extreme
* prejudice. */
bounddims.width = (dw - bounddims.x - (c->width - bounddims.x)) + 1;
bounddims.y = mousey - c->y;
bounddims.height = (dh - bounddims.y - (c->height - bounddims.y)) + 1;
- bounddims.y += (BARHEIGHT() * 2) - BORDERWIDTH(c);
- bounddims.height += c->height - ((BARHEIGHT() * 2) - DEF_BORDERWIDTH);
+ bounddims.y += BARHEIGHT() - BORDERWIDTH(c);
+ bounddims.height += c->height - (BARHEIGHT() - DEF_BORDERWIDTH);
constraint_win = XCreateWindow(dsply, root, bounddims.x, bounddims.y, bounddims.width, bounddims.height, 0, CopyFromParent, InputOnly, CopyFromParent, 0, &pattr);
XMapWindow(dsply, constraint_win);
ungrab();
XDestroyWindow(dsply, constraint_win);
}
-
-void write_titletext(Client *c, Window bar_win)
-{
- if (!c->trans && c->name != NULL)
- {
- (void) bar_win; // fixes a warning
- XftDrawString8(c->xftdraw, &xft_detail, xftfont, SPACE, SPACE + xftfont->ascent, (unsigned char *)c->name, strlen(c->name));
- }
-}
XSetWindowAttributes pattr;
pattr.override_redirect = True;
- pattr.background_pixel = empty_col.pixel;
+// pattr.background_pixel = empty_col.pixel;
pattr.border_pixel = border_col.pixel;
pattr.event_mask = ChildMask|ButtonPressMask|ExposureMask|EnterWindowMask;
c->frame = XCreateWindow(dsply, root, c->x, c->y - BARHEIGHT(), c->width, c->height + BARHEIGHT(), BORDERWIDTH(c), DefaultDepth(dsply, screen), CopyFromParent, DefaultVisual(dsply, screen), CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &pattr);
#ifndef WINDOWLAB_H
#define WINDOWLAB_H
-#define VERSION "1.40"
-#define RELEASEDATE "2010-04-04"
-
#include <errno.h>
#include <limits.h>
#include <pwd.h>
#include <X11/keysym.h>
#include <X11/Xft/Xft.h>
-#ifndef PATH_MAX
-#define PATH_MAX 4096
-#endif
-
// here are the default settings - change to suit your taste
// if you aren't sure about DEF_FONT, change it to "fixed"; almost all X installations will have that available
#define ACTIVE_SHADOW 0x2000 // eg #fff becomes #ddd
#define SPACE 3
-// change MODIFIER to None to remove the need to hold down a modifier key
-// the Windows key should be Mod4Mask and the Alt key is Mod1Mask
-#define MODIFIER Mod4Mask
-
-// keys may be used by other apps, so change them here
-#define KEY_CYCLEPREV XK_Tab
-#define KEY_CYCLENEXT XK_q
-#define KEY_FULLSCREEN XK_F11
-#define KEY_TOGGLEZ XK_F12
-
-// max time between clicks in double click
-#define DEF_DBLCLKTIME 400
-
// a few useful masks made up out of X's basic ones. `ChildMask' is a silly name, but oh well.
#define ChildMask (SubstructureRedirectMask|SubstructureNotifyMask)
#define ButtonMask (ButtonPressMask|ButtonReleaseMask)
#define WITHDRAW 0
#define REMAP 1
-// stuff for the menu file
-#define MAX_MENUITEMS 24
-#define MAX_MENUITEMS_SIZE (sizeof(MenuItem) * MAX_MENUITEMS)
-#define STR_SIZE 128
-#define NO_MENU_LABEL "xterm"
-#define NO_MENU_COMMAND "xterm"
-
/* This structure keeps track of top-level windows (hereinafter
* 'clients'). The clients we know about (i.e. all that don't set
* override-redirect) are kept track of in linked list starting at the
extern void gravitate(Client *, int);
extern void check_focus(Client *);
extern Client *get_prev_focused(void);
-extern void draw_hide_button(Client *, GC *, GC *);
-extern void draw_toggledepth_button(Client *, GC *, GC *);
-extern void draw_close_button(Client *, GC *, GC *);
// new.c
extern void make_new_client(Window);
// manage.c
extern void move(Client *);
-extern void raise_lower(Client *);
-extern void resize(Client *, int, int);
-extern void hide(Client *);
-extern void unhide(Client *);
-extern void toggle_fullscreen(Client *);
extern void send_wm_delete(Client *);
-extern void write_titletext(Client *, Window);
// misc.c
extern void err(const char *, ...);
-extern void fork_exec(char *);
-extern void sig_handler(int);
extern int handle_xerror(Display *, XErrorEvent *);
extern int ignore_xerror(Display *, XErrorEvent *);
extern int send_xmessage(Window, Atom, long);