aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorakir <akir>2004-09-10 16:12:49 (GMT)
committerakir <akir>2004-09-10 16:12:49 (GMT)
commitbf48239deea87d7d4ccb2a2fe616d15dc2750de5 (patch)
tree5f062562b393fa556b61dd173eab0f496bc42fe1 /src
parent97d2577f1a2861113f9755260ef0225618056a06 (diff)
downloadfluxbox_paul-bf48239deea87d7d4ccb2a2fe616d15dc2750de5.zip
fluxbox_paul-bf48239deea87d7d4ccb2a2fe616d15dc2750de5.tar.bz2
cosmetic + try to avoid App::instance()->display() calls when not needed
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/XftFontImp.cc23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/FbTk/XftFontImp.cc b/src/FbTk/XftFontImp.cc
index c2f1dc8..bf0aaa1 100644
--- a/src/FbTk/XftFontImp.cc
+++ b/src/FbTk/XftFontImp.cc
@@ -1,6 +1,6 @@
1// XftFontImp.cc Xft font implementation for FbTk 1// XftFontImp.cc Xft font implementation for FbTk
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org) 2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3// 3//
4// Permission is hereby granted, free of charge, to any person obtaining a 4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"), 5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation 6// to deal in the Software without restriction, including without limitation
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22//$Id: XftFontImp.cc,v 1.4 2004/08/29 08:33:13 rathnor Exp $ 22//$Id: XftFontImp.cc,v 1.5 2004/09/10 16:12:49 akir Exp $
23 23
24#include "XftFontImp.hh" 24#include "XftFontImp.hh"
25#include "App.hh" 25#include "App.hh"
@@ -43,10 +43,10 @@ XftFontImp::~XftFontImp() {
43 43
44bool XftFontImp::load(const std::string &name) { 44bool XftFontImp::load(const std::string &name) {
45 //Note: assumes screen 0 for now, changes on draw if needed 45 //Note: assumes screen 0 for now, changes on draw if needed
46 46
47 Display *disp = App::instance()->display(); 47 Display *disp = App::instance()->display();
48 XftFont *newxftfont = XftFontOpenName(disp, 0, name.c_str()); 48 XftFont *newxftfont = XftFontOpenName(disp, 0, name.c_str());
49 49
50 if (newxftfont == 0) { // failed to open font, lets test with XLFD 50 if (newxftfont == 0) { // failed to open font, lets test with XLFD
51 newxftfont = XftFontOpenXlfd(disp, 0, name.c_str()); 51 newxftfont = XftFontOpenXlfd(disp, 0, name.c_str());
52 if (newxftfont == 0) 52 if (newxftfont == 0)
@@ -87,7 +87,7 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
87 rendcol.green = xcol.green; 87 rendcol.green = xcol.green;
88 rendcol.blue = xcol.blue; 88 rendcol.blue = xcol.blue;
89 rendcol.alpha = 0xFFFF; 89 rendcol.alpha = 0xFFFF;
90 XftColor xftcolor; 90 XftColor xftcolor;
91 XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen), 91 XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen),
92 &rendcol, &xftcolor); 92 &rendcol, &xftcolor);
93 93
@@ -107,14 +107,14 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
107 m_xftfont, 107 m_xftfont,
108 x, y, 108 x, y,
109 (XftChar8 *)(text), len); 109 (XftChar8 *)(text), len);
110 XftColorFree(disp, DefaultVisual(disp, screen), 110 XftColorFree(disp, DefaultVisual(disp, screen),
111 DefaultColormap(disp, screen), &xftcolor); 111 DefaultColormap(disp, screen), &xftcolor);
112 XftDrawDestroy(draw); 112 XftDrawDestroy(draw);
113 return; 113 return;
114 } 114 }
115 } 115 }
116#endif // HAVE_XFT_UTF8_STRING 116#endif // HAVE_XFT_UTF8_STRING
117 117
118 XftDrawString8(draw, 118 XftDrawString8(draw,
119 &xftcolor, 119 &xftcolor,
120 m_xftfont, 120 m_xftfont,
@@ -122,7 +122,7 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
122 (XftChar8 *)(text), len); 122 (XftChar8 *)(text), len);
123 123
124 124
125 XftColorFree(disp, DefaultVisual(disp, screen), 125 XftColorFree(disp, DefaultVisual(disp, screen),
126 DefaultColormap(disp, screen), &xftcolor); 126 DefaultColormap(disp, screen), &xftcolor);
127 XftDrawDestroy(draw); 127 XftDrawDestroy(draw);
128} 128}
@@ -132,10 +132,11 @@ unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) co
132 return 0; 132 return 0;
133 133
134 XGlyphInfo ginfo; 134 XGlyphInfo ginfo;
135 Display* disp = App::instance()->display();
135 136
136#ifdef HAVE_XFT_UTF8_STRING 137#ifdef HAVE_XFT_UTF8_STRING
137 if (m_utf8mode) { 138 if (m_utf8mode) {
138 XftTextExtentsUtf8(App::instance()->display(), 139 XftTextExtentsUtf8(disp,
139 m_xftfont, 140 m_xftfont,
140 (XftChar8 *)text, len, 141 (XftChar8 *)text, len,
141 &ginfo); 142 &ginfo);
@@ -146,7 +147,7 @@ unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) co
146 } 147 }
147#endif //HAVE_XFT_UTF8_STRING 148#endif //HAVE_XFT_UTF8_STRING
148 149
149 XftTextExtents8(App::instance()->display(), 150 XftTextExtents8(disp,
150 m_xftfont, 151 m_xftfont,
151 (XftChar8 *)text, len, 152 (XftChar8 *)text, len,
152 &ginfo); 153 &ginfo);
@@ -157,7 +158,7 @@ unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) co
157unsigned int XftFontImp::height() const { 158unsigned int XftFontImp::height() const {
158 if (m_xftfont == 0) 159 if (m_xftfont == 0)
159 return 0; 160 return 0;
160 return m_xftfont->height; 161 return m_xftfont->height;
161 //m_xftfont->ascent + m_xftfont->descent; 162 //m_xftfont->ascent + m_xftfont->descent;
162 // curiously, fonts seem to have a smaller height, but the "height" 163 // curiously, fonts seem to have a smaller height, but the "height"
163 // is specified within the actual font, so it must be right, right? 164 // is specified within the actual font, so it must be right, right?