aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/FbWindow.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2005-04-26 01:41:55 (GMT)
committersimonb <simonb>2005-04-26 01:41:55 (GMT)
commit1c2f92a3d2288b1cae9500110a72173506a18072 (patch)
treecdb695da16dcee74872790c772bb535def9f2895 /src/FbTk/FbWindow.cc
parentb49432be05c6cf748e662e196778463e2190b4c3 (diff)
downloadfluxbox-1c2f92a3d2288b1cae9500110a72173506a18072.zip
fluxbox-1c2f92a3d2288b1cae9500110a72173506a18072.tar.bz2
extension of previous big patch. Move a bunch of menu things onto
background pixmap. Same for textbuttons.
Diffstat (limited to 'src/FbTk/FbWindow.cc')
-rw-r--r--src/FbTk/FbWindow.cc52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc
index 1b4f77f..acdc7c1 100644
--- a/src/FbTk/FbWindow.cc
+++ b/src/FbTk/FbWindow.cc
@@ -46,7 +46,7 @@ namespace FbTk {
46 46
47FbWindow::FbWindow():FbDrawable(), m_parent(0), m_screen_num(0), m_window(0), m_x(0), m_y(0), 47FbWindow::FbWindow():FbDrawable(), m_parent(0), m_screen_num(0), m_window(0), m_x(0), m_y(0),
48 m_width(0), m_height(0), m_border_width(0), m_depth(0), m_destroy(true), 48 m_width(0), m_height(0), m_border_width(0), m_depth(0), m_destroy(true),
49 m_lastbg_pm(0){ 49 m_lastbg_pm(0), m_renderer(0) {
50 50
51} 51}
52 52
@@ -57,7 +57,7 @@ FbWindow::FbWindow(const FbWindow& the_copy):FbDrawable(),
57 m_width(the_copy.width()), m_height(the_copy.height()), 57 m_width(the_copy.width()), m_height(the_copy.height()),
58 m_border_width(the_copy.borderWidth()), 58 m_border_width(the_copy.borderWidth()),
59 m_depth(the_copy.depth()), m_destroy(true), 59 m_depth(the_copy.depth()), m_destroy(true),
60 m_lastbg_pm(0) { 60 m_lastbg_pm(0), m_renderer(the_copy.m_renderer) {
61 the_copy.m_window = 0; 61 the_copy.m_window = 0;
62} 62}
63 63
@@ -75,7 +75,7 @@ FbWindow::FbWindow(int screen_num,
75 m_destroy(true), 75 m_destroy(true),
76 m_lastbg_color_set(false), 76 m_lastbg_color_set(false),
77 m_lastbg_color(0), 77 m_lastbg_color(0),
78 m_lastbg_pm(0) { 78 m_lastbg_pm(0), m_renderer(0) {
79 79
80 create(RootWindow(display(), screen_num), 80 create(RootWindow(display(), screen_num),
81 x, y, width, height, eventmask, 81 x, y, width, height, eventmask,
@@ -93,7 +93,7 @@ FbWindow::FbWindow(const FbWindow &parent,
93 m_destroy(true), 93 m_destroy(true),
94 m_lastbg_color_set(false), 94 m_lastbg_color_set(false),
95 m_lastbg_color(0x42), 95 m_lastbg_color(0x42),
96 m_lastbg_pm(0) { 96 m_lastbg_pm(0), m_renderer(0) {
97 97
98 create(parent.window(), x, y, width, height, eventmask, 98 create(parent.window(), x, y, width, height, eventmask,
99 override_redirect, save_unders, depth, class_type); 99 override_redirect, save_unders, depth, class_type);
@@ -109,7 +109,7 @@ FbWindow::FbWindow(Window client):FbDrawable(), m_parent(0),
109 m_border_width(0), 109 m_border_width(0),
110 m_depth(0), 110 m_depth(0),
111 m_destroy(false), // don't destroy this window 111 m_destroy(false), // don't destroy this window
112 m_lastbg_pm(0) { 112 m_lastbg_pm(0), m_renderer(0) {
113 113
114 setNew(client); 114 setNew(client);
115} 115}
@@ -166,22 +166,19 @@ void FbWindow::updateBackground(bool only_if_alpha) {
166 if (m_transparent->source() != root) 166 if (m_transparent->source() != root)
167 m_transparent->setSource(root, screenNumber()); 167 m_transparent->setSource(root, screenNumber());
168 168
169 newbg = XCreatePixmap(display(), window(), width(), height(), depth()); 169 FbPixmap newpm = FbPixmap(*this, width(), height(), depth());
170 free_newbg = true; 170 free_newbg = true; // newpm gets released to newbg at end of block
171 GC gc = XCreateGC(display(), window(), 0, 0); 171 GC gc = XCreateGC(display(), window(), 0, 0);
172 172
173 if (m_lastbg_pm == None && m_lastbg_color_set) { 173 if (m_lastbg_pm == None && m_lastbg_color_set) {
174 XSetForeground(display(), gc, m_lastbg_color); 174 XSetForeground(display(), gc, m_lastbg_color);
175 XFillRectangle(display(), newbg, gc, 0, 0, width(), height()); 175 newpm.fillRectangle(gc, 0, 0, width(), height());
176 } else { 176 } else {
177 // copy from window if no color and no bg... 177 // copy from window if no color and no bg...
178 XCopyArea(display(), (m_lastbg_pm == None)?drawable():m_lastbg_pm, newbg, gc, 178 newpm.copyArea((m_lastbg_pm == None)?drawable():m_lastbg_pm, gc, 0, 0, 0, 0, width(), height());
179 0, 0,
180 width(), height(),
181 0, 0);
182 } 179 }
183 XFreeGC(display(), gc); 180 XFreeGC(display(), gc);
184 m_transparent->setDest(newbg, screenNumber()); 181 m_transparent->setDest(newpm.drawable(), screenNumber());
185 182
186 // get root position 183 // get root position
187 184
@@ -202,7 +199,13 @@ void FbWindow::updateBackground(bool only_if_alpha) {
202 m_transparent->render(root_x, root_y, 199 m_transparent->render(root_x, root_y,
203 0, 0, 200 0, 0,
204 width(), height()); 201 width(), height());
202
203 // render any foreground items
204 if (m_renderer)
205 m_renderer->renderForeground(*this, newpm);
206
205 m_transparent->freeDest(); // it's only temporary, don't leave it hanging around 207 m_transparent->freeDest(); // it's only temporary, don't leave it hanging around
208 newbg = newpm.release();
206 } 209 }
207 210
208 if (newbg != None) 211 if (newbg != None)
@@ -238,10 +241,14 @@ void FbWindow::clear() {
238void FbWindow::clearArea(int x, int y, 241void FbWindow::clearArea(int x, int y,
239 unsigned int width, unsigned int height, 242 unsigned int width, unsigned int height,
240 bool exposures) { 243 bool exposures) {
244 // TODO: probably could call renderForeground here (with x,y,w,h)
241 XClearArea(display(), window(), x, y, width, height, exposures); 245 XClearArea(display(), window(), x, y, width, height, exposures);
242} 246}
243 247
244void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, unsigned int the_height) { 248// If override_is_offset, then dest_override is a pixmap located at the_x, the_y
249// with size the_width x the_height in the target window.
250
251void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, unsigned int the_height, Pixmap dest_override, bool override_is_offset) {
245#ifdef HAVE_XRENDER 252#ifdef HAVE_XRENDER
246 if (!m_transparent.get()) 253 if (!m_transparent.get())
247 return; 254 return;
@@ -249,13 +256,16 @@ void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, u
249 if (width() == 0 || height() == 0) 256 if (width() == 0 || height() == 0)
250 return; 257 return;
251 258
252 if ((the_width == 0 && the_height == 0 || the_width == width() && the_height == height()) && 259 if (!dest_override && (the_width == 0 && the_height == 0 || the_width == width() && the_height == height()) &&
253 the_x <= 0 && the_y <= 0) { 260 the_x <= 0 && the_y <= 0) {
254 // do the whole thing 261 // do the whole thing
255 updateBackground(true); 262 updateBackground(true);
256 return; 263 return;
257 } 264 }
258 265
266 if (!dest_override)
267 dest_override = window();
268
259 if (the_width == 0 || the_height == 0) { 269 if (the_width == 0 || the_height == 0) {
260 the_width = width(); 270 the_width = width();
261 the_height = height(); 271 the_height = height();
@@ -271,8 +281,8 @@ void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, u
271 if (m_transparent->source() != root) 281 if (m_transparent->source() != root)
272 m_transparent->setSource(root, screenNumber()); 282 m_transparent->setSource(root, screenNumber());
273 283
274 if (m_transparent->dest() != window()) 284 if (m_transparent->dest() != dest_override)
275 m_transparent->setDest(window(), screenNumber()); 285 m_transparent->setDest(dest_override, screenNumber());
276 286
277 // get root position 287 // get root position
278 288
@@ -292,7 +302,7 @@ void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, u
292 302
293 // render background image from root pos to our window 303 // render background image from root pos to our window
294 m_transparent->render(root_x + the_x, root_y + the_y, 304 m_transparent->render(root_x + the_x, root_y + the_y,
295 the_x, the_y, 305 override_is_offset?0:the_x, override_is_offset?0:the_y,
296 the_width, the_height); 306 the_width, the_height);
297#endif // HAVE_XRENDER 307#endif // HAVE_XRENDER
298} 308}
@@ -497,12 +507,6 @@ void FbWindow::setOpaque(unsigned char alpha) {
497#endif // HAVE_XRENDER 507#endif // HAVE_XRENDER
498} 508}
499 509
500/*
501void FbWindow::setBufferPixmap(Pixmap pm) {
502 m_lastbg_pm = pm;
503}
504*/
505
506void FbWindow::updateGeometry() { 510void FbWindow::updateGeometry() {
507 if (m_window == 0) 511 if (m_window == 0)
508 return; 512 return;