wmii/cmd/wm/wm.h

320 lines
6.4 KiB
C
Raw Normal View History

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>
#include <X11/Xlib.h>
2005-11-18 18:54:58 +03:00
#include <X11/Xutil.h>
#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,
CurW,
CurE,
CurN,
CurS,
CurNW,
CurNE,
CurSW,
CurSE,
CurLast
};
2006-02-02 16:50:04 +03:00
/* 8-bit qid.path.type */
enum {
2006-03-05 16:16:48 +03:00
FsDroot,
FsDdef,
FsDws,
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,
FsDlabel,
FsFexpand,
FsFdata,
2006-03-05 16:16:48 +03:00
FsFcolors,
FsFfont,
FsFselcolors,
FsFnormcolors,
FsFkeys,
2006-03-05 16:16:48 +03:00
FsFborder,
FsFsnap,
FsFbar,
FsFgeom,
FsFevent,
FsFctl,
FsFname,
2006-03-10 16:39:46 +03:00
FsFrules,
FsFtags,
2006-03-10 13:59:26 +03:00
FsFclass,
FsFtag,
2006-03-05 16:16:48 +03:00
FsFmode
2006-02-02 16:50:04 +03:00
};
2006-03-15 11:02:25 +03:00
#define MAX_TAGS 8
#define MAX_TAGLEN 32
2006-02-02 21:32:25 +03:00
#define DEF_BORDER 3
#define DEF_SNAP 20
2005-11-18 18:54:58 +03:00
#define ROOT_MASK SubstructureRedirectMask
#define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask)
2006-03-13 11:22:35 +03:00
#define WM_PROTOCOL_DELWIN 1
2005-11-18 18:54:58 +03:00
typedef struct Tag Tag;
typedef struct Area Area;
typedef struct Frame Frame;
2005-11-18 18:54:58 +03:00
typedef struct Client Client;
struct Tag {
char name[256];
unsigned short id;
Area **area;
unsigned int areasz;
unsigned int narea;
unsigned int sel;
unsigned int revert;
};
struct Area {
unsigned short id;
Frame **frame;
Tag *tag;
unsigned int framesz;
unsigned int sel;
unsigned int nframe;
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
};
struct Frame {
Area *area;
unsigned short id;
XRectangle rect;
Client *client;
};
struct Client {
2006-03-07 19:22:36 +03:00
unsigned short id;
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];
2005-12-21 18:18:11 +03:00
int proto;
unsigned int border;
Bool destroyed;
Window win;
Window trans;
XRectangle rect;
XSizeHints size;
2006-03-05 02:25:49 +03:00
Window framewin;
GC gc;
Cursor cursor;
Frame **frame;
unsigned int framesz;
unsigned int sel;
unsigned int nframe;
Area *revert;
2005-11-18 18:54:58 +03:00
};
typedef struct Key Key;
struct Key {
unsigned short id;
char name[128];
unsigned long mod;
KeyCode key;
Key *next;
};
typedef struct {
2006-03-09 04:15:43 +03:00
char name[256];
unsigned short id;
char data[256];
char colstr[24];
Color color;
XRectangle rect;
} Label;
/* default values */
typedef struct {
char selcolor[24];
char normcolor[24];
char tag[256];
char *font;
Color sel;
Color norm;
unsigned int border;
unsigned int snap;
char *keys;
unsigned int keyssz;
2006-03-10 16:39:46 +03:00
char *rules;
unsigned int rulessz;
} Default;
2005-11-18 18:54:58 +03:00
/* global variables */
Tag **tag;
unsigned int ntag;
unsigned int tagsz;
unsigned int sel;
2006-01-26 17:24:34 +03:00
Client **client;
unsigned int nclient;
unsigned int clientsz;
Key **key;
unsigned int keysz;
unsigned int nkey;
Label **label;
unsigned int nlabel;
unsigned int labelsz;
2006-03-09 04:43:20 +03:00
char expand[256];
char **ctag;
unsigned int nctag;
unsigned int ctagsz;
2005-12-05 01:45:59 +03:00
Display *dpy;
IXPServer *ixps;
int screen;
2005-12-05 01:45:59 +03:00
Window root;
XRectangle rect;
XFontStruct *xfont;
GC xorgc;
IXPServer srv;
Pixmap barpmap;
Window barwin;
GC bargc;
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];
2005-11-18 18:54:58 +03:00
2006-03-05 15:22:42 +03:00
Cursor cursor[CurLast];
2005-12-05 01:45:59 +03:00
unsigned int valid_mask, num_lock_mask;
2005-11-18 18:54:58 +03:00
/* area.c */
Area *alloc_area(Tag *t);
void destroy_area(Area *a);
int area2index(Area *a);
int aid2index(Tag *t, unsigned short id);
void select_area(Area *a, char *arg);
void send2area(Area *to, Area *from, Client *c);
2006-03-02 19:38:15 +03:00
void attach_toarea(Area *a, Client *c);
void detach_fromarea(Area *a, Client *c);
void arrange_tag(Tag *t, Bool updategeometry);
2006-03-02 17:28:55 +03:00
void arrange_area(Area *a);
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);
Bool clientofarea(Area *a, Client *c);
2005-11-18 18:54:58 +03:00
/* bar.c */
2006-03-09 04:15:43 +03:00
Label *get_label(char *name);
void destroy_label(Label *l);
void draw_bar();
int lid2index(unsigned short id);
void update_bar_geometry();
unsigned int bar_height();
2006-03-09 04:15:43 +03:00
Label *name2label(const char *name);
int label2index(Label *l);
2005-11-18 18:54:58 +03:00
/* client.c */
Client *alloc_client(Window w, XWindowAttributes *wa);
2006-02-24 19:13:58 +03:00
void configure_client(Client *c);
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);
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);
void manage_client(Client *c);
void destroy_client(Client *c);
Client *sel_client();
void focus_client(Client *c);
2006-03-01 18:20:02 +03:00
void resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall);
2006-02-14 14:06:16 +03:00
void select_client(Client *c, char *arg);
void send2area_client(Client *c, char *arg);
void resize_all_clients();
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
void tags4client(Client *c, const char *tags);
void client2tags(Client *c, char *tags, unsigned int tagsz);
Bool clienthastag(Client *c, const char *t);
2005-11-18 18:54:58 +03:00
/* event.c */
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);
/* fs.c */
2006-02-02 16:50:04 +03:00
unsigned long long mkqpath(unsigned char type, unsigned short pg,
unsigned short area, unsigned short cl);
2006-02-16 13:53:10 +03:00
void write_event(char *event);
2006-02-03 20:11:22 +03:00
void new_ixp_conn(IXPConn *c);
/* kb.c */
void handle_key(Window w, unsigned long mod, KeyCode keycode);
void update_keys();
void init_lock_modifiers();
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);
Cursor cursor_for_motion(Client *c, int x, int y);
2006-03-05 15:22:42 +03:00
Align cursor2align(Cursor cur);
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);
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
/* rule.c */
void match_tags(Client *c);
/* tag.c */
Tag *alloc_tag(char *name);
char *destroy_tag(Tag *t);
void focus_tag(Tag *t);
XRectangle *rectangles(Tag *t, Bool isfloat, unsigned int *num);
int tid2index(unsigned short id);
void select_tag(char *arg);
int tag2index(Tag *t);
void update_tags();
Bool clientoftag(Tag *t, Client *c);
void detach_fromtag(Tag *t, Client *c);
2006-03-07 19:22:36 +03:00
void attach_totag(Tag *t, Client *c);
Client *sel_client_of_tag(Tag *t);
void restack_tag(Tag *t);
2006-03-15 11:02:25 +03:00
unsigned int str2tags(const char *stags, char tags[MAX_TAGS][MAX_TAGLEN]);
2005-11-18 18:54:58 +03:00
2005-12-05 04:15:25 +03:00
/* wm.c */
void scan_wins();
Client *win2client(Window w);
2005-12-05 04:15:25 +03:00
int win_proto(Window w);
int win_state(Window w);
int wmii_error_handler(Display *dpy, XErrorEvent *error);