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-02-10 00:48:01 +03:00
|
|
|
|
#include "ixp.h"
|
|
|
|
|
#include "blitz.h"
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
2005-12-27 23:13:50 +03:00
|
|
|
|
/* array indexes of EWMH window properties */
|
|
|
|
|
/* TODO: set / react */
|
|
|
|
|
enum {
|
|
|
|
|
NET_NUMBER_OF_DESKTOPS, /* ✓ – */
|
|
|
|
|
NET_CURRENT_DESKTOP, /* ✓ ✓ */
|
|
|
|
|
NET_WM_DESKTOP /* ✗ ✗ */
|
|
|
|
|
};
|
|
|
|
|
|
2006-02-02 16:50:04 +03:00
|
|
|
|
/* 8-bit qid.path.type */
|
|
|
|
|
enum {
|
|
|
|
|
Droot,
|
2006-02-09 21:40:12 +03:00
|
|
|
|
Ddef,
|
2006-02-02 16:50:04 +03:00
|
|
|
|
Dpage,
|
|
|
|
|
Darea,
|
|
|
|
|
Dclient,
|
2006-02-09 21:40:12 +03:00
|
|
|
|
Dkeys,
|
2006-02-10 00:48:01 +03:00
|
|
|
|
Dbar,
|
2006-02-10 17:59:30 +03:00
|
|
|
|
Dlabel,
|
2006-02-10 00:48:01 +03:00
|
|
|
|
Fexpand,
|
|
|
|
|
Fdata, /* data to display */
|
2006-02-10 20:32:35 +03:00
|
|
|
|
Fcolors,
|
|
|
|
|
Ffont,
|
|
|
|
|
Fselcolors,
|
|
|
|
|
Fnormcolors,
|
2006-02-09 21:40:12 +03:00
|
|
|
|
Fkey,
|
2006-02-02 16:50:04 +03:00
|
|
|
|
Fborder,
|
|
|
|
|
Fsnap,
|
2006-02-02 22:36:10 +03:00
|
|
|
|
Fbar,
|
2006-02-02 16:50:04 +03:00
|
|
|
|
Finc,
|
|
|
|
|
Fgeom,
|
|
|
|
|
Fevent,
|
|
|
|
|
Fctl,
|
2006-02-28 18:23:05 +03:00
|
|
|
|
Fname,
|
|
|
|
|
Fmax,
|
|
|
|
|
Fmode
|
2006-02-02 16:50:04 +03:00
|
|
|
|
};
|
|
|
|
|
|
2005-12-27 23:13:50 +03:00
|
|
|
|
#define NET_ATOM_COUNT 3
|
|
|
|
|
|
2005-11-18 18:54:58 +03:00
|
|
|
|
#define PROTO_DEL 1
|
2006-02-02 21:32:25 +03:00
|
|
|
|
#define DEF_BORDER 3
|
|
|
|
|
#define DEF_SNAP 20
|
|
|
|
|
#define DEF_PAGER_GAP 5
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
2005-12-15 04:08:26 +03:00
|
|
|
|
#define ROOT_MASK SubstructureRedirectMask
|
2006-01-12 20:03:49 +03:00
|
|
|
|
#define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask)
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
2006-02-01 18:27:53 +03:00
|
|
|
|
typedef struct Area Area;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
typedef struct Page Page;
|
|
|
|
|
typedef struct Client Client;
|
|
|
|
|
|
2006-02-28 19:13:16 +03:00
|
|
|
|
typedef enum { COL_EQUAL, COL_STACK, COL_MAX, COL_MODE_LAST } ColumnMode;
|
2006-02-28 15:38:24 +03:00
|
|
|
|
|
2006-02-01 18:27:53 +03:00
|
|
|
|
struct Area {
|
2006-02-03 18:15:36 +03:00
|
|
|
|
unsigned short id;
|
2006-01-26 17:24:34 +03:00
|
|
|
|
Client **client;
|
2006-02-11 17:22:42 +03:00
|
|
|
|
Page *page;
|
2006-01-26 17:24:34 +03:00
|
|
|
|
size_t clientsz;
|
2006-01-25 20:39:08 +03:00
|
|
|
|
size_t sel;
|
2006-01-31 15:25:23 +03:00
|
|
|
|
size_t nclient;
|
2006-02-28 15:38:24 +03:00
|
|
|
|
size_t maxclient;
|
|
|
|
|
ColumnMode mode;
|
2006-01-26 17:24:34 +03:00
|
|
|
|
XRectangle rect;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
};
|
|
|
|
|
|
2006-01-25 20:39:08 +03:00
|
|
|
|
struct Page {
|
2006-02-03 18:15:36 +03:00
|
|
|
|
unsigned short id;
|
2006-02-01 18:27:53 +03:00
|
|
|
|
Area **area;
|
|
|
|
|
size_t areasz;
|
|
|
|
|
size_t narea;
|
|
|
|
|
size_t sel;
|
2006-02-16 03:05:16 +03:00
|
|
|
|
Page *revert;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Client {
|
2006-02-03 18:15:36 +03:00
|
|
|
|
unsigned short id;
|
2006-01-25 20:39:08 +03:00
|
|
|
|
char name[256];
|
2005-12-21 18:18:11 +03:00
|
|
|
|
int proto;
|
|
|
|
|
unsigned int border;
|
|
|
|
|
Bool destroyed;
|
2006-02-01 18:27:53 +03:00
|
|
|
|
Area *area;
|
2005-12-21 18:18:11 +03:00
|
|
|
|
Window win;
|
|
|
|
|
Window trans;
|
|
|
|
|
XRectangle rect;
|
|
|
|
|
XSizeHints size;
|
2006-02-09 02:50:30 +03:00
|
|
|
|
Client *revert;
|
2006-01-25 20:39:08 +03:00
|
|
|
|
struct Frame {
|
|
|
|
|
Window win;
|
|
|
|
|
XRectangle rect;
|
|
|
|
|
XRectangle revert;
|
|
|
|
|
GC gc;
|
|
|
|
|
Cursor cursor;
|
|
|
|
|
} frame;
|
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;
|
|
|
|
|
char name[128];
|
|
|
|
|
unsigned long mod;
|
|
|
|
|
KeyCode key;
|
|
|
|
|
Key *next;
|
|
|
|
|
};
|
|
|
|
|
|
2006-02-10 00:48:01 +03:00
|
|
|
|
typedef struct {
|
|
|
|
|
unsigned short id;
|
|
|
|
|
char data[256];
|
|
|
|
|
char colstr[24];
|
|
|
|
|
Color color;
|
|
|
|
|
XRectangle rect;
|
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];
|
|
|
|
|
char *font;
|
|
|
|
|
Bool inc;
|
|
|
|
|
Color sel;
|
|
|
|
|
Color norm;
|
|
|
|
|
unsigned int border;
|
|
|
|
|
unsigned int snap;
|
|
|
|
|
} Default;
|
|
|
|
|
|
2005-11-18 18:54:58 +03:00
|
|
|
|
/* global variables */
|
2006-01-26 17:24:34 +03:00
|
|
|
|
Page **page;
|
2006-01-31 15:25:23 +03:00
|
|
|
|
size_t npage;
|
2006-01-26 17:24:34 +03:00
|
|
|
|
size_t pagesz;
|
2006-02-02 00:24:07 +03:00
|
|
|
|
size_t sel;
|
2006-01-26 17:24:34 +03:00
|
|
|
|
Client **client;
|
2006-02-02 00:24:07 +03:00
|
|
|
|
size_t nclient;
|
2006-01-26 17:24:34 +03:00
|
|
|
|
size_t clientsz;
|
2006-02-09 21:40:12 +03:00
|
|
|
|
Key **key;
|
|
|
|
|
size_t keysz;
|
|
|
|
|
size_t nkey;
|
2006-02-10 17:59:30 +03:00
|
|
|
|
Label **label;
|
|
|
|
|
size_t nlabel;
|
|
|
|
|
size_t labelsz;
|
2006-02-10 00:48:01 +03:00
|
|
|
|
size_t iexpand;
|
2005-12-16 04:59:27 +03:00
|
|
|
|
|
2005-12-05 01:45:59 +03:00
|
|
|
|
Display *dpy;
|
|
|
|
|
IXPServer *ixps;
|
2006-01-25 20:39:08 +03:00
|
|
|
|
int screen;
|
2005-12-05 01:45:59 +03:00
|
|
|
|
Window root;
|
2006-01-25 20:39:08 +03:00
|
|
|
|
Window transient; /* pager / attach */
|
2005-12-05 01:45:59 +03:00
|
|
|
|
XRectangle rect;
|
2006-01-30 21:08:58 +03:00
|
|
|
|
XFontStruct *xfont;
|
2006-01-25 20:39:08 +03:00
|
|
|
|
GC gc_xor;
|
|
|
|
|
GC gc_transient;
|
2006-02-02 00:24:07 +03:00
|
|
|
|
IXPServer srv;
|
2006-02-10 00:48:01 +03:00
|
|
|
|
Pixmap pmapbar;
|
|
|
|
|
Window winbar;
|
|
|
|
|
GC gcbar;
|
|
|
|
|
XRectangle brect;
|
|
|
|
|
Qid root_qid;
|
2006-01-31 15:25:23 +03:00
|
|
|
|
|
|
|
|
|
Default def;
|
2006-01-30 21:08:58 +03:00
|
|
|
|
|
2005-12-27 23:13:50 +03:00
|
|
|
|
Atom wm_state; /* TODO: Maybe replace with wm_atoms[WM_ATOM_COUNT]? */
|
2005-12-05 01:45:59 +03:00
|
|
|
|
Atom wm_change_state;
|
|
|
|
|
Atom wm_protocols;
|
|
|
|
|
Atom wm_delete;
|
|
|
|
|
Atom motif_wm_hints;
|
2005-12-27 23:13:50 +03:00
|
|
|
|
Atom net_atoms[NET_ATOM_COUNT];
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
2005-12-05 01:45:59 +03:00
|
|
|
|
Cursor normal_cursor;
|
|
|
|
|
Cursor resize_cursor;
|
|
|
|
|
Cursor move_cursor;
|
|
|
|
|
Cursor drag_cursor;
|
|
|
|
|
Cursor w_cursor;
|
|
|
|
|
Cursor e_cursor;
|
|
|
|
|
Cursor n_cursor;
|
|
|
|
|
Cursor s_cursor;
|
|
|
|
|
Cursor nw_cursor;
|
|
|
|
|
Cursor ne_cursor;
|
|
|
|
|
Cursor sw_cursor;
|
|
|
|
|
Cursor se_cursor;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
2005-12-05 01:45:59 +03:00
|
|
|
|
unsigned int valid_mask, num_lock_mask;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
2006-02-03 18:15:36 +03:00
|
|
|
|
/* area.c */
|
2006-02-10 19:09:59 +03:00
|
|
|
|
Area *alloc_area(Page *p);
|
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);
|
|
|
|
|
int aid2index(Page *p, unsigned short id);
|
2006-02-19 17:40:44 +03:00
|
|
|
|
void update_area_geometry(Area *a);
|
2006-02-19 18:21:01 +03:00
|
|
|
|
void select_area(Area *a, char *arg);
|
2006-02-24 12:06:02 +03:00
|
|
|
|
void sendto_area(Area *new, Client *c);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
2006-02-10 00:48:01 +03:00
|
|
|
|
/* bar.c */
|
2006-02-10 17:59:30 +03:00
|
|
|
|
Label *new_label();
|
|
|
|
|
void detach_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-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 destroy_client(Client *c);
|
|
|
|
|
void configure_client(Client *c);
|
|
|
|
|
void handle_client_property(Client *c, XPropertyEvent *e);
|
|
|
|
|
void kill_client(Client *c);
|
|
|
|
|
void draw_client(Client *client);
|
|
|
|
|
void gravitate(Client *c, unsigned int tabh, unsigned int bw, int invert);
|
|
|
|
|
void unmap_client(Client *c);
|
|
|
|
|
void map_client(Client *c);
|
|
|
|
|
void reparent_client(Client *c, Window w, int x, int y);
|
|
|
|
|
void attach_client(Client *c);
|
2006-03-01 09:51:04 +03:00
|
|
|
|
void attach_client2page(Page *p, Client *c);
|
2006-02-24 19:13:58 +03:00
|
|
|
|
void detach_client(Client *c, Bool unmap);
|
2005-12-16 04:59:27 +03:00
|
|
|
|
Client *sel_client();
|
2006-01-26 20:29:49 +03:00
|
|
|
|
Client *sel_client_of_page(Page *p);
|
2006-02-28 10:51:53 +03:00
|
|
|
|
void focus_client(Client *c);
|
2006-03-01 09:51:04 +03:00
|
|
|
|
Client *win2clientframe(Window w);
|
2006-02-24 19:13:58 +03:00
|
|
|
|
void resize_client(Client *c, XRectangle *r, XPoint *pt);
|
2006-03-01 09:51:04 +03:00
|
|
|
|
int cid2index(Area *a, unsigned short id);
|
|
|
|
|
int client2index(Client *c);
|
2006-02-14 14:06:16 +03:00
|
|
|
|
void select_client(Client *c, char *arg);
|
2006-02-24 11:52:20 +03:00
|
|
|
|
void sendtopage_client(Client *c, char *arg);
|
|
|
|
|
void sendtoarea_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);
|
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-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,
|
|
|
|
|
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);
|
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);
|
|
|
|
|
void grab_key(Key *k);
|
|
|
|
|
void ungrab_key(Key *k);
|
2006-03-01 09:51:04 +03:00
|
|
|
|
Key * name2key(char *name);
|
|
|
|
|
int kid2index(unsigned short id);
|
2006-02-09 21:40:12 +03:00
|
|
|
|
Key *create_key(char *name);
|
|
|
|
|
void destroy_key(Key *k);
|
2006-02-10 00:48:01 +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);
|
|
|
|
|
Cursor cursor_for_motion(Client *c, int x, int y);
|
2006-03-01 09:51:04 +03:00
|
|
|
|
Align cursor2align(Cursor cursor);
|
|
|
|
|
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);
|
2006-02-16 03:05:16 +03:00
|
|
|
|
char *warp_mouse(char *arg);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
|
|
|
|
/* page.c */
|
2006-01-26 14:56:28 +03:00
|
|
|
|
Page *alloc_page();
|
2006-02-28 15:38:24 +03:00
|
|
|
|
char *destroy_page(Page *p);
|
2006-01-26 14:56:28 +03:00
|
|
|
|
void focus_page(Page *p);
|
2005-12-05 01:45:59 +03:00
|
|
|
|
XRectangle *rectangles(unsigned int *num);
|
2006-03-01 09:51:04 +03:00
|
|
|
|
int pid2index(unsigned short id);
|
2006-02-10 19:51:20 +03:00
|
|
|
|
void select_page(char *arg);
|
2006-03-01 09:51:04 +03:00
|
|
|
|
int page2index(Page *p);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
2006-02-10 00:48:01 +03:00
|
|
|
|
/* spawn.c */
|
|
|
|
|
void spawn(char *cmd);
|
|
|
|
|
|
2006-01-25 20:39:08 +03:00
|
|
|
|
/* column.c */
|
2006-02-19 17:40:44 +03:00
|
|
|
|
void arrange_page(Page *p, Bool update_colums);
|
|
|
|
|
void arrange_column(Area *col);
|
2006-01-26 14:39:20 +03:00
|
|
|
|
void resize_column(Client *c, XRectangle *r, XPoint *pt);
|
2006-02-19 17:56:16 +03:00
|
|
|
|
Area *new_column(Area *old);
|
2006-03-01 09:51:04 +03:00
|
|
|
|
ColumnMode str2colmode(char *arg);
|
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-01-30 21:08:58 +03:00
|
|
|
|
/*void handle_after_write(IXPServer * s, File * f);*/
|
2006-02-06 11:46:52 +03:00
|
|
|
|
void pager();
|
|
|
|
|
|