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>
|
|
|
|
|
|
|
|
|
|
#include "wmii.h"
|
|
|
|
|
|
|
|
|
|
/* array indexes of page file pointers */
|
|
|
|
|
enum {
|
2005-12-21 18:18:11 +03:00
|
|
|
|
P_PREFIX,
|
|
|
|
|
P_NAME,
|
2006-01-25 20:39:08 +03:00
|
|
|
|
P_MANAGED_PREFIX,
|
|
|
|
|
P_FLOATING_PREFIX,
|
|
|
|
|
P_SEL_PREFIX,
|
|
|
|
|
P_SEL_MANAGED_CLIENT,
|
|
|
|
|
P_SEL_FLOATING_CLIENT,
|
2005-12-21 18:18:11 +03:00
|
|
|
|
P_CTL,
|
|
|
|
|
P_LAST
|
2005-11-18 18:54:58 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* array indexes of frame file pointers */
|
|
|
|
|
enum {
|
2006-01-25 20:39:08 +03:00
|
|
|
|
C_PREFIX,
|
|
|
|
|
C_NAME,
|
|
|
|
|
C_GEOMETRY,
|
|
|
|
|
C_BORDER,
|
|
|
|
|
C_TAB,
|
|
|
|
|
C_HANDLE_INC,
|
|
|
|
|
C_LAST
|
2005-11-18 18:54:58 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* array indexes of wm file pointers */
|
|
|
|
|
enum {
|
2005-12-21 18:18:11 +03:00
|
|
|
|
WM_CTL,
|
|
|
|
|
WM_TRANS_COLOR,
|
2006-01-12 18:44:06 +03:00
|
|
|
|
WM_MANAGED_GEOMETRY,
|
2005-12-21 18:18:11 +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_SNAP_VALUE,
|
|
|
|
|
WM_SEL_PAGE,
|
|
|
|
|
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
|
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 /* ✗ ✗ */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define NET_ATOM_COUNT 3
|
|
|
|
|
|
2005-11-18 18:54:58 +03:00
|
|
|
|
#define PROTO_DEL 1
|
2005-12-07 04:20:36 +03:00
|
|
|
|
#define BORDER_WIDTH 3
|
|
|
|
|
#define 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-01-25 20:39:08 +03:00
|
|
|
|
typedef struct MapQueue MapQueue;
|
|
|
|
|
typedef struct Column Column;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
typedef struct Page Page;
|
|
|
|
|
typedef struct Client Client;
|
|
|
|
|
|
2006-01-25 20:39:08 +03:00
|
|
|
|
struct MapQueue {
|
2006-01-10 21:57:31 +03:00
|
|
|
|
Page *page;
|
2006-01-25 20:39:08 +03:00
|
|
|
|
MapQueue *next;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
};
|
|
|
|
|
|
2006-01-25 20:39:08 +03:00
|
|
|
|
struct Column {
|
|
|
|
|
Client **clients;
|
|
|
|
|
size_t clientssz;
|
|
|
|
|
size_t sel;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
};
|
|
|
|
|
|
2006-01-25 20:39:08 +03:00
|
|
|
|
struct Page {
|
|
|
|
|
Client **floating;
|
|
|
|
|
Column **managed;
|
|
|
|
|
size_t floatingsz;
|
|
|
|
|
size_t managedsz;
|
|
|
|
|
size_t sel_float;
|
|
|
|
|
size_t sel_managed;
|
|
|
|
|
Bool is_managed;
|
|
|
|
|
XRectangle rect_managed;
|
|
|
|
|
File *file[P_LAST];
|
2005-11-18 18:54:58 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Client {
|
2006-01-25 20:39:08 +03:00
|
|
|
|
char name[256];
|
2005-12-21 18:18:11 +03:00
|
|
|
|
int proto;
|
|
|
|
|
unsigned int border;
|
|
|
|
|
unsigned int ignore_unmap;
|
|
|
|
|
Bool destroyed;
|
2006-01-25 20:39:08 +03:00
|
|
|
|
Bool maximized;
|
2006-01-25 21:41:12 +03:00
|
|
|
|
Bool framed;
|
|
|
|
|
Bool managed;
|
2005-12-21 18:18:11 +03:00
|
|
|
|
Window win;
|
|
|
|
|
Window trans;
|
|
|
|
|
XRectangle rect;
|
|
|
|
|
XSizeHints size;
|
2006-01-25 21:41:12 +03:00
|
|
|
|
Page *page;
|
2006-01-25 20:39:08 +03:00
|
|
|
|
struct Frame {
|
|
|
|
|
Window win;
|
|
|
|
|
XRectangle rect;
|
|
|
|
|
XRectangle revert;
|
|
|
|
|
GC gc;
|
|
|
|
|
Cursor cursor;
|
|
|
|
|
} frame;
|
|
|
|
|
File *file[C_LAST];
|
2005-11-18 18:54:58 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* global variables */
|
2006-01-25 20:39:08 +03:00
|
|
|
|
Page **pages;
|
|
|
|
|
size_t pagessz;
|
|
|
|
|
size_t sel_page;
|
|
|
|
|
MapQueue *attachqueue;
|
|
|
|
|
Client **detached;
|
|
|
|
|
size_t detachedsz;
|
|
|
|
|
Client **clients;
|
|
|
|
|
size_t clientssz;
|
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;
|
|
|
|
|
XFontStruct *font;
|
2006-01-25 20:39:08 +03:00
|
|
|
|
XColor color_xor;
|
|
|
|
|
GC gc_xor;
|
|
|
|
|
GC gc_transient;
|
2005-11-18 18:54: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
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* client.c */
|
2006-01-25 20:39:08 +03:00
|
|
|
|
Client *alloc_client(Window w, XWindowAttributes *wa);
|
2005-12-05 22:38:03 +03:00
|
|
|
|
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-21 18:18:11 +03:00
|
|
|
|
void draw_client(Client * client);
|
2005-12-05 01:45:59 +03:00
|
|
|
|
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);
|
2006-01-13 15:24:55 +03:00
|
|
|
|
void unmap_client(Client * c);
|
|
|
|
|
void map_client(Client * c);
|
2005-12-05 01:45:59 +03:00
|
|
|
|
void reparent_client(Client * c, Window w, int x, int y);
|
2005-12-21 18:18:11 +03:00
|
|
|
|
void attach_client(Client * c);
|
|
|
|
|
void detach_client(Client * c, Bool unmap);
|
2005-12-16 04:59:27 +03:00
|
|
|
|
Client *sel_client();
|
2005-12-21 18:18:11 +03:00
|
|
|
|
Client *clientat(Client * clients, size_t idx);
|
|
|
|
|
void detach_detached(Client * c);
|
|
|
|
|
void attach_detached(Client * c);
|
2006-01-19 17:02:18 +03:00
|
|
|
|
void focus_client(Client *new, Client *old);
|
2006-01-25 20:39:08 +03:00
|
|
|
|
Client *win_to_frame(Window w);
|
|
|
|
|
Client *alloc_frame(XRectangle * r);
|
|
|
|
|
void destroy_frame(Client * f);
|
2006-01-25 21:41:12 +03:00
|
|
|
|
void resize_client(Client * f, XRectangle * r, XPoint * pt);
|
2006-01-25 20:39:08 +03:00
|
|
|
|
void draw_frame(Client * f);
|
|
|
|
|
void handle_frame_buttonpress(XButtonEvent * e, Client * f);
|
2005-12-21 18:18:11 +03:00
|
|
|
|
void detach_client_from_frame(Client * client, Bool unmap);
|
2006-01-25 20:39:08 +03:00
|
|
|
|
unsigned int tab_height(Client * f);
|
|
|
|
|
unsigned int border_width(Client * f);
|
|
|
|
|
Client *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 */
|
2006-01-25 20:39:08 +03:00
|
|
|
|
void mouse_resize(Client * f, Align align);
|
|
|
|
|
void mouse_move(Client * f);
|
|
|
|
|
Cursor cursor_for_motion(Client * f, int x, int y);
|
2005-12-05 01:45:59 +03:00
|
|
|
|
Align cursor_to_align(Cursor cursor);
|
|
|
|
|
Align xy_to_align(XRectangle * rect, int x, int y);
|
2006-01-25 20:39:08 +03:00
|
|
|
|
void drop_move(Client * f, XRectangle * new, XPoint * pt);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
|
|
|
|
/* page.c */
|
2006-01-25 20:39:08 +03:00
|
|
|
|
size_t alloc_page();
|
|
|
|
|
void destroy_page(size_t idx);
|
|
|
|
|
void focus_page(size_t idx);
|
2005-12-05 01:45:59 +03:00
|
|
|
|
XRectangle *rectangles(unsigned int *num);
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
2006-01-25 20:39:08 +03:00
|
|
|
|
/* column.c */
|
|
|
|
|
void arrange_column(Page *p);
|
2006-01-25 21:41:12 +03:00
|
|
|
|
void attach_column(Client *c);
|
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);
|
2006-01-25 20:39:08 +03:00
|
|
|
|
void detach(Client * f, int client_destroyed);
|
2005-12-05 04:15:25 +03:00
|
|
|
|
void set_client_state(Client * c, int state);
|