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-01-21 13:57:20 +02:00
|
|
|
#include <X11/Xlib.h>
|
2005-11-18 17:54:58 +02:00
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
2006-02-09 22:48:01 +01:00
|
|
|
#include "ixp.h"
|
|
|
|
#include "blitz.h"
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-03-05 13:22:42 +01:00
|
|
|
/* WM atoms */
|
2005-12-27 22:13:50 +02:00
|
|
|
enum {
|
2006-03-05 00:11:08 +01:00
|
|
|
WMState,
|
|
|
|
WMProtocols,
|
|
|
|
WMDelete,
|
|
|
|
WMLast
|
|
|
|
};
|
|
|
|
|
2006-03-05 13:22:42 +01:00
|
|
|
/* Column modes */
|
2006-03-05 00:11:08 +01:00
|
|
|
enum {
|
|
|
|
Colequal,
|
|
|
|
Colstack,
|
|
|
|
Colmax
|
2005-12-27 22:13:50 +02:00
|
|
|
};
|
|
|
|
|
2006-03-05 13:22:42 +01:00
|
|
|
/* Cursor */
|
|
|
|
enum {
|
|
|
|
CurNormal,
|
|
|
|
CurResize,
|
|
|
|
CurMove,
|
|
|
|
CurW,
|
|
|
|
CurE,
|
|
|
|
CurN,
|
|
|
|
CurS,
|
|
|
|
CurNW,
|
|
|
|
CurNE,
|
|
|
|
CurSW,
|
|
|
|
CurSE,
|
|
|
|
CurLast
|
|
|
|
};
|
|
|
|
|
2006-02-02 15:50:04 +02:00
|
|
|
/* 8-bit qid.path.type */
|
|
|
|
enum {
|
2006-03-05 14:16:48 +01:00
|
|
|
FsDroot,
|
|
|
|
FsDdef,
|
2006-03-05 16:48:14 +01:00
|
|
|
FsDws,
|
2006-03-05 14:16:48 +01:00
|
|
|
FsDarea,
|
2006-03-07 17:22:36 +01:00
|
|
|
FsDclients,
|
2006-03-05 14:16:48 +01:00
|
|
|
FsDclient,
|
2006-03-07 17:22:36 +01:00
|
|
|
FsDGclient,
|
2006-03-05 14:16:48 +01:00
|
|
|
FsDkeys,
|
2006-03-05 19:20:27 +01:00
|
|
|
FsDtags,
|
2006-03-05 14:16:48 +01:00
|
|
|
FsDbar,
|
|
|
|
FsDlabel,
|
|
|
|
FsFexpand,
|
|
|
|
FsFdata, /* data to display */
|
|
|
|
FsFcolors,
|
|
|
|
FsFfont,
|
|
|
|
FsFselcolors,
|
|
|
|
FsFnormcolors,
|
|
|
|
FsFkey,
|
|
|
|
FsFborder,
|
|
|
|
FsFsnap,
|
|
|
|
FsFbar,
|
|
|
|
FsFgeom,
|
|
|
|
FsFevent,
|
|
|
|
FsFctl,
|
|
|
|
FsFname,
|
2006-03-10 14:39:46 +01:00
|
|
|
FsFrules,
|
2006-03-05 19:20:27 +01:00
|
|
|
FsFtags,
|
2006-03-10 11:59:26 +01:00
|
|
|
FsFclass,
|
2006-03-06 16:35:07 +01:00
|
|
|
FsFtag,
|
2006-03-05 14:16:48 +01:00
|
|
|
FsFmode
|
2006-02-02 15:50:04 +02:00
|
|
|
};
|
|
|
|
|
2005-11-18 17:54:58 +02:00
|
|
|
#define PROTO_DEL 1
|
2006-02-02 20:32:25 +02:00
|
|
|
#define DEF_BORDER 3
|
|
|
|
#define DEF_SNAP 20
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2005-12-15 03:08:26 +02:00
|
|
|
#define ROOT_MASK SubstructureRedirectMask
|
2006-01-12 19:03:49 +02:00
|
|
|
#define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask)
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-03-04 09:23:17 +01:00
|
|
|
typedef struct Tag Tag;
|
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-03-06 16:35:07 +01:00
|
|
|
struct Tag {
|
|
|
|
char name[256];
|
|
|
|
unsigned short id;
|
|
|
|
Area **area;
|
|
|
|
unsigned int areasz;
|
|
|
|
unsigned int narea;
|
|
|
|
unsigned int sel;
|
|
|
|
};
|
|
|
|
|
2006-02-01 17:27:53 +02:00
|
|
|
struct Area {
|
2006-02-03 17:15:36 +02:00
|
|
|
unsigned short id;
|
2006-03-05 01:55:45 +01:00
|
|
|
Frame **frame;
|
2006-03-04 09:23:17 +01:00
|
|
|
Tag *tag;
|
2006-03-05 01:55:45 +01:00
|
|
|
unsigned int framesz;
|
2006-03-01 11:55:46 +01:00
|
|
|
unsigned int sel;
|
2006-03-05 01:55:45 +01:00
|
|
|
unsigned int nframe;
|
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 {
|
|
|
|
Area *area;
|
2006-02-03 17:15:36 +02:00
|
|
|
unsigned short id;
|
2006-03-05 01:55:45 +01:00
|
|
|
XRectangle rect;
|
|
|
|
Client *client;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Client {
|
2006-03-07 17:22:36 +01:00
|
|
|
unsigned short id;
|
2006-01-25 19:39:08 +02:00
|
|
|
char name[256];
|
2006-03-05 19:20:27 +01:00
|
|
|
char tags[256];
|
2006-03-10 11:59:26 +01:00
|
|
|
char classinst[256];
|
2005-12-21 17:18:11 +02:00
|
|
|
int proto;
|
|
|
|
unsigned int border;
|
|
|
|
Bool destroyed;
|
|
|
|
Window win;
|
|
|
|
Window trans;
|
|
|
|
XRectangle rect;
|
|
|
|
XSizeHints size;
|
2006-03-05 00:25:49 +01:00
|
|
|
Window framewin;
|
|
|
|
GC gc;
|
|
|
|
Cursor cursor;
|
2006-03-06 23:55:47 +01:00
|
|
|
Frame **frame;
|
|
|
|
unsigned int framesz;
|
|
|
|
unsigned int sel;
|
|
|
|
unsigned int nframe;
|
2005-11-18 17:54:58 +02:00
|
|
|
};
|
|
|
|
|
2006-02-09 19:40:12 +01:00
|
|
|
typedef struct Key Key;
|
|
|
|
struct Key {
|
|
|
|
unsigned short id;
|
|
|
|
char name[128];
|
|
|
|
unsigned long mod;
|
|
|
|
KeyCode key;
|
|
|
|
Key *next;
|
|
|
|
};
|
|
|
|
|
2006-02-09 22:48:01 +01:00
|
|
|
typedef struct {
|
2006-03-09 02:15:43 +01:00
|
|
|
char name[256];
|
2006-02-09 22:48:01 +01:00
|
|
|
unsigned short id;
|
|
|
|
char data[256];
|
|
|
|
char colstr[24];
|
|
|
|
Color color;
|
|
|
|
XRectangle rect;
|
2006-02-10 15:59:30 +01:00
|
|
|
} Label;
|
2006-02-09 22:48:01 +01:00
|
|
|
|
|
|
|
/* default values */
|
|
|
|
typedef struct {
|
|
|
|
char selcolor[24];
|
|
|
|
char normcolor[24];
|
2006-03-06 16:35:07 +01:00
|
|
|
char tag[256];
|
2006-02-09 22:48:01 +01:00
|
|
|
char *font;
|
|
|
|
Color sel;
|
|
|
|
Color norm;
|
|
|
|
unsigned int border;
|
|
|
|
unsigned int snap;
|
2006-03-10 14:39:46 +01:00
|
|
|
char *rules;
|
|
|
|
unsigned int rulessz;
|
2006-02-09 22:48:01 +01:00
|
|
|
} Default;
|
|
|
|
|
2005-11-18 17:54:58 +02:00
|
|
|
/* global variables */
|
2006-03-04 09:23:17 +01:00
|
|
|
Tag **tag;
|
|
|
|
unsigned int ntag;
|
|
|
|
unsigned int tagsz;
|
2006-03-01 11:55:46 +01:00
|
|
|
unsigned int sel;
|
2006-01-26 16:24:34 +02:00
|
|
|
Client **client;
|
2006-03-01 11:55:46 +01:00
|
|
|
unsigned int nclient;
|
|
|
|
unsigned int clientsz;
|
2006-02-09 19:40:12 +01:00
|
|
|
Key **key;
|
2006-03-01 11:55:46 +01:00
|
|
|
unsigned int keysz;
|
|
|
|
unsigned int nkey;
|
2006-02-10 15:59:30 +01:00
|
|
|
Label **label;
|
2006-03-01 11:55:46 +01:00
|
|
|
unsigned int nlabel;
|
|
|
|
unsigned int labelsz;
|
2006-03-09 02:43:20 +01:00
|
|
|
char expand[256];
|
2006-03-05 19:20:27 +01:00
|
|
|
char **ctag;
|
|
|
|
unsigned int nctag;
|
|
|
|
unsigned int ctagsz;
|
2005-12-16 03:59:27 +02:00
|
|
|
|
2005-12-05 00:45:59 +02:00
|
|
|
Display *dpy;
|
|
|
|
IXPServer *ixps;
|
2006-01-25 19:39:08 +02:00
|
|
|
int screen;
|
2005-12-05 00:45:59 +02:00
|
|
|
Window root;
|
|
|
|
XRectangle rect;
|
2006-01-30 20:08:58 +02:00
|
|
|
XFontStruct *xfont;
|
2006-01-25 19:39:08 +02:00
|
|
|
GC gc_xor;
|
2006-02-01 23:24:07 +02:00
|
|
|
IXPServer srv;
|
2006-02-09 22:48:01 +01:00
|
|
|
Pixmap pmapbar;
|
|
|
|
Window winbar;
|
|
|
|
GC gcbar;
|
|
|
|
XRectangle brect;
|
|
|
|
Qid root_qid;
|
2006-01-31 14:25:23 +02:00
|
|
|
|
|
|
|
Default def;
|
2006-03-05 00:11:08 +01:00
|
|
|
Atom wm_atom[WMLast];
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-03-05 13:22:42 +01:00
|
|
|
Cursor cursor[CurLast];
|
2005-12-05 00:45:59 +02:00
|
|
|
unsigned int valid_mask, num_lock_mask;
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-02-03 17:15:36 +02:00
|
|
|
/* area.c */
|
2006-03-04 09:23:17 +01:00
|
|
|
Area *alloc_area(Tag *t);
|
2006-02-03 17:15:36 +02:00
|
|
|
void destroy_area(Area *a);
|
2006-03-01 07:51:04 +01:00
|
|
|
int area2index(Area *a);
|
2006-03-04 09:23:17 +01:00
|
|
|
int aid2index(Tag *t, unsigned short id);
|
2006-02-19 15:40:44 +01:00
|
|
|
void update_area_geometry(Area *a);
|
2006-02-19 16:21:01 +01:00
|
|
|
void select_area(Area *a, char *arg);
|
2006-03-08 16:05:09 +01:00
|
|
|
void send2area(Area *to, Area *from, Client *c);
|
2006-03-02 17:38:15 +01:00
|
|
|
void attach_toarea(Area *a, Client *c);
|
2006-03-06 17:22:54 +01:00
|
|
|
void detach_fromarea(Area *a, Client *c);
|
2006-03-04 09:23:17 +01:00
|
|
|
void arrange_tag(Tag *t, Bool updategeometry);
|
2006-03-02 15:28:55 +01:00
|
|
|
void arrange_area(Area *a);
|
|
|
|
void resize_area(Client *c, XRectangle *r, XPoint *pt);
|
2006-03-05 00:11:08 +01:00
|
|
|
int str2mode(char *arg);
|
|
|
|
char *mode2str(int mode);
|
2006-03-06 17:22:54 +01:00
|
|
|
Bool clientofarea(Area *a, Client *c);
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-02-09 22:48:01 +01:00
|
|
|
/* bar.c */
|
2006-03-09 02:15:43 +01:00
|
|
|
Label *get_label(char *name);
|
|
|
|
void destroy_label(Label *l);
|
2006-02-09 22:48:01 +01:00
|
|
|
void draw_bar();
|
2006-03-01 07:51:04 +01:00
|
|
|
int lid2index(unsigned short id);
|
2006-02-10 18:32:35 +01:00
|
|
|
void update_bar_geometry();
|
2006-02-24 10:38:48 +01:00
|
|
|
unsigned int bar_height();
|
2006-03-09 02:15:43 +01:00
|
|
|
Label *name2label(const char *name);
|
|
|
|
int label2index(Label *l);
|
2006-02-09 22:48:01 +01:00
|
|
|
|
2005-11-18 17:54:58 +02:00
|
|
|
/* client.c */
|
2006-01-25 19:39:08 +02:00
|
|
|
Client *alloc_client(Window w, XWindowAttributes *wa);
|
2006-02-24 17:13:58 +01:00
|
|
|
void configure_client(Client *c);
|
2006-03-08 23:53:52 +01:00
|
|
|
void update_client_property(Client *c, XPropertyEvent *e);
|
2006-02-24 17:13:58 +01:00
|
|
|
void kill_client(Client *c);
|
|
|
|
void draw_client(Client *client);
|
2006-03-05 00:38:40 +01:00
|
|
|
void gravitate(Client *c, Bool invert);
|
2006-02-24 17:13:58 +01:00
|
|
|
void unmap_client(Client *c);
|
|
|
|
void map_client(Client *c);
|
|
|
|
void reparent_client(Client *c, Window w, int x, int y);
|
2006-03-08 23:53:52 +01:00
|
|
|
void manage_client(Client *c);
|
2006-03-09 20:25:50 +01:00
|
|
|
void destroy_client(Client *c);
|
2005-12-16 03:59:27 +02:00
|
|
|
Client *sel_client();
|
2006-02-28 08:51:53 +01:00
|
|
|
void focus_client(Client *c);
|
2006-03-01 16:20:02 +01:00
|
|
|
void resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall);
|
2006-02-14 12:06:16 +01:00
|
|
|
void select_client(Client *c, char *arg);
|
2006-03-08 16:05:09 +01:00
|
|
|
void send2area_client(Client *c, char *arg);
|
2006-02-24 10:38:48 +01:00
|
|
|
void resize_all_clients();
|
2006-02-28 08:51:53 +01:00
|
|
|
void focus(Client *c);
|
2006-03-07 17:22:36 +01:00
|
|
|
int cid2index(unsigned short id);
|
2005-11-18 17:54:58 +02:00
|
|
|
|
|
|
|
/* event.c */
|
2006-02-02 17:44:45 +02:00
|
|
|
void init_x_event_handler();
|
2006-02-03 19:11:22 +02:00
|
|
|
void check_x_event(IXPConn *c);
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-03-08 13:00:10 +01:00
|
|
|
/* frame.c */
|
|
|
|
int frid2index(Area *a, unsigned short id);
|
|
|
|
int frame2index(Frame *f);
|
|
|
|
Client *win2clientframe(Window w);
|
|
|
|
|
2006-02-01 23:24:07 +02:00
|
|
|
/* fs.c */
|
2006-02-02 15:50:04 +02:00
|
|
|
unsigned long long mkqpath(unsigned char type, unsigned short pg,
|
|
|
|
unsigned short area, unsigned short cl);
|
2006-02-16 11:53:10 +01:00
|
|
|
void write_event(char *event);
|
2006-02-03 19:11:22 +02:00
|
|
|
void new_ixp_conn(IXPConn *c);
|
2006-02-01 23:24:07 +02:00
|
|
|
|
2006-02-09 19:40:12 +01:00
|
|
|
/* kb.c */
|
|
|
|
void handle_key(Window w, unsigned long mod, KeyCode keycode);
|
|
|
|
void grab_key(Key *k);
|
|
|
|
void ungrab_key(Key *k);
|
2006-03-08 17:45:16 +01:00
|
|
|
Key *name2key(const char *name);
|
2006-03-01 07:51:04 +01:00
|
|
|
int kid2index(unsigned short id);
|
2006-03-08 17:45:16 +01:00
|
|
|
Key *get_key(const char *name);
|
2006-02-09 19:40:12 +01:00
|
|
|
void destroy_key(Key *k);
|
2006-02-09 22:48:01 +01:00
|
|
|
void init_lock_modifiers();
|
2006-02-09 19:40:12 +01:00
|
|
|
|
2005-11-18 17:54:58 +02:00
|
|
|
/* mouse.c */
|
2006-01-26 13:56:28 +02:00
|
|
|
void mouse_resize(Client *c, Align align);
|
|
|
|
void mouse_move(Client *c);
|
|
|
|
Cursor cursor_for_motion(Client *c, int x, int y);
|
2006-03-05 13:22:42 +01:00
|
|
|
Align cursor2align(Cursor cur);
|
|
|
|
Align xy2align(XRectangle *rect, int x, int y);
|
2006-01-26 13:56:28 +02:00
|
|
|
void drop_move(Client *c, XRectangle *new, XPoint *pt);
|
2006-02-09 19:40:12 +01:00
|
|
|
void grab_mouse(Window w, unsigned long mod, unsigned int button);
|
|
|
|
void ungrab_mouse(Window w, unsigned long mod, unsigned int button);
|
2006-02-16 01:05:16 +01:00
|
|
|
char *warp_mouse(char *arg);
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-03-10 11:50:52 +01:00
|
|
|
/* rule.c */
|
2006-03-10 14:17:32 +01:00
|
|
|
void match_tags(char *ruledef, Client *c);
|
2006-03-10 11:50:52 +01:00
|
|
|
|
2006-03-04 09:23:17 +01:00
|
|
|
/* tag.c */
|
2006-03-05 19:20:27 +01:00
|
|
|
Tag *alloc_tag(char *name);
|
2006-03-04 09:23:17 +01:00
|
|
|
char *destroy_tag(Tag *t);
|
|
|
|
void focus_tag(Tag *t);
|
2005-12-05 00:45:59 +02:00
|
|
|
XRectangle *rectangles(unsigned int *num);
|
2006-03-05 16:48:14 +01:00
|
|
|
int tid2index(unsigned short id);
|
2006-03-04 09:23:17 +01:00
|
|
|
void select_tag(char *arg);
|
|
|
|
int tag2index(Tag *t);
|
2006-03-09 00:27:12 +01:00
|
|
|
Bool has_tag(char **tags, char *tag, unsigned int ntags);
|
2006-03-08 23:53:52 +01:00
|
|
|
void update_tags();
|
2006-03-06 17:22:54 +01:00
|
|
|
Bool clientoftag(Tag *t, Client *c);
|
2006-03-09 20:25:50 +01:00
|
|
|
void detach_fromtag(Tag *t, Client *c);
|
2006-03-07 17:22:36 +01:00
|
|
|
void attach_totag(Tag *t, Client *c);
|
2006-03-08 22:41:45 +01:00
|
|
|
Client *sel_client_of_tag(Tag *t);
|
2006-03-09 13:19:12 +01:00
|
|
|
void restack_tag(Tag *t);
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2005-12-05 03:15:25 +02:00
|
|
|
/* wm.c */
|
|
|
|
void scan_wins();
|
2006-03-01 07:51:04 +01:00
|
|
|
Client *win2client(Window w);
|
2005-12-05 03:15:25 +02:00
|
|
|
int win_proto(Window w);
|
|
|
|
int win_state(Window w);
|
2006-03-09 20:25:50 +01:00
|
|
|
int wmii_error_handler(Display *dpy, XErrorEvent *error);
|