… | |
… | |
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]); |
… | |
… | |
887 | |
890 | |
888 | /*----------------------------------------------------------------------*/ |
891 | /*----------------------------------------------------------------------*/ |
889 | void |
892 | void |
890 | rxvt_term::init_env () |
893 | rxvt_term::init_env () |
891 | { |
894 | { |
892 | int i; |
|
|
893 | char *val; |
895 | char *val; |
894 | |
896 | |
895 | #ifdef DISPLAY_IS_IP |
897 | #ifdef DISPLAY_IS_IP |
896 | /* Fixup display_name for export over pty to any interested terminal |
898 | /* 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 |
899 | * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number |
… | |
… | |
911 | val = XDisplayString (dpy); |
913 | val = XDisplayString (dpy); |
912 | |
914 | |
913 | if (rs[Rs_display_name] == NULL) |
915 | if (rs[Rs_display_name] == NULL) |
914 | rs[Rs_display_name] = val; /* use broken `:0' value */ |
916 | rs[Rs_display_name] = val; /* use broken `:0' value */ |
915 | |
917 | |
916 | i = strlen (val); |
|
|
917 | env_display = (char *)rxvt_malloc (i + 9); |
918 | env_display = (char *)rxvt_malloc (strlen (val) + 9); |
918 | |
919 | |
919 | sprintf (env_display, "DISPLAY=%s", val); |
920 | sprintf (env_display, "DISPLAY=%s", val); |
920 | |
921 | |
921 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); |
922 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); |
922 | |
923 | |
… | |
… | |
1279 | |
1280 | |
1280 | if (i) |
1281 | if (i) |
1281 | ModMetaMask = modmasks[i - 1]; |
1282 | ModMetaMask = modmasks[i - 1]; |
1282 | } |
1283 | } |
1283 | |
1284 | |
|
|
1285 | void |
|
|
1286 | rxvt_term::set_icon (const char *file) |
|
|
1287 | { |
|
|
1288 | #ifdef HAVE_AFTERIMAGE |
|
|
1289 | init_asv (); |
|
|
1290 | |
|
|
1291 | ASImage *im = file2ASImage (file, 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL); |
|
|
1292 | if (!im) |
|
|
1293 | { |
|
|
1294 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
|
|
1295 | return; |
|
|
1296 | } |
|
|
1297 | |
|
|
1298 | unsigned int w = im->width; |
|
|
1299 | unsigned int h = im->height; |
|
|
1300 | |
|
|
1301 | if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383)) |
|
|
1302 | { |
|
|
1303 | rxvt_warn ("Icon image too big, continuing without.\n"); |
|
|
1304 | destroy_asimage (&im); |
|
|
1305 | return; |
|
|
1306 | } |
|
|
1307 | |
|
|
1308 | ASImage *result = scale_asimage (asv, im, |
|
|
1309 | w, h, ASA_ARGB32, |
|
|
1310 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1311 | destroy_asimage (&im); |
|
|
1312 | |
|
|
1313 | if (!result) |
|
|
1314 | { |
|
|
1315 | rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n"); |
|
|
1316 | return; |
|
|
1317 | } |
|
|
1318 | |
|
|
1319 | long *buffer = (long *)malloc ((2 + w * h) * sizeof (long)); |
|
|
1320 | if (buffer) |
|
|
1321 | { |
|
|
1322 | ARGB32 *asbuf = result->alt.argb32; |
|
|
1323 | buffer [0] = w; |
|
|
1324 | buffer [1] = h; |
|
|
1325 | |
|
|
1326 | for (unsigned int i = 0; i < w * h; ++i) |
|
|
1327 | buffer [i + 2] = asbuf [i]; |
|
|
1328 | |
|
|
1329 | XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
|
|
1330 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
|
|
1331 | free (buffer); |
|
|
1332 | } |
|
|
1333 | else |
|
|
1334 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
|
|
1335 | |
|
|
1336 | destroy_asimage (&result); |
|
|
1337 | #endif |
|
|
1338 | |
|
|
1339 | #ifdef HAVE_PIXBUF |
|
|
1340 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); |
|
|
1341 | if (!pixbuf) |
|
|
1342 | { |
|
|
1343 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
|
|
1344 | return; |
|
|
1345 | } |
|
|
1346 | |
|
|
1347 | unsigned int w = gdk_pixbuf_get_width (pixbuf); |
|
|
1348 | unsigned int h = gdk_pixbuf_get_height (pixbuf); |
|
|
1349 | |
|
|
1350 | if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383)) |
|
|
1351 | { |
|
|
1352 | rxvt_warn ("Icon image too big, continuing without.\n"); |
|
|
1353 | g_object_unref (pixbuf); |
|
|
1354 | return; |
|
|
1355 | } |
|
|
1356 | |
|
|
1357 | if (long *buffer = (long *)malloc ((2 + w * h) * sizeof (long))) |
|
|
1358 | { |
|
|
1359 | int rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
|
|
1360 | unsigned char *row = gdk_pixbuf_get_pixels (pixbuf); |
|
|
1361 | int channels = gdk_pixbuf_get_n_channels (pixbuf); |
|
|
1362 | |
|
|
1363 | buffer [0] = w; |
|
|
1364 | buffer [1] = h; |
|
|
1365 | for (int i = 0; i < h; i++) |
|
|
1366 | { |
|
|
1367 | for (int j = 0; j < w; j++) |
|
|
1368 | { |
|
|
1369 | unsigned char *pixel = row + j * channels; |
|
|
1370 | long value; |
|
|
1371 | |
|
|
1372 | if (channels == 4) |
|
|
1373 | value = pixel[3]; |
|
|
1374 | else |
|
|
1375 | value = (unsigned char)0x00ff; |
|
|
1376 | |
|
|
1377 | value = (value << 8) + pixel[0]; |
|
|
1378 | value = (value << 8) + pixel[1]; |
|
|
1379 | value = (value << 8) + pixel[2]; |
|
|
1380 | buffer[(i * w + j) + 2] = value; |
|
|
1381 | } |
|
|
1382 | |
|
|
1383 | row += rowstride; |
|
|
1384 | } |
|
|
1385 | |
|
|
1386 | XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
|
|
1387 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
|
|
1388 | free (buffer); |
|
|
1389 | } |
|
|
1390 | else |
|
|
1391 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
|
|
1392 | |
|
|
1393 | g_object_unref (pixbuf); |
|
|
1394 | #endif |
|
|
1395 | } |
|
|
1396 | |
1284 | /*----------------------------------------------------------------------*/ |
1397 | /*----------------------------------------------------------------------*/ |
1285 | /* rxvt_Create_Windows () - Open and map the window */ |
1398 | /* rxvt_Create_Windows () - Open and map the window */ |
1286 | void |
1399 | void |
1287 | rxvt_term::create_windows (int argc, const char *const *argv) |
1400 | rxvt_term::create_windows (int argc, const char *const *argv) |
1288 | { |
1401 | { |
… | |
… | |
1368 | wmHint.window_group = top; |
1481 | wmHint.window_group = top; |
1369 | |
1482 | |
1370 | XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, |
1483 | XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, |
1371 | &szHint, &wmHint, &classHint); |
1484 | &szHint, &wmHint, &classHint); |
1372 | #if ENABLE_EWMH |
1485 | #if ENABLE_EWMH |
1373 | # ifdef HAVE_AFTERIMAGE |
|
|
1374 | /* |
1486 | /* |
1375 | * set up icon hint |
1487 | * set up icon hint |
1376 | * rs [Rs_iconfile] is path to icon, asv has been created in init_resources |
1488 | * rs [Rs_iconfile] is path to icon |
1377 | */ |
1489 | */ |
1378 | |
1490 | |
1379 | if (rs [Rs_iconfile]) |
1491 | if (rs [Rs_iconfile]) |
1380 | { |
1492 | { |
1381 | init_asv (); |
1493 | set_icon (rs [Rs_iconfile]); |
1382 | |
|
|
1383 | ASImage *im = file2ASImage (rs [Rs_iconfile], 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL); |
|
|
1384 | if (asv && im) |
|
|
1385 | { |
|
|
1386 | int w = im->width; |
|
|
1387 | int h = im->height; |
|
|
1388 | long *buffer = (long *)malloc ((2 + w * h) * sizeof (long)); |
|
|
1389 | ASImage *result = scale_asimage (asv, im, |
|
|
1390 | w, h, ASA_ARGB32, |
|
|
1391 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1392 | destroy_asimage (&im); |
|
|
1393 | |
|
|
1394 | if (buffer && result) |
|
|
1395 | { |
|
|
1396 | ARGB32 *asbuf = result->alt.argb32; |
|
|
1397 | buffer [0] = w; |
|
|
1398 | buffer [1] = h; |
|
|
1399 | |
|
|
1400 | for (unsigned int i = 0; i < w * h; ++i) |
|
|
1401 | buffer [i + 2] = asbuf [i]; |
|
|
1402 | |
|
|
1403 | destroy_asimage (&result); |
|
|
1404 | XChangeProperty (dpy, top, xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
|
|
1405 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
|
|
1406 | free (buffer); |
|
|
1407 | } |
|
|
1408 | else |
|
|
1409 | { |
|
|
1410 | if (!buffer) |
|
|
1411 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
|
|
1412 | |
|
|
1413 | if (!result) |
|
|
1414 | rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n"); |
|
|
1415 | } |
|
|
1416 | } |
|
|
1417 | else |
|
|
1418 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
|
|
1419 | } |
1494 | } |
1420 | # endif |
|
|
1421 | #endif |
1495 | #endif |
1422 | |
1496 | |
1423 | #if ENABLE_FRILLS |
1497 | #if ENABLE_FRILLS |
1424 | if (mwmhints.flags) |
1498 | if (mwmhints.flags) |
1425 | XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
1499 | XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
… | |
… | |
1431 | #if ENABLE_EWMH |
1505 | #if ENABLE_EWMH |
1432 | xa[XA_NET_WM_PING], |
1506 | xa[XA_NET_WM_PING], |
1433 | #endif |
1507 | #endif |
1434 | }; |
1508 | }; |
1435 | |
1509 | |
1436 | XSetWMProtocols (dpy, top, protocols, sizeof (protocols) / sizeof (protocols[0])); |
1510 | XSetWMProtocols (dpy, top, protocols, ARRAY_LENGTH(protocols)); |
1437 | |
1511 | |
1438 | #if ENABLE_FRILLS |
1512 | #if ENABLE_FRILLS |
1439 | if (rs[Rs_transient_for]) |
1513 | if (rs[Rs_transient_for]) |
1440 | XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); |
1514 | XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); |
1441 | #endif |
1515 | #endif |