2005-11-18 18:54:58 +03:00
|
|
|
/*
|
|
|
|
* (C)opyright MMIV-MMV Anselm R. Garbe <garbeam at gmail dot com>
|
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
|
|
|
#include "wmii.h"
|
|
|
|
|
|
|
|
/* array indexes of page file pointers */
|
|
|
|
enum {
|
|
|
|
P_PREFIX,
|
2005-12-06 01:51:01 +03:00
|
|
|
P_NAME,
|
2005-11-18 18:54:58 +03:00
|
|
|
P_AREA_PREFIX,
|
|
|
|
P_SEL_AREA,
|
|
|
|
P_CTL,
|
|
|
|
P_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
/* array indexes of area file pointers */
|
|
|
|
enum {
|
|
|
|
A_PREFIX,
|
2005-12-05 22:38:03 +03:00
|
|
|
A_FRAME_PREFIX,
|
2005-11-18 18:54:58 +03:00
|
|
|
A_SEL_FRAME,
|
|
|
|
A_CTL,
|
|
|
|
A_LAYOUT,
|
|
|
|
A_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
/* array indexes of frame file pointers */
|
|
|
|
enum {
|
|
|
|
F_PREFIX,
|
|
|
|
F_CLIENT_PREFIX,
|
|
|
|
F_SEL_CLIENT,
|
|
|
|
F_CTL,
|
2005-12-06 01:51:01 +03:00
|
|
|
F_GEOMETRY,
|
2005-11-18 18:54:58 +03:00
|
|
|
F_BORDER,
|
|
|
|
F_TAB,
|
|
|
|
F_HANDLE_INC,
|
|
|
|
F_LOCKED,
|
|
|
|
F_SEL_BG_COLOR,
|
|
|
|
F_SEL_FG_COLOR,
|
|
|
|
F_SEL_BORDER_COLOR,
|
|
|
|
F_NORM_BG_COLOR,
|
|
|
|
F_NORM_FG_COLOR,
|
|
|
|
F_NORM_BORDER_COLOR,
|
|
|
|
F_EVENT_B2PRESS,
|
|
|
|
F_EVENT_B3PRESS,
|
|
|
|
F_EVENT_B4PRESS,
|
|
|
|
F_EVENT_B5PRESS,
|
|
|
|
F_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
/* array indexes of client file pointers */
|
|
|
|
enum {
|
|
|
|
C_PREFIX,
|
|
|
|
C_NAME,
|
|
|
|
C_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
/* array indexes of wm file pointers */
|
|
|
|
enum {
|
|
|
|
WM_CTL,
|
|
|
|
WM_DETACHED_FRAME,
|
|
|
|
WM_DETACHED_CLIENT,
|
|
|
|
WM_TRANS_COLOR,
|
2005-12-13 03:10:28 +03:00
|
|
|
WM_AREA_GEOMETRY,
|
2005-11-18 18:54:58 +03:00
|
|
|
WM_SEL_BG_COLOR,
|
|
|
|
WM_SEL_BORDER_COLOR,
|
|
|
|
WM_SEL_FG_COLOR,
|
|
|
|
WM_NORM_BG_COLOR,
|
|
|
|
WM_NORM_BORDER_COLOR,
|
|
|
|
WM_NORM_FG_COLOR,
|
|
|
|
WM_FONT,
|
|
|
|
WM_BORDER,
|
|
|
|
WM_TAB,
|
|
|
|
WM_HANDLE_INC,
|
|
|
|
WM_LOCKED,
|
|
|
|
WM_SNAP_VALUE,
|
|
|
|
WM_SEL_PAGE,
|
|
|
|
WM_LAYOUT,
|
|
|
|
WM_EVENT_PAGE_UPDATE,
|
|
|
|
WM_EVENT_CLIENT_UPDATE,
|
|
|
|
WM_EVENT_B1PRESS,
|
|
|
|
WM_EVENT_B2PRESS,
|
|
|
|
WM_EVENT_B3PRESS,
|
|
|
|
WM_EVENT_B4PRESS,
|
|
|
|
WM_EVENT_B5PRESS,
|
|
|
|
WM_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PROTO_DEL 1
|
2005-12-07 04:20:36 +03:00
|
|
|
#define BORDER_WIDTH 3
|
2005-12-12 19:04:40 +03:00
|
|
|
#define LAYOUT "column"
|
2005-12-07 04:20:36 +03:00
|
|
|
#define GAP 5
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2005-12-15 04:08:26 +03:00
|
|
|
#define ROOT_MASK SubstructureRedirectMask
|
2005-12-12 01:52:04 +03:00
|
|
|
#define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask | EnterWindowMask)
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
|
|
typedef struct Page Page;
|
|
|
|
typedef struct Layout Layout;
|
|
|
|
typedef struct Area Area;
|
|
|
|
typedef struct Frame Frame;
|
|
|
|
typedef struct Client Client;
|
|
|
|
|
|
|
|
struct Page {
|
2005-12-16 04:59:27 +03:00
|
|
|
Area *managed;
|
|
|
|
Area *floating;
|
|
|
|
Area *sel;
|
2005-12-05 22:38:03 +03:00
|
|
|
File *file[P_LAST];
|
2005-12-16 04:59:27 +03:00
|
|
|
Page *next;
|
|
|
|
Page *prev;
|
2005-11-18 18:54:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Layout {
|
2005-12-05 01:45:59 +03:00
|
|
|
char *name;
|
2005-12-16 04:59:27 +03:00
|
|
|
void (*init) (Area *, Client *); /* called when layout is initialized */
|
|
|
|
Client *(*deinit) (Area *); /* called when layout is uninitialized */
|
|
|
|
void (*arrange) (Area *); /* called when area is resized */
|
|
|
|
Bool (*attach) (Area *, Client *); /* called on attach */
|
|
|
|
void (*detach) (Area *, Client *, Bool unmap); /* called on detach */
|
|
|
|
void (*resize) (Frame *, XRectangle *, XPoint *); /* called after resize */
|
|
|
|
void (*focus) (Frame *, Bool raise); /* focussing a frame */
|
|
|
|
Frame *(*frames) (Area *); /* called for drawing */
|
|
|
|
Frame *(*sel) (Area *); /* returns selected frame */
|
|
|
|
Action *(*actions) (Area *); /* local action table */
|
|
|
|
Layout *next;
|
2005-11-18 18:54:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Area {
|
2005-12-05 01:45:59 +03:00
|
|
|
Page *page;
|
2005-12-07 17:06:16 +03:00
|
|
|
Layout *layout;
|
2005-12-05 01:45:59 +03:00
|
|
|
void *aux; /* free pointer */
|
2005-12-05 22:38:03 +03:00
|
|
|
File *file[A_LAST];
|
2005-11-18 18:54:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Frame {
|
2005-12-05 01:45:59 +03:00
|
|
|
Area *area;
|
|
|
|
Window win;
|
2005-12-16 04:59:27 +03:00
|
|
|
Client *sel;
|
|
|
|
Client *clients;
|
|
|
|
size_t nclients;
|
2005-12-05 01:45:59 +03:00
|
|
|
GC gc;
|
|
|
|
XRectangle rect;
|
|
|
|
Cursor cursor;
|
|
|
|
void *aux; /* free pointer */
|
2005-12-05 22:38:03 +03:00
|
|
|
File *file[F_LAST];
|
2005-12-16 04:59:27 +03:00
|
|
|
Frame *next;
|
|
|
|
Frame *prev;
|
2005-11-18 18:54:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Client {
|
2005-12-05 01:45:59 +03:00
|
|
|
int proto;
|
|
|
|
unsigned int border;
|
2005-12-12 01:52:04 +03:00
|
|
|
unsigned int ignore_unmap;
|
2005-12-06 00:22:24 +03:00
|
|
|
Bool destroyed;
|
2005-12-05 01:45:59 +03:00
|
|
|
Window win;
|
|
|
|
Window trans;
|
|
|
|
XRectangle rect;
|
|
|
|
XSizeHints size;
|
|
|
|
Frame *frame;
|
2005-12-05 22:38:03 +03:00
|
|
|
File *file[C_LAST];
|
2005-12-16 04:59:27 +03:00
|
|
|
Client *next;
|
|
|
|
Client *prev;
|
2005-11-18 18:54:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* global variables */
|
2005-12-16 04:59:27 +03:00
|
|
|
Page *pages;
|
|
|
|
Page *selpage;
|
|
|
|
size_t npages;
|
|
|
|
Client *detached;
|
|
|
|
size_t ndetached;
|
|
|
|
Layout *layouts;
|
|
|
|
|
2005-12-05 01:45:59 +03:00
|
|
|
Display *dpy;
|
|
|
|
IXPServer *ixps;
|
|
|
|
int screen_num;
|
|
|
|
Window root;
|
|
|
|
Window transient;
|
|
|
|
XRectangle rect;
|
2005-12-13 03:10:28 +03:00
|
|
|
XRectangle area_rect;
|
2005-12-05 01:45:59 +03:00
|
|
|
XFontStruct *font;
|
|
|
|
XColor xorcolor;
|
|
|
|
GC xorgc;
|
|
|
|
GC transient_gc;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2005-12-05 01:45:59 +03:00
|
|
|
Atom wm_state;
|
|
|
|
Atom wm_change_state;
|
|
|
|
Atom wm_protocols;
|
|
|
|
Atom wm_delete;
|
|
|
|
Atom motif_wm_hints;
|
|
|
|
Atom net_wm_desktop;
|
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
|
|
|
|
|
|
|
/* default file pointers */
|
2005-12-05 04:50:02 +03:00
|
|
|
File *def[WM_LAST];
|
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
|
|
|
|
|
|
|
/* area.c */
|
2005-12-13 03:10:28 +03:00
|
|
|
Area *alloc_area(Page *p, char *layout);
|
2005-12-16 04:59:27 +03:00
|
|
|
void destroy_area(Area *a);
|
|
|
|
void focus_area(Area *a);
|
|
|
|
void hide_area(Area *a);
|
|
|
|
void show_area(Area *a, Bool raise);
|
|
|
|
Area *sel_area();
|
2005-12-07 17:06:16 +03:00
|
|
|
void attach_frame_to_area(Area *a, Frame *f);
|
|
|
|
void detach_frame_from_area(Frame *f);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
|
|
/* client.c */
|
2005-12-05 01:45:59 +03:00
|
|
|
Client *alloc_client(Window w);
|
2005-12-05 22:38:03 +03:00
|
|
|
void init_client(Client * c, XWindowAttributes * wa);
|
|
|
|
void destroy_client(Client * c);
|
2005-12-05 01:45:59 +03:00
|
|
|
void configure_client(Client * c);
|
|
|
|
void handle_client_property(Client * c, XPropertyEvent * e);
|
|
|
|
void close_client(Client * c);
|
2005-12-16 04:59:27 +03:00
|
|
|
void draw_client(Client *client);
|
2005-12-05 01:45:59 +03:00
|
|
|
void draw_clients(Frame * f);
|
|
|
|
void gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert);
|
|
|
|
void grab_client(Client * c, unsigned long mod, unsigned int button);
|
|
|
|
void ungrab_client(Client * c, unsigned long mod, unsigned int button);
|
|
|
|
void hide_client(Client * c);
|
|
|
|
void show_client(Client * c);
|
|
|
|
void reparent_client(Client * c, Window w, int x, int y);
|
2005-12-16 04:59:27 +03:00
|
|
|
void focus_client(Client *c);
|
2005-12-06 00:22:24 +03:00
|
|
|
void attach_client(Client *c);
|
2005-12-11 18:24:52 +03:00
|
|
|
void detach_client(Client *c, Bool unmap);
|
2005-12-16 04:59:27 +03:00
|
|
|
Client *sel_client();
|
|
|
|
Client *clientat(Client *clients, size_t idx);
|
|
|
|
void detach_detached(Client *c);
|
|
|
|
void attach_detached(Client *c);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
|
|
/* frame.c */
|
2005-12-05 01:45:59 +03:00
|
|
|
Frame *win_to_frame(Window w);
|
2005-12-05 22:38:03 +03:00
|
|
|
Frame *alloc_frame(XRectangle * r);
|
2005-12-05 01:45:59 +03:00
|
|
|
void destroy_frame(Frame * f);
|
2005-12-10 18:38:43 +03:00
|
|
|
void resize_frame(Frame *f, XRectangle *r, XPoint *pt);
|
2005-12-14 03:22:37 +03:00
|
|
|
void draw_frame(Frame *f);
|
2005-12-09 17:49:55 +03:00
|
|
|
void handle_frame_buttonpress(XButtonEvent *e, Frame *f);
|
2005-12-16 04:59:27 +03:00
|
|
|
void attach_client_to_frame(Frame *f, Client *client);
|
|
|
|
void detach_client_from_frame(Client *client, Bool unmap);
|
2005-12-05 03:36:39 +03:00
|
|
|
unsigned int tab_height(Frame * f);
|
|
|
|
unsigned int border_width(Frame * f);
|
2005-12-16 04:59:27 +03:00
|
|
|
Frame *sel_frame();
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
|
|
/* event.c */
|
2005-12-05 01:45:59 +03:00
|
|
|
void init_event_hander();
|
|
|
|
void check_event(Connection * c);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
|
|
/* mouse.c */
|
2005-12-05 01:45:59 +03:00
|
|
|
void mouse_resize(Frame * f, Align align);
|
|
|
|
void mouse_move(Frame * f);
|
|
|
|
Cursor cursor_for_motion(Frame * f, int x, int y);
|
|
|
|
Align cursor_to_align(Cursor cursor);
|
|
|
|
Align xy_to_align(XRectangle * rect, int x, int y);
|
|
|
|
void drop_move(Frame * f, XRectangle * new, XPoint * pt);
|
2005-12-09 01:24:57 +03:00
|
|
|
void center_pointer(Frame * f);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
|
|
/* page.c */
|
2005-12-16 04:59:27 +03:00
|
|
|
Page *pageat(unsigned int idx);
|
2005-12-05 22:38:03 +03:00
|
|
|
Page *alloc_page();
|
2005-12-17 17:14:59 +03:00
|
|
|
void destroy_page(Page *p);
|
2005-12-16 04:59:27 +03:00
|
|
|
void focus_page(Page *p);
|
2005-12-05 01:45:59 +03:00
|
|
|
XRectangle *rectangles(unsigned int *num);
|
2005-12-17 17:14:59 +03:00
|
|
|
void hide_page(Page *p);
|
|
|
|
void show_page(Page *p);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
|
|
/* layout.c */
|
2005-12-16 04:59:27 +03:00
|
|
|
Layout *match_layout(char *name);
|
2005-12-07 17:06:16 +03:00
|
|
|
|
|
|
|
/* layoutdef.c */
|
2005-12-05 01:45:59 +03:00
|
|
|
void init_layouts();
|
2005-12-05 04:15:25 +03:00
|
|
|
|
|
|
|
/* wm.c */
|
|
|
|
void invoke_wm_event(File * f);
|
|
|
|
void run_action(File * f, void *obj, Action * acttbl);
|
|
|
|
void scan_wins();
|
|
|
|
Client *win_to_client(Window w);
|
|
|
|
int win_proto(Window w);
|
|
|
|
int win_state(Window w);
|
|
|
|
void handle_after_write(IXPServer * s, File * f);
|
|
|
|
void detach(Frame * f, int client_destroyed);
|
|
|
|
void set_client_state(Client * c, int state);
|