… | |
… | |
143 | |
143 | |
144 | return rval; |
144 | return rval; |
145 | } |
145 | } |
146 | #endif |
146 | #endif |
147 | |
147 | |
148 | const char *const def_colorName[] = |
148 | static const char *const def_colorName[] = |
149 | { |
149 | { |
150 | COLOR_FOREGROUND, |
150 | COLOR_FOREGROUND, |
151 | COLOR_BACKGROUND, |
151 | COLOR_BACKGROUND, |
152 | /* low-intensity colors */ |
152 | /* low-intensity colors */ |
153 | "rgb:00/00/00", // 0: black (Black) |
153 | "rgb:00/00/00", // 0: black (Black) |
… | |
… | |
632 | #ifdef HAVE_AFTERIMAGE |
632 | #ifdef HAVE_AFTERIMAGE |
633 | set_application_name ((char *)rs[Rs_name]); |
633 | set_application_name ((char *)rs[Rs_name]); |
634 | set_output_threshold (OUTPUT_LEVEL_WARNING); |
634 | set_output_threshold (OUTPUT_LEVEL_WARNING); |
635 | #endif |
635 | #endif |
636 | |
636 | |
|
|
637 | #ifdef HAVE_PIXBUF |
|
|
638 | g_type_init (); |
|
|
639 | #endif |
|
|
640 | |
637 | #if ENABLE_PERL |
641 | #if ENABLE_PERL |
638 | if (!rs[Rs_perl_ext_1]) |
642 | if (!rs[Rs_perl_ext_1]) |
639 | rs[Rs_perl_ext_1] = "default"; |
643 | rs[Rs_perl_ext_1] = "default"; |
640 | |
644 | |
641 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
645 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
… | |
… | |
808 | if (option (Opt_scrollBar)) |
812 | if (option (Opt_scrollBar)) |
809 | scrollBar.resize (); /* create and map scrollbar */ |
813 | scrollBar.resize (); /* create and map scrollbar */ |
810 | #ifdef HAVE_BG_PIXMAP |
814 | #ifdef HAVE_BG_PIXMAP |
811 | { |
815 | { |
812 | bgPixmap.set_target (this); |
816 | bgPixmap.set_target (this); |
813 | bgPixmap.invalidate (); |
|
|
814 | |
817 | |
815 | #ifdef ENABLE_TRANSPARENCY |
818 | #ifdef ENABLE_TRANSPARENCY |
816 | if (option (Opt_transparent)) |
819 | if (option (Opt_transparent)) |
817 | { |
820 | { |
818 | bgPixmap.set_transparent (); |
821 | bgPixmap.set_transparent (); |
819 | |
822 | |
820 | #ifdef HAVE_AFTERIMAGE |
|
|
821 | if (rs [Rs_blurradius]) |
823 | if (rs [Rs_blurradius]) |
822 | bgPixmap.set_blur_radius (rs [Rs_blurradius]); |
824 | bgPixmap.set_blur_radius (rs [Rs_blurradius]); |
823 | #endif |
825 | |
824 | if (ISSET_PIXCOLOR (Color_tint)) |
826 | if (ISSET_PIXCOLOR (Color_tint)) |
825 | bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
827 | bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
826 | |
828 | |
827 | if (rs [Rs_shade]) |
829 | if (rs [Rs_shade]) |
828 | bgPixmap.set_shade (rs [Rs_shade]); |
830 | bgPixmap.set_shade (rs [Rs_shade]); |
… | |
… | |
887 | |
889 | |
888 | /*----------------------------------------------------------------------*/ |
890 | /*----------------------------------------------------------------------*/ |
889 | void |
891 | void |
890 | rxvt_term::init_env () |
892 | rxvt_term::init_env () |
891 | { |
893 | { |
892 | int i; |
|
|
893 | char *val; |
894 | char *val; |
894 | |
895 | |
895 | #ifdef DISPLAY_IS_IP |
896 | #ifdef DISPLAY_IS_IP |
896 | /* Fixup display_name for export over pty to any interested terminal |
897 | /* Fixup display_name for export over pty to any interested terminal |
897 | * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number |
898 | * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number |
… | |
… | |
911 | val = XDisplayString (dpy); |
912 | val = XDisplayString (dpy); |
912 | |
913 | |
913 | if (rs[Rs_display_name] == NULL) |
914 | if (rs[Rs_display_name] == NULL) |
914 | rs[Rs_display_name] = val; /* use broken `:0' value */ |
915 | rs[Rs_display_name] = val; /* use broken `:0' value */ |
915 | |
916 | |
916 | i = strlen (val); |
|
|
917 | env_display = (char *)rxvt_malloc (i + 9); |
917 | env_display = (char *)rxvt_malloc (strlen (val) + 9); |
918 | |
918 | |
919 | sprintf (env_display, "DISPLAY=%s", val); |
919 | sprintf (env_display, "DISPLAY=%s", val); |
920 | |
920 | |
921 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); |
921 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); |
922 | |
922 | |
… | |
… | |
1332 | else |
1332 | else |
1333 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
1333 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
1334 | |
1334 | |
1335 | destroy_asimage (&result); |
1335 | destroy_asimage (&result); |
1336 | #endif |
1336 | #endif |
|
|
1337 | |
|
|
1338 | #ifdef HAVE_PIXBUF |
|
|
1339 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); |
|
|
1340 | if (!pixbuf) |
|
|
1341 | { |
|
|
1342 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
|
|
1343 | return; |
|
|
1344 | } |
|
|
1345 | |
|
|
1346 | unsigned int w = gdk_pixbuf_get_width (pixbuf); |
|
|
1347 | unsigned int h = gdk_pixbuf_get_height (pixbuf); |
|
|
1348 | |
|
|
1349 | if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383)) |
|
|
1350 | { |
|
|
1351 | rxvt_warn ("Icon image too big, continuing without.\n"); |
|
|
1352 | g_object_unref (pixbuf); |
|
|
1353 | return; |
|
|
1354 | } |
|
|
1355 | |
|
|
1356 | if (long *buffer = (long *)malloc ((2 + w * h) * sizeof (long))) |
|
|
1357 | { |
|
|
1358 | int rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
|
|
1359 | unsigned char *row = gdk_pixbuf_get_pixels (pixbuf); |
|
|
1360 | int channels = gdk_pixbuf_get_n_channels (pixbuf); |
|
|
1361 | |
|
|
1362 | buffer [0] = w; |
|
|
1363 | buffer [1] = h; |
|
|
1364 | for (int i = 0; i < h; i++) |
|
|
1365 | { |
|
|
1366 | for (int j = 0; j < w; j++) |
|
|
1367 | { |
|
|
1368 | unsigned char *pixel = row + j * channels; |
|
|
1369 | long value; |
|
|
1370 | |
|
|
1371 | if (channels == 4) |
|
|
1372 | value = pixel[3]; |
|
|
1373 | else |
|
|
1374 | value = (unsigned char)0x00ff; |
|
|
1375 | |
|
|
1376 | value = (value << 8) + pixel[0]; |
|
|
1377 | value = (value << 8) + pixel[1]; |
|
|
1378 | value = (value << 8) + pixel[2]; |
|
|
1379 | buffer[(i * w + j) + 2] = value; |
|
|
1380 | } |
|
|
1381 | |
|
|
1382 | row += rowstride; |
|
|
1383 | } |
|
|
1384 | |
|
|
1385 | XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
|
|
1386 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
|
|
1387 | free (buffer); |
|
|
1388 | } |
|
|
1389 | else |
|
|
1390 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
|
|
1391 | |
|
|
1392 | g_object_unref (pixbuf); |
|
|
1393 | #endif |
1337 | } |
1394 | } |
1338 | |
1395 | |
1339 | /*----------------------------------------------------------------------*/ |
1396 | /*----------------------------------------------------------------------*/ |
1340 | /* rxvt_Create_Windows () - Open and map the window */ |
1397 | /* rxvt_Create_Windows () - Open and map the window */ |
1341 | void |
1398 | void |
… | |
… | |
1447 | #if ENABLE_EWMH |
1504 | #if ENABLE_EWMH |
1448 | xa[XA_NET_WM_PING], |
1505 | xa[XA_NET_WM_PING], |
1449 | #endif |
1506 | #endif |
1450 | }; |
1507 | }; |
1451 | |
1508 | |
1452 | XSetWMProtocols (dpy, top, protocols, sizeof (protocols) / sizeof (protocols[0])); |
1509 | XSetWMProtocols (dpy, top, protocols, ARRAY_LENGTH(protocols)); |
1453 | |
1510 | |
1454 | #if ENABLE_FRILLS |
1511 | #if ENABLE_FRILLS |
1455 | if (rs[Rs_transient_for]) |
1512 | if (rs[Rs_transient_for]) |
1456 | XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); |
1513 | XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); |
1457 | #endif |
1514 | #endif |