aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/FbWinFrame.cc88
-rw-r--r--src/Window.cc60
3 files changed, 92 insertions, 58 deletions
diff --git a/ChangeLog b/ChangeLog
index 4c04175..689c952 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
1(Format: Year/Month/Day) 1(Format: Year/Month/Day)
2Changes for 0.1.15: 2Changes for 0.1.15:
3*03/02/22: 3*03/02/22:
4 * Fix frame size and window moving/resizing/outline bugs (Simon)
5 Window.cc FbWinFrame.cc
4 * s/""/'' so the shell does not have to expand the contents of the string 6 * s/""/'' so the shell does not have to expand the contents of the string
5 in fluxbox_generatemenu (Han) 7 in fluxbox_generatemenu (Han)
6 * Added portability notes in fluxbox_generatemenu (Han) 8 * Added portability notes in fluxbox_generatemenu (Han)
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 05c6f00..1444438 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.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: FbWinFrame.cc,v 1.12 2003/02/23 00:57:55 fluxgen Exp $ 22// $Id: FbWinFrame.cc,v 1.13 2003/02/23 13:40:22 rathnor Exp $
23 23
24#include "FbWinFrame.hh" 24#include "FbWinFrame.hh"
25#include "ImageControl.hh" 25#include "ImageControl.hh"
@@ -170,16 +170,16 @@ void FbWinFrame::resize(unsigned int width, unsigned int height) {
170} 170}
171 171
172void FbWinFrame::resizeForClient(unsigned int width, unsigned int height) { 172void FbWinFrame::resizeForClient(unsigned int width, unsigned int height) {
173 // total height for frame without client 173 // total height for frame
174 int handle_height = m_handle.height() + m_handle.borderWidth(); 174 unsigned int total_height = height;
175 int titlebar_height = m_titlebar.height() + m_titlebar.borderWidth(); 175
176 unsigned int total_height = handle_height + titlebar_height; 176 // having a titlebar = 1 extra border + titlebar height
177 // resize frame height with total height + specified height 177 if (m_use_titlebar)
178 if (!m_use_titlebar) 178 total_height += m_titlebar.height() + m_titlebar.borderWidth();
179 total_height -= titlebar_height; 179 // having a handle = 1 extra border + handle height
180 if (!m_use_handle) 180 if (m_use_handle)
181 total_height -= handle_height; 181 total_height += m_handle.height() + m_handle.borderWidth();
182 resize(width, total_height + height); 182 resize(width, total_height);
183} 183}
184 184
185void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int height) { 185void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int height) {
@@ -280,8 +280,10 @@ void FbWinFrame::hideTitlebar() {
280 m_titlebar.hide(); 280 m_titlebar.hide();
281 m_use_titlebar = false; 281 m_use_titlebar = false;
282 m_clientarea.raise(); 282 m_clientarea.raise();
283
284 // only take away one borderwidth (as the other border is still the "top" border)
283 m_window.resize(m_window.width(), m_window.height() - m_titlebar.height() - 285 m_window.resize(m_window.width(), m_window.height() - m_titlebar.height() -
284 m_titlebar.borderWidth()*2); 286 m_titlebar.borderWidth());
285#ifdef DEBUG 287#ifdef DEBUG
286 cerr<<__FILE__<<": Hide Titlebar"<<endl; 288 cerr<<__FILE__<<": Hide Titlebar"<<endl;
287#endif // DEBUG 289#endif // DEBUG
@@ -293,30 +295,43 @@ void FbWinFrame::showTitlebar() {
293 295
294 m_titlebar.show(); 296 m_titlebar.show();
295 m_use_titlebar = true; 297 m_use_titlebar = true;
298
299 // only add one borderwidth (as the other border is still the "top" border)
300 m_window.resize(m_window.width(), m_window.height() + m_titlebar.height() +
301 m_titlebar.borderWidth());
302
296#ifdef DEBUG 303#ifdef DEBUG
297 cerr<<__FILE__<<": Show Titlebar"<<endl; 304 cerr<<__FILE__<<": Show Titlebar"<<endl;
298#endif // DEBUG 305#endif // DEBUG
299} 306}
300 307
301void FbWinFrame::hideHandle() { 308void FbWinFrame::hideHandle() {
309 if (!m_use_handle)
310 return;
302 m_handle.hide(); 311 m_handle.hide();
303 m_grip_left.hide(); 312 m_grip_left.hide();
304 m_grip_right.hide(); 313 m_grip_right.hide();
305 m_use_handle = false; 314 m_use_handle = false;
315 m_window.resize(m_window.width(), m_window.height() - m_handle.height() -
316 m_handle.borderWidth());
317
306} 318}
307 319
308void FbWinFrame::showHandle() { 320void FbWinFrame::showHandle() {
321 if (m_use_handle)
322 return;
309 m_handle.show(); 323 m_handle.show();
310 m_grip_left.show(); 324 m_grip_left.show();
311 m_grip_right.show(); 325 m_grip_right.show();
312 m_use_handle = true; 326 m_use_handle = true;
327 m_window.resize(m_window.width(), m_window.height() + m_handle.height() +
328 m_handle.borderWidth());
313} 329}
314 330
315void FbWinFrame::hideAllDecorations() { 331void FbWinFrame::hideAllDecorations() {
316 hideHandle(); 332 hideHandle();
317 hideTitlebar(); 333 hideTitlebar();
318 m_window.setBorderWidth(0); 334 // resize done by hide*
319 m_window.resize(m_clientarea.width(), m_clientarea.height());
320 reconfigure(); 335 reconfigure();
321} 336}
322 337
@@ -325,7 +340,7 @@ void FbWinFrame::showAllDecorations() {
325 showHandle(); 340 showHandle();
326 if (!m_use_titlebar) 341 if (!m_use_titlebar)
327 showTitlebar(); 342 showTitlebar();
328 resizeForClient(m_clientarea.width(), m_clientarea.height()); 343 // resize shouldn't be necessary
329 reconfigure(); 344 reconfigure();
330} 345}
331 346
@@ -395,6 +410,10 @@ void FbWinFrame::exposeEvent(XExposeEvent &event) {
395 redrawTitlebar(); 410 redrawTitlebar();
396 else if (m_label == event.window) 411 else if (m_label == event.window)
397 redrawTitle(); 412 redrawTitle();
413 else if (m_handle == event.window ||
414 m_grip_left == event.window ||
415 m_grip_right == event.window)
416 renderHandles();
398} 417}
399 418
400void FbWinFrame::handleEvent(XEvent &event) { 419void FbWinFrame::handleEvent(XEvent &event) {
@@ -415,28 +434,28 @@ void FbWinFrame::reconfigure() {
415 if (m_use_titlebar) 434 if (m_use_titlebar)
416 reconfigureTitlebar(); 435 reconfigureTitlebar();
417 436
418 // setup client area size/pos 437 int client_top = 0;
419 int next_y = m_titlebar.height() + m_titlebar.borderWidth(); 438 int client_height = m_window.height();
420 unsigned int client_height = 439 if (m_use_titlebar) {
421 m_window.height() - next_y; 440 // only one borderwidth as titlebar is really at -borderwidth
422 /*- m_titlebar.height() - m_titlebar.y() - m_handle.height();*/ 441 int titlebar_height = m_titlebar.height() + m_titlebar.borderWidth();
442 client_top += titlebar_height;
443 client_height -= titlebar_height;
444 }
423 445
424 if (!m_use_titlebar) { 446 if (m_use_handle) {
425 next_y = -m_titlebar.y(); 447 client_height -= m_handle.height() + m_handle.borderWidth();
426 if (!m_use_handle)
427 client_height = m_window.height();
428 else
429 client_height = m_window.height() - m_handle.height();
430 } 448 }
431 449
432 m_clientarea.moveResize(0, m_titlebar.y() + next_y, 450 m_clientarea.moveResize(0, client_top,
433 m_window.width(), client_height); 451 m_window.width(), client_height);
434 452
435 if (m_clientwin != 0) { 453 if (m_clientwin != 0) {
436 XMoveResizeWindow(FbTk::App::instance()->display(), m_clientwin, 454 XMoveResizeWindow(FbTk::App::instance()->display(), m_clientwin,
437 0, 0, 455 0, 0,
438 m_clientarea.width(), m_clientarea.height()); 456 m_clientarea.width(), m_clientarea.height());
439 } 457 }
458
440 459
441 if (!m_use_handle) // no need to do anything more 460 if (!m_use_handle) // no need to do anything more
442 return; 461 return;
@@ -444,19 +463,18 @@ void FbWinFrame::reconfigure() {
444 // align handle and grips 463 // align handle and grips
445 const int grip_height = m_handle.height(); 464 const int grip_height = m_handle.height();
446 const int grip_width = 20; //TODO 465 const int grip_width = 20; //TODO
447
448 const int ypos = m_window.height() - grip_height;
449 466
450 m_grip_left.moveResize(0, ypos, 467 const int ypos = m_window.height() - grip_height - m_handle.borderWidth();
468
469 m_grip_left.moveResize(-m_handle.borderWidth(), ypos,
451 grip_width, grip_height); 470 grip_width, grip_height);
452 471
453 m_handle.moveResize(grip_width, ypos, 472 m_handle.moveResize(grip_width, ypos,
454 m_window.width() - grip_width*2, grip_height); 473 m_window.width() - grip_width*2 - m_handle.borderWidth()*2, grip_height);
455 474
456 m_grip_right.moveResize(m_window.width() - grip_width, ypos, 475 m_grip_right.moveResize(m_window.width() - grip_width - m_handle.borderWidth(), ypos,
457 grip_width, grip_height); 476 grip_width, grip_height);
458 477
459
460 // render the theme 478 // render the theme
461 renderButtons(); 479 renderButtons();
462 renderHandles(); 480 renderHandles();
diff --git a/src/Window.cc b/src/Window.cc
index 8871253..f0e3393 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.cc,v 1.125 2003/02/22 21:40:35 fluxgen Exp $ 25// $Id: Window.cc,v 1.126 2003/02/23 13:40:22 rathnor Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -349,6 +349,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num,
349 } 349 }
350 350
351 setState(current_state); 351 setState(current_state);
352 m_frame.resizeForClient(wattrib.width, wattrib.height);
352 353
353 // no focus default 354 // no focus default
354 setFocusFlag(false); 355 setFocusFlag(false);
@@ -497,21 +498,22 @@ void FluxboxWindow::reconfigure() {
497void FluxboxWindow::positionWindows() { 498void FluxboxWindow::positionWindows() {
498 499
499 m_frame.window().setBorderWidth(screen->getBorderWidth()); 500 m_frame.window().setBorderWidth(screen->getBorderWidth());
500 m_frame.clientArea().setBorderWidth(screen->getFrameWidth()); 501 m_frame.clientArea().setBorderWidth(0); // client area bordered by other things
501 502
503 m_frame.titlebar().setBorderWidth(screen->getBorderWidth());
502 if (decorations.titlebar) { 504 if (decorations.titlebar) {
503 m_frame.titlebar().setBorderWidth(screen->getBorderWidth());
504 m_frame.showTitlebar(); 505 m_frame.showTitlebar();
505 } else { 506 } else {
506 m_frame.hideTitlebar(); 507 m_frame.hideTitlebar();
507 } 508 }
509
510 m_frame.handle().setBorderWidth(screen->getBorderWidth());
511 m_frame.gripLeft().setBorderWidth(screen->getBorderWidth());
512 m_frame.gripRight().setBorderWidth(screen->getBorderWidth());
508 513
509 if (decorations.handle) { 514 if (decorations.handle)
510 m_frame.handle().setBorderWidth(screen->getBorderWidth());
511 m_frame.gripLeft().setBorderWidth(screen->getBorderWidth());
512 m_frame.gripRight().setBorderWidth(screen->getBorderWidth());
513 m_frame.showHandle(); 515 m_frame.showHandle();
514 } else 516 else
515 m_frame.hideHandle(); 517 m_frame.hideHandle();
516 518
517 m_frame.reconfigure(); 519 m_frame.reconfigure();
@@ -2111,11 +2113,13 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2111 if (! screen->doOpaqueMove()) { 2113 if (! screen->doOpaqueMove()) {
2112 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 2114 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2113 last_move_x, last_move_y, 2115 last_move_x, last_move_y,
2114 m_frame.width(), m_frame.height()); 2116 m_frame.width() + 2*frame().window().borderWidth(),
2117 m_frame.height() + 2*frame().window().borderWidth());
2115 2118
2116 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 2119 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2117 dx, dy, 2120 dx, dy,
2118 m_frame.width(), m_frame.height()); 2121 m_frame.width() + 2*frame().window().borderWidth(),
2122 m_frame.height() + 2*frame().window().borderWidth());
2119 last_move_x = dx; 2123 last_move_x = dx;
2120 last_move_y = dy; 2124 last_move_y = dy;
2121 } else { 2125 } else {
@@ -2138,7 +2142,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2138 // draw over old rect 2142 // draw over old rect
2139 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 2143 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2140 last_resize_x, last_resize_y, 2144 last_resize_x, last_resize_y,
2141 last_resize_w - 1, last_resize_h-1); 2145 last_resize_w - 1 + 2 * m_frame.window().borderWidth(),
2146 last_resize_h - 1 + 2 * m_frame.window().borderWidth());
2142 2147
2143 2148
2144 // move rectangle 2149 // move rectangle
@@ -2165,7 +2170,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2165 // draw resize rectangle 2170 // draw resize rectangle
2166 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 2171 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2167 last_resize_x, last_resize_y, 2172 last_resize_x, last_resize_y,
2168 last_resize_w - 1, last_resize_h - 1); 2173 last_resize_w - 1 + 2 * m_frame.window().borderWidth(),
2174 last_resize_h - 1 + 2 * m_frame.window().borderWidth());
2169 2175
2170 if (screen->doShowWindowPos()) 2176 if (screen->doShowWindowPos())
2171 screen->showGeometry(gx, gy); 2177 screen->showGeometry(gx, gy);
@@ -2304,7 +2310,8 @@ void FluxboxWindow::startMoving(Window win) {
2304 if (! screen->doOpaqueMove()) { 2310 if (! screen->doOpaqueMove()) {
2305 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 2311 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2306 frame().x(), frame().y(), 2312 frame().x(), frame().y(),
2307 frame().width(), frame().height()); 2313 frame().width() + 2*frame().window().borderWidth(),
2314 frame().height() + 2*frame().window().borderWidth());
2308 screen->showPosition(frame().x(), frame().y()); 2315 screen->showPosition(frame().x(), frame().y());
2309 } 2316 }
2310} 2317}
@@ -2319,7 +2326,8 @@ void FluxboxWindow::stopMoving() {
2319 if (! screen->doOpaqueMove()) { 2326 if (! screen->doOpaqueMove()) {
2320 XDrawRectangle(FbTk::App::instance()->display(), screen->getRootWindow(), screen->getOpGC(), 2327 XDrawRectangle(FbTk::App::instance()->display(), screen->getRootWindow(), screen->getOpGC(),
2321 last_move_x, last_move_y, 2328 last_move_x, last_move_y,
2322 frame().width(), frame().height()); 2329 frame().width() + 2*frame().window().borderWidth(),
2330 frame().height() + 2*frame().window().borderWidth());
2323 moveResize(last_move_x, last_move_y, m_frame.width(), m_frame.height()); 2331 moveResize(last_move_x, last_move_y, m_frame.width(), m_frame.height());
2324 } else 2332 } else
2325 moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height()); 2333 moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height());
@@ -2349,12 +2357,12 @@ void FluxboxWindow::startResizing(Window win, int x, int y, bool left) {
2349 CurrentTime); 2357 CurrentTime);
2350 2358
2351 int gx = 0, gy = 0; 2359 int gx = 0, gy = 0;
2352 button_grab_x = x - screen->getBorderWidth(); 2360 button_grab_x = x;
2353 button_grab_y = y - screen->getBorderWidth2x(); 2361 button_grab_y = y;
2354 last_resize_x = m_frame.x(); 2362 last_resize_x = m_frame.x();
2355 last_resize_y = m_frame.y(); 2363 last_resize_y = m_frame.y();
2356 last_resize_w = m_frame.width() + screen->getBorderWidth2x(); 2364 last_resize_w = m_frame.width();
2357 last_resize_h = m_frame.height() + screen->getBorderWidth2x(); 2365 last_resize_h = m_frame.height();
2358 2366
2359 if (left) 2367 if (left)
2360 left_fixsize(&gx, &gy); 2368 left_fixsize(&gx, &gy);
@@ -2366,7 +2374,8 @@ void FluxboxWindow::startResizing(Window win, int x, int y, bool left) {
2366 2374
2367 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 2375 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2368 last_resize_x, last_resize_y, 2376 last_resize_x, last_resize_y,
2369 last_resize_w - 1, last_resize_h - 1); 2377 last_resize_w - 1 + 2 * m_frame.window().borderWidth(),
2378 last_resize_h - 1 + 2 * m_frame.window().borderWidth());
2370} 2379}
2371 2380
2372void FluxboxWindow::stopResizing(Window win) { 2381void FluxboxWindow::stopResizing(Window win) {
@@ -2374,7 +2383,8 @@ void FluxboxWindow::stopResizing(Window win) {
2374 2383
2375 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), 2384 XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
2376 last_resize_x, last_resize_y, 2385 last_resize_x, last_resize_y,
2377 last_resize_w - 1, last_resize_h - 1); 2386 last_resize_w - 1 + 2 * m_frame.window().borderWidth(),
2387 last_resize_h - 1 + 2 * m_frame.window().borderWidth());
2378 2388
2379 screen->hideGeometry(); 2389 screen->hideGeometry();
2380 2390
@@ -2385,8 +2395,8 @@ void FluxboxWindow::stopResizing(Window win) {
2385 2395
2386 2396
2387 moveResize(last_resize_x, last_resize_y, 2397 moveResize(last_resize_x, last_resize_y,
2388 last_resize_w - screen->getBorderWidth2x(), 2398 last_resize_w;
2389 last_resize_h - screen->getBorderWidth2x()); 2399 last_resize_h;
2390 2400
2391 XUngrabPointer(display, CurrentTime); 2401 XUngrabPointer(display, CurrentTime);
2392} 2402}
@@ -2596,7 +2606,11 @@ void FluxboxWindow::left_fixsize(int *gx, int *gy) {
2596 int titlebar_height = (decorations.titlebar ? frame().titlebar().height() + frame().titlebar().borderWidth() : 0); 2606 int titlebar_height = (decorations.titlebar ? frame().titlebar().height() + frame().titlebar().borderWidth() : 0);
2597 int handle_height = (decorations.handle ? frame().handle().height() + frame().handle().borderWidth() : 0); 2607 int handle_height = (decorations.handle ? frame().handle().height() + frame().handle().borderWidth() : 0);
2598 int decoration_height = titlebar_height + handle_height; 2608 int decoration_height = titlebar_height + handle_height;
2609
2610 // dx is new width = current width + difference between new and old x values
2599 int dx = m_frame.width() + m_frame.x() - last_resize_x; 2611 int dx = m_frame.width() + m_frame.x() - last_resize_x;
2612
2613 // dy = new height (w/o decorations), similarly
2600 int dy = last_resize_h - client.base_height - decoration_height; 2614 int dy = last_resize_h - client.base_height - decoration_height;
2601 2615
2602 // check minimum size 2616 // check minimum size
@@ -2617,7 +2631,7 @@ void FluxboxWindow::left_fixsize(int *gx, int *gy) {
2617 if (client.height_inc == 0) 2631 if (client.height_inc == 0)
2618 client.height_inc = 1; 2632 client.height_inc = 1;
2619 2633
2620 // set snaping 2634 // set snapping
2621 dx /= client.width_inc; 2635 dx /= client.width_inc;
2622 dy /= client.height_inc; 2636 dy /= client.height_inc;
2623 2637