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

Last change on this file since 2447 was 2447, checked in by Jean-Yves Lamoureux, 13 years ago
  • Added an ugly-not-finished-yet screensaver
  • Property svn:keywords set to Id
File size: 5.1 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 2447 2008-06-18 13:47:59Z jylam $
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
29
30struct screen
31{
32    /* Graphics stuff */
33    int init;
34    cucul_canvas_t *cv;
35    uint32_t clearattr;
36    uint8_t fg, bg;   /* ANSI-context fg/bg */
37    uint8_t dfg, dbg; /* Default fg/bg */
38    uint8_t bold, blink, italics, negative, concealed, underline;
39    uint8_t faint, strike, proportional; /* unsupported */
40
41    /* Other stuff */
42    int visible;                 /* Draw canvas and border flag */
43    int fd;                      /* pty fd */
44    unsigned char *buf;          /* text buffer */
45    long int total;              /* buffer length */
46    char *title;                 /* tty title */
47    int bell;                    /* bell occuring */
48    unsigned int scroll, s1, s2; /* FIXME, ANSI scroll properties */
49    int pid;                     /* running program pid */
50
51    int x, y;                    /* Canvas position */
52    int w, h;                    /* Canvas size */
53
54    int orig_x, orig_y;          /* Used by recurrents */
55    int orig_w, orig_h;          /* Used by recurrents */
56
57};
58
59struct screen_list
60{
61    int wm_type;                 /* Window manager type */
62    int in_bell;                 /* Bell occuring in a window  */
63    int dont_update_coords;      /* Used by recurrents */
64    /* Add-ons*/
65    int mini;                    /* Thumbnails */
66    int status;                  /* Status bar */
67    int help;                    /* help */
68    long long unsigned int screensaver_timeout;     /* Screensaver timeout in us */
69
70
71    int pty, prevpty;            /* Current and previous window */
72    int count;                   /* Window count */
73    int width, height;           /* caca window size */
74    struct screen **screen;      /* Windows */
75};
76
77
78struct recurrent
79{
80    int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
81    void *user;
82    long long unsigned int  start_time;
83    int kill_me;
84};
85
86struct recurrent_list
87{
88    int count;
89    struct recurrent **recurrent;
90};
91
92
93void version(void);
94
95
96
97int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid);
98#ifdef USE_GRAB
99int create_pty_grab(pid_t pid, unsigned int w, unsigned int h);
100int grab_process(pid_t pid, char *ptyname, int ptyfd);
101#endif
102
103long int import_term(struct screen_list *screen_list, struct screen *sc, void const *data, unsigned int size);
104int set_tty_size(int fd, unsigned int w, unsigned int h);
105int update_terms(struct screen_list* screen_list);
106void refresh_screens(cucul_canvas_t *cv,
107                     caca_display_t *dp,
108                     struct screen_list *screen_list);
109int update_screens_contents(struct screen_list* screen_list);
110long long get_ms(void);
111
112
113/* Screens management */
114struct screen* create_screen(int w, int h, char *command);
115#ifdef USE_GRAB
116struct screen* create_screen_grab(int w, int h, int pid);
117#endif
118int destroy_screen(struct screen *s);
119int add_screen(struct screen_list *list, struct screen *s);
120int remove_screen(struct screen_list *list, int n, int please_kill);
121void resize_screen(struct screen *s, int z, int h);
122
123/* Window managers */
124void update_windows_props(cucul_canvas_t *cv, struct screen_list *screen_list);
125void update_windows_props_cards(cucul_canvas_t *cv, struct screen_list *screen_list);
126void update_windows_props_hsplit(cucul_canvas_t *cv, struct screen_list *screen_list);
127void update_windows_props_full(cucul_canvas_t *cv, struct screen_list *screen_list);
128void update_windows_props_vsplit(cucul_canvas_t *cv, struct screen_list *screen_list);
129
130/* Effects and addons */
131void draw_thumbnails(cucul_canvas_t *cv, struct screen_list *screen_list);
132void draw_status(cucul_canvas_t *cv, struct screen_list *screen_list);
133void draw_help(cucul_canvas_t *cv, struct screen_list *screen_list);
134int close_screen_recurrent(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
135
136
137/* Screensavers */
138void draw_screensaver(cucul_canvas_t *cv,
139                      caca_display_t *dp,
140                      struct screen_list *screen_list);
141void screensaver_flying_toasters(cucul_canvas_t *cv,
142                                 caca_display_t *dp,
143                                 struct screen_list *screen_list);
144
145
146/* Recurrents */
147int add_recurrent(struct recurrent_list *list,
148                  int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t),
149                  void *user);
150int remove_recurrent(struct recurrent_list *list, int n);
151
152
153#if 0
154#   define debug(f, z...) fprintf(stderr, f "\n", z)
155#else
156#   define debug(f, z...) do {} while(0)
157#endif
158
Note: See TracBrowser for help on using the repository browser.