aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorakir <akir>2004-09-10 16:48:15 (GMT)
committerakir <akir>2004-09-10 16:48:15 (GMT)
commitc8f9cf1177b6de1cc210f0706dae302b9aa4f7b5 (patch)
treeee799ee3af64cfd439abccb6b10371be1a232498 /src
parentdf0c942aa2576a8edaae5a13ace01643729035ea (diff)
downloadfluxbox-c8f9cf1177b6de1cc210f0706dae302b9aa4f7b5.zip
fluxbox-c8f9cf1177b6de1cc210f0706dae302b9aa4f7b5.tar.bz2
cosmetic + avoid unneeded App::instance()->display() calls
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/MenuItem.cc61
-rw-r--r--src/FbTk/Transparent.cc46
2 files changed, 47 insertions, 60 deletions
diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc
index ee997bb..69a2000 100644
--- a/src/FbTk/MenuItem.cc
+++ b/src/FbTk/MenuItem.cc
@@ -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: MenuItem.cc,v 1.8 2004/09/01 08:00:24 akir Exp $ 22// $Id: MenuItem.cc,v 1.9 2004/09/10 16:48:15 akir Exp $
23 23
24#include "MenuItem.hh" 24#include "MenuItem.hh"
25#include "Command.hh" 25#include "Command.hh"
@@ -37,11 +37,13 @@ void MenuItem::click(int button, int time) {
37 m_command->execute(); 37 m_command->execute();
38} 38}
39 39
40void MenuItem::draw(FbDrawable &draw, 40void MenuItem::draw(FbDrawable &draw,
41 const MenuTheme &theme, 41 const MenuTheme &theme,
42 bool highlight, 42 bool highlight,
43 int x, int y, 43 int x, int y,
44 unsigned int width, unsigned int height) const { 44 unsigned int width, unsigned int height) const {
45
46 Display *disp = App::instance()->display();
45 // 47 //
46 // Icon 48 // Icon
47 // 49 //
@@ -58,11 +60,8 @@ void MenuItem::draw(FbDrawable &draw,
58 int icon_x = x + theme.bevelWidth(); 60 int icon_x = x + theme.bevelWidth();
59 int icon_y = y + theme.bevelWidth(); 61 int icon_y = y + theme.bevelWidth();
60 // enable clip mask 62 // enable clip mask
61 XSetClipMask(FbTk::App::instance()->display(), 63 XSetClipMask(disp, gc, m_icon->pixmap->mask().drawable());
62 gc, 64 XSetClipOrigin(disp, gc, icon_x, icon_y);
63 m_icon->pixmap->mask().drawable());
64 XSetClipOrigin(FbTk::App::instance()->display(),
65 gc, icon_x, icon_y);
66 65
67 draw.copyArea(m_icon->pixmap->pixmap().drawable(), 66 draw.copyArea(m_icon->pixmap->pixmap().drawable(),
68 gc, 67 gc,
@@ -71,9 +70,7 @@ void MenuItem::draw(FbDrawable &draw,
71 m_icon->pixmap->width(), m_icon->pixmap->height()); 70 m_icon->pixmap->width(), m_icon->pixmap->height());
72 71
73 // restore clip mask 72 // restore clip mask
74 XSetClipMask(FbTk::App::instance()->display(), 73 XSetClipMask(disp, gc, None);
75 gc,
76 None);
77 } 74 }
78 75
79 } 76 }
@@ -90,7 +87,7 @@ void MenuItem::draw(FbDrawable &draw,
90 int text_y = y, text_x = x; 87 int text_y = y, text_x = x;
91 88
92 int text_w = theme.frameFont().textWidth(label().c_str(), label().size()); 89 int text_w = theme.frameFont().textWidth(label().c_str(), label().size());
93 90
94 int height_offset = theme.itemHeight() - (theme.frameFont().height() + 2*theme.bevelWidth()); 91 int height_offset = theme.itemHeight() - (theme.frameFont().height() + 2*theme.bevelWidth());
95 text_y = y + theme.bevelWidth() + theme.frameFont().ascent() + height_offset/2; ///2 + height/2; 92 text_y = y + theme.bevelWidth() + theme.frameFont().ascent() + height_offset/2; ///2 + height/2;
96 93
@@ -98,15 +95,15 @@ void MenuItem::draw(FbDrawable &draw,
98 case FbTk::LEFT: 95 case FbTk::LEFT:
99 text_x = x + theme.bevelWidth() + height + 1; 96 text_x = x + theme.bevelWidth() + height + 1;
100 break; 97 break;
101 98
102 case FbTk::RIGHT: 99 case FbTk::RIGHT:
103 text_x = x + width - (height + theme.bevelWidth() + text_w); 100 text_x = x + width - (height + theme.bevelWidth() + text_w);
104 break; 101 break;
105 default: //center 102 default: //center
106 text_x = x + ((width + 1 - text_w) / 2); 103 text_x = x + ((width + 1 - text_w) / 2);
107 break; 104 break;
108 } 105 }
109 106
110 theme.frameFont().drawText(draw.drawable(), // drawable 107 theme.frameFont().drawText(draw.drawable(), // drawable
111 theme.screenNum(), 108 theme.screenNum(),
112 tgc.gc(), 109 tgc.gc(),
@@ -127,11 +124,8 @@ void MenuItem::draw(FbDrawable &draw,
127 // ToggleItem 124 // ToggleItem
128 // 125 //
129 if (isToggleItem() && theme.unselectedPixmap().pixmap().drawable() != 0) { 126 if (isToggleItem() && theme.unselectedPixmap().pixmap().drawable() != 0) {
130 XSetClipMask(FbTk::App::instance()->display(), 127 XSetClipMask(disp, gc, theme.unselectedPixmap().mask().drawable());
131 gc, 128 XSetClipOrigin(disp, gc, sel_x, y);
132 theme.unselectedPixmap().mask().drawable());
133 XSetClipOrigin(FbTk::App::instance()->display(),
134 gc, sel_x, y);
135 // copy bullet pixmap to drawable 129 // copy bullet pixmap to drawable
136 draw.copyArea(theme.unselectedPixmap().pixmap().drawable(), 130 draw.copyArea(theme.unselectedPixmap().pixmap().drawable(),
137 gc, 131 gc,
@@ -140,22 +134,17 @@ void MenuItem::draw(FbDrawable &draw,
140 theme.unselectedPixmap().width(), 134 theme.unselectedPixmap().width(),
141 theme.unselectedPixmap().height()); 135 theme.unselectedPixmap().height());
142 // disable clip mask 136 // disable clip mask
143 XSetClipMask(FbTk::App::instance()->display(), 137 XSetClipMask(disp, gc, None);
144 gc,
145 None);
146 } 138 }
147 139
148 // 140 //
149 // Submenu 141 // Submenu
150 // 142 //
151 if (submenu()) { 143 if (submenu()) {
152 if (theme.bulletPixmap().pixmap().drawable() != 0) { 144 if (theme.bulletPixmap().pixmap().drawable() != 0) {
153 // enable clip mask 145 // enable clip mask
154 XSetClipMask(FbTk::App::instance()->display(), 146 XSetClipMask(disp, gc, theme.bulletPixmap().mask().drawable());
155 gc, 147 XSetClipOrigin(disp, gc, sel_x, y);
156 theme.bulletPixmap().mask().drawable());
157 XSetClipOrigin(FbTk::App::instance()->display(),
158 gc, sel_x, y);
159 // copy bullet pixmap to frame 148 // copy bullet pixmap to frame
160 draw.copyArea(theme.bulletPixmap().pixmap().drawable(), 149 draw.copyArea(theme.bulletPixmap().pixmap().drawable(),
161 gc, 150 gc,
@@ -164,9 +153,7 @@ void MenuItem::draw(FbDrawable &draw,
164 theme.bulletPixmap().width(), 153 theme.bulletPixmap().width(),
165 theme.bulletPixmap().height()); 154 theme.bulletPixmap().height());
166 // disable clip mask 155 // disable clip mask
167 XSetClipMask(FbTk::App::instance()->display(), 156 XSetClipMask(disp, gc, None);
168 gc,
169 None);
170 } else { 157 } else {
171 unsigned int half_w = height / 2, quarter_w = height / 4; 158 unsigned int half_w = height / 2, quarter_w = height / 4;
172 int sel_y = y + height/4; 159 int sel_y = y + height/4;
@@ -193,11 +180,11 @@ void MenuItem::draw(FbDrawable &draw,
193 tri[2].x = 0; 180 tri[2].x = 0;
194 tri[2].y = -4; 181 tri[2].y = -4;
195 } 182 }
196 183
197 draw.fillPolygon(gc, tri, 3, Convex, 184 draw.fillPolygon(gc, tri, 3, Convex,
198 CoordModePrevious); 185 CoordModePrevious);
199 break; 186 break;
200 187
201 case MenuTheme::DIAMOND: 188 case MenuTheme::DIAMOND:
202 XPoint dia[4]; 189 XPoint dia[4];
203 190
@@ -233,7 +220,7 @@ void MenuItem::setIcon(const std::string &filename, int screen_num) {
233 m_icon.reset(new Icon); 220 m_icon.reset(new Icon);
234 221
235 m_icon->filename = FbTk::StringUtil::expandFilename(filename); 222 m_icon->filename = FbTk::StringUtil::expandFilename(filename);
236 m_icon->pixmap.reset(Image::load(m_icon->filename.c_str(), 223 m_icon->pixmap.reset(Image::load(m_icon->filename.c_str(),
237 screen_num)); 224 screen_num));
238} 225}
239 226
@@ -245,8 +232,8 @@ unsigned int MenuItem::width(const MenuTheme &theme) const {
245 // textwidth + bevel width on each side of the text 232 // textwidth + bevel width on each side of the text
246 const unsigned int icon_width = height(theme); 233 const unsigned int icon_width = height(theme);
247 const unsigned int normal = theme.frameFont().textWidth(label().c_str(), label().size()) + 234 const unsigned int normal = theme.frameFont().textWidth(label().c_str(), label().size()) +
248 2 * (theme.bevelWidth() + icon_width); 235 2 * (theme.bevelWidth() + icon_width);
249 236
250 return m_icon.get() == 0 ? normal : normal + icon_width; 237 return m_icon.get() == 0 ? normal : normal + icon_width;
251} 238}
252 239
diff --git a/src/FbTk/Transparent.cc b/src/FbTk/Transparent.cc
index ab6b4d9..9cc377e 100644
--- a/src/FbTk/Transparent.cc
+++ b/src/FbTk/Transparent.cc
@@ -1,6 +1,6 @@
1// Transparent.cc for FbTk - Fluxbox Toolkit 1// Transparent.cc for FbTk - Fluxbox Toolkit
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen(at)users.sourceforge.net) 2// Copyright (c) 2003 Henrik Kinnunen (fluxgen(at)users.sourceforge.net)
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: Transparent.cc,v 1.6 2004/06/07 11:46:05 rathnor Exp $ 22// $Id: Transparent.cc,v 1.7 2004/09/10 16:48:15 akir Exp $
23 23
24#include "Transparent.hh" 24#include "Transparent.hh"
25#include "App.hh" 25#include "App.hh"
@@ -47,7 +47,7 @@ Picture createAlphaPic(Window drawable, unsigned char alpha) {
47 XRenderPictFormat pic_format; 47 XRenderPictFormat pic_format;
48 pic_format.type = PictTypeDirect; 48 pic_format.type = PictTypeDirect;
49 pic_format.depth = 8; // alpha with bit depth 8 49 pic_format.depth = 8; // alpha with bit depth 8
50 pic_format.direct.alphaMask = 0xff; 50 pic_format.direct.alphaMask = 0xff;
51 XRenderPictFormat *format = XRenderFindFormat(disp, PictFormatType | 51 XRenderPictFormat *format = XRenderFindFormat(disp, PictFormatType |
52 PictFormatDepth | PictFormatAlphaMask, 52 PictFormatDepth | PictFormatAlphaMask,
53 &pic_format, 0); 53 &pic_format, 0);
@@ -109,8 +109,8 @@ Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int s
109 // check for RENDER support 109 // check for RENDER support
110 if (!s_init) { 110 if (!s_init) {
111 int major_opcode, first_event, first_error; 111 int major_opcode, first_event, first_error;
112 if (XQueryExtension(disp, "RENDER", 112 if (XQueryExtension(disp, "RENDER",
113 &major_opcode, 113 &major_opcode,
114 &first_event, &first_error) == False) { 114 &first_event, &first_error) == False) {
115 s_render = false; 115 s_render = false;
116 } else { // we got RENDER support 116 } else { // we got RENDER support
@@ -119,7 +119,7 @@ Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int s
119 s_init = true; 119 s_init = true;
120 } 120 }
121 121
122 122
123#ifdef HAVE_XRENDER 123#ifdef HAVE_XRENDER
124 if (!s_render) 124 if (!s_render)
125 return; 125 return;
@@ -127,13 +127,13 @@ Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int s
127 allocAlpha(m_alpha); 127 allocAlpha(m_alpha);
128 128
129 129
130 XRenderPictFormat *format = 130 XRenderPictFormat *format =
131 XRenderFindVisualFormat(disp, 131 XRenderFindVisualFormat(disp,
132 DefaultVisual(disp, screen_num)); 132 DefaultVisual(disp, screen_num));
133 133
134 134
135 if (src != 0 && format != 0) { 135 if (src != 0 && format != 0) {
136 m_src_pic = XRenderCreatePicture(disp, src, format, 136 m_src_pic = XRenderCreatePicture(disp, src, format,
137 0, 0); 137 0, 0);
138 } 138 }
139 139
@@ -181,8 +181,8 @@ void Transparent::setDest(Drawable dest, int screen_num) {
181 // create new dest pic if we have a valid dest drawable 181 // create new dest pic if we have a valid dest drawable
182 if (dest != 0) { 182 if (dest != 0) {
183 183
184 XRenderPictFormat *format = 184 XRenderPictFormat *format =
185 XRenderFindVisualFormat(disp, 185 XRenderFindVisualFormat(disp,
186 DefaultVisual(disp, screen_num)); 186 DefaultVisual(disp, screen_num));
187 if (format == 0) { 187 if (format == 0) {
188 _FB_USES_NLS; 188 _FB_USES_NLS;
@@ -191,7 +191,7 @@ void Transparent::setDest(Drawable dest, int screen_num) {
191 cerr<<endl; 191 cerr<<endl;
192 } 192 }
193 m_dest_pic = XRenderCreatePicture(disp, dest, format, 0, 0); 193 m_dest_pic = XRenderCreatePicture(disp, dest, format, 0, 0);
194 194
195 195
196 } 196 }
197 m_dest = dest; 197 m_dest = dest;
@@ -208,7 +208,7 @@ void Transparent::setSource(Drawable source, int screen_num) {
208 if (m_alpha_pic != 0) 208 if (m_alpha_pic != 0)
209 freeAlpha(); 209 freeAlpha();
210 210
211 Display *disp = FbTk::App::instance()->display(); 211 Display *disp = FbTk::App::instance()->display();
212 212
213 if (m_src_pic != 0) { 213 if (m_src_pic != 0) {
214 XRenderFreePicture(disp, m_src_pic); 214 XRenderFreePicture(disp, m_src_pic);
@@ -220,8 +220,8 @@ void Transparent::setSource(Drawable source, int screen_num) {
220 // create new source pic if we have a valid source drawable 220 // create new source pic if we have a valid source drawable
221 if (m_source != 0) { 221 if (m_source != 0) {
222 222
223 XRenderPictFormat *format = 223 XRenderPictFormat *format =
224 XRenderFindVisualFormat(disp, 224 XRenderFindVisualFormat(disp,
225 DefaultVisual(disp, screen_num)); 225 DefaultVisual(disp, screen_num));
226 if (format == 0) { 226 if (format == 0) {
227 _FB_USES_NLS; 227 _FB_USES_NLS;
@@ -229,8 +229,8 @@ void Transparent::setSource(Drawable source, int screen_num) {
229 fprintf(stderr, _FBTKTEXT(Error, NoRenderVisualFormat, "Failed to find format for screen(%d)", "XRenderFindVisualFormat failed... include %d for screen number"), screen_num); 229 fprintf(stderr, _FBTKTEXT(Error, NoRenderVisualFormat, "Failed to find format for screen(%d)", "XRenderFindVisualFormat failed... include %d for screen number"), screen_num);
230 cerr<<endl; 230 cerr<<endl;
231 } 231 }
232 m_src_pic = XRenderCreatePicture(disp, m_source, format, 232 m_src_pic = XRenderCreatePicture(disp, m_source, format,
233 0, 0); 233 0, 0);
234 } 234 }
235 235
236 // recreate new alpha 236 // recreate new alpha
@@ -247,13 +247,13 @@ void Transparent::render(int src_x, int src_y,
247 m_alpha_pic == 0 || !s_render) 247 m_alpha_pic == 0 || !s_render)
248 return; 248 return;
249 // render src+alpha to dest picture 249 // render src+alpha to dest picture
250 XRenderComposite(FbTk::App::instance()->display(), 250 XRenderComposite(FbTk::App::instance()->display(),
251 PictOpOver, 251 PictOpOver,
252 m_src_pic, 252 m_src_pic,
253 m_alpha_pic, 253 m_alpha_pic,
254 m_dest_pic, 254 m_dest_pic,
255 src_x, src_y, 255 src_x, src_y,
256 0, 0, 256 0, 0,
257 dest_x, dest_y, 257 dest_x, dest_y,
258 width, height); 258 width, height);
259 259
@@ -284,4 +284,4 @@ void Transparent::freeAlpha() {
284}; // end namespace FbTk 284}; // end namespace FbTk
285 285
286 286
287 287