aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-08-22 17:16:33 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-08-22 17:16:33 (GMT)
commitc37a91e1504fa73da233cc59fe67ead56dbd3083 (patch)
tree4e233628bd7f8531aeaaf221be816f310dbd4a95
parentfeac120f4a433d4fee947ff9cc23e170d6af95c0 (diff)
downloadfluxbox_paul-c37a91e1504fa73da233cc59fe67ead56dbd3083.zip
fluxbox_paul-c37a91e1504fa73da233cc59fe67ead56dbd3083.tar.bz2
be a little smarter about size hints in tabbed windows
-rw-r--r--src/FbWinFrame.cc6
-rw-r--r--src/FbWinFrame.hh4
-rw-r--r--src/Window.cc69
-rw-r--r--src/Window.hh2
4 files changed, 51 insertions, 30 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index f6f591e..bac06d2 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -1860,8 +1860,10 @@ void FbWinFrame::SizeHints::reset(const XSizeHints &sizehint) {
1860 min_aspect_y = sizehint.min_aspect.y; 1860 min_aspect_y = sizehint.min_aspect.y;
1861 max_aspect_x = sizehint.max_aspect.x; 1861 max_aspect_x = sizehint.max_aspect.x;
1862 max_aspect_y = sizehint.max_aspect.y; 1862 max_aspect_y = sizehint.max_aspect.y;
1863 } else 1863 } else {
1864 min_aspect_x = min_aspect_y = max_aspect_x = max_aspect_y = 0; 1864 min_aspect_x = max_aspect_y = 0;
1865 min_aspect_y = max_aspect_x = 1;
1866 }
1865 1867
1866 if (sizehint.flags & PWinGravity) 1868 if (sizehint.flags & PWinGravity)
1867 win_gravity = sizehint.win_gravity; 1869 win_gravity = sizehint.win_gravity;
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh
index d2f7a1f..7f08175 100644
--- a/src/FbWinFrame.hh
+++ b/src/FbWinFrame.hh
@@ -112,8 +112,8 @@ public:
112 SizeHints(): 112 SizeHints():
113 min_width(1), max_width(0), min_height(1), max_height(0), 113 min_width(1), max_width(0), min_height(1), max_height(0),
114 width_inc(1), height_inc(1), base_width(0), base_height(0), 114 width_inc(1), height_inc(1), base_width(0), base_height(0),
115 min_aspect_x(0), max_aspect_x(0), 115 min_aspect_x(0), max_aspect_x(1),
116 min_aspect_y(0), max_aspect_y(0), 116 min_aspect_y(1), max_aspect_y(0),
117 win_gravity(0) { } 117 win_gravity(0) { }
118 118
119 void reset(const XSizeHints &sizehint); 119 void reset(const XSizeHints &sizehint);
diff --git a/src/Window.cc b/src/Window.cc
index 7dc268f..52672c0 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -1016,7 +1016,6 @@ bool FluxboxWindow::setCurrentClient(WinClient &client, bool setinput) {
1016 // frame focused doesn't necessarily mean input focused 1016 // frame focused doesn't necessarily mean input focused
1017 frame().setLabelButtonFocus(*button); 1017 frame().setLabelButtonFocus(*button);
1018 frame().setShapingClient(&client, false); 1018 frame().setShapingClient(&client, false);
1019 frame().setSizeHints(client.sizeHints());
1020 return ret; 1019 return ret;
1021} 1020}
1022 1021
@@ -1033,10 +1032,50 @@ void FluxboxWindow::associateClientWindow() {
1033 m_client->width(), m_client->height(), 1032 m_client->width(), m_client->height(),
1034 m_client->gravity(), m_client->old_bw); 1033 m_client->gravity(), m_client->old_bw);
1035 1034
1036 frame().setSizeHints(m_client->sizeHints()); 1035 updateSizeHints();
1037 frame().setClientWindow(*m_client); 1036 frame().setClientWindow(*m_client);
1038} 1037}
1039 1038
1039void FluxboxWindow::updateSizeHints() {
1040 m_size_hint = m_client->sizeHints();
1041
1042 ClientList::const_iterator it = clientList().begin();
1043 ClientList::const_iterator it_end = clientList().end();
1044 for (; it != it_end; ++it) {
1045 if ((*it) == m_client)
1046 continue;
1047
1048 const FbWinFrame::SizeHints &hint = (*it)->sizeHints();
1049 if (m_size_hint.min_width < hint.min_width)
1050 m_size_hint.min_width = hint.min_width;
1051 if (m_size_hint.max_width > hint.max_width)
1052 m_size_hint.max_width = hint.max_width;
1053 if (m_size_hint.min_height < hint.min_height)
1054 m_size_hint.min_height = hint.min_height;
1055 if (m_size_hint.max_height > hint.max_height)
1056 m_size_hint.max_height = hint.max_height;
1057 // lcm could end up a bit silly, and the situation is bad no matter what
1058 if (m_size_hint.width_inc < hint.width_inc)
1059 m_size_hint.width_inc = hint.width_inc;
1060 if (m_size_hint.height_inc < hint.height_inc)
1061 m_size_hint.height_inc = hint.height_inc;
1062 if (m_size_hint.base_width < hint.base_width)
1063 m_size_hint.base_width = hint.base_width;
1064 if (m_size_hint.base_height < hint.base_height)
1065 m_size_hint.base_height = hint.base_height;
1066 if (m_size_hint.min_aspect_x * hint.min_aspect_y >
1067 m_size_hint.min_aspect_y * hint.min_aspect_x) {
1068 m_size_hint.min_aspect_x = hint.min_aspect_x;
1069 m_size_hint.min_aspect_y = hint.min_aspect_y;
1070 }
1071 if (m_size_hint.max_aspect_x * hint.max_aspect_y >
1072 m_size_hint.max_aspect_y * hint.max_aspect_x) {
1073 m_size_hint.max_aspect_x = hint.max_aspect_x;
1074 m_size_hint.max_aspect_y = hint.max_aspect_y;
1075 }
1076 }
1077 frame().setSizeHints(m_size_hint);
1078}
1040 1079
1041void FluxboxWindow::grabButtons() { 1080void FluxboxWindow::grabButtons() {
1042 1081
@@ -1208,32 +1247,10 @@ void FluxboxWindow::moveResizeForClient(int new_x, int new_y,
1208} 1247}
1209 1248
1210void FluxboxWindow::getMaxSize(unsigned int* width, unsigned int* height) const { 1249void FluxboxWindow::getMaxSize(unsigned int* width, unsigned int* height) const {
1211
1212 if (!width || !height)
1213 return;
1214
1215 ClientList::const_iterator it = clientList().begin();
1216 ClientList::const_iterator it_end = clientList().end();
1217
1218 unsigned int w;
1219 unsigned int h;
1220
1221 w = h = 0; // unlimited
1222
1223 for (; it != it_end; ++it) {
1224 // special case for max height/width == 0
1225 // 0 indicates unlimited size, so we skip them
1226 if (!h || ((*it)->maxHeight() && h > (*it)->maxHeight()))
1227 h = (*it)->maxHeight();
1228 if (!w || ((*it)->maxWidth() && w > (*it)->maxWidth()))
1229 w = (*it)->maxWidth();
1230 }
1231
1232 if (width) 1250 if (width)
1233 *width = w; 1251 *width = m_size_hint.max_width;
1234
1235 if (height) 1252 if (height)
1236 *height = h; 1253 *height = m_size_hint.max_height;
1237} 1254}
1238 1255
1239// returns whether the focus was "set" to this window 1256// returns whether the focus was "set" to this window
diff --git a/src/Window.hh b/src/Window.hh
index 16d5bc9..89cbc69 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -491,6 +491,7 @@ private:
491 491
492 bool getState(); 492 bool getState();
493 void updateMWMHintsFromClient(WinClient &client); 493 void updateMWMHintsFromClient(WinClient &client);
494 void updateSizeHints();
494 void associateClientWindow(); 495 void associateClientWindow();
495 496
496 void setState(unsigned long stateval, bool setting_up); 497 void setState(unsigned long stateval, bool setting_up);
@@ -552,6 +553,7 @@ private:
552 typedef std::map<WinClient *, IconButton *> Client2ButtonMap; 553 typedef std::map<WinClient *, IconButton *> Client2ButtonMap;
553 Client2ButtonMap m_labelbuttons; 554 Client2ButtonMap m_labelbuttons;
554 555
556 FbWinFrame::SizeHints m_size_hint;
555 struct _decorations { 557 struct _decorations {
556 bool titlebar, handle, border, iconify, 558 bool titlebar, handle, border, iconify,
557 maximize, close, menu, sticky, shade, tab, enabled; 559 maximize, close, menu, sticky, shade, tab, enabled;