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

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