… | |
… | |
4 | * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de> |
4 | * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de> |
5 | * - original version. |
5 | * - original version. |
6 | * |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
9 | * the Free Software Foundation; either version 3 of the License, or |
10 | * (at your option) any later version. |
10 | * (at your option) any later version. |
11 | * |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
… | |
… | |
239 | else if (color >= 0) |
239 | else if (color >= 0) |
240 | { |
240 | { |
241 | #if XFT |
241 | #if XFT |
242 | Picture dst; |
242 | Picture dst; |
243 | |
243 | |
244 | # ifdef HAVE_BG_PIXMAP |
244 | # ifdef HAVE_IMG |
245 | if (term->bg_pixmap |
245 | if (term->bg_img |
246 | && !term->pix_colors[color].is_opaque () |
246 | && !term->pix_colors[color].is_opaque () |
247 | && ((dst = XftDrawPicture (d)))) |
247 | && ((dst = XftDrawPicture (d)))) |
248 | { |
248 | { |
249 | XClearArea (disp, d, x, y, w, h, false); |
249 | XClearArea (disp, d, x, y, w, h, false); |
250 | |
250 | |
… | |
… | |
934 | // ignore characters we wouldn't use anyways |
934 | // ignore characters we wouldn't use anyways |
935 | bool careful; |
935 | bool careful; |
936 | if (!has_char (*t, &prop, careful)) |
936 | if (!has_char (*t, &prop, careful)) |
937 | continue; |
937 | continue; |
938 | |
938 | |
939 | XChar2b ch = { *t >> 8, *t }; |
939 | // the casts are needed in C++11 (see 8.5.1) |
|
|
940 | XChar2b ch = { (unsigned char)(*t >> 8), (unsigned char)*t }; |
940 | |
941 | |
941 | XCharStruct g; |
942 | XCharStruct g; |
942 | int dir_ret, asc_ret, des_ret; |
943 | int dir_ret, asc_ret, des_ret; |
943 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
944 | XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); |
944 | |
945 | |
… | |
… | |
1044 | dTermDisplay; |
1045 | dTermDisplay; |
1045 | dTermGC; |
1046 | dTermGC; |
1046 | |
1047 | |
1047 | bool slow = this->slow |
1048 | bool slow = this->slow |
1048 | || width != term->fwidth |
1049 | || width != term->fwidth |
1049 | || height != term->fheight; |
1050 | || height != term->fheight |
|
|
1051 | || ascent != f->ascent; |
1050 | |
1052 | |
1051 | int base = ascent; // sorry, incorrect: term->fbase; |
1053 | int base = ascent; // sorry, incorrect: term->fbase; |
1052 | |
1054 | |
1053 | XGCValues v; |
1055 | XGCValues v; |
1054 | v.foreground = term->pix_colors[fg]; |
1056 | v.foreground = term->pix_colors[fg]; |
… | |
… | |
1408 | { |
1410 | { |
1409 | if (ep != enc) |
1411 | if (ep != enc) |
1410 | { |
1412 | { |
1411 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1413 | rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); |
1412 | |
1414 | |
1413 | #ifdef HAVE_BG_PIXMAP |
1415 | #ifdef HAVE_IMG |
1414 | Picture dst = 0; // the only assignment is done conditionally in the following if condition |
1416 | Picture dst = 0; // the only assignment is done conditionally in the following if condition |
1415 | |
1417 | |
1416 | if (term->bg_pixmap |
1418 | if (term->bg_img |
1417 | && (bg == Color_transparent || bg == Color_bg |
1419 | && (bg == Color_transparent || bg == Color_bg |
1418 | || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) |
1420 | || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) |
1419 | { |
1421 | { |
1420 | int src_x = x, src_y = y; |
1422 | int src_x = x, src_y = y; |
1421 | |
1423 | |
… | |
… | |
1423 | { |
1425 | { |
1424 | src_x += term->window_vt_x; |
1426 | src_x += term->window_vt_x; |
1425 | src_y += term->window_vt_y; |
1427 | src_y += term->window_vt_y; |
1426 | } |
1428 | } |
1427 | |
1429 | |
1428 | if (term->bg_pmap_width >= src_x + w |
1430 | if (term->bg_img->w >= src_x + w |
1429 | && term->bg_pmap_height >= src_y + h) |
1431 | && term->bg_img->h >= src_y + h) |
1430 | { |
1432 | { |
1431 | XCopyArea (disp, term->bg_pixmap, d2, gc, |
1433 | XCopyArea (disp, term->bg_img->pm, d2, gc, |
1432 | src_x, src_y, w, h, 0, 0); |
1434 | src_x, src_y, w, h, 0, 0); |
1433 | } |
1435 | } |
1434 | else |
1436 | else |
1435 | { |
1437 | { |
1436 | XGCValues gcv; |
1438 | XGCValues gcv; |
1437 | |
1439 | |
1438 | gcv.fill_style = FillTiled; |
1440 | gcv.fill_style = FillTiled; |
1439 | gcv.tile = term->bg_pixmap; |
1441 | gcv.tile = term->bg_img->pm; |
1440 | gcv.ts_x_origin = -src_x; |
1442 | gcv.ts_x_origin = -src_x; |
1441 | gcv.ts_y_origin = -src_y; |
1443 | gcv.ts_y_origin = -src_y; |
1442 | |
1444 | |
1443 | XChangeGC (disp, gc, |
1445 | XChangeGC (disp, gc, |
1444 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
1446 | GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, |
… | |
… | |
1499 | |
1501 | |
1500 | for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) |
1502 | for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) |
1501 | (*i)->unref (); |
1503 | (*i)->unref (); |
1502 | |
1504 | |
1503 | for (pagemap **p = fmap.begin (); p != fmap.end (); p++) |
1505 | for (pagemap **p = fmap.begin (); p != fmap.end (); p++) |
1504 | delete [] *p; |
1506 | delete *p; |
1505 | |
1507 | |
1506 | free (fontdesc); fontdesc = 0; |
1508 | free (fontdesc); fontdesc = 0; |
1507 | |
1509 | |
1508 | fonts.clear (); |
1510 | fonts.clear (); |
1509 | |
1511 | |
… | |
… | |
1604 | cs = codeset_from_name (spec + sizeof ("codeset=") - 1); |
1606 | cs = codeset_from_name (spec + sizeof ("codeset=") - 1); |
1605 | else |
1607 | else |
1606 | rxvt_warn ("unknown parameter '%s' in font specification, skipping.\n", spec); |
1608 | rxvt_warn ("unknown parameter '%s' in font specification, skipping.\n", spec); |
1607 | |
1609 | |
1608 | desc++; |
1610 | desc++; |
1609 | while (*desc <= ' ') desc++; |
1611 | while (*desc <= ' ' && *desc) desc++; |
1610 | } |
1612 | } |
1611 | |
1613 | |
1612 | end = strchr (desc, ','); |
1614 | end = strchr (desc, ','); |
1613 | if (!end) |
1615 | if (!end) |
1614 | end = desc + strlen (desc); |
1616 | end = desc + strlen (desc); |
… | |
… | |
1785 | while (hi >= fmap.size ()) |
1787 | while (hi >= fmap.size ()) |
1786 | fmap.push_back (0); |
1788 | fmap.push_back (0); |
1787 | |
1789 | |
1788 | if (!fmap[hi]) |
1790 | if (!fmap[hi]) |
1789 | { |
1791 | { |
1790 | // we use [1] here because C++ has no separate new and new [] forms, |
|
|
1791 | // and pagemap is char[256], so new incorrectly assumes we want to |
|
|
1792 | // allocate an array of chars instead of a single pagemap. |
|
|
1793 | // we can either cast the resulting pointer to (pagemap *) or |
|
|
1794 | // allocate an array of pagemaps, returning a pointer to the first member |
|
|
1795 | // this is no extra overhead, as new even allocates an array for |
|
|
1796 | // "new pagemap" |
|
|
1797 | fmap[hi] = new pagemap[1]; |
1792 | fmap[hi] = new pagemap; |
1798 | memset (fmap[hi], 0xff, sizeof (pagemap)); |
1793 | memset (fmap[hi], 0xff, sizeof (pagemap)); |
1799 | } |
1794 | } |
1800 | |
1795 | |
1801 | (*fmap[hi])[unicode & 0xff] = i; |
1796 | (*fmap[hi])[unicode & 0xff] = i; |
1802 | } |
1797 | } |