… | |
… | |
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]) |
… | |
… | |
815 | #ifdef ENABLE_TRANSPARENCY |
819 | #ifdef ENABLE_TRANSPARENCY |
816 | if (option (Opt_transparent)) |
820 | if (option (Opt_transparent)) |
817 | { |
821 | { |
818 | bgPixmap.set_transparent (); |
822 | bgPixmap.set_transparent (); |
819 | |
823 | |
820 | #ifdef HAVE_AFTERIMAGE |
|
|
821 | if (rs [Rs_blurradius]) |
824 | if (rs [Rs_blurradius]) |
822 | bgPixmap.set_blur_radius (rs [Rs_blurradius]); |
825 | bgPixmap.set_blur_radius (rs [Rs_blurradius]); |
823 | #endif |
826 | |
824 | if (ISSET_PIXCOLOR (Color_tint)) |
827 | if (ISSET_PIXCOLOR (Color_tint)) |
825 | bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
828 | bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
826 | |
829 | |
827 | if (rs [Rs_shade]) |
830 | if (rs [Rs_shade]) |
828 | bgPixmap.set_shade (rs [Rs_shade]); |
831 | bgPixmap.set_shade (rs [Rs_shade]); |
… | |
… | |
1292 | { |
1295 | { |
1293 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
1296 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
1294 | return; |
1297 | return; |
1295 | } |
1298 | } |
1296 | |
1299 | |
1297 | int w = im->width; |
1300 | unsigned int w = im->width; |
1298 | int h = im->height; |
1301 | unsigned int h = im->height; |
1299 | |
1302 | |
1300 | if (!IN_RANGE_INC (w, 1, 32767) || !IN_RANGE_INC (h, 1, 32767)) |
1303 | if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383)) |
1301 | { |
1304 | { |
1302 | rxvt_warn ("Icon image too big, continuing without.\n"); |
1305 | rxvt_warn ("Icon image too big, continuing without.\n"); |
1303 | destroy_asimage (&im); |
1306 | destroy_asimage (&im); |
1304 | return; |
1307 | return; |
1305 | } |
1308 | } |
… | |
… | |
1331 | } |
1334 | } |
1332 | else |
1335 | else |
1333 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
1336 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
1334 | |
1337 | |
1335 | destroy_asimage (&result); |
1338 | destroy_asimage (&result); |
|
|
1339 | #endif |
|
|
1340 | |
|
|
1341 | #ifdef HAVE_PIXBUF |
|
|
1342 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); |
|
|
1343 | if (!pixbuf) |
|
|
1344 | { |
|
|
1345 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
|
|
1346 | return; |
|
|
1347 | } |
|
|
1348 | |
|
|
1349 | unsigned int w = gdk_pixbuf_get_width (pixbuf); |
|
|
1350 | unsigned int h = gdk_pixbuf_get_height (pixbuf); |
|
|
1351 | |
|
|
1352 | if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383)) |
|
|
1353 | { |
|
|
1354 | rxvt_warn ("Icon image too big, continuing without.\n"); |
|
|
1355 | g_object_unref (pixbuf); |
|
|
1356 | return; |
|
|
1357 | } |
|
|
1358 | |
|
|
1359 | if (long *buffer = (long *)malloc ((2 + w * h) * sizeof (long))) |
|
|
1360 | { |
|
|
1361 | int rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
|
|
1362 | unsigned char *row = gdk_pixbuf_get_pixels (pixbuf); |
|
|
1363 | int channels = gdk_pixbuf_get_n_channels (pixbuf); |
|
|
1364 | |
|
|
1365 | buffer [0] = w; |
|
|
1366 | buffer [1] = h; |
|
|
1367 | for (int i = 0; i < h; i++) |
|
|
1368 | { |
|
|
1369 | for (int j = 0; j < w; j++) |
|
|
1370 | { |
|
|
1371 | unsigned char *pixel = row + j * channels; |
|
|
1372 | long value; |
|
|
1373 | |
|
|
1374 | if (channels == 4) |
|
|
1375 | value = pixel[3]; |
|
|
1376 | else |
|
|
1377 | value = (unsigned char)0x00ff; |
|
|
1378 | |
|
|
1379 | value = (value << 8) + pixel[0]; |
|
|
1380 | value = (value << 8) + pixel[1]; |
|
|
1381 | value = (value << 8) + pixel[2]; |
|
|
1382 | buffer[(i * w + j) + 2] = value; |
|
|
1383 | } |
|
|
1384 | |
|
|
1385 | row += rowstride; |
|
|
1386 | } |
|
|
1387 | |
|
|
1388 | XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
|
|
1389 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
|
|
1390 | free (buffer); |
|
|
1391 | } |
|
|
1392 | else |
|
|
1393 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
|
|
1394 | |
|
|
1395 | g_object_unref (pixbuf); |
1336 | #endif |
1396 | #endif |
1337 | } |
1397 | } |
1338 | |
1398 | |
1339 | /*----------------------------------------------------------------------*/ |
1399 | /*----------------------------------------------------------------------*/ |
1340 | /* rxvt_Create_Windows () - Open and map the window */ |
1400 | /* rxvt_Create_Windows () - Open and map the window */ |