2005-11-18 18:54:58 +03:00
|
|
|
/*
|
2006-01-20 17:20:24 +03:00
|
|
|
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
2005-11-18 18:54:58 +03:00
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2006-01-21 14:57:20 +03:00
|
|
|
#include <X11/Xlib.h>
|
2005-11-18 18:54:58 +03:00
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
2006-04-03 17:52:05 +04:00
|
|
|
#include <ixp.h>
|
|
|
|
#include <blitz.h>
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2006-03-05 15:22:42 +03:00
|
|
|
/* WM atoms */
|
2005-12-27 23:13:50 +03:00
|
|
|
enum {
|
2006-03-05 02:11:08 +03:00
|
|
|
WMState,
|
|
|
|
WMProtocols,
|
|
|
|
WMDelete,
|
|
|
|
WMLast
|
|
|
|
};
|
|
|
|
|
2006-03-05 15:22:42 +03:00
|
|
|
/* Column modes */
|
2006-03-05 02:11:08 +03:00
|
|
|
enum {
|
|
|
|
Colequal,
|
|
|
|
Colstack,
|
|
|
|
Colmax
|
2005-12-27 23:13:50 +03:00
|
|
|
};
|
|
|
|
|
2006-03-05 15:22:42 +03:00
|
|
|
/* Cursor */
|
|
|
|
enum {
|
|
|
|
CurNormal,
|
|
|
|
CurResize,
|
|
|
|
CurMove,
|
|
|
|
CurLast
|
|
|
|
};
|
|
|
|
|
2006-02-02 16:50:04 +03:00
|
|
|
/* 8-bit qid.path.type */
|
|
|
|
enum {
|
2006-03-23 16:22:43 +03:00
|
|
|
FsDroot,
|
2006-03-05 16:16:48 +03:00
|
|
|
FsDdef,
|
2006-03-23 11:54:20 +03:00
|
|
|
FsDview,
|
2006-03-05 16:16:48 +03:00
|
|
|
FsDarea,
|
2006-03-07 19:22:36 +03:00
|
|
|
FsDclients,
|
2006-03-05 16:16:48 +03:00
|
|
|
FsDclient,
|
2006-03-07 19:22:36 +03:00
|
|
|
FsDGclient,
|
2006-03-05 16:16:48 +03:00
|
|
|
FsDbar,
|
2006-03-23 16:22:43 +03:00
|
|
|
FsDlabel,
|
|
|
|
FsFdata,
|
|
|
|
FsFcolors,
|
|
|
|
FsFfont,
|
|
|
|
FsFselcolors,
|
|
|
|
FsFnormcolors,
|
2006-03-10 18:21:20 +03:00
|
|
|
FsFkeys,
|
2006-03-05 16:16:48 +03:00
|
|
|
FsFborder,
|
|
|
|
FsFbar,
|
|
|
|
FsFgeom,
|
|
|
|
FsFevent,
|
|
|
|
FsFctl,
|
|
|
|
FsFname,
|
2006-03-10 16:39:46 +03:00
|
|
|
FsFrules,
|
2006-03-05 21:20:27 +03:00
|
|
|
FsFtags,
|
2006-03-10 13:59:26 +03:00
|
|
|
FsFclass,
|
2006-03-06 18:35:07 +03:00
|
|
|
FsFtag,
|
2006-03-05 16:16:48 +03:00
|
|
|
FsFmode
|
2006-02-02 16:50:04 +03:00
|
|
|
};
|
|
|
|
|
2006-04-06 09:55:33 +04:00
|
|
|
enum { MAX_TAGS = 8 };
|
|
|
|
enum { MAX_TAGLEN = 32 };
|
|
|
|
enum { MIN_COLWIDTH = 64 };
|
|
|
|
enum { WM_PROTOCOL_DELWIN = 1 };
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2006-03-23 12:36:51 +03:00
|
|
|
typedef struct View View;
|
2006-03-05 03:55:45 +03:00
|
|
|
typedef struct Area Area;
|
|
|
|
typedef struct Frame Frame;
|
2005-11-18 18:54:58 +03:00
|
|
|
typedef struct Client Client;
|
|
|
|
|
2006-04-06 09:55:33 +04:00
|
|
|
typedef struct {
|
|
|
|
unsigned int size;
|
|
|
|
Area **data;
|
|
|
|
} AreaVector;
|
|
|
|
|
2006-03-23 12:36:51 +03:00
|
|
|
struct View {
|
2006-04-04 14:25:36 +04:00
|
|
|
char name[MAX_TAGLEN];
|
2006-03-06 18:35:07 +03:00
|
|
|
unsigned short id;
|
2006-04-03 15:40:34 +04:00
|
|
|
AreaVector area;
|
2006-03-06 18:35:07 +03:00
|
|
|
unsigned int sel;
|
2006-03-11 22:50:53 +03:00
|
|
|
unsigned int revert;
|
2006-03-06 18:35:07 +03:00
|
|
|
};
|
|
|
|
|
2006-04-06 09:55:33 +04:00
|
|
|
typedef struct {
|
|
|
|
unsigned int size;
|
|
|
|
Frame **data;
|
|
|
|
} FrameVector;
|
|
|
|
|
2006-02-01 18:27:53 +03:00
|
|
|
struct Area {
|
2006-02-03 18:15:36 +03:00
|
|
|
unsigned short id;
|
2006-04-03 15:40:34 +04:00
|
|
|
FrameVector frame;
|
2006-03-23 12:36:51 +03:00
|
|
|
View *view;
|
2006-03-01 13:55:46 +03:00
|
|
|
unsigned int sel;
|
2006-03-05 02:11:08 +03:00
|
|
|
int mode;
|
2006-01-26 17:24:34 +03:00
|
|
|
XRectangle rect;
|
2005-11-18 18:54:58 +03:00
|
|
|
};
|
|
|
|
|
2006-03-05 03:55:45 +03:00
|
|
|
struct Frame {
|
|
|
|
Area *area;
|
2006-02-03 18:15:36 +03:00
|
|
|
unsigned short id;
|
2006-03-05 03:55:45 +03:00
|
|
|
XRectangle rect;
|
|
|
|
Client *client;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Client {
|
2006-03-07 19:22:36 +03:00
|
|
|
unsigned short id;
|
2006-01-25 20:39:08 +03:00
|
|
|
char name[256];
|
2006-03-15 11:02:25 +03:00
|
|
|
char tag[MAX_TAGS][MAX_TAGLEN];
|
|
|
|
unsigned int ntag;
|
2006-03-10 13:59:26 +03:00
|
|
|
char classinst[256];
|
2006-03-23 16:22:43 +03:00
|
|
|
int proto;
|
|
|
|
unsigned int border;
|
2006-03-31 09:57:33 +04:00
|
|
|
Bool floating;
|
2006-03-23 16:22:43 +03:00
|
|
|
Window win;
|
|
|
|
Window trans;
|
|
|
|
XRectangle rect;
|
|
|
|
XSizeHints size;
|
2006-03-05 02:25:49 +03:00
|
|
|
Window framewin;
|
2006-03-23 16:22:43 +03:00
|
|
|
GC gc;
|
2006-04-03 15:40:34 +04:00
|
|
|
FrameVector frame;
|
2006-03-07 01:55:47 +03:00
|
|
|
unsigned int sel;
|
2006-03-11 22:50:53 +03:00
|
|
|
Area *revert;
|
2005-11-18 18:54:58 +03:00
|
|
|
};
|
|
|
|
|
2006-02-09 21:40:12 +03:00
|
|
|
typedef struct Key Key;
|
|
|
|
struct Key {
|
|
|
|
unsigned short id;
|
2006-03-23 16:22:43 +03:00
|
|
|
char name[128];
|
|
|
|
unsigned long mod;
|
|
|
|
KeyCode key;
|
|
|
|
Key *next;
|
2006-02-09 21:40:12 +03:00
|
|
|
};
|
|
|
|
|
2006-02-10 00:48:01 +03:00
|
|
|
typedef struct {
|
2006-03-23 16:22:43 +03:00
|
|
|
char name[256];
|
2006-02-10 00:48:01 +03:00
|
|
|
unsigned short id;
|
2006-03-23 16:22:43 +03:00
|
|
|
char data[256];
|
2006-02-10 00:48:01 +03:00
|
|
|
char colstr[24];
|
|
|
|
Color color;
|
|
|
|
XRectangle rect;
|
2006-03-24 15:36:35 +03:00
|
|
|
Bool intern;
|
2006-02-10 17:59:30 +03:00
|
|
|
} Label;
|
2006-02-10 00:48:01 +03:00
|
|
|
|
|
|
|
/* default values */
|
|
|
|
typedef struct {
|
|
|
|
char selcolor[24];
|
|
|
|
char normcolor[24];
|
2006-04-04 14:25:36 +04:00
|
|
|
char tag[MAX_TAGLEN];
|
2006-02-10 00:48:01 +03:00
|
|
|
char *font;
|
|
|
|
Color sel;
|
|
|
|
Color norm;
|
|
|
|
unsigned int border;
|
|
|
|
unsigned int snap;
|
2006-03-10 18:21:20 +03:00
|
|
|
char *keys;
|
|
|
|
unsigned int keyssz;
|
2006-03-10 16:39:46 +03:00
|
|
|
char *rules;
|
|
|
|
unsigned int rulessz;
|
2006-02-10 00:48:01 +03:00
|
|
|
} Default;
|
|
|
|
|
2005-11-18 18:54:58 +03:00
|
|
|
/* global variables */
|
2006-04-06 09:55:33 +04:00
|
|
|
typedef struct {
|
|
|
|
unsigned int size;
|
|
|
|
View **data;
|
|
|
|
} ViewVector;
|
2006-04-03 00:53:56 +04:00
|
|
|
|
2006-04-06 09:55:33 +04:00
|
|
|
typedef struct {
|
|
|
|
unsigned int size;
|
|
|
|
Client **data;
|
|
|
|
} ClientVector;
|
2006-04-03 00:53:56 +04:00
|
|
|
|
2006-04-06 09:55:33 +04:00
|
|
|
typedef struct {
|
|
|
|
unsigned int size;
|
|
|
|
Key **data;
|
|
|
|
} KeyVector;
|
2006-04-03 00:53:56 +04:00
|
|
|
|
2006-04-06 09:55:33 +04:00
|
|
|
typedef struct {
|
|
|
|
unsigned int size;
|
|
|
|
Label **data;
|
|
|
|
} LabelVector;
|
2006-04-03 15:40:34 +04:00
|
|
|
LabelVector label;
|
2006-04-03 00:53:56 +04:00
|
|
|
|
2006-04-06 09:55:33 +04:00
|
|
|
typedef struct {
|
|
|
|
unsigned int size;
|
|
|
|
char **data;
|
|
|
|
} TagVector;
|
2005-12-16 04:59:27 +03:00
|
|
|
|
2006-04-06 10:09:22 +04:00
|
|
|
/* global variables */
|
|
|
|
ViewVector view;
|
|
|
|
unsigned int sel;
|
|
|
|
ClientVector client;
|
|
|
|
TagVector tag;
|
|
|
|
KeyVector key;
|
2005-12-05 01:45:59 +03:00
|
|
|
Display *dpy;
|
2006-01-25 20:39:08 +03:00
|
|
|
int screen;
|
2005-12-05 01:45:59 +03:00
|
|
|
Window root;
|
|
|
|
XRectangle rect;
|
2006-01-30 21:08:58 +03:00
|
|
|
XFontStruct *xfont;
|
2006-03-10 20:35:00 +03:00
|
|
|
GC xorgc;
|
2006-02-02 00:24:07 +03:00
|
|
|
IXPServer srv;
|
2006-03-10 20:35:00 +03:00
|
|
|
Pixmap barpmap;
|
|
|
|
Window barwin;
|
|
|
|
GC bargc;
|
2006-02-10 00:48:01 +03:00
|
|
|
XRectangle brect;
|
|
|
|
Qid root_qid;
|
2006-01-31 15:25:23 +03:00
|
|
|
Default def;
|
2006-03-05 02:11:08 +03:00
|
|
|
Atom wm_atom[WMLast];
|
2006-03-05 15:22:42 +03:00
|
|
|
Cursor cursor[CurLast];
|
2006-04-06 10:09:22 +04:00
|
|
|
unsigned int valid_mask;
|
|
|
|
unsigned int num_lock_mask;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2006-02-03 18:15:36 +03:00
|
|
|
/* area.c */
|
2006-03-23 12:36:51 +03:00
|
|
|
Area *alloc_area(View *t);
|
2006-02-03 18:15:36 +03:00
|
|
|
void destroy_area(Area *a);
|
2006-03-01 09:51:04 +03:00
|
|
|
int area2index(Area *a);
|
2006-03-23 12:36:51 +03:00
|
|
|
int aid2index(View *t, unsigned short id);
|
2006-02-19 18:21:01 +03:00
|
|
|
void select_area(Area *a, char *arg);
|
2006-03-08 18:05:09 +03:00
|
|
|
void send2area(Area *to, Area *from, Client *c);
|
2006-03-02 19:38:15 +03:00
|
|
|
void attach_toarea(Area *a, Client *c);
|
2006-03-27 09:46:12 +04:00
|
|
|
void detach_fromarea(Area *a, Client *c);
|
2006-03-27 10:38:17 +04:00
|
|
|
void arrange_column(Area *a);
|
2006-03-02 17:28:55 +03:00
|
|
|
void resize_area(Client *c, XRectangle *r, XPoint *pt);
|
2006-03-05 02:11:08 +03:00
|
|
|
int str2mode(char *arg);
|
|
|
|
char *mode2str(int mode);
|
2006-03-06 19:22:54 +03:00
|
|
|
Bool clientofarea(Area *a, Client *c);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2006-02-10 00:48:01 +03:00
|
|
|
/* bar.c */
|
2006-03-27 13:55:41 +04:00
|
|
|
Label *get_label(char *name, Bool intern);
|
2006-03-09 04:15:43 +03:00
|
|
|
void destroy_label(Label *l);
|
2006-02-10 00:48:01 +03:00
|
|
|
void draw_bar();
|
2006-03-01 09:51:04 +03:00
|
|
|
int lid2index(unsigned short id);
|
2006-02-10 20:32:35 +03:00
|
|
|
void update_bar_geometry();
|
2006-02-24 12:38:48 +03:00
|
|
|
unsigned int bar_height();
|
2006-03-09 04:15:43 +03:00
|
|
|
Label *name2label(const char *name);
|
|
|
|
int label2index(Label *l);
|
2006-03-24 15:36:35 +03:00
|
|
|
void update_bar_tags();
|
2006-02-10 00:48:01 +03:00
|
|
|
|
2005-11-18 18:54:58 +03:00
|
|
|
/* client.c */
|
2006-01-25 20:39:08 +03:00
|
|
|
Client *alloc_client(Window w, XWindowAttributes *wa);
|
2006-02-24 19:13:58 +03:00
|
|
|
void configure_client(Client *c);
|
2006-03-09 01:53:52 +03:00
|
|
|
void update_client_property(Client *c, XPropertyEvent *e);
|
2006-02-24 19:13:58 +03:00
|
|
|
void kill_client(Client *c);
|
|
|
|
void draw_client(Client *client);
|
2006-03-05 02:38:40 +03:00
|
|
|
void gravitate(Client *c, Bool invert);
|
2006-02-24 19:13:58 +03:00
|
|
|
void unmap_client(Client *c);
|
|
|
|
void map_client(Client *c);
|
|
|
|
void reparent_client(Client *c, Window w, int x, int y);
|
2006-03-09 01:53:52 +03:00
|
|
|
void manage_client(Client *c);
|
2006-03-09 22:25:50 +03:00
|
|
|
void destroy_client(Client *c);
|
2005-12-16 04:59:27 +03:00
|
|
|
Client *sel_client();
|
2006-02-28 10:51:53 +03:00
|
|
|
void focus_client(Client *c);
|
2006-03-15 18:00:39 +03:00
|
|
|
void resize_client(Client *c, XRectangle *r, Bool ignore_xcall);
|
2006-02-14 14:06:16 +03:00
|
|
|
void select_client(Client *c, char *arg);
|
2006-03-08 18:05:09 +03:00
|
|
|
void send2area_client(Client *c, char *arg);
|
2006-02-24 12:38:48 +03:00
|
|
|
void resize_all_clients();
|
2006-02-28 10:51:53 +03:00
|
|
|
void focus(Client *c);
|
2006-03-07 19:22:36 +03:00
|
|
|
int cid2index(unsigned short id);
|
2006-03-15 11:02:25 +03:00
|
|
|
Bool clienthastag(Client *c, const char *t);
|
2006-03-27 11:38:41 +04:00
|
|
|
void swap_client(Client *c, char *arg);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
|
|
/* event.c */
|
2006-02-02 18:44:45 +03:00
|
|
|
void init_x_event_handler();
|
2006-02-03 20:11:22 +03:00
|
|
|
void check_x_event(IXPConn *c);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2006-03-08 15:00:10 +03:00
|
|
|
/* frame.c */
|
|
|
|
int frid2index(Area *a, unsigned short id);
|
|
|
|
int frame2index(Frame *f);
|
|
|
|
Client *win2clientframe(Window w);
|
|
|
|
|
2006-02-02 00:24:07 +03:00
|
|
|
/* fs.c */
|
2006-02-02 16:50:04 +03:00
|
|
|
unsigned long long mkqpath(unsigned char type, unsigned short pg,
|
2006-03-23 16:22:43 +03:00
|
|
|
unsigned short area, unsigned short cl);
|
2006-03-23 20:08:55 +03:00
|
|
|
void write_event(char *event);
|
2006-02-03 20:11:22 +03:00
|
|
|
void new_ixp_conn(IXPConn *c);
|
2006-02-02 00:24:07 +03:00
|
|
|
|
2006-02-09 21:40:12 +03:00
|
|
|
/* kb.c */
|
|
|
|
void handle_key(Window w, unsigned long mod, KeyCode keycode);
|
2006-03-10 18:21:20 +03:00
|
|
|
void update_keys();
|
2006-03-10 23:42:39 +03:00
|
|
|
void init_lock_modifiers();
|
2006-02-09 21:40:12 +03:00
|
|
|
|
2005-11-18 18:54:58 +03:00
|
|
|
/* mouse.c */
|
2006-01-26 14:56:28 +03:00
|
|
|
void mouse_resize(Client *c, Align align);
|
|
|
|
void mouse_move(Client *c);
|
2006-03-05 15:22:42 +03:00
|
|
|
Align xy2align(XRectangle *rect, int x, int y);
|
2006-01-26 14:56:28 +03:00
|
|
|
void drop_move(Client *c, XRectangle *new, XPoint *pt);
|
2006-02-09 21:40:12 +03:00
|
|
|
void grab_mouse(Window w, unsigned long mod, unsigned int button);
|
|
|
|
void ungrab_mouse(Window w, unsigned long mod, unsigned int button);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2006-03-10 13:50:52 +03:00
|
|
|
/* rule.c */
|
2006-03-26 20:21:12 +04:00
|
|
|
void update_rules();
|
2006-03-10 19:17:59 +03:00
|
|
|
void match_tags(Client *c);
|
2006-03-10 13:50:52 +03:00
|
|
|
|
2006-03-04 11:23:17 +03:00
|
|
|
/* tag.c */
|
2006-03-15 12:35:38 +03:00
|
|
|
unsigned int str2tags(char tags[MAX_TAGS][MAX_TAGLEN], const char *stags);
|
|
|
|
void tags2str(char *stags, unsigned int stagsz,
|
2006-03-23 16:22:43 +03:00
|
|
|
char tags[MAX_TAGS][MAX_TAGLEN], unsigned int ntags);
|
2006-03-23 20:08:55 +03:00
|
|
|
Bool istag(char *t);
|
2006-04-03 00:53:56 +04:00
|
|
|
void ensure_tag(char *t);
|
2006-03-23 12:36:51 +03:00
|
|
|
void update_tags();
|
|
|
|
|
2006-03-23 12:43:57 +03:00
|
|
|
/* view.c */
|
2006-03-27 09:17:47 +04:00
|
|
|
void arrange_view(View *v, Bool updategeometry);
|
2006-03-23 12:43:57 +03:00
|
|
|
View *alloc_view(char *name);
|
|
|
|
void focus_view(View *v);
|
2006-03-23 12:36:51 +03:00
|
|
|
XRectangle *rectangles(View *v, Bool isfloat, unsigned int *num);
|
2006-03-23 17:58:36 +03:00
|
|
|
int vid2index(unsigned short id);
|
2006-03-23 12:43:57 +03:00
|
|
|
void select_view(char *arg);
|
|
|
|
int view2index(View *v);
|
|
|
|
Bool clientofview(View *v, Client *c);
|
|
|
|
void detach_fromview(View *v, Client *c);
|
|
|
|
void attach_toview(View *v, Client *c);
|
|
|
|
Client *sel_client_of_view(View *v);
|
|
|
|
void restack_view(View *v);
|
2006-03-23 12:36:51 +03:00
|
|
|
Bool hasclient(View *v);
|
2006-03-24 15:36:35 +03:00
|
|
|
View *name2view(char *name);
|
2006-03-29 11:45:54 +04:00
|
|
|
void destroy_view(View *v);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2005-12-05 04:15:25 +03:00
|
|
|
/* wm.c */
|
|
|
|
void scan_wins();
|
2006-03-01 09:51:04 +03:00
|
|
|
Client *win2client(Window w);
|
2005-12-05 04:15:25 +03:00
|
|
|
int win_proto(Window w);
|
|
|
|
int win_state(Window w);
|
2006-03-09 22:25:50 +03:00
|
|
|
int wmii_error_handler(Display *dpy, XErrorEvent *error);
|