awesome/structs.h

466 lines
11 KiB
C
Raw Normal View History

2008-01-13 15:44:01 +01:00
/*
* structs.h - basic structs header
*
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef AWESOME_STRUCTS_H
#define AWESOME_STRUCTS_H
2008-03-21 16:50:17 +01:00
#include <xcb/xcb_event.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_property.h>
#include <ev.h>
2008-03-21 16:50:17 +01:00
#include "luaa.h"
2008-01-13 15:44:01 +01:00
#include "layout.h"
#include "swindow.h"
#include "image.h"
#include "common/xutil.h"
#include "common/xembed.h"
#include "common/refcount.h"
2008-01-13 15:44:01 +01:00
/** Stacking layout layers */
typedef enum
{
LAYER_DESKTOP = 1,
LAYER_BELOW,
LAYER_TILE,
LAYER_FLOAT,
LAYER_ABOVE,
LAYER_FULLSCREEN,
LAYER_MODAL,
LAYER_ONTOP,
LAYER_OUTOFSPACE
} layer_t;
/** Windows type */
typedef enum
{
WINDOW_TYPE_NORMAL = 0,
WINDOW_TYPE_DESKTOP,
WINDOW_TYPE_DOCK,
WINDOW_TYPE_SPLASH,
WINDOW_TYPE_DIALOG,
} window_type_t;
/** Wibox types */
typedef enum
{
WIBOX_TYPE_NONE = 0,
WIBOX_TYPE_STATUSBAR,
WIBOX_TYPE_TITLEBAR
} wibox_type_t;
2008-01-13 15:44:01 +01:00
/** Cursors */
enum
{
CurNormal, CurResize, CurResizeH, CurResizeV, CurMove,
CurTopLeft, CurTopRight, CurBotLeft, CurBotRight, CurLast
};
2008-01-13 15:44:01 +01:00
typedef struct button_t button_t;
typedef struct widget_t widget_t;
typedef struct widget_node_t widget_node_t;
typedef struct client_t client_t;
typedef struct client_node_t client_node_t;
typedef struct _tag_t tag_t;
typedef struct tag_client_node_t tag_client_node_t;
typedef widget_t *(widget_constructor_t)(alignment_t);
typedef void (widget_destructor_t)(widget_t *);
typedef struct awesome_t awesome_t;
2008-01-13 15:44:01 +01:00
/** Wibox type */
typedef struct
{
/** Ref count */
int refcount;
/** Wibox type */
wibox_type_t type;
/** Window */
simple_window_t sw;
/** Box width and height */
uint16_t width, height;
/** Box position */
position_t position;
/** Alignment */
alignment_t align;
/** Screen */
int screen;
/** Widget list */
widget_node_t *widgets;
/** Widget the mouse is over */
widget_node_t *mouse_over;
/** Need update */
bool need_update;
/** Default colors */
struct
{
xcolor_t fg, bg;
} colors;
struct
{
xcolor_t color;
uint16_t width;
} border;
} wibox_t;
ARRAY_TYPE(wibox_t *, wibox)
2008-01-13 15:44:01 +01:00
/** Mouse buttons bindings */
struct button_t
2008-01-13 15:44:01 +01:00
{
/** Ref count */
int refcount;
/** Key modifiers */
2008-01-13 15:44:01 +01:00
unsigned long mod;
/** Mouse button number */
2008-01-13 15:44:01 +01:00
unsigned int button;
/** Lua function to execute on press. */
luaA_ref press;
/** Lua function to execute on release. */
luaA_ref release;
2008-01-13 15:44:01 +01:00
};
DO_RCNT(button_t, button, p_delete)
DO_ARRAY(button_t *, button, button_unref)
/** Widget */
struct widget_t
2008-01-13 15:44:01 +01:00
{
/** Ref count */
int refcount;
/** widget_t name */
2008-01-13 15:44:01 +01:00
char *name;
/** Widget type is constructor */
widget_constructor_t *type;
/** Widget destructor */
widget_destructor_t *destructor;
/** Widget detach function */
void (*detach)(widget_t *, wibox_t *);
2008-01-13 15:44:01 +01:00
/** Draw function */
int (*draw)(draw_context_t *, int, widget_node_t *, int, int, wibox_t *);
/** Index function */
int (*index)(lua_State *, awesome_token_t);
/** Newindex function */
int (*newindex)(lua_State *, awesome_token_t);
/** Button event handler */
void (*button)(widget_node_t *, xcb_button_press_event_t *, int, wibox_t *);
/** Mouse over event handler */
luaA_ref mouse_enter, mouse_leave;
2008-01-13 15:44:01 +01:00
/** Alignement */
alignment_t align;
2008-01-13 15:44:01 +01:00
/** Misc private data */
void *data;
/** Button bindings */
button_array_t buttons;
/** Cache flags */
int cache_flags;
/** True if the widget is visible */
bool isvisible;
2008-01-13 15:44:01 +01:00
};
/** Delete a widget structure.
* \param widget The widget to destroy.
*/
static inline void
widget_delete(widget_t **widget)
{
if((*widget)->destructor)
(*widget)->destructor(*widget);
button_array_wipe(&(*widget)->buttons);
p_delete(&(*widget)->name);
p_delete(widget);
}
DO_RCNT(widget_t, widget, widget_delete)
struct widget_node_t
{
/** The widget */
widget_t *widget;
/** The area where the widget was drawn */
area_t area;
/** Next and previous widget in the list */
widget_node_t *prev, *next;
};
/** Delete a widget node structure.
* \param node The node to destroy.
*/
static inline void
widget_node_delete(widget_node_t **node)
{
widget_unref(&(*node)->widget);
p_delete(node);
}
DO_SLIST(widget_node_t, widget_node, widget_node_delete)
/* Strut */
typedef struct
{
uint16_t left, right, top, bottom;
uint16_t left_start_y, left_end_y;
uint16_t right_start_y, right_end_y;
uint16_t top_start_x, top_end_x;
uint16_t bottom_start_x, bottom_end_x;
} strut_t;
/** client_t type */
struct client_t
2008-01-13 15:44:01 +01:00
{
/** Ref counter */
int refcount;
/** Valid, or not ? */
bool invalid;
2008-01-13 15:44:01 +01:00
/** Client name */
char *name;
2008-01-13 15:44:01 +01:00
/** Window geometry */
2008-03-14 09:37:25 +01:00
area_t geometry;
2008-01-13 15:44:01 +01:00
/** Floating window geometry */
2008-03-14 09:37:25 +01:00
area_t f_geometry;
2008-01-13 15:44:01 +01:00
/** Max window geometry */
2008-03-14 09:37:25 +01:00
area_t m_geometry;
2008-06-18 13:56:03 +02:00
/* Size hints */
2008-01-13 15:44:01 +01:00
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int minax, maxax, minay, maxay;
2008-06-18 13:56:03 +02:00
bool hassizehints;
/** Strut */
strut_t strut;
/** Respect resize hints */
bool honorsizehints;
2008-01-13 15:44:01 +01:00
int border, oldborder;
xcolor_t border_color;
/** True if the client is sticky */
bool issticky;
2008-01-13 15:44:01 +01:00
/** Has urgency hint */
2008-03-21 16:50:17 +01:00
bool isurgent;
/** true if the window is floating */
bool isfloating;
/** true if the client is moving */
bool ismoving;
/** True if the client is hidden */
bool ishidden;
/** True if the client is minimized */
bool isminimized;
/** True if the client is fullscreen */
bool isfullscreen;
/** True if the client is above others */
bool isabove;
/** True if the client is below others */
bool isbelow;
/** True if the client is modal */
bool ismodal;
/** True if the client is on top */
bool isontop;
2008-03-21 16:50:17 +01:00
/** true if the client must be skipped from task bar client list */
bool skiptb;
/** True if the client cannot have focus */
bool nofocus;
/** The window type */
window_type_t type;
2008-01-13 15:44:01 +01:00
/** Window of the client */
2008-03-21 16:50:17 +01:00
xcb_window_t win;
/** Client logical screen */
int screen;
/** Client physical screen */
int phys_screen;
/** Path to an icon */
char *icon_path;
/** Titlebar */
wibox_t *titlebar;
/** Button bindings */
button_array_t buttons;
/** Icon */
image_t *icon;
/** Size hints */
xcb_size_hints_t size_hints;
/** Window it is transient for */
client_t *transient_for;
/** Next and previous clients */
client_t *prev, *next;
2008-01-13 15:44:01 +01:00
};
static void
client_delete(client_t **c)
{
button_array_wipe(&(*c)->buttons);
p_delete(&(*c)->icon_path);
p_delete(&(*c)->name);
p_delete(c);
}
DO_ARRAY(client_t *, client, DO_NOTHING)
DO_RCNT(client_t, client, client_delete)
2008-01-13 15:44:01 +01:00
struct client_node_t
{
/** The client */
client_t *client;
/** Next and previous client_nodes */
client_node_t *prev, *next;
2008-01-13 15:44:01 +01:00
};
/** Tag type */
struct _tag_t
2008-01-13 15:44:01 +01:00
{
/** Ref count */
int refcount;
2008-01-13 15:44:01 +01:00
/** Tag name */
char *name;
/** Screen */
int screen;
/** true if selected */
bool selected;
/** Current tag layout */
layout_t *layout;
2008-01-13 15:44:01 +01:00
/** Master width factor */
double mwfact;
/** Number of master windows */
int nmaster;
/** Number of columns in tile layout */
int ncol;
/** clients in this tag */
client_array_t clients;
2008-01-13 15:44:01 +01:00
};
ARRAY_TYPE(tag_t *, tag)
2008-01-13 15:44:01 +01:00
/** Padding type */
typedef struct
{
/** Padding at top */
int top;
/** Padding at bottom */
int bottom;
/** Padding at left */
int left;
/** Padding at right */
int right;
} padding_t;
2008-01-13 15:44:01 +01:00
typedef struct
{
/** Screen index */
int index;
/** Screen geometry */
area_t geometry;
/** true if we need to arrange() */
bool need_arrange;
/** Tag list */
tag_array_t tags;
/** Statusbars */
wibox_array_t statusbars;
2008-01-13 15:44:01 +01:00
/** Padding */
padding_t padding;
/** Window that contains the systray */
struct
{
xcb_window_t window;
/** Systray window parent */
xcb_window_t parent;
} systray;
/** Focused client */
client_t *client_focus;
} screen_t;
2008-01-13 15:44:01 +01:00
/** Main configuration structure */
struct awesome_t
2008-01-13 15:44:01 +01:00
{
2008-03-21 16:50:17 +01:00
/** Connection ref */
xcb_connection_t *connection;
/** Event and error handlers */
xcb_event_handlers_t evenths;
/** Property change handler */
xcb_property_handlers_t prophs;
2008-03-21 16:50:17 +01:00
/** Default screen number */
int default_screen;
/** Keys symbol table */
xcb_key_symbols_t *keysyms;
2008-01-13 15:44:01 +01:00
/** Logical screens */
screen_t *screens;
/** Number of screens */
int nscreen;
/** True if xinerama is active */
bool xinerama_is_active;
2008-01-13 15:44:01 +01:00
/** Mouse bindings list */
button_array_t buttons;
2008-01-13 15:44:01 +01:00
/** Numlock mask */
unsigned int numlockmask;
/** Numlock mask */
unsigned int shiftlockmask;
/** Numlock mask */
unsigned int capslockmask;
2008-01-13 15:44:01 +01:00
/** Check for XRandR extension */
2008-03-21 16:50:17 +01:00
bool have_randr;
2008-01-13 15:44:01 +01:00
/** Cursors */
2008-03-21 16:50:17 +01:00
xcb_cursor_t cursor[CurLast];
/** Clients list */
client_t *clients;
/** Embedded windows */
xembed_window_t *embedded;
2008-01-13 15:44:01 +01:00
/** Path to config file */
char *configpath;
/** Stack client history */
client_node_t *stack;
2008-01-13 15:44:01 +01:00
/** Command line passed to awesome */
char *argv;
/** Last XMotionEvent coords */
int pointer_x, pointer_y;
/** Lua VM state */
lua_State *L;
/** Default colors */
struct
{
xcolor_t fg, bg;
} colors;
/** Default font */
font_t *font;
struct
{
/** Command to execute when spawning a new client */
luaA_ref manage;
/** Command to execute when unmanaging client */
luaA_ref unmanage;
/** Command to execute when giving focus to a client */
luaA_ref focus;
/** Command to execute when removing focus to a client */
luaA_ref unfocus;
/** Command to run when mouse is over */
luaA_ref mouse_over;
/** Command to run on arrange */
luaA_ref arrange;
/** Command to run on title change */
luaA_ref titleupdate;
/** Command to run on urgent flag */
luaA_ref urgent;
/** Command to run on time */
luaA_ref timer;
} hooks;
/** The event loop */
struct ev_loop *loop;
/** The timeout after which we need to stop select() */
struct ev_timer timer;
/** The key grabber function */
luaA_ref keygrabber;
/** Focused screen */
screen_t *screen_focus;
2008-01-13 15:44:01 +01:00
};
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80