source: neercs/trunk/src/neercs.h @ 2510

Last change on this file since 2510 was 2510, checked in by Sam Hocevar, 14 years ago
  • Add a --debug flag to the configure step.
  • Property svn:keywords set to Id
File size: 7.0 KB
RevLine 
[1437]1/*
2 *  neercs        console-based window manager
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
[2357]4 *                2008 Jean-Yves Lamoureux <jylam@lnxscene.org>
[1437]5 *                All Rights Reserved
6 *
7 *  $Id: neercs.h 2510 2008-06-30 23:26:57Z sam $
8 *
[1459]9 *  This program is free software. It comes without any warranty, to
[1455]10 *  the extent permitted by applicable law. You can redistribute it
11 *  and/or modify it under the terms of the Do What The Fuck You Want
12 *  To Public License, Version 2, as published by Sam Hocevar. See
[1437]13 *  http://sam.zoy.org/wtfpl/COPYING for more details.
14 */
15
16#include <stdint.h>
[2505]17
[2426]18#include <caca.h>
[1437]19
[2362]20enum wm_types
21{
22    WM_FULL,
23    WM_CARD,
24    WM_HSPLIT,
25    WM_VSPLIT,
[2357]26
[2362]27    WM_MAX,
28};
[2357]29
[2463]30struct option
31{
32    char *key;
33    char *value;
34
35    struct option *next;
36};
37
38
[1437]39struct screen
40{
41    /* Graphics stuff */
42    int init;
43    cucul_canvas_t *cv;
44    uint32_t clearattr;
45    uint8_t fg, bg;   /* ANSI-context fg/bg */
46    uint8_t dfg, dbg; /* Default fg/bg */
47    uint8_t bold, blink, italics, negative, concealed, underline;
48    uint8_t faint, strike, proportional; /* unsupported */
49
50    /* Other stuff */
[2446]51    int visible;                 /* Draw canvas and border flag */
52    int fd;                      /* pty fd */
53    unsigned char *buf;          /* text buffer */
54    long int total;              /* buffer length */
55    char *title;                 /* tty title */
56    int bell;                    /* bell occuring */
57    unsigned int scroll, s1, s2; /* FIXME, ANSI scroll properties */
58    int pid;                     /* running program pid */
[2360]59
[2446]60    int x, y;                    /* Canvas position */
61    int w, h;                    /* Canvas size */
[2421]62
[2446]63    int orig_x, orig_y;          /* Used by recurrents */
64    int orig_w, orig_h;          /* Used by recurrents */
[2445]65
[1437]66};
67
[2357]68struct screen_list
69{
[2446]70    int wm_type;                 /* Window manager type */
71    int in_bell;                 /* Bell occuring in a window  */
72    int dont_update_coords;      /* Used by recurrents */
[2474]73
74    /* Detaching */
[2458]75    int attached;                /* Are we attached to a terminal */
[2474]76    int socket;                  /* Socket to ask for attaching */
77    char *socket_path;           /* Socket to ask for attaching */
78    char *socket_dir;            /* Where to create the socket */
[2488]79    char *session_name;          /* Name of the session */
[2457]80
81    /* Lock */
82    int locked;
[2495]83    int lock_offset;
[2500]84    long long unsigned int  autolock_timeout;
[2457]85    char lockpass[1024];
86    char lockmsg[1024];
87
[2400]88    /* Add-ons*/
[2446]89    int mini;                    /* Thumbnails */
90    int status;                  /* Status bar */
91    int help;                    /* help */
[2448]92
93    /* ScreenSaver stuff */
[2447]94    long long unsigned int screensaver_timeout;     /* Screensaver timeout in us */
[2448]95    int in_screensaver;
96    void *screensaver_data;
[2400]97
[2446]98    int pty, prevpty;            /* Current and previous window */
99    int count;                   /* Window count */
100    int width, height;           /* caca window size */
101    struct screen **screen;      /* Windows */
[2463]102
103    struct option *config;
[2495]104    char *default_shell;
105    struct recurrent_list *recurrent_list;
[2463]106
[2495]107    cucul_canvas_t *cv;
108    caca_display_t *dp;
[2357]109};
110
111
[2445]112struct recurrent
113{
114    int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
115    void *user;
116    long long unsigned int  start_time;
117    int kill_me;
118};
119
120struct recurrent_list
121{
122    int count;
123    struct recurrent **recurrent;
124};
125
126
[2463]127
[2444]128void version(void);
[2468]129void usage(int argc, char **argv);
[2444]130
131
[2495]132struct screen_list *create_screen_list(void);
[2444]133
[2402]134int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid);
[2505]135int create_pty_grab(long pid, unsigned int w, unsigned int h);
136int grab_process(long pid, char *ptyname, int ptyfd);
[2357]137
[2368]138long int import_term(struct screen_list *screen_list, struct screen *sc, void const *data, unsigned int size);
[2362]139int set_tty_size(int fd, unsigned int w, unsigned int h);
[2400]140int update_terms(struct screen_list* screen_list);
[2495]141void refresh_screens(struct screen_list *screen_list);
[2421]142int update_screens_contents(struct screen_list* screen_list);
[2473]143long long get_us(void);
[2359]144
[2458]145int detach(struct screen_list* screen_list, caca_display_t * dp);
[2474]146int request_attach(char *socket_path);
147int create_socket(struct screen_list* screen_list);
148int read_socket(struct screen_list* screen_list, cucul_canvas_t * cv, caca_display_t ** dp);
[2488]149char ** list_sockets(char *socket_dir, char *session_name);
[2445]150
[2357]151/* Screens management */
152struct screen* create_screen(int w, int h, char *command);
[2426]153struct screen* create_screen_grab(int w, int h, int pid);
[2357]154int destroy_screen(struct screen *s);
155int add_screen(struct screen_list *list, struct screen *s);
[2371]156int remove_screen(struct screen_list *list, int n, int please_kill);
[2362]157void resize_screen(struct screen *s, int z, int h);
[2357]158
[2362]159/* Window managers */
[2495]160void update_windows_props(struct screen_list *screen_list);
161void update_windows_props_cards(struct screen_list *screen_list);
162void update_windows_props_hsplit(struct screen_list *screen_list);
163void update_windows_props_full(struct screen_list *screen_list);
164void update_windows_props_vsplit(struct screen_list *screen_list);
[2357]165
[2367]166/* Effects and addons */
[2495]167void draw_thumbnails(struct screen_list *screen_list);
168void draw_status(struct screen_list *screen_list);
169void draw_help(struct screen_list *screen_list);
170void draw_lock(struct screen_list *screen_list);
171int update_lock(int c, struct screen_list *screen_list);
[2457]172int validate_lock(struct screen_list *screen_list, char *user, char *pass);
173
[2445]174int close_screen_recurrent(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
[2357]175
[2495]176/* Input to ANSI */
177void *convert_input_ansi(unsigned int *c, int *size);
178int  handle_command_input(struct screen_list*screen_list, unsigned int c);
[2367]179
[2495]180
[2447]181/* Screensavers */
[2495]182void screensaver_init(struct screen_list *screen_list);
183void screensaver_kill(struct screen_list *screen_list);
[2448]184
[2495]185void draw_screensaver(struct screen_list *screen_list);
186void screensaver_flying_toasters(struct screen_list *screen_list);
[2447]187
[2495]188void screensaver_flying_toasters_init(struct screen_list *screen_list);
[2447]189
[2495]190void screensaver_flying_toasters_kill(struct screen_list *screen_list);
[2448]191
192
193
[2445]194/* Recurrents */
[2495]195int handle_recurrents(struct screen_list* screen_list);
[2445]196int add_recurrent(struct recurrent_list *list,
197                  int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t),
198                  void *user);
199int remove_recurrent(struct recurrent_list *list, int n);
200
201
[2463]202
203/* Configuration file */
204int read_configuration_file(char *filename, struct screen_list *screen_list);
205int parse_conf_line(char *buf, int size, struct screen_list *screen_list);
206int get_key_value(char *line, struct option *option);
207int fill_config(struct screen_list *screen_list);
208
[2510]209#if defined DEBUG
210#   include <stdio.h>
211#   include <stdarg.h>
212static inline void debug(const char *format, ...)
213{
214    int saved_errno = geterrno();
215    va_list args;
216    va_start(args, format);
217    fprintf(stderr, "** neercs debug ** ");
218    vfprintf(stderr, format, args);
219    fprintf(stderr, "\n");
220    va_end(args);
221    seterrno(saved_errno);
222}
[1437]223#else
[2510]224#   define debug(format, ...) do {} while(0)
[1437]225#endif
226
Note: See TracBrowser for help on using the repository browser.