aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FbTk/FbWindow.cc53
-rw-r--r--src/FbTk/FbWindow.hh2
-rw-r--r--src/FbWinFrame.cc125
-rw-r--r--src/FbWinFrame.hh28
-rw-r--r--src/Window.cc73
-rw-r--r--src/Window.hh2
6 files changed, 137 insertions, 146 deletions
diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc
index 056e2f1..fb68eb9 100644
--- a/src/FbTk/FbWindow.cc
+++ b/src/FbTk/FbWindow.cc
@@ -43,21 +43,28 @@
43 43
44namespace FbTk { 44namespace FbTk {
45 45
46FbWindow::FbWindow():FbDrawable(), m_parent(0), m_screen_num(0), m_window(0), m_x(0), m_y(0), 46FbWindow::FbWindow():
47 m_width(0), m_height(0), m_border_width(0), m_depth(0), m_destroy(true), 47 FbDrawable(),
48 m_lastbg_color_set(false), m_lastbg_color(0), m_lastbg_pm(0), m_renderer(0) { 48 m_parent(0), m_screen_num(0), m_window(0),
49 m_x(0), m_y(0), m_width(0), m_height(0),
50 m_border_width(0), m_border_color(0),
51 m_depth(0), m_destroy(true),
52 m_lastbg_color_set(false), m_lastbg_color(0), m_lastbg_pm(0),
53 m_renderer(0) {
49 54
50} 55}
51 56
52FbWindow::FbWindow(const FbWindow& the_copy):FbDrawable(), 57FbWindow::FbWindow(const FbWindow& the_copy):
53 m_parent(the_copy.parent()), 58 FbDrawable(),
54 m_screen_num(the_copy.screenNumber()), m_window(the_copy.window()), 59 m_parent(the_copy.parent()),
55 m_x(the_copy.x()), m_y(the_copy.y()), 60 m_screen_num(the_copy.screenNumber()), m_window(the_copy.window()),
56 m_width(the_copy.width()), m_height(the_copy.height()), 61 m_x(the_copy.x()), m_y(the_copy.y()),
57 m_border_width(the_copy.borderWidth()), 62 m_width(the_copy.width()), m_height(the_copy.height()),
58 m_depth(the_copy.depth()), m_destroy(true), 63 m_border_width(the_copy.borderWidth()),
59 m_lastbg_color_set(false), m_lastbg_color(0), 64 m_border_color(the_copy.borderColor()),
60 m_lastbg_pm(0), m_renderer(the_copy.m_renderer) { 65 m_depth(the_copy.depth()), m_destroy(true),
66 m_lastbg_color_set(false), m_lastbg_color(0), m_lastbg_pm(0),
67 m_renderer(the_copy.m_renderer) {
61 the_copy.m_window = 0; 68 the_copy.m_window = 0;
62} 69}
63 70
@@ -100,17 +107,14 @@ FbWindow::FbWindow(const FbWindow &parent,
100 107
101}; 108};
102 109
103FbWindow::FbWindow(Window client):FbDrawable(), m_parent(0), 110FbWindow::FbWindow(Window client):
104 m_screen_num(0), 111 FbDrawable(),
105 m_window(0), 112 m_parent(0), m_screen_num(0), m_window(0),
106 m_x(0), m_y(0), 113 m_x(0), m_y(0), m_width(1), m_height(1),
107 m_width(1), m_height(1), 114 m_border_width(0), m_border_color(0),
108 m_border_width(0), 115 m_depth(0), m_destroy(false), // don't destroy this window
109 m_depth(0), 116 m_lastbg_color_set(false), m_lastbg_color(0), m_lastbg_pm(0),
110 m_destroy(false), // don't destroy this window 117 m_renderer(0) {
111 m_lastbg_color_set(false), m_lastbg_color(0),
112 m_lastbg_pm(0), m_renderer(0) {
113
114 setNew(client); 118 setNew(client);
115} 119}
116 120
@@ -235,6 +239,7 @@ void FbWindow::updateBackground(bool only_if_alpha) {
235 239
236void FbWindow::setBorderColor(const FbTk::Color &border_color) { 240void FbWindow::setBorderColor(const FbTk::Color &border_color) {
237 XSetWindowBorder(display(), m_window, border_color.pixel()); 241 XSetWindowBorder(display(), m_window, border_color.pixel());
242 m_border_color = border_color.pixel();
238} 243}
239 244
240void FbWindow::setBorderWidth(unsigned int size) { 245void FbWindow::setBorderWidth(unsigned int size) {
@@ -373,6 +378,7 @@ FbWindow &FbWindow::operator = (const FbWindow &win) {
373 m_width = win.width(); 378 m_width = win.width();
374 m_height = win.height(); 379 m_height = win.height();
375 m_border_width = win.borderWidth(); 380 m_border_width = win.borderWidth();
381 m_border_color = win.borderColor();
376 m_depth = win.depth(); 382 m_depth = win.depth();
377 // take over this window 383 // take over this window
378 win.m_window = 0; 384 win.m_window = 0;
@@ -601,6 +607,7 @@ void FbWindow::create(Window parent, int x, int y,
601 607
602 608
603 m_border_width = 0; 609 m_border_width = 0;
610 m_border_color = 0;
604 611
605 long valmask = CWEventMask; 612 long valmask = CWEventMask;
606 XSetWindowAttributes values; 613 XSetWindowAttributes values;
diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh
index e9f8e30..f212e50 100644
--- a/src/FbTk/FbWindow.hh
+++ b/src/FbTk/FbWindow.hh
@@ -177,6 +177,7 @@ public:
177 unsigned int width() const { return m_width; } 177 unsigned int width() const { return m_width; }
178 unsigned int height() const { return m_height; } 178 unsigned int height() const { return m_height; }
179 unsigned int borderWidth() const { return m_border_width; } 179 unsigned int borderWidth() const { return m_border_width; }
180 unsigned long borderColor() const { return m_border_color; }
180 unsigned int depth() const { return m_depth; } 181 unsigned int depth() const { return m_depth; }
181 unsigned char alpha() const; 182 unsigned char alpha() const;
182 int screenNumber() const; 183 int screenNumber() const;
@@ -225,6 +226,7 @@ private:
225 int m_x, m_y; ///< position of window 226 int m_x, m_y; ///< position of window
226 unsigned int m_width, m_height; ///< size of window 227 unsigned int m_width, m_height; ///< size of window
227 unsigned int m_border_width; ///< border size 228 unsigned int m_border_width; ///< border size
229 unsigned long m_border_color; ///< border color
228 unsigned int m_depth; ///< bit depth 230 unsigned int m_depth; ///< bit depth
229 bool m_destroy; ///< wheter the x window was created before 231 bool m_destroy; ///< wheter the x window was created before
230 std::auto_ptr<FbTk::Transparent> m_transparent; 232 std::auto_ptr<FbTk::Transparent> m_transparent;
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index a806888..a31c327 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -487,12 +487,7 @@ void FbWinFrame::setFocus(bool newvalue) {
487 } 487 }
488 } 488 }
489 489
490 if (m_decoration_mask & DECORM_BORDER && 490 setBorderWidth();
491 (theme().focusedTheme()->border().width() !=
492 theme().unfocusedTheme()->border().width() ||
493 theme().focusedTheme()->border().color().pixel() !=
494 theme().unfocusedTheme()->border().color().pixel()))
495 setBorderWidth(theme()->border().width());
496 491
497 applyAll(); 492 applyAll();
498 clearAll(); 493 clearAll();
@@ -759,28 +754,6 @@ bool FbWinFrame::showHandle() {
759 return true; 754 return true;
760} 755}
761 756
762bool FbWinFrame::hideAllDecorations() {
763 bool changed = false;
764 changed |= hideHandle();
765 changed |= hideTitlebar();
766 // resize done by hide*
767 reconfigure();
768
769 return changed;
770}
771
772bool FbWinFrame::showAllDecorations() {
773 bool changed = false;
774 if (!m_use_handle)
775 changed |= showHandle();
776 if (!m_use_titlebar)
777 changed |= showTitlebar();
778 // resize shouldn't be necessary
779 reconfigure();
780
781 return changed;
782}
783
784/** 757/**
785 Set new event handler for the frame's windows 758 Set new event handler for the frame's windows
786*/ 759*/
@@ -871,8 +844,7 @@ void FbWinFrame::reconfigure() {
871 gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false); 844 gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false);
872 845
873 m_bevel = theme()->bevelWidth(); 846 m_bevel = theme()->bevelWidth();
874 setBorderWidth(m_decoration_mask & DECORM_BORDER ? 847 setBorderWidth();
875 theme()->border().width() : 0);
876 848
877 if (m_decoration_mask & DECORM_HANDLE && theme()->handleWidth() != 0) 849 if (m_decoration_mask & DECORM_HANDLE && theme()->handleWidth() != 0)
878 showHandle(); 850 showHandle();
@@ -1439,14 +1411,78 @@ void FbWinFrame::applyTabContainer() {
1439 } 1411 }
1440} 1412}
1441 1413
1442void FbWinFrame::setBorderWidth(unsigned int border_width) { 1414void FbWinFrame::applyDecorations() {
1443 int bw_changes = 0;
1444
1445 int grav_x=0, grav_y=0; 1415 int grav_x=0, grav_y=0;
1446 // negate gravity 1416 // negate gravity
1447 gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false); 1417 gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw,
1418 false);
1419
1420 bool client_move = setBorderWidth(false);
1421
1422 // tab deocration only affects if we're external
1423 // must do before the setTabMode in case it goes
1424 // to external and is meant to be hidden
1425 if (m_decoration_mask & DECORM_TAB)
1426 client_move |= showTabs();
1427 else
1428 client_move |= hideTabs();
1429
1430 // we rely on frame not doing anything if it is already shown/hidden
1431 if (m_decoration_mask & DECORM_TITLEBAR) {
1432 client_move |= showTitlebar();
1433 if (m_screen.getDefaultInternalTabs())
1434 client_move |= setTabMode(INTERNAL);
1435 else
1436 client_move |= setTabMode(EXTERNAL);
1437 } else {
1438 client_move |= hideTitlebar();
1439 if (m_decoration_mask & DECORM_TAB)
1440 client_move |= setTabMode(EXTERNAL);
1441 }
1442
1443 if (m_decoration_mask & DECORM_HANDLE)
1444 client_move |= showHandle();
1445 else
1446 client_move |= hideHandle();
1448 1447
1448 // apply gravity once more
1449 gravityTranslate(grav_x, grav_y, m_active_gravity, m_active_orig_client_bw,
1450 false);
1449 1451
1452 // if the location changes, shift it
1453 if (grav_x != 0 || grav_y != 0) {
1454 move(grav_x + x(), grav_y + y());
1455 client_move = true;
1456 }
1457
1458 reconfigure();
1459 if (client_move)
1460 frameExtentSig().notify();
1461}
1462
1463bool FbWinFrame::setBorderWidth(bool do_move) {
1464 unsigned int border_width = m_decoration_mask & DECORM_BORDER ?
1465 theme()->border().width() : 0;
1466
1467 if (border_width &&
1468 theme()->border().color().pixel() != window().borderColor()) {
1469 window().setBorderColor(theme()->border().color());
1470 titlebar().setBorderColor(theme()->border().color());
1471 handle().setBorderColor(theme()->border().color());
1472 gripLeft().setBorderColor(theme()->border().color());
1473 gripRight().setBorderColor(theme()->border().color());
1474 }
1475
1476 if (border_width == window().borderWidth())
1477 return false;
1478
1479 int grav_x=0, grav_y=0;
1480 // negate gravity
1481 if (do_move)
1482 gravityTranslate(grav_x, grav_y, -m_active_gravity,
1483 m_active_orig_client_bw, false);
1484
1485 int bw_changes = 0;
1450 // we need to change the size of the window 1486 // we need to change the size of the window
1451 // if the border width changes... 1487 // if the border width changes...
1452 if (m_use_titlebar) 1488 if (m_use_titlebar)
@@ -1455,21 +1491,13 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) {
1455 bw_changes += static_cast<signed>(border_width - handle().borderWidth()); 1491 bw_changes += static_cast<signed>(border_width - handle().borderWidth());
1456 1492
1457 window().setBorderWidth(border_width); 1493 window().setBorderWidth(border_width);
1458 window().setBorderColor(theme()->border().color());
1459 1494
1460 setTabMode(NOTSET); 1495 setTabMode(NOTSET);
1461 1496
1462 titlebar().setBorderWidth(border_width); 1497 titlebar().setBorderWidth(border_width);
1463 titlebar().setBorderColor(theme()->border().color());
1464
1465 handle().setBorderWidth(border_width); 1498 handle().setBorderWidth(border_width);
1466 handle().setBorderColor(theme()->border().color());
1467
1468 gripLeft().setBorderWidth(border_width); 1499 gripLeft().setBorderWidth(border_width);
1469 gripLeft().setBorderColor(theme()->border().color());
1470
1471 gripRight().setBorderWidth(border_width); 1500 gripRight().setBorderWidth(border_width);
1472 gripRight().setBorderColor(theme()->border().color());
1473 1501
1474 if (bw_changes != 0) 1502 if (bw_changes != 0)
1475 resize(width(), height() + bw_changes); 1503 resize(width(), height() + bw_changes);
@@ -1477,11 +1505,16 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) {
1477 if (m_tabmode == EXTERNAL) 1505 if (m_tabmode == EXTERNAL)
1478 alignTabs(); 1506 alignTabs();
1479 1507
1480 gravityTranslate(grav_x, grav_y, m_active_gravity, m_active_orig_client_bw, false); 1508 if (do_move) {
1481 // if the location changes, shift it 1509 frameExtentSig().notify();
1482 if (grav_x != 0 || grav_y != 0) 1510 gravityTranslate(grav_x, grav_y, m_active_gravity,
1483 move(grav_x + x(), grav_y + y()); 1511 m_active_orig_client_bw, false);
1512 // if the location changes, shift it
1513 if (grav_x != 0 || grav_y != 0)
1514 move(grav_x + x(), grav_y + y());
1515 }
1484 1516
1517 return true;
1485} 1518}
1486 1519
1487// this function translates its arguments according to win_gravity 1520// this function translates its arguments according to win_gravity
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh
index 643fc49..f288253 100644
--- a/src/FbWinFrame.hh
+++ b/src/FbWinFrame.hh
@@ -25,7 +25,7 @@
25#include "FbTk/FbWindow.hh" 25#include "FbTk/FbWindow.hh"
26#include "FbTk/EventHandler.hh" 26#include "FbTk/EventHandler.hh"
27#include "FbTk/RefCount.hh" 27#include "FbTk/RefCount.hh"
28#include "FbTk/Observer.hh" 28#include "FbTk/Subject.hh"
29#include "FbTk/Color.hh" 29#include "FbTk/Color.hh"
30#include "FbTk/XLayerItem.hh" 30#include "FbTk/XLayerItem.hh"
31#include "FbTk/TextButton.hh" 31#include "FbTk/TextButton.hh"
@@ -186,21 +186,12 @@ public:
186 void removeEventHandler(); 186 void removeEventHandler();
187 187
188 void setDecorationMask(unsigned int mask) { m_decoration_mask = mask; } 188 void setDecorationMask(unsigned int mask) { m_decoration_mask = mask; }
189 // these return true/false for if something changed 189 void applyDecorations();
190 bool hideTitlebar();
191 bool showTitlebar();
192 bool hideTabs();
193 bool showTabs();
194 bool hideHandle();
195 bool showHandle();
196 bool hideAllDecorations();
197 bool showAllDecorations();
198 190
199 // this function translates its arguments according to win_gravity 191 // this function translates its arguments according to win_gravity
200 // if win_gravity is negative, it does an inverse translation 192 // if win_gravity is negative, it does an inverse translation
201 void gravityTranslate(int &x, int &y, int win_gravity, unsigned int client_bw, bool move_frame = false); 193 void gravityTranslate(int &x, int &y, int win_gravity, unsigned int client_bw, bool move_frame = false);
202 void setActiveGravity(int gravity, unsigned int orig_client_bw) { m_active_gravity = gravity; m_active_orig_client_bw = orig_client_bw; } 194 void setActiveGravity(int gravity, unsigned int orig_client_bw) { m_active_gravity = gravity; m_active_orig_client_bw = orig_client_bw; }
203 void setBorderWidth(unsigned int borderW);
204 195
205 /** 196 /**
206 @name Event handlers 197 @name Event handlers
@@ -266,6 +257,9 @@ public:
266 const FbTk::XLayerItem &layerItem() const { return m_layeritem; } 257 const FbTk::XLayerItem &layerItem() const { return m_layeritem; }
267 FbTk::XLayerItem &layerItem() { return m_layeritem; } 258 FbTk::XLayerItem &layerItem() { return m_layeritem; }
268 259
260 const FbTk::Subject &frameExtentSig() const { return m_frame_extent_sig; }
261 FbTk::Subject &frameExtentSig() { return m_frame_extent_sig; }
262
269 //@} 263 //@}
270 264
271private: 265private:
@@ -290,6 +284,15 @@ private:
290 284
291 //@} 285 //@}
292 286
287 // these return true/false for if something changed
288 bool hideTitlebar();
289 bool showTitlebar();
290 bool hideTabs();
291 bool showTabs();
292 bool hideHandle();
293 bool showHandle();
294 bool setBorderWidth(bool do_move = true);
295
293 /** 296 /**
294 @name apply pixmaps depending on focus 297 @name apply pixmaps depending on focus
295 */ 298 */
@@ -332,6 +335,9 @@ private:
332 m_grip_left; ///< left grip 335 m_grip_left; ///< left grip
333 FbTk::FbWindow m_clientarea; ///< window that sits behind client window to fill gaps @see setClientWindow 336 FbTk::FbWindow m_clientarea; ///< window that sits behind client window to fill gaps @see setClientWindow
334 //@} 337 //@}
338
339 FbTk::Subject m_frame_extent_sig;
340
335 typedef std::vector<FbTk::Button *> ButtonList; 341 typedef std::vector<FbTk::Button *> ButtonList;
336 ButtonList m_buttons_left, ///< buttons to the left 342 ButtonList m_buttons_left, ///< buttons to the left
337 m_buttons_right; ///< buttons to the right 343 m_buttons_right; ///< buttons to the right
diff --git a/src/Window.cc b/src/Window.cc
index 8ad1762..29acd3b 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -303,6 +303,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer):
303 m_resize_corner(RIGHTBOTTOM) { 303 m_resize_corner(RIGHTBOTTOM) {
304 304
305 m_theme.reconfigSig().attach(this); 305 m_theme.reconfigSig().attach(this);
306 m_frame.frameExtentSig().attach(this);
306 307
307 init(); 308 init();
308 309
@@ -501,7 +502,7 @@ void FluxboxWindow::init() {
501 setOnHead(screen().getCurrHead()); 502 setOnHead(screen().getCurrHead());
502 503
503 // we must do this now, or else resizing may not work properly 504 // we must do this now, or else resizing may not work properly
504 applyDecorations(true); 505 applyDecorations();
505 506
506 Fluxbox::instance()->attachSignals(*this); 507 Fluxbox::instance()->attachSignals(*this);
507 508
@@ -601,7 +602,7 @@ void FluxboxWindow::init() {
601 gettimeofday(&now, NULL); 602 gettimeofday(&now, NULL);
602 m_creation_time = now.tv_sec; 603 m_creation_time = now.tv_sec;
603 604
604 sendConfigureNotify(); 605 frame().frameExtentSig().notify();
605 606
606 setupWindow(); 607 setupWindow();
607 608
@@ -3015,74 +3016,16 @@ void FluxboxWindow::update(FbTk::Subject *subj) {
3015 } else if (subj == &m_theme.reconfigSig()) { 3016 } else if (subj == &m_theme.reconfigSig()) {
3016 frame().reconfigure(); 3017 frame().reconfigure();
3017 reconfigTheme(); 3018 reconfigTheme();
3019 } else if (m_initialized && subj == &m_frame.frameExtentSig()) {
3020 Fluxbox::instance()->updateFrameExtents(*this);
3021 sendConfigureNotify();
3018 } 3022 }
3019} 3023}
3020 3024
3021// commit current decoration values to actual displayed things 3025// commit current decoration values to actual displayed things
3022void FluxboxWindow::applyDecorations(bool initial) { 3026void FluxboxWindow::applyDecorations() {
3023 frame().clientArea().setBorderWidth(0); // client area bordered by other things
3024
3025 unsigned int border_width = 0;
3026 if (decorations.border)
3027 border_width = frame().theme()->border().width();
3028
3029 bool client_move = false;
3030
3031 // borderWidth setting handles its own gravity
3032 if (initial || frame().window().borderWidth() != border_width) {
3033 client_move = true;
3034 frame().setBorderWidth(border_width);
3035 }
3036
3037 int grav_x=0, grav_y=0;
3038 // negate gravity
3039 frame().gravityTranslate(grav_x, grav_y, -m_client->gravity(), m_client->old_bw, false);
3040
3041 // tab deocration only affects if we're external
3042 // must do before the setTabMode in case it goes
3043 // to external and is meant to be hidden
3044 if (decorations.tab)
3045 client_move |= frame().showTabs();
3046 else
3047 client_move |= frame().hideTabs();
3048
3049 // we rely on frame not doing anything if it is already shown/hidden
3050 if (decorations.titlebar) {
3051 bool change = frame().showTitlebar();
3052 client_move |= change;
3053 if (screen().getDefaultInternalTabs()) {
3054 client_move |= frame().setTabMode(FbWinFrame::INTERNAL);
3055 } else {
3056 client_move |= frame().setTabMode(FbWinFrame::EXTERNAL);
3057 }
3058 } else {
3059 client_move |= frame().hideTitlebar();
3060 if (decorations.tab)
3061 client_move |= frame().setTabMode(FbWinFrame::EXTERNAL);
3062 }
3063
3064 if (decorations.handle) {
3065 client_move |= frame().showHandle();
3066 } else
3067 client_move |= frame().hideHandle();
3068
3069 // apply gravity once more
3070 frame().gravityTranslate(grav_x, grav_y, m_client->gravity(), m_client->old_bw, false);
3071
3072 // if the location changes, shift it
3073 if (grav_x != 0 || grav_y != 0) {
3074 move(grav_x + frame().x(), grav_y + frame().y());
3075 client_move = true;
3076 }
3077
3078 frame().setDecorationMask(decorationMask()); 3027 frame().setDecorationMask(decorationMask());
3079 frame().reconfigure(); 3028 frame().applyDecorations();
3080 if (client_move)
3081 Fluxbox::instance()->updateFrameExtents(*this);
3082
3083 if (!initial && client_move)
3084 sendConfigureNotify();
3085
3086} 3029}
3087 3030
3088void FluxboxWindow::toggleDecoration() { 3031void FluxboxWindow::toggleDecoration() {
diff --git a/src/Window.hh b/src/Window.hh
index c05f525..3da2fb1 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -357,7 +357,7 @@ public:
357 /// handle Subject notifications 357 /// handle Subject notifications
358 void update(FbTk::Subject *subj); 358 void update(FbTk::Subject *subj);
359 359
360 void applyDecorations(bool initial = false); 360 void applyDecorations();
361 void toggleDecoration(); 361 void toggleDecoration();
362 362
363 unsigned int decorationMask() const; 363 unsigned int decorationMask() const;