wmii/cmd/wm/wm.h

333 lines
7.0 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 <regex.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
};
/* NET atoms */
enum {
NetSupported,
NetWMName,
NetLast
};
2006-03-05 15:22:42 +03:00
/* Column modes */
2006-03-05 02:11:08 +03:00
enum {
Coldefault,
2006-03-05 02:11:08 +03:00
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-04-06 09:55:33 +04:00
enum { MIN_COLWIDTH = 64 };
enum { WM_PROTOCOL_DELWIN = 1 };
2005-11-18 18:54:58 +03:00
typedef struct View View;
typedef struct Area Area;
typedef struct Frame Frame;
2005-11-18 18:54:58 +03:00
typedef struct Client Client;
struct View {
2006-06-08 12:54:19 +04:00
View *next;
2006-04-06 13:31:54 +04:00
char name[256];
unsigned short id;
2006-06-08 12:54:19 +04:00
Area *area;
Area *sel;
Area *revert;
};
typedef struct ViewLink ViewLink;
struct ViewLink {
ViewLink *next;
View *view;
};
struct Area {
2006-06-08 12:54:19 +04:00
Area *next;
Frame *frame;
Frame *sel;
View *view;
2006-06-08 12:54:19 +04:00
unsigned short id;
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 {
2006-06-08 12:54:19 +04:00
Frame *cnext;
Frame *anext;
Area *area;
unsigned short id;
XRectangle rect;
2006-06-12 14:11:22 +04:00
XRectangle revert;
Client *client;
2006-06-12 14:11:22 +04:00
Bool collapsed;
BlitzWidget *tile;
BlitzWidget *tagbar;
BlitzWidget *titlebar;
BlitzWidget *posbar;
};
struct Client {
2006-06-08 12:54:19 +04:00
Client *next;
ViewLink *views;
Area *revert;
Frame *frame;
Frame *sel;
char name[256];
2006-04-06 13:31:54 +04:00
char tags[256];
char props[512];
2006-06-08 12:54:19 +04:00
unsigned short id;
unsigned int border;
2006-06-08 12:54:19 +04:00
int proto;
Bool floating;
Bool fixedsize;
Window win;
Window trans;
2006-06-08 12:54:19 +04:00
Window framewin;
XRectangle rect;
XSizeHints size;
GC gc;
2005-11-18 18:54:58 +03:00
};
typedef struct Key Key;
struct Key {
2006-06-08 12:54:19 +04:00
Key *next;
Key *lnext;
Key *tnext;
unsigned short id;
char name[128];
unsigned long mod;
KeyCode key;
};
2006-06-08 12:54:19 +04:00
typedef struct Bar Bar;
struct Bar {
Bar *next;
2006-06-17 15:32:49 +04:00
char buf[280];
char name[256];
2006-06-08 12:54:19 +04:00
unsigned short id;
BlitzWidget *bar;
2006-06-08 12:54:19 +04:00
};
2006-06-17 15:32:49 +04:00
typedef struct Rule Rule;
struct Rule {
Rule *next;
regex_t regex;
char value[256];
};
typedef struct Rules {
Rule *rule;
char *string;
unsigned int size;
} Rules;
/* default values */
typedef struct {
BlitzColor selcolor;
BlitzColor normcolor;
BlitzFont font;
unsigned int border;
unsigned int snap;
char *keys;
unsigned int keyssz;
2006-06-17 15:32:49 +04:00
Rules tagrules;
Rules colrules;
char grabmod[5];
unsigned long mod;
int colmode;
} Default;
2006-04-06 10:09:22 +04:00
/* global variables */
2006-06-08 12:54:19 +04:00
View *view;
Client *client;
Key *key;
2006-06-17 15:32:49 +04:00
Bar *lbar;
Bar *rbar;
2006-06-08 12:54:19 +04:00
View *sel;
2006-06-17 15:32:49 +04:00
P9Srv p9srv;
2005-12-05 01:45:59 +03:00
Display *dpy;
int screen;
2005-12-05 01:45:59 +03:00
Window root;
XRectangle rect;
IXPServer srv;
Pixmap barpmap;
Window barwin;
GC bargc;
GC xorgc;
BlitzWidget *bartile;
XRectangle brect;
2006-06-22 11:28:39 +04:00
char *user;
2006-01-31 15:25:23 +03:00
Default def;
2006-03-05 02:11:08 +03:00
Atom wm_atom[WMLast];
Atom net_atom[NetLast];
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;
Bool sel_screen;
void (*handler[LASTEvent]) (XEvent *);
/* wm.c */
char *message_root(char *message);
2005-11-18 18:54:58 +03:00
/* area.c */
2006-06-08 12:54:19 +04:00
Area *create_area(View *v, Area *pos, unsigned int w);
void destroy_area(Area *a);
2006-06-08 12:54:19 +04:00
Area *area_of_id(View *t, unsigned short id);
2006-06-20 02:25:49 +04:00
char *select_area(Area *a, char *arg);
2006-04-12 12:44:07 +04:00
void send_to_area(Area *to, Area *from, Client *c);
void attach_to_area(Area *a, Client *c, Bool send);
2006-04-12 12:44:07 +04:00
void detach_from_area(Area *a, Client *c);
Bool is_of_area(Area *a, Client *c);
2006-06-08 12:54:19 +04:00
int idx_of_area(Area *a);
Client *sel_client_of_area(Area *a);
2005-11-18 18:54:58 +03:00
/* bar.c */
Bar *create_bar(Bar **b_link, char *name);
void destroy_bar(Bar **b_link, Bar *b);
void draw_bar();
2006-06-08 12:54:19 +04:00
Bar *bar_of_id(unsigned short id);
2006-04-12 12:44:07 +04:00
void resize_bar();
unsigned int height_of_bar();
Bar *bar_of_name(const char *name);
2005-11-18 18:54:58 +03:00
/* client.c */
2006-04-12 12:44:07 +04:00
Client *create_client(Window w, XWindowAttributes *wa);
void destroy_client(Client *c);
2006-02-24 19:13:58 +03:00
void configure_client(Client *c);
2006-04-12 12:44:07 +04:00
void prop_client(Client *c, XPropertyEvent *e);
2006-02-24 19:13:58 +03:00
void kill_client(Client *c);
2006-04-12 12:44:07 +04:00
void gravitate_client(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 focus_client(Client *c, Bool restack);
void focus(Client *c, Bool restack);
void resize_client(Client *c, XRectangle *r, Bool ignore_xcall);
2006-06-08 12:54:19 +04:00
void match_sizehints(Client *c, XRectangle *r, Bool floating, BlitzAlign sticky);
char *send_client(Frame *f, char *arg);
2006-06-20 02:25:49 +04:00
char * message_client(Client *c, char *message);
void move_client(Client *c, char *arg);
void size_client(Client *c, char *arg);
void newcol_client(Client *c, char *arg);
void resize_all_clients();
2006-04-12 12:44:07 +04:00
Client *sel_client();
2006-06-08 12:54:19 +04:00
Client *client_of_id(unsigned short id);
2006-04-12 12:44:07 +04:00
int idx_of_client_id(unsigned short id);
Client *client_of_win(Window w);
2006-06-08 12:54:19 +04:00
int idx_of_client(Client *c);
2006-04-27 20:32:37 +04:00
void update_client_grab(Client *c, Bool is_sel);
void apply_rules(Client *c);
void apply_tags(Client *c, const char *tags);
2006-04-12 12:44:07 +04:00
/* column.c */
void arrange_column(Area *a, Bool dirty);
2006-04-24 18:03:37 +04:00
void scale_column(Area *a, float h);
2006-04-12 12:44:07 +04:00
void resize_column(Client *c, XRectangle *r, XPoint *pt);
int column_mode_of_str(char *arg);
char *str_of_column_mode(int mode);
2006-06-08 12:54:19 +04:00
Area *new_column(View *v, Area *pos, unsigned int w);
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);
unsigned int flush_masked_events(long even_mask);
2005-11-18 18:54:58 +03:00
2006-03-08 15:00:10 +03:00
/* frame.c */
2006-04-12 12:44:07 +04:00
Frame *create_frame(Area *a, Client *c);
void destroy_frame(Frame *f);
2006-06-08 12:54:19 +04:00
void remove_frame(Frame *f);
void insert_frame(Frame *pos, Frame *f, Bool before);
2006-04-12 12:44:07 +04:00
int idx_of_frame(Frame *f);
2006-06-08 12:54:19 +04:00
Frame *frame_of_id(Area *a, unsigned short id);
2006-04-12 12:44:07 +04:00
Client *frame_of_win(Window w);
void draw_frame(Frame *f);
void draw_frames();
void resize_frame(Frame *f);
void update_frame_widget_colors(Frame *f);
2006-03-08 15:00:10 +03:00
/* fs.c */
2006-06-17 15:32:49 +04:00
void fs_attach(Req *r);
void fs_clunk(Req *r);
void fs_create(Req *r);
void fs_flush(Req *r);
void fs_freefid(Fid *f);
void fs_open(Req *r);
void fs_read(Req *r);
void fs_remove(Req *r);
void fs_stat(Req *r);
void fs_walk(Req *r);
void fs_write(Req *r);
void write_event(char *buf);
/* geom.c */
BlitzAlign quadofcoord(XRectangle *rect, int x, int y);
Bool ispointinrect(int x, int y, XRectangle * r);
int strtorect(XRectangle *r, const char *val);
2006-04-12 12:44:07 +04:00
/* key.c */
void handle_key(Window w, unsigned long mod, KeyCode keycode);
void update_keys();
2006-04-12 12:44:07 +04:00
void init_lock_keys();
unsigned long mod_key_of_str(char *val);
2005-11-18 18:54:58 +03:00
/* mouse.c */
void do_mouse_resize(Client *c,BlitzAlign align);
void grab_mouse(Window w, unsigned long mod, unsigned int button);
void ungrab_mouse(Window w, unsigned long mod, unsigned int button);
BlitzAlign snap_rect(XRectangle *rects, int num, XRectangle *current,
BlitzAlign *mask, int snap);
2005-11-18 18:54:58 +03:00
/* rule.c */
2006-06-08 12:54:19 +04:00
void update_rules(Rule **rule, const char *data);
/* view.c */
2006-04-24 19:19:50 +04:00
void arrange_view(View *v);
void scale_view(View *v, float w);
2006-06-08 12:54:19 +04:00
View *create_view(const char *name);
void focus_view(View *v);
void update_client_views(Client *c);
XRectangle *rects_of_view(View *v, unsigned int *num);
2006-06-08 12:54:19 +04:00
View *view_of_id(unsigned short id);
2006-05-24 11:26:08 +04:00
void select_view(const char *arg);
2006-04-12 12:44:07 +04:00
void detach_from_view(View *v, Client *c);
void attach_to_view(View *v, Client *c);
Client *sel_client_of_view(View *v);
char *message_view(View *v, char *message);
void restack_view(View *v);
2006-05-24 11:26:08 +04:00
View *view_of_name(const char *name);
2006-06-17 15:32:49 +04:00
unsigned char * view_index(View *v);
2006-06-08 12:54:19 +04:00
void destroy_view(View *v);
2006-04-11 12:16:01 +04:00
void update_views();
unsigned int newcolw_of_view(View *v);
2005-11-18 18:54:58 +03:00
2005-12-05 04:15:25 +03:00
/* wm.c */
void scan_wins();
int win_proto(Window w);
int win_state(Window w);
int wmii_error_handler(Display *dpy, XErrorEvent *error);