2005-11-18 17:54:58 +02:00
|
|
|
/*
|
2006-01-20 16:20:24 +02:00
|
|
|
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
2005-11-18 17:54:58 +02:00
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2006-05-30 18:28:05 +02:00
|
|
|
#include <regex.h>
|
2006-01-21 13:57:20 +02:00
|
|
|
#include <X11/Xlib.h>
|
2005-11-18 17:54:58 +02:00
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
2006-04-03 15:52:05 +02:00
|
|
|
#include <ixp.h>
|
|
|
|
#include <blitz.h>
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-07-11 16:15:01 +02:00
|
|
|
/* WM atoms */
|
2006-09-27 07:56:40 +02:00
|
|
|
enum { WMProtocols, WMDelete, WMLast };
|
2006-09-28 13:20:41 +02:00
|
|
|
enum { NetSupported, NetWMName, NetLast }; /* NET atoms */
|
|
|
|
enum { Coldefault, Colstack, Colmax }; /* Column modes */
|
|
|
|
enum { ColFG, ColBG, ColLast }; /* color */
|
|
|
|
enum { CurNormal, CurResize, CurMove, CurInput, CurLast }; /* Cursor */
|
2006-03-05 13:22:42 +01:00
|
|
|
|
2006-07-13 21:58:26 +00:00
|
|
|
enum { NCOL = 16 };
|
2006-04-06 07:55:33 +02:00
|
|
|
enum { WM_PROTOCOL_DELWIN = 1 };
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-06-29 19:02:51 -04:00
|
|
|
/* Data Structures */
|
2006-03-23 10:36:51 +01:00
|
|
|
typedef struct View View;
|
2006-03-05 01:55:45 +01:00
|
|
|
typedef struct Area Area;
|
|
|
|
typedef struct Frame Frame;
|
2005-11-18 17:54:58 +02:00
|
|
|
typedef struct Client Client;
|
2006-06-29 19:02:51 -04:00
|
|
|
typedef struct Key Key;
|
|
|
|
typedef struct Bar Bar;
|
|
|
|
typedef struct Rule Rule;
|
|
|
|
typedef struct Ruleset Ruleset;
|
|
|
|
typedef struct WMScreen WMScreen;
|
2006-06-25 09:16:03 -04:00
|
|
|
|
2006-09-28 13:20:41 +02:00
|
|
|
typedef struct {
|
|
|
|
int ascent;
|
|
|
|
int descent;
|
|
|
|
int height;
|
|
|
|
XFontSet set;
|
|
|
|
XFontStruct *xfont;
|
|
|
|
} Fnt;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int x, y, w, h;
|
|
|
|
unsigned long norm[ColLast];
|
|
|
|
unsigned long sel[ColLast];
|
|
|
|
unsigned long status[ColLast];
|
|
|
|
Drawable drawable;
|
|
|
|
Fnt font;
|
|
|
|
GC gc;
|
|
|
|
} DC; /* draw context */
|
|
|
|
|
2006-03-23 10:36:51 +01:00
|
|
|
struct View {
|
2006-06-08 10:54:19 +02:00
|
|
|
View *next;
|
2006-04-06 11:31:54 +02:00
|
|
|
char name[256];
|
2006-03-06 16:35:07 +01:00
|
|
|
unsigned short id;
|
2006-06-08 10:54:19 +02:00
|
|
|
Area *area;
|
|
|
|
Area *sel;
|
|
|
|
Area *revert;
|
|
|
|
};
|
|
|
|
|
2006-02-01 17:27:53 +02:00
|
|
|
struct Area {
|
2006-06-08 10:54:19 +02:00
|
|
|
Area *next;
|
|
|
|
Frame *frame;
|
|
|
|
Frame *sel;
|
2006-03-23 10:36:51 +01:00
|
|
|
View *view;
|
2006-06-23 21:22:04 -04:00
|
|
|
Bool floating;
|
2006-06-08 10:54:19 +02:00
|
|
|
unsigned short id;
|
2006-03-05 00:11:08 +01:00
|
|
|
int mode;
|
2006-01-26 16:24:34 +02:00
|
|
|
XRectangle rect;
|
2005-11-18 17:54:58 +02:00
|
|
|
};
|
|
|
|
|
2006-03-05 01:55:45 +01:00
|
|
|
struct Frame {
|
2006-06-08 10:54:19 +02:00
|
|
|
Frame *cnext;
|
|
|
|
Frame *anext;
|
2006-06-25 09:16:03 -04:00
|
|
|
View *view;
|
2006-03-05 01:55:45 +01:00
|
|
|
Area *area;
|
2006-02-03 17:15:36 +02:00
|
|
|
unsigned short id;
|
2006-03-05 01:55:45 +01:00
|
|
|
XRectangle rect;
|
2006-06-12 12:11:22 +02:00
|
|
|
XRectangle revert;
|
2006-03-05 01:55:45 +01:00
|
|
|
Client *client;
|
2006-06-12 12:11:22 +02:00
|
|
|
Bool collapsed;
|
2006-06-22 11:03:42 +02:00
|
|
|
BlitzBrush tile;
|
2006-07-10 09:13:09 +02:00
|
|
|
BlitzBrush grabbox;
|
2006-06-22 11:03:42 +02:00
|
|
|
BlitzBrush titlebar;
|
2006-03-05 01:55:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Client {
|
2006-06-08 10:54:19 +02:00
|
|
|
Client *next;
|
|
|
|
Area *revert;
|
|
|
|
Frame *frame;
|
|
|
|
Frame *sel;
|
2006-01-25 19:39:08 +02:00
|
|
|
char name[256];
|
2006-04-06 11:31:54 +02:00
|
|
|
char tags[256];
|
2006-05-30 16:32:28 +02:00
|
|
|
char props[512];
|
2006-06-08 10:54:19 +02:00
|
|
|
unsigned short id;
|
2006-03-23 05:22:43 -08:00
|
|
|
unsigned int border;
|
2006-07-11 16:15:01 +02:00
|
|
|
int proto;
|
2006-03-31 07:57:33 +02:00
|
|
|
Bool floating;
|
2006-05-22 20:35:20 +00:00
|
|
|
Bool fixedsize;
|
2006-03-23 05:22:43 -08:00
|
|
|
Window win;
|
|
|
|
Window trans;
|
2006-06-08 10:54:19 +02:00
|
|
|
Window framewin;
|
2006-03-23 05:22:43 -08:00
|
|
|
XRectangle rect;
|
|
|
|
XSizeHints size;
|
|
|
|
GC gc;
|
2005-11-18 17:54:58 +02:00
|
|
|
};
|
|
|
|
|
2006-02-09 19:40:12 +01:00
|
|
|
struct Key {
|
2006-06-08 10:54:19 +02:00
|
|
|
Key *next;
|
|
|
|
Key *lnext;
|
|
|
|
Key *tnext;
|
2006-02-09 19:40:12 +01:00
|
|
|
unsigned short id;
|
2006-03-23 05:22:43 -08:00
|
|
|
char name[128];
|
|
|
|
unsigned long mod;
|
|
|
|
KeyCode key;
|
2006-02-09 19:40:12 +01:00
|
|
|
};
|
|
|
|
|
2006-06-08 10:54:19 +02:00
|
|
|
struct Bar {
|
|
|
|
Bar *next;
|
2006-06-26 22:21:09 -04:00
|
|
|
Bar *smaller;
|
2006-06-17 07:32:49 -04:00
|
|
|
char buf[280];
|
2006-06-22 11:46:39 +02:00
|
|
|
char text[256];
|
2006-03-23 05:22:43 -08:00
|
|
|
char name[256];
|
2006-06-08 10:54:19 +02:00
|
|
|
unsigned short id;
|
2006-06-22 11:03:42 +02:00
|
|
|
BlitzBrush brush;
|
2006-06-08 10:54:19 +02:00
|
|
|
};
|
2006-02-09 22:48:01 +01:00
|
|
|
|
2006-06-17 07:32:49 -04:00
|
|
|
struct Rule {
|
|
|
|
Rule *next;
|
|
|
|
regex_t regex;
|
|
|
|
char value[256];
|
|
|
|
};
|
|
|
|
|
2006-06-29 19:02:51 -04:00
|
|
|
struct Ruleset {
|
2006-06-17 07:32:49 -04:00
|
|
|
Rule *rule;
|
|
|
|
char *string;
|
|
|
|
unsigned int size;
|
2006-06-29 19:02:51 -04:00
|
|
|
};
|
2006-06-17 07:32:49 -04:00
|
|
|
|
2006-06-29 19:02:51 -04:00
|
|
|
/* global variables */
|
2006-06-29 18:03:35 -04:00
|
|
|
struct {
|
2006-06-19 10:28:37 +02:00
|
|
|
BlitzColor selcolor;
|
|
|
|
BlitzColor normcolor;
|
2006-07-05 15:14:50 +02:00
|
|
|
BlitzColor bcolor[3];
|
2006-06-19 10:28:37 +02:00
|
|
|
BlitzFont font;
|
2006-02-09 22:48:01 +01:00
|
|
|
unsigned int border;
|
|
|
|
unsigned int snap;
|
2006-03-10 16:21:20 +01:00
|
|
|
char *keys;
|
|
|
|
unsigned int keyssz;
|
2006-06-29 19:02:51 -04:00
|
|
|
Ruleset tagrules;
|
|
|
|
Ruleset colrules;
|
2006-04-12 11:08:31 +02:00
|
|
|
char grabmod[5];
|
|
|
|
unsigned long mod;
|
2006-04-14 12:03:44 +02:00
|
|
|
int colmode;
|
2006-06-29 18:03:35 -04:00
|
|
|
} def;
|
|
|
|
|
|
|
|
struct WMScreen {
|
|
|
|
Bar *lbar;
|
|
|
|
Bar *rbar;
|
|
|
|
View *sel;
|
2006-06-29 19:02:51 -04:00
|
|
|
Window barwin;
|
2006-06-29 18:03:35 -04:00
|
|
|
|
|
|
|
XRectangle rect;
|
|
|
|
XRectangle brect;
|
|
|
|
BlitzBrush bbrush;
|
2006-06-29 20:02:52 -04:00
|
|
|
} *screens, *screen;
|
2006-02-09 22:48:01 +01:00
|
|
|
|
2006-06-08 10:54:19 +02:00
|
|
|
Client *client;
|
2006-06-29 19:02:51 -04:00
|
|
|
View *view;
|
2006-06-08 10:54:19 +02:00
|
|
|
Key *key;
|
|
|
|
|
2006-06-25 09:16:03 -04:00
|
|
|
enum { BUFFER_SIZE = 8092 };
|
|
|
|
char buffer[BUFFER_SIZE];
|
|
|
|
|
2006-06-29 19:02:51 -04:00
|
|
|
/* IXP */
|
|
|
|
IXPServer srv;
|
2006-06-17 07:32:49 -04:00
|
|
|
P9Srv p9srv;
|
2006-06-29 19:02:51 -04:00
|
|
|
|
|
|
|
/* X11 */
|
|
|
|
unsigned int num_screens;
|
2006-06-22 11:03:42 +02:00
|
|
|
Blitz blz;
|
2006-05-29 14:15:16 +02:00
|
|
|
GC xorgc;
|
2006-06-22 03:28:39 -04:00
|
|
|
char *user;
|
2006-07-11 16:15:01 +02:00
|
|
|
Atom wm_atom[WMLast];
|
2006-05-10 13:38:01 +02:00
|
|
|
Atom net_atom[NetLast];
|
2006-06-23 00:37:59 -04:00
|
|
|
Atom tags_atom;
|
2006-03-05 13:22:42 +01:00
|
|
|
Cursor cursor[CurLast];
|
2006-04-06 08:09:22 +02:00
|
|
|
unsigned int valid_mask;
|
|
|
|
unsigned int num_lock_mask;
|
2006-06-16 02:52:13 -04:00
|
|
|
Bool sel_screen;
|
2006-06-22 15:25:59 +02:00
|
|
|
Pixmap pmap;
|
2006-05-29 11:04:29 +02:00
|
|
|
void (*handler[LASTEvent]) (XEvent *);
|
2006-05-30 18:28:05 +02:00
|
|
|
|
2006-06-29 19:02:51 -04:00
|
|
|
/* Misc */
|
|
|
|
Bool starting;
|
|
|
|
|
2006-06-19 23:58:20 -04:00
|
|
|
/* wm.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern char *message_root(char *message);
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-02-03 17:15:36 +02:00
|
|
|
/* area.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern Area *create_area(View *v, Area *pos, unsigned int w);
|
|
|
|
extern void destroy_area(Area *a);
|
|
|
|
extern Area *area_of_id(View *t, unsigned short id);
|
|
|
|
extern char *select_area(Area *a, char *arg);
|
|
|
|
extern void send_to_area(Area *to, Area *from, Frame *f);
|
|
|
|
extern void attach_to_area(Area *a, Frame *f, Bool send);
|
|
|
|
extern void detach_from_area(Area *a, Frame *f);
|
|
|
|
extern Client *sel_client_of_area(Area *a);
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-02-09 22:48:01 +01:00
|
|
|
/* bar.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern Bar *create_bar(Bar **b_link, char *name);
|
|
|
|
extern void destroy_bar(Bar **b_link, Bar *b);
|
|
|
|
extern void draw_bar(WMScreen *s);
|
|
|
|
extern void resize_bar();
|
|
|
|
extern Bar *bar_of_name(Bar *b_link, const char *name);
|
2006-02-09 22:48:01 +01:00
|
|
|
|
2005-11-18 17:54:58 +02:00
|
|
|
/* client.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern Client *create_client(Window w, XWindowAttributes *wa);
|
|
|
|
extern void destroy_client(Client *c);
|
|
|
|
extern void configure_client(Client *c);
|
|
|
|
extern void prop_client(Client *c, XPropertyEvent *e);
|
|
|
|
extern void kill_client(Client *c);
|
|
|
|
extern void gravitate_client(Client *c, Bool invert);
|
|
|
|
extern void unmap_client(Client *c);
|
|
|
|
extern void map_client(Client *c);
|
|
|
|
extern void reparent_client(Client *c, Window w, int x, int y);
|
|
|
|
extern void manage_client(Client *c);
|
|
|
|
extern void focus_client(Client *c, Bool restack);
|
|
|
|
extern void focus(Client *c, Bool restack);
|
|
|
|
extern void resize_client(Client *c, XRectangle *r, Bool ignore_xcall);
|
|
|
|
extern void match_sizehints(Client *c, XRectangle *r, Bool floating, BlitzAlign sticky);
|
|
|
|
extern char *send_client(Frame *f, char *arg);
|
|
|
|
extern char * message_client(Client *c, char *message);
|
|
|
|
extern void move_client(Client *c, char *arg);
|
|
|
|
extern void size_client(Client *c, char *arg);
|
|
|
|
extern void newcol_client(Client *c, char *arg);
|
|
|
|
extern Client *sel_client();
|
|
|
|
extern Frame *frame_of_win(Window w);
|
|
|
|
extern Client *client_of_win(Window w);
|
|
|
|
extern int idx_of_client(Client *c);
|
|
|
|
extern void update_client_grab(Client *c, Bool is_sel);
|
|
|
|
extern void apply_rules(Client *c);
|
|
|
|
extern void apply_tags(Client *c, const char *tags);
|
2006-04-12 10:44:07 +02:00
|
|
|
|
|
|
|
/* column.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern void arrange_column(Area *a, Bool dirty);
|
|
|
|
extern void scale_column(Area *a, float h);
|
|
|
|
extern void resize_column(Client *c, XRectangle *r, XPoint *pt);
|
|
|
|
extern int column_mode_of_str(char *arg);
|
|
|
|
extern char *str_of_column_mode(int mode);
|
|
|
|
extern Area *new_column(View *v, Area *pos, unsigned int w);
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-09-28 13:20:41 +02:00
|
|
|
/* draw.c */
|
|
|
|
extern void drawall(void); /* draw all visible client titles and the bar */
|
|
|
|
extern void drawstatus(void); /* draw the bar */
|
|
|
|
extern void drawtitle(Client *c); /* draw title of c */
|
|
|
|
extern unsigned long getcolor(const char *colstr); /* return color of colstr */
|
|
|
|
extern void setfont(const char *fontstr); /* set the font for DC */
|
|
|
|
extern unsigned int textw(const char *text); /* return the width of text in px*/
|
|
|
|
|
2005-11-18 17:54:58 +02:00
|
|
|
/* event.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern void check_x_event(IXPConn *c);
|
|
|
|
extern unsigned int flush_masked_events(long even_mask);
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-03-08 13:00:10 +01:00
|
|
|
/* frame.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern Frame *create_frame(Client *c, View *v);
|
|
|
|
extern void remove_frame(Frame *f);
|
|
|
|
extern void insert_frame(Frame *pos, Frame *f, Bool before);
|
|
|
|
extern void draw_frame(Frame *f);
|
|
|
|
extern void draw_frames();
|
|
|
|
extern void update_frame_widget_colors(Frame *f);
|
2006-03-08 13:00:10 +01:00
|
|
|
|
2006-06-19 18:26:06 +02:00
|
|
|
/* fs.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern void fs_attach(P9Req *r);
|
|
|
|
extern void fs_clunk(P9Req *r);
|
|
|
|
extern void fs_create(P9Req *r);
|
|
|
|
extern void fs_flush(P9Req *r);
|
|
|
|
extern void fs_freefid(Fid *f);
|
|
|
|
extern void fs_open(P9Req *r);
|
|
|
|
extern void fs_read(P9Req *r);
|
|
|
|
extern void fs_remove(P9Req *r);
|
|
|
|
extern void fs_stat(P9Req *r);
|
|
|
|
extern void fs_walk(P9Req *r);
|
|
|
|
extern void fs_write(P9Req *r);
|
|
|
|
extern void write_event(char *format, ...);
|
2006-02-01 23:24:07 +02:00
|
|
|
|
2006-06-12 13:20:30 +02:00
|
|
|
/* geom.c */
|
2006-09-28 13:20:41 +02:00
|
|
|
extern Bool ispointinrect(int x, int y, XRectangle * r);
|
2006-09-27 07:56:40 +02:00
|
|
|
extern BlitzAlign quadofcoord(XRectangle *rect, int x, int y);
|
|
|
|
extern int strtorect(XRectangle *r, const char *val);
|
2006-06-12 13:20:30 +02:00
|
|
|
|
2006-04-12 10:44:07 +02:00
|
|
|
/* key.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern void kpress(Window w, unsigned long mod, KeyCode keycode);
|
|
|
|
extern void update_keys();
|
|
|
|
extern void init_lock_keys();
|
|
|
|
extern unsigned long mod_key_of_str(char *val);
|
2006-02-09 19:40:12 +01:00
|
|
|
|
2005-11-18 17:54:58 +02:00
|
|
|
/* mouse.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern void do_mouse_resize(Client *c,BlitzAlign align);
|
|
|
|
extern void grab_mouse(Window w, unsigned long mod, unsigned int button);
|
|
|
|
extern void ungrab_mouse(Window w, unsigned long mod, unsigned int button);
|
|
|
|
extern BlitzAlign snap_rect(XRectangle *rects, int num, XRectangle *current,
|
2006-06-04 23:47:09 -04:00
|
|
|
BlitzAlign *mask, int snap);
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-03-10 11:50:52 +01:00
|
|
|
/* rule.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern void update_rules(Rule **rule, const char *data);
|
2006-03-10 11:50:52 +01:00
|
|
|
|
2006-03-23 10:43:57 +01:00
|
|
|
/* view.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern void arrange_view(View *v);
|
|
|
|
extern void scale_view(View *v, float w);
|
|
|
|
extern View *get_view(const char *name);
|
|
|
|
extern View *create_view(const char *name);
|
|
|
|
extern void focus_view(WMScreen *s, View *v);
|
|
|
|
extern void update_client_views(Client *c, char **tags);
|
|
|
|
extern XRectangle *rects_of_view(View *v, unsigned int *num);
|
|
|
|
extern View *view_of_id(unsigned short id);
|
|
|
|
extern void select_view(const char *arg);
|
|
|
|
extern void attach_to_view(View *v, Frame *f);
|
|
|
|
extern Client *sel_client_of_view(View *v);
|
|
|
|
extern char *message_view(View *v, char *message);
|
|
|
|
extern void restack_view(View *v);
|
|
|
|
extern unsigned char *view_index(View *v);
|
|
|
|
extern void destroy_view(View *v);
|
|
|
|
extern void update_views();
|
|
|
|
extern unsigned int newcolw_of_view(View *v);
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2005-12-05 03:15:25 +02:00
|
|
|
/* wm.c */
|
2006-09-27 07:56:40 +02:00
|
|
|
extern int wmii_error_handler(Display *dpy, XErrorEvent *error);
|
|
|
|
extern int win_proto(Window w);
|