… | |
… | |
70 | #include <X11/cursorfont.h> |
70 | #include <X11/cursorfont.h> |
71 | #include <X11/keysym.h> |
71 | #include <X11/keysym.h> |
72 | #include <X11/keysymdef.h> |
72 | #include <X11/keysymdef.h> |
73 | #include <X11/Xatom.h> |
73 | #include <X11/Xatom.h> |
74 | |
74 | |
75 | #ifdef HAVE_PIXBUF |
75 | #if HAVE_PIXBUF |
76 | # include <gdk-pixbuf/gdk-pixbuf.h> |
76 | # include <gdk-pixbuf/gdk-pixbuf.h> |
77 | #endif |
77 | #endif |
78 | |
78 | |
79 | #if defined(BG_IMAGE_FROM_FILE) || defined(ENABLE_TRANSPARENCY) |
79 | #if defined(BG_IMAGE_FROM_FILE) || defined(ENABLE_TRANSPARENCY) |
80 | # define HAVE_BG_PIXMAP 1 |
80 | # define HAVE_BG_PIXMAP 1 |
… | |
… | |
83 | #include <ecb.h> |
83 | #include <ecb.h> |
84 | #include "encoding.h" |
84 | #include "encoding.h" |
85 | #include "rxvtutil.h" |
85 | #include "rxvtutil.h" |
86 | #include "rxvtfont.h" |
86 | #include "rxvtfont.h" |
87 | #include "rxvttoolkit.h" |
87 | #include "rxvttoolkit.h" |
|
|
88 | #include "rxvtimg.h" |
88 | #include "scrollbar.h" |
89 | #include "scrollbar.h" |
89 | #include "ev_cpp.h" |
90 | #include "ev_cpp.h" |
90 | #include "libptytty.h" |
91 | #include "libptytty.h" |
91 | |
92 | |
92 | #include "rxvtperl.h" |
93 | #include "rxvtperl.h" |
… | |
… | |
147 | |
148 | |
148 | const char * rxvt_basename (const char *str) NOTHROW; |
149 | const char * rxvt_basename (const char *str) NOTHROW; |
149 | void rxvt_vlog (const char *fmt, va_list arg_ptr) NOTHROW; |
150 | void rxvt_vlog (const char *fmt, va_list arg_ptr) NOTHROW; |
150 | void rxvt_log (const char *fmt,...) NOTHROW; |
151 | void rxvt_log (const char *fmt,...) NOTHROW; |
151 | void rxvt_warn (const char *fmt,...) NOTHROW; |
152 | void rxvt_warn (const char *fmt,...) NOTHROW; |
152 | void rxvt_fatal (const char *fmt, ...) THROW ((class rxvt_failure_exception)) ecb_noreturn; |
153 | void rxvt_fatal (const char *fmt, ...) THROW ((class rxvt_failure_exception)) ecb_noreturn ecb_cold; |
153 | void rxvt_exit_failure () THROW ((class rxvt_failure_exception)) ecb_noreturn; |
154 | void rxvt_exit_failure () THROW ((class rxvt_failure_exception)) ecb_noreturn ecb_cold; |
154 | |
155 | |
155 | char * rxvt_strtrim (char *str) NOTHROW; |
156 | char * rxvt_strtrim (char *str) NOTHROW; |
156 | char ** rxvt_strsplit (char delim, const char *str) NOTHROW; |
157 | char ** rxvt_strsplit (char delim, const char *str) NOTHROW; |
157 | |
158 | |
158 | static inline void |
159 | static inline void |
… | |
… | |
209 | environ = orig_env; |
210 | environ = orig_env; |
210 | } |
211 | } |
211 | }; |
212 | }; |
212 | |
213 | |
213 | #ifdef HAVE_BG_PIXMAP |
214 | #ifdef HAVE_BG_PIXMAP |
|
|
215 | struct image_effects |
|
|
216 | { |
|
|
217 | bool tint_set; |
|
|
218 | rxvt_color tint; |
|
|
219 | int shade; |
|
|
220 | int h_blurRadius, v_blurRadius; |
|
|
221 | |
|
|
222 | image_effects () |
|
|
223 | { |
|
|
224 | tint_set = |
|
|
225 | h_blurRadius = |
|
|
226 | v_blurRadius = 0; |
|
|
227 | shade = 100; |
|
|
228 | } |
|
|
229 | |
|
|
230 | bool need_tint () |
|
|
231 | { |
|
|
232 | return shade != 100 || tint_set; |
|
|
233 | } |
|
|
234 | |
|
|
235 | bool need_blur () |
|
|
236 | { |
|
|
237 | return h_blurRadius && v_blurRadius; |
|
|
238 | } |
|
|
239 | |
|
|
240 | bool set_tint (const rxvt_color &new_tint); |
|
|
241 | bool set_shade (const char *shade_str); |
|
|
242 | bool set_blur (const char *geom); |
|
|
243 | }; |
|
|
244 | |
214 | # ifdef BG_IMAGE_FROM_FILE |
245 | # if BG_IMAGE_FROM_FILE |
215 | enum { |
246 | enum { |
216 | IM_IS_SET = 1 << 0, |
247 | IM_IS_SET = 1 << 0, |
217 | IM_IS_SIZE_SENSITIVE = 1 << 1, |
248 | IM_IS_SIZE_SENSITIVE = 1 << 1, |
218 | IM_KEEP_ASPECT = 1 << 2, |
249 | IM_KEEP_ASPECT = 1 << 2, |
219 | IM_ROOT_ALIGN = 1 << 3, |
250 | IM_ROOT_ALIGN = 1 << 3, |
… | |
… | |
227 | defaultScale = windowScale, |
258 | defaultScale = windowScale, |
228 | centerAlign = 50, |
259 | centerAlign = 50, |
229 | defaultAlign = centerAlign, |
260 | defaultAlign = centerAlign, |
230 | }; |
261 | }; |
231 | |
262 | |
232 | struct rxvt_image |
263 | struct rxvt_image : image_effects |
233 | { |
264 | { |
234 | unsigned short alpha; |
265 | unsigned short alpha; |
235 | uint8_t flags; |
266 | uint8_t flags; |
236 | unsigned int h_scale, v_scale; /* percents of the window size */ |
267 | unsigned int h_scale, v_scale; /* percents of the window size */ |
237 | int h_align, v_align; /* percents of the window size: |
268 | int h_align, v_align; /* percents of the window size: |
238 | 0 - left align, 50 - center, 100 - right */ |
269 | 0 - left align, 50 - center, 100 - right */ |
239 | |
270 | |
|
|
271 | bool is_size_sensitive () |
|
|
272 | { |
|
|
273 | return (!(flags & IM_TILE) |
|
|
274 | || h_scale || v_scale |
|
|
275 | || (!(flags & IM_ROOT_ALIGN) && (h_align || v_align))); |
|
|
276 | } |
|
|
277 | |
240 | # ifdef HAVE_PIXBUF |
278 | # if HAVE_PIXBUF |
241 | GdkPixbuf *pixbuf; |
279 | GdkPixbuf *pixbuf; |
242 | |
280 | |
243 | void destroy () |
281 | void destroy () |
244 | { |
282 | { |
245 | if (pixbuf) |
283 | if (pixbuf) |
… | |
… | |
313 | ***************************************************************************** |
351 | ***************************************************************************** |
314 | */ |
352 | */ |
315 | |
353 | |
316 | /* COLORTERM, TERM environment variables */ |
354 | /* COLORTERM, TERM environment variables */ |
317 | #define COLORTERMENV "rxvt" |
355 | #define COLORTERMENV "rxvt" |
318 | #ifdef BG_IMAGE_FROM_FILE |
356 | #if BG_IMAGE_FROM_FILE |
319 | # define COLORTERMENVFULL COLORTERMENV "-xpm" |
357 | # define COLORTERMENVFULL COLORTERMENV "-xpm" |
320 | #else |
358 | #else |
321 | # define COLORTERMENVFULL COLORTERMENV |
359 | # define COLORTERMENVFULL COLORTERMENV |
322 | #endif |
360 | #endif |
323 | #ifndef TERMENV |
361 | #ifndef TERMENV |
… | |
… | |
1154 | enum { |
1192 | enum { |
1155 | BG_IS_VALID = 1 << 0, |
1193 | BG_IS_VALID = 1 << 0, |
1156 | |
1194 | |
1157 | BG_IS_TRANSPARENT = 1 << 1, |
1195 | BG_IS_TRANSPARENT = 1 << 1, |
1158 | BG_NEEDS_REFRESH = 1 << 2, |
1196 | BG_NEEDS_REFRESH = 1 << 2, |
1159 | |
|
|
1160 | BG_HAS_RENDER = 1 << 3, |
|
|
1161 | BG_HAS_RENDER_CONV = 1 << 4, |
|
|
1162 | BG_CLIENT_RENDER = 1 << 5, |
|
|
1163 | |
|
|
1164 | BG_TINT_SET = 1 << 6, |
|
|
1165 | BG_TINT_BITAND = 1 << 7, |
|
|
1166 | }; |
1197 | }; |
1167 | |
1198 | |
1168 | uint8_t bg_flags; |
1199 | uint8_t bg_flags; |
1169 | |
1200 | |
1170 | # ifdef BG_IMAGE_FROM_FILE |
1201 | # if BG_IMAGE_FROM_FILE |
1171 | vector<rxvt_image> image_vec; |
1202 | vector<rxvt_image> image_vec; |
1172 | rxvt_image *new_image () |
1203 | rxvt_image *new_image () |
1173 | { |
1204 | { |
1174 | image_vec.resize (image_vec.size () + 1); |
1205 | image_vec.resize (image_vec.size () + 1); |
1175 | return &image_vec.back (); |
1206 | return &image_vec.back (); |
… | |
… | |
1177 | void get_image_geometry (rxvt_image &image, int &w, int &h, int &x, int &y); |
1208 | void get_image_geometry (rxvt_image &image, int &w, int &h, int &x, int &y); |
1178 | bool render_image (rxvt_image &image); |
1209 | bool render_image (rxvt_image &image); |
1179 | void parse_image (int id, const char *type, const char *arg); |
1210 | void parse_image (int id, const char *type, const char *arg); |
1180 | # endif |
1211 | # endif |
1181 | |
1212 | |
1182 | # ifdef ENABLE_TRANSPARENCY |
1213 | # if ENABLE_TRANSPARENCY |
1183 | Pixmap root_pixmap; /* current root pixmap set */ |
1214 | Pixmap root_pixmap; /* current root pixmap set */ |
1184 | rxvt_color tint; |
1215 | image_effects root_effects; |
1185 | int shade; |
|
|
1186 | int h_blurRadius, v_blurRadius; |
|
|
1187 | |
1216 | |
1188 | void bg_set_transparent () |
1217 | void bg_set_transparent () |
1189 | { |
1218 | { |
1190 | bg_flags |= BG_IS_TRANSPARENT; |
1219 | bg_flags |= BG_IS_TRANSPARENT; |
1191 | } |
1220 | } |
1192 | void bg_set_root_pixmap (); |
1221 | void bg_set_root_pixmap (); |
1193 | bool bg_set_tint (rxvt_color &new_tint); |
1222 | bool render_root_image (); |
1194 | bool bg_set_shade (const char *shade_str); |
|
|
1195 | bool bg_set_blur (const char *geom); |
|
|
1196 | |
|
|
1197 | bool blur_pixmap (Pixmap pixmap, int width, int height); |
|
|
1198 | bool tint_pixmap (Pixmap pixmap, int width, int height); |
|
|
1199 | void tint_ximage (XImage *ximage); |
|
|
1200 | bool make_transparency_pixmap (); |
|
|
1201 | # endif |
1223 | # endif |
|
|
1224 | |
|
|
1225 | bool blur_pixmap (Pixmap pixmap, int width, int height, bool argb, int h_blurRadius, int v_blurRadius); |
|
|
1226 | bool tint_pixmap (Pixmap pixmap, int width, int height, bool argb, rxvt_color &tint, bool tint_set, int shade); |
|
|
1227 | void tint_ximage (XImage *ximage, rxvt_color &tint, bool tint_set, int shade); |
1202 | |
1228 | |
1203 | ev_tstamp bg_valid_since; |
1229 | ev_tstamp bg_valid_since; |
1204 | |
1230 | |
1205 | Pixmap bg_pixmap; |
1231 | Pixmap bg_pixmap; |
1206 | unsigned int bg_pmap_width, bg_pmap_height; |
1232 | unsigned int bg_pmap_width, bg_pmap_height; |
… | |
… | |
1215 | void bg_invalidate () |
1241 | void bg_invalidate () |
1216 | { |
1242 | { |
1217 | bg_flags &= ~BG_IS_VALID; |
1243 | bg_flags &= ~BG_IS_VALID; |
1218 | } |
1244 | } |
1219 | #endif |
1245 | #endif |
1220 | #ifdef HAVE_PIXBUF |
1246 | #if HAVE_PIXBUF |
1221 | bool pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, |
1247 | bool pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, |
1222 | int src_x, int src_y, int dst_x, int dst_y, |
1248 | int src_x, int src_y, int dst_x, int dst_y, |
1223 | unsigned int width, unsigned int height, bool argb); |
1249 | unsigned int width, unsigned int height, bool argb); |
1224 | #endif |
1250 | #endif |
1225 | |
1251 | |
… | |
… | |
1235 | void scr_overlay_set (int x, int y, const char *s) NOTHROW; |
1261 | void scr_overlay_set (int x, int y, const char *s) NOTHROW; |
1236 | void scr_overlay_set (int x, int y, const wchar_t *s) NOTHROW; |
1262 | void scr_overlay_set (int x, int y, const wchar_t *s) NOTHROW; |
1237 | #endif |
1263 | #endif |
1238 | |
1264 | |
1239 | vector<void *> allocated; // free these memory blocks with free() |
1265 | vector<void *> allocated; // free these memory blocks with free() |
|
|
1266 | |
|
|
1267 | int parent_x, parent_y; // parent window position relative to root, only updated on demand |
1240 | |
1268 | |
1241 | char *locale; |
1269 | char *locale; |
1242 | char charsets[4]; |
1270 | char charsets[4]; |
1243 | char *v_buffer; /* pointer to physical buffer */ |
1271 | char *v_buffer; /* pointer to physical buffer */ |
1244 | unsigned int v_buflen; /* size of area to write */ |
1272 | unsigned int v_buflen; /* size of area to write */ |
… | |
… | |
1439 | char *get_colorfgbg (); |
1467 | char *get_colorfgbg (); |
1440 | bool set_color (rxvt_color &color, const char *name); |
1468 | bool set_color (rxvt_color &color, const char *name); |
1441 | void alias_color (int dst, int src); |
1469 | void alias_color (int dst, int src); |
1442 | void set_widthheight (unsigned int newwidth, unsigned int newheight); |
1470 | void set_widthheight (unsigned int newwidth, unsigned int newheight); |
1443 | void get_window_origin (int &x, int &y); |
1471 | void get_window_origin (int &x, int &y); |
1444 | Pixmap get_pixmap_property (Atom property); |
|
|
1445 | |
1472 | |
1446 | // screen.C |
1473 | // screen.C |
1447 | |
1474 | |
1448 | int fgcolor_of (rend_t r) const NOTHROW |
1475 | int fgcolor_of (rend_t r) const NOTHROW |
1449 | { |
1476 | { |