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

Last change on this file since 2478 was 2478, checked in by pterjan, 6 years ago
  • Don't use the caca_display in refresh_screens, it would make clean detach very hard
  • Property svn:keywords set to Id
File size: 6.9 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: neercs.h 2478 2008-06-23 14:37:19Z pterjan $
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
79    /* Lock */
80    int locked;
81    char lockpass[1024];
82    char lockmsg[1024];
83
84    /* Add-ons*/
85    int mini;                    /* Thumbnails */
86    int status;                  /* Status bar */
87    int help;                    /* help */
88
89    /* ScreenSaver stuff */
90    long long unsigned int screensaver_timeout;     /* Screensaver timeout in us */
91    int in_screensaver;
92    void *screensaver_data;
93
94    int pty, prevpty;            /* Current and previous window */
95    int count;                   /* Window count */
96    int width, height;           /* caca window size */
97    struct screen **screen;      /* Windows */
98
99    struct option *config;
100
101};
102
103
104struct recurrent
105{
106    int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
107    void *user;
108    long long unsigned int  start_time;
109    int kill_me;
110};
111
112struct recurrent_list
113{
114    int count;
115    struct recurrent **recurrent;
116};
117
118
119
120void version(void);
121void usage(int argc, char **argv);
122
123
124
125int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid);
126int create_pty_grab(pid_t pid, unsigned int w, unsigned int h);
127int grab_process(pid_t pid, char *ptyname, int ptyfd);
128
129long int import_term(struct screen_list *screen_list, struct screen *sc, void const *data, unsigned int size);
130int set_tty_size(int fd, unsigned int w, unsigned int h);
131int update_terms(struct screen_list* screen_list);
132void refresh_screens(cucul_canvas_t *cv, struct screen_list *screen_list);
133int update_screens_contents(struct screen_list* screen_list);
134long long get_us(void);
135
136int detach(struct screen_list* screen_list, caca_display_t * dp);
137int request_attach(char *socket_path);
138int create_socket(struct screen_list* screen_list);
139int read_socket(struct screen_list* screen_list, cucul_canvas_t * cv, caca_display_t ** dp);
140char ** list_sockets(char *socket_dir);
141
142/* Screens management */
143struct screen* create_screen(int w, int h, char *command);
144struct screen* create_screen_grab(int w, int h, int pid);
145int destroy_screen(struct screen *s);
146int add_screen(struct screen_list *list, struct screen *s);
147int remove_screen(struct screen_list *list, int n, int please_kill);
148void resize_screen(struct screen *s, int z, int h);
149
150/* Window managers */
151void update_windows_props(cucul_canvas_t *cv, struct screen_list *screen_list);
152void update_windows_props_cards(cucul_canvas_t *cv, struct screen_list *screen_list);
153void update_windows_props_hsplit(cucul_canvas_t *cv, struct screen_list *screen_list);
154void update_windows_props_full(cucul_canvas_t *cv, struct screen_list *screen_list);
155void update_windows_props_vsplit(cucul_canvas_t *cv, struct screen_list *screen_list);
156
157/* Effects and addons */
158void draw_thumbnails(cucul_canvas_t *cv, struct screen_list *screen_list);
159void draw_status(cucul_canvas_t *cv, struct screen_list *screen_list);
160void draw_help(cucul_canvas_t *cv, struct screen_list *screen_list);
161void draw_lock(cucul_canvas_t *cv, struct screen_list *screen_list);
162int validate_lock(struct screen_list *screen_list, char *user, char *pass);
163
164int close_screen_recurrent(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
165
166
167/* Screensavers */
168void screensaver_init(cucul_canvas_t *cv,
169                      caca_display_t *dp,
170                      struct screen_list *screen_list);
171void screensaver_kill(cucul_canvas_t *cv,
172                      caca_display_t *dp,
173                      struct screen_list *screen_list);
174
175void draw_screensaver(cucul_canvas_t *cv,
176                      caca_display_t *dp,
177                      struct screen_list *screen_list);
178void screensaver_flying_toasters(cucul_canvas_t *cv,
179                                 caca_display_t *dp,
180                                 struct screen_list *screen_list);
181
182void screensaver_flying_toasters_init(cucul_canvas_t *cv,
183                                 caca_display_t *dp,
184                                 struct screen_list *screen_list);
185
186void screensaver_flying_toasters_kill(cucul_canvas_t *cv,
187                                 caca_display_t *dp,
188                                 struct screen_list *screen_list);
189
190
191
192/* Recurrents */
193int add_recurrent(struct recurrent_list *list,
194                  int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t),
195                  void *user);
196int remove_recurrent(struct recurrent_list *list, int n);
197
198
199
200/* Configuration file */
201int read_configuration_file(char *filename, struct screen_list *screen_list);
202int parse_conf_line(char *buf, int size, struct screen_list *screen_list);
203int get_key_value(char *line, struct option *option);
204int fill_config(struct screen_list *screen_list);
205
206#if 0
207#   define debug(f, z...) fprintf(stderr, f "\n", z)
208#else
209#   define debug(f, z...) do {} while(0)
210#endif
211
Note: See TracBrowser for help on using the repository browser.