aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-07-24 03:19:02 (GMT)
committerrathnor <rathnor>2003-07-24 03:19:02 (GMT)
commitd4131b25bbf3b988f86b40deb2be940ba3db849d (patch)
tree6063d193760e5b75495d5845b548e95feda4d392 /src
parent75b98260377ca2e5a22d85d05595b40ae6f65638 (diff)
downloadfluxbox_paul-d4131b25bbf3b988f86b40deb2be940ba3db849d.zip
fluxbox_paul-d4131b25bbf3b988f86b40deb2be940ba3db849d.tar.bz2
fix some bugs + issues with maximisation.
it should be much safer now
Diffstat (limited to 'src')
-rw-r--r--src/FbCommandFactory.cc4
-rw-r--r--src/Window.cc177
-rw-r--r--src/Window.hh8
3 files changed, 122 insertions, 67 deletions
diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc
index 55455aa..59a01bd 100644
--- a/src/FbCommandFactory.cc
+++ b/src/FbCommandFactory.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: FbCommandFactory.cc,v 1.8 2003/07/02 05:14:48 fluxgen Exp $ 23// $Id: FbCommandFactory.cc,v 1.9 2003/07/24 03:19:02 rathnor Exp $
24 24
25#include "FbCommandFactory.hh" 25#include "FbCommandFactory.hh"
26 26
@@ -113,7 +113,7 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
113 else if (command == "minimizewindow" || command == "minimize" || command == "iconify") 113 else if (command == "minimizewindow" || command == "minimize" || command == "iconify")
114 return new CurrentWindowCmd(&FluxboxWindow::iconify); 114 return new CurrentWindowCmd(&FluxboxWindow::iconify);
115 else if (command == "maximizewindow" || command == "maximize") 115 else if (command == "maximizewindow" || command == "maximize")
116 return new CurrentWindowCmd(&FluxboxWindow::maximize); 116 return new CurrentWindowCmd(&FluxboxWindow::maximizeFull);
117 else if (command == "maximizevertical") 117 else if (command == "maximizevertical")
118 return new CurrentWindowCmd(&FluxboxWindow::maximizeVertical); 118 return new CurrentWindowCmd(&FluxboxWindow::maximizeVertical);
119 else if (command == "maximizehorizontal") 119 else if (command == "maximizehorizontal")
diff --git a/src/Window.cc b/src/Window.cc
index a84d710..0ba7a4a 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.209 2003/07/21 17:54:07 rathnor Exp $ 25// $Id: Window.cc,v 1.210 2003/07/24 03:19:02 rathnor Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -533,8 +533,11 @@ void FluxboxWindow::init() {
533 } 533 }
534 534
535 if (maximized && functions.maximize) { // start maximized 535 if (maximized && functions.maximize) { // start maximized
536 maximized = MAX_NONE; 536 // This will set it to the appropriate style of maximisation
537 maximize(); 537 int req_maximized = maximized;
538 // NOTE: don't manually change maximized ANYWHERE else, it isn't safe
539 maximized = MAX_NONE; // it is not maximized now
540 maximize(req_maximized);
538 } 541 }
539 542
540 if (stuck) { 543 if (stuck) {
@@ -1291,64 +1294,101 @@ void FluxboxWindow::withdraw() {
1291/** 1294/**
1292 Maximize window both horizontal and vertical 1295 Maximize window both horizontal and vertical
1293*/ 1296*/
1294void FluxboxWindow::maximize() { 1297void FluxboxWindow::maximize(int type) {
1295 if (isIconic()) 1298 if (isIconic())
1296 deiconify(); 1299 deiconify();
1297 1300
1298 if (!maximized) { 1301 int head = screen().getHead(frame().window());
1299 // save old values 1302 int new_x = frame().x(),
1300 int head = screen().getHead(frame().window()); 1303 new_y = frame().y(),
1301 m_old_width = frame().width(); 1304 new_w = frame().width(),
1302 m_old_height = frame().height(); 1305 new_h = frame().height();
1303 m_old_pos_x = frame().x(); 1306
1304 m_old_pos_y = frame().y(); 1307 int orig_max = maximized;
1305 unsigned int left_x = screen().maxLeft(head); 1308
1306 unsigned int max_width = screen().maxRight(head); 1309 // These evaluate whether we need to TOGGLE the value for that field
1307 unsigned int max_top = screen().maxTop(head); 1310 // Why? If maximize is only set to zero outside this,
1308 moveResize(left_x, max_top, 1311 // and we only EVER toggle them, then:
1309 max_width - left_x - 2*frame().window().borderWidth(), 1312 // 1) We will never loose the old_ values
1310 screen().maxBottom(head) - max_top - 2*frame().window().borderWidth()); 1313 // 2) It shouldn't get confused
1311 maximized = MAX_FULL; 1314
1312 } else { // demaximize, restore to old values 1315 // Worst case being that some action will toggle the wrong way, but
1313 moveResize(m_old_pos_x, m_old_pos_y, 1316 // we still won't lose the state in that case.
1314 m_old_width, m_old_height); 1317
1315 maximized = MAX_NONE; 1318 // NOTE: There is one option to the way this works - what it does when
1319 // fully maximised and maximise(vert, horz) is selected.
1320 // There are 2 options here - either:
1321 // 1) maximiseVertical results in a vertically (not horz) maximised window, or
1322 // 2) " toggles vertical maximisation, thus resulting in a horizontally
1323 // maximised window.
1324 //
1325 // The current implementation uses style 1, to change this, removed the
1326 // item corresponding to the [[ ]] comment
1327
1328 // toggle maximize vertically?
1329 // when _don't_ we want to toggle?
1330 // - type is horizontal maximise, [[and we aren't fully maximised]] or
1331 // - [[ type is vertical maximise and we are fully maximised ]]
1332 // - type is none and we are not vertically maximised, or
1333 // - type is full and we are not horizontally maximised, but already vertically
1334 if (!(type == MAX_HORZ && orig_max != MAX_FULL ||
1335 type == MAX_VERT && orig_max == MAX_FULL ||
1336 type == MAX_NONE && !(orig_max & MAX_VERT) ||
1337 type == MAX_FULL && orig_max == MAX_VERT)) {
1338 // already maximized in that direction?
1339 if (orig_max & MAX_VERT) {
1340 new_y = m_old_pos_y;
1341 new_h = m_old_height;
1342 } else {
1343 m_old_pos_y = new_y;
1344 m_old_height = new_h;
1345 new_y = screen().maxTop(head);
1346 new_h = screen().maxBottom(head) - new_y - 2*frame().window().borderWidth();
1347 }
1348 maximized ^= MAX_VERT;
1349 }
1350
1351 // maximize horizontally?
1352 if (!(type == MAX_VERT && orig_max != MAX_FULL ||
1353 type == MAX_HORZ && orig_max == MAX_FULL ||
1354 type == MAX_NONE && !(orig_max & MAX_HORZ) ||
1355 type == MAX_FULL && orig_max == MAX_HORZ)) {
1356 // already maximized in that direction?
1357 if (orig_max & MAX_HORZ) {
1358 new_x = m_old_pos_x;
1359 new_w = m_old_width;
1360 } else {
1361 // only save if we weren't already maximized
1362 m_old_pos_x = new_x;
1363 m_old_width = new_w;
1364 new_x = screen().maxLeft(head);
1365 new_w = screen().maxRight(head) - new_x - 2*frame().window().borderWidth();
1366 }
1367 maximized ^= MAX_HORZ;
1316 } 1368 }
1369
1370 moveResize(new_x, new_y, new_w, new_h);
1317 1371
1318} 1372}
1319/** 1373/**
1320 * Maximize window horizontal 1374 * Maximize window horizontal
1321 */ 1375 */
1322void FluxboxWindow::maximizeHorizontal() { 1376void FluxboxWindow::maximizeHorizontal() {
1323 if (! (maximized & MAX_HORZ) ) { 1377 maximize(MAX_HORZ);
1324 const int head = screen().getHead(frame().window());
1325 const unsigned int left_x = screen().maxLeft(head);
1326 const unsigned int max_width = screen().maxRight(head);
1327 m_old_width = frame().width();
1328 m_old_pos_x = frame().x();
1329 moveResize(left_x, frame().y(), max_width - left_x, frame().height());
1330 maximized |= MAX_HORZ;
1331 } else {
1332 moveResize(m_old_pos_x, frame().y(), m_old_width, frame().height());
1333 maximized &= ~MAX_HORZ;
1334 }
1335} 1378}
1336 1379
1337/** 1380/**
1338 * Maximize window vertical 1381 * Maximize window vertical
1339 */ 1382 */
1340void FluxboxWindow::maximizeVertical() { 1383void FluxboxWindow::maximizeVertical() {
1341 if (! (maximized & MAX_VERT) ) { 1384 maximize(MAX_VERT);
1342 const int head = screen().getHead(frame().window()); 1385}
1343 const unsigned int max_top = screen().maxTop(head); 1386
1344 m_old_height = frame().height(); 1387/**
1345 m_old_pos_y = frame().y(); 1388 * Maximize window fully
1346 moveResize(frame().x(), max_top, frame().width(), screen().maxBottom(head) - max_top); 1389 */
1347 maximized |= MAX_VERT; 1390void FluxboxWindow::maximizeFull() {
1348 } else { 1391 maximize(MAX_FULL);
1349 moveResize(frame().x(), m_old_pos_y, frame().width(), m_old_height);
1350 maximized &= ~MAX_VERT;
1351 }
1352} 1392}
1353 1393
1354 1394
@@ -1853,9 +1893,9 @@ void FluxboxWindow::restoreAttributes() {
1853 (m_blackbox_attrib.flags & ATTRIB_MAXVERT)) 1893 (m_blackbox_attrib.flags & ATTRIB_MAXVERT))
1854 maximized = MAX_FULL; 1894 maximized = MAX_FULL;
1855 else if (m_blackbox_attrib.flags & ATTRIB_MAXVERT) 1895 else if (m_blackbox_attrib.flags & ATTRIB_MAXVERT)
1856 maximizeVertical(); 1896 maximized = MAX_VERT;
1857 else if (m_blackbox_attrib.flags & ATTRIB_MAXHORIZ) 1897 else if (m_blackbox_attrib.flags & ATTRIB_MAXHORIZ)
1858 maximizeHorizontal(); 1898 maximized = MAX_HORZ;
1859 1899
1860 m_blackbox_attrib.premax_x = x; 1900 m_blackbox_attrib.premax_x = x;
1861 m_blackbox_attrib.premax_y = y; 1901 m_blackbox_attrib.premax_y = y;
@@ -3144,22 +3184,35 @@ void FluxboxWindow::changeBlackboxHints(const BlackboxHints &net) {
3144 (net.attrib & ATTRIB_SHADED))) 3184 (net.attrib & ATTRIB_SHADED)))
3145 shade(); 3185 shade();
3146 3186
3147 if ((net.flags & (ATTRIB_MAXVERT | ATTRIB_MAXHORIZ)) && 3187 if (net.flags & (ATTRIB_MAXVERT | ATTRIB_MAXHORIZ)) {
3148 ((m_blackbox_attrib.attrib & (ATTRIB_MAXVERT | ATTRIB_MAXHORIZ)) != 3188 // make maximise look like the net maximise flags
3149 (net.attrib & (ATTRIB_MAXVERT | ATTRIB_MAXHORIZ)))) { 3189 int want_max = MAX_NONE;
3150 if (maximized) { 3190
3151 maximize(); 3191 if (net.flags & ATTRIB_MAXVERT)
3152 } else { 3192 want_max |= MAX_VERT;
3153 if ((net.flags & ATTRIB_MAXHORIZ) && (net.flags & ATTRIB_MAXVERT)) 3193 if (net.flags & ATTRIB_MAXHORIZ)
3154 maximize(); 3194 want_max |= MAX_HORZ;
3155 else if (net.flags & ATTRIB_MAXVERT) 3195
3156 maximizeVertical(); 3196 if (want_max == MAX_NONE && maximized != MAX_NONE) {
3157 else if (net.flags & ATTRIB_MAXHORIZ) 3197 maximize(MAX_NONE);
3158 maximizeHorizontal(); 3198 } else if (want_max == MAX_FULL && maximized != MAX_FULL) {
3159 3199 maximize(MAX_FULL);
3200 // horz and vert are a little trickier to morph
3201 }
3202 // to toggle vert
3203 // either we want vert and aren't
3204 // or we want horizontal, and are vertically (or full) at present
3205 if (want_max == MAX_VERT && !(maximized & MAX_VERT) ||
3206 want_max == MAX_HORZ && (maximized & MAX_VERT)) {
3207 maximize(MAX_VERT);
3208 }
3209 // note that if we want horz, it WONT be vert any more from above
3210 if (want_max == MAX_HORZ && !(maximized & MAX_HORZ) ||
3211 want_max == MAX_VERT && (maximized & MAX_HORZ)) {
3212 maximize(MAX_HORZ);
3160 } 3213 }
3161 } 3214 }
3162 3215
3163 if ((net.flags & ATTRIB_OMNIPRESENT) && 3216 if ((net.flags & ATTRIB_OMNIPRESENT) &&
3164 ((m_blackbox_attrib.attrib & ATTRIB_OMNIPRESENT) != 3217 ((m_blackbox_attrib.attrib & ATTRIB_OMNIPRESENT) !=
3165 (net.attrib & ATTRIB_OMNIPRESENT))) 3218 (net.attrib & ATTRIB_OMNIPRESENT)))
@@ -3384,7 +3437,7 @@ void FluxboxWindow::setupWindow() {
3384 typedef SimpleCommand<FluxboxWindow> WindowCmd; 3437 typedef SimpleCommand<FluxboxWindow> WindowCmd;
3385 3438
3386 CommandRef iconify_cmd(new WindowCmd(*this, &FluxboxWindow::iconify)); 3439 CommandRef iconify_cmd(new WindowCmd(*this, &FluxboxWindow::iconify));
3387 CommandRef maximize_cmd(new WindowCmd(*this, &FluxboxWindow::maximize)); 3440 CommandRef maximize_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeFull));
3388 CommandRef maximize_vert_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeVertical)); 3441 CommandRef maximize_vert_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeVertical));
3389 CommandRef maximize_horiz_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeHorizontal)); 3442 CommandRef maximize_horiz_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeHorizontal));
3390 CommandRef close_cmd(new WindowCmd(*this, &FluxboxWindow::close)); 3443 CommandRef close_cmd(new WindowCmd(*this, &FluxboxWindow::close));
diff --git a/src/Window.hh b/src/Window.hh
index 4042be9..d6eb944 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -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.hh,v 1.85 2003/07/20 08:12:36 rathnor Exp $ 25// $Id: Window.hh,v 1.86 2003/07/24 03:19:02 rathnor Exp $
26 26
27#ifndef WINDOW_HH 27#ifndef WINDOW_HH
28#define WINDOW_HH 28#define WINDOW_HH
@@ -180,12 +180,14 @@ public:
180 void close(); 180 void close();
181 /// set the window in withdrawn state 181 /// set the window in withdrawn state
182 void withdraw(); 182 void withdraw();
183 /// toggel maximize 183 /// toggle maximize
184 void maximize(); 184 void maximize(int type = MAX_FULL);
185 /// maximizes the window horizontal 185 /// maximizes the window horizontal
186 void maximizeHorizontal(); 186 void maximizeHorizontal();
187 /// maximizes the window vertical 187 /// maximizes the window vertical
188 void maximizeVertical(); 188 void maximizeVertical();
189 /// maximizes the window fully
190 void maximizeFull();
189 /// toggles shade 191 /// toggles shade
190 void shade(); 192 void shade();
191 /// toggles sticky 193 /// toggles sticky