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 2448 2008-06-18 14:50:41Z 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 | |
---|
19 | enum wm_types |
---|
20 | { |
---|
21 | WM_FULL, |
---|
22 | WM_CARD, |
---|
23 | WM_HSPLIT, |
---|
24 | WM_VSPLIT, |
---|
25 | |
---|
26 | WM_MAX, |
---|
27 | }; |
---|
28 | |
---|
29 | |
---|
30 | struct 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 | |
---|
59 | struct 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 | |
---|
69 | /* ScreenSaver stuff */ |
---|
70 | long long unsigned int screensaver_timeout; /* Screensaver timeout in us */ |
---|
71 | int in_screensaver; |
---|
72 | void *screensaver_data; |
---|
73 | |
---|
74 | int pty, prevpty; /* Current and previous window */ |
---|
75 | int count; /* Window count */ |
---|
76 | int width, height; /* caca window size */ |
---|
77 | struct screen **screen; /* Windows */ |
---|
78 | }; |
---|
79 | |
---|
80 | |
---|
81 | struct recurrent |
---|
82 | { |
---|
83 | int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t); |
---|
84 | void *user; |
---|
85 | long long unsigned int start_time; |
---|
86 | int kill_me; |
---|
87 | }; |
---|
88 | |
---|
89 | struct recurrent_list |
---|
90 | { |
---|
91 | int count; |
---|
92 | struct recurrent **recurrent; |
---|
93 | }; |
---|
94 | |
---|
95 | |
---|
96 | void version(void); |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid); |
---|
101 | #ifdef USE_GRAB |
---|
102 | int create_pty_grab(pid_t pid, unsigned int w, unsigned int h); |
---|
103 | int grab_process(pid_t pid, char *ptyname, int ptyfd); |
---|
104 | #endif |
---|
105 | |
---|
106 | long int import_term(struct screen_list *screen_list, struct screen *sc, void const *data, unsigned int size); |
---|
107 | int set_tty_size(int fd, unsigned int w, unsigned int h); |
---|
108 | int update_terms(struct screen_list* screen_list); |
---|
109 | void refresh_screens(cucul_canvas_t *cv, |
---|
110 | caca_display_t *dp, |
---|
111 | struct screen_list *screen_list); |
---|
112 | int update_screens_contents(struct screen_list* screen_list); |
---|
113 | long long get_ms(void); |
---|
114 | |
---|
115 | |
---|
116 | /* Screens management */ |
---|
117 | struct screen* create_screen(int w, int h, char *command); |
---|
118 | #ifdef USE_GRAB |
---|
119 | struct screen* create_screen_grab(int w, int h, int pid); |
---|
120 | #endif |
---|
121 | int destroy_screen(struct screen *s); |
---|
122 | int add_screen(struct screen_list *list, struct screen *s); |
---|
123 | int remove_screen(struct screen_list *list, int n, int please_kill); |
---|
124 | void resize_screen(struct screen *s, int z, int h); |
---|
125 | |
---|
126 | /* Window managers */ |
---|
127 | void update_windows_props(cucul_canvas_t *cv, struct screen_list *screen_list); |
---|
128 | void update_windows_props_cards(cucul_canvas_t *cv, struct screen_list *screen_list); |
---|
129 | void update_windows_props_hsplit(cucul_canvas_t *cv, struct screen_list *screen_list); |
---|
130 | void update_windows_props_full(cucul_canvas_t *cv, struct screen_list *screen_list); |
---|
131 | void update_windows_props_vsplit(cucul_canvas_t *cv, struct screen_list *screen_list); |
---|
132 | |
---|
133 | /* Effects and addons */ |
---|
134 | void draw_thumbnails(cucul_canvas_t *cv, struct screen_list *screen_list); |
---|
135 | void draw_status(cucul_canvas_t *cv, struct screen_list *screen_list); |
---|
136 | void draw_help(cucul_canvas_t *cv, struct screen_list *screen_list); |
---|
137 | int close_screen_recurrent(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t); |
---|
138 | |
---|
139 | |
---|
140 | /* Screensavers */ |
---|
141 | void screensaver_init(cucul_canvas_t *cv, |
---|
142 | caca_display_t *dp, |
---|
143 | struct screen_list *screen_list); |
---|
144 | void screensaver_kill(cucul_canvas_t *cv, |
---|
145 | caca_display_t *dp, |
---|
146 | struct screen_list *screen_list); |
---|
147 | |
---|
148 | void draw_screensaver(cucul_canvas_t *cv, |
---|
149 | caca_display_t *dp, |
---|
150 | struct screen_list *screen_list); |
---|
151 | void screensaver_flying_toasters(cucul_canvas_t *cv, |
---|
152 | caca_display_t *dp, |
---|
153 | struct screen_list *screen_list); |
---|
154 | |
---|
155 | void screensaver_flying_toasters_init(cucul_canvas_t *cv, |
---|
156 | caca_display_t *dp, |
---|
157 | struct screen_list *screen_list); |
---|
158 | |
---|
159 | void screensaver_flying_toasters_kill(cucul_canvas_t *cv, |
---|
160 | caca_display_t *dp, |
---|
161 | struct screen_list *screen_list); |
---|
162 | |
---|
163 | |
---|
164 | |
---|
165 | /* Recurrents */ |
---|
166 | int add_recurrent(struct recurrent_list *list, |
---|
167 | int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t), |
---|
168 | void *user); |
---|
169 | int remove_recurrent(struct recurrent_list *list, int n); |
---|
170 | |
---|
171 | |
---|
172 | #if 0 |
---|
173 | # define debug(f, z...) fprintf(stderr, f "\n", z) |
---|
174 | #else |
---|
175 | # define debug(f, z...) do {} while(0) |
---|
176 | #endif |
---|
177 | |
---|